@parcha/agentrun-serve 0.1.0-beta.38 → 0.1.0-beta.39
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.
- package/CHANGELOG.md +418 -0
- package/README.md +325 -124
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +0 -2
- package/dist/agents-store.d.ts +5 -5
- package/dist/agents-store.js +14 -14
- package/dist/bash-read-only.js +2 -1
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -10
- package/dist/cap.js +2 -5
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +1 -5
- package/dist/chatgpt-plan.d.ts +163 -0
- package/dist/chatgpt-plan.js +549 -0
- package/dist/cli.js +26 -6
- package/dist/composio-preset.d.ts +8 -0
- package/dist/composio-preset.js +8 -7
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.js +2 -2
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +7 -2
- package/dist/computer-live.js +9 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +3 -3
- package/dist/computer-setting.js +5 -5
- package/dist/computer-view.d.ts +15 -0
- package/dist/computer-view.js +16 -2
- package/dist/computer-viewer.js +14 -1
- package/dist/computers.d.ts +5 -2
- package/dist/computers.js +9 -5
- package/dist/console/assets/index-BNhZs-jp.css +1 -0
- package/dist/console/assets/index-BQv5aOGB.js +700 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.js +3 -3
- package/dist/decision-cap.d.ts +2 -5
- package/dist/decision-cap.js +3 -6
- package/dist/decision-rows.js +11 -11
- package/dist/email/account.d.ts +84 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +10 -0
- package/dist/email/answer.js +182 -0
- package/dist/email/email-faux.d.ts +95 -0
- package/dist/email/email-faux.js +849 -0
- package/dist/email/labels.d.ts +1 -0
- package/dist/email/labels.js +84 -0
- package/dist/email/mail.d.ts +186 -0
- package/dist/email/mail.js +380 -0
- package/dist/email/names.d.ts +20 -0
- package/dist/email/names.js +40 -0
- package/dist/email/routes.d.ts +9 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +20 -0
- package/dist/email/tools.js +517 -0
- package/dist/environment.d.ts +17 -2
- package/dist/environment.js +36 -8
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +12 -0
- package/dist/eval-mailbox.d.ts +103 -0
- package/dist/eval-mailbox.js +236 -0
- package/dist/graph-view.d.ts +9 -2
- package/dist/graph-view.js +6 -2
- package/dist/harness-install.d.ts +28 -2
- package/dist/harness-install.js +147 -59
- package/dist/harness-opencode/adapter.js +2 -26
- package/dist/harness-opencode/facts.js +5 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -0
- package/dist/harness-opencode/host/policy.js +10 -5
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/versions.d.ts +6 -0
- package/dist/harness-opencode/versions.js +6 -0
- package/dist/harness-table.js +8 -5
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/hosted-search.d.ts +3 -1
- package/dist/hosted-search.js +51 -11
- package/dist/import-sources.d.ts +1 -1
- package/dist/import-sources.js +3 -3
- package/dist/import.d.ts +21 -0
- package/dist/import.js +186 -1
- package/dist/key-check.d.ts +0 -2
- package/dist/key-check.js +3 -4
- package/dist/key-refusal.d.ts +8 -2
- package/dist/key-refusal.js +16 -13
- package/dist/learn/check.d.ts +18 -3
- package/dist/learn/check.js +328 -3
- package/dist/learn/compile.d.ts +9 -2
- package/dist/learn/compile.js +52 -16
- package/dist/learn/grade.d.ts +4 -0
- package/dist/learn/grade.js +4 -1
- package/dist/learn/promote.d.ts +106 -51
- package/dist/learn/promote.js +82 -189
- package/dist/learn/refit.d.ts +21 -12
- package/dist/learn/refit.js +51 -23
- package/dist/learn/replay-calls.js +1 -1
- package/dist/learn/skills.d.ts +2 -7
- package/dist/learn/skills.js +28 -14
- package/dist/learned-nodes.d.ts +15 -7
- package/dist/learned-nodes.js +29 -5
- package/dist/learned-workflow.d.ts +41 -31
- package/dist/learned-workflow.js +122 -63
- package/dist/learning-batch.js +3 -3
- package/dist/learning-cost.d.ts +26 -8
- package/dist/learning-cost.js +17 -7
- package/dist/learning-routes.d.ts +2 -4
- package/dist/learning-routes.js +20 -3
- package/dist/learning-words.d.ts +1 -1
- package/dist/learning-words.js +4 -1
- package/dist/learning.d.ts +5 -5
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-pin-first.js +6 -0
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +25 -16
- package/dist/mcp-servers-store.js +23 -3
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +26 -6
- package/dist/model.js +126 -18
- package/dist/monid.d.ts +26 -31
- package/dist/monid.js +84 -79
- package/dist/native/binding.d.ts +13 -0
- package/dist/native/binding.js +57 -0
- package/dist/native/cli.d.ts +2 -0
- package/dist/native/cli.js +48 -0
- package/dist/native/connection.d.ts +8 -0
- package/dist/native/connection.js +94 -0
- package/dist/native/context.d.ts +6 -0
- package/dist/native/context.js +22 -0
- package/dist/native/discovery.d.ts +27 -0
- package/dist/native/discovery.js +404 -0
- package/dist/native/environment.d.ts +4 -0
- package/dist/native/environment.js +18 -0
- package/dist/native/history.d.ts +20 -0
- package/dist/native/history.js +147 -0
- package/dist/native/instructions.d.ts +21 -0
- package/dist/native/instructions.js +173 -0
- package/dist/native/remote-worker-bridge.d.ts +3 -0
- package/dist/native/remote-worker-bridge.js +278 -0
- package/dist/native/remote.d.ts +187 -0
- package/dist/native/remote.js +492 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.js +316 -0
- package/dist/native/runtimes.d.ts +66 -0
- package/dist/native/runtimes.js +41 -0
- package/dist/native/schema.d.ts +46 -0
- package/dist/native/schema.js +41 -0
- package/dist/native/types.d.ts +87 -0
- package/dist/native/types.js +1 -0
- package/dist/observation/http.d.ts +4 -0
- package/dist/observation/http.js +140 -0
- package/dist/observation/observer.d.ts +301 -0
- package/dist/observation/observer.js +919 -0
- package/dist/observation/schema.d.ts +52 -0
- package/dist/observation/schema.js +154 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +394 -85
- package/dist/paid-calls.d.ts +8 -3
- package/dist/paid-calls.js +6 -2
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +7 -2
- package/dist/port-models.js +5 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +1 -2
- package/dist/propose.js +10 -1
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +8 -0
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/run-launch.d.ts +10 -1
- package/dist/run-launch.js +11 -4
- package/dist/run-learning-served.d.ts +75 -2
- package/dist/run-manifest.d.ts +3 -0
- package/dist/run-manifest.js +13 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +8 -9
- package/dist/run-view.d.ts +42 -35
- package/dist/run-view.js +79 -44
- package/dist/runnable.d.ts +13 -5
- package/dist/runnable.js +69 -60
- package/dist/runner/adapter-loop.d.ts +42 -11
- package/dist/runner/adapter-loop.js +651 -247
- package/dist/runner/adapter-run-spec.d.ts +37 -12
- package/dist/runner/adapter-run-spec.js +139 -106
- package/dist/runner/adapters/pi.d.ts +24 -0
- package/dist/runner/adapters/pi.js +59 -9
- package/dist/runner/beside.d.ts +3 -1
- package/dist/runner/beside.js +24 -8
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +28 -4
- package/dist/runner/cli-run-spec.d.ts +30 -0
- package/dist/runner/cli-run-spec.js +94 -50
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +3 -2
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.js +6 -3
- package/dist/runner/end-of-run.d.ts +2 -0
- package/dist/runner/end-of-run.js +3 -1
- package/dist/runner/feedback-round.d.ts +40 -13
- package/dist/runner/feedback-round.js +64 -16
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +37 -13
- package/dist/runner/journal-kinds.js +9 -5
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +4 -0
- package/dist/runner/learning-end.js +64 -36
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +2 -0
- package/dist/runner/learning-loop.js +19 -4
- package/dist/runner/loop.d.ts +18 -0
- package/dist/runner/loop.js +34 -0
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-run.d.ts +4 -1
- package/dist/runner/mcp-run.js +11 -5
- package/dist/runner/meta-tools.d.ts +10 -3
- package/dist/runner/meta-tools.js +112 -36
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +114 -39
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +139 -18
- package/dist/runner/monid-run.d.ts +8 -6
- package/dist/runner/monid-run.js +117 -43
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +74 -8
- package/dist/runner/promotion.js +365 -124
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.js +9 -0
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +8 -4
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/workflow-first.d.ts +30 -20
- package/dist/runner/workflow-first.js +22 -32
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +18 -12
- package/dist/runner/workflow-spec.d.ts +4 -1
- package/dist/runner/workflow-spec.js +56 -45
- package/dist/runs-over-store.d.ts +30 -2
- package/dist/runs-over-store.js +46 -14
- package/dist/sdk/runs.d.ts +115 -0
- package/dist/sdk/runs.js +422 -0
- package/dist/sdk/schema.d.ts +175 -0
- package/dist/sdk/schema.js +138 -0
- package/dist/sdk/workflows.d.ts +22 -0
- package/dist/sdk/workflows.js +39 -0
- package/dist/secrets.d.ts +2 -0
- package/dist/secrets.js +19 -1
- package/dist/server.d.ts +48 -32
- package/dist/server.js +554 -130
- package/dist/skill-route.d.ts +3 -0
- package/dist/skill-route.js +16 -0
- package/dist/skills/agentrun-serve/SKILL.md +368 -0
- package/dist/stats.d.ts +10 -10
- package/dist/store/agent-body.d.ts +12 -8
- package/dist/store/agent-body.js +9 -4
- package/dist/store/index.d.ts +1 -1
- package/dist/store/native-command-owner.d.ts +10 -0
- package/dist/store/native-command-owner.js +47 -0
- package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
- package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
- package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
- package/dist/store/postgres/store.js +3 -0
- package/dist/store/schema.d.ts +7 -0
- package/dist/store/schema.js +20 -1
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +14 -3
- package/dist/store/sqlite/store.js +133 -18
- package/dist/store/store.d.ts +52 -7
- package/dist/store-reads/analytics.d.ts +7 -7
- package/dist/store-reads/analytics.js +23 -5
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/journal.d.ts +5 -0
- package/dist/store-reads/journal.js +85 -41
- package/dist/store-reads/learning.d.ts +85 -5
- package/dist/store-reads/learning.js +45 -17
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.js +75 -21
- package/dist/template-eval.d.ts +73 -11
- package/dist/template-eval.js +535 -75
- package/dist/templates.d.ts +70 -20
- package/dist/templates.js +191 -34
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/index.d.ts +3 -2
- package/dist/timeline/index.js +3 -2
- package/dist/timeline/labels.d.ts +5 -2
- package/dist/timeline/labels.js +29 -6
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +66 -4
- package/dist/timeline/timeline.js +160 -30
- package/dist/timeline/util.d.ts +5 -0
- package/dist/timeline/util.js +44 -8
- package/dist/timeline/web-calls.d.ts +17 -0
- package/dist/timeline/web-calls.js +106 -0
- package/dist/tool-gate.d.ts +42 -42
- package/dist/tool-gate.js +97 -91
- package/dist/tool-list.d.ts +4 -1
- package/dist/tool-list.js +8 -1
- package/dist/tool-names.d.ts +18 -13
- package/dist/tool-names.js +19 -17
- package/dist/tool-plane.d.ts +17 -13
- package/dist/tool-plane.js +12 -5
- package/dist/tools.d.ts +44 -16
- package/dist/tools.js +28 -28
- package/dist/trigger-adapter.d.ts +85 -5
- package/dist/trigger-adapter.js +6 -0
- package/dist/trigger-adapters.js +3 -1
- package/dist/trigger-composio.d.ts +10 -0
- package/dist/trigger-composio.js +122 -0
- package/dist/trigger-email.d.ts +4 -0
- package/dist/trigger-email.js +228 -0
- package/dist/trigger-signatures.d.ts +6 -10
- package/dist/trigger-signatures.js +16 -16
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +4 -3
- package/dist/trigger-webhook.js +6 -4
- package/dist/triggers.d.ts +94 -9
- package/dist/triggers.js +263 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.js +1 -7
- package/dist/web-fake.d.ts +56 -0
- package/dist/web-fake.js +102 -0
- package/dist/web-fetch-direct.d.ts +3 -0
- package/dist/web-fetch-direct.js +4 -1
- package/dist/web-fetch.d.ts +5 -1
- package/dist/web-fetch.js +8 -31
- package/dist/web-search.d.ts +51 -2
- package/dist/web-search.js +116 -18
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -1
- package/dist/workflow/node-runner.js +10 -2
- package/dist/workspace/archil-claim.d.ts +3 -0
- package/dist/workspace/archil-claim.js +9 -2
- package/dist/workspace/computer-deps.d.ts +22 -9
- package/dist/workspace/computer-deps.js +78 -37
- package/dist/workspace/computer-for-claim.d.ts +54 -4
- package/dist/workspace/computer-for-claim.js +179 -39
- package/dist/workspace/computer-janitor.d.ts +10 -3
- package/dist/workspace/computer-janitor.js +96 -29
- package/dist/workspace/computer-kept.d.ts +82 -0
- package/dist/workspace/computer-kept.js +147 -0
- package/dist/workspace/computer-mcp.js +4 -3
- package/dist/workspace/computer-ports.d.ts +23 -3
- package/dist/workspace/computer-ports.js +115 -5
- package/dist/workspace/index.d.ts +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +25 -18
- package/dist/workspace/kind-skills/phone/SKILL.md +28 -17
- package/dist/workspace/resolve-computer.d.ts +15 -3
- package/dist/workspace/resolve-computer.js +10 -7
- package/dist/workspace/revision-skills.d.ts +6 -2
- package/dist/workspace/revision-skills.js +12 -5
- package/dist/workspace/run-end-computers.d.ts +30 -0
- package/dist/workspace/run-end-computers.js +137 -0
- package/dist/workspace/run-tools.d.ts +28 -29
- package/dist/workspace/run-tools.js +29 -30
- package/dist/wrap-up.d.ts +19 -5
- package/dist/wrap-up.js +31 -4
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +117 -23
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +18 -4
- package/templates/code-review/evals/mentions-defused/case.yaml +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +1 -1
- package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
- package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
- package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
- package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
- package/templates/code-review/skills/review/DEEP.md +2 -2
- package/templates/code-review/skills/review/REVIEWER.md +2 -2
- package/templates/code-review/skills/review/SKILL.md +7 -3
- package/templates/release-notes/evals/draft-not-publish/case.yaml +1 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +1 -1
- package/templates/release-notes/evals/late-arrival/case.yaml +1 -1
- package/templates/release-notes/evals/other-repo/case.yaml +1 -1
- package/dist/console/assets/index-CjqQirbo.css +0 -1
- package/dist/console/assets/index-b6-XY5A9.js +0 -576
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -9
- package/dist/runner/adapters/pi-computer.js +0 -51
- package/dist/workspace/computer-script.d.ts +0 -53
- package/dist/workspace/computer-script.js +0 -172
|
@@ -0,0 +1,700 @@
|
|
|
1
|
+
var L_=Object.defineProperty;var I_=(e,n,s)=>n in e?L_(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var Rt=(e,n,s)=>I_(e,typeof n!="symbol"?n+"":n,s);function z_(e,n){for(var s=0;s<n.length;s++){const r=n[s];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(r,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function s(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=s(a);fetch(a.href,i)}})();function uN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $p={exports:{}},Zl={},_p={exports:{}},gt={};/**
|
|
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 Iw;function D_(){if(Iw)return gt;Iw=1;var e=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),b=Symbol.iterator;function g(z){return z===null||typeof z!="object"?null:(z=b&&z[b]||z["@@iterator"],typeof z=="function"?z:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,y={};function j(z,Q,K){this.props=z,this.context=Q,this.refs=y,this.updater=K||h}j.prototype.isReactComponent={},j.prototype.setState=function(z,Q){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,Q,"setState")},j.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function k(){}k.prototype=j.prototype;function $(z,Q,K){this.props=z,this.context=Q,this.refs=y,this.updater=K||h}var S=$.prototype=new k;S.constructor=$,v(S,j.prototype),S.isPureReactComponent=!0;var N=Array.isArray,_=Object.prototype.hasOwnProperty,E={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function A(z,Q,K){var Z,de={},re=null,fe=null;if(Q!=null)for(Z in Q.ref!==void 0&&(fe=Q.ref),Q.key!==void 0&&(re=""+Q.key),Q)_.call(Q,Z)&&!O.hasOwnProperty(Z)&&(de[Z]=Q[Z]);var ve=arguments.length-2;if(ve===1)de.children=K;else if(1<ve){for(var Ee=Array(ve),ue=0;ue<ve;ue++)Ee[ue]=arguments[ue+2];de.children=Ee}if(z&&z.defaultProps)for(Z in ve=z.defaultProps,ve)de[Z]===void 0&&(de[Z]=ve[Z]);return{$$typeof:e,type:z,key:re,ref:fe,props:de,_owner:E.current}}function I(z,Q){return{$$typeof:e,type:z.type,key:Q,ref:z.ref,props:z.props,_owner:z._owner}}function M(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function R(z){var Q={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(K){return Q[K]})}var P=/\/+/g;function D(z,Q){return typeof z=="object"&&z!==null&&z.key!=null?R(""+z.key):Q.toString(36)}function W(z,Q,K,Z,de){var re=typeof z;(re==="undefined"||re==="boolean")&&(z=null);var fe=!1;if(z===null)fe=!0;else switch(re){case"string":case"number":fe=!0;break;case"object":switch(z.$$typeof){case e:case n:fe=!0}}if(fe)return fe=z,de=de(fe),z=Z===""?"."+D(fe,0):Z,N(de)?(K="",z!=null&&(K=z.replace(P,"$&/")+"/"),W(de,Q,K,"",function(ue){return ue})):de!=null&&(M(de)&&(de=I(de,K+(!de.key||fe&&fe.key===de.key?"":(""+de.key).replace(P,"$&/")+"/")+z)),Q.push(de)),1;if(fe=0,Z=Z===""?".":Z+":",N(z))for(var ve=0;ve<z.length;ve++){re=z[ve];var Ee=Z+D(re,ve);fe+=W(re,Q,K,Ee,de)}else if(Ee=g(z),typeof Ee=="function")for(z=Ee.call(z),ve=0;!(re=z.next()).done;)re=re.value,Ee=Z+D(re,ve++),fe+=W(re,Q,K,Ee,de);else if(re==="object")throw Q=String(z),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.");return fe}function Y(z,Q,K){if(z==null)return z;var Z=[],de=0;return W(z,Z,"","",function(re){return Q.call(K,re,de++)}),Z}function H(z){if(z._status===-1){var Q=z._result;Q=Q(),Q.then(function(K){(z._status===0||z._status===-1)&&(z._status=1,z._result=K)},function(K){(z._status===0||z._status===-1)&&(z._status=2,z._result=K)}),z._status===-1&&(z._status=0,z._result=Q)}if(z._status===1)return z._result.default;throw z._result}var q={current:null},F={transition:null},G={ReactCurrentDispatcher:q,ReactCurrentBatchConfig:F,ReactCurrentOwner:E};function U(){throw Error("act(...) is not supported in production builds of React.")}return gt.Children={map:Y,forEach:function(z,Q,K){Y(z,function(){Q.apply(this,arguments)},K)},count:function(z){var Q=0;return Y(z,function(){Q++}),Q},toArray:function(z){return Y(z,function(Q){return Q})||[]},only:function(z){if(!M(z))throw Error("React.Children.only expected to receive a single React element child.");return z}},gt.Component=j,gt.Fragment=s,gt.Profiler=a,gt.PureComponent=$,gt.StrictMode=r,gt.Suspense=u,gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,gt.act=U,gt.cloneElement=function(z,Q,K){if(z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+z+".");var Z=v({},z.props),de=z.key,re=z.ref,fe=z._owner;if(Q!=null){if(Q.ref!==void 0&&(re=Q.ref,fe=E.current),Q.key!==void 0&&(de=""+Q.key),z.type&&z.type.defaultProps)var ve=z.type.defaultProps;for(Ee in Q)_.call(Q,Ee)&&!O.hasOwnProperty(Ee)&&(Z[Ee]=Q[Ee]===void 0&&ve!==void 0?ve[Ee]:Q[Ee])}var Ee=arguments.length-2;if(Ee===1)Z.children=K;else if(1<Ee){ve=Array(Ee);for(var ue=0;ue<Ee;ue++)ve[ue]=arguments[ue+2];Z.children=ve}return{$$typeof:e,type:z.type,key:de,ref:re,props:Z,_owner:fe}},gt.createContext=function(z){return z={$$typeof:c,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},z.Provider={$$typeof:i,_context:z},z.Consumer=z},gt.createElement=A,gt.createFactory=function(z){var Q=A.bind(null,z);return Q.type=z,Q},gt.createRef=function(){return{current:null}},gt.forwardRef=function(z){return{$$typeof:d,render:z}},gt.isValidElement=M,gt.lazy=function(z){return{$$typeof:x,_payload:{_status:-1,_result:z},_init:H}},gt.memo=function(z,Q){return{$$typeof:f,type:z,compare:Q===void 0?null:Q}},gt.startTransition=function(z){var Q=F.transition;F.transition={};try{z()}finally{F.transition=Q}},gt.unstable_act=U,gt.useCallback=function(z,Q){return q.current.useCallback(z,Q)},gt.useContext=function(z){return q.current.useContext(z)},gt.useDebugValue=function(){},gt.useDeferredValue=function(z){return q.current.useDeferredValue(z)},gt.useEffect=function(z,Q){return q.current.useEffect(z,Q)},gt.useId=function(){return q.current.useId()},gt.useImperativeHandle=function(z,Q,K){return q.current.useImperativeHandle(z,Q,K)},gt.useInsertionEffect=function(z,Q){return q.current.useInsertionEffect(z,Q)},gt.useLayoutEffect=function(z,Q){return q.current.useLayoutEffect(z,Q)},gt.useMemo=function(z,Q){return q.current.useMemo(z,Q)},gt.useReducer=function(z,Q,K){return q.current.useReducer(z,Q,K)},gt.useRef=function(z){return q.current.useRef(z)},gt.useState=function(z){return q.current.useState(z)},gt.useSyncExternalStore=function(z,Q,K){return q.current.useSyncExternalStore(z,Q,K)},gt.useTransition=function(){return q.current.useTransition()},gt.version="18.3.1",gt}var zw;function Xf(){return zw||(zw=1,_p.exports=D_()),_p.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 Dw;function F_(){if(Dw)return Zl;Dw=1;var e=Xf(),n=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,i={key:!0,ref:!0,__self:!0,__source:!0};function c(d,u,f){var x,b={},g=null,h=null;f!==void 0&&(g=""+f),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(h=u.ref);for(x in u)r.call(u,x)&&!i.hasOwnProperty(x)&&(b[x]=u[x]);if(d&&d.defaultProps)for(x in u=d.defaultProps,u)b[x]===void 0&&(b[x]=u[x]);return{$$typeof:n,type:d,key:g,ref:h,props:b,_owner:a.current}}return Zl.Fragment=s,Zl.jsx=c,Zl.jsxs=c,Zl}var Fw;function U_(){return Fw||(Fw=1,$p.exports=F_()),$p.exports}var t=U_(),p=Xf();const He=uN(p),wg=z_({__proto__:null,default:He},[p]);var Cu={},Tp={exports:{}},ds={},Rp={exports:{}},Ap={};/**
|
|
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 Uw;function W_(){return Uw||(Uw=1,(function(e){function n(F,G){var U=F.length;F.push(G);e:for(;0<U;){var z=U-1>>>1,Q=F[z];if(0<a(Q,G))F[z]=G,F[U]=Q,U=z;else break e}}function s(F){return F.length===0?null:F[0]}function r(F){if(F.length===0)return null;var G=F[0],U=F.pop();if(U!==G){F[0]=U;e:for(var z=0,Q=F.length,K=Q>>>1;z<K;){var Z=2*(z+1)-1,de=F[Z],re=Z+1,fe=F[re];if(0>a(de,U))re<Q&&0>a(fe,de)?(F[z]=fe,F[re]=U,z=re):(F[z]=de,F[Z]=U,z=Z);else if(re<Q&&0>a(fe,U))F[z]=fe,F[re]=U,z=re;else break e}}return G}function a(F,G){var U=F.sortIndex-G.sortIndex;return U!==0?U:F.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var u=[],f=[],x=1,b=null,g=3,h=!1,v=!1,y=!1,j=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,$=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(F){for(var G=s(f);G!==null;){if(G.callback===null)r(f);else if(G.startTime<=F)r(f),G.sortIndex=G.expirationTime,n(u,G);else break;G=s(f)}}function N(F){if(y=!1,S(F),!v)if(s(u)!==null)v=!0,H(_);else{var G=s(f);G!==null&&q(N,G.startTime-F)}}function _(F,G){v=!1,y&&(y=!1,k(A),A=-1),h=!0;var U=g;try{for(S(G),b=s(u);b!==null&&(!(b.expirationTime>G)||F&&!R());){var z=b.callback;if(typeof z=="function"){b.callback=null,g=b.priorityLevel;var Q=z(b.expirationTime<=G);G=e.unstable_now(),typeof Q=="function"?b.callback=Q:b===s(u)&&r(u),S(G)}else r(u);b=s(u)}if(b!==null)var K=!0;else{var Z=s(f);Z!==null&&q(N,Z.startTime-G),K=!1}return K}finally{b=null,g=U,h=!1}}var E=!1,O=null,A=-1,I=5,M=-1;function R(){return!(e.unstable_now()-M<I)}function P(){if(O!==null){var F=e.unstable_now();M=F;var G=!0;try{G=O(!0,F)}finally{G?D():(E=!1,O=null)}}else E=!1}var D;if(typeof $=="function")D=function(){$(P)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,Y=W.port2;W.port1.onmessage=P,D=function(){Y.postMessage(null)}}else D=function(){j(P,0)};function H(F){O=F,E||(E=!0,D())}function q(F,G){A=j(function(){F(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(F){F.callback=null},e.unstable_continueExecution=function(){v||h||(v=!0,H(_))},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return s(u)},e.unstable_next=function(F){switch(g){case 1:case 2:case 3:var G=3;break;default:G=g}var U=g;g=G;try{return F()}finally{g=U}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(F,G){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var U=g;g=F;try{return G()}finally{g=U}},e.unstable_scheduleCallback=function(F,G,U){var z=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?z+U:z):U=z,F){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=U+Q,F={id:x++,callback:G,priorityLevel:F,startTime:U,expirationTime:Q,sortIndex:-1},U>z?(F.sortIndex=U,n(f,F),s(u)===null&&F===s(f)&&(y?(k(A),A=-1):y=!0,q(N,U-z))):(F.sortIndex=Q,n(u,F),v||h||(v=!0,H(_))),F},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(F){var G=g;return function(){var U=g;g=G;try{return F.apply(this,arguments)}finally{g=U}}}})(Ap)),Ap}var Ww;function H_(){return Ww||(Ww=1,Rp.exports=W_()),Rp.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 Hw;function B_(){if(Hw)return ds;Hw=1;var e=Xf(),n=H_();function s(o){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+o,m=1;m<arguments.length;m++)l+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+o+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,a={};function i(o,l){c(o,l),c(o+"Capture",l)}function c(o,l){for(a[o]=l,o=0;o<l.length;o++)r.add(l[o])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},b={};function g(o){return u.call(b,o)?!0:u.call(x,o)?!1:f.test(o)?b[o]=!0:(x[o]=!0,!1)}function h(o,l,m,w){if(m!==null&&m.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return w?!1:m!==null?!m.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function v(o,l,m,w){if(l===null||typeof l>"u"||h(o,l,m,w))return!0;if(w)return!1;if(m!==null)switch(m.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function y(o,l,m,w,C,T,L){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=w,this.attributeNamespace=C,this.mustUseProperty=m,this.propertyName=o,this.type=l,this.sanitizeURL=T,this.removeEmptyString=L}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){j[o]=new y(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var l=o[0];j[l]=new y(l,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){j[o]=new y(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){j[o]=new y(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){j[o]=new y(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){j[o]=new y(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){j[o]=new y(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){j[o]=new y(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){j[o]=new y(o,5,!1,o.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function $(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 l=o.replace(k,$);j[l]=new y(l,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var l=o.replace(k,$);j[l]=new y(l,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var l=o.replace(k,$);j[l]=new y(l,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){j[o]=new y(o,1,!1,o.toLowerCase(),null,!1,!1)}),j.xlinkHref=new y("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){j[o]=new y(o,1,!1,o.toLowerCase(),null,!0,!0)});function S(o,l,m,w){var C=j.hasOwnProperty(l)?j[l]:null;(C!==null?C.type!==0:w||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(v(l,m,C,w)&&(m=null),w||C===null?g(l)&&(m===null?o.removeAttribute(l):o.setAttribute(l,""+m)):C.mustUseProperty?o[C.propertyName]=m===null?C.type===3?!1:"":m:(l=C.attributeName,w=C.attributeNamespace,m===null?o.removeAttribute(l):(C=C.type,m=C===3||C===4&&m===!0?"":""+m,w?o.setAttributeNS(w,l,m):o.setAttribute(l,m))))}var N=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_=Symbol.for("react.element"),E=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),R=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),q=Symbol.for("react.offscreen"),F=Symbol.iterator;function G(o){return o===null||typeof o!="object"?null:(o=F&&o[F]||o["@@iterator"],typeof o=="function"?o:null)}var U=Object.assign,z;function Q(o){if(z===void 0)try{throw Error()}catch(m){var l=m.stack.trim().match(/\n( *(at )?)/);z=l&&l[1]||""}return`
|
|
34
|
+
`+z+o}var K=!1;function Z(o,l){if(!o||K)return"";K=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ce){var w=ce}Reflect.construct(o,[],l)}else{try{l.call()}catch(ce){w=ce}o.call(l.prototype)}else{try{throw Error()}catch(ce){w=ce}o()}}catch(ce){if(ce&&w&&typeof ce.stack=="string"){for(var C=ce.stack.split(`
|
|
35
|
+
`),T=w.stack.split(`
|
|
36
|
+
`),L=C.length-1,V=T.length-1;1<=L&&0<=V&&C[L]!==T[V];)V--;for(;1<=L&&0<=V;L--,V--)if(C[L]!==T[V]){if(L!==1||V!==1)do if(L--,V--,0>V||C[L]!==T[V]){var X=`
|
|
37
|
+
`+C[L].replace(" at new "," at ");return o.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",o.displayName)),X}while(1<=L&&0<=V);break}}}finally{K=!1,Error.prepareStackTrace=m}return(o=o?o.displayName||o.name:"")?Q(o):""}function de(o){switch(o.tag){case 5:return Q(o.type);case 16:return Q("Lazy");case 13:return Q("Suspense");case 19:return Q("SuspenseList");case 0:case 2:case 15:return o=Z(o.type,!1),o;case 11:return o=Z(o.type.render,!1),o;case 1:return o=Z(o.type,!0),o;default:return""}}function re(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 O:return"Fragment";case E:return"Portal";case I:return"Profiler";case A:return"StrictMode";case D:return"Suspense";case W:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case R:return(o.displayName||"Context")+".Consumer";case M:return(o._context.displayName||"Context")+".Provider";case P:var l=o.render;return o=o.displayName,o||(o=l.displayName||l.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case Y:return l=o.displayName||null,l!==null?l:re(o.type)||"Memo";case H:l=o._payload,o=o._init;try{return re(o(l))}catch{}}return null}function fe(o){var l=o.type;switch(o.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=l.render,o=o.displayName||o.name||"",l.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return re(l);case 8:return l===A?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function ve(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function Ee(o){var l=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function ue(o){var l=Ee(o)?"checked":"value",m=Object.getOwnPropertyDescriptor(o.constructor.prototype,l),w=""+o[l];if(!o.hasOwnProperty(l)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var C=m.get,T=m.set;return Object.defineProperty(o,l,{configurable:!0,get:function(){return C.call(this)},set:function(L){w=""+L,T.call(this,L)}}),Object.defineProperty(o,l,{enumerable:m.enumerable}),{getValue:function(){return w},setValue:function(L){w=""+L},stopTracking:function(){o._valueTracker=null,delete o[l]}}}}function pe(o){o._valueTracker||(o._valueTracker=ue(o))}function me(o){if(!o)return!1;var l=o._valueTracker;if(!l)return!0;var m=l.getValue(),w="";return o&&(w=Ee(o)?o.checked?"true":"false":o.value),o=w,o!==m?(l.setValue(o),!0):!1}function ke(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 $e(o,l){var m=l.checked;return U({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??o._wrapperState.initialChecked})}function J(o,l){var m=l.defaultValue==null?"":l.defaultValue,w=l.checked!=null?l.checked:l.defaultChecked;m=ve(l.value!=null?l.value:m),o._wrapperState={initialChecked:w,initialValue:m,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Le(o,l){l=l.checked,l!=null&&S(o,"checked",l,!1)}function qe(o,l){Le(o,l);var m=ve(l.value),w=l.type;if(m!=null)w==="number"?(m===0&&o.value===""||o.value!=m)&&(o.value=""+m):o.value!==""+m&&(o.value=""+m);else if(w==="submit"||w==="reset"){o.removeAttribute("value");return}l.hasOwnProperty("value")?vt(o,l.type,m):l.hasOwnProperty("defaultValue")&&vt(o,l.type,ve(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(o.defaultChecked=!!l.defaultChecked)}function rt(o,l,m){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var w=l.type;if(!(w!=="submit"&&w!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+o._wrapperState.initialValue,m||l===o.value||(o.value=l),o.defaultValue=l}m=o.name,m!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,m!==""&&(o.name=m)}function vt(o,l,m){(l!=="number"||ke(o.ownerDocument)!==o)&&(m==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+m&&(o.defaultValue=""+m))}var st=Array.isArray;function Se(o,l,m,w){if(o=o.options,l){l={};for(var C=0;C<m.length;C++)l["$"+m[C]]=!0;for(m=0;m<o.length;m++)C=l.hasOwnProperty("$"+o[m].value),o[m].selected!==C&&(o[m].selected=C),C&&w&&(o[m].defaultSelected=!0)}else{for(m=""+ve(m),l=null,C=0;C<o.length;C++){if(o[C].value===m){o[C].selected=!0,w&&(o[C].defaultSelected=!0);return}l!==null||o[C].disabled||(l=o[C])}l!==null&&(l.selected=!0)}}function Be(o,l){if(l.dangerouslySetInnerHTML!=null)throw Error(s(91));return U({},l,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function he(o,l){var m=l.value;if(m==null){if(m=l.children,l=l.defaultValue,m!=null){if(l!=null)throw Error(s(92));if(st(m)){if(1<m.length)throw Error(s(93));m=m[0]}l=m}l==null&&(l=""),m=l}o._wrapperState={initialValue:ve(m)}}function Ve(o,l){var m=ve(l.value),w=ve(l.defaultValue);m!=null&&(m=""+m,m!==o.value&&(o.value=m),l.defaultValue==null&&o.defaultValue!==m&&(o.defaultValue=m)),w!=null&&(o.defaultValue=""+w)}function ct(o){var l=o.textContent;l===o._wrapperState.initialValue&&l!==""&&l!==null&&(o.value=l)}function Me(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 ot(o,l){return o==null||o==="http://www.w3.org/1999/xhtml"?Me(l):o==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var oe,xe=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,m,w,C){MSApp.execUnsafeLocalFunction(function(){return o(l,m,w,C)})}:o})(function(o,l){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=l;else{for(oe=oe||document.createElement("div"),oe.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=oe.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;l.firstChild;)o.appendChild(l.firstChild)}});function Ae(o,l){if(l){var m=o.firstChild;if(m&&m===o.lastChild&&m.nodeType===3){m.nodeValue=l;return}}o.textContent=l}var De={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},ut=["Webkit","ms","Moz","O"];Object.keys(De).forEach(function(o){ut.forEach(function(l){l=l+o.charAt(0).toUpperCase()+o.substring(1),De[l]=De[o]})});function ee(o,l,m){return l==null||typeof l=="boolean"||l===""?"":m||typeof l!="number"||l===0||De.hasOwnProperty(o)&&De[o]?(""+l).trim():l+"px"}function Re(o,l){o=o.style;for(var m in l)if(l.hasOwnProperty(m)){var w=m.indexOf("--")===0,C=ee(m,l[m],w);m==="float"&&(m="cssFloat"),w?o.setProperty(m,C):o[m]=C}}var Qe=U({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 Ze(o,l){if(l){if(Qe[o]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(s(137,o));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(s(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(s(61))}if(l.style!=null&&typeof l.style!="object")throw Error(s(62))}}function at(o,l){if(o.indexOf("-")===-1)return typeof l.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 Xe=null;function pt(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var et=null,kt=null,Ct=null;function Tn(o){if(o=zl(o)){if(typeof et!="function")throw Error(s(280));var l=o.stateNode;l&&(l=Ud(l),et(o.stateNode,o.type,l))}}function dn(o){kt?Ct?Ct.push(o):Ct=[o]:kt=o}function Nt(){if(kt){var o=kt,l=Ct;if(Ct=kt=null,Tn(o),l)for(o=0;o<l.length;o++)Tn(l[o])}}function Rn(o,l){return o(l)}function hs(){}var Ys=!1;function Cn(o,l,m){if(Ys)return o(l,m);Ys=!0;try{return Rn(o,l,m)}finally{Ys=!1,(kt!==null||Ct!==null)&&(hs(),Nt())}}function Un(o,l){var m=o.stateNode;if(m===null)return null;var w=Ud(m);if(w===null)return null;m=w[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(o=o.type,w=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!w;break e;default:o=!1}if(o)return null;if(m&&typeof m!="function")throw Error(s(231,l,typeof m));return m}var ps=!1;if(d)try{var gs={};Object.defineProperty(gs,"passive",{get:function(){ps=!0}}),window.addEventListener("test",gs,gs),window.removeEventListener("test",gs,gs)}catch{ps=!1}function un(o,l,m,w,C,T,L,V,X){var ce=Array.prototype.slice.call(arguments,3);try{l.apply(m,ce)}catch(we){this.onError(we)}}var Wn=!1,$s=null,Hn=!1,_s=null,Ts={onError:function(o){Wn=!0,$s=o}};function An(o,l,m,w,C,T,L,V,X){Wn=!1,$s=null,un.apply(Ts,arguments)}function te(o,l,m,w,C,T,L,V,X){if(An.apply(this,arguments),Wn){if(Wn){var ce=$s;Wn=!1,$s=null}else throw Error(s(198));Hn||(Hn=!0,_s=ce)}}function Oe(o){var l=o,m=o;if(o.alternate)for(;l.return;)l=l.return;else{o=l;do l=o,(l.flags&4098)!==0&&(m=l.return),o=l.return;while(o)}return l.tag===3?m:null}function ft(o){if(o.tag===13){var l=o.memoizedState;if(l===null&&(o=o.alternate,o!==null&&(l=o.memoizedState)),l!==null)return l.dehydrated}return null}function Ot(o){if(Oe(o)!==o)throw Error(s(188))}function Vt(o){var l=o.alternate;if(!l){if(l=Oe(o),l===null)throw Error(s(188));return l!==o?null:o}for(var m=o,w=l;;){var C=m.return;if(C===null)break;var T=C.alternate;if(T===null){if(w=C.return,w!==null){m=w;continue}break}if(C.child===T.child){for(T=C.child;T;){if(T===m)return Ot(C),o;if(T===w)return Ot(C),l;T=T.sibling}throw Error(s(188))}if(m.return!==w.return)m=C,w=T;else{for(var L=!1,V=C.child;V;){if(V===m){L=!0,m=C,w=T;break}if(V===w){L=!0,w=C,m=T;break}V=V.sibling}if(!L){for(V=T.child;V;){if(V===m){L=!0,m=T,w=C;break}if(V===w){L=!0,w=T,m=C;break}V=V.sibling}if(!L)throw Error(s(189))}}if(m.alternate!==w)throw Error(s(190))}if(m.tag!==3)throw Error(s(188));return m.stateNode.current===m?o:l}function Fe(o){return o=Vt(o),o!==null?ne(o):null}function ne(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var l=ne(o);if(l!==null)return l;o=o.sibling}return null}var ye=n.unstable_scheduleCallback,We=n.unstable_cancelCallback,St=n.unstable_shouldYield,Lt=n.unstable_requestPaint,it=n.unstable_now,yn=n.unstable_getCurrentPriorityLevel,En=n.unstable_ImmediatePriority,ur=n.unstable_UserBlockingPriority,Ut=n.unstable_NormalPriority,Za=n.unstable_LowPriority,ao=n.unstable_IdlePriority,sa=null,xs=null;function jd(o){if(xs&&typeof xs.onCommitFiberRoot=="function")try{xs.onCommitFiberRoot(sa,o,void 0,(o.current.flags&128)===128)}catch{}}var ss=Math.clz32?Math.clz32:Sd,kd=Math.log,Nd=Math.LN2;function Sd(o){return o>>>=0,o===0?32:31-(kd(o)/Nd|0)|0}var ra=64,oa=4194304;function io(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 aa(o,l){var m=o.pendingLanes;if(m===0)return 0;var w=0,C=o.suspendedLanes,T=o.pingedLanes,L=m&268435455;if(L!==0){var V=L&~C;V!==0?w=io(V):(T&=L,T!==0&&(w=io(T)))}else L=m&~C,L!==0?w=io(L):T!==0&&(w=io(T));if(w===0)return 0;if(l!==0&&l!==w&&(l&C)===0&&(C=w&-w,T=l&-l,C>=T||C===16&&(T&4194240)!==0))return l;if((w&4)!==0&&(w|=m&16),l=o.entangledLanes,l!==0)for(o=o.entanglements,l&=w;0<l;)m=31-ss(l),C=1<<m,w|=o[m],l&=~C;return w}function Cd(o,l){switch(o){case 1:case 2:case 4:return l+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ed(o,l){for(var m=o.suspendedLanes,w=o.pingedLanes,C=o.expirationTimes,T=o.pendingLanes;0<T;){var L=31-ss(T),V=1<<L,X=C[L];X===-1?((V&m)===0||(V&w)!==0)&&(C[L]=Cd(V,l)):X<=l&&(o.expiredLanes|=V),T&=~V}}function ei(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function wl(){var o=ra;return ra<<=1,(ra&4194240)===0&&(ra=64),o}function ti(o){for(var l=[],m=0;31>m;m++)l.push(o);return l}function lo(o,l,m){o.pendingLanes|=l,l!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,l=31-ss(l),o[l]=m}function $d(o,l){var m=o.pendingLanes&~l;o.pendingLanes=l,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=l,o.mutableReadLanes&=l,o.entangledLanes&=l,l=o.entanglements;var w=o.eventTimes;for(o=o.expirationTimes;0<m;){var C=31-ss(m),T=1<<C;l[C]=0,w[C]=-1,o[C]=-1,m&=~T}}function ni(o,l){var m=o.entangledLanes|=l;for(o=o.entanglements;m;){var w=31-ss(m),C=1<<w;C&l|o[w]&l&&(o[w]|=l),m&=~C}}var $t=0;function jl(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var kl,si,Nl,Sl,Cl,ri=!1,ia=[],Qs=null,Js=null,Xs=null,ge=new Map,Ce=new Map,Pe=[],_t="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 wt(o,l){switch(o){case"focusin":case"focusout":Qs=null;break;case"dragenter":case"dragleave":Js=null;break;case"mouseover":case"mouseout":Xs=null;break;case"pointerover":case"pointerout":ge.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ce.delete(l.pointerId)}}function rs(o,l,m,w,C,T){return o===null||o.nativeEvent!==T?(o={blockedOn:l,domEventName:m,eventSystemFlags:w,nativeEvent:T,targetContainers:[C]},l!==null&&(l=zl(l),l!==null&&si(l)),o):(o.eventSystemFlags|=w,l=o.targetContainers,C!==null&&l.indexOf(C)===-1&&l.push(C),o)}function Bn(o,l,m,w,C){switch(l){case"focusin":return Qs=rs(Qs,o,l,m,w,C),!0;case"dragenter":return Js=rs(Js,o,l,m,w,C),!0;case"mouseover":return Xs=rs(Xs,o,l,m,w,C),!0;case"pointerover":var T=C.pointerId;return ge.set(T,rs(ge.get(T)||null,o,l,m,w,C)),!0;case"gotpointercapture":return T=C.pointerId,Ce.set(T,rs(Ce.get(T)||null,o,l,m,w,C)),!0}return!1}function Gn(o){var l=la(o.target);if(l!==null){var m=Oe(l);if(m!==null){if(l=m.tag,l===13){if(l=ft(m),l!==null){o.blockedOn=l,Cl(o.priority,function(){Nl(m)});return}}else if(l===3&&m.stateNode.current.memoizedState.isDehydrated){o.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}o.blockedOn=null}function oi(o){if(o.blockedOn!==null)return!1;for(var l=o.targetContainers;0<l.length;){var m=th(o.domEventName,o.eventSystemFlags,l[0],o.nativeEvent);if(m===null){m=o.nativeEvent;var w=new m.constructor(m.type,m);Xe=w,m.target.dispatchEvent(w),Xe=null}else return l=zl(m),l!==null&&si(l),o.blockedOn=m,!1;l.shift()}return!0}function Rr(o,l,m){oi(o)&&m.delete(l)}function Zm(){ri=!1,Qs!==null&&oi(Qs)&&(Qs=null),Js!==null&&oi(Js)&&(Js=null),Xs!==null&&oi(Xs)&&(Xs=null),ge.forEach(Rr),Ce.forEach(Rr)}function co(o,l){o.blockedOn===l&&(o.blockedOn=null,ri||(ri=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Zm)))}function uo(o){function l(C){return co(C,o)}if(0<ia.length){co(ia[0],o);for(var m=1;m<ia.length;m++){var w=ia[m];w.blockedOn===o&&(w.blockedOn=null)}}for(Qs!==null&&co(Qs,o),Js!==null&&co(Js,o),Xs!==null&&co(Xs,o),ge.forEach(l),Ce.forEach(l),m=0;m<Pe.length;m++)w=Pe[m],w.blockedOn===o&&(w.blockedOn=null);for(;0<Pe.length&&(m=Pe[0],m.blockedOn===null);)Gn(m),m.blockedOn===null&&Pe.shift()}var Ar=N.ReactCurrentBatchConfig,Or=!0;function fo(o,l,m,w){var C=$t,T=Ar.transition;Ar.transition=null;try{$t=1,eh(o,l,m,w)}finally{$t=C,Ar.transition=T}}function fr(o,l,m,w){var C=$t,T=Ar.transition;Ar.transition=null;try{$t=4,eh(o,l,m,w)}finally{$t=C,Ar.transition=T}}function eh(o,l,m,w){if(Or){var C=th(o,l,m,w);if(C===null)vh(o,l,w,_d,m),wt(o,w);else if(Bn(C,o,l,m,w))w.stopPropagation();else if(wt(o,w),l&4&&-1<_t.indexOf(o)){for(;C!==null;){var T=zl(C);if(T!==null&&kl(T),T=th(o,l,m,w),T===null&&vh(o,l,w,_d,m),T===C)break;C=T}C!==null&&w.stopPropagation()}else vh(o,l,w,null,m)}}var _d=null;function th(o,l,m,w){if(_d=null,o=pt(w),o=la(o),o!==null)if(l=Oe(o),l===null)o=null;else if(m=l.tag,m===13){if(o=ft(l),o!==null)return o;o=null}else if(m===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;o=null}else l!==o&&(o=null);return _d=o,null}function ky(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(yn()){case En:return 1;case ur:return 4;case Ut:case Za:return 16;case ao:return 536870912;default:return 16}default:return 16}}var mo=null,nh=null,Td=null;function Ny(){if(Td)return Td;var o,l=nh,m=l.length,w,C="value"in mo?mo.value:mo.textContent,T=C.length;for(o=0;o<m&&l[o]===C[o];o++);var L=m-o;for(w=1;w<=L&&l[m-w]===C[T-w];w++);return Td=C.slice(o,1<w?1-w:void 0)}function Rd(o){var l=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&l===13&&(o=13)):o=l,o===10&&(o=13),32<=o||o===13?o:0}function Ad(){return!0}function Sy(){return!1}function vs(o){function l(m,w,C,T,L){this._reactName=m,this._targetInst=C,this.type=w,this.nativeEvent=T,this.target=L,this.currentTarget=null;for(var V in o)o.hasOwnProperty(V)&&(m=o[V],this[V]=m?m(T):T[V]);return this.isDefaultPrevented=(T.defaultPrevented!=null?T.defaultPrevented:T.returnValue===!1)?Ad:Sy,this.isPropagationStopped=Sy,this}return U(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=Ad)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=Ad)},persist:function(){},isPersistent:Ad}),l}var ai={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},sh=vs(ai),El=U({},ai,{view:0,detail:0}),c$=vs(El),rh,oh,$l,Od=U({},El,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ih,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!==$l&&($l&&o.type==="mousemove"?(rh=o.screenX-$l.screenX,oh=o.screenY-$l.screenY):oh=rh=0,$l=o),rh)},movementY:function(o){return"movementY"in o?o.movementY:oh}}),Cy=vs(Od),d$=U({},Od,{dataTransfer:0}),u$=vs(d$),f$=U({},El,{relatedTarget:0}),ah=vs(f$),m$=U({},ai,{animationName:0,elapsedTime:0,pseudoElement:0}),h$=vs(m$),p$=U({},ai,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),g$=vs(p$),x$=U({},ai,{data:0}),Ey=vs(x$),v$={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},y$={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"},b$={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function w$(o){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(o):(o=b$[o])?!!l[o]:!1}function ih(){return w$}var j$=U({},El,{key:function(o){if(o.key){var l=v$[o.key]||o.key;if(l!=="Unidentified")return l}return o.type==="keypress"?(o=Rd(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?y$[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ih,charCode:function(o){return o.type==="keypress"?Rd(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?Rd(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),k$=vs(j$),N$=U({},Od,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$y=vs(N$),S$=U({},El,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ih}),C$=vs(S$),E$=U({},ai,{propertyName:0,elapsedTime:0,pseudoElement:0}),$$=vs(E$),_$=U({},Od,{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}),T$=vs(_$),R$=[9,13,27,32],lh=d&&"CompositionEvent"in window,_l=null;d&&"documentMode"in document&&(_l=document.documentMode);var A$=d&&"TextEvent"in window&&!_l,_y=d&&(!lh||_l&&8<_l&&11>=_l),Ty=" ",Ry=!1;function Ay(o,l){switch(o){case"keyup":return R$.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Oy(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var ii=!1;function O$(o,l){switch(o){case"compositionend":return Oy(l);case"keypress":return l.which!==32?null:(Ry=!0,Ty);case"textInput":return o=l.data,o===Ty&&Ry?null:o;default:return null}}function M$(o,l){if(ii)return o==="compositionend"||!lh&&Ay(o,l)?(o=Ny(),Td=nh=mo=null,ii=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return _y&&l.locale!=="ko"?null:l.data;default:return null}}var P$={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 My(o){var l=o&&o.nodeName&&o.nodeName.toLowerCase();return l==="input"?!!P$[o.type]:l==="textarea"}function Py(o,l,m,w){dn(w),l=zd(l,"onChange"),0<l.length&&(m=new sh("onChange","change",null,m,w),o.push({event:m,listeners:l}))}var Tl=null,Rl=null;function L$(o){Zy(o,0)}function Md(o){var l=fi(o);if(me(l))return o}function I$(o,l){if(o==="change")return l}var Ly=!1;if(d){var ch;if(d){var dh="oninput"in document;if(!dh){var Iy=document.createElement("div");Iy.setAttribute("oninput","return;"),dh=typeof Iy.oninput=="function"}ch=dh}else ch=!1;Ly=ch&&(!document.documentMode||9<document.documentMode)}function zy(){Tl&&(Tl.detachEvent("onpropertychange",Dy),Rl=Tl=null)}function Dy(o){if(o.propertyName==="value"&&Md(Rl)){var l=[];Py(l,Rl,o,pt(o)),Cn(L$,l)}}function z$(o,l,m){o==="focusin"?(zy(),Tl=l,Rl=m,Tl.attachEvent("onpropertychange",Dy)):o==="focusout"&&zy()}function D$(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return Md(Rl)}function F$(o,l){if(o==="click")return Md(l)}function U$(o,l){if(o==="input"||o==="change")return Md(l)}function W$(o,l){return o===l&&(o!==0||1/o===1/l)||o!==o&&l!==l}var Zs=typeof Object.is=="function"?Object.is:W$;function Al(o,l){if(Zs(o,l))return!0;if(typeof o!="object"||o===null||typeof l!="object"||l===null)return!1;var m=Object.keys(o),w=Object.keys(l);if(m.length!==w.length)return!1;for(w=0;w<m.length;w++){var C=m[w];if(!u.call(l,C)||!Zs(o[C],l[C]))return!1}return!0}function Fy(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function Uy(o,l){var m=Fy(o);o=0;for(var w;m;){if(m.nodeType===3){if(w=o+m.textContent.length,o<=l&&w>=l)return{node:m,offset:l-o};o=w}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=Fy(m)}}function Wy(o,l){return o&&l?o===l?!0:o&&o.nodeType===3?!1:l&&l.nodeType===3?Wy(o,l.parentNode):"contains"in o?o.contains(l):o.compareDocumentPosition?!!(o.compareDocumentPosition(l)&16):!1:!1}function Hy(){for(var o=window,l=ke();l instanceof o.HTMLIFrameElement;){try{var m=typeof l.contentWindow.location.href=="string"}catch{m=!1}if(m)o=l.contentWindow;else break;l=ke(o.document)}return l}function uh(o){var l=o&&o.nodeName&&o.nodeName.toLowerCase();return l&&(l==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||l==="textarea"||o.contentEditable==="true")}function H$(o){var l=Hy(),m=o.focusedElem,w=o.selectionRange;if(l!==m&&m&&m.ownerDocument&&Wy(m.ownerDocument.documentElement,m)){if(w!==null&&uh(m)){if(l=w.start,o=w.end,o===void 0&&(o=l),"selectionStart"in m)m.selectionStart=l,m.selectionEnd=Math.min(o,m.value.length);else if(o=(l=m.ownerDocument||document)&&l.defaultView||window,o.getSelection){o=o.getSelection();var C=m.textContent.length,T=Math.min(w.start,C);w=w.end===void 0?T:Math.min(w.end,C),!o.extend&&T>w&&(C=w,w=T,T=C),C=Uy(m,T);var L=Uy(m,w);C&&L&&(o.rangeCount!==1||o.anchorNode!==C.node||o.anchorOffset!==C.offset||o.focusNode!==L.node||o.focusOffset!==L.offset)&&(l=l.createRange(),l.setStart(C.node,C.offset),o.removeAllRanges(),T>w?(o.addRange(l),o.extend(L.node,L.offset)):(l.setEnd(L.node,L.offset),o.addRange(l)))}}for(l=[],o=m;o=o.parentNode;)o.nodeType===1&&l.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<l.length;m++)o=l[m],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var B$=d&&"documentMode"in document&&11>=document.documentMode,li=null,fh=null,Ol=null,mh=!1;function By(o,l,m){var w=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;mh||li==null||li!==ke(w)||(w=li,"selectionStart"in w&&uh(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),Ol&&Al(Ol,w)||(Ol=w,w=zd(fh,"onSelect"),0<w.length&&(l=new sh("onSelect","select",null,l,m),o.push({event:l,listeners:w}),l.target=li)))}function Pd(o,l){var m={};return m[o.toLowerCase()]=l.toLowerCase(),m["Webkit"+o]="webkit"+l,m["Moz"+o]="moz"+l,m}var ci={animationend:Pd("Animation","AnimationEnd"),animationiteration:Pd("Animation","AnimationIteration"),animationstart:Pd("Animation","AnimationStart"),transitionend:Pd("Transition","TransitionEnd")},hh={},Gy={};d&&(Gy=document.createElement("div").style,"AnimationEvent"in window||(delete ci.animationend.animation,delete ci.animationiteration.animation,delete ci.animationstart.animation),"TransitionEvent"in window||delete ci.transitionend.transition);function Ld(o){if(hh[o])return hh[o];if(!ci[o])return o;var l=ci[o],m;for(m in l)if(l.hasOwnProperty(m)&&m in Gy)return hh[o]=l[m];return o}var qy=Ld("animationend"),Ky=Ld("animationiteration"),Vy=Ld("animationstart"),Yy=Ld("transitionend"),Qy=new Map,Jy="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 ho(o,l){Qy.set(o,l),i(l,[o])}for(var ph=0;ph<Jy.length;ph++){var gh=Jy[ph],G$=gh.toLowerCase(),q$=gh[0].toUpperCase()+gh.slice(1);ho(G$,"on"+q$)}ho(qy,"onAnimationEnd"),ho(Ky,"onAnimationIteration"),ho(Vy,"onAnimationStart"),ho("dblclick","onDoubleClick"),ho("focusin","onFocus"),ho("focusout","onBlur"),ho(Yy,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ml="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),K$=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ml));function Xy(o,l,m){var w=o.type||"unknown-event";o.currentTarget=m,te(w,l,void 0,o),o.currentTarget=null}function Zy(o,l){l=(l&4)!==0;for(var m=0;m<o.length;m++){var w=o[m],C=w.event;w=w.listeners;e:{var T=void 0;if(l)for(var L=w.length-1;0<=L;L--){var V=w[L],X=V.instance,ce=V.currentTarget;if(V=V.listener,X!==T&&C.isPropagationStopped())break e;Xy(C,V,ce),T=X}else for(L=0;L<w.length;L++){if(V=w[L],X=V.instance,ce=V.currentTarget,V=V.listener,X!==T&&C.isPropagationStopped())break e;Xy(C,V,ce),T=X}}}if(Hn)throw o=_s,Hn=!1,_s=null,o}function Wt(o,l){var m=l[Nh];m===void 0&&(m=l[Nh]=new Set);var w=o+"__bubble";m.has(w)||(eb(l,o,2,!1),m.add(w))}function xh(o,l,m){var w=0;l&&(w|=4),eb(m,o,w,l)}var Id="_reactListening"+Math.random().toString(36).slice(2);function Pl(o){if(!o[Id]){o[Id]=!0,r.forEach(function(m){m!=="selectionchange"&&(K$.has(m)||xh(m,!1,o),xh(m,!0,o))});var l=o.nodeType===9?o:o.ownerDocument;l===null||l[Id]||(l[Id]=!0,xh("selectionchange",!1,l))}}function eb(o,l,m,w){switch(ky(l)){case 1:var C=fo;break;case 4:C=fr;break;default:C=eh}m=C.bind(null,l,m,o),C=void 0,!ps||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(C=!0),w?C!==void 0?o.addEventListener(l,m,{capture:!0,passive:C}):o.addEventListener(l,m,!0):C!==void 0?o.addEventListener(l,m,{passive:C}):o.addEventListener(l,m,!1)}function vh(o,l,m,w,C){var T=w;if((l&1)===0&&(l&2)===0&&w!==null)e:for(;;){if(w===null)return;var L=w.tag;if(L===3||L===4){var V=w.stateNode.containerInfo;if(V===C||V.nodeType===8&&V.parentNode===C)break;if(L===4)for(L=w.return;L!==null;){var X=L.tag;if((X===3||X===4)&&(X=L.stateNode.containerInfo,X===C||X.nodeType===8&&X.parentNode===C))return;L=L.return}for(;V!==null;){if(L=la(V),L===null)return;if(X=L.tag,X===5||X===6){w=T=L;continue e}V=V.parentNode}}w=w.return}Cn(function(){var ce=T,we=pt(m),Ne=[];e:{var be=Qy.get(o);if(be!==void 0){var Ue=sh,Ke=o;switch(o){case"keypress":if(Rd(m)===0)break e;case"keydown":case"keyup":Ue=k$;break;case"focusin":Ke="focus",Ue=ah;break;case"focusout":Ke="blur",Ue=ah;break;case"beforeblur":case"afterblur":Ue=ah;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ue=Cy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ue=u$;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ue=C$;break;case qy:case Ky:case Vy:Ue=h$;break;case Yy:Ue=$$;break;case"scroll":Ue=c$;break;case"wheel":Ue=T$;break;case"copy":case"cut":case"paste":Ue=g$;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ue=$y}var Ye=(l&4)!==0,nn=!Ye&&o==="scroll",ie=Ye?be!==null?be+"Capture":null:be;Ye=[];for(var se=ce,le;se!==null;){le=se;var _e=le.stateNode;if(le.tag===5&&_e!==null&&(le=_e,ie!==null&&(_e=Un(se,ie),_e!=null&&Ye.push(Ll(se,_e,le)))),nn)break;se=se.return}0<Ye.length&&(be=new Ue(be,Ke,null,m,we),Ne.push({event:be,listeners:Ye}))}}if((l&7)===0){e:{if(be=o==="mouseover"||o==="pointerover",Ue=o==="mouseout"||o==="pointerout",be&&m!==Xe&&(Ke=m.relatedTarget||m.fromElement)&&(la(Ke)||Ke[Mr]))break e;if((Ue||be)&&(be=we.window===we?we:(be=we.ownerDocument)?be.defaultView||be.parentWindow:window,Ue?(Ke=m.relatedTarget||m.toElement,Ue=ce,Ke=Ke?la(Ke):null,Ke!==null&&(nn=Oe(Ke),Ke!==nn||Ke.tag!==5&&Ke.tag!==6)&&(Ke=null)):(Ue=null,Ke=ce),Ue!==Ke)){if(Ye=Cy,_e="onMouseLeave",ie="onMouseEnter",se="mouse",(o==="pointerout"||o==="pointerover")&&(Ye=$y,_e="onPointerLeave",ie="onPointerEnter",se="pointer"),nn=Ue==null?be:fi(Ue),le=Ke==null?be:fi(Ke),be=new Ye(_e,se+"leave",Ue,m,we),be.target=nn,be.relatedTarget=le,_e=null,la(we)===ce&&(Ye=new Ye(ie,se+"enter",Ke,m,we),Ye.target=le,Ye.relatedTarget=nn,_e=Ye),nn=_e,Ue&&Ke)t:{for(Ye=Ue,ie=Ke,se=0,le=Ye;le;le=di(le))se++;for(le=0,_e=ie;_e;_e=di(_e))le++;for(;0<se-le;)Ye=di(Ye),se--;for(;0<le-se;)ie=di(ie),le--;for(;se--;){if(Ye===ie||ie!==null&&Ye===ie.alternate)break t;Ye=di(Ye),ie=di(ie)}Ye=null}else Ye=null;Ue!==null&&tb(Ne,be,Ue,Ye,!1),Ke!==null&&nn!==null&&tb(Ne,nn,Ke,Ye,!0)}}e:{if(be=ce?fi(ce):window,Ue=be.nodeName&&be.nodeName.toLowerCase(),Ue==="select"||Ue==="input"&&be.type==="file")var Je=I$;else if(My(be))if(Ly)Je=U$;else{Je=D$;var tt=z$}else(Ue=be.nodeName)&&Ue.toLowerCase()==="input"&&(be.type==="checkbox"||be.type==="radio")&&(Je=F$);if(Je&&(Je=Je(o,ce))){Py(Ne,Je,m,we);break e}tt&&tt(o,be,ce),o==="focusout"&&(tt=be._wrapperState)&&tt.controlled&&be.type==="number"&&vt(be,"number",be.value)}switch(tt=ce?fi(ce):window,o){case"focusin":(My(tt)||tt.contentEditable==="true")&&(li=tt,fh=ce,Ol=null);break;case"focusout":Ol=fh=li=null;break;case"mousedown":mh=!0;break;case"contextmenu":case"mouseup":case"dragend":mh=!1,By(Ne,m,we);break;case"selectionchange":if(B$)break;case"keydown":case"keyup":By(Ne,m,we)}var nt;if(lh)e:{switch(o){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else ii?Ay(o,m)&&(lt="onCompositionEnd"):o==="keydown"&&m.keyCode===229&&(lt="onCompositionStart");lt&&(_y&&m.locale!=="ko"&&(ii||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&ii&&(nt=Ny()):(mo=we,nh="value"in mo?mo.value:mo.textContent,ii=!0)),tt=zd(ce,lt),0<tt.length&&(lt=new Ey(lt,o,null,m,we),Ne.push({event:lt,listeners:tt}),nt?lt.data=nt:(nt=Oy(m),nt!==null&&(lt.data=nt)))),(nt=A$?O$(o,m):M$(o,m))&&(ce=zd(ce,"onBeforeInput"),0<ce.length&&(we=new Ey("onBeforeInput","beforeinput",null,m,we),Ne.push({event:we,listeners:ce}),we.data=nt))}Zy(Ne,l)})}function Ll(o,l,m){return{instance:o,listener:l,currentTarget:m}}function zd(o,l){for(var m=l+"Capture",w=[];o!==null;){var C=o,T=C.stateNode;C.tag===5&&T!==null&&(C=T,T=Un(o,m),T!=null&&w.unshift(Ll(o,T,C)),T=Un(o,l),T!=null&&w.push(Ll(o,T,C))),o=o.return}return w}function di(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function tb(o,l,m,w,C){for(var T=l._reactName,L=[];m!==null&&m!==w;){var V=m,X=V.alternate,ce=V.stateNode;if(X!==null&&X===w)break;V.tag===5&&ce!==null&&(V=ce,C?(X=Un(m,T),X!=null&&L.unshift(Ll(m,X,V))):C||(X=Un(m,T),X!=null&&L.push(Ll(m,X,V)))),m=m.return}L.length!==0&&o.push({event:l,listeners:L})}var V$=/\r\n?/g,Y$=/\u0000|\uFFFD/g;function nb(o){return(typeof o=="string"?o:""+o).replace(V$,`
|
|
38
|
+
`).replace(Y$,"")}function Dd(o,l,m){if(l=nb(l),nb(o)!==l&&m)throw Error(s(425))}function Fd(){}var yh=null,bh=null;function wh(o,l){return o==="textarea"||o==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var jh=typeof setTimeout=="function"?setTimeout:void 0,Q$=typeof clearTimeout=="function"?clearTimeout:void 0,sb=typeof Promise=="function"?Promise:void 0,J$=typeof queueMicrotask=="function"?queueMicrotask:typeof sb<"u"?function(o){return sb.resolve(null).then(o).catch(X$)}:jh;function X$(o){setTimeout(function(){throw o})}function kh(o,l){var m=l,w=0;do{var C=m.nextSibling;if(o.removeChild(m),C&&C.nodeType===8)if(m=C.data,m==="/$"){if(w===0){o.removeChild(C),uo(l);return}w--}else m!=="$"&&m!=="$?"&&m!=="$!"||w++;m=C}while(m);uo(l)}function po(o){for(;o!=null;o=o.nextSibling){var l=o.nodeType;if(l===1||l===3)break;if(l===8){if(l=o.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return o}function rb(o){o=o.previousSibling;for(var l=0;o;){if(o.nodeType===8){var m=o.data;if(m==="$"||m==="$!"||m==="$?"){if(l===0)return o;l--}else m==="/$"&&l++}o=o.previousSibling}return null}var ui=Math.random().toString(36).slice(2),mr="__reactFiber$"+ui,Il="__reactProps$"+ui,Mr="__reactContainer$"+ui,Nh="__reactEvents$"+ui,Z$="__reactListeners$"+ui,e_="__reactHandles$"+ui;function la(o){var l=o[mr];if(l)return l;for(var m=o.parentNode;m;){if(l=m[Mr]||m[mr]){if(m=l.alternate,l.child!==null||m!==null&&m.child!==null)for(o=rb(o);o!==null;){if(m=o[mr])return m;o=rb(o)}return l}o=m,m=o.parentNode}return null}function zl(o){return o=o[mr]||o[Mr],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function fi(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(s(33))}function Ud(o){return o[Il]||null}var Sh=[],mi=-1;function go(o){return{current:o}}function Ht(o){0>mi||(o.current=Sh[mi],Sh[mi]=null,mi--)}function zt(o,l){mi++,Sh[mi]=o.current,o.current=l}var xo={},On=go(xo),os=go(!1),ca=xo;function hi(o,l){var m=o.type.contextTypes;if(!m)return xo;var w=o.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===l)return w.__reactInternalMemoizedMaskedChildContext;var C={},T;for(T in m)C[T]=l[T];return w&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=l,o.__reactInternalMemoizedMaskedChildContext=C),C}function as(o){return o=o.childContextTypes,o!=null}function Wd(){Ht(os),Ht(On)}function ob(o,l,m){if(On.current!==xo)throw Error(s(168));zt(On,l),zt(os,m)}function ab(o,l,m){var w=o.stateNode;if(l=l.childContextTypes,typeof w.getChildContext!="function")return m;w=w.getChildContext();for(var C in w)if(!(C in l))throw Error(s(108,fe(o)||"Unknown",C));return U({},m,w)}function Hd(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||xo,ca=On.current,zt(On,o),zt(os,os.current),!0}function ib(o,l,m){var w=o.stateNode;if(!w)throw Error(s(169));m?(o=ab(o,l,ca),w.__reactInternalMemoizedMergedChildContext=o,Ht(os),Ht(On),zt(On,o)):Ht(os),zt(os,m)}var Pr=null,Bd=!1,Ch=!1;function lb(o){Pr===null?Pr=[o]:Pr.push(o)}function t_(o){Bd=!0,lb(o)}function vo(){if(!Ch&&Pr!==null){Ch=!0;var o=0,l=$t;try{var m=Pr;for($t=1;o<m.length;o++){var w=m[o];do w=w(!0);while(w!==null)}Pr=null,Bd=!1}catch(C){throw Pr!==null&&(Pr=Pr.slice(o+1)),ye(En,vo),C}finally{$t=l,Ch=!1}}return null}var pi=[],gi=0,Gd=null,qd=0,Rs=[],As=0,da=null,Lr=1,Ir="";function ua(o,l){pi[gi++]=qd,pi[gi++]=Gd,Gd=o,qd=l}function cb(o,l,m){Rs[As++]=Lr,Rs[As++]=Ir,Rs[As++]=da,da=o;var w=Lr;o=Ir;var C=32-ss(w)-1;w&=~(1<<C),m+=1;var T=32-ss(l)+C;if(30<T){var L=C-C%5;T=(w&(1<<L)-1).toString(32),w>>=L,C-=L,Lr=1<<32-ss(l)+C|m<<C|w,Ir=T+o}else Lr=1<<T|m<<C|w,Ir=o}function Eh(o){o.return!==null&&(ua(o,1),cb(o,1,0))}function $h(o){for(;o===Gd;)Gd=pi[--gi],pi[gi]=null,qd=pi[--gi],pi[gi]=null;for(;o===da;)da=Rs[--As],Rs[As]=null,Ir=Rs[--As],Rs[As]=null,Lr=Rs[--As],Rs[As]=null}var ys=null,bs=null,Gt=!1,er=null;function db(o,l){var m=Ls(5,null,null,0);m.elementType="DELETED",m.stateNode=l,m.return=o,l=o.deletions,l===null?(o.deletions=[m],o.flags|=16):l.push(m)}function ub(o,l){switch(o.tag){case 5:var m=o.type;return l=l.nodeType!==1||m.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(o.stateNode=l,ys=o,bs=po(l.firstChild),!0):!1;case 6:return l=o.pendingProps===""||l.nodeType!==3?null:l,l!==null?(o.stateNode=l,ys=o,bs=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(m=da!==null?{id:Lr,overflow:Ir}:null,o.memoizedState={dehydrated:l,treeContext:m,retryLane:1073741824},m=Ls(18,null,null,0),m.stateNode=l,m.return=o,o.child=m,ys=o,bs=null,!0):!1;default:return!1}}function _h(o){return(o.mode&1)!==0&&(o.flags&128)===0}function Th(o){if(Gt){var l=bs;if(l){var m=l;if(!ub(o,l)){if(_h(o))throw Error(s(418));l=po(m.nextSibling);var w=ys;l&&ub(o,l)?db(w,m):(o.flags=o.flags&-4097|2,Gt=!1,ys=o)}}else{if(_h(o))throw Error(s(418));o.flags=o.flags&-4097|2,Gt=!1,ys=o}}}function fb(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;ys=o}function Kd(o){if(o!==ys)return!1;if(!Gt)return fb(o),Gt=!0,!1;var l;if((l=o.tag!==3)&&!(l=o.tag!==5)&&(l=o.type,l=l!=="head"&&l!=="body"&&!wh(o.type,o.memoizedProps)),l&&(l=bs)){if(_h(o))throw mb(),Error(s(418));for(;l;)db(o,l),l=po(l.nextSibling)}if(fb(o),o.tag===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(s(317));e:{for(o=o.nextSibling,l=0;o;){if(o.nodeType===8){var m=o.data;if(m==="/$"){if(l===0){bs=po(o.nextSibling);break e}l--}else m!=="$"&&m!=="$!"&&m!=="$?"||l++}o=o.nextSibling}bs=null}}else bs=ys?po(o.stateNode.nextSibling):null;return!0}function mb(){for(var o=bs;o;)o=po(o.nextSibling)}function xi(){bs=ys=null,Gt=!1}function Rh(o){er===null?er=[o]:er.push(o)}var n_=N.ReactCurrentBatchConfig;function Dl(o,l,m){if(o=m.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(s(309));var w=m.stateNode}if(!w)throw Error(s(147,o));var C=w,T=""+o;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===T?l.ref:(l=function(L){var V=C.refs;L===null?delete V[T]:V[T]=L},l._stringRef=T,l)}if(typeof o!="string")throw Error(s(284));if(!m._owner)throw Error(s(290,o))}return o}function Vd(o,l){throw o=Object.prototype.toString.call(l),Error(s(31,o==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":o))}function hb(o){var l=o._init;return l(o._payload)}function pb(o){function l(ie,se){if(o){var le=ie.deletions;le===null?(ie.deletions=[se],ie.flags|=16):le.push(se)}}function m(ie,se){if(!o)return null;for(;se!==null;)l(ie,se),se=se.sibling;return null}function w(ie,se){for(ie=new Map;se!==null;)se.key!==null?ie.set(se.key,se):ie.set(se.index,se),se=se.sibling;return ie}function C(ie,se){return ie=Co(ie,se),ie.index=0,ie.sibling=null,ie}function T(ie,se,le){return ie.index=le,o?(le=ie.alternate,le!==null?(le=le.index,le<se?(ie.flags|=2,se):le):(ie.flags|=2,se)):(ie.flags|=1048576,se)}function L(ie){return o&&ie.alternate===null&&(ie.flags|=2),ie}function V(ie,se,le,_e){return se===null||se.tag!==6?(se=jp(le,ie.mode,_e),se.return=ie,se):(se=C(se,le),se.return=ie,se)}function X(ie,se,le,_e){var Je=le.type;return Je===O?we(ie,se,le.props.children,_e,le.key):se!==null&&(se.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===H&&hb(Je)===se.type)?(_e=C(se,le.props),_e.ref=Dl(ie,se,le),_e.return=ie,_e):(_e=vu(le.type,le.key,le.props,null,ie.mode,_e),_e.ref=Dl(ie,se,le),_e.return=ie,_e)}function ce(ie,se,le,_e){return se===null||se.tag!==4||se.stateNode.containerInfo!==le.containerInfo||se.stateNode.implementation!==le.implementation?(se=kp(le,ie.mode,_e),se.return=ie,se):(se=C(se,le.children||[]),se.return=ie,se)}function we(ie,se,le,_e,Je){return se===null||se.tag!==7?(se=ya(le,ie.mode,_e,Je),se.return=ie,se):(se=C(se,le),se.return=ie,se)}function Ne(ie,se,le){if(typeof se=="string"&&se!==""||typeof se=="number")return se=jp(""+se,ie.mode,le),se.return=ie,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case _:return le=vu(se.type,se.key,se.props,null,ie.mode,le),le.ref=Dl(ie,null,se),le.return=ie,le;case E:return se=kp(se,ie.mode,le),se.return=ie,se;case H:var _e=se._init;return Ne(ie,_e(se._payload),le)}if(st(se)||G(se))return se=ya(se,ie.mode,le,null),se.return=ie,se;Vd(ie,se)}return null}function be(ie,se,le,_e){var Je=se!==null?se.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Je!==null?null:V(ie,se,""+le,_e);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case _:return le.key===Je?X(ie,se,le,_e):null;case E:return le.key===Je?ce(ie,se,le,_e):null;case H:return Je=le._init,be(ie,se,Je(le._payload),_e)}if(st(le)||G(le))return Je!==null?null:we(ie,se,le,_e,null);Vd(ie,le)}return null}function Ue(ie,se,le,_e,Je){if(typeof _e=="string"&&_e!==""||typeof _e=="number")return ie=ie.get(le)||null,V(se,ie,""+_e,Je);if(typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case _:return ie=ie.get(_e.key===null?le:_e.key)||null,X(se,ie,_e,Je);case E:return ie=ie.get(_e.key===null?le:_e.key)||null,ce(se,ie,_e,Je);case H:var tt=_e._init;return Ue(ie,se,le,tt(_e._payload),Je)}if(st(_e)||G(_e))return ie=ie.get(le)||null,we(se,ie,_e,Je,null);Vd(se,_e)}return null}function Ke(ie,se,le,_e){for(var Je=null,tt=null,nt=se,lt=se=0,jn=null;nt!==null&<<le.length;lt++){nt.index>lt?(jn=nt,nt=null):jn=nt.sibling;var Tt=be(ie,nt,le[lt],_e);if(Tt===null){nt===null&&(nt=jn);break}o&&nt&&Tt.alternate===null&&l(ie,nt),se=T(Tt,se,lt),tt===null?Je=Tt:tt.sibling=Tt,tt=Tt,nt=jn}if(lt===le.length)return m(ie,nt),Gt&&ua(ie,lt),Je;if(nt===null){for(;lt<le.length;lt++)nt=Ne(ie,le[lt],_e),nt!==null&&(se=T(nt,se,lt),tt===null?Je=nt:tt.sibling=nt,tt=nt);return Gt&&ua(ie,lt),Je}for(nt=w(ie,nt);lt<le.length;lt++)jn=Ue(nt,ie,lt,le[lt],_e),jn!==null&&(o&&jn.alternate!==null&&nt.delete(jn.key===null?lt:jn.key),se=T(jn,se,lt),tt===null?Je=jn:tt.sibling=jn,tt=jn);return o&&nt.forEach(function(Eo){return l(ie,Eo)}),Gt&&ua(ie,lt),Je}function Ye(ie,se,le,_e){var Je=G(le);if(typeof Je!="function")throw Error(s(150));if(le=Je.call(le),le==null)throw Error(s(151));for(var tt=Je=null,nt=se,lt=se=0,jn=null,Tt=le.next();nt!==null&&!Tt.done;lt++,Tt=le.next()){nt.index>lt?(jn=nt,nt=null):jn=nt.sibling;var Eo=be(ie,nt,Tt.value,_e);if(Eo===null){nt===null&&(nt=jn);break}o&&nt&&Eo.alternate===null&&l(ie,nt),se=T(Eo,se,lt),tt===null?Je=Eo:tt.sibling=Eo,tt=Eo,nt=jn}if(Tt.done)return m(ie,nt),Gt&&ua(ie,lt),Je;if(nt===null){for(;!Tt.done;lt++,Tt=le.next())Tt=Ne(ie,Tt.value,_e),Tt!==null&&(se=T(Tt,se,lt),tt===null?Je=Tt:tt.sibling=Tt,tt=Tt);return Gt&&ua(ie,lt),Je}for(nt=w(ie,nt);!Tt.done;lt++,Tt=le.next())Tt=Ue(nt,ie,lt,Tt.value,_e),Tt!==null&&(o&&Tt.alternate!==null&&nt.delete(Tt.key===null?lt:Tt.key),se=T(Tt,se,lt),tt===null?Je=Tt:tt.sibling=Tt,tt=Tt);return o&&nt.forEach(function(P_){return l(ie,P_)}),Gt&&ua(ie,lt),Je}function nn(ie,se,le,_e){if(typeof le=="object"&&le!==null&&le.type===O&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case _:e:{for(var Je=le.key,tt=se;tt!==null;){if(tt.key===Je){if(Je=le.type,Je===O){if(tt.tag===7){m(ie,tt.sibling),se=C(tt,le.props.children),se.return=ie,ie=se;break e}}else if(tt.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===H&&hb(Je)===tt.type){m(ie,tt.sibling),se=C(tt,le.props),se.ref=Dl(ie,tt,le),se.return=ie,ie=se;break e}m(ie,tt);break}else l(ie,tt);tt=tt.sibling}le.type===O?(se=ya(le.props.children,ie.mode,_e,le.key),se.return=ie,ie=se):(_e=vu(le.type,le.key,le.props,null,ie.mode,_e),_e.ref=Dl(ie,se,le),_e.return=ie,ie=_e)}return L(ie);case E:e:{for(tt=le.key;se!==null;){if(se.key===tt)if(se.tag===4&&se.stateNode.containerInfo===le.containerInfo&&se.stateNode.implementation===le.implementation){m(ie,se.sibling),se=C(se,le.children||[]),se.return=ie,ie=se;break e}else{m(ie,se);break}else l(ie,se);se=se.sibling}se=kp(le,ie.mode,_e),se.return=ie,ie=se}return L(ie);case H:return tt=le._init,nn(ie,se,tt(le._payload),_e)}if(st(le))return Ke(ie,se,le,_e);if(G(le))return Ye(ie,se,le,_e);Vd(ie,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,se!==null&&se.tag===6?(m(ie,se.sibling),se=C(se,le),se.return=ie,ie=se):(m(ie,se),se=jp(le,ie.mode,_e),se.return=ie,ie=se),L(ie)):m(ie,se)}return nn}var vi=pb(!0),gb=pb(!1),Yd=go(null),Qd=null,yi=null,Ah=null;function Oh(){Ah=yi=Qd=null}function Mh(o){var l=Yd.current;Ht(Yd),o._currentValue=l}function Ph(o,l,m){for(;o!==null;){var w=o.alternate;if((o.childLanes&l)!==l?(o.childLanes|=l,w!==null&&(w.childLanes|=l)):w!==null&&(w.childLanes&l)!==l&&(w.childLanes|=l),o===m)break;o=o.return}}function bi(o,l){Qd=o,Ah=yi=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&l)!==0&&(is=!0),o.firstContext=null)}function Os(o){var l=o._currentValue;if(Ah!==o)if(o={context:o,memoizedValue:l,next:null},yi===null){if(Qd===null)throw Error(s(308));yi=o,Qd.dependencies={lanes:0,firstContext:o}}else yi=yi.next=o;return l}var fa=null;function Lh(o){fa===null?fa=[o]:fa.push(o)}function xb(o,l,m,w){var C=l.interleaved;return C===null?(m.next=m,Lh(l)):(m.next=C.next,C.next=m),l.interleaved=m,zr(o,w)}function zr(o,l){o.lanes|=l;var m=o.alternate;for(m!==null&&(m.lanes|=l),m=o,o=o.return;o!==null;)o.childLanes|=l,m=o.alternate,m!==null&&(m.childLanes|=l),m=o,o=o.return;return m.tag===3?m.stateNode:null}var yo=!1;function Ih(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function vb(o,l){o=o.updateQueue,l.updateQueue===o&&(l.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function Dr(o,l){return{eventTime:o,lane:l,tag:0,payload:null,callback:null,next:null}}function bo(o,l,m){var w=o.updateQueue;if(w===null)return null;if(w=w.shared,(Et&2)!==0){var C=w.pending;return C===null?l.next=l:(l.next=C.next,C.next=l),w.pending=l,zr(o,m)}return C=w.interleaved,C===null?(l.next=l,Lh(w)):(l.next=C.next,C.next=l),w.interleaved=l,zr(o,m)}function Jd(o,l,m){if(l=l.updateQueue,l!==null&&(l=l.shared,(m&4194240)!==0)){var w=l.lanes;w&=o.pendingLanes,m|=w,l.lanes=m,ni(o,m)}}function yb(o,l){var m=o.updateQueue,w=o.alternate;if(w!==null&&(w=w.updateQueue,m===w)){var C=null,T=null;if(m=m.firstBaseUpdate,m!==null){do{var L={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};T===null?C=T=L:T=T.next=L,m=m.next}while(m!==null);T===null?C=T=l:T=T.next=l}else C=T=l;m={baseState:w.baseState,firstBaseUpdate:C,lastBaseUpdate:T,shared:w.shared,effects:w.effects},o.updateQueue=m;return}o=m.lastBaseUpdate,o===null?m.firstBaseUpdate=l:o.next=l,m.lastBaseUpdate=l}function Xd(o,l,m,w){var C=o.updateQueue;yo=!1;var T=C.firstBaseUpdate,L=C.lastBaseUpdate,V=C.shared.pending;if(V!==null){C.shared.pending=null;var X=V,ce=X.next;X.next=null,L===null?T=ce:L.next=ce,L=X;var we=o.alternate;we!==null&&(we=we.updateQueue,V=we.lastBaseUpdate,V!==L&&(V===null?we.firstBaseUpdate=ce:V.next=ce,we.lastBaseUpdate=X))}if(T!==null){var Ne=C.baseState;L=0,we=ce=X=null,V=T;do{var be=V.lane,Ue=V.eventTime;if((w&be)===be){we!==null&&(we=we.next={eventTime:Ue,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var Ke=o,Ye=V;switch(be=l,Ue=m,Ye.tag){case 1:if(Ke=Ye.payload,typeof Ke=="function"){Ne=Ke.call(Ue,Ne,be);break e}Ne=Ke;break e;case 3:Ke.flags=Ke.flags&-65537|128;case 0:if(Ke=Ye.payload,be=typeof Ke=="function"?Ke.call(Ue,Ne,be):Ke,be==null)break e;Ne=U({},Ne,be);break e;case 2:yo=!0}}V.callback!==null&&V.lane!==0&&(o.flags|=64,be=C.effects,be===null?C.effects=[V]:be.push(V))}else Ue={eventTime:Ue,lane:be,tag:V.tag,payload:V.payload,callback:V.callback,next:null},we===null?(ce=we=Ue,X=Ne):we=we.next=Ue,L|=be;if(V=V.next,V===null){if(V=C.shared.pending,V===null)break;be=V,V=be.next,be.next=null,C.lastBaseUpdate=be,C.shared.pending=null}}while(!0);if(we===null&&(X=Ne),C.baseState=X,C.firstBaseUpdate=ce,C.lastBaseUpdate=we,l=C.shared.interleaved,l!==null){C=l;do L|=C.lane,C=C.next;while(C!==l)}else T===null&&(C.shared.lanes=0);pa|=L,o.lanes=L,o.memoizedState=Ne}}function bb(o,l,m){if(o=l.effects,l.effects=null,o!==null)for(l=0;l<o.length;l++){var w=o[l],C=w.callback;if(C!==null){if(w.callback=null,w=m,typeof C!="function")throw Error(s(191,C));C.call(w)}}}var Fl={},hr=go(Fl),Ul=go(Fl),Wl=go(Fl);function ma(o){if(o===Fl)throw Error(s(174));return o}function zh(o,l){switch(zt(Wl,l),zt(Ul,o),zt(hr,Fl),o=l.nodeType,o){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:ot(null,"");break;default:o=o===8?l.parentNode:l,l=o.namespaceURI||null,o=o.tagName,l=ot(l,o)}Ht(hr),zt(hr,l)}function wi(){Ht(hr),Ht(Ul),Ht(Wl)}function wb(o){ma(Wl.current);var l=ma(hr.current),m=ot(l,o.type);l!==m&&(zt(Ul,o),zt(hr,m))}function Dh(o){Ul.current===o&&(Ht(hr),Ht(Ul))}var Yt=go(0);function Zd(o){for(var l=o;l!==null;){if(l.tag===13){var m=l.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Fh=[];function Uh(){for(var o=0;o<Fh.length;o++)Fh[o]._workInProgressVersionPrimary=null;Fh.length=0}var eu=N.ReactCurrentDispatcher,Wh=N.ReactCurrentBatchConfig,ha=0,Qt=null,gn=null,bn=null,tu=!1,Hl=!1,Bl=0,s_=0;function Mn(){throw Error(s(321))}function Hh(o,l){if(l===null)return!1;for(var m=0;m<l.length&&m<o.length;m++)if(!Zs(o[m],l[m]))return!1;return!0}function Bh(o,l,m,w,C,T){if(ha=T,Qt=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,eu.current=o===null||o.memoizedState===null?i_:l_,o=m(w,C),Hl){T=0;do{if(Hl=!1,Bl=0,25<=T)throw Error(s(301));T+=1,bn=gn=null,l.updateQueue=null,eu.current=c_,o=m(w,C)}while(Hl)}if(eu.current=ru,l=gn!==null&&gn.next!==null,ha=0,bn=gn=Qt=null,tu=!1,l)throw Error(s(300));return o}function Gh(){var o=Bl!==0;return Bl=0,o}function pr(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return bn===null?Qt.memoizedState=bn=o:bn=bn.next=o,bn}function Ms(){if(gn===null){var o=Qt.alternate;o=o!==null?o.memoizedState:null}else o=gn.next;var l=bn===null?Qt.memoizedState:bn.next;if(l!==null)bn=l,gn=o;else{if(o===null)throw Error(s(310));gn=o,o={memoizedState:gn.memoizedState,baseState:gn.baseState,baseQueue:gn.baseQueue,queue:gn.queue,next:null},bn===null?Qt.memoizedState=bn=o:bn=bn.next=o}return bn}function Gl(o,l){return typeof l=="function"?l(o):l}function qh(o){var l=Ms(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=o;var w=gn,C=w.baseQueue,T=m.pending;if(T!==null){if(C!==null){var L=C.next;C.next=T.next,T.next=L}w.baseQueue=C=T,m.pending=null}if(C!==null){T=C.next,w=w.baseState;var V=L=null,X=null,ce=T;do{var we=ce.lane;if((ha&we)===we)X!==null&&(X=X.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),w=ce.hasEagerState?ce.eagerState:o(w,ce.action);else{var Ne={lane:we,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};X===null?(V=X=Ne,L=w):X=X.next=Ne,Qt.lanes|=we,pa|=we}ce=ce.next}while(ce!==null&&ce!==T);X===null?L=w:X.next=V,Zs(w,l.memoizedState)||(is=!0),l.memoizedState=w,l.baseState=L,l.baseQueue=X,m.lastRenderedState=w}if(o=m.interleaved,o!==null){C=o;do T=C.lane,Qt.lanes|=T,pa|=T,C=C.next;while(C!==o)}else C===null&&(m.lanes=0);return[l.memoizedState,m.dispatch]}function Kh(o){var l=Ms(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=o;var w=m.dispatch,C=m.pending,T=l.memoizedState;if(C!==null){m.pending=null;var L=C=C.next;do T=o(T,L.action),L=L.next;while(L!==C);Zs(T,l.memoizedState)||(is=!0),l.memoizedState=T,l.baseQueue===null&&(l.baseState=T),m.lastRenderedState=T}return[T,w]}function jb(){}function kb(o,l){var m=Qt,w=Ms(),C=l(),T=!Zs(w.memoizedState,C);if(T&&(w.memoizedState=C,is=!0),w=w.queue,Vh(Cb.bind(null,m,w,o),[o]),w.getSnapshot!==l||T||bn!==null&&bn.memoizedState.tag&1){if(m.flags|=2048,ql(9,Sb.bind(null,m,w,C,l),void 0,null),wn===null)throw Error(s(349));(ha&30)!==0||Nb(m,l,C)}return C}function Nb(o,l,m){o.flags|=16384,o={getSnapshot:l,value:m},l=Qt.updateQueue,l===null?(l={lastEffect:null,stores:null},Qt.updateQueue=l,l.stores=[o]):(m=l.stores,m===null?l.stores=[o]:m.push(o))}function Sb(o,l,m,w){l.value=m,l.getSnapshot=w,Eb(l)&&$b(o)}function Cb(o,l,m){return m(function(){Eb(l)&&$b(o)})}function Eb(o){var l=o.getSnapshot;o=o.value;try{var m=l();return!Zs(o,m)}catch{return!0}}function $b(o){var l=zr(o,1);l!==null&&rr(l,o,1,-1)}function _b(o){var l=pr();return typeof o=="function"&&(o=o()),l.memoizedState=l.baseState=o,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Gl,lastRenderedState:o},l.queue=o,o=o.dispatch=a_.bind(null,Qt,o),[l.memoizedState,o]}function ql(o,l,m,w){return o={tag:o,create:l,destroy:m,deps:w,next:null},l=Qt.updateQueue,l===null?(l={lastEffect:null,stores:null},Qt.updateQueue=l,l.lastEffect=o.next=o):(m=l.lastEffect,m===null?l.lastEffect=o.next=o:(w=m.next,m.next=o,o.next=w,l.lastEffect=o)),o}function Tb(){return Ms().memoizedState}function nu(o,l,m,w){var C=pr();Qt.flags|=o,C.memoizedState=ql(1|l,m,void 0,w===void 0?null:w)}function su(o,l,m,w){var C=Ms();w=w===void 0?null:w;var T=void 0;if(gn!==null){var L=gn.memoizedState;if(T=L.destroy,w!==null&&Hh(w,L.deps)){C.memoizedState=ql(l,m,T,w);return}}Qt.flags|=o,C.memoizedState=ql(1|l,m,T,w)}function Rb(o,l){return nu(8390656,8,o,l)}function Vh(o,l){return su(2048,8,o,l)}function Ab(o,l){return su(4,2,o,l)}function Ob(o,l){return su(4,4,o,l)}function Mb(o,l){if(typeof l=="function")return o=o(),l(o),function(){l(null)};if(l!=null)return o=o(),l.current=o,function(){l.current=null}}function Pb(o,l,m){return m=m!=null?m.concat([o]):null,su(4,4,Mb.bind(null,l,o),m)}function Yh(){}function Lb(o,l){var m=Ms();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&Hh(l,w[1])?w[0]:(m.memoizedState=[o,l],o)}function Ib(o,l){var m=Ms();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&Hh(l,w[1])?w[0]:(o=o(),m.memoizedState=[o,l],o)}function zb(o,l,m){return(ha&21)===0?(o.baseState&&(o.baseState=!1,is=!0),o.memoizedState=m):(Zs(m,l)||(m=wl(),Qt.lanes|=m,pa|=m,o.baseState=!0),l)}function r_(o,l){var m=$t;$t=m!==0&&4>m?m:4,o(!0);var w=Wh.transition;Wh.transition={};try{o(!1),l()}finally{$t=m,Wh.transition=w}}function Db(){return Ms().memoizedState}function o_(o,l,m){var w=No(o);if(m={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null},Fb(o))Ub(l,m);else if(m=xb(o,l,m,w),m!==null){var C=Kn();rr(m,o,w,C),Wb(m,l,w)}}function a_(o,l,m){var w=No(o),C={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null};if(Fb(o))Ub(l,C);else{var T=o.alternate;if(o.lanes===0&&(T===null||T.lanes===0)&&(T=l.lastRenderedReducer,T!==null))try{var L=l.lastRenderedState,V=T(L,m);if(C.hasEagerState=!0,C.eagerState=V,Zs(V,L)){var X=l.interleaved;X===null?(C.next=C,Lh(l)):(C.next=X.next,X.next=C),l.interleaved=C;return}}catch{}finally{}m=xb(o,l,C,w),m!==null&&(C=Kn(),rr(m,o,w,C),Wb(m,l,w))}}function Fb(o){var l=o.alternate;return o===Qt||l!==null&&l===Qt}function Ub(o,l){Hl=tu=!0;var m=o.pending;m===null?l.next=l:(l.next=m.next,m.next=l),o.pending=l}function Wb(o,l,m){if((m&4194240)!==0){var w=l.lanes;w&=o.pendingLanes,m|=w,l.lanes=m,ni(o,m)}}var ru={readContext:Os,useCallback:Mn,useContext:Mn,useEffect:Mn,useImperativeHandle:Mn,useInsertionEffect:Mn,useLayoutEffect:Mn,useMemo:Mn,useReducer:Mn,useRef:Mn,useState:Mn,useDebugValue:Mn,useDeferredValue:Mn,useTransition:Mn,useMutableSource:Mn,useSyncExternalStore:Mn,useId:Mn,unstable_isNewReconciler:!1},i_={readContext:Os,useCallback:function(o,l){return pr().memoizedState=[o,l===void 0?null:l],o},useContext:Os,useEffect:Rb,useImperativeHandle:function(o,l,m){return m=m!=null?m.concat([o]):null,nu(4194308,4,Mb.bind(null,l,o),m)},useLayoutEffect:function(o,l){return nu(4194308,4,o,l)},useInsertionEffect:function(o,l){return nu(4,2,o,l)},useMemo:function(o,l){var m=pr();return l=l===void 0?null:l,o=o(),m.memoizedState=[o,l],o},useReducer:function(o,l,m){var w=pr();return l=m!==void 0?m(l):l,w.memoizedState=w.baseState=l,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:l},w.queue=o,o=o.dispatch=o_.bind(null,Qt,o),[w.memoizedState,o]},useRef:function(o){var l=pr();return o={current:o},l.memoizedState=o},useState:_b,useDebugValue:Yh,useDeferredValue:function(o){return pr().memoizedState=o},useTransition:function(){var o=_b(!1),l=o[0];return o=r_.bind(null,o[1]),pr().memoizedState=o,[l,o]},useMutableSource:function(){},useSyncExternalStore:function(o,l,m){var w=Qt,C=pr();if(Gt){if(m===void 0)throw Error(s(407));m=m()}else{if(m=l(),wn===null)throw Error(s(349));(ha&30)!==0||Nb(w,l,m)}C.memoizedState=m;var T={value:m,getSnapshot:l};return C.queue=T,Rb(Cb.bind(null,w,T,o),[o]),w.flags|=2048,ql(9,Sb.bind(null,w,T,m,l),void 0,null),m},useId:function(){var o=pr(),l=wn.identifierPrefix;if(Gt){var m=Ir,w=Lr;m=(w&~(1<<32-ss(w)-1)).toString(32)+m,l=":"+l+"R"+m,m=Bl++,0<m&&(l+="H"+m.toString(32)),l+=":"}else m=s_++,l=":"+l+"r"+m.toString(32)+":";return o.memoizedState=l},unstable_isNewReconciler:!1},l_={readContext:Os,useCallback:Lb,useContext:Os,useEffect:Vh,useImperativeHandle:Pb,useInsertionEffect:Ab,useLayoutEffect:Ob,useMemo:Ib,useReducer:qh,useRef:Tb,useState:function(){return qh(Gl)},useDebugValue:Yh,useDeferredValue:function(o){var l=Ms();return zb(l,gn.memoizedState,o)},useTransition:function(){var o=qh(Gl)[0],l=Ms().memoizedState;return[o,l]},useMutableSource:jb,useSyncExternalStore:kb,useId:Db,unstable_isNewReconciler:!1},c_={readContext:Os,useCallback:Lb,useContext:Os,useEffect:Vh,useImperativeHandle:Pb,useInsertionEffect:Ab,useLayoutEffect:Ob,useMemo:Ib,useReducer:Kh,useRef:Tb,useState:function(){return Kh(Gl)},useDebugValue:Yh,useDeferredValue:function(o){var l=Ms();return gn===null?l.memoizedState=o:zb(l,gn.memoizedState,o)},useTransition:function(){var o=Kh(Gl)[0],l=Ms().memoizedState;return[o,l]},useMutableSource:jb,useSyncExternalStore:kb,useId:Db,unstable_isNewReconciler:!1};function tr(o,l){if(o&&o.defaultProps){l=U({},l),o=o.defaultProps;for(var m in o)l[m]===void 0&&(l[m]=o[m]);return l}return l}function Qh(o,l,m,w){l=o.memoizedState,m=m(w,l),m=m==null?l:U({},l,m),o.memoizedState=m,o.lanes===0&&(o.updateQueue.baseState=m)}var ou={isMounted:function(o){return(o=o._reactInternals)?Oe(o)===o:!1},enqueueSetState:function(o,l,m){o=o._reactInternals;var w=Kn(),C=No(o),T=Dr(w,C);T.payload=l,m!=null&&(T.callback=m),l=bo(o,T,C),l!==null&&(rr(l,o,C,w),Jd(l,o,C))},enqueueReplaceState:function(o,l,m){o=o._reactInternals;var w=Kn(),C=No(o),T=Dr(w,C);T.tag=1,T.payload=l,m!=null&&(T.callback=m),l=bo(o,T,C),l!==null&&(rr(l,o,C,w),Jd(l,o,C))},enqueueForceUpdate:function(o,l){o=o._reactInternals;var m=Kn(),w=No(o),C=Dr(m,w);C.tag=2,l!=null&&(C.callback=l),l=bo(o,C,w),l!==null&&(rr(l,o,w,m),Jd(l,o,w))}};function Hb(o,l,m,w,C,T,L){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(w,T,L):l.prototype&&l.prototype.isPureReactComponent?!Al(m,w)||!Al(C,T):!0}function Bb(o,l,m){var w=!1,C=xo,T=l.contextType;return typeof T=="object"&&T!==null?T=Os(T):(C=as(l)?ca:On.current,w=l.contextTypes,T=(w=w!=null)?hi(o,C):xo),l=new l(m,T),o.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=ou,o.stateNode=l,l._reactInternals=o,w&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=C,o.__reactInternalMemoizedMaskedChildContext=T),l}function Gb(o,l,m,w){o=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(m,w),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(m,w),l.state!==o&&ou.enqueueReplaceState(l,l.state,null)}function Jh(o,l,m,w){var C=o.stateNode;C.props=m,C.state=o.memoizedState,C.refs={},Ih(o);var T=l.contextType;typeof T=="object"&&T!==null?C.context=Os(T):(T=as(l)?ca:On.current,C.context=hi(o,T)),C.state=o.memoizedState,T=l.getDerivedStateFromProps,typeof T=="function"&&(Qh(o,l,T,m),C.state=o.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(l=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),l!==C.state&&ou.enqueueReplaceState(C,C.state,null),Xd(o,m,C,w),C.state=o.memoizedState),typeof C.componentDidMount=="function"&&(o.flags|=4194308)}function ji(o,l){try{var m="",w=l;do m+=de(w),w=w.return;while(w);var C=m}catch(T){C=`
|
|
39
|
+
Error generating stack: `+T.message+`
|
|
40
|
+
`+T.stack}return{value:o,source:l,stack:C,digest:null}}function Xh(o,l,m){return{value:o,source:null,stack:m??null,digest:l??null}}function Zh(o,l){try{console.error(l.value)}catch(m){setTimeout(function(){throw m})}}var d_=typeof WeakMap=="function"?WeakMap:Map;function qb(o,l,m){m=Dr(-1,m),m.tag=3,m.payload={element:null};var w=l.value;return m.callback=function(){fu||(fu=!0,hp=w),Zh(o,l)},m}function Kb(o,l,m){m=Dr(-1,m),m.tag=3;var w=o.type.getDerivedStateFromError;if(typeof w=="function"){var C=l.value;m.payload=function(){return w(C)},m.callback=function(){Zh(o,l)}}var T=o.stateNode;return T!==null&&typeof T.componentDidCatch=="function"&&(m.callback=function(){Zh(o,l),typeof w!="function"&&(jo===null?jo=new Set([this]):jo.add(this));var L=l.stack;this.componentDidCatch(l.value,{componentStack:L!==null?L:""})}),m}function Vb(o,l,m){var w=o.pingCache;if(w===null){w=o.pingCache=new d_;var C=new Set;w.set(l,C)}else C=w.get(l),C===void 0&&(C=new Set,w.set(l,C));C.has(m)||(C.add(m),o=N_.bind(null,o,l,m),l.then(o,o))}function Yb(o){do{var l;if((l=o.tag===13)&&(l=o.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return o;o=o.return}while(o!==null);return null}function Qb(o,l,m,w,C){return(o.mode&1)===0?(o===l?o.flags|=65536:(o.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(l=Dr(-1,1),l.tag=2,bo(m,l,1))),m.lanes|=1),o):(o.flags|=65536,o.lanes=C,o)}var u_=N.ReactCurrentOwner,is=!1;function qn(o,l,m,w){l.child=o===null?gb(l,null,m,w):vi(l,o.child,m,w)}function Jb(o,l,m,w,C){m=m.render;var T=l.ref;return bi(l,C),w=Bh(o,l,m,w,T,C),m=Gh(),o!==null&&!is?(l.updateQueue=o.updateQueue,l.flags&=-2053,o.lanes&=~C,Fr(o,l,C)):(Gt&&m&&Eh(l),l.flags|=1,qn(o,l,w,C),l.child)}function Xb(o,l,m,w,C){if(o===null){var T=m.type;return typeof T=="function"&&!wp(T)&&T.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(l.tag=15,l.type=T,Zb(o,l,T,w,C)):(o=vu(m.type,null,w,l,l.mode,C),o.ref=l.ref,o.return=l,l.child=o)}if(T=o.child,(o.lanes&C)===0){var L=T.memoizedProps;if(m=m.compare,m=m!==null?m:Al,m(L,w)&&o.ref===l.ref)return Fr(o,l,C)}return l.flags|=1,o=Co(T,w),o.ref=l.ref,o.return=l,l.child=o}function Zb(o,l,m,w,C){if(o!==null){var T=o.memoizedProps;if(Al(T,w)&&o.ref===l.ref)if(is=!1,l.pendingProps=w=T,(o.lanes&C)!==0)(o.flags&131072)!==0&&(is=!0);else return l.lanes=o.lanes,Fr(o,l,C)}return ep(o,l,m,w,C)}function ew(o,l,m){var w=l.pendingProps,C=w.children,T=o!==null?o.memoizedState:null;if(w.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},zt(Ni,ws),ws|=m;else{if((m&1073741824)===0)return o=T!==null?T.baseLanes|m:m,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:o,cachePool:null,transitions:null},l.updateQueue=null,zt(Ni,ws),ws|=o,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=T!==null?T.baseLanes:m,zt(Ni,ws),ws|=w}else T!==null?(w=T.baseLanes|m,l.memoizedState=null):w=m,zt(Ni,ws),ws|=w;return qn(o,l,C,m),l.child}function tw(o,l){var m=l.ref;(o===null&&m!==null||o!==null&&o.ref!==m)&&(l.flags|=512,l.flags|=2097152)}function ep(o,l,m,w,C){var T=as(m)?ca:On.current;return T=hi(l,T),bi(l,C),m=Bh(o,l,m,w,T,C),w=Gh(),o!==null&&!is?(l.updateQueue=o.updateQueue,l.flags&=-2053,o.lanes&=~C,Fr(o,l,C)):(Gt&&w&&Eh(l),l.flags|=1,qn(o,l,m,C),l.child)}function nw(o,l,m,w,C){if(as(m)){var T=!0;Hd(l)}else T=!1;if(bi(l,C),l.stateNode===null)iu(o,l),Bb(l,m,w),Jh(l,m,w,C),w=!0;else if(o===null){var L=l.stateNode,V=l.memoizedProps;L.props=V;var X=L.context,ce=m.contextType;typeof ce=="object"&&ce!==null?ce=Os(ce):(ce=as(m)?ca:On.current,ce=hi(l,ce));var we=m.getDerivedStateFromProps,Ne=typeof we=="function"||typeof L.getSnapshotBeforeUpdate=="function";Ne||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(V!==w||X!==ce)&&Gb(l,L,w,ce),yo=!1;var be=l.memoizedState;L.state=be,Xd(l,w,L,C),X=l.memoizedState,V!==w||be!==X||os.current||yo?(typeof we=="function"&&(Qh(l,m,we,w),X=l.memoizedState),(V=yo||Hb(l,m,V,w,be,X,ce))?(Ne||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(l.flags|=4194308)):(typeof L.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=w,l.memoizedState=X),L.props=w,L.state=X,L.context=ce,w=V):(typeof L.componentDidMount=="function"&&(l.flags|=4194308),w=!1)}else{L=l.stateNode,vb(o,l),V=l.memoizedProps,ce=l.type===l.elementType?V:tr(l.type,V),L.props=ce,Ne=l.pendingProps,be=L.context,X=m.contextType,typeof X=="object"&&X!==null?X=Os(X):(X=as(m)?ca:On.current,X=hi(l,X));var Ue=m.getDerivedStateFromProps;(we=typeof Ue=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(V!==Ne||be!==X)&&Gb(l,L,w,X),yo=!1,be=l.memoizedState,L.state=be,Xd(l,w,L,C);var Ke=l.memoizedState;V!==Ne||be!==Ke||os.current||yo?(typeof Ue=="function"&&(Qh(l,m,Ue,w),Ke=l.memoizedState),(ce=yo||Hb(l,m,ce,w,be,Ke,X)||!1)?(we||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(w,Ke,X),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(w,Ke,X)),typeof L.componentDidUpdate=="function"&&(l.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof L.componentDidUpdate!="function"||V===o.memoizedProps&&be===o.memoizedState||(l.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||V===o.memoizedProps&&be===o.memoizedState||(l.flags|=1024),l.memoizedProps=w,l.memoizedState=Ke),L.props=w,L.state=Ke,L.context=X,w=ce):(typeof L.componentDidUpdate!="function"||V===o.memoizedProps&&be===o.memoizedState||(l.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||V===o.memoizedProps&&be===o.memoizedState||(l.flags|=1024),w=!1)}return tp(o,l,m,w,T,C)}function tp(o,l,m,w,C,T){tw(o,l);var L=(l.flags&128)!==0;if(!w&&!L)return C&&ib(l,m,!1),Fr(o,l,T);w=l.stateNode,u_.current=l;var V=L&&typeof m.getDerivedStateFromError!="function"?null:w.render();return l.flags|=1,o!==null&&L?(l.child=vi(l,o.child,null,T),l.child=vi(l,null,V,T)):qn(o,l,V,T),l.memoizedState=w.state,C&&ib(l,m,!0),l.child}function sw(o){var l=o.stateNode;l.pendingContext?ob(o,l.pendingContext,l.pendingContext!==l.context):l.context&&ob(o,l.context,!1),zh(o,l.containerInfo)}function rw(o,l,m,w,C){return xi(),Rh(C),l.flags|=256,qn(o,l,m,w),l.child}var np={dehydrated:null,treeContext:null,retryLane:0};function sp(o){return{baseLanes:o,cachePool:null,transitions:null}}function ow(o,l,m){var w=l.pendingProps,C=Yt.current,T=!1,L=(l.flags&128)!==0,V;if((V=L)||(V=o!==null&&o.memoizedState===null?!1:(C&2)!==0),V?(T=!0,l.flags&=-129):(o===null||o.memoizedState!==null)&&(C|=1),zt(Yt,C&1),o===null)return Th(l),o=l.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((l.mode&1)===0?l.lanes=1:o.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(L=w.children,o=w.fallback,T?(w=l.mode,T=l.child,L={mode:"hidden",children:L},(w&1)===0&&T!==null?(T.childLanes=0,T.pendingProps=L):T=yu(L,w,0,null),o=ya(o,w,m,null),T.return=l,o.return=l,T.sibling=o,l.child=T,l.child.memoizedState=sp(m),l.memoizedState=np,o):rp(l,L));if(C=o.memoizedState,C!==null&&(V=C.dehydrated,V!==null))return f_(o,l,L,w,V,C,m);if(T){T=w.fallback,L=l.mode,C=o.child,V=C.sibling;var X={mode:"hidden",children:w.children};return(L&1)===0&&l.child!==C?(w=l.child,w.childLanes=0,w.pendingProps=X,l.deletions=null):(w=Co(C,X),w.subtreeFlags=C.subtreeFlags&14680064),V!==null?T=Co(V,T):(T=ya(T,L,m,null),T.flags|=2),T.return=l,w.return=l,w.sibling=T,l.child=w,w=T,T=l.child,L=o.child.memoizedState,L=L===null?sp(m):{baseLanes:L.baseLanes|m,cachePool:null,transitions:L.transitions},T.memoizedState=L,T.childLanes=o.childLanes&~m,l.memoizedState=np,w}return T=o.child,o=T.sibling,w=Co(T,{mode:"visible",children:w.children}),(l.mode&1)===0&&(w.lanes=m),w.return=l,w.sibling=null,o!==null&&(m=l.deletions,m===null?(l.deletions=[o],l.flags|=16):m.push(o)),l.child=w,l.memoizedState=null,w}function rp(o,l){return l=yu({mode:"visible",children:l},o.mode,0,null),l.return=o,o.child=l}function au(o,l,m,w){return w!==null&&Rh(w),vi(l,o.child,null,m),o=rp(l,l.pendingProps.children),o.flags|=2,l.memoizedState=null,o}function f_(o,l,m,w,C,T,L){if(m)return l.flags&256?(l.flags&=-257,w=Xh(Error(s(422))),au(o,l,L,w)):l.memoizedState!==null?(l.child=o.child,l.flags|=128,null):(T=w.fallback,C=l.mode,w=yu({mode:"visible",children:w.children},C,0,null),T=ya(T,C,L,null),T.flags|=2,w.return=l,T.return=l,w.sibling=T,l.child=w,(l.mode&1)!==0&&vi(l,o.child,null,L),l.child.memoizedState=sp(L),l.memoizedState=np,T);if((l.mode&1)===0)return au(o,l,L,null);if(C.data==="$!"){if(w=C.nextSibling&&C.nextSibling.dataset,w)var V=w.dgst;return w=V,T=Error(s(419)),w=Xh(T,w,void 0),au(o,l,L,w)}if(V=(L&o.childLanes)!==0,is||V){if(w=wn,w!==null){switch(L&-L){case 4:C=2;break;case 16:C=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:C=32;break;case 536870912:C=268435456;break;default:C=0}C=(C&(w.suspendedLanes|L))!==0?0:C,C!==0&&C!==T.retryLane&&(T.retryLane=C,zr(o,C),rr(w,o,C,-1))}return bp(),w=Xh(Error(s(421))),au(o,l,L,w)}return C.data==="$?"?(l.flags|=128,l.child=o.child,l=S_.bind(null,o),C._reactRetry=l,null):(o=T.treeContext,bs=po(C.nextSibling),ys=l,Gt=!0,er=null,o!==null&&(Rs[As++]=Lr,Rs[As++]=Ir,Rs[As++]=da,Lr=o.id,Ir=o.overflow,da=l),l=rp(l,w.children),l.flags|=4096,l)}function aw(o,l,m){o.lanes|=l;var w=o.alternate;w!==null&&(w.lanes|=l),Ph(o.return,l,m)}function op(o,l,m,w,C){var T=o.memoizedState;T===null?o.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:w,tail:m,tailMode:C}:(T.isBackwards=l,T.rendering=null,T.renderingStartTime=0,T.last=w,T.tail=m,T.tailMode=C)}function iw(o,l,m){var w=l.pendingProps,C=w.revealOrder,T=w.tail;if(qn(o,l,w.children,m),w=Yt.current,(w&2)!==0)w=w&1|2,l.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=l.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&aw(o,m,l);else if(o.tag===19)aw(o,m,l);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===l)break e;for(;o.sibling===null;){if(o.return===null||o.return===l)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}w&=1}if(zt(Yt,w),(l.mode&1)===0)l.memoizedState=null;else switch(C){case"forwards":for(m=l.child,C=null;m!==null;)o=m.alternate,o!==null&&Zd(o)===null&&(C=m),m=m.sibling;m=C,m===null?(C=l.child,l.child=null):(C=m.sibling,m.sibling=null),op(l,!1,C,m,T);break;case"backwards":for(m=null,C=l.child,l.child=null;C!==null;){if(o=C.alternate,o!==null&&Zd(o)===null){l.child=C;break}o=C.sibling,C.sibling=m,m=C,C=o}op(l,!0,m,null,T);break;case"together":op(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function iu(o,l){(l.mode&1)===0&&o!==null&&(o.alternate=null,l.alternate=null,l.flags|=2)}function Fr(o,l,m){if(o!==null&&(l.dependencies=o.dependencies),pa|=l.lanes,(m&l.childLanes)===0)return null;if(o!==null&&l.child!==o.child)throw Error(s(153));if(l.child!==null){for(o=l.child,m=Co(o,o.pendingProps),l.child=m,m.return=l;o.sibling!==null;)o=o.sibling,m=m.sibling=Co(o,o.pendingProps),m.return=l;m.sibling=null}return l.child}function m_(o,l,m){switch(l.tag){case 3:sw(l),xi();break;case 5:wb(l);break;case 1:as(l.type)&&Hd(l);break;case 4:zh(l,l.stateNode.containerInfo);break;case 10:var w=l.type._context,C=l.memoizedProps.value;zt(Yd,w._currentValue),w._currentValue=C;break;case 13:if(w=l.memoizedState,w!==null)return w.dehydrated!==null?(zt(Yt,Yt.current&1),l.flags|=128,null):(m&l.child.childLanes)!==0?ow(o,l,m):(zt(Yt,Yt.current&1),o=Fr(o,l,m),o!==null?o.sibling:null);zt(Yt,Yt.current&1);break;case 19:if(w=(m&l.childLanes)!==0,(o.flags&128)!==0){if(w)return iw(o,l,m);l.flags|=128}if(C=l.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),zt(Yt,Yt.current),w)break;return null;case 22:case 23:return l.lanes=0,ew(o,l,m)}return Fr(o,l,m)}var lw,ap,cw,dw;lw=function(o,l){for(var m=l.child;m!==null;){if(m.tag===5||m.tag===6)o.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===l)break;for(;m.sibling===null;){if(m.return===null||m.return===l)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},ap=function(){},cw=function(o,l,m,w){var C=o.memoizedProps;if(C!==w){o=l.stateNode,ma(hr.current);var T=null;switch(m){case"input":C=$e(o,C),w=$e(o,w),T=[];break;case"select":C=U({},C,{value:void 0}),w=U({},w,{value:void 0}),T=[];break;case"textarea":C=Be(o,C),w=Be(o,w),T=[];break;default:typeof C.onClick!="function"&&typeof w.onClick=="function"&&(o.onclick=Fd)}Ze(m,w);var L;m=null;for(ce in C)if(!w.hasOwnProperty(ce)&&C.hasOwnProperty(ce)&&C[ce]!=null)if(ce==="style"){var V=C[ce];for(L in V)V.hasOwnProperty(L)&&(m||(m={}),m[L]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(a.hasOwnProperty(ce)?T||(T=[]):(T=T||[]).push(ce,null));for(ce in w){var X=w[ce];if(V=C!=null?C[ce]:void 0,w.hasOwnProperty(ce)&&X!==V&&(X!=null||V!=null))if(ce==="style")if(V){for(L in V)!V.hasOwnProperty(L)||X&&X.hasOwnProperty(L)||(m||(m={}),m[L]="");for(L in X)X.hasOwnProperty(L)&&V[L]!==X[L]&&(m||(m={}),m[L]=X[L])}else m||(T||(T=[]),T.push(ce,m)),m=X;else ce==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,V=V?V.__html:void 0,X!=null&&V!==X&&(T=T||[]).push(ce,X)):ce==="children"?typeof X!="string"&&typeof X!="number"||(T=T||[]).push(ce,""+X):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(a.hasOwnProperty(ce)?(X!=null&&ce==="onScroll"&&Wt("scroll",o),T||V===X||(T=[])):(T=T||[]).push(ce,X))}m&&(T=T||[]).push("style",m);var ce=T;(l.updateQueue=ce)&&(l.flags|=4)}},dw=function(o,l,m,w){m!==w&&(l.flags|=4)};function Kl(o,l){if(!Gt)switch(o.tailMode){case"hidden":l=o.tail;for(var m=null;l!==null;)l.alternate!==null&&(m=l),l=l.sibling;m===null?o.tail=null:m.sibling=null;break;case"collapsed":m=o.tail;for(var w=null;m!==null;)m.alternate!==null&&(w=m),m=m.sibling;w===null?l||o.tail===null?o.tail=null:o.tail.sibling=null:w.sibling=null}}function Pn(o){var l=o.alternate!==null&&o.alternate.child===o.child,m=0,w=0;if(l)for(var C=o.child;C!==null;)m|=C.lanes|C.childLanes,w|=C.subtreeFlags&14680064,w|=C.flags&14680064,C.return=o,C=C.sibling;else for(C=o.child;C!==null;)m|=C.lanes|C.childLanes,w|=C.subtreeFlags,w|=C.flags,C.return=o,C=C.sibling;return o.subtreeFlags|=w,o.childLanes=m,l}function h_(o,l,m){var w=l.pendingProps;switch($h(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pn(l),null;case 1:return as(l.type)&&Wd(),Pn(l),null;case 3:return w=l.stateNode,wi(),Ht(os),Ht(On),Uh(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(o===null||o.child===null)&&(Kd(l)?l.flags|=4:o===null||o.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,er!==null&&(xp(er),er=null))),ap(o,l),Pn(l),null;case 5:Dh(l);var C=ma(Wl.current);if(m=l.type,o!==null&&l.stateNode!=null)cw(o,l,m,w,C),o.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!w){if(l.stateNode===null)throw Error(s(166));return Pn(l),null}if(o=ma(hr.current),Kd(l)){w=l.stateNode,m=l.type;var T=l.memoizedProps;switch(w[mr]=l,w[Il]=T,o=(l.mode&1)!==0,m){case"dialog":Wt("cancel",w),Wt("close",w);break;case"iframe":case"object":case"embed":Wt("load",w);break;case"video":case"audio":for(C=0;C<Ml.length;C++)Wt(Ml[C],w);break;case"source":Wt("error",w);break;case"img":case"image":case"link":Wt("error",w),Wt("load",w);break;case"details":Wt("toggle",w);break;case"input":J(w,T),Wt("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!T.multiple},Wt("invalid",w);break;case"textarea":he(w,T),Wt("invalid",w)}Ze(m,T),C=null;for(var L in T)if(T.hasOwnProperty(L)){var V=T[L];L==="children"?typeof V=="string"?w.textContent!==V&&(T.suppressHydrationWarning!==!0&&Dd(w.textContent,V,o),C=["children",V]):typeof V=="number"&&w.textContent!==""+V&&(T.suppressHydrationWarning!==!0&&Dd(w.textContent,V,o),C=["children",""+V]):a.hasOwnProperty(L)&&V!=null&&L==="onScroll"&&Wt("scroll",w)}switch(m){case"input":pe(w),rt(w,T,!0);break;case"textarea":pe(w),ct(w);break;case"select":case"option":break;default:typeof T.onClick=="function"&&(w.onclick=Fd)}w=C,l.updateQueue=w,w!==null&&(l.flags|=4)}else{L=C.nodeType===9?C:C.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=Me(m)),o==="http://www.w3.org/1999/xhtml"?m==="script"?(o=L.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof w.is=="string"?o=L.createElement(m,{is:w.is}):(o=L.createElement(m),m==="select"&&(L=o,w.multiple?L.multiple=!0:w.size&&(L.size=w.size))):o=L.createElementNS(o,m),o[mr]=l,o[Il]=w,lw(o,l,!1,!1),l.stateNode=o;e:{switch(L=at(m,w),m){case"dialog":Wt("cancel",o),Wt("close",o),C=w;break;case"iframe":case"object":case"embed":Wt("load",o),C=w;break;case"video":case"audio":for(C=0;C<Ml.length;C++)Wt(Ml[C],o);C=w;break;case"source":Wt("error",o),C=w;break;case"img":case"image":case"link":Wt("error",o),Wt("load",o),C=w;break;case"details":Wt("toggle",o),C=w;break;case"input":J(o,w),C=$e(o,w),Wt("invalid",o);break;case"option":C=w;break;case"select":o._wrapperState={wasMultiple:!!w.multiple},C=U({},w,{value:void 0}),Wt("invalid",o);break;case"textarea":he(o,w),C=Be(o,w),Wt("invalid",o);break;default:C=w}Ze(m,C),V=C;for(T in V)if(V.hasOwnProperty(T)){var X=V[T];T==="style"?Re(o,X):T==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&xe(o,X)):T==="children"?typeof X=="string"?(m!=="textarea"||X!=="")&&Ae(o,X):typeof X=="number"&&Ae(o,""+X):T!=="suppressContentEditableWarning"&&T!=="suppressHydrationWarning"&&T!=="autoFocus"&&(a.hasOwnProperty(T)?X!=null&&T==="onScroll"&&Wt("scroll",o):X!=null&&S(o,T,X,L))}switch(m){case"input":pe(o),rt(o,w,!1);break;case"textarea":pe(o),ct(o);break;case"option":w.value!=null&&o.setAttribute("value",""+ve(w.value));break;case"select":o.multiple=!!w.multiple,T=w.value,T!=null?Se(o,!!w.multiple,T,!1):w.defaultValue!=null&&Se(o,!!w.multiple,w.defaultValue,!0);break;default:typeof C.onClick=="function"&&(o.onclick=Fd)}switch(m){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}}w&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return Pn(l),null;case 6:if(o&&l.stateNode!=null)dw(o,l,o.memoizedProps,w);else{if(typeof w!="string"&&l.stateNode===null)throw Error(s(166));if(m=ma(Wl.current),ma(hr.current),Kd(l)){if(w=l.stateNode,m=l.memoizedProps,w[mr]=l,(T=w.nodeValue!==m)&&(o=ys,o!==null))switch(o.tag){case 3:Dd(w.nodeValue,m,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&Dd(w.nodeValue,m,(o.mode&1)!==0)}T&&(l.flags|=4)}else w=(m.nodeType===9?m:m.ownerDocument).createTextNode(w),w[mr]=l,l.stateNode=w}return Pn(l),null;case 13:if(Ht(Yt),w=l.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(Gt&&bs!==null&&(l.mode&1)!==0&&(l.flags&128)===0)mb(),xi(),l.flags|=98560,T=!1;else if(T=Kd(l),w!==null&&w.dehydrated!==null){if(o===null){if(!T)throw Error(s(318));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(s(317));T[mr]=l}else xi(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Pn(l),T=!1}else er!==null&&(xp(er),er=null),T=!0;if(!T)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=m,l):(w=w!==null,w!==(o!==null&&o.memoizedState!==null)&&w&&(l.child.flags|=8192,(l.mode&1)!==0&&(o===null||(Yt.current&1)!==0?xn===0&&(xn=3):bp())),l.updateQueue!==null&&(l.flags|=4),Pn(l),null);case 4:return wi(),ap(o,l),o===null&&Pl(l.stateNode.containerInfo),Pn(l),null;case 10:return Mh(l.type._context),Pn(l),null;case 17:return as(l.type)&&Wd(),Pn(l),null;case 19:if(Ht(Yt),T=l.memoizedState,T===null)return Pn(l),null;if(w=(l.flags&128)!==0,L=T.rendering,L===null)if(w)Kl(T,!1);else{if(xn!==0||o!==null&&(o.flags&128)!==0)for(o=l.child;o!==null;){if(L=Zd(o),L!==null){for(l.flags|=128,Kl(T,!1),w=L.updateQueue,w!==null&&(l.updateQueue=w,l.flags|=4),l.subtreeFlags=0,w=m,m=l.child;m!==null;)T=m,o=w,T.flags&=14680066,L=T.alternate,L===null?(T.childLanes=0,T.lanes=o,T.child=null,T.subtreeFlags=0,T.memoizedProps=null,T.memoizedState=null,T.updateQueue=null,T.dependencies=null,T.stateNode=null):(T.childLanes=L.childLanes,T.lanes=L.lanes,T.child=L.child,T.subtreeFlags=0,T.deletions=null,T.memoizedProps=L.memoizedProps,T.memoizedState=L.memoizedState,T.updateQueue=L.updateQueue,T.type=L.type,o=L.dependencies,T.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),m=m.sibling;return zt(Yt,Yt.current&1|2),l.child}o=o.sibling}T.tail!==null&&it()>Si&&(l.flags|=128,w=!0,Kl(T,!1),l.lanes=4194304)}else{if(!w)if(o=Zd(L),o!==null){if(l.flags|=128,w=!0,m=o.updateQueue,m!==null&&(l.updateQueue=m,l.flags|=4),Kl(T,!0),T.tail===null&&T.tailMode==="hidden"&&!L.alternate&&!Gt)return Pn(l),null}else 2*it()-T.renderingStartTime>Si&&m!==1073741824&&(l.flags|=128,w=!0,Kl(T,!1),l.lanes=4194304);T.isBackwards?(L.sibling=l.child,l.child=L):(m=T.last,m!==null?m.sibling=L:l.child=L,T.last=L)}return T.tail!==null?(l=T.tail,T.rendering=l,T.tail=l.sibling,T.renderingStartTime=it(),l.sibling=null,m=Yt.current,zt(Yt,w?m&1|2:m&1),l):(Pn(l),null);case 22:case 23:return yp(),w=l.memoizedState!==null,o!==null&&o.memoizedState!==null!==w&&(l.flags|=8192),w&&(l.mode&1)!==0?(ws&1073741824)!==0&&(Pn(l),l.subtreeFlags&6&&(l.flags|=8192)):Pn(l),null;case 24:return null;case 25:return null}throw Error(s(156,l.tag))}function p_(o,l){switch($h(l),l.tag){case 1:return as(l.type)&&Wd(),o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 3:return wi(),Ht(os),Ht(On),Uh(),o=l.flags,(o&65536)!==0&&(o&128)===0?(l.flags=o&-65537|128,l):null;case 5:return Dh(l),null;case 13:if(Ht(Yt),o=l.memoizedState,o!==null&&o.dehydrated!==null){if(l.alternate===null)throw Error(s(340));xi()}return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 19:return Ht(Yt),null;case 4:return wi(),null;case 10:return Mh(l.type._context),null;case 22:case 23:return yp(),null;case 24:return null;default:return null}}var lu=!1,Ln=!1,g_=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function ki(o,l){var m=o.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(w){Zt(o,l,w)}else m.current=null}function ip(o,l,m){try{m()}catch(w){Zt(o,l,w)}}var uw=!1;function x_(o,l){if(yh=Or,o=Hy(),uh(o)){if("selectionStart"in o)var m={start:o.selectionStart,end:o.selectionEnd};else e:{m=(m=o.ownerDocument)&&m.defaultView||window;var w=m.getSelection&&m.getSelection();if(w&&w.rangeCount!==0){m=w.anchorNode;var C=w.anchorOffset,T=w.focusNode;w=w.focusOffset;try{m.nodeType,T.nodeType}catch{m=null;break e}var L=0,V=-1,X=-1,ce=0,we=0,Ne=o,be=null;t:for(;;){for(var Ue;Ne!==m||C!==0&&Ne.nodeType!==3||(V=L+C),Ne!==T||w!==0&&Ne.nodeType!==3||(X=L+w),Ne.nodeType===3&&(L+=Ne.nodeValue.length),(Ue=Ne.firstChild)!==null;)be=Ne,Ne=Ue;for(;;){if(Ne===o)break t;if(be===m&&++ce===C&&(V=L),be===T&&++we===w&&(X=L),(Ue=Ne.nextSibling)!==null)break;Ne=be,be=Ne.parentNode}Ne=Ue}m=V===-1||X===-1?null:{start:V,end:X}}else m=null}m=m||{start:0,end:0}}else m=null;for(bh={focusedElem:o,selectionRange:m},Or=!1,Ge=l;Ge!==null;)if(l=Ge,o=l.child,(l.subtreeFlags&1028)!==0&&o!==null)o.return=l,Ge=o;else for(;Ge!==null;){l=Ge;try{var Ke=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Ke!==null){var Ye=Ke.memoizedProps,nn=Ke.memoizedState,ie=l.stateNode,se=ie.getSnapshotBeforeUpdate(l.elementType===l.type?Ye:tr(l.type,Ye),nn);ie.__reactInternalSnapshotBeforeUpdate=se}break;case 3:var le=l.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(_e){Zt(l,l.return,_e)}if(o=l.sibling,o!==null){o.return=l.return,Ge=o;break}Ge=l.return}return Ke=uw,uw=!1,Ke}function Vl(o,l,m){var w=l.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var C=w=w.next;do{if((C.tag&o)===o){var T=C.destroy;C.destroy=void 0,T!==void 0&&ip(l,m,T)}C=C.next}while(C!==w)}}function cu(o,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var m=l=l.next;do{if((m.tag&o)===o){var w=m.create;m.destroy=w()}m=m.next}while(m!==l)}}function lp(o){var l=o.ref;if(l!==null){var m=o.stateNode;switch(o.tag){case 5:o=m;break;default:o=m}typeof l=="function"?l(o):l.current=o}}function fw(o){var l=o.alternate;l!==null&&(o.alternate=null,fw(l)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(l=o.stateNode,l!==null&&(delete l[mr],delete l[Il],delete l[Nh],delete l[Z$],delete l[e_])),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 mw(o){return o.tag===5||o.tag===3||o.tag===4}function hw(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||mw(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 cp(o,l,m){var w=o.tag;if(w===5||w===6)o=o.stateNode,l?m.nodeType===8?m.parentNode.insertBefore(o,l):m.insertBefore(o,l):(m.nodeType===8?(l=m.parentNode,l.insertBefore(o,m)):(l=m,l.appendChild(o)),m=m._reactRootContainer,m!=null||l.onclick!==null||(l.onclick=Fd));else if(w!==4&&(o=o.child,o!==null))for(cp(o,l,m),o=o.sibling;o!==null;)cp(o,l,m),o=o.sibling}function dp(o,l,m){var w=o.tag;if(w===5||w===6)o=o.stateNode,l?m.insertBefore(o,l):m.appendChild(o);else if(w!==4&&(o=o.child,o!==null))for(dp(o,l,m),o=o.sibling;o!==null;)dp(o,l,m),o=o.sibling}var $n=null,nr=!1;function wo(o,l,m){for(m=m.child;m!==null;)pw(o,l,m),m=m.sibling}function pw(o,l,m){if(xs&&typeof xs.onCommitFiberUnmount=="function")try{xs.onCommitFiberUnmount(sa,m)}catch{}switch(m.tag){case 5:Ln||ki(m,l);case 6:var w=$n,C=nr;$n=null,wo(o,l,m),$n=w,nr=C,$n!==null&&(nr?(o=$n,m=m.stateNode,o.nodeType===8?o.parentNode.removeChild(m):o.removeChild(m)):$n.removeChild(m.stateNode));break;case 18:$n!==null&&(nr?(o=$n,m=m.stateNode,o.nodeType===8?kh(o.parentNode,m):o.nodeType===1&&kh(o,m),uo(o)):kh($n,m.stateNode));break;case 4:w=$n,C=nr,$n=m.stateNode.containerInfo,nr=!0,wo(o,l,m),$n=w,nr=C;break;case 0:case 11:case 14:case 15:if(!Ln&&(w=m.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){C=w=w.next;do{var T=C,L=T.destroy;T=T.tag,L!==void 0&&((T&2)!==0||(T&4)!==0)&&ip(m,l,L),C=C.next}while(C!==w)}wo(o,l,m);break;case 1:if(!Ln&&(ki(m,l),w=m.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=m.memoizedProps,w.state=m.memoizedState,w.componentWillUnmount()}catch(V){Zt(m,l,V)}wo(o,l,m);break;case 21:wo(o,l,m);break;case 22:m.mode&1?(Ln=(w=Ln)||m.memoizedState!==null,wo(o,l,m),Ln=w):wo(o,l,m);break;default:wo(o,l,m)}}function gw(o){var l=o.updateQueue;if(l!==null){o.updateQueue=null;var m=o.stateNode;m===null&&(m=o.stateNode=new g_),l.forEach(function(w){var C=C_.bind(null,o,w);m.has(w)||(m.add(w),w.then(C,C))})}}function sr(o,l){var m=l.deletions;if(m!==null)for(var w=0;w<m.length;w++){var C=m[w];try{var T=o,L=l,V=L;e:for(;V!==null;){switch(V.tag){case 5:$n=V.stateNode,nr=!1;break e;case 3:$n=V.stateNode.containerInfo,nr=!0;break e;case 4:$n=V.stateNode.containerInfo,nr=!0;break e}V=V.return}if($n===null)throw Error(s(160));pw(T,L,C),$n=null,nr=!1;var X=C.alternate;X!==null&&(X.return=null),C.return=null}catch(ce){Zt(C,l,ce)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)xw(l,o),l=l.sibling}function xw(o,l){var m=o.alternate,w=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(sr(l,o),gr(o),w&4){try{Vl(3,o,o.return),cu(3,o)}catch(Ye){Zt(o,o.return,Ye)}try{Vl(5,o,o.return)}catch(Ye){Zt(o,o.return,Ye)}}break;case 1:sr(l,o),gr(o),w&512&&m!==null&&ki(m,m.return);break;case 5:if(sr(l,o),gr(o),w&512&&m!==null&&ki(m,m.return),o.flags&32){var C=o.stateNode;try{Ae(C,"")}catch(Ye){Zt(o,o.return,Ye)}}if(w&4&&(C=o.stateNode,C!=null)){var T=o.memoizedProps,L=m!==null?m.memoizedProps:T,V=o.type,X=o.updateQueue;if(o.updateQueue=null,X!==null)try{V==="input"&&T.type==="radio"&&T.name!=null&&Le(C,T),at(V,L);var ce=at(V,T);for(L=0;L<X.length;L+=2){var we=X[L],Ne=X[L+1];we==="style"?Re(C,Ne):we==="dangerouslySetInnerHTML"?xe(C,Ne):we==="children"?Ae(C,Ne):S(C,we,Ne,ce)}switch(V){case"input":qe(C,T);break;case"textarea":Ve(C,T);break;case"select":var be=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!T.multiple;var Ue=T.value;Ue!=null?Se(C,!!T.multiple,Ue,!1):be!==!!T.multiple&&(T.defaultValue!=null?Se(C,!!T.multiple,T.defaultValue,!0):Se(C,!!T.multiple,T.multiple?[]:"",!1))}C[Il]=T}catch(Ye){Zt(o,o.return,Ye)}}break;case 6:if(sr(l,o),gr(o),w&4){if(o.stateNode===null)throw Error(s(162));C=o.stateNode,T=o.memoizedProps;try{C.nodeValue=T}catch(Ye){Zt(o,o.return,Ye)}}break;case 3:if(sr(l,o),gr(o),w&4&&m!==null&&m.memoizedState.isDehydrated)try{uo(l.containerInfo)}catch(Ye){Zt(o,o.return,Ye)}break;case 4:sr(l,o),gr(o);break;case 13:sr(l,o),gr(o),C=o.child,C.flags&8192&&(T=C.memoizedState!==null,C.stateNode.isHidden=T,!T||C.alternate!==null&&C.alternate.memoizedState!==null||(mp=it())),w&4&&gw(o);break;case 22:if(we=m!==null&&m.memoizedState!==null,o.mode&1?(Ln=(ce=Ln)||we,sr(l,o),Ln=ce):sr(l,o),gr(o),w&8192){if(ce=o.memoizedState!==null,(o.stateNode.isHidden=ce)&&!we&&(o.mode&1)!==0)for(Ge=o,we=o.child;we!==null;){for(Ne=Ge=we;Ge!==null;){switch(be=Ge,Ue=be.child,be.tag){case 0:case 11:case 14:case 15:Vl(4,be,be.return);break;case 1:ki(be,be.return);var Ke=be.stateNode;if(typeof Ke.componentWillUnmount=="function"){w=be,m=be.return;try{l=w,Ke.props=l.memoizedProps,Ke.state=l.memoizedState,Ke.componentWillUnmount()}catch(Ye){Zt(w,m,Ye)}}break;case 5:ki(be,be.return);break;case 22:if(be.memoizedState!==null){bw(Ne);continue}}Ue!==null?(Ue.return=be,Ge=Ue):bw(Ne)}we=we.sibling}e:for(we=null,Ne=o;;){if(Ne.tag===5){if(we===null){we=Ne;try{C=Ne.stateNode,ce?(T=C.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none"):(V=Ne.stateNode,X=Ne.memoizedProps.style,L=X!=null&&X.hasOwnProperty("display")?X.display:null,V.style.display=ee("display",L))}catch(Ye){Zt(o,o.return,Ye)}}}else if(Ne.tag===6){if(we===null)try{Ne.stateNode.nodeValue=ce?"":Ne.memoizedProps}catch(Ye){Zt(o,o.return,Ye)}}else if((Ne.tag!==22&&Ne.tag!==23||Ne.memoizedState===null||Ne===o)&&Ne.child!==null){Ne.child.return=Ne,Ne=Ne.child;continue}if(Ne===o)break e;for(;Ne.sibling===null;){if(Ne.return===null||Ne.return===o)break e;we===Ne&&(we=null),Ne=Ne.return}we===Ne&&(we=null),Ne.sibling.return=Ne.return,Ne=Ne.sibling}}break;case 19:sr(l,o),gr(o),w&4&&gw(o);break;case 21:break;default:sr(l,o),gr(o)}}function gr(o){var l=o.flags;if(l&2){try{e:{for(var m=o.return;m!==null;){if(mw(m)){var w=m;break e}m=m.return}throw Error(s(160))}switch(w.tag){case 5:var C=w.stateNode;w.flags&32&&(Ae(C,""),w.flags&=-33);var T=hw(o);dp(o,T,C);break;case 3:case 4:var L=w.stateNode.containerInfo,V=hw(o);cp(o,V,L);break;default:throw Error(s(161))}}catch(X){Zt(o,o.return,X)}o.flags&=-3}l&4096&&(o.flags&=-4097)}function v_(o,l,m){Ge=o,vw(o)}function vw(o,l,m){for(var w=(o.mode&1)!==0;Ge!==null;){var C=Ge,T=C.child;if(C.tag===22&&w){var L=C.memoizedState!==null||lu;if(!L){var V=C.alternate,X=V!==null&&V.memoizedState!==null||Ln;V=lu;var ce=Ln;if(lu=L,(Ln=X)&&!ce)for(Ge=C;Ge!==null;)L=Ge,X=L.child,L.tag===22&&L.memoizedState!==null?ww(C):X!==null?(X.return=L,Ge=X):ww(C);for(;T!==null;)Ge=T,vw(T),T=T.sibling;Ge=C,lu=V,Ln=ce}yw(o)}else(C.subtreeFlags&8772)!==0&&T!==null?(T.return=C,Ge=T):yw(o)}}function yw(o){for(;Ge!==null;){var l=Ge;if((l.flags&8772)!==0){var m=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Ln||cu(5,l);break;case 1:var w=l.stateNode;if(l.flags&4&&!Ln)if(m===null)w.componentDidMount();else{var C=l.elementType===l.type?m.memoizedProps:tr(l.type,m.memoizedProps);w.componentDidUpdate(C,m.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var T=l.updateQueue;T!==null&&bb(l,T,w);break;case 3:var L=l.updateQueue;if(L!==null){if(m=null,l.child!==null)switch(l.child.tag){case 5:m=l.child.stateNode;break;case 1:m=l.child.stateNode}bb(l,L,m)}break;case 5:var V=l.stateNode;if(m===null&&l.flags&4){m=V;var X=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":X.autoFocus&&m.focus();break;case"img":X.src&&(m.src=X.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ce=l.alternate;if(ce!==null){var we=ce.memoizedState;if(we!==null){var Ne=we.dehydrated;Ne!==null&&uo(Ne)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}Ln||l.flags&512&&lp(l)}catch(be){Zt(l,l.return,be)}}if(l===o){Ge=null;break}if(m=l.sibling,m!==null){m.return=l.return,Ge=m;break}Ge=l.return}}function bw(o){for(;Ge!==null;){var l=Ge;if(l===o){Ge=null;break}var m=l.sibling;if(m!==null){m.return=l.return,Ge=m;break}Ge=l.return}}function ww(o){for(;Ge!==null;){var l=Ge;try{switch(l.tag){case 0:case 11:case 15:var m=l.return;try{cu(4,l)}catch(X){Zt(l,m,X)}break;case 1:var w=l.stateNode;if(typeof w.componentDidMount=="function"){var C=l.return;try{w.componentDidMount()}catch(X){Zt(l,C,X)}}var T=l.return;try{lp(l)}catch(X){Zt(l,T,X)}break;case 5:var L=l.return;try{lp(l)}catch(X){Zt(l,L,X)}}}catch(X){Zt(l,l.return,X)}if(l===o){Ge=null;break}var V=l.sibling;if(V!==null){V.return=l.return,Ge=V;break}Ge=l.return}}var y_=Math.ceil,du=N.ReactCurrentDispatcher,up=N.ReactCurrentOwner,Ps=N.ReactCurrentBatchConfig,Et=0,wn=null,fn=null,_n=0,ws=0,Ni=go(0),xn=0,Yl=null,pa=0,uu=0,fp=0,Ql=null,ls=null,mp=0,Si=1/0,Ur=null,fu=!1,hp=null,jo=null,mu=!1,ko=null,hu=0,Jl=0,pp=null,pu=-1,gu=0;function Kn(){return(Et&6)!==0?it():pu!==-1?pu:pu=it()}function No(o){return(o.mode&1)===0?1:(Et&2)!==0&&_n!==0?_n&-_n:n_.transition!==null?(gu===0&&(gu=wl()),gu):(o=$t,o!==0||(o=window.event,o=o===void 0?16:ky(o.type)),o)}function rr(o,l,m,w){if(50<Jl)throw Jl=0,pp=null,Error(s(185));lo(o,m,w),((Et&2)===0||o!==wn)&&(o===wn&&((Et&2)===0&&(uu|=m),xn===4&&So(o,_n)),cs(o,w),m===1&&Et===0&&(l.mode&1)===0&&(Si=it()+500,Bd&&vo()))}function cs(o,l){var m=o.callbackNode;Ed(o,l);var w=aa(o,o===wn?_n:0);if(w===0)m!==null&&We(m),o.callbackNode=null,o.callbackPriority=0;else if(l=w&-w,o.callbackPriority!==l){if(m!=null&&We(m),l===1)o.tag===0?t_(kw.bind(null,o)):lb(kw.bind(null,o)),J$(function(){(Et&6)===0&&vo()}),m=null;else{switch(jl(w)){case 1:m=En;break;case 4:m=ur;break;case 16:m=Ut;break;case 536870912:m=ao;break;default:m=Ut}m=Rw(m,jw.bind(null,o))}o.callbackPriority=l,o.callbackNode=m}}function jw(o,l){if(pu=-1,gu=0,(Et&6)!==0)throw Error(s(327));var m=o.callbackNode;if(Ci()&&o.callbackNode!==m)return null;var w=aa(o,o===wn?_n:0);if(w===0)return null;if((w&30)!==0||(w&o.expiredLanes)!==0||l)l=xu(o,w);else{l=w;var C=Et;Et|=2;var T=Sw();(wn!==o||_n!==l)&&(Ur=null,Si=it()+500,xa(o,l));do try{j_();break}catch(V){Nw(o,V)}while(!0);Oh(),du.current=T,Et=C,fn!==null?l=0:(wn=null,_n=0,l=xn)}if(l!==0){if(l===2&&(C=ei(o),C!==0&&(w=C,l=gp(o,C))),l===1)throw m=Yl,xa(o,0),So(o,w),cs(o,it()),m;if(l===6)So(o,w);else{if(C=o.current.alternate,(w&30)===0&&!b_(C)&&(l=xu(o,w),l===2&&(T=ei(o),T!==0&&(w=T,l=gp(o,T))),l===1))throw m=Yl,xa(o,0),So(o,w),cs(o,it()),m;switch(o.finishedWork=C,o.finishedLanes=w,l){case 0:case 1:throw Error(s(345));case 2:va(o,ls,Ur);break;case 3:if(So(o,w),(w&130023424)===w&&(l=mp+500-it(),10<l)){if(aa(o,0)!==0)break;if(C=o.suspendedLanes,(C&w)!==w){Kn(),o.pingedLanes|=o.suspendedLanes&C;break}o.timeoutHandle=jh(va.bind(null,o,ls,Ur),l);break}va(o,ls,Ur);break;case 4:if(So(o,w),(w&4194240)===w)break;for(l=o.eventTimes,C=-1;0<w;){var L=31-ss(w);T=1<<L,L=l[L],L>C&&(C=L),w&=~T}if(w=C,w=it()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*y_(w/1960))-w,10<w){o.timeoutHandle=jh(va.bind(null,o,ls,Ur),w);break}va(o,ls,Ur);break;case 5:va(o,ls,Ur);break;default:throw Error(s(329))}}}return cs(o,it()),o.callbackNode===m?jw.bind(null,o):null}function gp(o,l){var m=Ql;return o.current.memoizedState.isDehydrated&&(xa(o,l).flags|=256),o=xu(o,l),o!==2&&(l=ls,ls=m,l!==null&&xp(l)),o}function xp(o){ls===null?ls=o:ls.push.apply(ls,o)}function b_(o){for(var l=o;;){if(l.flags&16384){var m=l.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var w=0;w<m.length;w++){var C=m[w],T=C.getSnapshot;C=C.value;try{if(!Zs(T(),C))return!1}catch{return!1}}}if(m=l.child,l.subtreeFlags&16384&&m!==null)m.return=l,l=m;else{if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function So(o,l){for(l&=~fp,l&=~uu,o.suspendedLanes|=l,o.pingedLanes&=~l,o=o.expirationTimes;0<l;){var m=31-ss(l),w=1<<m;o[m]=-1,l&=~w}}function kw(o){if((Et&6)!==0)throw Error(s(327));Ci();var l=aa(o,0);if((l&1)===0)return cs(o,it()),null;var m=xu(o,l);if(o.tag!==0&&m===2){var w=ei(o);w!==0&&(l=w,m=gp(o,w))}if(m===1)throw m=Yl,xa(o,0),So(o,l),cs(o,it()),m;if(m===6)throw Error(s(345));return o.finishedWork=o.current.alternate,o.finishedLanes=l,va(o,ls,Ur),cs(o,it()),null}function vp(o,l){var m=Et;Et|=1;try{return o(l)}finally{Et=m,Et===0&&(Si=it()+500,Bd&&vo())}}function ga(o){ko!==null&&ko.tag===0&&(Et&6)===0&&Ci();var l=Et;Et|=1;var m=Ps.transition,w=$t;try{if(Ps.transition=null,$t=1,o)return o()}finally{$t=w,Ps.transition=m,Et=l,(Et&6)===0&&vo()}}function yp(){ws=Ni.current,Ht(Ni)}function xa(o,l){o.finishedWork=null,o.finishedLanes=0;var m=o.timeoutHandle;if(m!==-1&&(o.timeoutHandle=-1,Q$(m)),fn!==null)for(m=fn.return;m!==null;){var w=m;switch($h(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&Wd();break;case 3:wi(),Ht(os),Ht(On),Uh();break;case 5:Dh(w);break;case 4:wi();break;case 13:Ht(Yt);break;case 19:Ht(Yt);break;case 10:Mh(w.type._context);break;case 22:case 23:yp()}m=m.return}if(wn=o,fn=o=Co(o.current,null),_n=ws=l,xn=0,Yl=null,fp=uu=pa=0,ls=Ql=null,fa!==null){for(l=0;l<fa.length;l++)if(m=fa[l],w=m.interleaved,w!==null){m.interleaved=null;var C=w.next,T=m.pending;if(T!==null){var L=T.next;T.next=C,w.next=L}m.pending=w}fa=null}return o}function Nw(o,l){do{var m=fn;try{if(Oh(),eu.current=ru,tu){for(var w=Qt.memoizedState;w!==null;){var C=w.queue;C!==null&&(C.pending=null),w=w.next}tu=!1}if(ha=0,bn=gn=Qt=null,Hl=!1,Bl=0,up.current=null,m===null||m.return===null){xn=1,Yl=l,fn=null;break}e:{var T=o,L=m.return,V=m,X=l;if(l=_n,V.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var ce=X,we=V,Ne=we.tag;if((we.mode&1)===0&&(Ne===0||Ne===11||Ne===15)){var be=we.alternate;be?(we.updateQueue=be.updateQueue,we.memoizedState=be.memoizedState,we.lanes=be.lanes):(we.updateQueue=null,we.memoizedState=null)}var Ue=Yb(L);if(Ue!==null){Ue.flags&=-257,Qb(Ue,L,V,T,l),Ue.mode&1&&Vb(T,ce,l),l=Ue,X=ce;var Ke=l.updateQueue;if(Ke===null){var Ye=new Set;Ye.add(X),l.updateQueue=Ye}else Ke.add(X);break e}else{if((l&1)===0){Vb(T,ce,l),bp();break e}X=Error(s(426))}}else if(Gt&&V.mode&1){var nn=Yb(L);if(nn!==null){(nn.flags&65536)===0&&(nn.flags|=256),Qb(nn,L,V,T,l),Rh(ji(X,V));break e}}T=X=ji(X,V),xn!==4&&(xn=2),Ql===null?Ql=[T]:Ql.push(T),T=L;do{switch(T.tag){case 3:T.flags|=65536,l&=-l,T.lanes|=l;var ie=qb(T,X,l);yb(T,ie);break e;case 1:V=X;var se=T.type,le=T.stateNode;if((T.flags&128)===0&&(typeof se.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(jo===null||!jo.has(le)))){T.flags|=65536,l&=-l,T.lanes|=l;var _e=Kb(T,V,l);yb(T,_e);break e}}T=T.return}while(T!==null)}Ew(m)}catch(Je){l=Je,fn===m&&m!==null&&(fn=m=m.return);continue}break}while(!0)}function Sw(){var o=du.current;return du.current=ru,o===null?ru:o}function bp(){(xn===0||xn===3||xn===2)&&(xn=4),wn===null||(pa&268435455)===0&&(uu&268435455)===0||So(wn,_n)}function xu(o,l){var m=Et;Et|=2;var w=Sw();(wn!==o||_n!==l)&&(Ur=null,xa(o,l));do try{w_();break}catch(C){Nw(o,C)}while(!0);if(Oh(),Et=m,du.current=w,fn!==null)throw Error(s(261));return wn=null,_n=0,xn}function w_(){for(;fn!==null;)Cw(fn)}function j_(){for(;fn!==null&&!St();)Cw(fn)}function Cw(o){var l=Tw(o.alternate,o,ws);o.memoizedProps=o.pendingProps,l===null?Ew(o):fn=l,up.current=null}function Ew(o){var l=o;do{var m=l.alternate;if(o=l.return,(l.flags&32768)===0){if(m=h_(m,l,ws),m!==null){fn=m;return}}else{if(m=p_(m,l),m!==null){m.flags&=32767,fn=m;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{xn=6,fn=null;return}}if(l=l.sibling,l!==null){fn=l;return}fn=l=o}while(l!==null);xn===0&&(xn=5)}function va(o,l,m){var w=$t,C=Ps.transition;try{Ps.transition=null,$t=1,k_(o,l,m,w)}finally{Ps.transition=C,$t=w}return null}function k_(o,l,m,w){do Ci();while(ko!==null);if((Et&6)!==0)throw Error(s(327));m=o.finishedWork;var C=o.finishedLanes;if(m===null)return null;if(o.finishedWork=null,o.finishedLanes=0,m===o.current)throw Error(s(177));o.callbackNode=null,o.callbackPriority=0;var T=m.lanes|m.childLanes;if($d(o,T),o===wn&&(fn=wn=null,_n=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||mu||(mu=!0,Rw(Ut,function(){return Ci(),null})),T=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||T){T=Ps.transition,Ps.transition=null;var L=$t;$t=1;var V=Et;Et|=4,up.current=null,x_(o,m),xw(m,o),H$(bh),Or=!!yh,bh=yh=null,o.current=m,v_(m),Lt(),Et=V,$t=L,Ps.transition=T}else o.current=m;if(mu&&(mu=!1,ko=o,hu=C),T=o.pendingLanes,T===0&&(jo=null),jd(m.stateNode),cs(o,it()),l!==null)for(w=o.onRecoverableError,m=0;m<l.length;m++)C=l[m],w(C.value,{componentStack:C.stack,digest:C.digest});if(fu)throw fu=!1,o=hp,hp=null,o;return(hu&1)!==0&&o.tag!==0&&Ci(),T=o.pendingLanes,(T&1)!==0?o===pp?Jl++:(Jl=0,pp=o):Jl=0,vo(),null}function Ci(){if(ko!==null){var o=jl(hu),l=Ps.transition,m=$t;try{if(Ps.transition=null,$t=16>o?16:o,ko===null)var w=!1;else{if(o=ko,ko=null,hu=0,(Et&6)!==0)throw Error(s(331));var C=Et;for(Et|=4,Ge=o.current;Ge!==null;){var T=Ge,L=T.child;if((Ge.flags&16)!==0){var V=T.deletions;if(V!==null){for(var X=0;X<V.length;X++){var ce=V[X];for(Ge=ce;Ge!==null;){var we=Ge;switch(we.tag){case 0:case 11:case 15:Vl(8,we,T)}var Ne=we.child;if(Ne!==null)Ne.return=we,Ge=Ne;else for(;Ge!==null;){we=Ge;var be=we.sibling,Ue=we.return;if(fw(we),we===ce){Ge=null;break}if(be!==null){be.return=Ue,Ge=be;break}Ge=Ue}}}var Ke=T.alternate;if(Ke!==null){var Ye=Ke.child;if(Ye!==null){Ke.child=null;do{var nn=Ye.sibling;Ye.sibling=null,Ye=nn}while(Ye!==null)}}Ge=T}}if((T.subtreeFlags&2064)!==0&&L!==null)L.return=T,Ge=L;else e:for(;Ge!==null;){if(T=Ge,(T.flags&2048)!==0)switch(T.tag){case 0:case 11:case 15:Vl(9,T,T.return)}var ie=T.sibling;if(ie!==null){ie.return=T.return,Ge=ie;break e}Ge=T.return}}var se=o.current;for(Ge=se;Ge!==null;){L=Ge;var le=L.child;if((L.subtreeFlags&2064)!==0&&le!==null)le.return=L,Ge=le;else e:for(L=se;Ge!==null;){if(V=Ge,(V.flags&2048)!==0)try{switch(V.tag){case 0:case 11:case 15:cu(9,V)}}catch(Je){Zt(V,V.return,Je)}if(V===L){Ge=null;break e}var _e=V.sibling;if(_e!==null){_e.return=V.return,Ge=_e;break e}Ge=V.return}}if(Et=C,vo(),xs&&typeof xs.onPostCommitFiberRoot=="function")try{xs.onPostCommitFiberRoot(sa,o)}catch{}w=!0}return w}finally{$t=m,Ps.transition=l}}return!1}function $w(o,l,m){l=ji(m,l),l=qb(o,l,1),o=bo(o,l,1),l=Kn(),o!==null&&(lo(o,1,l),cs(o,l))}function Zt(o,l,m){if(o.tag===3)$w(o,o,m);else for(;l!==null;){if(l.tag===3){$w(l,o,m);break}else if(l.tag===1){var w=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(jo===null||!jo.has(w))){o=ji(m,o),o=Kb(l,o,1),l=bo(l,o,1),o=Kn(),l!==null&&(lo(l,1,o),cs(l,o));break}}l=l.return}}function N_(o,l,m){var w=o.pingCache;w!==null&&w.delete(l),l=Kn(),o.pingedLanes|=o.suspendedLanes&m,wn===o&&(_n&m)===m&&(xn===4||xn===3&&(_n&130023424)===_n&&500>it()-mp?xa(o,0):fp|=m),cs(o,l)}function _w(o,l){l===0&&((o.mode&1)===0?l=1:(l=oa,oa<<=1,(oa&130023424)===0&&(oa=4194304)));var m=Kn();o=zr(o,l),o!==null&&(lo(o,l,m),cs(o,m))}function S_(o){var l=o.memoizedState,m=0;l!==null&&(m=l.retryLane),_w(o,m)}function C_(o,l){var m=0;switch(o.tag){case 13:var w=o.stateNode,C=o.memoizedState;C!==null&&(m=C.retryLane);break;case 19:w=o.stateNode;break;default:throw Error(s(314))}w!==null&&w.delete(l),_w(o,m)}var Tw;Tw=function(o,l,m){if(o!==null)if(o.memoizedProps!==l.pendingProps||os.current)is=!0;else{if((o.lanes&m)===0&&(l.flags&128)===0)return is=!1,m_(o,l,m);is=(o.flags&131072)!==0}else is=!1,Gt&&(l.flags&1048576)!==0&&cb(l,qd,l.index);switch(l.lanes=0,l.tag){case 2:var w=l.type;iu(o,l),o=l.pendingProps;var C=hi(l,On.current);bi(l,m),C=Bh(null,l,w,o,C,m);var T=Gh();return l.flags|=1,typeof C=="object"&&C!==null&&typeof C.render=="function"&&C.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,as(w)?(T=!0,Hd(l)):T=!1,l.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,Ih(l),C.updater=ou,l.stateNode=C,C._reactInternals=l,Jh(l,w,o,m),l=tp(null,l,w,!0,T,m)):(l.tag=0,Gt&&T&&Eh(l),qn(null,l,C,m),l=l.child),l;case 16:w=l.elementType;e:{switch(iu(o,l),o=l.pendingProps,C=w._init,w=C(w._payload),l.type=w,C=l.tag=$_(w),o=tr(w,o),C){case 0:l=ep(null,l,w,o,m);break e;case 1:l=nw(null,l,w,o,m);break e;case 11:l=Jb(null,l,w,o,m);break e;case 14:l=Xb(null,l,w,tr(w.type,o),m);break e}throw Error(s(306,w,""))}return l;case 0:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:tr(w,C),ep(o,l,w,C,m);case 1:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:tr(w,C),nw(o,l,w,C,m);case 3:e:{if(sw(l),o===null)throw Error(s(387));w=l.pendingProps,T=l.memoizedState,C=T.element,vb(o,l),Xd(l,w,null,m);var L=l.memoizedState;if(w=L.element,T.isDehydrated)if(T={element:w,isDehydrated:!1,cache:L.cache,pendingSuspenseBoundaries:L.pendingSuspenseBoundaries,transitions:L.transitions},l.updateQueue.baseState=T,l.memoizedState=T,l.flags&256){C=ji(Error(s(423)),l),l=rw(o,l,w,m,C);break e}else if(w!==C){C=ji(Error(s(424)),l),l=rw(o,l,w,m,C);break e}else for(bs=po(l.stateNode.containerInfo.firstChild),ys=l,Gt=!0,er=null,m=gb(l,null,w,m),l.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(xi(),w===C){l=Fr(o,l,m);break e}qn(o,l,w,m)}l=l.child}return l;case 5:return wb(l),o===null&&Th(l),w=l.type,C=l.pendingProps,T=o!==null?o.memoizedProps:null,L=C.children,wh(w,C)?L=null:T!==null&&wh(w,T)&&(l.flags|=32),tw(o,l),qn(o,l,L,m),l.child;case 6:return o===null&&Th(l),null;case 13:return ow(o,l,m);case 4:return zh(l,l.stateNode.containerInfo),w=l.pendingProps,o===null?l.child=vi(l,null,w,m):qn(o,l,w,m),l.child;case 11:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:tr(w,C),Jb(o,l,w,C,m);case 7:return qn(o,l,l.pendingProps,m),l.child;case 8:return qn(o,l,l.pendingProps.children,m),l.child;case 12:return qn(o,l,l.pendingProps.children,m),l.child;case 10:e:{if(w=l.type._context,C=l.pendingProps,T=l.memoizedProps,L=C.value,zt(Yd,w._currentValue),w._currentValue=L,T!==null)if(Zs(T.value,L)){if(T.children===C.children&&!os.current){l=Fr(o,l,m);break e}}else for(T=l.child,T!==null&&(T.return=l);T!==null;){var V=T.dependencies;if(V!==null){L=T.child;for(var X=V.firstContext;X!==null;){if(X.context===w){if(T.tag===1){X=Dr(-1,m&-m),X.tag=2;var ce=T.updateQueue;if(ce!==null){ce=ce.shared;var we=ce.pending;we===null?X.next=X:(X.next=we.next,we.next=X),ce.pending=X}}T.lanes|=m,X=T.alternate,X!==null&&(X.lanes|=m),Ph(T.return,m,l),V.lanes|=m;break}X=X.next}}else if(T.tag===10)L=T.type===l.type?null:T.child;else if(T.tag===18){if(L=T.return,L===null)throw Error(s(341));L.lanes|=m,V=L.alternate,V!==null&&(V.lanes|=m),Ph(L,m,l),L=T.sibling}else L=T.child;if(L!==null)L.return=T;else for(L=T;L!==null;){if(L===l){L=null;break}if(T=L.sibling,T!==null){T.return=L.return,L=T;break}L=L.return}T=L}qn(o,l,C.children,m),l=l.child}return l;case 9:return C=l.type,w=l.pendingProps.children,bi(l,m),C=Os(C),w=w(C),l.flags|=1,qn(o,l,w,m),l.child;case 14:return w=l.type,C=tr(w,l.pendingProps),C=tr(w.type,C),Xb(o,l,w,C,m);case 15:return Zb(o,l,l.type,l.pendingProps,m);case 17:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:tr(w,C),iu(o,l),l.tag=1,as(w)?(o=!0,Hd(l)):o=!1,bi(l,m),Bb(l,w,C),Jh(l,w,C,m),tp(null,l,w,!0,o,m);case 19:return iw(o,l,m);case 22:return ew(o,l,m)}throw Error(s(156,l.tag))};function Rw(o,l){return ye(o,l)}function E_(o,l,m,w){this.tag=o,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ls(o,l,m,w){return new E_(o,l,m,w)}function wp(o){return o=o.prototype,!(!o||!o.isReactComponent)}function $_(o){if(typeof o=="function")return wp(o)?1:0;if(o!=null){if(o=o.$$typeof,o===P)return 11;if(o===Y)return 14}return 2}function Co(o,l){var m=o.alternate;return m===null?(m=Ls(o.tag,l,o.key,o.mode),m.elementType=o.elementType,m.type=o.type,m.stateNode=o.stateNode,m.alternate=o,o.alternate=m):(m.pendingProps=l,m.type=o.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=o.flags&14680064,m.childLanes=o.childLanes,m.lanes=o.lanes,m.child=o.child,m.memoizedProps=o.memoizedProps,m.memoizedState=o.memoizedState,m.updateQueue=o.updateQueue,l=o.dependencies,m.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},m.sibling=o.sibling,m.index=o.index,m.ref=o.ref,m}function vu(o,l,m,w,C,T){var L=2;if(w=o,typeof o=="function")wp(o)&&(L=1);else if(typeof o=="string")L=5;else e:switch(o){case O:return ya(m.children,C,T,l);case A:L=8,C|=8;break;case I:return o=Ls(12,m,l,C|2),o.elementType=I,o.lanes=T,o;case D:return o=Ls(13,m,l,C),o.elementType=D,o.lanes=T,o;case W:return o=Ls(19,m,l,C),o.elementType=W,o.lanes=T,o;case q:return yu(m,C,T,l);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case M:L=10;break e;case R:L=9;break e;case P:L=11;break e;case Y:L=14;break e;case H:L=16,w=null;break e}throw Error(s(130,o==null?o:typeof o,""))}return l=Ls(L,m,l,C),l.elementType=o,l.type=w,l.lanes=T,l}function ya(o,l,m,w){return o=Ls(7,o,w,l),o.lanes=m,o}function yu(o,l,m,w){return o=Ls(22,o,w,l),o.elementType=q,o.lanes=m,o.stateNode={isHidden:!1},o}function jp(o,l,m){return o=Ls(6,o,null,l),o.lanes=m,o}function kp(o,l,m){return l=Ls(4,o.children!==null?o.children:[],o.key,l),l.lanes=m,l.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},l}function __(o,l,m,w,C){this.tag=l,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=ti(0),this.expirationTimes=ti(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ti(0),this.identifierPrefix=w,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function Np(o,l,m,w,C,T,L,V,X){return o=new __(o,l,m,V,X),l===1?(l=1,T===!0&&(l|=8)):l=0,T=Ls(3,null,null,l),o.current=T,T.stateNode=o,T.memoizedState={element:w,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ih(T),o}function T_(o,l,m){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:E,key:w==null?null:""+w,children:o,containerInfo:l,implementation:m}}function Aw(o){if(!o)return xo;o=o._reactInternals;e:{if(Oe(o)!==o||o.tag!==1)throw Error(s(170));var l=o;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(as(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(s(171))}if(o.tag===1){var m=o.type;if(as(m))return ab(o,m,l)}return l}function Ow(o,l,m,w,C,T,L,V,X){return o=Np(m,w,!0,o,C,T,L,V,X),o.context=Aw(null),m=o.current,w=Kn(),C=No(m),T=Dr(w,C),T.callback=l??null,bo(m,T,C),o.current.lanes=C,lo(o,C,w),cs(o,w),o}function bu(o,l,m,w){var C=l.current,T=Kn(),L=No(C);return m=Aw(m),l.context===null?l.context=m:l.pendingContext=m,l=Dr(T,L),l.payload={element:o},w=w===void 0?null:w,w!==null&&(l.callback=w),o=bo(C,l,L),o!==null&&(rr(o,C,L,T),Jd(o,C,L)),L}function wu(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 Mw(o,l){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var m=o.retryLane;o.retryLane=m!==0&&m<l?m:l}}function Sp(o,l){Mw(o,l),(o=o.alternate)&&Mw(o,l)}function R_(){return null}var Pw=typeof reportError=="function"?reportError:function(o){console.error(o)};function Cp(o){this._internalRoot=o}ju.prototype.render=Cp.prototype.render=function(o){var l=this._internalRoot;if(l===null)throw Error(s(409));bu(o,l,null,null)},ju.prototype.unmount=Cp.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var l=o.containerInfo;ga(function(){bu(null,o,null,null)}),l[Mr]=null}};function ju(o){this._internalRoot=o}ju.prototype.unstable_scheduleHydration=function(o){if(o){var l=Sl();o={blockedOn:null,target:o,priority:l};for(var m=0;m<Pe.length&&l!==0&&l<Pe[m].priority;m++);Pe.splice(m,0,o),m===0&&Gn(o)}};function Ep(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function ku(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function Lw(){}function A_(o,l,m,w,C){if(C){if(typeof w=="function"){var T=w;w=function(){var ce=wu(L);T.call(ce)}}var L=Ow(l,w,o,0,null,!1,!1,"",Lw);return o._reactRootContainer=L,o[Mr]=L.current,Pl(o.nodeType===8?o.parentNode:o),ga(),L}for(;C=o.lastChild;)o.removeChild(C);if(typeof w=="function"){var V=w;w=function(){var ce=wu(X);V.call(ce)}}var X=Np(o,0,!1,null,null,!1,!1,"",Lw);return o._reactRootContainer=X,o[Mr]=X.current,Pl(o.nodeType===8?o.parentNode:o),ga(function(){bu(l,X,m,w)}),X}function Nu(o,l,m,w,C){var T=m._reactRootContainer;if(T){var L=T;if(typeof C=="function"){var V=C;C=function(){var X=wu(L);V.call(X)}}bu(l,L,o,C)}else L=A_(m,l,o,C,w);return wu(L)}kl=function(o){switch(o.tag){case 3:var l=o.stateNode;if(l.current.memoizedState.isDehydrated){var m=io(l.pendingLanes);m!==0&&(ni(l,m|1),cs(l,it()),(Et&6)===0&&(Si=it()+500,vo()))}break;case 13:ga(function(){var w=zr(o,1);if(w!==null){var C=Kn();rr(w,o,1,C)}}),Sp(o,1)}},si=function(o){if(o.tag===13){var l=zr(o,134217728);if(l!==null){var m=Kn();rr(l,o,134217728,m)}Sp(o,134217728)}},Nl=function(o){if(o.tag===13){var l=No(o),m=zr(o,l);if(m!==null){var w=Kn();rr(m,o,l,w)}Sp(o,l)}},Sl=function(){return $t},Cl=function(o,l){var m=$t;try{return $t=o,l()}finally{$t=m}},et=function(o,l,m){switch(l){case"input":if(qe(o,m),l=m.name,m.type==="radio"&&l!=null){for(m=o;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<m.length;l++){var w=m[l];if(w!==o&&w.form===o.form){var C=Ud(w);if(!C)throw Error(s(90));me(w),qe(w,C)}}}break;case"textarea":Ve(o,m);break;case"select":l=m.value,l!=null&&Se(o,!!m.multiple,l,!1)}},Rn=vp,hs=ga;var O_={usingClientEntryPoint:!1,Events:[zl,fi,Ud,dn,Nt,vp]},Xl={findFiberByHostInstance:la,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},M_={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:N.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=Fe(o),o===null?null:o.stateNode},findFiberByHostInstance:Xl.findFiberByHostInstance||R_,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 Su=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Su.isDisabled&&Su.supportsFiber)try{sa=Su.inject(M_),xs=Su}catch{}}return ds.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=O_,ds.createPortal=function(o,l){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ep(l))throw Error(s(200));return T_(o,l,null,m)},ds.createRoot=function(o,l){if(!Ep(o))throw Error(s(299));var m=!1,w="",C=Pw;return l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(w=l.identifierPrefix),l.onRecoverableError!==void 0&&(C=l.onRecoverableError)),l=Np(o,1,!1,null,null,m,!1,w,C),o[Mr]=l.current,Pl(o.nodeType===8?o.parentNode:o),new Cp(l)},ds.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var l=o._reactInternals;if(l===void 0)throw typeof o.render=="function"?Error(s(188)):(o=Object.keys(o).join(","),Error(s(268,o)));return o=Fe(l),o=o===null?null:o.stateNode,o},ds.flushSync=function(o){return ga(o)},ds.hydrate=function(o,l,m){if(!ku(l))throw Error(s(200));return Nu(null,o,l,!0,m)},ds.hydrateRoot=function(o,l,m){if(!Ep(o))throw Error(s(405));var w=m!=null&&m.hydratedSources||null,C=!1,T="",L=Pw;if(m!=null&&(m.unstable_strictMode===!0&&(C=!0),m.identifierPrefix!==void 0&&(T=m.identifierPrefix),m.onRecoverableError!==void 0&&(L=m.onRecoverableError)),l=Ow(l,null,o,1,m??null,C,!1,T,L),o[Mr]=l.current,Pl(o),w)for(o=0;o<w.length;o++)m=w[o],C=m._getVersion,C=C(m._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[m,C]:l.mutableSourceEagerHydrationData.push(m,C);return new ju(l)},ds.render=function(o,l,m){if(!ku(l))throw Error(s(200));return Nu(null,o,l,!1,m)},ds.unmountComponentAtNode=function(o){if(!ku(o))throw Error(s(40));return o._reactRootContainer?(ga(function(){Nu(null,null,o,!1,function(){o._reactRootContainer=null,o[Mr]=null})}),!0):!1},ds.unstable_batchedUpdates=vp,ds.unstable_renderSubtreeIntoContainer=function(o,l,m,w){if(!ku(m))throw Error(s(200));if(o==null||o._reactInternals===void 0)throw Error(s(38));return Nu(o,l,m,!1,w)},ds.version="18.3.1-next-f1338f8080-20240426",ds}var Bw;function fN(){if(Bw)return Tp.exports;Bw=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Tp.exports=B_(),Tp.exports}var Gw;function G_(){if(Gw)return Cu;Gw=1;var e=fN();return Cu.createRoot=e.createRoot,Cu.hydrateRoot=e.hydrateRoot,Cu}var q_=G_();function Zn(e){const n=e&&typeof e=="object"?e.sdk:void 0;return(n==null?void 0:n.runtime)==="claude-agent-sdk"||(n==null?void 0:n.runtime)==="codex-sdk"?{runtime:n.runtime}:void 0}const Ko=e=>e==="claude-agent-sdk"?"Claude Agent SDK":"Codex SDK";/**
|
|
41
|
+
* @license lucide-react v0.468.0 - ISC
|
|
42
|
+
*
|
|
43
|
+
* This source code is licensed under the ISC license.
|
|
44
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
45
|
+
*/const K_=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),mN=(...e)=>e.filter((n,s,r)=>!!n&&n.trim()!==""&&r.indexOf(n)===s).join(" ").trim();/**
|
|
46
|
+
* @license lucide-react v0.468.0 - ISC
|
|
47
|
+
*
|
|
48
|
+
* This source code is licensed under the ISC license.
|
|
49
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
50
|
+
*/var 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 Y_=p.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:c,...d},u)=>p.createElement("svg",{ref:u,...V_,width:n,height:n,stroke:e,strokeWidth:r?Number(s)*24/Number(n):s,className:mN("lucide",a),...d},[...c.map(([f,x])=>p.createElement(f,x)),...Array.isArray(i)?i:[i]]));/**
|
|
56
|
+
* @license lucide-react v0.468.0 - ISC
|
|
57
|
+
*
|
|
58
|
+
* This source code is licensed under the ISC license.
|
|
59
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
60
|
+
*/const Te=(e,n)=>{const s=p.forwardRef(({className:r,...a},i)=>p.createElement(Y_,{ref:i,iconNode:n,className:mN(`lucide-${K_(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 Q_=Te("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
|
|
66
|
+
* @license lucide-react v0.468.0 - ISC
|
|
67
|
+
*
|
|
68
|
+
* This source code is licensed under the ISC license.
|
|
69
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
70
|
+
*/const hN=Te("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
|
|
71
|
+
* @license lucide-react v0.468.0 - ISC
|
|
72
|
+
*
|
|
73
|
+
* This source code is licensed under the ISC license.
|
|
74
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
75
|
+
*/const qc=Te("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
|
|
76
|
+
* @license lucide-react v0.468.0 - ISC
|
|
77
|
+
*
|
|
78
|
+
* This source code is licensed under the ISC license.
|
|
79
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
80
|
+
*/const zn=Te("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
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 Ex=Te("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
|
|
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 cr=Te("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
|
|
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 pN=Te("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
|
|
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 Zf=Te("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/**
|
|
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 ff=Te("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"}]]);/**
|
|
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 $x=Te("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
|
|
111
|
+
* @license lucide-react v0.468.0 - ISC
|
|
112
|
+
*
|
|
113
|
+
* This source code is licensed under the ISC license.
|
|
114
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
115
|
+
*/const mf=Te("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
|
|
116
|
+
* @license lucide-react v0.468.0 - ISC
|
|
117
|
+
*
|
|
118
|
+
* This source code is licensed under the ISC license.
|
|
119
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
120
|
+
*/const em=Te("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
|
|
121
|
+
* @license lucide-react v0.468.0 - ISC
|
|
122
|
+
*
|
|
123
|
+
* This source code is licensed under the ISC license.
|
|
124
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
125
|
+
*/const cl=Te("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
|
126
|
+
* @license lucide-react v0.468.0 - ISC
|
|
127
|
+
*
|
|
128
|
+
* This source code is licensed under the ISC license.
|
|
129
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
130
|
+
*/const Tr=Te("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
131
|
+
* @license lucide-react v0.468.0 - ISC
|
|
132
|
+
*
|
|
133
|
+
* This source code is licensed under the ISC license.
|
|
134
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
135
|
+
*/const J_=Te("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
|
136
|
+
* @license lucide-react v0.468.0 - ISC
|
|
137
|
+
*
|
|
138
|
+
* This source code is licensed under the ISC license.
|
|
139
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
140
|
+
*/const Cs=Te("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
141
|
+
* @license lucide-react v0.468.0 - ISC
|
|
142
|
+
*
|
|
143
|
+
* This source code is licensed under the ISC license.
|
|
144
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
145
|
+
*/const Ji=Te("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
|
146
|
+
* @license lucide-react v0.468.0 - ISC
|
|
147
|
+
*
|
|
148
|
+
* This source code is licensed under the ISC license.
|
|
149
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
150
|
+
*/const X_=Te("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/**
|
|
151
|
+
* @license lucide-react v0.468.0 - ISC
|
|
152
|
+
*
|
|
153
|
+
* This source code is licensed under the ISC license.
|
|
154
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
155
|
+
*/const gN=Te("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
156
|
+
* @license lucide-react v0.468.0 - ISC
|
|
157
|
+
*
|
|
158
|
+
* This source code is licensed under the ISC license.
|
|
159
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
160
|
+
*/const _x=Te("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/**
|
|
161
|
+
* @license lucide-react v0.468.0 - ISC
|
|
162
|
+
*
|
|
163
|
+
* This source code is licensed under the ISC license.
|
|
164
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
165
|
+
*/const Z_=Te("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
|
|
166
|
+
* @license lucide-react v0.468.0 - ISC
|
|
167
|
+
*
|
|
168
|
+
* This source code is licensed under the ISC license.
|
|
169
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
170
|
+
*/const xN=Te("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
|
|
171
|
+
* @license lucide-react v0.468.0 - ISC
|
|
172
|
+
*
|
|
173
|
+
* This source code is licensed under the ISC license.
|
|
174
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
175
|
+
*/const eT=Te("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/**
|
|
176
|
+
* @license lucide-react v0.468.0 - ISC
|
|
177
|
+
*
|
|
178
|
+
* This source code is licensed under the ISC license.
|
|
179
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
180
|
+
*/const tT=Te("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
|
181
|
+
* @license lucide-react v0.468.0 - ISC
|
|
182
|
+
*
|
|
183
|
+
* This source code is licensed under the ISC license.
|
|
184
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
185
|
+
*/const tm=Te("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
|
|
186
|
+
* @license lucide-react v0.468.0 - ISC
|
|
187
|
+
*
|
|
188
|
+
* This source code is licensed under the ISC license.
|
|
189
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
190
|
+
*/const Ba=Te("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
191
|
+
* @license lucide-react v0.468.0 - ISC
|
|
192
|
+
*
|
|
193
|
+
* This source code is licensed under the ISC license.
|
|
194
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
195
|
+
*/const nT=Te("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/**
|
|
196
|
+
* @license lucide-react v0.468.0 - ISC
|
|
197
|
+
*
|
|
198
|
+
* This source code is licensed under the ISC license.
|
|
199
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
200
|
+
*/const sT=Te("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
|
|
201
|
+
* @license lucide-react v0.468.0 - ISC
|
|
202
|
+
*
|
|
203
|
+
* This source code is licensed under the ISC license.
|
|
204
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
205
|
+
*/const rT=Te("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
206
|
+
* @license lucide-react v0.468.0 - ISC
|
|
207
|
+
*
|
|
208
|
+
* This source code is licensed under the ISC license.
|
|
209
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
210
|
+
*/const oT=Te("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
|
|
211
|
+
* @license lucide-react v0.468.0 - ISC
|
|
212
|
+
*
|
|
213
|
+
* This source code is licensed under the ISC license.
|
|
214
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
215
|
+
*/const Tx=Te("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
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 Ga=Te("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
|
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 vN=Te("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
|
|
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 aT=Te("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
|
|
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 nm=Te("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/**
|
|
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 qw=Te("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/**
|
|
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 yN=Te("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
|
|
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 iT=Te("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/**
|
|
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 lT=Te("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
|
|
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 Kc=Te("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
|
|
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 Rx=Te("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/**
|
|
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 jg=Te("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
|
|
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 Ma=Te("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
|
|
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 cT=Te("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"}]]);/**
|
|
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 dT=Te("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
|
|
286
|
+
* @license lucide-react v0.468.0 - ISC
|
|
287
|
+
*
|
|
288
|
+
* This source code is licensed under the ISC license.
|
|
289
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
290
|
+
*/const Ax=Te("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
|
|
291
|
+
* @license lucide-react v0.468.0 - ISC
|
|
292
|
+
*
|
|
293
|
+
* This source code is licensed under the ISC license.
|
|
294
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
295
|
+
*/const uT=Te("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
|
|
296
|
+
* @license lucide-react v0.468.0 - ISC
|
|
297
|
+
*
|
|
298
|
+
* This source code is licensed under the ISC license.
|
|
299
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
300
|
+
*/const fT=Te("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
301
|
+
* @license lucide-react v0.468.0 - ISC
|
|
302
|
+
*
|
|
303
|
+
* This source code is licensed under the ISC license.
|
|
304
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
305
|
+
*/const Op=Te("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/**
|
|
306
|
+
* @license lucide-react v0.468.0 - ISC
|
|
307
|
+
*
|
|
308
|
+
* This source code is licensed under the ISC license.
|
|
309
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
310
|
+
*/const mT=Te("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
|
311
|
+
* @license lucide-react v0.468.0 - ISC
|
|
312
|
+
*
|
|
313
|
+
* This source code is licensed under the ISC license.
|
|
314
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
315
|
+
*/const hT=Te("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
|
316
|
+
* @license lucide-react v0.468.0 - ISC
|
|
317
|
+
*
|
|
318
|
+
* This source code is licensed under the ISC license.
|
|
319
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
320
|
+
*/const pT=Te("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
321
|
+
* @license lucide-react v0.468.0 - ISC
|
|
322
|
+
*
|
|
323
|
+
* This source code is licensed under the ISC license.
|
|
324
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
325
|
+
*/const gT=Te("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
|
|
326
|
+
* @license lucide-react v0.468.0 - ISC
|
|
327
|
+
*
|
|
328
|
+
* This source code is licensed under the ISC license.
|
|
329
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
330
|
+
*/const Ox=Te("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
331
|
+
* @license lucide-react v0.468.0 - ISC
|
|
332
|
+
*
|
|
333
|
+
* This source code is licensed under the ISC license.
|
|
334
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
335
|
+
*/const xT=Te("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/**
|
|
336
|
+
* @license lucide-react v0.468.0 - ISC
|
|
337
|
+
*
|
|
338
|
+
* This source code is licensed under the ISC license.
|
|
339
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
340
|
+
*/const vT=Te("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
341
|
+
* @license lucide-react v0.468.0 - ISC
|
|
342
|
+
*
|
|
343
|
+
* This source code is licensed under the ISC license.
|
|
344
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
345
|
+
*/const qa=Te("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
|
|
346
|
+
* @license lucide-react v0.468.0 - ISC
|
|
347
|
+
*
|
|
348
|
+
* This source code is licensed under the ISC license.
|
|
349
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
350
|
+
*/const yT=Te("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
351
|
+
* @license lucide-react v0.468.0 - ISC
|
|
352
|
+
*
|
|
353
|
+
* This source code is licensed under the ISC license.
|
|
354
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
355
|
+
*/const bT=Te("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
|
|
356
|
+
* @license lucide-react v0.468.0 - ISC
|
|
357
|
+
*
|
|
358
|
+
* This source code is licensed under the ISC license.
|
|
359
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
360
|
+
*/const wT=Te("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);/**
|
|
361
|
+
* @license lucide-react v0.468.0 - ISC
|
|
362
|
+
*
|
|
363
|
+
* This source code is licensed under the ISC license.
|
|
364
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
365
|
+
*/const Xi=Te("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
|
|
366
|
+
* @license lucide-react v0.468.0 - ISC
|
|
367
|
+
*
|
|
368
|
+
* This source code is licensed under the ISC license.
|
|
369
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
370
|
+
*/const Mx=Te("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
|
|
371
|
+
* @license lucide-react v0.468.0 - ISC
|
|
372
|
+
*
|
|
373
|
+
* This source code is licensed under the ISC license.
|
|
374
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
375
|
+
*/const Vo=Te("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
|
|
376
|
+
* @license lucide-react v0.468.0 - ISC
|
|
377
|
+
*
|
|
378
|
+
* This source code is licensed under the ISC license.
|
|
379
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
380
|
+
*/const jT=Te("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
|
|
381
|
+
* @license lucide-react v0.468.0 - ISC
|
|
382
|
+
*
|
|
383
|
+
* This source code is licensed under the ISC license.
|
|
384
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
385
|
+
*/const dl=Te("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
386
|
+
* @license lucide-react v0.468.0 - ISC
|
|
387
|
+
*
|
|
388
|
+
* This source code is licensed under the ISC license.
|
|
389
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
390
|
+
*/const kT=Te("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/**
|
|
391
|
+
* @license lucide-react v0.468.0 - ISC
|
|
392
|
+
*
|
|
393
|
+
* This source code is licensed under the ISC license.
|
|
394
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
395
|
+
*/const Px=Te("RadioTower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);/**
|
|
396
|
+
* @license lucide-react v0.468.0 - ISC
|
|
397
|
+
*
|
|
398
|
+
* This source code is licensed under the ISC license.
|
|
399
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
400
|
+
*/const Yo=Te("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
|
|
401
|
+
* @license lucide-react v0.468.0 - ISC
|
|
402
|
+
*
|
|
403
|
+
* This source code is licensed under the ISC license.
|
|
404
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
405
|
+
*/const bN=Te("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
|
|
406
|
+
* @license lucide-react v0.468.0 - ISC
|
|
407
|
+
*
|
|
408
|
+
* This source code is licensed under the ISC license.
|
|
409
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
410
|
+
*/const NT=Te("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/**
|
|
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 sm=Te("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
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 wN=Te("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
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 ST=Te("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
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 jN=Te("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
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 kN=Te("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
|
|
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 Lx=Te("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
|
|
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 CT=Te("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
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 ET=Te("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
|
|
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 $T=Te("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
|
|
456
|
+
* @license lucide-react v0.468.0 - ISC
|
|
457
|
+
*
|
|
458
|
+
* This source code is licensed under the ISC license.
|
|
459
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
460
|
+
*/const NN=Te("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
|
461
|
+
* @license lucide-react v0.468.0 - ISC
|
|
462
|
+
*
|
|
463
|
+
* This source code is licensed under the ISC license.
|
|
464
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
465
|
+
*/const Gs=Te("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
466
|
+
* @license lucide-react v0.468.0 - ISC
|
|
467
|
+
*
|
|
468
|
+
* This source code is licensed under the ISC license.
|
|
469
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
470
|
+
*/const Ix=Te("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
|
|
471
|
+
* @license lucide-react v0.468.0 - ISC
|
|
472
|
+
*
|
|
473
|
+
* This source code is licensed under the ISC license.
|
|
474
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
475
|
+
*/const Zi=Te("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/**
|
|
476
|
+
* @license lucide-react v0.468.0 - ISC
|
|
477
|
+
*
|
|
478
|
+
* This source code is licensed under the ISC license.
|
|
479
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
480
|
+
*/const SN=Te("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
|
481
|
+
* @license lucide-react v0.468.0 - ISC
|
|
482
|
+
*
|
|
483
|
+
* This source code is licensed under the ISC license.
|
|
484
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
485
|
+
*/const Ka=Te("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/**
|
|
486
|
+
* @license lucide-react v0.468.0 - ISC
|
|
487
|
+
*
|
|
488
|
+
* This source code is licensed under the ISC license.
|
|
489
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
490
|
+
*/const hf=Te("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
|
|
491
|
+
* @license lucide-react v0.468.0 - ISC
|
|
492
|
+
*
|
|
493
|
+
* This source code is licensed under the ISC license.
|
|
494
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
495
|
+
*/const Qo=Te("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
|
|
496
|
+
* @license lucide-react v0.468.0 - ISC
|
|
497
|
+
*
|
|
498
|
+
* This source code is licensed under the ISC license.
|
|
499
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
500
|
+
*/const _T=Te("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function CN(e){var n,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(n=0;n<a;n++)e[n]&&(s=CN(e[n]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function EN(){for(var e,n,s=0,r="",a=arguments.length;s<a;s++)(e=arguments[s])&&(n=CN(e))&&(r&&(r+=" "),r+=n);return r}const zx="-",TT=e=>{const n=AT(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const d=c.split(zx);return d[0]===""&&d.length!==1&&d.shift(),$N(d,n)||RT(c)},getConflictingClassGroupIds:(c,d)=>{const u=s[c]||[];return d&&r[c]?[...u,...r[c]]:u}}},$N=(e,n)=>{var c;if(e.length===0)return n.classGroupId;const s=e[0],r=n.nextPart.get(s),a=r?$N(e.slice(1),r):void 0;if(a)return a;if(n.validators.length===0)return;const i=e.join(zx);return(c=n.validators.find(({validator:d})=>d(i)))==null?void 0:c.classGroupId},Kw=/^\[(.+)\]$/,RT=e=>{if(Kw.test(e)){const n=Kw.exec(e)[1],s=n==null?void 0:n.substring(0,n.indexOf(":"));if(s)return"arbitrary.."+s}},AT=e=>{const{theme:n,prefix:s}=e,r={nextPart:new Map,validators:[]};return MT(Object.entries(e.classGroups),s).forEach(([i,c])=>{kg(c,r,i,n)}),r},kg=(e,n,s,r)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?n:Vw(n,a);i.classGroupId=s;return}if(typeof a=="function"){if(OT(a)){kg(a(r),n,s,r);return}n.validators.push({validator:a,classGroupId:s});return}Object.entries(a).forEach(([i,c])=>{kg(c,Vw(n,i),s,r)})})},Vw=(e,n)=>{let s=e;return n.split(zx).forEach(r=>{s.nextPart.has(r)||s.nextPart.set(r,{nextPart:new Map,validators:[]}),s=s.nextPart.get(r)}),s},OT=e=>e.isThemeGetter,MT=(e,n)=>n?e.map(([s,r])=>{const a=r.map(i=>typeof i=="string"?n+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([c,d])=>[n+c,d])):i);return[s,a]}):e,PT=e=>{if(e<1)return{get:()=>{},set:()=>{}};let n=0,s=new Map,r=new Map;const a=(i,c)=>{s.set(i,c),n++,n>e&&(n=0,r=s,s=new Map)};return{get(i){let c=s.get(i);if(c!==void 0)return c;if((c=r.get(i))!==void 0)return a(i,c),c},set(i,c){s.has(i)?s.set(i,c):a(i,c)}}},_N="!",LT=e=>{const{separator:n,experimentalParseClassName:s}=e,r=n.length===1,a=n[0],i=n.length,c=d=>{const u=[];let f=0,x=0,b;for(let j=0;j<d.length;j++){let k=d[j];if(f===0){if(k===a&&(r||d.slice(j,j+i)===n)){u.push(d.slice(x,j)),x=j+i;continue}if(k==="/"){b=j;continue}}k==="["?f++:k==="]"&&f--}const g=u.length===0?d:d.substring(x),h=g.startsWith(_N),v=h?g.substring(1):g,y=b&&b>x?b-x:void 0;return{modifiers:u,hasImportantModifier:h,baseClassName:v,maybePostfixModifierPosition:y}};return s?d=>s({className:d,parseClassName:c}):c},IT=e=>{if(e.length<=1)return e;const n=[];let s=[];return e.forEach(r=>{r[0]==="["?(n.push(...s.sort(),r),s=[]):s.push(r)}),n.push(...s.sort()),n},zT=e=>({cache:PT(e.cacheSize),parseClassName:LT(e),...TT(e)}),DT=/\s+/,FT=(e,n)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:a}=n,i=[],c=e.trim().split(DT);let d="";for(let u=c.length-1;u>=0;u-=1){const f=c[u],{modifiers:x,hasImportantModifier:b,baseClassName:g,maybePostfixModifierPosition:h}=s(f);let v=!!h,y=r(v?g.substring(0,h):g);if(!y){if(!v){d=f+(d.length>0?" "+d:d);continue}if(y=r(g),!y){d=f+(d.length>0?" "+d:d);continue}v=!1}const j=IT(x).join(":"),k=b?j+_N:j,$=k+y;if(i.includes($))continue;i.push($);const S=a(y,v);for(let N=0;N<S.length;++N){const _=S[N];i.push(k+_)}d=f+(d.length>0?" "+d:d)}return d};function UT(){let e=0,n,s,r="";for(;e<arguments.length;)(n=arguments[e++])&&(s=TN(n))&&(r&&(r+=" "),r+=s);return r}const TN=e=>{if(typeof e=="string")return e;let n,s="";for(let r=0;r<e.length;r++)e[r]&&(n=TN(e[r]))&&(s&&(s+=" "),s+=n);return s};function Yw(e,...n){let s,r,a,i=c;function c(u){const f=n.reduce((x,b)=>b(x),e());return s=zT(f),r=s.cache.get,a=s.cache.set,i=d,d(u)}function d(u){const f=r(u);if(f)return f;const x=FT(u,s);return a(u,x),x}return function(){return i(UT.apply(null,arguments))}}const Bt=e=>{const n=s=>s[e]||[];return n.isThemeGetter=!0,n},RN=/^\[(?:([a-z-]+):)?(.+)\]$/i,WT=/^\d+\/\d+$/,HT=new Set(["px","full","screen"]),BT=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,GT=/\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$/,qT=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,KT=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,VT=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Wr=e=>Fi(e)||HT.has(e)||WT.test(e),$o=e=>ul(e,"length",nR),Fi=e=>!!e&&!Number.isNaN(Number(e)),Mp=e=>ul(e,"number",Fi),ec=e=>!!e&&Number.isInteger(Number(e)),YT=e=>e.endsWith("%")&&Fi(e.slice(0,-1)),ht=e=>RN.test(e),_o=e=>BT.test(e),QT=new Set(["length","size","percentage"]),JT=e=>ul(e,QT,AN),XT=e=>ul(e,"position",AN),ZT=new Set(["image","url"]),eR=e=>ul(e,ZT,rR),tR=e=>ul(e,"",sR),tc=()=>!0,ul=(e,n,s)=>{const r=RN.exec(e);return r?r[1]?typeof n=="string"?r[1]===n:n.has(r[1]):s(r[2]):!1},nR=e=>GT.test(e)&&!qT.test(e),AN=()=>!1,sR=e=>KT.test(e),rR=e=>VT.test(e),Qw=()=>{const e=Bt("colors"),n=Bt("spacing"),s=Bt("blur"),r=Bt("brightness"),a=Bt("borderColor"),i=Bt("borderRadius"),c=Bt("borderSpacing"),d=Bt("borderWidth"),u=Bt("contrast"),f=Bt("grayscale"),x=Bt("hueRotate"),b=Bt("invert"),g=Bt("gap"),h=Bt("gradientColorStops"),v=Bt("gradientColorStopPositions"),y=Bt("inset"),j=Bt("margin"),k=Bt("opacity"),$=Bt("padding"),S=Bt("saturate"),N=Bt("scale"),_=Bt("sepia"),E=Bt("skew"),O=Bt("space"),A=Bt("translate"),I=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto",ht,n],P=()=>[ht,n],D=()=>["",Wr,$o],W=()=>["auto",Fi,ht],Y=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],H=()=>["solid","dashed","dotted","double","none"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F=()=>["start","end","center","between","around","evenly","stretch"],G=()=>["","0",ht],U=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[Fi,ht];return{cacheSize:500,separator:":",theme:{colors:[tc],spacing:[Wr,$o],blur:["none","",_o,ht],brightness:z(),borderColor:[e],borderRadius:["none","","full",_o,ht],borderSpacing:P(),borderWidth:D(),contrast:z(),grayscale:G(),hueRotate:z(),invert:G(),gap:P(),gradientColorStops:[e],gradientColorStopPositions:[YT,$o],inset:R(),margin:R(),opacity:z(),padding:P(),saturate:z(),scale:z(),sepia:G(),skew:z(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",ht]}],container:["container"],columns:[{columns:[_o]}],"break-after":[{"break-after":U()}],"break-before":[{"break-before":U()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Y(),ht]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ec,ht]}],basis:[{basis:R()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ht]}],grow:[{grow:G()}],shrink:[{shrink:G()}],order:[{order:["first","last","none",ec,ht]}],"grid-cols":[{"grid-cols":[tc]}],"col-start-end":[{col:["auto",{span:["full",ec,ht]},ht]}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":[tc]}],"row-start-end":[{row:["auto",{span:[ec,ht]},ht]}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ht]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ht]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...F()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...F(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...F(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[$]}],px:[{px:[$]}],py:[{py:[$]}],ps:[{ps:[$]}],pe:[{pe:[$]}],pt:[{pt:[$]}],pr:[{pr:[$]}],pb:[{pb:[$]}],pl:[{pl:[$]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[O]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[O]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ht,n]}],"min-w":[{"min-w":[ht,n,"min","max","fit"]}],"max-w":[{"max-w":[ht,n,"none","full","min","max","fit","prose",{screen:[_o]},_o]}],h:[{h:[ht,n,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ht,n,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ht,n,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ht,n,"auto","min","max","fit"]}],"font-size":[{text:["base",_o,$o]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Mp]}],"font-family":[{font:[tc]}],"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",ht]}],"line-clamp":[{"line-clamp":["none",Fi,Mp]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Wr,ht]}],"list-image":[{"list-image":["none",ht]}],"list-style-type":[{list:["none","disc","decimal",ht]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Wr,$o]}],"underline-offset":[{"underline-offset":["auto",Wr,ht]}],"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:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ht]}],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",ht]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Y(),XT]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",JT]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},eR]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[d]}],"border-w-x":[{"border-x":[d]}],"border-w-y":[{"border-y":[d]}],"border-w-s":[{"border-s":[d]}],"border-w-e":[{"border-e":[d]}],"border-w-t":[{"border-t":[d]}],"border-w-r":[{"border-r":[d]}],"border-w-b":[{"border-b":[d]}],"border-w-l":[{"border-l":[d]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...H(),"hidden"]}],"divide-x":[{"divide-x":[d]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[d]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:H()}],"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:["",...H()]}],"outline-offset":[{"outline-offset":[Wr,ht]}],"outline-w":[{outline:[Wr,$o]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Wr,$o]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",_o,tR]}],"shadow-color":[{shadow:[tc]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...q(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":q()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",_o,ht]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[x]}],invert:[{invert:[b]}],saturate:[{saturate:[S]}],sepia:[{sepia:[_]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[x]}],"backdrop-invert":[{"backdrop-invert":[b]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[S]}],"backdrop-sepia":[{"backdrop-sepia":[_]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ht]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",ht]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",ht]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[N]}],"scale-x":[{"scale-x":[N]}],"scale-y":[{"scale-y":[N]}],rotate:[{rotate:[ec,ht]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[E]}],"skew-y":[{"skew-y":[E]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ht]}],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",ht]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"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",ht]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Wr,$o,Mp]}],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"]}}},oR=(e,{cacheSize:n,prefix:s,separator:r,experimentalParseClassName:a,extend:i={},override:c={}})=>{hc(e,"cacheSize",n),hc(e,"prefix",s),hc(e,"separator",r),hc(e,"experimentalParseClassName",a);for(const d in c)aR(e[d],c[d]);for(const d in i)iR(e[d],i[d]);return e},hc=(e,n,s)=>{s!==void 0&&(e[n]=s)},aR=(e,n)=>{if(n)for(const s in n)hc(e,s,n[s])},iR=(e,n)=>{if(n)for(const s in n){const r=n[s];r!==void 0&&(e[s]=(e[s]||[]).concat(r))}},lR=(e,...n)=>typeof e=="function"?Yw(Qw,e,...n):Yw(()=>oR(Qw(),e),...n),cR=lR({override:{conflictingClassGroups:{"font-size":[]}},extend:{theme:{spacing:["sidebar","control-sm","control-md","control-lg"],borderRadius:["composer","action"]},classGroups:{"max-w":[{"max-w":["page","page-wide"]}],"font-size":[{text:["micro","label","small","body","lead","prose","figure","display"]}],z:[{z:["raised","sticky","overlay","dialog","popover","toast"]}],shadow:[{shadow:["float"]}],duration:[{duration:["fast","base","slow"]}],ease:[{ease:["standard"]}],"outline-w":[{outline:["focus"]}],"outline-offset":[{"outline-offset":["focus"]}]}}}),ae=(...e)=>cR(EN(e)),dR={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:jg},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:jg},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:gN},warning:{box:"border-warning/50 bg-warning/5",text:"text-warning-text",Icon:Gs},error:{box:"border-destructive/50 bg-destructive/5",text:"text-destructive-text",Icon:Ji}};function xt({tone:e="neutral",title:n,actions:s,bar:r,icon:a,role:i,className:c,children:d,...u}){const f=dR[e],x=a===!1?null:a??f.Icon;return t.jsxs("div",{role:i??(e==="error"?"alert":"status"),...u,className:ae("flex gap-3 text-body",r?"shrink-0 items-center border-b bg-card px-5 py-2 md:px-8":ae("border p-4",f.box),c),children:[x&&t.jsx(x,{className:ae("size-4 shrink-0",!r&&"mt-0.5",f.text),"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[n&&t.jsx("p",{className:ae("font-semibold",!r&&"caps text-small",!r&&f.text),children:n}),d&&t.jsx("div",{className:ae(n&&!r&&"mt-2"),children:d})]}),s&&t.jsx("div",{className:"flex shrink-0 items-start gap-2",children:s})]})}const Jw=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Xw=EN,uR=(e,n)=>s=>{var r;if((n==null?void 0:n.variants)==null)return Xw(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:a,defaultVariants:i}=n,c=Object.keys(a).map(f=>{const x=s==null?void 0:s[f],b=i==null?void 0:i[f];if(x===null)return null;const g=Jw(x)||Jw(b);return a[f][g]}),d=s&&Object.entries(s).reduce((f,x)=>{let[b,g]=x;return g===void 0||(f[b]=g),f},{}),u=n==null||(r=n.compoundVariants)===null||r===void 0?void 0:r.reduce((f,x)=>{let{class:b,className:g,...h}=x;return Object.entries(h).every(v=>{let[y,j]=v;return Array.isArray(j)?j.includes({...i,...d}[y]):{...i,...d}[y]===j})?[...f,b,g]:f},[]);return Xw(e,c,u,s==null?void 0:s.class,s==null?void 0:s.className)},$c=uR("caps inline-flex items-center justify-center gap-2 whitespace-nowrap !rounded-action border text-small transition-colors disabled:cursor-not-allowed disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0",{variants:{variant:{outline:"border-border bg-background hover:border-border-strong hover:bg-accent",primary:"border-transparent bg-primary/10 text-primary-action-text hover:bg-primary/20 focus-visible:bg-primary/20",solid:"border-transparent bg-primary/10 text-primary-action-text hover:bg-primary/20 focus-visible:bg-primary/20",destructive:"border-destructive/60 text-destructive-text hover:bg-destructive/10",ghost:"border-transparent hover:bg-accent"},size:{xs:"h-7 gap-1.5 px-2 text-label",sm:"h-control-sm px-3",md:"h-control-md px-4",lg:"h-control-lg px-5",icon:"size-control-sm"}},defaultVariants:{variant:"outline",size:"md"}}),B=p.forwardRef(({className:e,variant:n,size:s,...r},a)=>t.jsx("button",{ref:a,className:ae($c({variant:n,size:s}),e),...r}));B.displayName="Button";const Zw={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 je({tone:e="plain",className:n,title:s,label:r,children:a}){return r?t.jsx("span",{title:s,className:ae("caps inline-flex h-5 min-w-0 items-center gap-1 border px-1.5 text-micro leading-none",Zw[e],n),children:t.jsx("span",{className:"min-w-0 truncate",children:a})}):t.jsx("span",{title:s,className:ae("caps inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap border px-1.5 text-micro leading-none",Zw[e],n),children:a})}const qs=e=>fR(e)?e.document:mR(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),rm=e=>{let n=qs(e);return(n==null?void 0:n.defaultView)??(typeof window<"u"?window:void 0)};function ON(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function fR(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function mR(e){return ON(e)&&e.nodeType===9}function hR(e){return ON(e)&&e.nodeType===11&&"host"in e}let pR=!1;function Dx(){return pR}function $a(e,n){var r;if(!Dx())return n&&e?e.contains(n):!1;if(!e||!n)return!1;let s=n;for(;s!=null;){if(s===e)return!0;typeof s.assignedElements!="function"&&((r=s.assignedSlot)!=null&&r.parentNode)?s=s.assignedSlot.parentNode:hR(s)?s=s.host:s=s.parentNode}return!1}const Wo=(e=document)=>{var s;if(!Dx())return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&((s=n.shadowRoot)!=null&&s.activeElement);)n=n.shadowRoot.activeElement;return n};function Qn(e){if(Dx()&&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 gR(e){e.focus({preventScroll:!0})}const xR=typeof document<"u"?He.useLayoutEffect:()=>{};function MN(e){let n=e;return n.nativeEvent=e,n.isDefaultPrevented=()=>n.defaultPrevented,n.isPropagationStopped=()=>n.cancelBubble,n.persist=()=>{},n}function vR(e,n){Object.defineProperty(e,"target",{value:n}),Object.defineProperty(e,"currentTarget",{value:n})}function PN(e){let n=p.useRef({isFocused:!1,observer:null});return xR(()=>{const s=n.current;return()=>{s.observer&&(s.observer.disconnect(),s.observer=null)}},[]),p.useCallback(s=>{let r=Qn(s);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){n.current.isFocused=!0;let a=r,i=c=>{if(n.current.isFocused=!1,a.disabled){let d=MN(c);e==null||e(d)}n.current.observer&&(n.current.observer.disconnect(),n.current.observer=null)};a.addEventListener("focusout",i,{once:!0}),n.current.observer=new MutationObserver(()=>{var c;if(n.current.isFocused&&a.disabled){(c=n.current.observer)==null||c.disconnect();let d=a===Wo()?null:Wo();a.dispatchEvent(new FocusEvent("blur",{relatedTarget:d})),a.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:d}))}}),n.current.observer.observe(a,{attributes:!0,attributeFilter:["disabled"]})}},[e])}function Fx(e){var s;if(typeof window>"u"||window.navigator==null)return!1;let n=(s=window.navigator.userAgentData)==null?void 0:s.brands;return Array.isArray(n)&&n.some(r=>e.test(r.brand))||e.test(window.navigator.userAgent)}function Ux(e){var n;return typeof window<"u"&&window.navigator!=null?e.test(((n=window.navigator.userAgentData)==null?void 0:n.platform)||window.navigator.platform):!1}function Va(e){let n=null;return()=>(n==null&&(n=e()),n)}const Wx=Va(function(){return Ux(/^Mac/i)}),yR=Va(function(){return Ux(/^iPhone/i)}),LN=Va(function(){return Ux(/^iPad/i)||Wx()&&navigator.maxTouchPoints>1}),bR=Va(function(){return yR()||LN()}),wR=Va(function(){return Fx(/AppleWebKit/i)&&(bR()||!jR())}),jR=Va(function(){return Fx(/Chrome|CriOS|CrMo/i)}),kR=Va(function(){return Fx(/Android/i)});function NR(e){return e.pointerType===""&&e.isTrusted?!0:kR()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function _c(e,n,s=!0){let{metaKey:r,ctrlKey:a,altKey:i,shiftKey:c}=n,d=wR()&&Wx()&&!LN()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:a,altKey:i,shiftKey:c}):new MouseEvent("click",{metaKey:r,ctrlKey:a,altKey:i,shiftKey:c,detail:1,bubbles:!0,cancelable:!0});_c.isOpening=s,gR(e),e.dispatchEvent(d),_c.isOpening=!1}_c.isOpening=!1;let fl=null;const Ng=new Set;let bc=new Map,Pa=!1,Zu=!1;const SR={Tab:!0,Escape:!0};function om(e,n){for(let s of Ng)s(e,n)}function CR(e){return!(e.metaKey||!Wx()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function pf(e){Pa=!0,!_c.isOpening&&CR(e)&&(fl="keyboard",om("keyboard",e))}function Ui(e){fl="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(Pa=!0,om("pointer",e))}function IN(e){!_c.isOpening&&NR(e)&&(Pa=!0,fl="virtual")}function zN(e){let n=Qn(e),s=rm(n),r=qs(n);if(n===s){Zu=!0;return}n===r||!e.isTrusted||(!Pa&&!Zu&&(fl="virtual",om("virtual",e)),Pa=!1,Zu=!1)}function DN(){Pa=!1,Zu=!0}function FN(e){let n=Wo(qs(Qn(e)));queueMicrotask(()=>{Wo(qs(Qn(e)))!==n&&$R("keyboard")})}function Sg(e){if(typeof window>"u"||typeof document>"u")return;const n=rm(e),s=qs(e);if(bc.get(n))return;let r=n.HTMLElement.prototype.focus;Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){Pa=!0,r.apply(this,arguments)}}),s.addEventListener("keydown",pf,!0),s.addEventListener("keyup",pf,!0),s.addEventListener("click",IN,!0),s.addEventListener("invalid",FN,!0),n.addEventListener("focus",zN,!0),n.addEventListener("blur",DN,!1),typeof PointerEvent<"u"&&(s.addEventListener("pointerdown",Ui,!0),s.addEventListener("pointermove",Ui,!0),s.addEventListener("pointerup",Ui,!0)),n.addEventListener("beforeunload",()=>{UN(e)},{once:!0}),bc.set(n,{focus:r})}const UN=(e,n)=>{const s=rm(e),r=qs(e);n&&r.removeEventListener("DOMContentLoaded",n),bc.has(s)&&(Reflect.defineProperty(s.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:bc.get(s).focus}),r.removeEventListener("keydown",pf,!0),r.removeEventListener("keyup",pf,!0),r.removeEventListener("click",IN,!0),r.removeEventListener("invalid",FN,!0),s.removeEventListener("focus",zN,!0),s.removeEventListener("blur",DN,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",Ui,!0),r.removeEventListener("pointermove",Ui,!0),r.removeEventListener("pointerup",Ui,!0)),bc.delete(s))};function ER(e){const n=qs(e);let s;return n.readyState!=="loading"?Sg(e):(s=()=>{Sg(e)},n.addEventListener("DOMContentLoaded",s)),()=>UN(e,s)}typeof document<"u"&&ER();function Cg(){return fl!=="pointer"}function $R(e){fl=e,om(e,null)}const _R=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function TR(e,n,s){let r=s?Qn(s):void 0,a=qs(r),i=rm(r);const c=typeof i<"u"?i.HTMLInputElement:HTMLInputElement,d=typeof i<"u"?i.HTMLTextAreaElement:HTMLTextAreaElement,u=typeof i<"u"?i.HTMLElement:HTMLElement,f=typeof i<"u"?i.KeyboardEvent:KeyboardEvent;let x=Wo(a);return e=e||x instanceof c&&!_R.has(x.type)||x instanceof d||x instanceof u&&x.isContentEditable,!(e&&n==="keyboard"&&s instanceof f&&!SR[s.key])}function RR(e,n,s){Sg(),p.useEffect(()=>{if((s==null?void 0:s.enabled)===!1)return;let r=(a,i)=>{TR(!!(s!=null&&s.isTextInput),a,i)&&e(Cg())};return Ng.add(r),()=>{Ng.delete(r)}},n)}function AR(e){let{isDisabled:n,onFocus:s,onBlur:r,onFocusChange:a}=e;const i=p.useCallback(u=>{if(Qn(u)===u.currentTarget)return r&&r(u),a&&a(!1),!0},[r,a]),c=PN(i),d=p.useCallback(u=>{let f=Qn(u);const x=qs(f),b=x?Wo(x):Wo();f===u.currentTarget&&f===b&&(s&&s(u),a&&a(!0),c(u))},[a,s,c]);return{focusProps:{onFocus:!n&&(s||a||r)?d:void 0,onBlur:!n&&(r||a)?i:void 0}}}function WN(){let e=p.useRef(new Map),n=p.useCallback((a,i,c,d)=>{let u=d!=null&&d.once?(...f)=>{e.current.delete(c),c(...f)}:c;e.current.set(c,{type:i,eventTarget:a,fn:u,options:d}),a.addEventListener(i,u,d)},[]),s=p.useCallback((a,i,c,d)=>{var f;let u=((f=e.current.get(c))==null?void 0:f.fn)||c;a.removeEventListener(i,u,d),e.current.delete(c)},[]),r=p.useCallback(()=>{e.current.forEach((a,i)=>{s(a.eventTarget,a.type,i,a.options)})},[s]);return p.useEffect(()=>r,[r]),{addGlobalListener:n,removeGlobalListener:s,removeAllGlobalListeners:r}}function OR(e){let{isDisabled:n,onBlurWithin:s,onFocusWithin:r,onFocusWithinChange:a}=e,i=p.useRef({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:d}=WN(),u=p.useCallback(b=>{$a(b.currentTarget,Qn(b))&&i.current.isFocusWithin&&!$a(b.currentTarget,b.relatedTarget)&&(i.current.isFocusWithin=!1,d(),s&&s(b),a&&a(!1))},[s,a,i,d]),f=PN(u),x=p.useCallback(b=>{if(!$a(b.currentTarget,Qn(b)))return;let g=Qn(b);const h=qs(g),v=Wo(h);if(!i.current.isFocusWithin&&v===g){r&&r(b),a&&a(!0),i.current.isFocusWithin=!0,f(b);let y=b.currentTarget;c(h,"focus",j=>{let k=Qn(j);if(i.current.isFocusWithin&&!$a(y,k)){let $=new h.defaultView.FocusEvent("blur",{relatedTarget:k});vR($,y);let S=MN($);u(S)}},{capture:!0})}},[r,a,f,c,u]);return n?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:x,onBlur:u}}}function MR(e={}){let{autoFocus:n=!1,isTextInput:s,within:r}=e,a=p.useRef({isFocused:!1,isFocusVisible:n||Cg()}),[i,c]=p.useState(!1),[d,u]=p.useState(()=>a.current.isFocused&&a.current.isFocusVisible),f=p.useCallback(()=>u(a.current.isFocused&&a.current.isFocusVisible),[]),x=p.useCallback(h=>{a.current.isFocused=h,a.current.isFocusVisible=Cg(),c(h),f()},[f]);RR(h=>{a.current.isFocusVisible=h,f()},[s,i],{enabled:i,isTextInput:s});let{focusProps:b}=AR({isDisabled:r,onFocusChange:x}),{focusWithinProps:g}=OR({isDisabled:!r,onFocusWithinChange:x});return{isFocused:i,isFocusVisible:d,focusProps:r?g:b}}var ks=fN();let Eg=!1,Eu=0;function PR(){Eg=!0,setTimeout(()=>{Eg=!1},500)}function ej(e){e.pointerType==="touch"&&PR()}function LR(){let e=qs(null);if(!(typeof e>"u"))return Eu===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",ej),Eu++,()=>{Eu--,!(Eu>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",ej)}}function IR(e){let{onHoverStart:n,onHoverChange:s,onHoverEnd:r,isDisabled:a}=e,[i,c]=p.useState(!1),d=p.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;p.useEffect(LR,[]);let{addGlobalListener:u,removeAllGlobalListeners:f}=WN(),{hoverProps:x,triggerHoverEnd:b}=p.useMemo(()=>{let g=(y,j)=>{if(d.pointerType=j,a||j==="touch"||d.isHovered||!$a(y.currentTarget,Qn(y)))return;d.isHovered=!0;let k=y.currentTarget;d.target=k,u(qs(Qn(y)),"pointerover",$=>{d.isHovered&&d.target&&!$a(d.target,Qn($))&&h($,$.pointerType)},{capture:!0}),n&&n({type:"hoverstart",target:k,pointerType:j}),s&&s(!0),c(!0)},h=(y,j)=>{let k=d.target;d.pointerType="",d.target=null,!(j==="touch"||!d.isHovered||!k)&&(d.isHovered=!1,f(),r&&r({type:"hoverend",target:k,pointerType:j}),s&&s(!1),c(!1))},v={};return typeof PointerEvent<"u"&&(v.onPointerEnter=y=>{Eg&&y.pointerType==="mouse"||g(y,y.pointerType)},v.onPointerLeave=y=>{!a&&$a(y.currentTarget,Qn(y))&&h(y,y.pointerType)}),{hoverProps:v,triggerHoverEnd:h}},[n,s,r,a,d,u,f]);return p.useEffect(()=>{a&&b({currentTarget:d.target},d.pointerType)},[a]),{hoverProps:x,isHovered:i}}var zR=Object.defineProperty,DR=(e,n,s)=>n in e?zR(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Pp=(e,n,s)=>(DR(e,typeof n!="symbol"?n+"":n,s),s);let FR=class{constructor(){Pp(this,"current",this.detect()),Pp(this,"handoffState","pending"),Pp(this,"currentId",0)}set(n){this.current!==n&&(this.handoffState="pending",this.currentId=0,this.current=n)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},Nr=new FR;function ml(e){var n;return Nr.isServer?null:e==null?document:(n=e==null?void 0:e.ownerDocument)!=null?n:document}function gf(e){var n,s;return Nr.isServer?null:e==null?document:(s=(n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))!=null?s:document}function HN(e){var n,s;return(s=(n=gf(e))==null?void 0:n.activeElement)!=null?s:null}function BN(e){return HN(e)===e}function am(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(n=>setTimeout(()=>{throw n}))}function Es(){let e=[],n={addEventListener(s,r,a,i){return s.addEventListener(r,a,i),n.add(()=>s.removeEventListener(r,a,i))},requestAnimationFrame(...s){let r=requestAnimationFrame(...s);return n.add(()=>cancelAnimationFrame(r))},nextFrame(...s){return n.requestAnimationFrame(()=>n.requestAnimationFrame(...s))},setTimeout(...s){let r=setTimeout(...s);return n.add(()=>clearTimeout(r))},microTask(...s){let r={current:!0};return am(()=>{r.current&&s[0]()}),n.add(()=>{r.current=!1})},style(s,r,a){let i=s.style.getPropertyValue(r);return Object.assign(s.style,{[r]:a}),this.add(()=>{Object.assign(s.style,{[r]:i})})},group(s){let r=Es();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 n}function Jo(){let[e]=p.useState(Es);return p.useEffect(()=>()=>e.dispose(),[e]),e}let Xt=(e,n)=>{Nr.isServer?p.useEffect(e,n):p.useLayoutEffect(e,n)};function Xo(e){let n=p.useRef(e);return Xt(()=>{n.current=e},[e]),n}let dt=function(e){let n=Xo(e);return He.useCallback((...s)=>n.current(...s),[n])};function UR(e){let n=e.width/2,s=e.height/2;return{top:e.clientY-s,right:e.clientX+n,bottom:e.clientY+s,left:e.clientX-n}}function WR(e,n){return!(!e||!n||e.right<n.left||e.left>n.right||e.bottom<n.top||e.top>n.bottom)}function HR({disabled:e=!1}={}){let n=p.useRef(null),[s,r]=p.useState(!1),a=Jo(),i=dt(()=>{n.current=null,r(!1),a.dispose()}),c=dt(d=>{if(a.dispose(),n.current===null){n.current=d.currentTarget,r(!0);{let u=ml(d.currentTarget);a.addEventListener(u,"pointerup",i,!1),a.addEventListener(u,"pointermove",f=>{if(n.current){let x=UR(f);r(WR(x,n.current.getBoundingClientRect()))}},!1),a.addEventListener(u,"pointercancel",i,!1)}}});return{pressed:s,pressProps:e?{}:{onPointerDown:c,onPointerUp:i,onClick:i}}}function Ks(e){return p.useMemo(()=>e,Object.values(e))}let BR=p.createContext(void 0);function Hx(){return p.useContext(BR)}function $g(...e){return Array.from(new Set(e.flatMap(n=>typeof n=="string"?n.split(" "):[]))).filter(Boolean).join(" ")}function es(e,n,...s){if(e in n){let a=n[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(n).map(a=>`"${a}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,es),r}var el=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(el||{}),Io=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Io||{});function Sn(){let e=qR();return p.useCallback(n=>GR({mergeRefs:e,...n}),[e])}function GR({ourProps:e,theirProps:n,slot:s,defaultTag:r,features:a,visible:i=!0,name:c,mergeRefs:d}){d=d??KR;let u=GN(n,e);if(i)return $u(u,s,r,c,d);let f=a??0;if(f&2){let{static:x=!1,...b}=u;if(x)return $u(b,s,r,c,d)}if(f&1){let{unmount:x=!0,...b}=u;return es(x?0:1,{0(){return null},1(){return $u({...b,hidden:!0,style:{display:"none"}},s,r,c,d)}})}return $u(u,s,r,c,d)}function $u(e,n={},s,r,a){let{as:i=s,children:c,refName:d="ref",...u}=Lp(e,["unmount","static"]),f=e.ref!==void 0?{[d]:e.ref}:{},x=typeof c=="function"?c(n):c;x=KN(x),"className"in u&&u.className&&typeof u.className=="function"&&(u.className=u.className(n)),u["aria-labelledby"]&&u["aria-labelledby"]===u.id&&(u["aria-labelledby"]=void 0);let b={};if(n){let g=!1,h=[];for(let[v,y]of Object.entries(n))typeof y=="boolean"&&(g=!0),y===!0&&h.push(v.replace(/([A-Z])/g,j=>`-${j.toLowerCase()}`));if(g){b["data-headlessui-state"]=h.join(" ");for(let v of h)b[`data-${v}`]=""}}if(wc(i)&&(Object.keys(Po(u)).length>0||Object.keys(Po(b)).length>0))if(!p.isValidElement(x)||Array.isArray(x)&&x.length>1||YR(x)){if(Object.keys(Po(u)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(Po(u)).concat(Object.keys(Po(b))).map(g=>` - ${g}`).join(`
|
|
501
|
+
`),"","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(g=>` - ${g}`).join(`
|
|
502
|
+
`)].join(`
|
|
503
|
+
`))}else{let g=x.props,h=g==null?void 0:g.className,v=typeof h=="function"?(...k)=>$g(h(...k),u.className):$g(h,u.className),y=v?{className:v}:{},j=GN(x.props,Po(Lp(u,["ref"])));for(let k in b)k in j&&delete b[k];return p.cloneElement(x,Object.assign({},j,b,f,{ref:a(VR(x),f.ref)},y))}return p.createElement(i,Object.assign({},Lp(u,["ref"]),!wc(i)&&f,!wc(i)&&b),x)}function qR(){let e=p.useRef([]),n=p.useCallback(s=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(s):r.current=s)},[]);return(...s)=>{if(!s.every(r=>r==null))return e.current=s,n}}function KR(...e){return e.every(n=>n==null)?void 0:n=>{for(let s of e)s!=null&&(typeof s=="function"?s(n):s.current=n)}}function GN(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},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])):n[a]=r[a];if(n.disabled||n["aria-disabled"])for(let r in s)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(s[r]=[a=>{var i;return(i=a==null?void 0:a.preventDefault)==null?void 0:i.call(a)}]);for(let r in s)Object.assign(n,{[r](a,...i){let c=s[r];for(let d of c){if((a instanceof Event||(a==null?void 0:a.nativeEvent)instanceof Event)&&a.defaultPrevented)return;d(a,...i)}}});return n}function qN(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},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])):n[a]=r[a];for(let r in s)Object.assign(n,{[r](...a){let i=s[r];for(let c of i)c==null||c(...a)}});return n}function pn(e){var n;return Object.assign(p.forwardRef(e),{displayName:(n=e.displayName)!=null?n:e.name})}function Po(e){let n=Object.assign({},e);for(let s in n)n[s]===void 0&&delete n[s];return n}function Lp(e,n=[]){let s=Object.assign({},e);for(let r of n)r in s&&delete s[r];return s}function VR(e){return He.version.split(".")[0]>="19"?e.props.ref:e.ref}function KN(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let n=e._payload;if(n!=null&&n.status==="fulfilled")return KN(n.value)}return e}function wc(e){return e===p.Fragment||e===Symbol.for("react.fragment")}function YR(e){return wc(e.type)}function QR(e,n,s){let[r,a]=p.useState(s),i=e!==void 0,c=p.useRef(i),d=p.useRef(!1),u=p.useRef(!1);return i&&!c.current&&!d.current?(d.current=!0,c.current=i,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!i&&c.current&&!u.current&&(u.current=!0,c.current=i,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[i?e:r,dt(f=>(i||ks.flushSync(()=>a(f)),n==null?void 0:n(f)))]}function JR(e){let[n]=p.useState(e);return n}function VN(e={},n=null,s=[]){for(let[r,a]of Object.entries(e))QN(s,YN(n,r),a);return s}function YN(e,n){return e?e+"["+n+"]":n}function QN(e,n,s){if(Array.isArray(s))for(let[r,a]of s.entries())QN(e,YN(n,r.toString()),a);else s instanceof Date?e.push([n,s.toISOString()]):typeof s=="boolean"?e.push([n,s?"1":"0"]):typeof s=="string"?e.push([n,s]):typeof s=="number"?e.push([n,`${s}`]):s==null?e.push([n,""]):ZR(s)&&!p.isValidElement(s)&&VN(s,n,e)}function XR(e){var n,s;let r=(n=e==null?void 0:e.form)!=null?n: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 ZR(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}let eA="span";var tl=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(tl||{});function tA(e,n){var s;let{features:r=1,...a}=e,i={ref:n,"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 Sn()({ourProps:i,theirProps:a,slot:{},defaultTag:eA,name:"Hidden"})}let Tc=pn(tA),nA=p.createContext(null);function sA({children:e}){let n=p.useContext(nA);if(!n)return He.createElement(He.Fragment,null,e);let{target:s}=n;return s?ks.createPortal(He.createElement(He.Fragment,null,e),s):null}function rA({data:e,form:n,disabled:s,onReset:r,overrides:a}){let[i,c]=p.useState(null),d=Jo();return p.useEffect(()=>{if(r&&i)return d.addEventListener(i,"reset",r)},[i,n,r]),He.createElement(sA,null,He.createElement(oA,{setForm:c,formId:n}),VN(e).map(([u,f])=>He.createElement(Tc,{features:tl.Hidden,...Po({key:u,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:n,disabled:s,name:u,value:f,...a})})))}function oA({setForm:e,formId:n}){return p.useEffect(()=>{if(n){let s=document.getElementById(n);s&&e(s)}},[e,n]),n?null:He.createElement(Tc,{features:tl.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let r=s.closest("form");r&&e(r)}})}let aA=p.createContext(void 0);function JN(){return p.useContext(aA)}function XN(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function Yr(e){return XN(e)&&"tagName"in e}function Ns(e){return Yr(e)&&"accessKey"in e}function qr(e){return Yr(e)&&"tabIndex"in e}function iA(e){return Yr(e)&&"style"in e}function lA(e){return Ns(e)&&e.nodeName==="IFRAME"}function ZN(e){return Ns(e)&&e.nodeName==="INPUT"}function tj(e){return Ns(e)&&e.nodeName==="LABEL"}function cA(e){return Ns(e)&&e.nodeName==="FIELDSET"}function e1(e){return Ns(e)&&e.nodeName==="LEGEND"}function dA(e){return Yr(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function nj(e){let n=e.parentElement,s=null;for(;n&&!cA(n);)e1(n)&&(s=n),n=n.parentElement;let r=(n==null?void 0:n.getAttribute("disabled"))==="";return r&&uA(s)?!1:r}function uA(e){if(!e)return!1;let n=e.previousElementSibling;for(;n!==null;){if(e1(n))return!1;n=n.previousElementSibling}return!0}let t1=Symbol();function fA(e,n=!0){return Object.assign(e,{[t1]:n})}function Dn(...e){let n=p.useRef(e);p.useEffect(()=>{n.current=e},[e]);let s=dt(r=>{for(let a of n.current)a!=null&&(typeof a=="function"?a(r):a.current=r)});return e.every(r=>r==null||(r==null?void 0:r[t1]))?void 0:s}let im=p.createContext(null);im.displayName="DescriptionContext";function n1(){let e=p.useContext(im);if(e===null){let n=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(n,n1),n}return e}function mA(){var e,n;return(n=(e=p.useContext(im))==null?void 0:e.value)!=null?n:void 0}function hA(){let[e,n]=p.useState([]);return[e.length>0?e.join(" "):void 0,p.useMemo(()=>function(s){let r=dt(i=>(n(c=>[...c,i]),()=>n(c=>{let d=c.slice(),u=d.indexOf(i);return u!==-1&&d.splice(u,1),d}))),a=p.useMemo(()=>({register:r,slot:s.slot,name:s.name,props:s.props,value:s.value}),[r,s.slot,s.name,s.props,s.value]);return He.createElement(im.Provider,{value:a},s.children)},[n])]}let pA="p";function gA(e,n){let s=p.useId(),r=Hx(),{id:a=`headlessui-description-${s}`,...i}=e,c=n1(),d=Dn(n);Xt(()=>c.register(a),[a,c.register]);let u=Ks({...c.slot,disabled:r||!1}),f={ref:d,...c.props,id:a};return Sn()({ourProps:f,theirProps:i,slot:u,defaultTag:pA,name:c.name||"Description"})}let xA=pn(gA),s1=Object.assign(xA,{});var vn=(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))(vn||{});let lm=p.createContext(null);lm.displayName="LabelContext";function r1(){let e=p.useContext(lm);if(e===null){let n=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(n,r1),n}return e}function o1(e){var n,s,r;let a=(s=(n=p.useContext(lm))==null?void 0:n.value)!=null?s:void 0;return((r=e==null?void 0:e.length)!=null?r:0)>0?[a,...e].filter(Boolean).join(" "):a}function vA({inherit:e=!1}={}){let n=o1(),[s,r]=p.useState([]),a=e?[n,...s].filter(Boolean):s;return[a.length>0?a.join(" "):void 0,p.useMemo(()=>function(i){let c=dt(u=>(r(f=>[...f,u]),()=>r(f=>{let x=f.slice(),b=x.indexOf(u);return b!==-1&&x.splice(b,1),x}))),d=p.useMemo(()=>({register:c,slot:i.slot,name:i.name,props:i.props,value:i.value}),[c,i.slot,i.name,i.props,i.value]);return He.createElement(lm.Provider,{value:d},i.children)},[r])]}let yA="label";function bA(e,n){var s;let r=p.useId(),a=r1(),i=JN(),c=Hx(),{id:d=`headlessui-label-${r}`,htmlFor:u=i??((s=a.props)==null?void 0:s.htmlFor),passive:f=!1,...x}=e,b=Dn(n);Xt(()=>a.register(d),[d,a.register]);let g=dt(y=>{let j=y.currentTarget;if(!(y.target!==y.currentTarget&&dA(y.target))&&(tj(j)&&y.preventDefault(),a.props&&"onClick"in a.props&&typeof a.props.onClick=="function"&&a.props.onClick(y),tj(j))){let k=document.getElementById(j.htmlFor);if(k){let $=k.getAttribute("disabled");if($==="true"||$==="")return;let S=k.getAttribute("aria-disabled");if(S==="true"||S==="")return;(ZN(k)&&(k.type==="file"||k.type==="radio"||k.type==="checkbox")||k.role==="radio"||k.role==="checkbox"||k.role==="switch")&&k.click(),k.focus({preventScroll:!0})}}}),h=Ks({...a.slot,disabled:c||!1}),v={ref:b,...a.props,id:d,htmlFor:u,onClick:g};return f&&("onClick"in v&&(delete v.htmlFor,delete v.onClick),"onClick"in x&&delete x.onClick),Sn()({ourProps:v,theirProps:x,slot:h,defaultTag:u?yA:"div",name:a.name||"Label"})}let wA=pn(bA),jA=Object.assign(wA,{}),kA=p.createContext(()=>{});function NA({value:e,children:n}){return He.createElement(kA.Provider,{value:e},n)}function SA(e,n){return e!==null&&n!==null&&typeof e=="object"&&typeof n=="object"&&"id"in e&&"id"in n?e.id===n.id:e===n}function CA(e=SA){return p.useCallback((n,s)=>{if(typeof e=="string"){let r=e;return(n==null?void 0:n[r])===(s==null?void 0:s[r])}return e(n,s)},[e])}function sj(e){if(e===null)return{width:0,height:0};let{width:n,height:s}=e.getBoundingClientRect();return{width:n,height:s}}function EA(e,n,s=!1){let[r,a]=p.useState(()=>sj(n));return Xt(()=>{if(!n||!e)return;let i=Es();return i.requestAnimationFrame(function c(){i.requestAnimationFrame(c),a(d=>{let u=sj(n);return u.width===d.width&&u.height===d.height?d:u})}),()=>{i.dispose()}},[n,e]),s?{width:`${r.width}px`,height:`${r.height}px`}:r}var a1=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(a1||{});function $A(e){let n=p.useRef(null),s=dt(a=>{n.current=a.pointerType,!nj(a.currentTarget)&&a.pointerType==="mouse"&&a.button===a1.Left&&(a.preventDefault(),e(a))}),r=dt(a=>{n.current!=="mouse"&&(nj(a.currentTarget)||e(a))});return{onPointerDown:s,onClick:r}}let i1=class extends Map{constructor(n){super(),this.factory=n}get(n){let s=super.get(n);return s===void 0&&(s=this.factory(n),this.set(n,s)),s}};var _A=Object.defineProperty,TA=(e,n,s)=>n in e?_A(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,RA=(e,n,s)=>(TA(e,n+"",s),s),l1=(e,n,s)=>{if(!n.has(e))throw TypeError("Cannot "+s)},Is=(e,n,s)=>(l1(e,n,"read from private field"),s?s.call(e):n.get(e)),Ip=(e,n,s)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,s)},rj=(e,n,s,r)=>(l1(e,n,"write to private field"),n.set(e,s),s),br,pc,gc;let c1=class{constructor(n){Ip(this,br,{}),Ip(this,pc,new i1(()=>new Set)),Ip(this,gc,new Set),RA(this,"disposables",Es()),rj(this,br,n),Nr.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return Is(this,br)}subscribe(n,s){if(Nr.isServer)return()=>{};let r={selector:n,callback:s,current:n(Is(this,br))};return Is(this,gc).add(r),this.disposables.add(()=>{Is(this,gc).delete(r)})}on(n,s){return Nr.isServer?()=>{}:(Is(this,pc).get(n).add(s),this.disposables.add(()=>{Is(this,pc).get(n).delete(s)}))}send(n){let s=this.reduce(Is(this,br),n);if(s!==Is(this,br)){rj(this,br,s);for(let r of Is(this,gc)){let a=r.selector(Is(this,br));d1(r.current,a)||(r.current=a,r.callback(a))}for(let r of Is(this,pc).get(n.type))r(Is(this,br),n)}}};br=new WeakMap,pc=new WeakMap,gc=new WeakMap;function d1(e,n){return Object.is(e,n)?!0:typeof e!="object"||e===null||typeof n!="object"||n===null?!1:Array.isArray(e)&&Array.isArray(n)?e.length!==n.length?!1:zp(e[Symbol.iterator](),n[Symbol.iterator]()):e instanceof Map&&n instanceof Map||e instanceof Set&&n instanceof Set?e.size!==n.size?!1:zp(e.entries(),n.entries()):oj(e)&&oj(n)?zp(Object.entries(e)[Symbol.iterator](),Object.entries(n)[Symbol.iterator]()):!1}function zp(e,n){do{let s=e.next(),r=n.next();if(s.done&&r.done)return!0;if(s.done||r.done||!Object.is(s.value,r.value))return!1}while(!0)}function oj(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}function Dp(e){let[n,s]=e(),r=Es();return(...a)=>{n(...a),r.dispose(),r.microTask(s)}}var AA=Object.defineProperty,OA=(e,n,s)=>n in e?AA(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,aj=(e,n,s)=>(OA(e,typeof n!="symbol"?n+"":n,s),s),u1=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(u1||{});let MA={0(e,n){let s=n.id,r=e.stack,a=e.stack.indexOf(s);if(a!==-1){let i=e.stack.slice();return i.splice(a,1),i.push(s),r=i,{...e,stack:r}}return{...e,stack:[...e.stack,s]}},1(e,n){let s=n.id,r=e.stack.indexOf(s);if(r===-1)return e;let a=e.stack.slice();return a.splice(r,1),{...e,stack:a}}},PA=class f1 extends c1{constructor(){super(...arguments),aj(this,"actions",{push:n=>this.send({type:0,id:n}),pop:n=>this.send({type:1,id:n})}),aj(this,"selectors",{isTop:(n,s)=>n.stack[n.stack.length-1]===s,inStack:(n,s)=>n.stack.includes(s)})}static new(){return new f1({stack:[]})}reduce(n,s){return es(s.type,MA,n,s)}};const cm=new i1(()=>PA.new());var Fp={exports:{}},Up={};/**
|
|
504
|
+
* @license React
|
|
505
|
+
* use-sync-external-store-with-selector.production.js
|
|
506
|
+
*
|
|
507
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
508
|
+
*
|
|
509
|
+
* This source code is licensed under the MIT license found in the
|
|
510
|
+
* LICENSE file in the root directory of this source tree.
|
|
511
|
+
*/var ij;function LA(){if(ij)return Up;ij=1;var e=Xf();function n(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var s=typeof Object.is=="function"?Object.is:n,r=e.useSyncExternalStore,a=e.useRef,i=e.useEffect,c=e.useMemo,d=e.useDebugValue;return Up.useSyncExternalStoreWithSelector=function(u,f,x,b,g){var h=a(null);if(h.current===null){var v={hasValue:!1,value:null};h.current=v}else v=h.current;h=c(function(){function j(_){if(!k){if(k=!0,$=_,_=b(_),g!==void 0&&v.hasValue){var E=v.value;if(g(E,_))return S=E}return S=_}if(E=S,s($,_))return E;var O=b(_);return g!==void 0&&g(E,O)?($=_,E):($=_,S=O)}var k=!1,$,S,N=x===void 0?null:x;return[function(){return j(f())},N===null?void 0:function(){return j(N())}]},[f,x,b,g]);var y=r(u,h[0],h[1]);return i(function(){v.hasValue=!0,v.value=y},[y]),d(y),y},Up}var lj;function IA(){return lj||(lj=1,Fp.exports=LA()),Fp.exports}var zA=IA();function Yn(e,n,s=d1){return zA.useSyncExternalStoreWithSelector(dt(r=>e.subscribe(DA,r)),dt(()=>e.state),dt(()=>e.state),dt(n),s)}function DA(e){return e}function Vc(e,n){let s=p.useId(),r=cm.get(n),[a,i]=Yn(r,p.useCallback(c=>[r.selectors.isTop(c,s),r.selectors.inStack(c,s)],[r,s]));return Xt(()=>{if(e)return r.actions.push(s),()=>r.actions.pop(s)},[r,e,s]),e?i?a:!0:!1}let _g=new Map,jc=new Map;function cj(e){var n;let s=(n=jc.get(e))!=null?n:0;return jc.set(e,s+1),s!==0?()=>dj(e):(_g.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>dj(e))}function dj(e){var n;let s=(n=jc.get(e))!=null?n:1;if(s===1?jc.delete(e):jc.set(e,s-1),s!==1)return;let r=_g.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,_g.delete(e))}function m1(e,{allowed:n,disallowed:s}={}){let r=Vc(e,"inert-others");Xt(()=>{var a,i;if(!r)return;let c=Es();for(let u of(a=s==null?void 0:s())!=null?a:[])u&&c.add(cj(u));let d=(i=n==null?void 0:n())!=null?i:[];for(let u of d){if(!u)continue;let f=ml(u);if(!f)continue;let x=u.parentElement;for(;x&&x!==f.body;){for(let b of x.children)d.some(g=>b.contains(g))||c.add(cj(b));x=x.parentElement}}return c.dispose},[r,n,s])}function h1(e,n,s){let r=Xo(a=>{let i=a.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&s()});p.useEffect(()=>{if(!e)return;let a=n===null?null:Ns(n)?n:n.current;if(!a)return;let i=Es();if(typeof ResizeObserver<"u"){let c=new ResizeObserver(()=>r.current(a));c.observe(a),i.add(()=>c.disconnect())}if(typeof IntersectionObserver<"u"){let c=new IntersectionObserver(()=>r.current(a));c.observe(a),i.add(()=>c.disconnect())}return()=>i.dispose()},[n,r,e])}let xf=["[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(","),FA=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var ir=(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))(ir||{}),Tg=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(Tg||{}),UA=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(UA||{});function p1(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(xf)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}function WA(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(FA)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}var Bx=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Bx||{});function g1(e,n=0){var s;return e===((s=ml(e))==null?void 0:s.body)?!1:es(n,{0(){return e.matches(xf)},1(){let r=e;for(;r!==null;){if(r.matches(xf))return!0;r=r.parentElement}return!1}})}var HA=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(HA||{});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 Qr(e){e==null||e.focus({preventScroll:!0})}let BA=["textarea","input"].join(",");function GA(e){var n,s;return(s=(n=e==null?void 0:e.matches)==null?void 0:n.call(e,BA))!=null?s:!1}function x1(e,n=s=>s){return e.slice().sort((s,r)=>{let a=n(s),i=n(r);if(a===null||i===null)return 0;let c=a.compareDocumentPosition(i);return c&Node.DOCUMENT_POSITION_FOLLOWING?-1:c&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function qA(e,n,s=e===null?document.body:gf(e)){return Wi(p1(s),n,{relativeTo:e})}function Wi(e,n,{sorted:s=!0,relativeTo:r=null,skipElements:a=[]}={}){let i=Array.isArray(e)?e.length>0?gf(e[0]):document:gf(e),c=Array.isArray(e)?s?x1(e):e:n&64?WA(e):p1(e);a.length>0&&c.length>1&&(c=c.filter(h=>!a.some(v=>v!=null&&"current"in v?(v==null?void 0:v.current)===h:v===h))),r=r??(i==null?void 0:i.activeElement);let d=(()=>{if(n&5)return 1;if(n&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),u=(()=>{if(n&1)return 0;if(n&2)return Math.max(0,c.indexOf(r))-1;if(n&4)return Math.max(0,c.indexOf(r))+1;if(n&8)return c.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),f=n&32?{preventScroll:!0}:{},x=0,b=c.length,g;do{if(x>=b||x+b<=0)return 0;let h=u+x;if(n&16)h=(h+b)%b;else{if(h<0)return 3;if(h>=b)return 1}g=c[h],g==null||g.focus(f),x+=d}while(g!==HN(g));return n&6&&GA(g)&&g.select(),2}function v1(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function KA(){return/Android/gi.test(window.navigator.userAgent)}function uj(){return v1()||KA()}function Pi(e,n,s,r){let a=Xo(s);p.useEffect(()=>{if(!e)return;function i(c){a.current(c)}return document.addEventListener(n,i,r),()=>document.removeEventListener(n,i,r)},[e,n,r])}function y1(e,n,s,r){let a=Xo(s);p.useEffect(()=>{if(!e)return;function i(c){a.current(c)}return window.addEventListener(n,i,r),()=>window.removeEventListener(n,i,r)},[e,n,r])}const fj=30;function b1(e,n,s){let r=Xo(s),a=p.useCallback(function(d,u){if(d.defaultPrevented)return;let f=u(d);if(f===null||!f.getRootNode().contains(f)||!f.isConnected)return;let x=(function b(g){return typeof g=="function"?b(g()):Array.isArray(g)||g instanceof Set?g:[g]})(n);for(let b of x)if(b!==null&&(b.contains(f)||d.composed&&d.composedPath().includes(b)))return;return!g1(f,Bx.Loose)&&f.tabIndex!==-1&&d.preventDefault(),r.current(d,f)},[r,n]),i=p.useRef(null);Pi(e,"pointerdown",d=>{var u,f;uj()||(i.current=((f=(u=d.composedPath)==null?void 0:u.call(d))==null?void 0:f[0])||d.target)},!0),Pi(e,"pointerup",d=>{if(uj()||!i.current)return;let u=i.current;return i.current=null,a(d,()=>u)},!0);let c=p.useRef({x:0,y:0});Pi(e,"touchstart",d=>{c.current.x=d.touches[0].clientX,c.current.y=d.touches[0].clientY},!0),Pi(e,"touchend",d=>{let u={x:d.changedTouches[0].clientX,y:d.changedTouches[0].clientY};if(!(Math.abs(u.x-c.current.x)>=fj||Math.abs(u.y-c.current.y)>=fj))return a(d,()=>qr(d.target)?d.target:null)},!0),y1(e,"blur",d=>a(d,()=>lA(window.document.activeElement)?window.document.activeElement:null),!0)}function Rc(...e){return p.useMemo(()=>ml(...e),[...e])}var VA=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(VA||{});const _u={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},YA=200,mj=5;function QA(e,{trigger:n,action:s,close:r,select:a}){let i=p.useRef(null),c=p.useRef(null),d=p.useRef(null);Pi(e&&n!==null,"pointerdown",u=>{XN(u==null?void 0:u.target)&&n!=null&&n.contains(u.target)&&(c.current=u.x,d.current=u.y,i.current=u.timeStamp)}),Pi(e&&n!==null,"pointerup",u=>{var f,x;let b=i.current;if(b===null||(i.current=null,!qr(u.target))||Math.abs(u.x-((f=c.current)!=null?f:u.x))<mj&&Math.abs(u.y-((x=d.current)!=null?x:u.y))<mj)return;let g=s(u);switch(g.kind){case 0:return;case 1:{u.timeStamp-b>YA&&(a(g.target),r());break}case 2:{r();break}}},{capture:!0})}function w1(e,n,s,r){let a=Xo(s);p.useEffect(()=>{e=e??window;function i(c){a.current(c)}return e.addEventListener(n,i,r),()=>e.removeEventListener(n,i,r)},[e,n,r])}function JA(e,n){return p.useMemo(()=>{var s;if(e.type)return e.type;let r=(s=e.as)!=null?s:"button";if(typeof r=="string"&&r.toLowerCase()==="button"||(n==null?void 0:n.tagName)==="BUTTON"&&!n.hasAttribute("type"))return"button"},[e.type,e.as,n])}function XA(e){return p.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function ZA(e,n){let s=e(),r=new Set;return{getSnapshot(){return s},subscribe(a){return r.add(a),()=>r.delete(a)},dispatch(a,...i){let c=n[a].call(s,...i);c&&(s=c,r.forEach(d=>d()))}}}function e3(){let e;return{before({doc:n}){var s;let r=n.documentElement,a=(s=n.defaultView)!=null?s:window;e=Math.max(0,a.innerWidth-r.clientWidth)},after({doc:n,d:s}){let r=n.documentElement,a=Math.max(0,r.clientWidth-r.offsetWidth),i=Math.max(0,e-a);s.style(r,"paddingRight",`${i}px`)}}}function t3(){return v1()?{before({doc:e,d:n,meta:s}){function r(a){for(let i of s().containers)for(let c of i())if(c.contains(a))return!0;return!1}n.microTask(()=>{var a;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let d=Es();d.style(e.documentElement,"scrollBehavior","auto"),n.add(()=>n.microTask(()=>d.dispose()))}let i=(a=window.scrollY)!=null?a:window.pageYOffset,c=null;n.addEventListener(e,"click",d=>{if(qr(d.target))try{let u=d.target.closest("a");if(!u)return;let{hash:f}=new URL(u.href),x=e.querySelector(f);qr(x)&&!r(x)&&(c=x)}catch{}},!0),n.group(d=>{n.addEventListener(e,"touchstart",u=>{if(d.dispose(),qr(u.target)&&iA(u.target))if(r(u.target)){let f=u.target;for(;f.parentElement&&r(f.parentElement);)f=f.parentElement;d.style(f,"overscrollBehavior","contain")}else d.style(u.target,"touchAction","none")})}),n.addEventListener(e,"touchmove",d=>{if(qr(d.target)){if(ZN(d.target))return;if(r(d.target)){let u=d.target;for(;u.parentElement&&u.dataset.headlessuiPortal!==""&&!(u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth);)u=u.parentElement;u.dataset.headlessuiPortal===""&&d.preventDefault()}else d.preventDefault()}},{passive:!1}),n.add(()=>{var d;let u=(d=window.scrollY)!=null?d:window.pageYOffset;i!==u&&window.scrollTo(0,i),c&&c.isConnected&&(c.scrollIntoView({block:"nearest"}),c=null)})})}}:{}}function n3(){return{before({doc:e,d:n}){n.style(e.documentElement,"overflow","hidden")}}}function hj(e){let n={};for(let s of e)Object.assign(n,s(n));return n}let _a=ZA(()=>new Map,{PUSH(e,n){var s;let r=(s=this.get(e))!=null?s:{doc:e,count:0,d:Es(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(n),r.computedMeta=hj(r.meta),this.set(e,r),this},POP(e,n){let s=this.get(e);return s&&(s.count--,s.meta.delete(n),s.computedMeta=hj(s.meta)),this},SCROLL_PREVENT(e){let n={doc:e.doc,d:e.d,meta(){return e.computedMeta}},s=[t3(),e3(),n3()];s.forEach(({before:r})=>r==null?void 0:r(n)),s.forEach(({after:r})=>r==null?void 0:r(n))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});_a.subscribe(()=>{let e=_a.getSnapshot(),n=new Map;for(let[s]of e)n.set(s,s.documentElement.style.overflow);for(let s of e.values()){let r=n.get(s.doc)==="hidden",a=s.count!==0;(a&&!r||!a&&r)&&_a.dispatch(s.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",s),s.count===0&&_a.dispatch("TEARDOWN",s)}});function s3(e,n,s=()=>({containers:[]})){let r=XA(_a),a=n?r.get(n):void 0,i=a?a.count>0:!1;return Xt(()=>{if(!(!n||!e))return _a.dispatch("PUSH",n,s),()=>_a.dispatch("POP",n,s)},[e,n]),i}function j1(e,n,s=()=>[document.body]){let r=Vc(e,"scroll-lock");s3(r,n,a=>{var i;return{containers:[...(i=a.containers)!=null?i:[],s]}})}function pj(e){return[e.screenX,e.screenY]}function r3(){let e=p.useRef([-1,-1]);return{wasMoved(n){let s=pj(n);return e.current[0]===s[0]&&e.current[1]===s[1]?!1:(e.current=s,!0)},update(n){e.current=pj(n)}}}function o3(e=0){let[n,s]=p.useState(e),r=p.useCallback(u=>s(u),[]),a=p.useCallback(u=>s(f=>f|u),[]),i=p.useCallback(u=>(n&u)===u,[n]),c=p.useCallback(u=>s(f=>f&~u),[]),d=p.useCallback(u=>s(f=>f^u),[]);return{flags:n,setFlag:r,addFlag:a,hasFlag:i,removeFlag:c,toggleFlag:d}}var a3={},gj,xj;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((gj=process==null?void 0:a3)==null?void 0:gj.NODE_ENV)==="test"&&typeof((xj=Element==null?void 0:Element.prototype)==null?void 0:xj.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(`
|
|
512
|
+
`)),[]});var i3=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(i3||{});function k1(e){let n={};for(let s in e)e[s]===!0&&(n[`data-${s}`]="");return n}function N1(e,n,s,r){let[a,i]=p.useState(s),{hasFlag:c,addFlag:d,removeFlag:u}=o3(e&&a?3:0),f=p.useRef(!1),x=p.useRef(!1),b=Jo();return Xt(()=>{var g;if(e){if(s&&i(!0),!n){s&&d(3);return}return(g=r==null?void 0:r.start)==null||g.call(r,s),l3(n,{inFlight:f,prepare(){x.current?x.current=!1:x.current=f.current,f.current=!0,!x.current&&(s?(d(3),u(4)):(d(4),u(2)))},run(){x.current?s?(u(3),d(4)):(u(4),d(3)):s?u(1):d(1)},done(){var h;x.current&&u3(n)||(f.current=!1,u(7),s||i(!1),(h=r==null?void 0:r.end)==null||h.call(r,s))}})}},[e,s,n,b]),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 l3(e,{prepare:n,run:s,done:r,inFlight:a}){let i=Es();return d3(e,{prepare:n,inFlight:a}),i.nextFrame(()=>{s(),i.requestAnimationFrame(()=>{i.add(c3(e,r))})}),i.dispose}function c3(e,n){var s,r;let a=Es();if(!e)return a.dispose;let i=!1;a.add(()=>{i=!0});let c=(r=(s=e.getAnimations)==null?void 0:s.call(e).filter(d=>d instanceof CSSTransition))!=null?r:[];return c.length===0?(n(),a.dispose):(Promise.allSettled(c.map(d=>d.finished)).then(()=>{i||n()}),a.dispose)}function d3(e,{inFlight:n,prepare:s}){if(n!=null&&n.current){s();return}let r=e.style.transition;e.style.transition="none",s(),e.offsetHeight,e.style.transition=r}function u3(e){var n,s;return((s=(n=e.getAnimations)==null?void 0:n.call(e))!=null?s:[]).some(r=>r instanceof CSSTransition&&r.playState!=="finished")}function Gx(e,n){let s=p.useRef([]),r=dt(e);p.useEffect(()=>{let a=[...s.current];for(let[i,c]of n.entries())if(s.current[i]!==c){let d=r(n,a);return s.current=n,d}},[r,...n])}function dm(){return typeof window<"u"}function hl(e){return S1(e)?(e.nodeName||"").toLowerCase():"#document"}function fs(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function oo(e){var n;return(n=(S1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function S1(e){return dm()?e instanceof Node||e instanceof fs(e).Node:!1}function us(e){return dm()?e instanceof Element||e instanceof fs(e).Element:!1}function Zo(e){return dm()?e instanceof HTMLElement||e instanceof fs(e).HTMLElement:!1}function vj(e){return!dm()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof fs(e).ShadowRoot}function um(e){const{overflow:n,overflowX:s,overflowY:r,display:a}=Er(e);return/auto|scroll|overlay|hidden|clip/.test(n+r+s)&&a!=="inline"&&a!=="contents"}function f3(e){return/^(table|td|th)$/.test(hl(e))}function fm(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const m3=/transform|translate|scale|rotate|perspective|filter/,h3=/paint|layout|strict|content/,ba=e=>!!e&&e!=="none";let Wp;function qx(e){const n=us(e)?Er(e):e;return ba(n.transform)||ba(n.translate)||ba(n.scale)||ba(n.rotate)||ba(n.perspective)||!Kx()&&(ba(n.backdropFilter)||ba(n.filter))||m3.test(n.willChange||"")||h3.test(n.contain||"")}function p3(e){let n=La(e);for(;Zo(n)&&!Ac(n);){if(qx(n))return n;if(fm(n))return null;n=La(n)}return null}function Kx(){return Wp==null&&(Wp=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Wp}function Ac(e){return/^(html|body|#document)$/.test(hl(e))}function Er(e){return fs(e).getComputedStyle(e)}function mm(e){return us(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function La(e){if(hl(e)==="html")return e;const n=e.assignedSlot||e.parentNode||vj(e)&&e.host||oo(e);return vj(n)?n.host:n}function C1(e){const n=La(e);return Ac(n)?(e.ownerDocument||e).body:Zo(n)&&um(n)?n:C1(n)}function Oc(e,n,s){var r;n===void 0&&(n=[]),s===void 0&&(s=!0);const a=C1(e),i=a===((r=e.ownerDocument)==null?void 0:r.body),c=fs(a);if(i){const d=Rg(c);return n.concat(c,c.visualViewport||[],um(a)?a:[],d&&s?Oc(d):[])}else return n.concat(a,Oc(a,[],s))}function Rg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function g3(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(n=>{let{brand:s,version:r}=n;return s+"/"+r}).join(" "):navigator.userAgent}const Ia=Math.min,Hs=Math.max,Mc=Math.round,Tu=Math.floor,Jr=e=>({x:e,y:e}),x3={left:"right",right:"left",bottom:"top",top:"bottom"};function v3(e,n,s){return Hs(e,Ia(n,s))}function pl(e,n){return typeof e=="function"?e(n):e}function za(e){return e.split("-")[0]}function Yc(e){return e.split("-")[1]}function E1(e){return e==="x"?"y":"x"}function $1(e){return e==="y"?"height":"width"}function Kr(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function _1(e){return E1(Kr(e))}function y3(e,n,s){s===void 0&&(s=!1);const r=Yc(e),a=_1(e),i=$1(a);let c=a==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[i]>n.floating[i]&&(c=vf(c)),[c,vf(c)]}function b3(e){const n=vf(e);return[Ag(e),n,Ag(n)]}function Ag(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const yj=["left","right"],bj=["right","left"],w3=["top","bottom"],j3=["bottom","top"];function k3(e,n,s){switch(e){case"top":case"bottom":return s?n?bj:yj:n?yj:bj;case"left":case"right":return n?w3:j3;default:return[]}}function N3(e,n,s,r){const a=Yc(e);let i=k3(za(e),s==="start",r);return a&&(i=i.map(c=>c+"-"+a),n&&(i=i.concat(i.map(Ag)))),i}function vf(e){const n=za(e);return x3[n]+e.slice(n.length)}function S3(e){var n,s,r,a;return{top:(n=e.top)!=null?n:0,right:(s=e.right)!=null?s:0,bottom:(r=e.bottom)!=null?r:0,left:(a=e.left)!=null?a:0}}function C3(e){return typeof e!="number"?S3(e):{top:e,right:e,bottom:e,left:e}}function yf(e){const{x:n,y:s,width:r,height:a}=e;return{width:r,height:a,top:s,left:n,right:n+r,bottom:s+a,x:n,y:s}}function wj(e,n,s){let{reference:r,floating:a}=e;const i=Kr(n),c=_1(n),d=$1(c),u=za(n),f=i==="y",x=r.x+r.width/2-a.width/2,b=r.y+r.height/2-a.height/2,g=r[d]/2-a[d]/2;let h;switch(u){case"top":h={x,y:r.y-a.height};break;case"bottom":h={x,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:b};break;case"left":h={x:r.x-a.width,y:b};break;default:h={x:r.x,y:r.y}}const v=Yc(n);return v&&(h[c]+=g*(v==="end"?1:-1)*(s&&f?-1:1)),h}async function T1(e,n){var s;n===void 0&&(n={});const{x:r,y:a,platform:i,rects:c,elements:d,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:x="viewport",elementContext:b="floating",altBoundary:g=!1,padding:h=0}=pl(n,e),v=C3(h),j=d[g?b==="floating"?"reference":"floating":b],k=yf(await i.getClippingRect({element:(s=await(i.isElement==null?void 0:i.isElement(j)))==null||s?j:j.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(d.floating)),boundary:f,rootBoundary:x,strategy:u})),$=b==="floating"?{x:r,y:a,width:c.floating.width,height:c.floating.height}:c.reference,S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d.floating)),N=await(i.isElement==null?void 0:i.isElement(S))&&await(i.getScale==null?void 0:i.getScale(S))||{x:1,y:1},_=yf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:$,offsetParent:S,strategy:u}):$);return{top:(k.top-_.top+v.top)/N.y,bottom:(_.bottom-k.bottom+v.bottom)/N.y,left:(k.left-_.left+v.left)/N.x,right:(_.right-k.right+v.right)/N.x}}const E3=50,$3=async(e,n,s)=>{const{placement:r="bottom",strategy:a="absolute",middleware:i=[],platform:c}=s,d=c.detectOverflow?c:{...c,detectOverflow:T1},u=await(c.isRTL==null?void 0:c.isRTL(n));let f=await c.getElementRects({reference:e,floating:n,strategy:a}),{x,y:b}=wj(f,r,u),g=r,h=0;const v={};for(let y=0;y<i.length;y++){const j=i[y];if(!j)continue;const{name:k,fn:$}=j,{x:S,y:N,data:_,reset:E}=await $({x,y:b,initialPlacement:r,placement:g,strategy:a,middlewareData:v,rects:f,platform:d,elements:{reference:e,floating:n}});x=S??x,b=N??b,v[k]={...v[k],..._},E&&h<E3&&(h++,typeof E=="object"&&(E.placement&&(g=E.placement),E.rects&&(f=E.rects===!0?await c.getElementRects({reference:e,floating:n,strategy:a}):E.rects),{x,y:b}=wj(f,g,u)),y=-1)}return{x,y:b,placement:g,strategy:a,middlewareData:v}},_3=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,r;const{placement:a,middlewareData:i,rects:c,initialPlacement:d,platform:u,elements:f}=n,{mainAxis:x=!0,crossAxis:b=!0,fallbackPlacements:g,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:y=!0,...j}=pl(e,n);if((s=i.arrow)!=null&&s.alignmentOffset)return{};const k=za(a),$=Kr(d),S=za(d)===d,N=await(u.isRTL==null?void 0:u.isRTL(f.floating)),_=g||(S||!y?[vf(d)]:b3(d)),E=v!=="none";!g&&E&&_.push(...N3(d,y,v,N));const O=[d,..._],A=await u.detectOverflow(n,j),I=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(x&&I.push(A[k]),b){const W=y3(a,c,N);I.push(A[W[0]],A[W[1]])}if(M=[...M,{placement:a,overflows:I}],!I.every(W=>W<=0)){var R,P;const W=(((R=i.flip)==null?void 0:R.index)||0)+1,Y=O[W];if(Y&&(!(b==="alignment"?$!==Kr(Y):!1)||M.every(F=>Kr(F.placement)===$?F.overflows[0]>0:!0)))return{data:{index:W,overflows:M},reset:{placement:Y}};let H=(P=M.filter(q=>q.overflows[0]<=0).sort((q,F)=>q.overflows[1]-F.overflows[1])[0])==null?void 0:P.placement;if(!H)switch(h){case"bestFit":{var D;const q=(D=M.filter(F=>{if(E){const G=Kr(F.placement);return G===$||G==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(G=>G>0).reduce((G,U)=>G+U,0)]).sort((F,G)=>F[1]-G[1])[0])==null?void 0:D[0];q&&(H=q);break}case"initialPlacement":H=d;break}if(a!==H)return{reset:{placement:H}}}return{}}}},T3=new Set(["left","top"]);async function R3(e,n){const{placement:s,platform:r,elements:a}=e,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),c=za(s),d=Yc(s),u=Kr(s)==="y",f=T3.has(c)?-1:1,x=i&&u?-1:1,b=pl(n,e);let{mainAxis:g,crossAxis:h,alignmentAxis:v}=typeof b=="number"?{mainAxis:b,crossAxis:0,alignmentAxis:null}:{mainAxis:b.mainAxis||0,crossAxis:b.crossAxis||0,alignmentAxis:b.alignmentAxis};return d&&typeof v=="number"&&(h=d==="end"?v*-1:v),u?{x:h*x,y:g*f}:{x:g*f,y:h*x}}const A3=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var s,r;const{x:a,y:i,placement:c,middlewareData:d}=n,u=await R3(n,e);return c===((s=d.offset)==null?void 0:s.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:a+u.x,y:i+u.y,data:{...u,placement:c}}}}},O3=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:s,y:r,placement:a,platform:i}=n,{mainAxis:c=!0,crossAxis:d=!1,limiter:u={fn:$=>{let{x:S,y:N}=$;return{x:S,y:N}}},...f}=pl(e,n),x={x:s,y:r},b=await i.detectOverflow(n,f),g=Kr(a),h=E1(g);let v=x[h],y=x[g];const j=($,S)=>v3(S+b[$==="y"?"top":"left"],S,S-b[$==="y"?"bottom":"right"]);c&&(v=j(h,v)),d&&(y=j(g,y));const k=u.fn({...n,[h]:v,[g]:y});return{...k,data:{x:k.x-s,y:k.y-r,enabled:{[h]:c,[g]:d}}}}}},M3=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){const{placement:s,rects:r,platform:a,elements:i}=n,{apply:c=()=>{},...d}=pl(e,n),u=await a.detectOverflow(n,d),f=za(s),x=Yc(s),b=Kr(s)==="y",{width:g,height:h}=r.floating;let v,y;f==="top"||f==="bottom"?(v=f,y=x===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(y=f,v=x==="end"?"top":"bottom");const j=h-u.top-u.bottom,k=g-u.left-u.right,$=Ia(h-u[v],j),S=Ia(g-u[y],k),N=n.middlewareData.shift,_=!N;let E=$,O=S;N!=null&&N.enabled.x&&(O=k),N!=null&&N.enabled.y&&(E=j),_&&!x&&(b?O=g-2*Hs(u.left,u.right):E=h-2*Hs(u.top,u.bottom)),await c({...n,availableWidth:O,availableHeight:E});const A=await a.getDimensions(i.floating);return g!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function R1(e){const n=Er(e);let s=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const a=Zo(e),i=a?e.offsetWidth:s,c=a?e.offsetHeight:r,d=Mc(s)!==i||Mc(r)!==c;return d&&(s=i,r=c),{width:s,height:r,$:d}}function Vx(e){return us(e)?e:e.contextElement}function Hi(e){const n=Vx(e);if(!Zo(n))return Jr(1);const s=n.getBoundingClientRect(),{width:r,height:a,$:i}=R1(n);let c=(i?Mc(s.width):s.width)/r,d=(i?Mc(s.height):s.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const P3=Jr(0);function A1(e){const n=fs(e);return!Kx()||!n.visualViewport?P3:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function L3(e,n,s){return n===void 0&&(n=!1),!!s&&n&&s===fs(e)}function Da(e,n,s,r){n===void 0&&(n=!1),s===void 0&&(s=!1);const a=e.getBoundingClientRect(),i=Vx(e);let c=Jr(1);n&&(r?us(r)&&(c=Hi(r)):c=Hi(e));const d=L3(i,s,r)?A1(i):Jr(0);let u=(a.left+d.x)/c.x,f=(a.top+d.y)/c.y,x=a.width/c.x,b=a.height/c.y;if(i&&r){const g=fs(i),h=us(r)?fs(r):r;let v=g,y=Rg(v);for(;y&&h!==v;){const j=Hi(y),k=y.getBoundingClientRect(),$=Er(y),S=k.left+(y.clientLeft+parseFloat($.paddingLeft))*j.x,N=k.top+(y.clientTop+parseFloat($.paddingTop))*j.y;u*=j.x,f*=j.y,x*=j.x,b*=j.y,u+=S,f+=N,v=fs(y),y=Rg(v)}}return yf({width:x,height:b,x:u,y:f})}function hm(e,n){const s=mm(e).scrollLeft;return n?n.left+s:Da(oo(e)).left+s}function O1(e,n){const s=e.getBoundingClientRect(),r=s.left+n.scrollLeft-hm(e,s),a=s.top+n.scrollTop;return{x:r,y:a}}function I3(e){let{elements:n,rect:s,offsetParent:r,strategy:a}=e;const i=a==="fixed",c=oo(r),d=n?fm(n.floating):!1;if(r===c||d&&i)return s;let u={scrollLeft:0,scrollTop:0},f=Jr(1);const x=Jr(0),b=Zo(r);if((b||!i)&&((hl(r)!=="body"||um(c))&&(u=mm(r)),b)){const h=Da(r);f=Hi(r),x.x=h.x+r.clientLeft,x.y=h.y+r.clientTop}const g=c&&!b&&!i?O1(c,u):Jr(0);return{width:s.width*f.x,height:s.height*f.y,x:s.x*f.x-u.scrollLeft*f.x+x.x+g.x,y:s.y*f.y-u.scrollTop*f.y+x.y+g.y}}function z3(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function D3(e){const n=mm(e),s=e.ownerDocument.body,r=Hs(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),a=Hs(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+hm(e);const c=-n.scrollTop;return Er(s).direction==="rtl"&&(i+=Hs(e.clientWidth,s.clientWidth)-r),{width:r,height:a,x:i,y:c}}const F3=25;function U3(e,n,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",a=fs(e),i=oo(e),c=a.visualViewport;let d=i.clientWidth,u=i.clientHeight,f=0,x=0;if(c){const g=!Kx()||n==="fixed";r?g||(f=-c.offsetLeft,x=-c.offsetTop):(d=c.width,u=c.height,g&&(f=c.offsetLeft,x=c.offsetTop))}if(hm(i)<=0){const g=i.ownerDocument,h=g.body,v=getComputedStyle(h),y=g.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,j=Math.abs(i.clientWidth-h.clientWidth-y),k=getComputedStyle(i).scrollbarGutter==="stable both-edges"?j/2:j;k<=F3&&(d-=k)}return{width:d,height:u,x:f,y:x}}function W3(e,n){const s=Da(e,!0,n==="fixed"),r=s.top+e.clientTop,a=s.left+e.clientLeft,i=Hi(e),c=e.clientWidth*i.x,d=e.clientHeight*i.y,u=a*i.x,f=r*i.y;return{width:c,height:d,x:u,y:f}}function jj(e,n,s){let r;if(n==="viewport"||n==="layoutViewport")r=U3(e,s,n);else if(n==="document")r=D3(oo(e));else if(us(n))r=W3(n,s);else{const a=A1(e);r={x:n.x-a.x,y:n.y-a.y,width:n.width,height:n.height}}return yf(r)}function H3(e,n){const s=n.get(e);if(s)return s;let r=Oc(e,[],!1).filter(d=>us(d)&&hl(d)!=="body"),a=null;const i=Er(e).position==="fixed";let c=i?La(e):e;for(;us(c)&&!Ac(c);){const d=Er(c),u=qx(c),f=a?a.position:i?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&d.position==="static")?r=r.filter(b=>b!==c):a=d,c=La(c)}return n.set(e,r),r}function B3(e){let{element:n,boundary:s,rootBoundary:r,strategy:a}=e;const c=[...s==="clippingAncestors"?fm(n)?[]:H3(n,this._c):[].concat(s),r],d=jj(n,c[0],a);let u=d.top,f=d.right,x=d.bottom,b=d.left;for(let g=1;g<c.length;g++){const h=jj(n,c[g],a);u=Hs(h.top,u),f=Ia(h.right,f),x=Ia(h.bottom,x),b=Hs(h.left,b)}return{width:f-b,height:x-u,x:b,y:u}}function G3(e){const{width:n,height:s}=R1(e);return{width:n,height:s}}function q3(e,n,s){const r=Zo(n),a=oo(n),i=s==="fixed",c=Da(e,!0,i,n);let d={scrollLeft:0,scrollTop:0};const u=Jr(0);if((r||!i)&&((hl(n)!=="body"||um(a))&&(d=mm(n)),r)){const g=Da(n,!0,i,n);u.x=g.x+n.clientLeft,u.y=g.y+n.clientTop}!r&&a&&(u.x=hm(a));const f=a&&!r&&!i?O1(a,d):Jr(0),x=c.left+d.scrollLeft-u.x-f.x,b=c.top+d.scrollTop-u.y-f.y;return{x,y:b,width:c.width,height:c.height}}function Hp(e){return Er(e).position==="static"}function kj(e,n){if(!Zo(e)||Er(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return oo(e)===s&&(s=s.ownerDocument.body),s}function M1(e,n){const s=fs(e);if(fm(e))return s;if(!Zo(e)){let a=La(e);for(;a&&!Ac(a);){if(us(a)&&!Hp(a))return a;a=La(a)}return s}let r=kj(e,n);for(;r&&f3(r)&&Hp(r);)r=kj(r,n);return r&&Ac(r)&&Hp(r)&&!qx(r)?s:r||p3(e)||s}const K3=async function(e){const n=this.getOffsetParent||M1,s=this.getDimensions,r=await s(e.floating);return{reference:q3(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function V3(e){return Er(e).direction==="rtl"}const Y3={convertOffsetParentRelativeRectToViewportRelativeRect:I3,getDocumentElement:oo,getClippingRect:B3,getOffsetParent:M1,getElementRects:K3,getClientRects:z3,getDimensions:G3,getScale:Hi,isElement:us,isRTL:V3};function P1(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function Q3(e,n,s){let r=null,a;const i=oo(e);function c(){var x;clearTimeout(a),(x=r)==null||x.disconnect(),r=null}function d(x,b){x===void 0&&(x=!1),b===void 0&&(b=1),c();const g=e.getBoundingClientRect(),{left:h,top:v,width:y,height:j}=g;if(x||n(),!y||!j)return;const k=Tu(v),$=Tu(i.clientWidth-(h+y)),S=Tu(i.clientHeight-(v+j)),N=Tu(h),E={rootMargin:-k+"px "+-$+"px "+-S+"px "+-N+"px",threshold:Hs(0,Ia(1,b))||1};let O=!0;function A(I){const M=I[0].intersectionRatio;if(!P1(g,e.getBoundingClientRect()))return d();if(M!==b){if(!O)return d();M?d(!1,M):a=setTimeout(()=>{d(!1,1e-7)},1e3)}O=!1}try{r=new IntersectionObserver(A,{...E,root:i.ownerDocument})}catch{r=new IntersectionObserver(A,E)}r.observe(e)}const u=fs(e),f=()=>d(s);return u.addEventListener("resize",f),d(!0),()=>{u.removeEventListener("resize",f),c()}}function J3(e,n,s,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=Vx(e),x=a||i?[...f?Oc(f):[],...n?Oc(n):[]]:[];x.forEach(k=>{a&&k.addEventListener("scroll",s),i&&k.addEventListener("resize",s)});const b=f&&d?Q3(f,s,i):null;let g=-1,h=null;c&&(h=new ResizeObserver(k=>{let[$]=k;$&&$.target===f&&h&&n&&(h.unobserve(n),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var S;(S=h)==null||S.observe(n)})),s()}),f&&!u&&h.observe(f),n&&h.observe(n));let v,y=u?Da(e):null;u&&j();function j(){const k=Da(e);y&&!P1(y,k)&&s(),y=k,v=requestAnimationFrame(j)}return s(),()=>{var k;x.forEach($=>{a&&$.removeEventListener("scroll",s),i&&$.removeEventListener("resize",s)}),b==null||b(),(k=h)==null||k.disconnect(),h=null,u&&cancelAnimationFrame(v)}}const Bp=T1,X3=A3,Z3=O3,e4=_3,t4=M3,n4=(e,n,s)=>{const r=new Map,a=s??{},i={...Y3,...a.platform,_c:r};return $3(e,n,{...a,platform:i})};var s4=typeof document<"u",r4=function(){},ef=s4?p.useLayoutEffect:r4;function bf(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let s,r,a;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==n.length)return!1;for(r=s;r--!==0;)if(!bf(e[r],n[r]))return!1;return!0}if(a=Object.keys(e),s=a.length,s!==Object.keys(n).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(n,a[r]))return!1;for(r=s;r--!==0;){const i=a[r];if(!(i==="_owner"&&e.$$typeof)&&!bf(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}function L1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Nj(e,n){const s=L1(e);return Math.round(n*s)/s}function Gp(e){const n=p.useRef(e);return ef(()=>{n.current=e}),n}function o4(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:a,elements:{reference:i,floating:c}={},transform:d=!0,whileElementsMounted:u,open:f}=e,[x,b]=p.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[g,h]=p.useState(r);bf(g,r)||h(r);const[v,y]=p.useState(null),[j,k]=p.useState(null),$=p.useCallback(F=>{F!==E.current&&(E.current=F,y(F))},[]),S=p.useCallback(F=>{F!==O.current&&(O.current=F,k(F))},[]),N=i||v,_=c||j,E=p.useRef(null),O=p.useRef(null),A=p.useRef(x),I=u!=null,M=Gp(u),R=Gp(a),P=Gp(f),D=p.useCallback(()=>{if(!E.current||!O.current)return;const F={placement:n,strategy:s,middleware:g};R.current&&(F.platform=R.current),n4(E.current,O.current,F).then(G=>{const U={...G,isPositioned:P.current!==!1};W.current&&!bf(A.current,U)&&(A.current=U,ks.flushSync(()=>{b(U)}))})},[g,n,s,R,P]);ef(()=>{f===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,b(F=>({...F,isPositioned:!1})))},[f]);const W=p.useRef(!1);ef(()=>(W.current=!0,()=>{W.current=!1}),[]),ef(()=>{if(N&&(E.current=N),_&&(O.current=_),N&&_){if(M.current)return M.current(N,_,D);D()}},[N,_,D,M,I]);const Y=p.useMemo(()=>({reference:E,floating:O,setReference:$,setFloating:S}),[$,S]),H=p.useMemo(()=>({reference:N,floating:_}),[N,_]),q=p.useMemo(()=>{const F={position:s,left:0,top:0};if(!H.floating)return F;const G=Nj(H.floating,x.x),U=Nj(H.floating,x.y);return d?{...F,transform:"translate("+G+"px, "+U+"px)",...L1(H.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:G,top:U}},[s,d,H.floating,x.x,x.y]);return p.useMemo(()=>({...x,update:D,refs:Y,elements:H,floatingStyles:q}),[x,D,Y,H,q])}const I1=(e,n)=>{const s=X3(e);return{name:s.name,fn:s.fn,options:[e,n]}},a4=(e,n)=>{const s=Z3(e);return{name:s.name,fn:s.fn,options:[e,n]}},i4=(e,n)=>{const s=e4(e);return{name:s.name,fn:s.fn,options:[e,n]}},l4=(e,n)=>{const s=t4(e);return{name:s.name,fn:s.fn,options:[e,n]}},z1={...wg},c4=z1.useInsertionEffect,d4=c4||(e=>e());function D1(e){const n=p.useRef(()=>{});return d4(()=>{n.current=e}),p.useCallback(function(){for(var s=arguments.length,r=new Array(s),a=0;a<s;a++)r[a]=arguments[a];return n.current==null?void 0:n.current(...r)},[])}var Og=typeof document<"u"?p.useLayoutEffect:p.useEffect;let Sj=!1,u4=0;const Cj=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+u4++;function f4(){const[e,n]=p.useState(()=>Sj?Cj():void 0);return Og(()=>{e==null&&n(Cj())},[]),p.useEffect(()=>{Sj=!0},[]),e}const m4=z1.useId,h4=m4||f4;function p4(){const e=new Map;return{emit(n,s){var r;(r=e.get(n))==null||r.forEach(a=>a(s))},on(n,s){e.set(n,[...e.get(n)||[],s])},off(n,s){var r;e.set(n,((r=e.get(n))==null?void 0:r.filter(a=>a!==s))||[])}}}const g4=p.createContext(null),x4=p.createContext(null),v4=()=>{var e;return((e=p.useContext(g4))==null?void 0:e.id)||null},y4=()=>p.useContext(x4),b4="data-floating-ui-focusable";function w4(e){const{open:n=!1,onOpenChange:s,elements:r}=e,a=h4(),i=p.useRef({}),[c]=p.useState(()=>p4()),d=v4()!=null,[u,f]=p.useState(r.reference),x=D1((h,v,y)=>{i.current.openEvent=h?v:void 0,c.emit("openchange",{open:h,event:v,reason:y,nested:d}),s==null||s(h,v,y)}),b=p.useMemo(()=>({setPositionReference:f}),[]),g=p.useMemo(()=>({reference:u||r.reference||null,floating:r.floating||null,domReference:r.reference}),[u,r.reference,r.floating]);return p.useMemo(()=>({dataRef:i,open:n,onOpenChange:x,elements:g,events:c,floatingId:a,refs:b}),[n,x,g,c,a,b])}function j4(e){e===void 0&&(e={});const{nodeId:n}=e,s=w4({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||s,a=r.elements,[i,c]=p.useState(null),[d,u]=p.useState(null),x=(a==null?void 0:a.domReference)||i,b=p.useRef(null),g=y4();Og(()=>{x&&(b.current=x)},[x]);const h=o4({...e,elements:{...a,...d&&{reference:d}}}),v=p.useCallback(S=>{const N=us(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),contextElement:S}:S;u(N),h.refs.setReference(N)},[h.refs]),y=p.useCallback(S=>{(us(S)||S===null)&&(b.current=S,c(S)),(us(h.refs.reference.current)||h.refs.reference.current===null||S!==null&&!us(S))&&h.refs.setReference(S)},[h.refs]),j=p.useMemo(()=>({...h.refs,setReference:y,setPositionReference:v,domReference:b}),[h.refs,y,v]),k=p.useMemo(()=>({...h.elements,domReference:x}),[h.elements,x]),$=p.useMemo(()=>({...h,...r,refs:j,elements:k,nodeId:n}),[h,j,k,n,r]);return Og(()=>{r.dataRef.current.floatingContext=$;const S=g==null?void 0:g.nodesRef.current.find(N=>N.id===n);S&&(S.context=$)}),p.useMemo(()=>({...h,context:$,refs:j,elements:k}),[h,j,k,$])}const Ej="active",$j="selected";function qp(e,n,s){const r=new Map,a=s==="item";let i=e;if(a&&e){const{[Ej]:c,[$j]:d,...u}=e;i=u}return{...s==="floating"&&{tabIndex:-1,[b4]:""},...i,...n.map(c=>{const d=c?c[s]:null;return typeof d=="function"?e?d(e):null:d}).concat(e).reduce((c,d)=>(d&&Object.entries(d).forEach(u=>{let[f,x]=u;if(!(a&&[Ej,$j].includes(f)))if(f.indexOf("on")===0){if(r.has(f)||r.set(f,[]),typeof x=="function"){var b;(b=r.get(f))==null||b.push(x),c[f]=function(){for(var g,h=arguments.length,v=new Array(h),y=0;y<h;y++)v[y]=arguments[y];return(g=r.get(f))==null?void 0:g.map(j=>j(...v)).find(j=>j!==void 0)}}}else c[f]=x}),c),{})}}function k4(e){e===void 0&&(e=[]);const n=e.map(d=>d==null?void 0:d.reference),s=e.map(d=>d==null?void 0:d.floating),r=e.map(d=>d==null?void 0:d.item),a=p.useCallback(d=>qp(d,e,"reference"),n),i=p.useCallback(d=>qp(d,e,"floating"),s),c=p.useCallback(d=>qp(d,e,"item"),r);return p.useMemo(()=>({getReferenceProps:a,getFloatingProps:i,getItemProps:c}),[a,i,c])}function _j(e,n){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:n}}}}const N4=e=>({name:"inner",options:e,async fn(n){const{listRef:s,overflowRef:r,onFallbackChange:a,offset:i=0,index:c=0,minItemsVisible:d=4,referenceOverflowThreshold:u=0,scrollRef:f,...x}=pl(e,n),{rects:b,elements:{floating:g}}=n,h=s.current[c],v=(f==null?void 0:f.current)||g,y=g.clientTop||v.clientTop,j=g.clientTop!==0,k=v.clientTop!==0,$=g===v;if(!h)return{};const S={...n,...await I1(-h.offsetTop-g.clientTop-b.reference.height/2-h.offsetHeight/2-i).fn(n)},N=await Bp(_j(S,v.scrollHeight+y+g.clientTop),x),_=await Bp(S,{...x,elementContext:"reference"}),E=Hs(0,N.top),O=S.y+E,M=(v.scrollHeight>v.clientHeight?R=>R:Mc)(Hs(0,v.scrollHeight+(j&&$||k?y*2:0)-E-Hs(0,N.bottom)));if(v.style.maxHeight=M+"px",v.scrollTop=E,a){const R=v.offsetHeight<h.offsetHeight*Ia(d,s.current.length)-1||_.top>=-u||_.bottom>=-u;ks.flushSync(()=>a(R))}return r&&(r.current=await Bp(_j({...S,y:O},v.offsetHeight+y+g.clientTop),x)),{y:O}}});function S4(e,n){const{open:s,elements:r}=e,{enabled:a=!0,overflowRef:i,scrollRef:c,onChange:d}=n,u=D1(d),f=p.useRef(!1),x=p.useRef(null),b=p.useRef(null);p.useEffect(()=>{if(!a)return;function h(y){if(y.ctrlKey||!v||i.current==null)return;const j=y.deltaY,k=i.current.top>=-.5,$=i.current.bottom>=-.5,S=v.scrollHeight-v.clientHeight,N=j<0?-1:1,_=j<0?"max":"min";v.scrollHeight<=v.clientHeight||(!k&&j>0||!$&&j<0?(y.preventDefault(),ks.flushSync(()=>{u(E=>E+Math[_](j,S*N))})):/firefox/i.test(g3())&&(v.scrollTop+=j))}const v=(c==null?void 0:c.current)||r.floating;if(s&&v)return v.addEventListener("wheel",h),requestAnimationFrame(()=>{x.current=v.scrollTop,i.current!=null&&(b.current={...i.current})}),()=>{x.current=null,b.current=null,v.removeEventListener("wheel",h)}},[a,s,r.floating,i,c,u]);const g=p.useMemo(()=>({onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const h=(c==null?void 0:c.current)||r.floating;if(!(!i.current||!h||!f.current)){if(x.current!==null){const v=h.scrollTop-x.current;(i.current.bottom<-.5&&v<-1||i.current.top<-.5&&v>1)&&ks.flushSync(()=>u(y=>y+v))}requestAnimationFrame(()=>{x.current=h.scrollTop})}}}),[r.floating,u,i,c]);return p.useMemo(()=>a?{floating:g}:{},[a,g])}let gl=p.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});gl.displayName="FloatingContext";let Yx=p.createContext(null);Yx.displayName="PlacementContext";function C4(e){return p.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function E4(){return p.useContext(gl).setReference}function $4(){return p.useContext(gl).getReferenceProps}function _4(){let{getFloatingProps:e,slot:n}=p.useContext(gl);return p.useCallback((...s)=>Object.assign({},e(...s),{"data-anchor":n.anchor}),[e,n])}function T4(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let n=p.useContext(Yx),s=p.useMemo(()=>e,[JSON.stringify(e,(a,i)=>{var c;return(c=i==null?void 0:i.outerHTML)!=null?c:i})]);Xt(()=>{n==null||n(s??null)},[n,s]);let r=p.useContext(gl);return p.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let Tj=4;function R4({children:e,enabled:n=!0}){let[s,r]=p.useState(null),[a,i]=p.useState(0),c=p.useRef(null),[d,u]=p.useState(null);A4(d);let f=n&&s!==null&&d!==null,{to:x="bottom",gap:b=0,offset:g=0,padding:h=0,inner:v}=O4(s,d),[y,j="center"]=x.split(" ");Xt(()=>{f&&i(0)},[f]);let{refs:k,floatingStyles:$,context:S}=j4({open:f,placement:y==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${y}`:`${y}-${j}`,strategy:"absolute",transform:!1,middleware:[I1({mainAxis:y==="selection"?0:b,crossAxis:g}),a4({padding:h}),y!=="selection"&&i4({padding:h}),y==="selection"&&v?N4({...v,padding:h,overflowRef:c,offset:a,minItemsVisible:Tj,referenceOverflowThreshold:h,onFallbackChange(R){var P,D;if(!R)return;let W=S.elements.floating;if(!W)return;let Y=parseFloat(getComputedStyle(W).scrollPaddingBottom)||0,H=Math.min(Tj,W.childElementCount),q=0,F=0;for(let G of(D=(P=S.elements.floating)==null?void 0:P.childNodes)!=null?D:[])if(Ns(G)){let U=G.offsetTop,z=U+G.clientHeight+Y,Q=W.scrollTop,K=Q+W.clientHeight;if(U>=Q&&z<=K)H--;else{F=Math.max(0,Math.min(z,K)-Math.max(U,Q)),q=G.clientHeight;break}}H>=1&&i(G=>{let U=q*H-F+Y;return G>=U?G:U})}}):null,l4({padding:h,apply({availableWidth:R,availableHeight:P,elements:D}){Object.assign(D.floating.style,{overflow:"auto",maxWidth:`${R}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${P}px)`})}})].filter(Boolean),whileElementsMounted:J3}),[N=y,_=j]=S.placement.split("-");y==="selection"&&(N="selection");let E=p.useMemo(()=>({anchor:[N,_].filter(Boolean).join(" ")}),[N,_]),O=S4(S,{overflowRef:c,onChange:i}),{getReferenceProps:A,getFloatingProps:I}=k4([O]),M=dt(R=>{u(R),k.setFloating(R)});return p.createElement(Yx.Provider,{value:r},p.createElement(gl.Provider,{value:{setFloating:M,setReference:k.setReference,styles:$,getReferenceProps:A,getFloatingProps:I,slot:E}},e))}function A4(e){Xt(()=>{if(!e)return;let n=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 n.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{n.disconnect()}},[e])}function O4(e,n){var s,r,a;let i=Kp((s=e==null?void 0:e.gap)!=null?s:"var(--anchor-gap, 0)",n),c=Kp((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",n),d=Kp((a=e==null?void 0:e.padding)!=null?a:"var(--anchor-padding, 0)",n);return{...e,gap:i,offset:c,padding:d}}function Kp(e,n,s=void 0){let r=Jo(),a=dt((u,f)=>{if(u==null)return[s,null];if(typeof u=="number")return[u,null];if(typeof u=="string"){if(!f)return[s,null];let x=Rj(u,f);return[x,b=>{let g=F1(u);{let h=g.map(v=>window.getComputedStyle(f).getPropertyValue(v));r.requestAnimationFrame(function v(){r.nextFrame(v);let y=!1;for(let[k,$]of g.entries()){let S=window.getComputedStyle(f).getPropertyValue($);if(h[k]!==S){h[k]=S,y=!0;break}}if(!y)return;let j=Rj(u,f);x!==j&&(b(j),x=j)})}return r.dispose}]}return[s,null]}),i=p.useMemo(()=>a(e,n)[0],[e,n]),[c=i,d]=p.useState();return Xt(()=>{let[u,f]=a(e,n);if(d(u),!!f)return f(d)},[e,n]),c}function F1(e){let n=/var\((.*)\)/.exec(e);if(n){let s=n[1].indexOf(",");if(s===-1)return[n[1]];let r=n[1].slice(0,s).trim(),a=n[1].slice(s+1).trim();return a?[r,...F1(a)]:[r]}return[]}function Rj(e,n){let s=document.createElement("div");n.appendChild(s),s.style.setProperty("margin-top","0px","important"),s.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(s).marginTop)||0;return n.removeChild(s),r}function M4({children:e,freeze:n},s){let r=U1(n,e);return p.isValidElement(r)?p.cloneElement(r,{ref:s}):He.createElement(He.Fragment,null,r)}He.forwardRef(M4);function U1(e,n){let[s,r]=p.useState(n);return!e&&s!==n&&r(n),e?s:n}let pm=p.createContext(null);pm.displayName="OpenClosedContext";var Jn=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Jn||{});function Qc(){return p.useContext(pm)}function W1({value:e,children:n}){return He.createElement(pm.Provider,{value:e},n)}function P4({children:e}){return He.createElement(pm.Provider,{value:null},e)}function L4(e){function n(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",n))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",n),n())}let Lo=[];L4(()=>{function e(n){if(!qr(n.target)||n.target===document.body||Lo[0]===n.target)return;let s=n.target;s=s.closest(xf),Lo.unshift(s??n.target),Lo=Lo.filter(r=>r!=null&&r.isConnected),Lo.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 I4(e){throw new Error("Unexpected object: "+e)}var en=(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))(en||{});function Ru(e,n){let s=n.resolveItems();if(s.length<=0)return null;let r=n.resolveActiveIndex(),a=r??-1;switch(e.focus){case 0:{for(let i=0;i<s.length;++i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 1:{a===-1&&(a=s.length);for(let i=a-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 2:{for(let i=a+1;i<s.length;++i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 3:{for(let i=s.length-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 4:{for(let i=0;i<s.length;++i)if(n.resolveId(s[i],i,s)===e.id)return i;return r}case 5:return null;default:I4(e)}}function Qx(e){let n=dt(e),s=p.useRef(!1);p.useEffect(()=>(s.current=!1,()=>{s.current=!0,am(()=>{s.current&&n()})}),[n])}function z4(){let e=typeof document>"u";return"useSyncExternalStore"in wg?(n=>n.useSyncExternalStore)(wg)(()=>()=>{},()=>!1,()=>!e):!1}function Jc(){let e=z4(),[n,s]=p.useState(Nr.isHandoffComplete);return n&&Nr.isHandoffComplete===!1&&s(!1),p.useEffect(()=>{n!==!0&&s(!0)},[n]),p.useEffect(()=>Nr.handoff(),[]),e?!1:n}let H1=p.createContext(!1);function D4(){return p.useContext(H1)}function Aj(e){return He.createElement(H1.Provider,{value:e.force},e.children)}function F4(e){let n=D4(),s=p.useContext(G1),[r,a]=p.useState(()=>{var i;if(!n&&s!==null)return(i=s.current)!=null?i:null;if(Nr.isServer)return null;let c=e==null?void 0:e.getElementById("headlessui-portal-root");if(c)return c;if(e===null)return null;let d=e.createElement("div");return d.setAttribute("id","headlessui-portal-root"),e.body.appendChild(d)});return p.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),p.useEffect(()=>{n||s!==null&&a(s.current)},[s,a,n]),r}let B1=p.Fragment,U4=pn(function(e,n){let{ownerDocument:s=null,...r}=e,a=p.useRef(null),i=Dn(fA(h=>{a.current=h}),n),c=Rc(a.current),d=s??c,u=F4(d),f=p.useContext(Mg),x=Jo(),b=Jc(),g=Sn();return Qx(()=>{var h;u&&u.childNodes.length<=0&&((h=u.parentElement)==null||h.removeChild(u))}),!u||!b?null:ks.createPortal(He.createElement("div",{"data-headlessui-portal":"",ref:h=>{x.dispose(),f&&h&&x.add(f.register(h))}},g({ourProps:{ref:i},theirProps:r,slot:{},defaultTag:B1,name:"Portal"})),u)});function W4(e,n){let s=Dn(n),{enabled:r=!0,ownerDocument:a,...i}=e,c=Sn();return r?He.createElement(U4,{...i,ownerDocument:a,ref:s}):c({ourProps:{ref:s},theirProps:i,slot:{},defaultTag:B1,name:"Portal"})}let H4=p.Fragment,G1=p.createContext(null);function B4(e,n){let{target:s,...r}=e,a={ref:Dn(n)},i=Sn();return He.createElement(G1.Provider,{value:s},i({ourProps:a,theirProps:r,defaultTag:H4,name:"Popover.Group"}))}let Mg=p.createContext(null);function G4(){let e=p.useContext(Mg),n=p.useRef([]),s=dt(i=>(n.current.push(i),e&&e.register(i),()=>r(i))),r=dt(i=>{let c=n.current.indexOf(i);c!==-1&&n.current.splice(c,1),e&&e.unregister(i)}),a=p.useMemo(()=>({register:s,unregister:r,portals:n}),[s,r,n]);return[n,p.useMemo(()=>function({children:i}){return He.createElement(Mg.Provider,{value:a},i)},[a])]}let q4=pn(W4),q1=pn(B4),K1=Object.assign(q4,{Group:q1});const tf={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function V1(e){let n=e.getBoundingClientRect();return`${n.x},${n.y}`}function K4(e,n,s){let r=Es();if(n.kind==="Tracked"){let a=function(){i!==V1(e)&&(r.dispose(),s())},{position:i}=n,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 V4(e,n=typeof document<"u"?document.defaultView:null,s){let r=Vc(e,"escape");w1(n,"keydown",a=>{r&&(a.defaultPrevented||a.key===vn.Escape&&s(a))})}function Y4(){var e;let[n]=p.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[s,r]=p.useState((e=n==null?void 0:n.matches)!=null?e:!1);return Xt(()=>{if(!n)return;function a(i){r(i.matches)}return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},[n]),s}function Q4({defaultContainers:e=[],portals:n,mainTreeNode:s}={}){let r=dt(()=>{var a,i;let c=ml(s),d=[];for(let u of e)u!==null&&(Yr(u)?d.push(u):"current"in u&&Yr(u.current)&&d.push(u.current));if(n!=null&&n.current)for(let u of n.current)d.push(u);for(let u of(a=c==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?a:[])u!==document.body&&u!==document.head&&Yr(u)&&u.id!=="headlessui-portal-root"&&(s&&(u.contains(s)||u.contains((i=s==null?void 0:s.getRootNode())==null?void 0:i.host))||d.some(f=>u.contains(f))||d.push(u));return d});return{resolveContainers:r,contains:dt(a=>r().some(i=>i.contains(a)))}}let Y1=p.createContext(null);function Oj({children:e,node:n}){let[s,r]=p.useState(null),a=Q1(n??s);return He.createElement(Y1.Provider,{value:a},e,a===null&&He.createElement(Tc,{features:tl.Hidden,ref:i=>{var c,d;if(i){for(let u of(d=(c=ml(i))==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?d:[])if(u!==document.body&&u!==document.head&&Yr(u)&&u!=null&&u.contains(i)){r(u);break}}}}))}function Q1(e=null){var n;return(n=p.useContext(Y1))!=null?n:e}function Jx(){let e=p.useRef(!1);return Xt(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var xc=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(xc||{});function J4(){let e=p.useRef(0);return y1(!0,"keydown",n=>{n.key==="Tab"&&(e.current=n.shiftKey?1:0)},!0),e}function J1(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let n=new Set;for(let s of e.current)Yr(s.current)&&n.add(s.current);return n}let X4="div";var ka=(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))(ka||{});function Z4(e,n){let s=p.useRef(null),r=Dn(s,n),{initialFocus:a,initialFocusFallback:i,containers:c,features:d=15,...u}=e;Jc()||(d=0);let f=Rc(s.current);sO(d,{ownerDocument:f});let x=rO(d,{ownerDocument:f,container:s,initialFocus:a,initialFocusFallback:i});oO(d,{ownerDocument:f,container:s,containers:c,previousActiveElement:x});let b=J4(),g=dt($=>{if(!Ns(s.current))return;let S=s.current;(N=>N())(()=>{es(b.current,{[xc.Forwards]:()=>{Wi(S,ir.First,{skipElements:[$.relatedTarget,i]})},[xc.Backwards]:()=>{Wi(S,ir.Last,{skipElements:[$.relatedTarget,i]})}})})}),h=Vc(!!(d&2),"focus-trap#tab-lock"),v=Jo(),y=p.useRef(!1),j={ref:r,onKeyDown($){$.key=="Tab"&&(y.current=!0,v.requestAnimationFrame(()=>{y.current=!1}))},onBlur($){if(!(d&4))return;let S=J1(c);Ns(s.current)&&S.add(s.current);let N=$.relatedTarget;qr(N)&&N.dataset.headlessuiFocusGuard!=="true"&&(X1(S,N)||(y.current?Wi(s.current,es(b.current,{[xc.Forwards]:()=>ir.Next,[xc.Backwards]:()=>ir.Previous})|ir.WrapAround,{relativeTo:$.target}):qr($.target)&&Qr($.target)))}},k=Sn();return He.createElement(He.Fragment,null,h&&He.createElement(Tc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:g,features:tl.Focusable}),k({ourProps:j,theirProps:u,defaultTag:X4,name:"FocusTrap"}),h&&He.createElement(Tc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:g,features:tl.Focusable}))}let eO=pn(Z4),tO=Object.assign(eO,{features:ka});function nO(e=!0){let n=p.useRef(Lo.slice());return Gx(([s],[r])=>{r===!0&&s===!1&&am(()=>{n.current.splice(0)}),r===!1&&s===!0&&(n.current=Lo.slice())},[e,Lo,n]),dt(()=>{var s;return(s=n.current.find(r=>r!=null&&r.isConnected))!=null?s:null})}function sO(e,{ownerDocument:n}){let s=!!(e&8),r=nO(s);Gx(()=>{s||BN(n==null?void 0:n.body)&&Qr(r())},[s]),Qx(()=>{s&&Qr(r())})}function rO(e,{ownerDocument:n,container:s,initialFocus:r,initialFocusFallback:a}){let i=p.useRef(null),c=Vc(!!(e&1),"focus-trap#initial-focus"),d=Jx();return Gx(()=>{if(e===0)return;if(!c){a!=null&&a.current&&Qr(a.current);return}let u=s.current;u&&am(()=>{if(!d.current)return;let f=n==null?void 0:n.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===f){i.current=f;return}}else if(u.contains(f)){i.current=f;return}if(r!=null&&r.current)Qr(r.current);else{if(e&16){if(Wi(u,ir.First|ir.AutoFocus)!==Tg.Error)return}else if(Wi(u,ir.First)!==Tg.Error)return;if(a!=null&&a.current&&(Qr(a.current),(n==null?void 0:n.activeElement)===a.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}i.current=n==null?void 0:n.activeElement})},[a,c,e]),i}function oO(e,{ownerDocument:n,container:s,containers:r,previousActiveElement:a}){let i=Jx(),c=!!(e&4);w1(n==null?void 0:n.defaultView,"focus",d=>{if(!c||!i.current)return;let u=J1(r);Ns(s.current)&&u.add(s.current);let f=a.current;if(!f)return;let x=d.target;Ns(x)?X1(u,x)?(a.current=x,Qr(x)):(d.preventDefault(),d.stopPropagation(),Qr(f)):Qr(a.current)},!0)}function X1(e,n){for(let s of e)if(s.contains(n))return!0;return!1}function Z1(e){var n;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!wc((n=e.as)!=null?n:tS)||He.Children.count(e.children)===1}let gm=p.createContext(null);gm.displayName="TransitionContext";var aO=(e=>(e.Visible="visible",e.Hidden="hidden",e))(aO||{});function iO(){let e=p.useContext(gm);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function lO(){let e=p.useContext(xm);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let xm=p.createContext(null);xm.displayName="NestingContext";function vm(e){return"children"in e?vm(e.children):e.current.filter(({el:n})=>n.current!==null).filter(({state:n})=>n==="visible").length>0}function eS(e,n){let s=Xo(e),r=p.useRef([]),a=Jx(),i=Jo(),c=dt((h,v=Io.Hidden)=>{let y=r.current.findIndex(({el:j})=>j===h);y!==-1&&(es(v,{[Io.Unmount](){r.current.splice(y,1)},[Io.Hidden](){r.current[y].state="hidden"}}),i.microTask(()=>{var j;!vm(r)&&a.current&&((j=s.current)==null||j.call(s))}))}),d=dt(h=>{let v=r.current.find(({el:y})=>y===h);return v?v.state!=="visible"&&(v.state="visible"):r.current.push({el:h,state:"visible"}),()=>c(h,Io.Unmount)}),u=p.useRef([]),f=p.useRef(Promise.resolve()),x=p.useRef({enter:[],leave:[]}),b=dt((h,v,y)=>{u.current.splice(0),n&&(n.chains.current[v]=n.chains.current[v].filter(([j])=>j!==h)),n==null||n.chains.current[v].push([h,new Promise(j=>{u.current.push(j)})]),n==null||n.chains.current[v].push([h,new Promise(j=>{Promise.all(x.current[v].map(([k,$])=>$)).then(()=>j())})]),v==="enter"?f.current=f.current.then(()=>n==null?void 0:n.wait.current).then(()=>y(v)):y(v)}),g=dt((h,v,y)=>{Promise.all(x.current[v].splice(0).map(([j,k])=>k)).then(()=>{var j;(j=u.current.shift())==null||j()}).then(()=>y(v))});return p.useMemo(()=>({children:r,register:d,unregister:c,onStart:b,onStop:g,wait:f,chains:x}),[d,c,r,b,g,x,f])}let tS=p.Fragment,nS=el.RenderStrategy;function cO(e,n){var s,r;let{transition:a=!0,beforeEnter:i,afterEnter:c,beforeLeave:d,afterLeave:u,enter:f,enterFrom:x,enterTo:b,entered:g,leave:h,leaveFrom:v,leaveTo:y,...j}=e,[k,$]=p.useState(null),S=p.useRef(null),N=Z1(e),_=Dn(...N?[S,n,$]:n===null?[]:[n]),E=(s=j.unmount)==null||s?Io.Unmount:Io.Hidden,{show:O,appear:A,initial:I}=iO(),[M,R]=p.useState(O?"visible":"hidden"),P=lO(),{register:D,unregister:W}=P;Xt(()=>D(S),[D,S]),Xt(()=>{if(E===Io.Hidden&&S.current){if(O&&M!=="visible"){R("visible");return}return es(M,{hidden:()=>W(S),visible:()=>D(S)})}},[M,S,D,W,O,E]);let Y=Jc();Xt(()=>{if(N&&Y&&M==="visible"&&S.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[S,M,Y,N]);let H=I&&!A,q=A&&O&&I,F=p.useRef(!1),G=eS(()=>{F.current||(R("hidden"),W(S))},P),U=dt(fe=>{F.current=!0;let ve=fe?"enter":"leave";G.onStart(S,ve,Ee=>{Ee==="enter"?i==null||i():Ee==="leave"&&(d==null||d())})}),z=dt(fe=>{let ve=fe?"enter":"leave";F.current=!1,G.onStop(S,ve,Ee=>{Ee==="enter"?c==null||c():Ee==="leave"&&(u==null||u())}),ve==="leave"&&!vm(G)&&(R("hidden"),W(S))});p.useEffect(()=>{N&&a||(U(O),z(O))},[O,N,a]);let Q=!(!a||!N||!Y||H),[,K]=N1(Q,k,O,{start:U,end:z}),Z=Po({ref:_,className:((r=$g(j.className,q&&f,q&&x,K.enter&&f,K.enter&&K.closed&&x,K.enter&&!K.closed&&b,K.leave&&h,K.leave&&!K.closed&&v,K.leave&&K.closed&&y,!K.transition&&O&&g))==null?void 0:r.trim())||void 0,...k1(K)}),de=0;M==="visible"&&(de|=Jn.Open),M==="hidden"&&(de|=Jn.Closed),O&&M==="hidden"&&(de|=Jn.Opening),!O&&M==="visible"&&(de|=Jn.Closing);let re=Sn();return He.createElement(xm.Provider,{value:G},He.createElement(W1,{value:de},re({ourProps:Z,theirProps:j,defaultTag:tS,features:nS,visible:M==="visible",name:"Transition.Child"})))}function dO(e,n){let{show:s,appear:r=!1,unmount:a=!0,...i}=e,c=p.useRef(null),d=Z1(e),u=Dn(...d?[c,n]:n===null?[]:[n]);Jc();let f=Qc();if(s===void 0&&f!==null&&(s=(f&Jn.Open)===Jn.Open),s===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[x,b]=p.useState(s?"visible":"hidden"),g=eS(()=>{s||b("hidden")}),[h,v]=p.useState(!0),y=p.useRef([s]);Xt(()=>{h!==!1&&y.current[y.current.length-1]!==s&&(y.current.push(s),v(!1))},[y,s]);let j=p.useMemo(()=>({show:s,appear:r,initial:h}),[s,r,h]);Xt(()=>{s?b("visible"):!vm(g)&&c.current!==null&&b("hidden")},[s,g]);let k={unmount:a},$=dt(()=>{var _;h&&v(!1),(_=e.beforeEnter)==null||_.call(e)}),S=dt(()=>{var _;h&&v(!1),(_=e.beforeLeave)==null||_.call(e)}),N=Sn();return He.createElement(xm.Provider,{value:g},He.createElement(gm.Provider,{value:j},N({ourProps:{...k,as:p.Fragment,children:He.createElement(sS,{ref:u,...k,...i,beforeEnter:$,beforeLeave:S})},theirProps:{},defaultTag:p.Fragment,features:nS,visible:x==="visible",name:"Transition"})))}function uO(e,n){let s=p.useContext(gm)!==null,r=Qc()!==null;return He.createElement(He.Fragment,null,!s&&r?He.createElement(Pg,{ref:n,...e}):He.createElement(sS,{ref:n,...e}))}let Pg=pn(dO),sS=pn(cO),Xx=pn(uO),fO=Object.assign(Pg,{Child:Xx,Root:Pg});var mO=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(mO||{}),hO=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(hO||{});let pO={0(e,n){return e.titleId===n.id?e:{...e,titleId:n.id}}},Zx=p.createContext(null);Zx.displayName="DialogContext";function ym(e){let n=p.useContext(Zx);if(n===null){let s=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,ym),s}return n}function gO(e,n){return es(n.type,pO,e,n)}let Mj=pn(function(e,n){let s=p.useId(),{id:r=`headlessui-dialog-${s}`,open:a,onClose:i,initialFocus:c,role:d="dialog",autoFocus:u=!0,__demoMode:f=!1,unmount:x=!1,...b}=e,g=p.useRef(!1);d=(function(){return d==="dialog"||d==="alertdialog"?d:(g.current||(g.current=!0,console.warn(`Invalid role [${d}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let h=Qc();a===void 0&&h!==null&&(a=(h&Jn.Open)===Jn.Open);let v=p.useRef(null),y=Dn(v,n),j=Rc(v.current),k=a?0:1,[$,S]=p.useReducer(gO,{titleId:null,descriptionId:null,panelRef:p.createRef()}),N=dt(()=>i(!1)),_=dt(K=>S({type:0,id:K})),E=Jc()?k===0:!1,[O,A]=G4(),I={get current(){var K;return(K=$.panelRef.current)!=null?K:v.current}},M=Q1(),{resolveContainers:R}=Q4({mainTreeNode:M,portals:O,defaultContainers:[I]}),P=h!==null?(h&Jn.Closing)===Jn.Closing:!1;m1(f||P?!1:E,{allowed:dt(()=>{var K,Z;return[(Z=(K=v.current)==null?void 0:K.closest("[data-headlessui-portal]"))!=null?Z:null]}),disallowed:dt(()=>{var K;return[(K=M==null?void 0:M.closest("body > *:not(#headlessui-portal-root)"))!=null?K:null]})});let D=cm.get(null);Xt(()=>{if(E)return D.actions.push(r),()=>D.actions.pop(r)},[D,r,E]);let W=Yn(D,p.useCallback(K=>D.selectors.isTop(K,r),[D,r]));b1(W,R,K=>{K.preventDefault(),N()}),V4(W,j==null?void 0:j.defaultView,K=>{K.preventDefault(),K.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),N()}),j1(f||P?!1:E,j,R),h1(E,v,N);let[Y,H]=hA(),q=p.useMemo(()=>[{dialogState:k,close:N,setTitleId:_,unmount:x},$],[k,N,_,x,$]),F=Ks({open:k===0}),G={ref:y,id:r,role:d,tabIndex:-1,"aria-modal":f?void 0:k===0?!0:void 0,"aria-labelledby":$.titleId,"aria-describedby":Y,unmount:x},U=!Y4(),z=ka.None;E&&!f&&(z|=ka.RestoreFocus,z|=ka.TabLock,u&&(z|=ka.AutoFocus),U&&(z|=ka.InitialFocus));let Q=Sn();return He.createElement(P4,null,He.createElement(Aj,{force:!0},He.createElement(K1,null,He.createElement(Zx.Provider,{value:q},He.createElement(q1,{target:v},He.createElement(Aj,{force:!1},He.createElement(H,{slot:F},He.createElement(A,null,He.createElement(tO,{initialFocus:c,initialFocusFallback:v,containers:R,features:z},He.createElement(NA,{value:N},Q({ourProps:G,theirProps:b,slot:F,defaultTag:xO,features:vO,visible:k===0,name:"Dialog"})))))))))))}),xO="div",vO=el.RenderStrategy|el.Static;function yO(e,n){let{transition:s=!1,open:r,...a}=e,i=Qc(),c=e.hasOwnProperty("open")||i!==null,d=e.hasOwnProperty("onClose");if(!c&&!d)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!c)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!d)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!i&&typeof e.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(r!==void 0||s)&&!a.static?He.createElement(Oj,null,He.createElement(fO,{show:r,transition:s,unmount:a.unmount},He.createElement(Mj,{ref:n,...a}))):He.createElement(Oj,null,He.createElement(Mj,{ref:n,open:r,...a}))}let bO="div";function wO(e,n){let s=p.useId(),{id:r=`headlessui-dialog-panel-${s}`,transition:a=!1,...i}=e,[{dialogState:c,unmount:d},u]=ym("Dialog.Panel"),f=Dn(n,u.panelRef),x=Ks({open:c===0}),b=dt(j=>{j.stopPropagation()}),g={ref:f,id:r,onClick:b},h=a?Xx:p.Fragment,v=a?{unmount:d}:{},y=Sn();return He.createElement(h,{...v},y({ourProps:g,theirProps:i,slot:x,defaultTag:bO,name:"Dialog.Panel"}))}let jO="div";function kO(e,n){let{transition:s=!1,...r}=e,[{dialogState:a,unmount:i}]=ym("Dialog.Backdrop"),c=Ks({open:a===0}),d={ref:n,"aria-hidden":!0},u=s?Xx:p.Fragment,f=s?{unmount:i}:{},x=Sn();return He.createElement(u,{...f},x({ourProps:d,theirProps:r,slot:c,defaultTag:jO,name:"Dialog.Backdrop"}))}let NO="h2";function SO(e,n){let s=p.useId(),{id:r=`headlessui-dialog-title-${s}`,...a}=e,[{dialogState:i,setTitleId:c}]=ym("Dialog.Title"),d=Dn(n);p.useEffect(()=>(c(r),()=>c(null)),[r,c]);let u=Ks({open:i===0}),f={ref:d,id:r};return Sn()({ourProps:f,theirProps:a,slot:u,defaultTag:NO,name:"Dialog.Title"})}let CO=pn(yO),rS=pn(wO),EO=pn(kO),oS=pn(SO),$O=Object.assign(CO,{Panel:rS,Title:oS,Description:s1}),Pj=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function Lj(e){var n,s;let r=(n=e.innerText)!=null?n:"",a=e.cloneNode(!0);if(!Ns(a))return r;let i=!1;for(let d of a.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))d.remove(),i=!0;let c=i?(s=a.innerText)!=null?s:"":r;return Pj.test(c)&&(c=c.replace(Pj,"")),c}function _O(e){let n=e.getAttribute("aria-label");if(typeof n=="string")return n.trim();let s=e.getAttribute("aria-labelledby");if(s){let r=s.split(" ").map(a=>{let i=document.getElementById(a);if(i){let c=i.getAttribute("aria-label");return typeof c=="string"?c.trim():Lj(i).trim()}return null}).filter(Boolean);if(r.length>0)return r.join(", ")}return Lj(e).trim()}function TO(e){let n=p.useRef(""),s=p.useRef("");return dt(()=>{let r=e.current;if(!r)return"";let a=r.innerText;if(n.current===a)return s.current;let i=_O(r).trim().toLowerCase();return n.current=a,s.current=i,i})}var RO=Object.defineProperty,AO=(e,n,s)=>n in e?RO(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Ij=(e,n,s)=>(AO(e,typeof n!="symbol"?n+"":n,s),s),In=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(In||{}),zo=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(zo||{}),nf=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(nf||{}),aS=(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))(aS||{});function zj(e,n=s=>s){let s=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=x1(n(e.options.slice()),i=>i.dataRef.current.domRef.current),a=s?r.indexOf(s):null;return a===-1&&(a=null),{options:r,activeOptionIndex:a}}let OO={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=e.buttonElement?tf.Tracked(V1(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:en.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:n}},0(e,n){if(e.dataRef.current.disabled||e.listboxState===0)return e;let s=e.activeOptionIndex,{isSelected:r}=e.dataRef.current,a=e.options.findIndex(i=>r(i.dataRef.current.value));return a!==-1&&(s=a),{...e,frozenValue:!1,pendingFocus:n.focus,listboxState:0,activeOptionIndex:s,__demoMode:!1,buttonPositionState:tf.Idle}},2(e,n){var s,r,a,i,c;if(e.dataRef.current.disabled||e.listboxState===1)return e;let d={...e,searchQuery:"",activationTrigger:(s=n.trigger)!=null?s:1,__demoMode:!1};if(n.focus===en.Nothing)return{...d,activeOptionIndex:null};if(n.focus===en.Specific)return{...d,activeOptionIndex:e.options.findIndex(x=>x.id===n.id)};if(n.focus===en.Previous){let x=e.activeOptionIndex;if(x!==null){let b=e.options[x].dataRef.current.domRef,g=Ru(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(g!==null){let h=e.options[g].dataRef.current.domRef;if(((r=b.current)==null?void 0:r.previousElementSibling)===h.current||((a=h.current)==null?void 0:a.previousElementSibling)===null)return{...d,activeOptionIndex:g}}}}else if(n.focus===en.Next){let x=e.activeOptionIndex;if(x!==null){let b=e.options[x].dataRef.current.domRef,g=Ru(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(g!==null){let h=e.options[g].dataRef.current.domRef;if(((i=b.current)==null?void 0:i.nextElementSibling)===h.current||((c=h.current)==null?void 0:c.nextElementSibling)===null)return{...d,activeOptionIndex:g}}}}let u=zj(e),f=Ru(n,{resolveItems:()=>u.options,resolveActiveIndex:()=>u.activeOptionIndex,resolveId:x=>x.id,resolveDisabled:x=>x.dataRef.current.disabled});return{...d,...u,activeOptionIndex:f}},3:(e,n)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let s=e.searchQuery!==""?0:1,r=e.searchQuery+n.value.toLowerCase(),a=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+s).concat(e.options.slice(0,e.activeOptionIndex+s)):e.options).find(c=>{var d;return!c.dataRef.current.disabled&&((d=c.dataRef.current.textValue)==null?void 0:d.startsWith(r))}),i=a?e.options.indexOf(a):-1;return i===-1||i===e.activeOptionIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeOptionIndex:i,activationTrigger:1}},4(e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},5(e){return e.dataRef.current.mode===0?{...e,frozenValue:!0}:{...e}},6:(e,n)=>{let s=e.options.concat(n.options),r=e.activeOptionIndex;if(e.pendingFocus.focus!==en.Nothing&&(r=Ru(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 i=s.findIndex(c=>a==null?void 0:a(c.dataRef.current.value));i!==-1&&(r=i)}}return{...e,options:s,activeOptionIndex:r,pendingFocus:{focus:en.Nothing},pendingShouldSort:!0}},7:(e,n)=>{let s=e.options,r=[],a=new Set(n.options);for(let[i,c]of s.entries())if(a.has(c.id)&&(r.push(i),a.delete(c.id),a.size===0))break;if(r.length>0){s=s.slice();for(let i of r.reverse())s.splice(i,1)}return{...e,options:s,activationTrigger:1}},8:(e,n)=>e.buttonElement===n.element?e:{...e,buttonElement:n.element},9:(e,n)=>e.optionsElement===n.element?e:{...e,optionsElement:n.element},10:e=>e.pendingShouldSort?{...e,...zj(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:tf.Moved}}};class ev extends c1{constructor(n){super(n),Ij(this,"actions",{onChange:s=>{let{onChange:r,compare:a,mode:i,value:c}=this.state.dataRef.current;return es(i,{0:()=>r==null?void 0:r(s),1:()=>{let d=c.slice(),u=d.findIndex(f=>a(f,s));return u===-1?d.push(s):d.splice(u,1),r==null?void 0:r(d)}})},registerOption:Dp(()=>{let s=[],r=new Set;return[(a,i)=>{r.has(i)||(r.add(i),s.push({id:a,dataRef:i}))},()=>(r.clear(),this.send({type:6,options:s.splice(0)}))]}),unregisterOption:Dp(()=>{let s=[];return[r=>s.push(r),()=>{this.send({type:7,options:s.splice(0)})}]}),goToOption:Dp(()=>{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})}}),Ij(this,"selectors",{activeDescendantId(s){var r;let a=s.activeOptionIndex,i=s.options;return a===null||(r=i[a])==null?void 0:r.id},isActive(s,r){var a;let i=s.activeOptionIndex,c=s.options;return i!==null?((a=c[i])==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=cm.get(null);this.disposables.add(r.on(u1.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(K4(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:n,__demoMode:s=!1}){return new ev({id:n,dataRef:{current:{}},listboxState:s?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:en.Nothing},frozenValue:!1,__demoMode:s,buttonPositionState:tf.Idle})}reduce(n,s){return es(s.type,OO,n,s)}}const iS=p.createContext(null);function tv(e){let n=p.useContext(iS);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,lS),s}return n}function lS({id:e,__demoMode:n=!1}){let s=p.useMemo(()=>ev.new({id:e,__demoMode:n}),[]);return Qx(()=>s.dispose()),s}let bm=p.createContext(null);bm.displayName="ListboxDataContext";function Xc(e){let n=p.useContext(bm);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Xc),s}return n}let MO=p.Fragment;function PO(e,n){let s=p.useId(),r=Hx(),{value:a,defaultValue:i,form:c,name:d,onChange:u,by:f,invalid:x=!1,disabled:b=r||!1,horizontal:g=!1,multiple:h=!1,__demoMode:v=!1,...y}=e;const j=g?"horizontal":"vertical";let k=Dn(n),$=JR(i),[S=h?[]:void 0,N]=QR(a,u,$),_=lS({id:s,__demoMode:v}),E=p.useRef({static:!1,hold:!1}),O=p.useRef(new Map),A=CA(f),I=p.useCallback(Q=>es(M.mode,{[zo.Multi]:()=>S.some(K=>A(K,Q)),[zo.Single]:()=>A(S,Q)}),[S]),M=Ks({value:S,disabled:b,invalid:x,mode:h?zo.Multi:zo.Single,orientation:j,onChange:N,compare:A,isSelected:I,optionsPropsRef:E,listRef:O});Xt(()=>{_.state.dataRef.current=M},[M]);let R=Yn(_,Q=>Q.listboxState),P=cm.get(null),D=Yn(P,p.useCallback(Q=>P.selectors.isTop(Q,s),[P,s])),[W,Y]=Yn(_,Q=>[Q.buttonElement,Q.optionsElement]);b1(D,[W,Y],(Q,K)=>{_.send({type:aS.CloseListbox}),g1(K,Bx.Loose)||(Q.preventDefault(),W==null||W.focus())});let H=Ks({open:R===In.Open,disabled:b,invalid:x,value:S}),[q,F]=vA({inherit:!0}),G={ref:k},U=p.useCallback(()=>{if($!==void 0)return N==null?void 0:N($)},[N,$]),z=Sn();return He.createElement(F,{value:q,props:{htmlFor:W==null?void 0:W.id},slot:{open:R===In.Open,disabled:b}},He.createElement(R4,null,He.createElement(iS.Provider,{value:_},He.createElement(bm.Provider,{value:M},He.createElement(W1,{value:es(R,{[In.Open]:Jn.Open,[In.Closed]:Jn.Closed})},d!=null&&S!=null&&He.createElement(rA,{disabled:b,data:{[d]:S},form:c,onReset:U}),z({ourProps:G,theirProps:y,slot:H,defaultTag:MO,name:"Listbox"}))))))}let LO="button";function IO(e,n){let s=p.useId(),r=JN(),a=Xc("Listbox.Button"),i=tv("Listbox.Button"),{id:c=r||`headlessui-listbox-button-${s}`,disabled:d=a.disabled||!1,autoFocus:u=!1,...f}=e,x=Dn(n,E4(),i.actions.setButtonElement),b=$4(),[g,h,v]=Yn(i,Y=>[Y.listboxState,Y.buttonElement,Y.optionsElement]),y=g===In.Open;QA(y,{trigger:h,action:p.useCallback(Y=>{if(h!=null&&h.contains(Y.target))return _u.Ignore;let H=Y.target.closest('[role="option"]:not([data-disabled])');return Ns(H)?_u.Select(H):v!=null&&v.contains(Y.target)?_u.Ignore:_u.Close},[h,v]),close:i.actions.closeListbox,select:i.actions.selectActiveOption});let j=dt(Y=>{switch(Y.key){case vn.Enter:XR(Y.currentTarget);break;case vn.Space:case vn.ArrowDown:Y.preventDefault(),i.actions.openListbox({focus:a.value?en.Nothing:en.First});break;case vn.ArrowUp:Y.preventDefault(),i.actions.openListbox({focus:a.value?en.Nothing:en.Last});break}}),k=dt(Y=>{switch(Y.key){case vn.Space:Y.preventDefault();break}}),$=$A(Y=>{var H;i.state.listboxState===In.Open?(ks.flushSync(()=>i.actions.closeListbox()),(H=i.state.buttonElement)==null||H.focus({preventScroll:!0})):(Y.preventDefault(),i.actions.openListbox({focus:en.Nothing}))}),S=dt(Y=>Y.preventDefault()),N=o1([c]),_=mA(),{isFocusVisible:E,focusProps:O}=MR({autoFocus:u}),{isHovered:A,hoverProps:I}=IR({isDisabled:d}),{pressed:M,pressProps:R}=HR({disabled:d}),P=Ks({open:g===In.Open,active:M||g===In.Open,disabled:d,invalid:a.invalid,value:a.value,hover:A,focus:E,autofocus:u}),D=Yn(i,Y=>Y.listboxState===In.Open),W=qN(b(),{ref:x,id:c,type:JA(e,h),"aria-haspopup":"listbox","aria-controls":v==null?void 0:v.id,"aria-expanded":D,"aria-labelledby":N,"aria-describedby":_,disabled:d||void 0,autoFocus:u,onKeyDown:j,onKeyUp:k,onKeyPress:S},$,O,I,R);return Sn()({ourProps:W,theirProps:f,slot:P,defaultTag:LO,name:"Listbox.Button"})}let cS=p.createContext(!1),zO="div",DO=el.RenderStrategy|el.Static;function FO(e,n){let s=p.useId(),{id:r=`headlessui-listbox-options-${s}`,anchor:a,portal:i=!1,modal:c=!0,transition:d=!1,...u}=e,f=C4(a),[x,b]=p.useState(null);f&&(i=!0);let g=Xc("Listbox.Options"),h=tv("Listbox.Options"),[v,y,j,k]=Yn(h,re=>[re.listboxState,re.buttonElement,re.optionsElement,re.__demoMode]),$=Rc(y),S=Rc(j),N=Qc(),[_,E]=N1(d,x,N!==null?(N&Jn.Open)===Jn.Open:v===In.Open);h1(_,y,h.actions.closeListbox);let O=k?!1:c&&v===In.Open;j1(O,S);let A=k?!1:c&&v===In.Open;m1(A,{allowed:p.useCallback(()=>[y,j],[y,j])});let I=Yn(h,h.selectors.didButtonMove)?!1:_,M=Yn(h,h.selectors.hasFrozenValue)&&!e.static,R=U1(M,g.value),P=p.useCallback(re=>g.compare(R,re),[g.compare,R]),D=Yn(h,re=>{var fe;if(f==null||!((fe=f==null?void 0:f.to)!=null&&fe.includes("selection")))return null;let ve=re.options.findIndex(Ee=>P(Ee.dataRef.current.value));return ve===-1&&(ve=0),ve}),W=(()=>{if(f==null)return;if(D===null)return{...f,inner:void 0};let re=Array.from(g.listRef.current.values());return{...f,inner:{listRef:{current:re},index:D}}})(),[Y,H]=T4(W),q=_4(),F=Dn(n,f?Y:null,h.actions.setOptionsElement,b),G=Jo();p.useEffect(()=>{let re=j;re&&v===In.Open&&(BN(re)||re==null||re.focus({preventScroll:!0}))},[v,j]);let U=dt(re=>{var fe;switch(G.dispose(),re.key){case vn.Space:if(h.state.searchQuery!=="")return re.preventDefault(),re.stopPropagation(),h.actions.search(re.key);case vn.Enter:re.preventDefault(),re.stopPropagation(),h.actions.selectActiveOption();break;case es(g.orientation,{vertical:vn.ArrowDown,horizontal:vn.ArrowRight}):return re.preventDefault(),re.stopPropagation(),h.actions.goToOption({focus:en.Next});case es(g.orientation,{vertical:vn.ArrowUp,horizontal:vn.ArrowLeft}):return re.preventDefault(),re.stopPropagation(),h.actions.goToOption({focus:en.Previous});case vn.Home:case vn.PageUp:return re.preventDefault(),re.stopPropagation(),h.actions.goToOption({focus:en.First});case vn.End:case vn.PageDown:return re.preventDefault(),re.stopPropagation(),h.actions.goToOption({focus:en.Last});case vn.Escape:re.preventDefault(),re.stopPropagation(),ks.flushSync(()=>h.actions.closeListbox()),(fe=h.state.buttonElement)==null||fe.focus({preventScroll:!0});return;case vn.Tab:re.preventDefault(),re.stopPropagation(),ks.flushSync(()=>h.actions.closeListbox()),qA(h.state.buttonElement,re.shiftKey?ir.Previous:ir.Next);break;default:re.key.length===1&&(h.actions.search(re.key),G.setTimeout(()=>h.actions.clearSearch(),350));break}}),z=Yn(h,re=>{var fe;return(fe=re.buttonElement)==null?void 0:fe.id}),Q=Ks({open:v===In.Open}),K=qN(f?q():{},{id:r,ref:F,"aria-activedescendant":Yn(h,h.selectors.activeDescendantId),"aria-multiselectable":g.mode===zo.Multi?!0:void 0,"aria-labelledby":z,"aria-orientation":g.orientation,onKeyDown:U,role:"listbox",tabIndex:v===In.Open?0:void 0,style:{...u.style,...H,"--button-width":EA(_,y,!0).width},...k1(E)}),Z=Sn(),de=p.useMemo(()=>g.mode===zo.Multi?g:{...g,isSelected:P},[g,P]);return He.createElement(K1,{enabled:i?e.static||_:!1,ownerDocument:$},He.createElement(bm.Provider,{value:de},Z({ourProps:K,theirProps:u,slot:Q,defaultTag:zO,features:DO,visible:I,name:"Listbox.Options"})))}let UO="div";function WO(e,n){let s=p.useId(),{id:r=`headlessui-listbox-option-${s}`,disabled:a=!1,value:i,...c}=e,d=p.useContext(cS)===!0,u=Xc("Listbox.Option"),f=tv("Listbox.Option"),x=Yn(f,M=>f.selectors.isActive(M,r)),b=u.isSelected(i),g=p.useRef(null),h=TO(g),v=Xo({disabled:a,value:i,domRef:g,get textValue(){return h()}}),y=Dn(n,g,M=>{M?u.listRef.current.set(r,M):u.listRef.current.delete(r)}),j=Yn(f,M=>f.selectors.shouldScrollIntoView(M,r));Xt(()=>{if(j)return Es().requestAnimationFrame(()=>{var M,R;(R=(M=g.current)==null?void 0:M.scrollIntoView)==null||R.call(M,{block:"nearest"})})},[j,g]),Xt(()=>{if(!d)return f.actions.registerOption(r,v),()=>f.actions.unregisterOption(r)},[v,r,d]);let k=dt(M=>{if(a)return M.preventDefault();f.actions.selectOption(i)}),$=dt(()=>{if(a)return f.actions.goToOption({focus:en.Nothing});f.actions.goToOption({focus:en.Specific,id:r})}),S=r3(),N=dt(M=>S.update(M)),_=dt(M=>{S.wasMoved(M)&&(a||x&&f.state.activationTrigger===nf.Pointer||f.actions.goToOption({focus:en.Specific,id:r},nf.Pointer))}),E=dt(M=>{S.wasMoved(M)&&(a||x&&f.state.activationTrigger===nf.Pointer&&f.actions.goToOption({focus:en.Nothing}))}),O=Ks({active:x,focus:x,selected:b,disabled:a,selectedOption:b&&d}),A=d?{}:{id:r,ref:y,role:"option",tabIndex:a===!0?void 0:-1,"aria-disabled":a===!0?!0:void 0,"aria-selected":b,disabled:void 0,onClick:k,onFocus:$,onPointerEnter:N,onMouseEnter:N,onPointerMove:_,onMouseMove:_,onPointerLeave:E,onMouseLeave:E},I=Sn();return!b&&d?null:I({ourProps:A,theirProps:c,slot:O,defaultTag:UO,name:"Listbox.Option"})}let HO=p.Fragment;function BO(e,n){let{options:s,placeholder:r,...a}=e,i={ref:Dn(n)},c=Xc("ListboxSelectedOption"),d=Ks({}),u=c.value===void 0||c.value===null||c.mode===zo.Multi&&Array.isArray(c.value)&&c.value.length===0,f=Sn();return He.createElement(cS.Provider,{value:!0},f({ourProps:i,theirProps:{...a,children:He.createElement(He.Fragment,null,r&&u?r:s)},slot:d,defaultTag:HO,name:"ListboxSelectedOption"}))}let GO=pn(PO),dS=pn(IO),qO=jA,uS=pn(FO),fS=pn(WO),KO=pn(BO),VO=Object.assign(GO,{Button:dS,Label:qO,Options:uS,Option:fS,SelectedOption:KO});const YO={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function wm({open:e,onClose:n,title:s,description:r,footer:a,size:i="md",initialFocus:c,hideClose:d,className:u,children:f}){return t.jsxs($O,{open:e,onClose:n,initialFocus:c,className:"relative z-dialog",children:[t.jsx(EO,{className:"fixed inset-0 bg-overlay/70"}),t.jsx("div",{className:ae("fixed inset-0 flex justify-center p-4 md:p-8",i==="full"?"items-stretch":"items-start overflow-y-auto pt-[12vh]"),children:t.jsxs(rS,{className:ae("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",YO[i],u),children:[t.jsxs("header",{className:"flex items-start gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx(oS,{className:"text-lg font-semibold",children:s}),r&&t.jsx(s1,{className:"mt-1 text-body text-muted-foreground",children:r})]}),!d&&t.jsx(B,{size:"icon",variant:"ghost",onClick:n,"aria-label":"Close",children:t.jsx(Qo,{"aria-hidden":!0})})]}),f&&t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4 text-body",children:f}),a&&t.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t px-5 py-3",children:a})]})})]})}function nv({open:e,title:n,confirm:s,cancel:r="Cancel",tone:a="destructive",busy:i,onConfirm:c,onCancel:d,children:u}){const f=p.useRef(null);return t.jsx(wm,{open:e,onClose:i?()=>{}:d,title:n,size:"sm",hideClose:!0,initialFocus:f,footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{ref:f,size:"sm",onClick:d,disabled:i,children:r}),t.jsx(B,{size:"sm",variant:a,onClick:c,disabled:i,"aria-busy":i||void 0,children:s})]}),children:u})}const sv=p.createContext(null),QO=()=>p.useContext(sv);function rv(e){const n=p.useContext(sv);return{id:e.id??(n==null?void 0:n.id),"aria-describedby":e["aria-describedby"]??(n==null?void 0:n.describedBy),"aria-invalid":e["aria-invalid"]??((n==null?void 0:n.invalid)||void 0),"aria-required":e["aria-required"]??((n==null?void 0:n.required)&&!e.required||void 0)}}function jt({label:e,id:n,required:s,optional:r,note:a,hint:i,error:c,warning:d,aside:u,group:f,className:x,children:b}){const g=p.useId(),h=n??`${g}-control`,[v,y,j,k,$]=[`${g}-label`,`${g}-note`,`${g}-hint`,`${g}-error`,`${g}-warning`],S=[a&&y,i&&j,c&&k,d&&$].filter(Boolean).join(" ")||void 0,N=t.jsxs(t.Fragment,{children:[e,s&&t.jsx("span",{className:"text-destructive-text","aria-hidden":!0,children:" *"}),r&&t.jsx("span",{className:"font-normal normal-case text-muted-foreground",children:" (optional)"})]});return t.jsxs("div",{className:x,...f===!0?{role:"group","aria-labelledby":v,"aria-describedby":S}:{},children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[f?t.jsx("span",{id:v,className:"caps text-small font-semibold",children:N}):t.jsx("label",{id:v,htmlFor:h,className:"caps text-small font-semibold",children:N}),u]}),a&&t.jsx("p",{id:y,className:"-mt-1 mb-2 text-small text-muted-foreground",children:a}),t.jsx(sv.Provider,{value:f?null:{id:h,describedBy:S,invalid:!!c,required:!!s},children:b}),i&&t.jsx("p",{id:j,className:"mt-1.5 text-small text-muted-foreground",children:i}),c&&t.jsx("p",{id:k,className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{id:$,className:"mt-2 font-mono text-small text-warning-text",children:d})]})}const mS="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",hS="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",Pc="border border-input bg-background hover:border-foreground/60 focus-within:outline focus-within:outline-focus focus-within:outline-ring",Ie=p.forwardRef(({className:e,fieldSize:n="md",bare:s,...r},a)=>t.jsx("input",{ref:a,...r,...rv(r),className:ae(s?hS:ae(mS,n==="sm"?"h-control-sm":"h-control-md"),e)}));Ie.displayName="Input";const ln=p.forwardRef(({className:e,bare:n,...s},r)=>t.jsx("textarea",{ref:r,...s,...rv(s),className:ae(n?hS:ae(mS,"py-2.5"),e)}));ln.displayName="Textarea";const pS=e=>{const n=p.forwardRef(({label:s,note:r,className:a,disabled:i,...c},d)=>t.jsxs("label",{className:ae("flex items-start gap-2.5 text-body",i?"cursor-not-allowed opacity-45":"cursor-pointer",a),children:[t.jsx("input",{ref:d,type:e,disabled:i,...c,...rv(c),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block",children:s}),r&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:r})]})]}));return n.displayName=e==="checkbox"?"Checkbox":"Radio",n},JO=pS("checkbox");pS("radio");function xr({icon:e,active:n,className:s,children:r,...a}){return t.jsxs("button",{type:"button","aria-current":n?"page":void 0,...a,className:ae("flex min-h-11 items-center gap-2.5 p-3 text-left text-body -outline-offset-2 hover:bg-accent",n&&"!rounded-action bg-primary/[0.06] text-primary-text hover:bg-primary/10",s),children:[e&&t.jsx(e,{className:"size-4 shrink-0","aria-hidden":!0})," ",r]})}function At({value:e,onChange:n,options:s,label:r,id:a,className:i,disabled:c=!1,name:d,small:u=!1,placeholder:f,autoFocus:x}){const b=s.find(h=>h.value===e),g=QO();return t.jsxs(VO,{value:e,onChange:n,disabled:c,name:d,children:[t.jsxs(dS,{id:a??(g==null?void 0:g.id),autoFocus:x,"aria-label":r,"aria-describedby":g==null?void 0:g.describedBy,"aria-invalid":(g==null?void 0:g.invalid)||void 0,"data-value":e,className:ae("flex min-w-0 items-center justify-between gap-2 border border-input bg-background text-left font-mono hover:border-foreground/60 focus-visible:outline-offset-0 disabled:opacity-60 data-[open]:border-foreground",u?"h-control-sm px-2 text-small":"h-control-md px-3 text-body",i),children:[t.jsx("span",{className:ae("min-w-0 truncate",!b&&"text-muted-foreground"),children:(b==null?void 0:b.label)??f??""}),t.jsx(Tr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsx(uS,{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(h=>t.jsxs(fS,{value:h.value,disabled:h.disabled,title:h.title,"data-value":h.value,className:"group flex min-h-10 cursor-pointer items-center gap-2 px-3 py-2 data-[disabled]:cursor-not-allowed data-[focus]:bg-accent data-[disabled]:opacity-50 data-[selected]:text-foreground",children:[t.jsx(cl,{className:"invisible size-3.5 shrink-0 text-primary-text group-data-[selected]:visible","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 break-words",children:h.label}),h.tag&&t.jsx(je,{tone:"success",className:"ml-auto",children:h.tag})]},h.value))})]})}function Zc({value:e,onChange:n,options:s,label:r,name:a,size:i="md",className:c}){return t.jsx("div",{role:"radiogroup","aria-label":r,className:ae("inline-flex",c),children:s.map(d=>t.jsxs("label",{title:d.title,className:ae("caps -ml-px inline-flex items-center justify-center gap-1.5 border first:ml-0 has-[:focus-visible]:relative has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring [&_svg]:size-3.5",i==="sm"?"h-control-sm px-2.5 text-label":"h-control-md px-3 text-small",d.disabled?"cursor-not-allowed opacity-45":"cursor-pointer",e===d.value?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[t.jsx("input",{type:"radio",name:a,value:d.value,checked:e===d.value,disabled:d.disabled,onChange:()=>n(d.value),className:"sr-only"}),d.label]},d.value))})}const XO=["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 ZO({value:e,onChange:n,min:s,max:r,label:a,valueText:i,className:c,disabled:d=!1}){return t.jsx("input",{type:"range",min:s,max:r,step:1,value:e,disabled:d,"aria-label":a,"aria-valuetext":i,onChange:u=>n(Number(u.target.value)),className:ae(XO,"h-control-sm cursor-pointer disabled:cursor-not-allowed disabled:opacity-45",c)})}function e5({label:e,className:n}){return t.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[t.jsx(fT,{className:ae("size-4 animate-spin text-run-active",n),"aria-hidden":!0}),e&&t.jsx("span",{className:"sr-only",children:e})]})}function jm({checked:e,onChange:n,disabled:s,label:r,labelledBy:a,busy:i,className:c}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":r,"aria-labelledby":a,"aria-busy":i||void 0,disabled:s||i,onClick:()=>n(!e),className:ae("relative inline-flex h-5 w-9 shrink-0 items-center border transition-colors disabled:cursor-not-allowed disabled:opacity-45",e?"border-primary bg-primary/20":"border-border-strong bg-background hover:border-foreground/60",i&&"motion-safe:animate-pulse",c),children:t.jsx("span",{"aria-hidden":!0,className:ae("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 gS({tabs:e,value:n,onChange:s,label:r,id:a,className:i}){var f;const c=e.some(x=>x.id===n)?n:(f=e[0])==null?void 0:f.id,d=p.useRef(null),u=x=>{var h,v;const b=e.findIndex(y=>y.id===n),g=x.key==="ArrowRight"?(b+1)%e.length:x.key==="ArrowLeft"?(b-1+e.length)%e.length:x.key==="Home"?0:x.key==="End"?e.length-1:-1;g<0||g===b||(x.preventDefault(),s(e[g].id),(v=(h=d.current)==null?void 0:h.querySelectorAll('[role="tab"]')[g])==null||v.focus())};return t.jsx("div",{ref:d,role:"tablist","aria-label":r,onKeyDown:u,className:ae("flex border-b px-5 md:px-8",i),children:e.map(x=>t.jsx("button",{type:"button",role:"tab",id:a&&`${a}-tab-${x.id}`,"aria-controls":a&&`${a}-panel-${x.id}`,"aria-selected":n===x.id,tabIndex:c===x.id?0:-1,onClick:()=>s(x.id),className:ae("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",n===x.id?"border-primary text-primary-text":"border-transparent text-muted-foreground hover:text-foreground"),children:x.label},x.id))})}const t5=(e,n)=>({role:"tabpanel",id:`${e}-panel-${n}`,"aria-labelledby":`${e}-tab-${n}`});function n5({tip:e,children:n,className:s,align:r="start"}){const a=p.useId();return t.jsxs("span",{className:ae("group/tip relative inline-flex",s),children:[p.cloneElement(n,{"aria-describedby":a}),t.jsx("span",{role:"tooltip",id:a,className:ae("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 xS=p.createContext(null),s5={neutral:[jg,"text-muted-foreground"],success:[gN,"text-success-text"],warning:[Gs,"text-warning-text"],error:[Ji,"text-destructive-text"]},r5=5e3;function o5(){return p.useContext(xS)??a5}const a5=()=>{};function i5({toast:e,done:n}){const s=p.useCallback(()=>n(e.id),[n,e.id]),r=e.tone??"neutral",a=e.duration??(r==="error"?0:r5),[i,c]=p.useState(!1),[d,u]=p.useState(!1),f=i||d;p.useEffect(()=>{if(!a||f)return;const g=setTimeout(s,a);return()=>clearTimeout(g)},[a,f,s]);const[x,b]=s5[r];return t.jsxs("div",{role:r==="error"?"alert":"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>u(!0),onBlur:()=>u(!1),className:"pointer-events-auto flex w-full items-start gap-3 border border-border-strong bg-card p-3 text-body text-card-foreground shadow-float motion-safe:animate-toast-in",children:[t.jsx(x,{className:ae("mt-0.5 size-4 shrink-0",b),"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"font-semibold",children:e.title}),e.description&&t.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:e.description})]}),t.jsx("button",{type:"button",onClick:s,"aria-label":"Dismiss",className:"-m-1 shrink-0 p-1 text-muted-foreground hover:text-foreground",children:t.jsx(Qo,{className:"size-3.5","aria-hidden":!0})})]})}function l5({children:e}){const[n,s]=p.useState([]),r=p.useRef(0),a=p.useCallback(c=>s(d=>[...d,{...c,id:r.current++}].slice(-3)),[]),i=p.useCallback(c=>s(d=>d.filter(u=>u.id!==c)),[]);return t.jsxs(xS.Provider,{value:a,children:[e,t.jsx("div",{role:"region","aria-label":"Notifications","aria-live":"polite",className:"pointer-events-none fixed inset-x-4 bottom-4 z-toast flex flex-col gap-2 sm:left-auto sm:w-[22rem]",children:n.map(c=>t.jsx(i5,{toast:c,done:i},c.id))})]})}/*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */const{entries:vS,setPrototypeOf:Dj,isFrozen:c5,getPrototypeOf:d5,getOwnPropertyDescriptor:u5}=Object;let{freeze:ts,seal:Vs,create:yS}=Object,{apply:Lg,construct:Ig}=typeof Reflect<"u"&&Reflect;ts||(ts=function(n){return n});Vs||(Vs=function(n){return n});Lg||(Lg=function(n,s,r){return n.apply(s,r)});Ig||(Ig=function(n,s){return new n(...s)});const Au=Ss(Array.prototype.forEach),Fj=Ss(Array.prototype.pop),nc=Ss(Array.prototype.push),sf=Ss(String.prototype.toLowerCase),Vp=Ss(String.prototype.toString),Uj=Ss(String.prototype.match),sc=Ss(String.prototype.replace),f5=Ss(String.prototype.indexOf),m5=Ss(String.prototype.trim),or=Ss(Object.prototype.hasOwnProperty),Vn=Ss(RegExp.prototype.test),rc=h5(TypeError);function Ss(e){return function(n){for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];return Lg(e,n,r)}}function h5(e){return function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return Ig(e,s)}}function yt(e,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:sf;Dj&&Dj(e,null);let r=n.length;for(;r--;){let a=n[r];if(typeof a=="string"){const i=s(a);i!==a&&(c5(n)||(n[r]=i),a=i)}e[a]=!0}return e}function p5(e){for(let n=0;n<e.length;n++)or(e,n)||(e[n]=null);return e}function ja(e){const n=yS(null);for(const[s,r]of vS(e))or(e,s)&&(Array.isArray(r)?n[s]=p5(r):r&&typeof r=="object"&&r.constructor===Object?n[s]=ja(r):n[s]=r);return n}function oc(e,n){for(;e!==null;){const r=u5(e,n);if(r){if(r.get)return Ss(r.get);if(typeof r.value=="function")return Ss(r.value)}e=d5(e)}function s(){return null}return s}const Wj=ts(["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"]),Yp=ts(["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"]),Qp=ts(["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"]),g5=ts(["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"]),Jp=ts(["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"]),x5=ts(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Hj=ts(["#text"]),Bj=ts(["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"]),Xp=ts(["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"]),Gj=ts(["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"]),Ou=ts(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),v5=Vs(/\{\{[\w\W]*|[\w\W]*\}\}/gm),y5=Vs(/<%[\w\W]*|[\w\W]*%>/gm),b5=Vs(/\$\{[\w\W]*}/gm),w5=Vs(/^data-[\-\w.\u00B7-\uFFFF]+$/),j5=Vs(/^aria-[\-\w]+$/),bS=Vs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),k5=Vs(/^(?:\w+script|data):/i),N5=Vs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),wS=Vs(/^html$/i),S5=Vs(/^[a-z][.\w]*(-[.\w]+)+$/i);var qj=Object.freeze({__proto__:null,ARIA_ATTR:j5,ATTR_WHITESPACE:N5,CUSTOM_ELEMENT:S5,DATA_ATTR:w5,DOCTYPE_NAME:wS,ERB_EXPR:y5,IS_ALLOWED_URI:bS,IS_SCRIPT_OR_DATA:k5,MUSTACHE_EXPR:v5,TMPLIT_EXPR:b5});const ac={element:1,text:3,progressingInstruction:7,comment:8,document:9},C5=function(){return typeof window>"u"?null:window},E5=function(n,s){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let r=null;const a="data-tt-policy-suffix";s&&s.hasAttribute(a)&&(r=s.getAttribute(a));const i="dompurify"+(r?"#"+r:"");try{return n.createPolicy(i,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Kj=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function jS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:C5();const n=Fe=>jS(Fe);if(n.version="3.2.3",n.removed=[],!e||!e.document||e.document.nodeType!==ac.document)return n.isSupported=!1,n;let{document:s}=e;const r=s,a=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:c,Node:d,Element:u,NodeFilter:f,NamedNodeMap:x=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:b,DOMParser:g,trustedTypes:h}=e,v=u.prototype,y=oc(v,"cloneNode"),j=oc(v,"remove"),k=oc(v,"nextSibling"),$=oc(v,"childNodes"),S=oc(v,"parentNode");if(typeof c=="function"){const Fe=s.createElement("template");Fe.content&&Fe.content.ownerDocument&&(s=Fe.content.ownerDocument)}let N,_="";const{implementation:E,createNodeIterator:O,createDocumentFragment:A,getElementsByTagName:I}=s,{importNode:M}=r;let R=Kj();n.isSupported=typeof vS=="function"&&typeof S=="function"&&E&&E.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:P,ERB_EXPR:D,TMPLIT_EXPR:W,DATA_ATTR:Y,ARIA_ATTR:H,IS_SCRIPT_OR_DATA:q,ATTR_WHITESPACE:F,CUSTOM_ELEMENT:G}=qj;let{IS_ALLOWED_URI:U}=qj,z=null;const Q=yt({},[...Wj,...Yp,...Qp,...Jp,...Hj]);let K=null;const Z=yt({},[...Bj,...Xp,...Gj,...Ou]);let de=Object.seal(yS(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}})),re=null,fe=null,ve=!0,Ee=!0,ue=!1,pe=!0,me=!1,ke=!0,$e=!1,J=!1,Le=!1,qe=!1,rt=!1,vt=!1,st=!0,Se=!1;const Be="user-content-";let he=!0,Ve=!1,ct={},Me=null;const ot=yt({},["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 oe=null;const xe=yt({},["audio","video","img","source","image","track"]);let Ae=null;const De=yt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ut="http://www.w3.org/1998/Math/MathML",ee="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let Qe=Re,Ze=!1,at=null;const Xe=yt({},[ut,ee,Re],Vp);let pt=yt({},["mi","mo","mn","ms","mtext"]),et=yt({},["annotation-xml"]);const kt=yt({},["title","style","font","a","script"]);let Ct=null;const Tn=["application/xhtml+xml","text/html"],dn="text/html";let Nt=null,Rn=null;const hs=s.createElement("form"),Ys=function(ne){return ne instanceof RegExp||ne instanceof Function},Cn=function(){let ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Rn&&Rn===ne)){if((!ne||typeof ne!="object")&&(ne={}),ne=ja(ne),Ct=Tn.indexOf(ne.PARSER_MEDIA_TYPE)===-1?dn:ne.PARSER_MEDIA_TYPE,Nt=Ct==="application/xhtml+xml"?Vp:sf,z=or(ne,"ALLOWED_TAGS")?yt({},ne.ALLOWED_TAGS,Nt):Q,K=or(ne,"ALLOWED_ATTR")?yt({},ne.ALLOWED_ATTR,Nt):Z,at=or(ne,"ALLOWED_NAMESPACES")?yt({},ne.ALLOWED_NAMESPACES,Vp):Xe,Ae=or(ne,"ADD_URI_SAFE_ATTR")?yt(ja(De),ne.ADD_URI_SAFE_ATTR,Nt):De,oe=or(ne,"ADD_DATA_URI_TAGS")?yt(ja(xe),ne.ADD_DATA_URI_TAGS,Nt):xe,Me=or(ne,"FORBID_CONTENTS")?yt({},ne.FORBID_CONTENTS,Nt):ot,re=or(ne,"FORBID_TAGS")?yt({},ne.FORBID_TAGS,Nt):{},fe=or(ne,"FORBID_ATTR")?yt({},ne.FORBID_ATTR,Nt):{},ct=or(ne,"USE_PROFILES")?ne.USE_PROFILES:!1,ve=ne.ALLOW_ARIA_ATTR!==!1,Ee=ne.ALLOW_DATA_ATTR!==!1,ue=ne.ALLOW_UNKNOWN_PROTOCOLS||!1,pe=ne.ALLOW_SELF_CLOSE_IN_ATTR!==!1,me=ne.SAFE_FOR_TEMPLATES||!1,ke=ne.SAFE_FOR_XML!==!1,$e=ne.WHOLE_DOCUMENT||!1,qe=ne.RETURN_DOM||!1,rt=ne.RETURN_DOM_FRAGMENT||!1,vt=ne.RETURN_TRUSTED_TYPE||!1,Le=ne.FORCE_BODY||!1,st=ne.SANITIZE_DOM!==!1,Se=ne.SANITIZE_NAMED_PROPS||!1,he=ne.KEEP_CONTENT!==!1,Ve=ne.IN_PLACE||!1,U=ne.ALLOWED_URI_REGEXP||bS,Qe=ne.NAMESPACE||Re,pt=ne.MATHML_TEXT_INTEGRATION_POINTS||pt,et=ne.HTML_INTEGRATION_POINTS||et,de=ne.CUSTOM_ELEMENT_HANDLING||{},ne.CUSTOM_ELEMENT_HANDLING&&Ys(ne.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(de.tagNameCheck=ne.CUSTOM_ELEMENT_HANDLING.tagNameCheck),ne.CUSTOM_ELEMENT_HANDLING&&Ys(ne.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(de.attributeNameCheck=ne.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),ne.CUSTOM_ELEMENT_HANDLING&&typeof ne.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=ne.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),me&&(Ee=!1),rt&&(qe=!0),ct&&(z=yt({},Hj),K=[],ct.html===!0&&(yt(z,Wj),yt(K,Bj)),ct.svg===!0&&(yt(z,Yp),yt(K,Xp),yt(K,Ou)),ct.svgFilters===!0&&(yt(z,Qp),yt(K,Xp),yt(K,Ou)),ct.mathMl===!0&&(yt(z,Jp),yt(K,Gj),yt(K,Ou))),ne.ADD_TAGS&&(z===Q&&(z=ja(z)),yt(z,ne.ADD_TAGS,Nt)),ne.ADD_ATTR&&(K===Z&&(K=ja(K)),yt(K,ne.ADD_ATTR,Nt)),ne.ADD_URI_SAFE_ATTR&&yt(Ae,ne.ADD_URI_SAFE_ATTR,Nt),ne.FORBID_CONTENTS&&(Me===ot&&(Me=ja(Me)),yt(Me,ne.FORBID_CONTENTS,Nt)),he&&(z["#text"]=!0),$e&&yt(z,["html","head","body"]),z.table&&(yt(z,["tbody"]),delete re.tbody),ne.TRUSTED_TYPES_POLICY){if(typeof ne.TRUSTED_TYPES_POLICY.createHTML!="function")throw rc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof ne.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw rc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=ne.TRUSTED_TYPES_POLICY,_=N.createHTML("")}else N===void 0&&(N=E5(h,a)),N!==null&&typeof _=="string"&&(_=N.createHTML(""));ts&&ts(ne),Rn=ne}},Un=yt({},[...Yp,...Qp,...g5]),ps=yt({},[...Jp,...x5]),gs=function(ne){let ye=S(ne);(!ye||!ye.tagName)&&(ye={namespaceURI:Qe,tagName:"template"});const We=sf(ne.tagName),St=sf(ye.tagName);return at[ne.namespaceURI]?ne.namespaceURI===ee?ye.namespaceURI===Re?We==="svg":ye.namespaceURI===ut?We==="svg"&&(St==="annotation-xml"||pt[St]):!!Un[We]:ne.namespaceURI===ut?ye.namespaceURI===Re?We==="math":ye.namespaceURI===ee?We==="math"&&et[St]:!!ps[We]:ne.namespaceURI===Re?ye.namespaceURI===ee&&!et[St]||ye.namespaceURI===ut&&!pt[St]?!1:!ps[We]&&(kt[We]||!Un[We]):!!(Ct==="application/xhtml+xml"&&at[ne.namespaceURI]):!1},un=function(ne){nc(n.removed,{element:ne});try{S(ne).removeChild(ne)}catch{j(ne)}},Wn=function(ne,ye){try{nc(n.removed,{attribute:ye.getAttributeNode(ne),from:ye})}catch{nc(n.removed,{attribute:null,from:ye})}if(ye.removeAttribute(ne),ne==="is")if(qe||rt)try{un(ye)}catch{}else try{ye.setAttribute(ne,"")}catch{}},$s=function(ne){let ye=null,We=null;if(Le)ne="<remove></remove>"+ne;else{const it=Uj(ne,/^[\r\n\t ]+/);We=it&&it[0]}Ct==="application/xhtml+xml"&&Qe===Re&&(ne='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+ne+"</body></html>");const St=N?N.createHTML(ne):ne;if(Qe===Re)try{ye=new g().parseFromString(St,Ct)}catch{}if(!ye||!ye.documentElement){ye=E.createDocument(Qe,"template",null);try{ye.documentElement.innerHTML=Ze?_:St}catch{}}const Lt=ye.body||ye.documentElement;return ne&&We&&Lt.insertBefore(s.createTextNode(We),Lt.childNodes[0]||null),Qe===Re?I.call(ye,$e?"html":"body")[0]:$e?ye.documentElement:Lt},Hn=function(ne){return O.call(ne.ownerDocument||ne,ne,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},_s=function(ne){return ne instanceof b&&(typeof ne.nodeName!="string"||typeof ne.textContent!="string"||typeof ne.removeChild!="function"||!(ne.attributes instanceof x)||typeof ne.removeAttribute!="function"||typeof ne.setAttribute!="function"||typeof ne.namespaceURI!="string"||typeof ne.insertBefore!="function"||typeof ne.hasChildNodes!="function")},Ts=function(ne){return typeof d=="function"&&ne instanceof d};function An(Fe,ne,ye){Au(Fe,We=>{We.call(n,ne,ye,Rn)})}const te=function(ne){let ye=null;if(An(R.beforeSanitizeElements,ne,null),_s(ne))return un(ne),!0;const We=Nt(ne.nodeName);if(An(R.uponSanitizeElement,ne,{tagName:We,allowedTags:z}),ne.hasChildNodes()&&!Ts(ne.firstElementChild)&&Vn(/<[/\w]/g,ne.innerHTML)&&Vn(/<[/\w]/g,ne.textContent)||ne.nodeType===ac.progressingInstruction||ke&&ne.nodeType===ac.comment&&Vn(/<[/\w]/g,ne.data))return un(ne),!0;if(!z[We]||re[We]){if(!re[We]&&ft(We)&&(de.tagNameCheck instanceof RegExp&&Vn(de.tagNameCheck,We)||de.tagNameCheck instanceof Function&&de.tagNameCheck(We)))return!1;if(he&&!Me[We]){const St=S(ne)||ne.parentNode,Lt=$(ne)||ne.childNodes;if(Lt&&St){const it=Lt.length;for(let yn=it-1;yn>=0;--yn){const En=y(Lt[yn],!0);En.__removalCount=(ne.__removalCount||0)+1,St.insertBefore(En,k(ne))}}}return un(ne),!0}return ne instanceof u&&!gs(ne)||(We==="noscript"||We==="noembed"||We==="noframes")&&Vn(/<\/no(script|embed|frames)/i,ne.innerHTML)?(un(ne),!0):(me&&ne.nodeType===ac.text&&(ye=ne.textContent,Au([P,D,W],St=>{ye=sc(ye,St," ")}),ne.textContent!==ye&&(nc(n.removed,{element:ne.cloneNode()}),ne.textContent=ye)),An(R.afterSanitizeElements,ne,null),!1)},Oe=function(ne,ye,We){if(st&&(ye==="id"||ye==="name")&&(We in s||We in hs))return!1;if(!(Ee&&!fe[ye]&&Vn(Y,ye))){if(!(ve&&Vn(H,ye))){if(!K[ye]||fe[ye]){if(!(ft(ne)&&(de.tagNameCheck instanceof RegExp&&Vn(de.tagNameCheck,ne)||de.tagNameCheck instanceof Function&&de.tagNameCheck(ne))&&(de.attributeNameCheck instanceof RegExp&&Vn(de.attributeNameCheck,ye)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(ye))||ye==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&Vn(de.tagNameCheck,We)||de.tagNameCheck instanceof Function&&de.tagNameCheck(We))))return!1}else if(!Ae[ye]){if(!Vn(U,sc(We,F,""))){if(!((ye==="src"||ye==="xlink:href"||ye==="href")&&ne!=="script"&&f5(We,"data:")===0&&oe[ne])){if(!(ue&&!Vn(q,sc(We,F,"")))){if(We)return!1}}}}}}return!0},ft=function(ne){return ne!=="annotation-xml"&&Uj(ne,G)},Ot=function(ne){An(R.beforeSanitizeAttributes,ne,null);const{attributes:ye}=ne;if(!ye||_s(ne))return;const We={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K,forceKeepAttr:void 0};let St=ye.length;for(;St--;){const Lt=ye[St],{name:it,namespaceURI:yn,value:En}=Lt,ur=Nt(it);let Ut=it==="value"?En:m5(En);if(We.attrName=ur,We.attrValue=Ut,We.keepAttr=!0,We.forceKeepAttr=void 0,An(R.uponSanitizeAttribute,ne,We),Ut=We.attrValue,Se&&(ur==="id"||ur==="name")&&(Wn(it,ne),Ut=Be+Ut),ke&&Vn(/((--!?|])>)|<\/(style|title)/i,Ut)){Wn(it,ne);continue}if(We.forceKeepAttr||(Wn(it,ne),!We.keepAttr))continue;if(!pe&&Vn(/\/>/i,Ut)){Wn(it,ne);continue}me&&Au([P,D,W],ao=>{Ut=sc(Ut,ao," ")});const Za=Nt(ne.nodeName);if(Oe(Za,ur,Ut)){if(N&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!yn)switch(h.getAttributeType(Za,ur)){case"TrustedHTML":{Ut=N.createHTML(Ut);break}case"TrustedScriptURL":{Ut=N.createScriptURL(Ut);break}}try{yn?ne.setAttributeNS(yn,it,Ut):ne.setAttribute(it,Ut),_s(ne)?un(ne):Fj(n.removed)}catch{}}}An(R.afterSanitizeAttributes,ne,null)},Vt=function Fe(ne){let ye=null;const We=Hn(ne);for(An(R.beforeSanitizeShadowDOM,ne,null);ye=We.nextNode();)An(R.uponSanitizeShadowNode,ye,null),te(ye),Ot(ye),ye.content instanceof i&&Fe(ye.content);An(R.afterSanitizeShadowDOM,ne,null)};return n.sanitize=function(Fe){let ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ye=null,We=null,St=null,Lt=null;if(Ze=!Fe,Ze&&(Fe="<!-->"),typeof Fe!="string"&&!Ts(Fe))if(typeof Fe.toString=="function"){if(Fe=Fe.toString(),typeof Fe!="string")throw rc("dirty is not a string, aborting")}else throw rc("toString is not a function");if(!n.isSupported)return Fe;if(J||Cn(ne),n.removed=[],typeof Fe=="string"&&(Ve=!1),Ve){if(Fe.nodeName){const En=Nt(Fe.nodeName);if(!z[En]||re[En])throw rc("root node is forbidden and cannot be sanitized in-place")}}else if(Fe instanceof d)ye=$s("<!---->"),We=ye.ownerDocument.importNode(Fe,!0),We.nodeType===ac.element&&We.nodeName==="BODY"||We.nodeName==="HTML"?ye=We:ye.appendChild(We);else{if(!qe&&!me&&!$e&&Fe.indexOf("<")===-1)return N&&vt?N.createHTML(Fe):Fe;if(ye=$s(Fe),!ye)return qe?null:vt?_:""}ye&&Le&&un(ye.firstChild);const it=Hn(Ve?Fe:ye);for(;St=it.nextNode();)te(St),Ot(St),St.content instanceof i&&Vt(St.content);if(Ve)return Fe;if(qe){if(rt)for(Lt=A.call(ye.ownerDocument);ye.firstChild;)Lt.appendChild(ye.firstChild);else Lt=ye;return(K.shadowroot||K.shadowrootmode)&&(Lt=M.call(r,Lt,!0)),Lt}let yn=$e?ye.outerHTML:ye.innerHTML;return $e&&z["!doctype"]&&ye.ownerDocument&&ye.ownerDocument.doctype&&ye.ownerDocument.doctype.name&&Vn(wS,ye.ownerDocument.doctype.name)&&(yn="<!DOCTYPE "+ye.ownerDocument.doctype.name+`>
|
|
513
|
+
`+yn),me&&Au([P,D,W],En=>{yn=sc(yn,En," ")}),N&&vt?N.createHTML(yn):yn},n.setConfig=function(){let Fe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Cn(Fe),J=!0},n.clearConfig=function(){Rn=null,J=!1},n.isValidAttribute=function(Fe,ne,ye){Rn||Cn({});const We=Nt(Fe),St=Nt(ne);return Oe(We,St,ye)},n.addHook=function(Fe,ne){typeof ne=="function"&&nc(R[Fe],ne)},n.removeHook=function(Fe){return Fj(R[Fe])},n.removeHooks=function(Fe){R[Fe]=[]},n.removeAllHooks=function(){R=Kj()},n}var rf=jS();function ov(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Ya=ov();function kS(e){Ya=e}const kc={exec:()=>null};function It(e,n=""){let s=typeof e=="string"?e:e.source;const r={replace:(a,i)=>{let c=typeof i=="string"?i:i.source;return c=c.replace(Xn.caret,"$1"),s=s.replace(a,c),r},getRegex:()=>new RegExp(s,n)};return r}const Xn={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")},$5=/^(?:[ \t]*(?:\n|$))+/,_5=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,T5=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ed=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,R5=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,NS=/(?:[*+-]|\d{1,9}[.)])/,SS=It(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,NS).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(),av=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,A5=/^[^\n]+/,iv=/(?!\s*\])(?:\\.|[^\[\]\\])+/,O5=It(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",iv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),M5=It(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,NS).getRegex(),km="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",lv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,P5=It("^ {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",lv).replace("tag",km).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),CS=It(av).replace("hr",ed).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",km).getRegex(),L5=It(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",CS).getRegex(),cv={blockquote:L5,code:_5,def:O5,fences:T5,heading:R5,hr:ed,html:P5,lheading:SS,list:M5,newline:$5,paragraph:CS,table:kc,text:A5},Vj=It("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ed).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",km).getRegex(),I5={...cv,table:Vj,paragraph:It(av).replace("hr",ed).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Vj).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",km).getRegex()},z5={...cv,html:It(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",lv).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:kc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:It(av).replace("hr",ed).replace("heading",` *#{1,6} *[^
|
|
514
|
+
]`).replace("lheading",SS).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},D5=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,F5=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ES=/^( {2,}|\\)\n(?!\s*$)/,U5=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Nm=/[\p{P}\p{S}]/u,dv=/[\s\p{P}\p{S}]/u,$S=/[^\s\p{P}\p{S}]/u,W5=It(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,dv).getRegex(),_S=/(?!~)[\p{P}\p{S}]/u,H5=/(?!~)[\s\p{P}\p{S}]/u,B5=/(?:[^\s\p{P}\p{S}]|~)/u,G5=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,TS=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,q5=It(TS,"u").replace(/punct/g,Nm).getRegex(),K5=It(TS,"u").replace(/punct/g,_S).getRegex(),RS="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",V5=It(RS,"gu").replace(/notPunctSpace/g,$S).replace(/punctSpace/g,dv).replace(/punct/g,Nm).getRegex(),Y5=It(RS,"gu").replace(/notPunctSpace/g,B5).replace(/punctSpace/g,H5).replace(/punct/g,_S).getRegex(),Q5=It("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,$S).replace(/punctSpace/g,dv).replace(/punct/g,Nm).getRegex(),J5=It(/\\(punct)/,"gu").replace(/punct/g,Nm).getRegex(),X5=It(/^<(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(),Z5=It(lv).replace("(?:-->|$)","-->").getRegex(),eM=It("^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",Z5).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),wf=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,tM=It(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",wf).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),AS=It(/^!?\[(label)\]\[(ref)\]/).replace("label",wf).replace("ref",iv).getRegex(),OS=It(/^!?\[(ref)\](?:\[\])?/).replace("ref",iv).getRegex(),nM=It("reflink|nolink(?!\\()","g").replace("reflink",AS).replace("nolink",OS).getRegex(),uv={_backpedal:kc,anyPunctuation:J5,autolink:X5,blockSkip:G5,br:ES,code:F5,del:kc,emStrongLDelim:q5,emStrongRDelimAst:V5,emStrongRDelimUnd:Q5,escape:D5,link:tM,nolink:OS,punctuation:W5,reflink:AS,reflinkSearch:nM,tag:eM,text:U5,url:kc},sM={...uv,link:It(/^!?\[(label)\]\((.*?)\)/).replace("label",wf).getRegex(),reflink:It(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",wf).getRegex()},zg={...uv,emStrongRDelimAst:Y5,emStrongLDelim:K5,url:It(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},rM={...zg,br:It(ES).replace("{2,}","*").getRegex(),text:It(zg.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Mu={normal:cv,gfm:I5,pedantic:z5},ic={normal:uv,gfm:zg,breaks:rM,pedantic:sM},oM={"&":"&","<":"<",">":">",'"':""","'":"'"},Yj=e=>oM[e];function wr(e,n){if(n){if(Xn.escapeTest.test(e))return e.replace(Xn.escapeReplace,Yj)}else if(Xn.escapeTestNoEncode.test(e))return e.replace(Xn.escapeReplaceNoEncode,Yj);return e}function Qj(e){try{e=encodeURI(e).replace(Xn.percentDecode,"%")}catch{return null}return e}function Jj(e,n){var i;const s=e.replace(Xn.findPipe,(c,d,u)=>{let f=!1,x=d;for(;--x>=0&&u[x]==="\\";)f=!f;return f?"|":" |"}),r=s.split(Xn.splitPipe);let a=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.trim())&&r.pop(),n)if(r.length>n)r.splice(n);else for(;r.length<n;)r.push("");for(;a<r.length;a++)r[a]=r[a].trim().replace(Xn.slashPipe,"|");return r}function lc(e,n,s){const r=e.length;if(r===0)return"";let a=0;for(;a<r&&e.charAt(r-a-1)===n;)a++;return e.slice(0,r-a)}function aM(e,n){if(e.indexOf(n[1])===-1)return-1;let s=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===n[0])s++;else if(e[r]===n[1]&&(s--,s<0))return r;return-1}function Xj(e,n,s,r,a){const i=n.href,c=n.title||null,d=e[1].replace(a.other.outputLinkReplace,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const u={type:"link",raw:s,href:i,title:c,text:d,tokens:r.inlineTokens(d)};return r.state.inLink=!1,u}return{type:"image",raw:s,href:i,title:c,text:d}}function iM(e,n,s){const r=e.match(s.other.indentCodeCompensation);if(r===null)return n;const a=r[1];return n.split(`
|
|
515
|
+
`).map(i=>{const c=i.match(s.other.beginningSpace);if(c===null)return i;const[d]=c;return d.length>=a.length?i.slice(a.length):i}).join(`
|
|
516
|
+
`)}class jf{constructor(n){Rt(this,"options");Rt(this,"rules");Rt(this,"lexer");this.options=n||Ya}space(n){const s=this.rules.block.newline.exec(n);if(s&&s[0].length>0)return{type:"space",raw:s[0]}}code(n){const s=this.rules.block.code.exec(n);if(s){const r=s[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:s[0],codeBlockStyle:"indented",text:this.options.pedantic?r:lc(r,`
|
|
517
|
+
`)}}}fences(n){const s=this.rules.block.fences.exec(n);if(s){const r=s[0],a=iM(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(n){const s=this.rules.block.heading.exec(n);if(s){let r=s[2].trim();if(this.rules.other.endingHash.test(r)){const a=lc(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(n){const s=this.rules.block.hr.exec(n);if(s)return{type:"hr",raw:lc(s[0],`
|
|
518
|
+
`)}}blockquote(n){const s=this.rules.block.blockquote.exec(n);if(s){let r=lc(s[0],`
|
|
519
|
+
`).split(`
|
|
520
|
+
`),a="",i="";const c=[];for(;r.length>0;){let d=!1;const u=[];let f;for(f=0;f<r.length;f++)if(this.rules.other.blockquoteStart.test(r[f]))u.push(r[f]),d=!0;else if(!d)u.push(r[f]);else break;r=r.slice(f);const x=u.join(`
|
|
521
|
+
`),b=x.replace(this.rules.other.blockquoteSetextReplace,`
|
|
522
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");a=a?`${a}
|
|
523
|
+
${x}`:x,i=i?`${i}
|
|
524
|
+
${b}`:b;const g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(b,c,!0),this.lexer.state.top=g,r.length===0)break;const h=c.at(-1);if((h==null?void 0:h.type)==="code")break;if((h==null?void 0:h.type)==="blockquote"){const v=h,y=v.raw+`
|
|
525
|
+
`+r.join(`
|
|
526
|
+
`),j=this.blockquote(y);c[c.length-1]=j,a=a.substring(0,a.length-v.raw.length)+j.raw,i=i.substring(0,i.length-v.text.length)+j.text;break}else if((h==null?void 0:h.type)==="list"){const v=h,y=v.raw+`
|
|
527
|
+
`+r.join(`
|
|
528
|
+
`),j=this.list(y);c[c.length-1]=j,a=a.substring(0,a.length-h.raw.length)+j.raw,i=i.substring(0,i.length-v.raw.length)+j.raw,r=y.substring(c.at(-1).raw.length).split(`
|
|
529
|
+
`);continue}}return{type:"blockquote",raw:a,tokens:c,text:i}}}list(n){let s=this.rules.block.list.exec(n);if(s){let r=s[1].trim();const a=r.length>1,i={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 d=!1;for(;n;){let f=!1,x="",b="";if(!(s=c.exec(n))||this.rules.block.hr.test(n))break;x=s[0],n=n.substring(x.length);let g=s[2].split(`
|
|
530
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,$=>" ".repeat(3*$.length)),h=n.split(`
|
|
531
|
+
`,1)[0],v=!g.trim(),y=0;if(this.options.pedantic?(y=2,b=g.trimStart()):v?y=s[1].length+1:(y=s[2].search(this.rules.other.nonSpaceChar),y=y>4?1:y,b=g.slice(y),y+=s[1].length),v&&this.rules.other.blankLine.test(h)&&(x+=h+`
|
|
532
|
+
`,n=n.substring(h.length+1),f=!0),!f){const $=this.rules.other.nextBulletRegex(y),S=this.rules.other.hrRegex(y),N=this.rules.other.fencesBeginRegex(y),_=this.rules.other.headingBeginRegex(y),E=this.rules.other.htmlBeginRegex(y);for(;n;){const O=n.split(`
|
|
533
|
+
`,1)[0];let A;if(h=O,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),A=h):A=h.replace(this.rules.other.tabCharGlobal," "),N.test(h)||_.test(h)||E.test(h)||$.test(h)||S.test(h))break;if(A.search(this.rules.other.nonSpaceChar)>=y||!h.trim())b+=`
|
|
534
|
+
`+A.slice(y);else{if(v||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(g)||_.test(g)||S.test(g))break;b+=`
|
|
535
|
+
`+h}!v&&!h.trim()&&(v=!0),x+=O+`
|
|
536
|
+
`,n=n.substring(O.length+1),g=A.slice(y)}}i.loose||(d?i.loose=!0:this.rules.other.doubleBlankLine.test(x)&&(d=!0));let j=null,k;this.options.gfm&&(j=this.rules.other.listIsTask.exec(b),j&&(k=j[0]!=="[ ] ",b=b.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:x,task:!!j,checked:k,loose:!1,text:b,tokens:[]}),i.raw+=x}const u=i.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let f=0;f<i.items.length;f++)if(this.lexer.state.top=!1,i.items[f].tokens=this.lexer.blockTokens(i.items[f].text,[]),!i.loose){const x=i.items[f].tokens.filter(g=>g.type==="space"),b=x.length>0&&x.some(g=>this.rules.other.anyLine.test(g.raw));i.loose=b}if(i.loose)for(let f=0;f<i.items.length;f++)i.items[f].loose=!0;return i}}html(n){const s=this.rules.block.html.exec(n);if(s)return{type:"html",block:!0,raw:s[0],pre:s[1]==="pre"||s[1]==="script"||s[1]==="style",text:s[0]}}def(n){const s=this.rules.block.def.exec(n);if(s){const r=s[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),a=s[2]?s[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=s[3]?s[3].substring(1,s[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):s[3];return{type:"def",tag:r,raw:s[0],href:a,title:i}}}table(n){var d;const s=this.rules.block.table.exec(n);if(!s||!this.rules.other.tableDelimiter.test(s[2]))return;const r=Jj(s[1]),a=s[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(d=s[3])!=null&&d.trim()?s[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
537
|
+
`):[],c={type:"table",raw:s[0],header:[],align:[],rows:[]};if(r.length===a.length){for(const u of a)this.rules.other.tableAlignRight.test(u)?c.align.push("right"):this.rules.other.tableAlignCenter.test(u)?c.align.push("center"):this.rules.other.tableAlignLeft.test(u)?c.align.push("left"):c.align.push(null);for(let u=0;u<r.length;u++)c.header.push({text:r[u],tokens:this.lexer.inline(r[u]),header:!0,align:c.align[u]});for(const u of i)c.rows.push(Jj(u,c.header.length).map((f,x)=>({text:f,tokens:this.lexer.inline(f),header:!1,align:c.align[x]})));return c}}lheading(n){const s=this.rules.block.lheading.exec(n);if(s)return{type:"heading",raw:s[0],depth:s[2].charAt(0)==="="?1:2,text:s[1],tokens:this.lexer.inline(s[1])}}paragraph(n){const s=this.rules.block.paragraph.exec(n);if(s){const r=s[1].charAt(s[1].length-1)===`
|
|
538
|
+
`?s[1].slice(0,-1):s[1];return{type:"paragraph",raw:s[0],text:r,tokens:this.lexer.inline(r)}}}text(n){const s=this.rules.block.text.exec(n);if(s)return{type:"text",raw:s[0],text:s[0],tokens:this.lexer.inline(s[0])}}escape(n){const s=this.rules.inline.escape.exec(n);if(s)return{type:"escape",raw:s[0],text:s[1]}}tag(n){const s=this.rules.inline.tag.exec(n);if(s)return!this.lexer.state.inLink&&this.rules.other.startATag.test(s[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(s[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(s[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(s[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:s[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:s[0]}}link(n){const s=this.rules.inline.link.exec(n);if(s){const r=s[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;const c=lc(r.slice(0,-1),"\\");if((r.length-c.length)%2===0)return}else{const c=aM(s[2],"()");if(c>-1){const u=(s[0].indexOf("!")===0?5:4)+s[1].length+c;s[2]=s[2].substring(0,c),s[0]=s[0].substring(0,u).trim(),s[3]=""}}let a=s[2],i="";if(this.options.pedantic){const c=this.rules.other.pedanticHrefTitle.exec(a);c&&(a=c[1],i=c[3])}else i=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)),Xj(s,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},s[0],this.lexer,this.rules)}}reflink(n,s){let r;if((r=this.rules.inline.reflink.exec(n))||(r=this.rules.inline.nolink.exec(n))){const a=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=s[a.toLowerCase()];if(!i){const c=r[0].charAt(0);return{type:"text",raw:c,text:c}}return Xj(r,i,r[0],this.lexer,this.rules)}}emStrong(n,s,r=""){let a=this.rules.inline.emStrongLDelim.exec(n);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 d,u,f=c,x=0;const b=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(b.lastIndex=0,s=s.slice(-1*n.length+c);(a=b.exec(s))!=null;){if(d=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!d)continue;if(u=[...d].length,a[3]||a[4]){f+=u;continue}else if((a[5]||a[6])&&c%3&&!((c+u)%3)){x+=u;continue}if(f-=u,f>0)continue;u=Math.min(u,u+f+x);const g=[...a[0]][0].length,h=n.slice(0,c+a.index+g+u);if(Math.min(c,u)%2){const y=h.slice(1,-1);return{type:"em",raw:h,text:y,tokens:this.lexer.inlineTokens(y)}}const v=h.slice(2,-2);return{type:"strong",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){const s=this.rules.inline.code.exec(n);if(s){let r=s[2].replace(this.rules.other.newLineCharGlobal," ");const a=this.rules.other.nonSpaceChar.test(r),i=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return a&&i&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:s[0],text:r}}}br(n){const s=this.rules.inline.br.exec(n);if(s)return{type:"br",raw:s[0]}}del(n){const s=this.rules.inline.del.exec(n);if(s)return{type:"del",raw:s[0],text:s[2],tokens:this.lexer.inlineTokens(s[2])}}autolink(n){const s=this.rules.inline.autolink.exec(n);if(s){let r,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(n){var r;let s;if(s=this.rules.inline.url.exec(n)){let a,i;if(s[2]==="@")a=s[0],i="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."?i="http://"+s[0]:i=s[0]}return{type:"link",raw:s[0],text:a,href:i,tokens:[{type:"text",raw:a,text:a}]}}}inlineText(n){const s=this.rules.inline.text.exec(n);if(s){const r=this.lexer.state.inRawBlock;return{type:"text",raw:s[0],text:s[0],escaped:r}}}}class Ds{constructor(n){Rt(this,"tokens");Rt(this,"options");Rt(this,"state");Rt(this,"tokenizer");Rt(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||Ya,this.options.tokenizer=this.options.tokenizer||new jf,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const s={other:Xn,block:Mu.normal,inline:ic.normal};this.options.pedantic?(s.block=Mu.pedantic,s.inline=ic.pedantic):this.options.gfm&&(s.block=Mu.gfm,this.options.breaks?s.inline=ic.breaks:s.inline=ic.gfm),this.tokenizer.rules=s}static get rules(){return{block:Mu,inline:ic}}static lex(n,s){return new Ds(s).lex(n)}static lexInline(n,s){return new Ds(s).inlineTokens(n)}lex(n){n=n.replace(Xn.carriageReturn,`
|
|
539
|
+
`),this.blockTokens(n,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){const r=this.inlineQueue[s];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(n,s=[],r=!1){var a,i,c;for(this.options.pedantic&&(n=n.replace(Xn.tabCharGlobal," ").replace(Xn.spaceLine,""));n;){let d;if((i=(a=this.options.extensions)==null?void 0:a.block)!=null&&i.some(f=>(d=f.call({lexer:this},n,s))?(n=n.substring(d.raw.length),s.push(d),!0):!1))continue;if(d=this.tokenizer.space(n)){n=n.substring(d.raw.length);const f=s.at(-1);d.raw.length===1&&f!==void 0?f.raw+=`
|
|
540
|
+
`:s.push(d);continue}if(d=this.tokenizer.code(n)){n=n.substring(d.raw.length);const f=s.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=`
|
|
541
|
+
`+d.raw,f.text+=`
|
|
542
|
+
`+d.text,this.inlineQueue.at(-1).src=f.text):s.push(d);continue}if(d=this.tokenizer.fences(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.heading(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.hr(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.blockquote(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.list(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.html(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.def(n)){n=n.substring(d.raw.length);const f=s.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=`
|
|
543
|
+
`+d.raw,f.text+=`
|
|
544
|
+
`+d.raw,this.inlineQueue.at(-1).src=f.text):this.tokens.links[d.tag]||(this.tokens.links[d.tag]={href:d.href,title:d.title});continue}if(d=this.tokenizer.table(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.lheading(n)){n=n.substring(d.raw.length),s.push(d);continue}let u=n;if((c=this.options.extensions)!=null&&c.startBlock){let f=1/0;const x=n.slice(1);let b;this.options.extensions.startBlock.forEach(g=>{b=g.call({lexer:this},x),typeof b=="number"&&b>=0&&(f=Math.min(f,b))}),f<1/0&&f>=0&&(u=n.substring(0,f+1))}if(this.state.top&&(d=this.tokenizer.paragraph(u))){const f=s.at(-1);r&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=`
|
|
545
|
+
`+d.raw,f.text+=`
|
|
546
|
+
`+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):s.push(d),r=u.length!==n.length,n=n.substring(d.raw.length);continue}if(d=this.tokenizer.text(n)){n=n.substring(d.raw.length);const f=s.at(-1);(f==null?void 0:f.type)==="text"?(f.raw+=`
|
|
547
|
+
`+d.raw,f.text+=`
|
|
548
|
+
`+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):s.push(d);continue}if(n){const f="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(f);break}else throw new Error(f)}}return this.state.top=!0,s}inline(n,s=[]){return this.inlineQueue.push({src:n,tokens:s}),s}inlineTokens(n,s=[]){var d,u,f;let r=n,a=null;if(this.tokens.links){const x=Object.keys(this.tokens.links);if(x.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)x.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 i=!1,c="";for(;n;){i||(c=""),i=!1;let x;if((u=(d=this.options.extensions)==null?void 0:d.inline)!=null&&u.some(g=>(x=g.call({lexer:this},n,s))?(n=n.substring(x.raw.length),s.push(x),!0):!1))continue;if(x=this.tokenizer.escape(n)){n=n.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.tag(n)){n=n.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.link(n)){n=n.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.reflink(n,this.tokens.links)){n=n.substring(x.raw.length);const g=s.at(-1);x.type==="text"&&(g==null?void 0:g.type)==="text"?(g.raw+=x.raw,g.text+=x.text):s.push(x);continue}if(x=this.tokenizer.emStrong(n,r,c)){n=n.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.codespan(n)){n=n.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.br(n)){n=n.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.del(n)){n=n.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.autolink(n)){n=n.substring(x.raw.length),s.push(x);continue}if(!this.state.inLink&&(x=this.tokenizer.url(n))){n=n.substring(x.raw.length),s.push(x);continue}let b=n;if((f=this.options.extensions)!=null&&f.startInline){let g=1/0;const h=n.slice(1);let v;this.options.extensions.startInline.forEach(y=>{v=y.call({lexer:this},h),typeof v=="number"&&v>=0&&(g=Math.min(g,v))}),g<1/0&&g>=0&&(b=n.substring(0,g+1))}if(x=this.tokenizer.inlineText(b)){n=n.substring(x.raw.length),x.raw.slice(-1)!=="_"&&(c=x.raw.slice(-1)),i=!0;const g=s.at(-1);(g==null?void 0:g.type)==="text"?(g.raw+=x.raw,g.text+=x.text):s.push(x);continue}if(n){const g="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(g);break}else throw new Error(g)}}return s}}class kf{constructor(n){Rt(this,"options");Rt(this,"parser");this.options=n||Ya}space(n){return""}code({text:n,lang:s,escaped:r}){var c;const a=(c=(s||"").match(Xn.notSpaceStart))==null?void 0:c[0],i=n.replace(Xn.endingNewline,"")+`
|
|
549
|
+
`;return a?'<pre><code class="language-'+wr(a)+'">'+(r?i:wr(i,!0))+`</code></pre>
|
|
550
|
+
`:"<pre><code>"+(r?i:wr(i,!0))+`</code></pre>
|
|
551
|
+
`}blockquote({tokens:n}){return`<blockquote>
|
|
552
|
+
${this.parser.parse(n)}</blockquote>
|
|
553
|
+
`}html({text:n}){return n}heading({tokens:n,depth:s}){return`<h${s}>${this.parser.parseInline(n)}</h${s}>
|
|
554
|
+
`}hr(n){return`<hr>
|
|
555
|
+
`}list(n){const s=n.ordered,r=n.start;let a="";for(let d=0;d<n.items.length;d++){const u=n.items[d];a+=this.listitem(u)}const i=s?"ol":"ul",c=s&&r!==1?' start="'+r+'"':"";return"<"+i+c+`>
|
|
556
|
+
`+a+"</"+i+`>
|
|
557
|
+
`}listitem(n){var r;let s="";if(n.task){const a=this.checkbox({checked:!!n.checked});n.loose?((r=n.tokens[0])==null?void 0:r.type)==="paragraph"?(n.tokens[0].text=a+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=a+" "+wr(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:a+" ",text:a+" ",escaped:!0}):s+=a+" "}return s+=this.parser.parse(n.tokens,!!n.loose),`<li>${s}</li>
|
|
558
|
+
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
559
|
+
`}table(n){let s="",r="";for(let i=0;i<n.header.length;i++)r+=this.tablecell(n.header[i]);s+=this.tablerow({text:r});let a="";for(let i=0;i<n.rows.length;i++){const c=n.rows[i];r="";for(let d=0;d<c.length;d++)r+=this.tablecell(c[d]);a+=this.tablerow({text:r})}return a&&(a=`<tbody>${a}</tbody>`),`<table>
|
|
560
|
+
<thead>
|
|
561
|
+
`+s+`</thead>
|
|
562
|
+
`+a+`</table>
|
|
563
|
+
`}tablerow({text:n}){return`<tr>
|
|
564
|
+
${n}</tr>
|
|
565
|
+
`}tablecell(n){const s=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+s+`</${r}>
|
|
566
|
+
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${wr(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:s,tokens:r}){const a=this.parser.parseInline(r),i=Qj(n);if(i===null)return a;n=i;let c='<a href="'+n+'"';return s&&(c+=' title="'+wr(s)+'"'),c+=">"+a+"</a>",c}image({href:n,title:s,text:r}){const a=Qj(n);if(a===null)return wr(r);n=a;let i=`<img src="${n}" alt="${r}"`;return s&&(i+=` title="${wr(s)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:wr(n.text)}}class fv{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}}class Fs{constructor(n){Rt(this,"options");Rt(this,"renderer");Rt(this,"textRenderer");this.options=n||Ya,this.options.renderer=this.options.renderer||new kf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new fv}static parse(n,s){return new Fs(s).parse(n)}static parseInline(n,s){return new Fs(s).parseInline(n)}parse(n,s=!0){var a,i;let r="";for(let c=0;c<n.length;c++){const d=n[c];if((i=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&i[d.type]){const f=d,x=this.options.extensions.renderers[f.type].call({parser:this},f);if(x!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type)){r+=x||"";continue}}const u=d;switch(u.type){case"space":{r+=this.renderer.space(u);continue}case"hr":{r+=this.renderer.hr(u);continue}case"heading":{r+=this.renderer.heading(u);continue}case"code":{r+=this.renderer.code(u);continue}case"table":{r+=this.renderer.table(u);continue}case"blockquote":{r+=this.renderer.blockquote(u);continue}case"list":{r+=this.renderer.list(u);continue}case"html":{r+=this.renderer.html(u);continue}case"paragraph":{r+=this.renderer.paragraph(u);continue}case"text":{let f=u,x=this.renderer.text(f);for(;c+1<n.length&&n[c+1].type==="text";)f=n[++c],x+=`
|
|
567
|
+
`+this.renderer.text(f);s?r+=this.renderer.paragraph({type:"paragraph",raw:x,text:x,tokens:[{type:"text",raw:x,text:x,escaped:!0}]}):r+=x;continue}default:{const f='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}parseInline(n,s=this.renderer){var a,i;let r="";for(let c=0;c<n.length;c++){const d=n[c];if((i=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&i[d.type]){const f=this.options.extensions.renderers[d.type].call({parser:this},d);if(f!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(d.type)){r+=f||"";continue}}const u=d;switch(u.type){case"escape":{r+=s.text(u);break}case"html":{r+=s.html(u);break}case"link":{r+=s.link(u);break}case"image":{r+=s.image(u);break}case"strong":{r+=s.strong(u);break}case"em":{r+=s.em(u);break}case"codespan":{r+=s.codespan(u);break}case"br":{r+=s.br(u);break}case"del":{r+=s.del(u);break}case"text":{r+=s.text(u);break}default:{const f='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}}class Nc{constructor(n){Rt(this,"options");Rt(this,"block");this.options=n||Ya}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Ds.lex:Ds.lexInline}provideParser(){return this.block?Fs.parse:Fs.parseInline}}Rt(Nc,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class lM{constructor(...n){Rt(this,"defaults",ov());Rt(this,"options",this.setOptions);Rt(this,"parse",this.parseMarkdown(!0));Rt(this,"parseInline",this.parseMarkdown(!1));Rt(this,"Parser",Fs);Rt(this,"Renderer",kf);Rt(this,"TextRenderer",fv);Rt(this,"Lexer",Ds);Rt(this,"Tokenizer",jf);Rt(this,"Hooks",Nc);this.use(...n)}walkTokens(n,s){var a,i;let r=[];for(const c of n)switch(r=r.concat(s.call(this,c)),c.type){case"table":{const d=c;for(const u of d.header)r=r.concat(this.walkTokens(u.tokens,s));for(const u of d.rows)for(const f of u)r=r.concat(this.walkTokens(f.tokens,s));break}case"list":{const d=c;r=r.concat(this.walkTokens(d.items,s));break}default:{const d=c;(i=(a=this.defaults.extensions)==null?void 0:a.childTokens)!=null&&i[d.type]?this.defaults.extensions.childTokens[d.type].forEach(u=>{const f=d[u].flat(1/0);r=r.concat(this.walkTokens(f,s))}):d.tokens&&(r=r.concat(this.walkTokens(d.tokens,s)))}}return r}use(...n){const s=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(r=>{const a={...r};if(a.async=this.defaults.async||a.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const c=s.renderers[i.name];c?s.renderers[i.name]=function(...d){let u=i.renderer.apply(this,d);return u===!1&&(u=c.apply(this,d)),u}:s.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const c=s[i.level];c?c.unshift(i.tokenizer):s[i.level]=[i.tokenizer],i.start&&(i.level==="block"?s.startBlock?s.startBlock.push(i.start):s.startBlock=[i.start]:i.level==="inline"&&(s.startInline?s.startInline.push(i.start):s.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(s.childTokens[i.name]=i.childTokens)}),a.extensions=s),r.renderer){const i=this.defaults.renderer||new kf(this.defaults);for(const c in r.renderer){if(!(c in i))throw new Error(`renderer '${c}' does not exist`);if(["options","parser"].includes(c))continue;const d=c,u=r.renderer[d],f=i[d];i[d]=(...x)=>{let b=u.apply(i,x);return b===!1&&(b=f.apply(i,x)),b||""}}a.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new jf(this.defaults);for(const c in r.tokenizer){if(!(c in i))throw new Error(`tokenizer '${c}' does not exist`);if(["options","rules","lexer"].includes(c))continue;const d=c,u=r.tokenizer[d],f=i[d];i[d]=(...x)=>{let b=u.apply(i,x);return b===!1&&(b=f.apply(i,x)),b}}a.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new Nc;for(const c in r.hooks){if(!(c in i))throw new Error(`hook '${c}' does not exist`);if(["options","block"].includes(c))continue;const d=c,u=r.hooks[d],f=i[d];Nc.passThroughHooks.has(c)?i[d]=x=>{if(this.defaults.async)return Promise.resolve(u.call(i,x)).then(g=>f.call(i,g));const b=u.call(i,x);return f.call(i,b)}:i[d]=(...x)=>{let b=u.apply(i,x);return b===!1&&(b=f.apply(i,x)),b}}a.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,c=r.walkTokens;a.walkTokens=function(d){let u=[];return u.push(c.call(this,d)),i&&(u=u.concat(i.call(this,d))),u}}this.defaults={...this.defaults,...a}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,s){return Ds.lex(n,s??this.defaults)}parser(n,s){return Fs.parse(n,s??this.defaults)}parseMarkdown(n){return(r,a)=>{const i={...a},c={...this.defaults,...i},d=this.onError(!!c.silent,!!c.async);if(this.defaults.async===!0&&i.async===!1)return d(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return d(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return d(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));c.hooks&&(c.hooks.options=c,c.hooks.block=n);const u=c.hooks?c.hooks.provideLexer():n?Ds.lex:Ds.lexInline,f=c.hooks?c.hooks.provideParser():n?Fs.parse:Fs.parseInline;if(c.async)return Promise.resolve(c.hooks?c.hooks.preprocess(r):r).then(x=>u(x,c)).then(x=>c.hooks?c.hooks.processAllTokens(x):x).then(x=>c.walkTokens?Promise.all(this.walkTokens(x,c.walkTokens)).then(()=>x):x).then(x=>f(x,c)).then(x=>c.hooks?c.hooks.postprocess(x):x).catch(d);try{c.hooks&&(r=c.hooks.preprocess(r));let x=u(r,c);c.hooks&&(x=c.hooks.processAllTokens(x)),c.walkTokens&&this.walkTokens(x,c.walkTokens);let b=f(x,c);return c.hooks&&(b=c.hooks.postprocess(b)),b}catch(x){return d(x)}}}onError(n,s){return r=>{if(r.message+=`
|
|
568
|
+
Please report this to https://github.com/markedjs/marked.`,n){const a="<p>An error occurred:</p><pre>"+wr(r.message+"",!0)+"</pre>";return s?Promise.resolve(a):a}if(s)return Promise.reject(r);throw r}}}const Fa=new lM;function Pt(e,n){return Fa.parse(e,n)}Pt.options=Pt.setOptions=function(e){return Fa.setOptions(e),Pt.defaults=Fa.defaults,kS(Pt.defaults),Pt};Pt.getDefaults=ov;Pt.defaults=Ya;Pt.use=function(...e){return Fa.use(...e),Pt.defaults=Fa.defaults,kS(Pt.defaults),Pt};Pt.walkTokens=function(e,n){return Fa.walkTokens(e,n)};Pt.parseInline=Fa.parseInline;Pt.Parser=Fs;Pt.parser=Fs.parse;Pt.Renderer=kf;Pt.TextRenderer=fv;Pt.Lexer=Ds;Pt.lexer=Ds.lex;Pt.Tokenizer=jf;Pt.Hooks=Nc;Pt.parse=Pt;Pt.options;Pt.setOptions;Pt.use;Pt.walkTokens;Pt.parseInline;Fs.parse;Ds.lex;let cc;const cM=e=>(cc||(rf.addHook("uponSanitizeElement",(n,s)=>{cc??(cc=s.allowedTags)}),rf.sanitize("<b></b>"),rf.removeHook("uponSanitizeElement")),(cc==null?void 0:cc[e.toLowerCase()])===!0),dM=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");Pt.use({breaks:!0,renderer:{html:({text:e,block:n})=>{let s=0;const r=e.replace(/<\/?([A-Za-z][\w:-]*)[^<>]*>/g,(a,i)=>cM(i)?(s++,a):dM(a));return n&&!s&&r!==e?`<p>${r.trim().replace(/\n/g,`<br>
|
|
569
|
+
`)}</p>
|
|
570
|
+
`:r}}});const ea=e=>e.slice(-8),td=e=>new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),mt=e=>new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function nl(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const MS=e=>e.basis==="estimate",Xr=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Nf=e=>{if(e>0&&e<1e-4)return"<$0.0001";if(e>=1)return`$${e.toFixed(2)}`;const[n,s=""]=e.toFixed(4).split(".");return`$${n}.${s.replace(/0+$/,"").padEnd(2,"0")}`},xl=e=>e&&e.usd===null&&typeof e.so_far_usd=="number"&&typeof e.unpriced=="number"?e:void 0,Zj=(e,{ended:n=!1}={})=>`The charges priced${n?"":" so far"}. ${e.unpriced} ${e.unpriced===1?"charge has":"charges have"} no price, so this is not the whole cost.`,uM=new Set(["completed","failed","cancelled"]),Ua=e=>typeof e=="string"&&uM.has(e),fM="$0 · free model",PS=e=>e.usd===0&&e.free===!0,LS=e=>e.upper_bound===!0?"at most ":"",mM=(e,{ended:n=!1}={})=>e.usd!==null?`${LS(e)}${Xr(e.usd)}`:typeof e.so_far_usd=="number"?n?`${Nf(e.so_far_usd)} known, ${e.unpriced??0} not priced`:`so far ${Nf(e.so_far_usd)}, ${e.unpriced??0} not priced`:"not priced";function Zr(e,{ended:n=!1}={}){const s=nd(e);if(s&&(e==null?void 0:e.usd)===0)return`${IS(s.tokens)} tokens · Using ChatGPT plan`;const r=hM(e,n);return s?`${r} + ChatGPT plan`:r}function hM(e,n){const s=xl(e),r=a=>MS(a)?" est.":"";return s?n?`${Nf(s.so_far_usd)}${r(s)} known · ${s.unpriced} not priced`:`so far ${Nf(s.so_far_usd)}${r(s)} · ${s.unpriced} not priced`:!e||e.usd===null?"Unknown":PS(e)?fM:`${LS(e)}${Xr(e.usd)}${r(e)}`}const nd=e=>e!=null&&e.plan&&e.plan.requests>0?e.plan:void 0;function IS(e){if(e<1e4)return e.toLocaleString("en-US");const[n,s]=e<1e6?[e/1e3,"K"]:e<1e9?[e/1e6,"M"]:[e/1e9,"B"];return`${n<100?n.toFixed(1).replace(/\.0$/,""):Math.round(n)}${s}`}function ek(e,n,{ended:s=!1,text:r}={}){const a=r??Zr(e,{ended:s});return typeof n!="number"?a:(r!==void 0?pM.test(r):!xl(e)&&!nd(e)&&!!e&&e.usd!==null&&!PS(e))?`${a} of ${tk(n)}`:`${a} · cap ${tk(n)}`}const pM=/^<?\$[\d.,]+( est\.)?$/;function tk(e){for(let n=2;n<8;n++)if(Number(e.toFixed(n))===e)return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}function gM(e,n){if(e.startsWith("/")||e.startsWith("#"))return null;const s=n.from?`${n.from.replace(/\/*$/,"").split("/").map(encodeURIComponent).join("/")}/`:"";try{const r=decodeURIComponent(new URL(e,`file:///${s}`).pathname.slice(1));return n.paths.includes(r)?r:null}catch{return null}}function eo(e,n){const s=rf.sanitize(Pt.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 i=n&&gM(a,n);if(i){const c=r.ownerDocument.createElement("button");c.type="button",c.title=`Open ${i}`,c.dataset.runFile=i,c.append(...r.childNodes),r.replaceWith(c)}else r.replaceWith(...r.childNodes)}return s.innerHTML}const mv=e=>n=>{var r,a,i;const s=(i=(a=(r=n.target).closest)==null?void 0:a.call(r,"[data-run-file]"))==null?void 0:i.getAttribute("data-run-file");s&&(n.preventDefault(),e(s))},xM=e=>{const n=s=>{var r;return(r=new RegExp(`\\b${s}="([^"]*)"`).exec(e))==null?void 0:r[1]};return n("scheme")==="github"||n("source")==="github"?"A GitHub event":n("source")==="webhook"?"A webhook request":"A trigger's request"};function Nn(e){const{title:n}=e;if(!e.trigger)return n;let s=n.search(/<trigger-payload\b/);if(s<0){const a=/<([a-z-]*)…$/.exec(n);if(!a||!"trigger-payload".startsWith(a[1]))return n;s=a.index}return n.slice(0,s).trim()||xM(n.slice(s))}function vM(e,n){if(n.unchanged&&!n.reset&&!n.drop.length&&!n.rows.length)return e;const s=new Map;if(!n.reset)for(const r of e)s.set(r.id,r);for(const r of n.drop)s.delete(r);for(const r of n.rows)s.set(r.id,r);return[...s.values()].sort((r,a)=>r.seq-a.seq)}const zS=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,DS=e=>e.refused===!0,FS=e=>e.tool_status==="failed"&&!DS(e)||e.kind==="error",yM=e=>e.paused===!0;function bM(e){const n=new Map(e.filter(f=>f.kind==="tool_result"&&f.tool_use_id).map(f=>[f.tool_use_id,f])),s=new Set(e.filter(f=>f.kind==="tool_use"&&f.tool_use_id).map(f=>f.tool_use_id)),r=new Set(e.filter(f=>f.kind==="waiting"&&f.id.endsWith(":waiting")).map(f=>f.id.slice(0,-8))),a=f=>{var x;return r.has(f.id)||(f.tool_use_id?r.has(((x=n.get(f.tool_use_id))==null?void 0:x.id)??""):!1)},i=e.findLast(f=>f.kind==="usage"),c=[],d=new Map;let u;for(const f of e){if(f.kind==="usage")continue;if(f.tool_name==="ask_person"&&(f.kind==="tool_use"||f.kind==="tool_result")&&a(f)){u=void 0;continue}if(f.kind==="tool_result"&&f.tool_use_id&&s.has(f.tool_use_id)){u=d.get(f.tool_use_id);continue}if(f.kind==="phase"&&f.path&&u&&(u.row.kind==="tool_result"||u.row.kind==="tool_use")&&!u.saved){u.saved=f.path;continue}const x=c.at(-1);if(f.kind==="error"&&(x==null?void 0:x.row.kind)==="error"&&x.row.summary===f.summary&&x.row.text===f.text&&(x.row.agent_label??null)===(f.agent_label??null)){x.times=(x.times??1)+1,x.until=f.timestamp,u=x;continue}let b;const g=f.kind==="tool_use"&&f.tool_use_id?n.get(f.tool_use_id):void 0;if(g){const h=g.tool_status!=="failed",v=[f.tool_input_preview,g.tool_result_preview].filter(Boolean),y=g.tool_status!==null;b={row:{...g,id:f.id,seq:f.seq,timestamp:f.timestamp,summary:h?(g.summary??"").replace(/:\s*ok$/i,""):g.summary,...f.usage?{usage:f.usage}:{}},...y?{ms:Math.max(0,Date.parse(g.timestamp)-Date.parse(f.timestamp))}:{},detail:v.length===2?`${v[0]}
|
|
571
|
+
|
|
572
|
+
→ ${v[1]}`:v[0]??null}}else b={row:f};c.push(b),f.kind==="tool_use"&&f.tool_use_id&&d.set(f.tool_use_id,b),u=b}return i&&c.push({row:i}),c}class ze extends Error{constructor(s,r,a,i=!1,c){super(a);Rt(this,"fields");Rt(this,"retryAfterMs");Rt(this,"details");Rt(this,"problems");this.status=s,this.code=r,this.retryable=i,this.requestId=c,this.name="ClientError"}toApiError(){return{code:this.code,message:this.message,retryable:this.retryable,request_id:this.requestId,...this.details?{details:this.details}:{}}}}const Dt=e=>e instanceof ze?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),nk=(e,n,{status:s,archived:r}={})=>{const a=new URLSearchParams({limit:String(e)});return n&&a.set("cursor",n),s&&a.set("status",s),r&&a.set("archived","true"),`?${a}`},wM=new Set(["/auth/sign-in","/setup"]);function jM({fetch:e=globalThis.fetch.bind(globalThis),base:n="/v2",onSignedOut:s}={}){async function r(v,y,j={}){return(await a(v,y,j)).body}async function a(v,y,{body:j,headers:k={},signal:$,text:S=!1}={}){var O;const N=j!==void 0||v!=="GET"&&v!=="HEAD",_=await e(`${n}${y}`,{method:v,signal:$,credentials:"same-origin",headers:{accept:"application/json",...N?{"content-type":"application/json"}:{},...k},body:j===void 0?void 0:JSON.stringify(j)});if(!_.ok){_.status===401&&!wM.has(y)&&(s==null||s());const A=(O=await _.json().catch(()=>null))==null?void 0:O.error,I=new ze(_.status,(A==null?void 0:A.code)??"http_error",(A==null?void 0:A.message)??`${v} ${y}: ${_.status}`,(A==null?void 0:A.retryable)??!1,A==null?void 0:A.request_id);throw A!=null&&A.fields&&(I.fields=A.fields),typeof(A==null?void 0:A.retry_after_ms)=="number"&&(I.retryAfterMs=A.retry_after_ms),A!=null&&A.details&&typeof A.details=="object"&&!Array.isArray(A.details)&&(I.details=A.details),Array.isArray(A==null?void 0:A.problems)&&(I.problems=A.problems),I}return{body:!S&&(_.headers.get("content-type")??"").includes("json")?await _.json():await _.text(),etag:_.headers.get("etag"),status:_.status}}const i=v=>`/agents/${encodeURIComponent(v)}`,c=v=>`/runs/${encodeURIComponent(v)}`,d=(v,y,j)=>`${i(v)}/learning/workflows/${encodeURIComponent(y)}/revisions/${encodeURIComponent(j)}/replays`,u=v=>`/settings/mcp-servers/${encodeURIComponent(v)}`,f=v=>`/triggers/${encodeURIComponent(v)}`,x=new Map,b=(v,y)=>`${i(v)}/learning/files/${encodeURIComponent(y)}`,g=v=>({note:v.body,etag:v.etag}),h={accept:"text/markdown, application/json"};return{capabilities:()=>r("GET","/capabilities"),session:()=>a("GET","/auth/session").then(v=>({status:v.status,body:v.body})),signIn:v=>r("POST","/auth/sign-in",{body:{password:v}}),setup:(v,y,j=!1)=>r("POST","/setup",{body:{password:v,...y?{code:y}:{},...j?{import:!0}:{}}}),setupImport:()=>r("GET","/setup/import").then(v=>(v==null?void 0:v.offer)===!1?null:v,v=>{if(v instanceof ze&&(v.status===404||v.status===403))return null;throw v}),signOut:()=>r("POST","/auth/sign-out",{body:{}}),signOutEverywhere:()=>r("POST","/auth/sign-out-everywhere",{body:{}}),stats:()=>r("GET","/stats"),listRuns:(v=50,y,j)=>r("GET",`/runs${nk(v,y,j)}`),listAgentRuns:(v,y=50,j,k={})=>r("GET",`${i(v)}/runs${nk(y,j,typeof k=="boolean"?{archived:k}:k)}`),discoverNative:(v,y)=>r("POST","/native/discover",{body:{project:v,...y?{runtime:y}:{}}}),connectNative:v=>r("POST","/native/connect",{body:v}),getNative:v=>r("GET",`${i(v)}/native`),verifyNative:v=>r("POST",`${i(v)}/native/verify`,{body:{}}),disconnectNative:v=>r("POST",`${i(v)}/native/disconnect`,{body:{}}),observations:({days:v=30,sessionId:y}={},j)=>{const k=new URLSearchParams({days:String(v)});return y&&k.set("session_id",y),r("GET",`/observations?${k}`,{signal:j})},listConnectors:()=>r("GET","/connectors"),enrollConnector:(v,y)=>r("POST","/connectors/enrollment",{body:{...v!=null&&v.trim()?{label:v.trim()}:{},...y?{capabilities:y}:{}}}),revokeConnector:v=>r("DELETE",`/connectors/${encodeURIComponent(v)}`),listAgents:({archived:v=!1,cursor:y}={})=>{const j=new URLSearchParams;return v&&j.set("archived","true"),y&&j.set("cursor",y),r("GET",`/agents${j.size?`?${j}`:""}`)},getAgent:async v=>{const y=await a("GET",i(v)),j=x.get(v);return{agent:j&&j.revision===y.body.revision&&!y.body.warnings?{...y.body,warnings:j.warnings}:y.body,etag:y.etag}},createAgent:async v=>{var j;const y=await r("POST","/agents",{body:v});return(j=y.warnings)!=null&&j.length&&x.set(y.agent_id,{revision:y.revision,warnings:y.warnings}),y},updateDefinition:async(v,y,j)=>{const k=await a("PUT",`${i(v)}/definition`,{body:y,headers:j?{"if-match":j}:{}});return x.delete(v),{agent:k.body,etag:k.etag}},listRevisions:(v,y)=>r("GET",`${i(v)}/revisions${y?`?cursor=${encodeURIComponent(y)}`:""}`),setCurrent:async(v,y)=>{const j=await r("POST",`${i(v)}/current`,{body:{revision:y}});return x.delete(v),j},archiveAgent:v=>r("POST",`${i(v)}/archive`,{body:{}}),unarchiveAgent:v=>r("POST",`${i(v)}/unarchive`,{body:{}}),agentLearning:v=>r("GET",`${i(v)}/learning`),learningCost:(v,y)=>r("GET",`${i(v)}/learning/cost${y?`?limit=${y}`:""}`),learningBatches:v=>r("GET",`${i(v)}/learning/batches`),learningBatch:(v,y)=>r("GET",`${i(v)}/learning/batches/${encodeURIComponent(y)}`),startLearningBatch:(v,y)=>r("POST",`${i(v)}/learning/batches`,{body:y}),cancelLearningBatch:(v,y)=>r("POST",`${i(v)}/learning/batches/${encodeURIComponent(y)}/cancel`,{body:{}}),learningEvals:v=>r("GET",`${i(v)}/learning/evals`),learningPromotions:v=>r("GET",`${i(v)}/learning/promotions`),learningLoop:v=>r("GET",`${i(v)}/learning/loop`),learnedWorkflowRevisions:(v,y,j)=>r("GET",`${i(v)}/learning/workflows/${encodeURIComponent(y)}/revisions${j?`?limit=${j}`:""}`),startLearnedWorkflowReplay:(v,y,j)=>r("POST",`${d(v,y,j)}`,{body:{}}),learnedWorkflowReplay:(v,y,j,k)=>r("GET",`${d(v,y,j)}/${encodeURIComponent(k)}`),learningNotes:(v,y)=>r("GET",`${i(v)}/learning/notes?cursor=${encodeURIComponent(y)}`),learningLog:(v,y)=>r("GET",`${i(v)}/learning/log?cursor=${encodeURIComponent(y)}`),readNote:async(v,y)=>g(await a("GET",b(v,y),{headers:h,text:!0})),writeNote:async(v,y,j,k)=>g(await a("PUT",b(v,y),{body:{text:j},headers:{...h,..."etag"in k?{"if-match":k.etag}:{"if-none-match":"*"}},text:!0})),retireNote:async(v,y,j)=>g(await a("POST",`${b(v,y)}/retire`,{body:{},headers:{...h,"if-match":j},text:!0})),approveNote:async(v,y,j)=>g(await a("POST",`${b(v,y)}/approve`,{body:{},headers:{...h,"if-match":j},text:!0})),restoreNote:async(v,y,j)=>g(await a("POST",`${b(v,y)}/restore`,{body:{},headers:{...h,"if-match":j},text:!0})),forgetSignIn:(v,y)=>r("DELETE",`${i(v)}/sign-ins/${encodeURIComponent(y)}`),promoteWorkflow:async(v,y,j)=>{var $;const k=await r("POST",`${i(v)}/learning/workflows/${encodeURIComponent(y)}/promote`,{body:{},headers:{"idempotency-key":j}});return($=k.warnings)!=null&&$.length&&x.set(k.agent_id,{revision:k.revision,warnings:k.warnings}),k},getRun:v=>r("GET",c(v)),runLearningResult:v=>r("GET",`${c(v)}/learning`),runLearningDiff:v=>r("GET",`${c(v)}/learning/diff`),runLearning:v=>r("GET",`${c(v)}/learning`),runComputer:v=>r("GET",`${c(v)}/computer`),takeOverComputer:v=>r("POST",`${c(v)}/computer/take-over`,{body:{}}),handBackComputer:(v,y)=>r("POST",`${c(v)}/computer/hand-back`,{body:y?{outcome:y}:{}}),archiveRun:v=>r("POST",`${c(v)}/archive`,{body:{}}),unarchiveRun:v=>r("POST",`${c(v)}/unarchive`,{body:{}}),raiseCap:(v,y)=>r("PATCH",c(v),{body:{max_cost_usd:y}}),gradeRun:(v,y)=>r("PUT",`${c(v)}/grade`,{body:y}),startRun:async(v,y,j)=>{const k=await a("POST",`${i(v)}/runs`,{body:y,headers:{"idempotency-key":j}});return{run:k.body,status:k.status}},getTimeline:(v,{after:y,waitMs:j,signal:k}={})=>{const $=new URLSearchParams;return y!==void 0&&$.set("after",String(y)),j!==void 0&&$.set("wait_ms",String(j)),r("GET",`${c(v)}/timeline${$.size?`?${$}`:""}`,{signal:k})},listFiles:v=>r("GET",`${c(v)}/files`),deleteUpload:v=>r("DELETE",`/files/${encodeURIComponent(v)}`),readFile:(v,y)=>r("GET",`${c(v)}/files/${y.split("/").map(encodeURIComponent).join("/")}`,{text:!0}),sendMessage:(v,y,j)=>r("POST",`${c(v)}/messages`,{body:{content:y},headers:{"idempotency-key":j}}),getRunGraph:(v,y)=>r("GET",`${c(v)}/graph`,{signal:y}),pauseRun:v=>r("POST",`${c(v)}/pause`,{body:{}}),resumeRun:v=>r("POST",`${c(v)}/resume`,{body:{}}),validateWorkflow:(v,y)=>r("POST","/workflows/validate",{body:v,signal:y}),statsOver:({from:v,agent:y})=>{const j=new URLSearchParams;return v&&j.set("from",v),y&&j.set("agent",y),r("GET",`/stats${j.size?`?${j}`:""}`)},fileUrl:(v,y)=>`${n}${c(v)}/files/${y.split("/").map(encodeURIComponent).join("/")}`,listToolKeys:()=>r("GET","/settings/tool-keys"),saveToolKey:(v,y)=>r("PUT",`/settings/tool-keys/${encodeURIComponent(v)}`,{body:{values:y}}),removeToolKey:v=>r("DELETE",`/settings/tool-keys/${encodeURIComponent(v)}`),chatGPT:()=>r("GET","/settings/chatgpt"),startChatGPT:()=>r("POST","/settings/chatgpt/sign-in"),finishChatGPT:v=>r("POST","/settings/chatgpt/sign-in/finish",{body:{redirect_url:v}}),signOutChatGPT:()=>r("DELETE","/settings/chatgpt"),computers:()=>r("GET","/computers"),saveComputerKeys:(v,y)=>r("PUT",`/computers/${encodeURIComponent(v)}/keys`,{body:y}),testComputer:v=>r("POST",`/computers/${encodeURIComponent(v)}/test`),computerChoices:v=>r("GET",`/computers/${encodeURIComponent(v)}/choices`),createPairing:()=>r("POST","/computers/pairings"),removeComputer:v=>r("DELETE",`/computers/${encodeURIComponent(v)}`),archil:()=>r("GET","/workspace/archil"),saveArchil:v=>r("PUT","/workspace/archil",{body:v}),archilOff:()=>r("DELETE","/workspace/archil"),testArchil:()=>r("POST","/workspace/archil/test"),webhook:()=>r("GET","/settings/webhook"),saveWebhook:v=>r("PUT","/settings/webhook",{body:{url:v}}),removeWebhook:()=>r("DELETE","/settings/webhook"),testWebhook:()=>r("POST","/settings/webhook/test",{body:{}}),emailAccount:()=>r("GET","/settings/email"),saveEmailAccount:v=>r("PUT","/settings/email",{body:v}),removeEmailAccount:()=>r("DELETE","/settings/email"),testEmailAccount:(v={})=>r("POST","/settings/email/test",{body:v}),listTriggers:()=>r("GET","/triggers"),getTrigger:v=>r("GET",f(v)),createTrigger:(v,y)=>r("POST","/triggers",{body:v,headers:{"idempotency-key":y}}),rotateTriggerSecret:v=>r("POST",`${f(v)}/secret`),updateTrigger:(v,y)=>r("PATCH",f(v),{body:y}),deleteTrigger:v=>r("DELETE",f(v)),fireTrigger:(v,y)=>r("POST",`${f(v)}/fire`,{body:{},headers:{"idempotency-key":y}}),triggerFirings:v=>r("GET",`${f(v)}/firings`),webhookDeliveries:()=>r("GET","/settings/webhook/deliveries"),redeliverWebhook:v=>r("POST",`/settings/webhook/deliveries/${encodeURIComponent(v)}/redeliver`,{body:{}}),listTemplates:()=>r("GET","/templates"),applyTemplate:(v,y,j)=>r("POST",`/templates/${encodeURIComponent(v)}/apply`,{body:y,headers:{"idempotency-key":j}}),importTemplate:(v,y={})=>r("POST","/templates/import",{body:{source:v,...y.dryRun?{dry_run:!0}:{},...y.trustPublisher?{trust_publisher:!0}:{}}}),deleteTemplate:v=>r("DELETE",`/templates/${encodeURIComponent(v)}`),listMcpServers:()=>r("GET","/settings/mcp-servers"),previewMcpServer:(v,y,j)=>r("POST","/settings/mcp-servers/preview",{body:{url:v,auth:y,...j?{name:j}:{}}}),saveMcpServer:(v,y,j,k={})=>r("PUT",u(v),{body:{url:y,auth:j,...k}}),composioTools:(v,y)=>r("POST","/settings/mcp-servers/composio/tools",{body:{api_key:v,toolkit:y}}),saveComposioServer:(v,y,j,k)=>r("PUT",`${u(v)}/composio`,{body:{api_key:y,toolkit:j,tools:k}}),refreshMcpServer:v=>r("POST",`${u(v)}/refresh`,{body:{}}),deleteMcpServer:v=>r("DELETE",u(v)),composioEvents:v=>r("GET",`${u(v)}/composio/events`),composioTriggers:v=>r("GET",`${u(v)}/composio/triggers`),rotateComposioSecret:v=>r("POST",`${u(v)}/composio/rotate-secret`,{body:{}}),deleteComposioSubscription:v=>r("DELETE",`${u(v)}/composio/subscription`),startMcpSignIn:(v,y)=>r("POST",`${u(v)}/oauth/start`,{body:y}),mcpPrivateHosts:()=>r("GET","/settings/mcp-servers/oauth/private-hosts"),saveMcpPrivateHosts:v=>r("PUT","/settings/mcp-servers/oauth/private-hosts",{body:{hosts:v}}),githubConnection:()=>r("GET","/integrations/github"),connectGitHub:v=>r("POST","/integrations/github/connect",{body:v?{org:v}:{}}),disconnectGitHub:()=>r("DELETE","/integrations/github"),toolSettings:()=>r("GET","/settings/tools"),saveToolSettings:v=>r("PUT","/settings/tools",{body:v}),stop:v=>r("POST",`${c(v)}/stop`,{body:{}}),answerApproval:(v,y,j,k,$)=>r("POST",`${c(v)}/approvals/${encodeURIComponent(y)}`,{body:{decision:j,...k?{note:k}:{},...$?{confirm_destructive:!0}:{}}}),cancel:v=>r("POST",`${c(v)}/cancel`,{body:{}})}}async function Gr(e,n,s=100){const r=[];let a=null;for(let i=0;i<s;i++){const c=await e(a);if(r.push(...n(c)),!c.next_cursor)break;a=c.next_cursor}return r}async function US(e,n,{onRows:s,onPage:r,signal:a,waitMs:i=25e3,minDelayMs:c=250}){let d=[],u,f;for(;!(a!=null&&a.aborted);){const x=await e.getTimeline(n,u===void 0?{signal:a}:{after:u,waitMs:i,signal:a}).catch(g=>{if(a!=null&&a.aborted)return null;throw g});if(!x||a!=null&&a.aborted||(f=x,s&&(d=vM(d,x)),r==null||r(x),s==null||s(d),x.final&&!x.has_more))break;u=x.next_after;const b=Math.max(c,x.unchanged?x.poll_after_ms??0:0);b&&await new Promise(g=>setTimeout(g,b))}return f}const sk=e=>`#/observations/${encodeURIComponent(e)}`,Sf=e=>e==="claude"?"Claude Code":e==="codex"?"Codex":e;function Na(e){return e.connection_state==="revoked"?"Revoked":e.connection_state==="disconnected"?"Disconnected":e.selection_active?e.connection_state!=="online"?"Disconnected":{working:"Running",running:"Running",waiting:"Needs input",waiting_input:"Needs input",idle:"Idle",stopped:"Stopped",finished:"Session ended",failed:"Failed",unknown:"Unknown"}[e.activity]??e.activity:"Not selected"}const Dg=e=>{const n=Na(e);return n==="Running"?"success":["Needs input","Disconnected","Failed"].includes(n)?"warning":"muted"},Sa=e=>e==null?"—":e.toLocaleString("en-US");function hv(e,{active:n=!0,days:s=30,sessionId:r}={}){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[x,b]=p.useState(!1);return p.useEffect(()=>{i(null),d(null)},[e,n,s,r]),p.useEffect(()=>{let g=!0;if(!n||typeof e.observations!="function"){b(!1);return}let h=null,v,y;const j=async()=>{if(!g||h)return;clearTimeout(v);const $=h=new AbortController,S=()=>g&&h===$;b(!0);const N=()=>{clearTimeout(_),S()&&(h=null,y=void 0,b(!1),clearTimeout(v),v=setTimeout(k,15e3))},_=y=setTimeout(()=>{S()&&(d("The observation read timed out. Try refreshing again."),$.abort(),N())},3e4);try{const E=await e.observations({days:s,sessionId:r},$.signal);S()&&(i(E),d(null))}catch(E){S()&&(E instanceof ze&&E.status===404?(i(null),d(null)):d(Dt(E)))}finally{N()}},k=()=>{!g||h||(document.hidden?(clearTimeout(v),v=setTimeout(k,15e3)):j())};return j(),window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{g=!1,clearTimeout(v),clearTimeout(y),h==null||h.abort(),h=null,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[e,n,s,r,u]),{data:a,error:c,loading:x,refresh:()=>f(g=>g+1)}}function pv({read:e,view:n="table",query:s="",days:r=30}){const{data:a,error:i,refresh:c}=e,d=a==null?void 0:a.connectors.some(f=>f.storage_full);if(!(a!=null&&a.sessions.length)&&!i&&!d)return null;const u=((a==null?void 0:a.sessions)??[]).filter(f=>`${f.display_name} ${f.harness} ${f.models.join(" ")}`.toLowerCase().includes(s.toLowerCase()));return t.jsxs("section",{className:"space-y-4","aria-label":"Observed sessions",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("div",{className:"mr-auto",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-lead font-semibold",children:[t.jsx(Px,{className:"size-4","aria-hidden":!0}),"Observed sessions"]}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"Agents running in their original applications. Activity refreshes every 15 seconds."})]}),t.jsx(B,{size:"icon","aria-label":"Refresh observed sessions",disabled:e.loading,onClick:c,children:t.jsx(Yo,{className:"size-4","aria-hidden":!0})})]}),d&&t.jsx(xt,{tone:"warning",title:"Telemetry needs attention",children:"A connector has reached its telemetry storage capacity. New reports cannot be accepted until storage becomes available."}),i&&t.jsxs(xt,{tone:"error",children:["Could not refresh observed sessions: ",i]}),n==="summary"&&a&&t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsx("dl",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[["Retained sessions",u.length],["Running",u.filter(f=>Na(f)==="Running").length],["Needs input",u.filter(f=>Na(f)==="Needs input").length],["Disconnected",u.filter(f=>Na(f)==="Disconnected").length]].map(([f,x])=>t.jsxs("div",{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:f}),t.jsx("dd",{className:"mt-2 font-mono text-figure",children:x})]},f))}),t.jsxs("h3",{className:"text-body font-semibold",children:["Observed token usage · last ",r," days"]}),a.usage.status==="unavailable"?t.jsx("p",{className:"text-small text-muted-foreground",children:a.usage.overflow?"Combined token totals are too large to display reliably. Open individual sessions for exact counters.":"Token usage has not been reported."}):t.jsxs(t.Fragment,{children:[t.jsx(WS,{usage:a.usage}),t.jsx(kM,{models:a.usage.models}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Reported tokens only. Input includes cache reads and writes; cache hit rate is cache reads divided by input. Idle does not mean a task completed."})]})]}),n==="summary"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Session totals cover retained reports, independently of the aggregate range."}),u.length?n==="cards"?t.jsx("ul",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 2xl:grid-cols-3",children:u.map(f=>t.jsx("li",{className:"border p-5 transition-colors hover:border-border-strong",children:t.jsxs("a",{href:sk(f.id),className:"block space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[t.jsx("h3",{className:"min-w-0 flex-1 break-words text-base font-semibold",children:f.display_name}),t.jsx(cr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(je,{children:Sf(f.harness)}),t.jsx(je,{tone:Dg(f),children:Na(f)}),t.jsx(je,{tone:"muted",children:"Observed"})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:f.models.join(", ")||"Model not reported"}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Session ",f.id.slice(0,8)," · Last received ",mt(f.received_at)]})]})},f.id))}):t.jsx("div",{className:"overflow-x-auto border",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Observed sessions",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Activity","Session","Harness","Model","Tokens · retained","Last received"].map(f=>t.jsx("th",{className:"whitespace-nowrap px-4 py-3 font-semibold",children:f},f))})}),t.jsx("tbody",{children:u.map(f=>t.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-accent",children:[t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:t.jsx(je,{tone:Dg(f),children:Na(f)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("a",{href:sk(f.id),className:"inline-flex items-center gap-1 underline underline-offset-2",children:[f.display_name,t.jsx(cr,{className:"size-3 shrink-0","aria-hidden":!0})]})}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:Sf(f.harness)}),t.jsx("td",{className:"px-4 py-3",children:f.models.join(", ")||"Not reported"}),t.jsx("td",{className:"px-4 py-3 font-mono",children:f.usage.status==="unavailable"?"—":Sa(f.usage.total_tokens)}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:mt(f.received_at)})]},f.id))})]})}):t.jsx("p",{className:"text-body text-muted-foreground",children:"No observed session matches."})]})}function WS({usage:e}){return e.status==="unavailable"?t.jsx("p",{className:"text-small text-muted-foreground",children:"Token usage has not been reported."}):t.jsx("dl",{className:"grid grid-cols-2 gap-4 md:grid-cols-3",children:[["Input",Sa(e.input_tokens)],["Output",Sa(e.output_tokens)],["Cache writes",Sa(e.cache_write_tokens)],["Cache reads",Sa(e.cache_read_tokens)],["Total tokens",Sa(e.total_tokens)],["Cache hit rate",e.cache_hit_rate==null?"—":`${(e.cache_hit_rate*100).toFixed(1)}%`]].map(([n,s])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:n}),t.jsx("dd",{className:"mt-1 font-mono text-body",children:s})]},n))})}function kM({models:e}){return e.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-right text-small","aria-label":"Observed tokens by model",children:[t.jsx("thead",{className:"border-b text-muted-foreground",children:t.jsx("tr",{children:["Model","Input","Output","Cache writes","Cache reads"].map(n=>t.jsx("th",{className:"whitespace-nowrap py-2 pl-4 font-normal first:pl-0 first:text-left",children:n},n))})}),t.jsx("tbody",{children:e.map(n=>t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsx("th",{className:"py-2 text-left font-normal",children:n.model}),[n.input_tokens,n.output_tokens,n.cache_write_tokens,n.cache_read_tokens].map((s,r)=>t.jsx("td",{className:"py-2 pl-4 font-mono",children:Sa(s)},r))]},n.model))})]})}):null}function NM({v2:e,sessionId:n,go:s}){var i;const r=hv(e,{sessionId:n}),a=(i=r.data)==null?void 0:i.sessions.find(c=>c.id===n);return t.jsxs("section",{className:"flex min-h-full flex-col","aria-label":"Observed session detail",children:[t.jsxs("header",{className:"flex min-h-12 flex-wrap items-center gap-2 border-b px-5 py-2",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>s("#/agents"),children:t.jsx(zn,{"aria-hidden":!0})}),t.jsx(Px,{className:"size-4","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 flex-1 truncate text-body",children:(a==null?void 0:a.display_name)??"Observed session"}),t.jsx(B,{size:"icon","aria-label":"Refresh session",disabled:r.loading,onClick:r.refresh,children:t.jsx(Yo,{"aria-hidden":!0})})]}),t.jsxs("main",{className:"mx-auto w-full max-w-page space-y-6 p-5 md:p-8",children:[r.error&&t.jsxs(xt,{tone:"error",children:["Could not read this session: ",r.error]}),a?t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold",children:a.display_name}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[t.jsx(je,{tone:"muted",children:"Observed"}),t.jsx(je,{tone:Dg(a),children:Na(a)}),t.jsx(je,{children:Sf(a.harness)})]})]}),t.jsx(xt,{children:"Activity and token usage come from the original application. Run, edit and stop remain in that application. This connection observes activity; the backend SDK integration adds self-improvement."}),t.jsx("dl",{className:"grid gap-4 border bg-card p-4 sm:grid-cols-2",children:[["Harness",Sf(a.harness)],["Model",a.models.join(", ")||"Not reported"],["Connection",a.connection_state],["Last reported activity",a.reported_activity],["First seen",mt(a.created_at)],["Last received",mt(a.received_at)],["Session",a.id],["Connector",a.connector_id]].map(([c,d])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:c}),t.jsx("dd",{className:"mt-1 break-all text-body",children:d})]},c))}),t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Session token usage",children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Reported token usage · retained session"}),t.jsx(WS,{usage:a.usage}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Session totals cover retained reports. Input includes cache reads and writes. Missing cache counters are shown as a dash. Activity signals do not establish a completed task or its outcome."})]})]}):t.jsx("p",{className:"text-body text-muted-foreground",children:r.loading?"Loading observed session…":r.data?"This session was not found.":"Observed sessions are unavailable on this server."})]})]})}function gv(e,n={}){const s=new URLSearchParams({operation:"list-runs"});return e&&s.set("agent",e),n.status&&s.set("status",n.status),n.archived&&s.set("archived","true"),`#/playground?${s}`}const qt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),SM=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),Fg=128,CM=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},Ug=(e,n=0)=>n>Fg?'"…"':Array.isArray(e)?`[${e.map(s=>Ug(s,n+1)).join(",")}]`:qt(e)?`{${Object.keys(e).filter(s=>e[s]!==void 0).sort().map(s=>`${JSON.stringify(s)}:${Ug(e[s],n+1)}`).join(",")}}`:CM(e),EM=e=>{let n=2166136261;for(let s=0;s<e.length;s+=1)n=Math.imul(n^e.charCodeAt(s),16777619);return(n>>>0).toString(16).padStart(8,"0")},dc=(e,n)=>Object.fromEntries(Object.entries(e).filter(([s])=>s!==n)),$M=e=>{switch(e.node){case"chain":return dc(e,"steps");case"parallel":return dc(e,"branches");case"map":case"loop":return dc(e,"body");case"route":return qt(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([n,s])=>[n,qt(s)?dc(s,"body"):s]))}:e;case"workflow":return qt(e.workflow)?{...e,workflow:dc(e.workflow,"root")}:e;default:return e}};function sl(e){const n=[],s=[],r=(a,i,c,d)=>{if(!qt(a)||typeof a.node!="string"||c>Fg)return;n.push({path:i,kind:a.node,label:typeof a.label=="string"?a.label:a.node,...a.node==="call"&&typeof a.via=="string"?{via:a.via}:{},changeCheck:EM(Ug($M(a))),...TM(a,d)});const u=(f,x,b,g=i,h=d)=>{!qt(f)||typeof f.node!="string"||c+1>Fg||(s.push({from:g,to:x,kind:b}),r(f,x,c+1,h))};switch(a.node){case"chain":Array.isArray(a.steps)&&a.steps.forEach((f,x)=>u(f,`${i}/steps/${x}`,"next",x===0?i:`${i}/steps/${x-1}`));break;case"parallel":Array.isArray(a.branches)&&a.branches.forEach((f,x)=>u(f,`${i}/branches/${x}`,"branch"));break;case"map":u(a.body,`${i}/body`,"item");break;case"loop":u(a.body,`${i}/body`,"next");break;case"route":if(qt(a.branches))for(const[f,x]of Object.entries(a.branches))qt(x)&&u(x.body,`${i}/branches/${SM(f)}/body`,"route");break;case"workflow":qt(a.workflow)&&u(a.workflow.root,`${i}/workflow/root`,"child",i,qt(a.workflow.schemas)?a.workflow.schemas:{});break}};return r(qt(e)?e.root:void 0,"/root",0,qt(e)&&qt(e.schemas)?e.schemas:{}),{nodes:n,edges:s}}const _M=(e,n)=>{const s=typeof e=="string"&&Object.hasOwn(n,e)?n[e]:void 0,r=i=>{var c;for(let d=0;qt(i)&&typeof i.$ref=="string"&&d<8;d+=1){const u=(c=/^#\/definitions\/(.+)$/.exec(i.$ref))==null?void 0:c[1],f=qt(s)&&qt(s.definitions)?s.definitions:{};i=u===void 0?void 0:Object.hasOwn(f,u)?f[u]:Object.hasOwn(n,u)?n[u]:void 0}return i},a=r(s);return!qt(a)||!qt(a.properties)?[]:Object.entries(a.properties).map(([i,c])=>{const d=r(c),u=qt(d)&&typeof d.description=="string"?d.description:"",f=qt(d)?(Array.isArray(d.type)?d.type:[d.type]).filter(x=>x!=="null"):[];return qt(d)&&Array.isArray(d.enum)?{id:i,type:"choice",instructions:u,options:d.enum.map(String)}:f.length===1&&f[0]==="boolean"?{id:i,type:"noul",instructions:u}:f.length===1&&f[0]==="integer"?{id:i,type:"score",instructions:u}:{id:i,type:"unknown",instructions:u}})},TM=(e,n)=>{let s=e,r;const a=i=>typeof i=="string"?i:"";switch(e.node){case"judge":case"sift":r=_M(e.out,n);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:qt(e.branches)?Object.keys(e.branches):[]}];break;case"loop":case"escalate":{const i=e.node==="loop"?e.until:e.when;if(!qt(i)||i.predicate!=="ask")return{};s=i,r=[{id:"holds",type:"noul",instructions:a(i.instructions)}];break}default:return{}}return{...typeof s.provider=="string"?{provider:s.provider}:{},...typeof s.model=="string"?{model:s.model}:{},questions:r,...qt(s.images)&&Object.keys(s.images).length?{images:Object.keys(s.images)}:{}}};function HS(e,n){const s=S=>JSON.stringify([S.kind,S.label]),r=S=>{const N=new Map;for(const _ of S.nodes)N.set(s(_),(N.get(s(_))??0)+1);return N},[a,i]=[r(e),r(n)],c=S=>a.get(s(S))===1&&i.get(s(S))===1,d=new Map,u=new Map,f=(S,N)=>{d.set(N,S),u.set(S,N)},x=new Map(e.nodes.filter(c).map(S=>[s(S),S.path]));for(const S of n.nodes){const N=c(S)?x.get(s(S)):void 0;N!==void 0&&f(N,S.path)}const b=new Map(e.nodes.map(S=>[S.path,S])),g=[];for(const S of n.nodes){const N=b.get(S.path);d.has(S.path)||N===void 0||u.has(N.path)||(f(N.path,S.path),(N.kind!==S.kind||N.label!==S.label)&&g.push({prev:N.path,next:S.path,was:{kind:N.kind,label:N.label},now:{kind:S.kind,label:S.label}}))}const h=[];for(const S of n.nodes){const N=d.get(S.path),_=N===void 0?void 0:b.get(N);_===void 0||_.kind!==S.kind||_.label!==S.label||_.changeCheck!==void 0&&S.changeCheck!==void 0&&_.changeCheck!==S.changeCheck&&h.push({prev:_.path,next:S.path,kind:S.kind,label:S.label})}const v=({path:S,kind:N,label:_})=>({path:S,kind:N,label:_}),y=(S,N,_)=>JSON.stringify([S,N,_]),j=new Set(e.edges.map(S=>y(S.from,S.to,S.kind))),k=new Set(n.edges.map(S=>y(S.from,S.to,S.kind))),$=(S,N,_)=>{const[E,O]=[N.get(S.from),N.get(S.to)];return E!==void 0&&O!==void 0&&_.has(y(E,O,S.kind))};return{added:n.nodes.filter(S=>!d.has(S.path)).map(v),removed:e.nodes.filter(S=>!u.has(S.path)).map(v),changed:g,moved:n.nodes.flatMap(S=>{const N=d.get(S.path);return N!==void 0&&N!==S.path?[{prev:N,next:S.path}]:[]}),rewritten:h,edges:{added:n.edges.filter(S=>!$(S,d,j)).map(({from:S,to:N,kind:_})=>({from:S,to:N,kind:_})),removed:e.edges.filter(S=>!$(S,u,k)).map(({from:S,to:N,kind:_})=>({from:S,to:N,kind:_}))}}}function hn({className:e}){return t.jsx("span",{"aria-hidden":!0,className:ae("block bg-muted motion-safe:animate-pulse",e)})}function Sm({label:e,className:n,children:s}){return t.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:n,children:[s,t.jsxs("span",{className:"sr-only",children:[e,"…"]})]})}function RM(){return t.jsxs(Sm,{label:"Loading Mission Control",className:"mx-auto max-w-[1600px] space-y-8 px-6 py-8",children:[t.jsx(hn,{className:"h-8 w-56"}),t.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6",children:Array.from({length:6},(e,n)=>t.jsxs("div",{className:"border p-4",children:[t.jsx(hn,{className:"h-3 w-16"}),t.jsx(hn,{className:"mt-3 h-6 w-12"})]},n))}),t.jsx(hn,{className:"h-48 w-full"}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[t.jsx(Cf,{n:4}),t.jsx(Cf,{n:6})]})]})}function Cf({n:e}){return t.jsx("div",{className:"border",children:Array.from({length:e},(n,s)=>t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsx(hn,{className:"h-4 w-20"}),t.jsx(hn,{className:"h-4 flex-1"}),t.jsx(hn,{className:"hidden h-4 w-24 sm:block"})]},s))})}function Fn({label:e,rows:n=8}){return t.jsx(Sm,{label:e,children:t.jsx(Cf,{n})})}function AM(){return t.jsxs(Sm,{label:"Loading the run",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3 border-b pb-6",children:[t.jsx(hn,{className:"h-4 w-24"}),t.jsx(hn,{className:"h-7 w-2/3"}),t.jsx(hn,{className:"h-3 w-1/3"})]}),t.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,n)=>t.jsx(hn,{className:"h-4 w-16"},n))}),t.jsx("div",{className:"space-y-4",children:Array.from({length:5},(e,n)=>t.jsxs("div",{className:"flex gap-3",children:[t.jsx(hn,{className:"size-4 shrink-0"}),t.jsx(hn,{className:ae("h-4",n%2?"w-1/2":"w-3/4")})]},n))})]})}function OM(){return t.jsxs(Sm,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(hn,{className:"h-7 w-64"}),t.jsx(hn,{className:"h-3 w-80 max-w-full"})]}),t.jsx(hn,{className:"h-12 w-full"}),t.jsx(Cf,{n:5})]})}function Kt({problem:e,onRetry:n,link:s,className:r="m-8"}){return t.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${r}`,role:"alert",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-prose font-semibold",children:e.title}),t.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&t.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),(n||s)&&t.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[n&&t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"}),s&&t.jsx("a",{href:s.href,className:"caps border px-3 py-2 text-small hover:bg-accent",children:s.label})]})]})]})}function BS({what:e,id:n,list:s}){return t.jsx(Kt,{problem:{title:`No ${e} with this id.`,why:`This server has no ${e} ${n}.`,next:`Check the address, or find the ${e} in the list.`},link:s})}class Wg extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const Hg=e=>Math.min(1e4,1e3*2**e),rk=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),MM=e=>(e==null?void 0:e.name)==="AbortError",ok=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function PM({fetch:e=(a,i)=>globalThis.fetch(a,i),probe:n="/v2/health",resumedMs:s=5e3,probeMs:r=5e3}={}){let a={state:"online"};const i=new Set,c=new Set;let d=[],u,f=null,x=null;const b=N=>{a=N;for(const _ of[...i])_()},g=N=>{const _=Hg(N);clearTimeout(u),b({state:"offline",attempt:N,retryAt:Date.now()+_}),u=setTimeout(()=>void j(),_)},h=()=>{a.state!=="offline"&&g(0)},v=()=>{if(a.state!=="offline")return;clearTimeout(u),b({state:"resumed"});const N=d;d=[];for(const _ of N)_();for(const _ of[...c])_();u=setTimeout(()=>{a.state==="resumed"&&b({state:"online"})},s)};async function y(N){const _=setTimeout(()=>N.abort(),r);try{return!rk(await e(n,{method:"GET",cache:"no-store",credentials:"same-origin",signal:N.signal}))}catch{return!1}finally{clearTimeout(_)}}async function j(){if(a.state!=="offline")return;clearTimeout(u),f==null||f.abort();const N=f=new AbortController,_=await y(N);f===N&&(f=null,a.state==="offline"&&(_?v():g(a.attempt+1)))}const k=()=>x??(x=y(new AbortController).finally(()=>{x=null})),$=N=>new Promise((_,E)=>{if(N!=null&&N.aborted)return E(ok(N));const O=()=>{d=d.filter(I=>I!==A),E(ok(N))},A=()=>{N==null||N.removeEventListener("abort",O),_()};d.push(A),N==null||N.addEventListener("abort",O,{once:!0})});return{fetch:async(N,_)=>{var A;const E=((_==null?void 0:_.method)??"GET").toUpperCase(),O=E==="GET"||E==="HEAD";for(let I=0;;I++){let M,R;try{M=await e(N,_)}catch(P){if((A=_==null?void 0:_.signal)!=null&&A.aborted||MM(P))throw P;R=P}if(M&&!rk(M))return v(),M;if(a.state!=="offline"&&await k()){if(M)return M;if(!O)throw new Wg;if(I>=2)throw R;await new Promise(P=>setTimeout(P,Hg(I)));continue}if(h(),!O)throw new Wg;await $(_==null?void 0:_.signal)}},link:()=>a,subscribe:N=>(i.add(N),()=>{i.delete(N)}),onResume:N=>(c.add(N),()=>{c.delete(N)}),retryNow:()=>void j()}}const LM=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),GS=e=>e instanceof Wg||e instanceof TypeError&&/fetch|network/i.test(e.message);function Ft(e,n){const s=`${LM(n)} could not be read.`;if(GS(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof ze))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(" · "),i=(c,d)=>({title:s,why:c,next:d,said:r,code:a});return e.status===401?i("This browser is signed out.","Reload the page to sign in again."):e.status===403?i("The server doesn't allow this here.","Sign in as the server's owner, or open the console from the address the server printed."):e.status===404?i("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===429?i("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?i("The server is busy.","Try again in a moment."):e.status>=500?i("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):i("The server turned the request down.","Its words say why: change what they name, then try again.")}function IM(e){return GS(e)?"Can't reach agentrun-serve":e instanceof ze?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}function zM({agent:e,v2:n}){const[s,r]=p.useState(null),[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[x,b]=p.useState(null),g=p.useRef(0),h=p.useRef(!1),v=async y=>{if(h.current)return;h.current=!0;const j=++g.current;f(!0);try{const k=await n.listRevisions(e.agent_id,y);if(j!==g.current)return;r($=>{const S=new Map((y?$??[]:[]).map(N=>[N.revision,N]));for(const N of k.revisions)S.set(N.revision,N);return[...S.values()]}),i(k.next_cursor),d(null)}catch(k){j===g.current&&d(Ft(k,y?"more versions":"the versions"))}finally{j===g.current&&(h.current=!1,f(!1))}};return p.useEffect(()=>(h.current=!1,r(null),i(null),d(null),b(null),v(null),()=>{g.current++,h.current=!1}),[n,e.agent_id,e.revision,e.revisions]),c&&!s?t.jsx(Kt,{problem:c,onRetry:()=>void v(null),className:""}):s?t.jsxs("section",{className:"overflow-hidden border","aria-label":"Agent versions",children:[t.jsxs("div",{className:"border-b px-4 py-3 text-body text-muted-foreground",children:[e.revisions," ",e.revisions===1?"version":"versions"," · Current version ",e.definition.version]}),s.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Versions",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Version","Created","Note","Configuration"].map(y=>t.jsx("th",{className:"px-4 py-3 font-semibold",children:y},y))})}),t.jsx("tbody",{children:s.map(y=>t.jsxs(p.Fragment,{children:[t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsxs("td",{className:"whitespace-nowrap px-4 py-3",children:[t.jsxs("span",{className:"font-semibold",children:["v",y.version]}),y.revision===e.revision&&t.jsx("span",{className:"ml-2 bg-primary/10 px-2 py-1 text-micro text-primary-text",children:"Current"})]}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:mt(y.created_at)}),t.jsx("td",{className:"min-w-40 px-4 py-3 text-muted-foreground",children:y.note||"—"}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(B,{size:"sm","aria-expanded":x===y.revision,"aria-label":`View configuration for version ${y.version}`,onClick:()=>b(j=>j===y.revision?null:y.revision),children:x===y.revision?"Hide":"View"})})]}),x===y.revision&&t.jsx("tr",{className:"border-b bg-card",children:t.jsxs("td",{colSpan:4,className:"p-4",children:[t.jsx("p",{className:"mb-3 break-all font-mono text-label text-muted-foreground",children:y.revision}),t.jsx("pre",{"aria-label":`Version ${y.version} configuration`,className:"max-h-[520px] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:JSON.stringify(y.definition,null,2)})]})})]},y.revision))})]})}):t.jsx("p",{className:"p-10 text-center text-body text-muted-foreground",children:"No versions were returned for this agent."}),c&&t.jsx(Kt,{problem:c,className:"m-4"}),a&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",disabled:u,onClick:()=>void v(a),children:u?"Loading":"Load more versions"})})]}):t.jsx(Fn,{label:"Loading versions",rows:4})}const qS=(e,n)=>e.name.localeCompare(n.name,void 0,{sensitivity:"base",numeric:!0})||(e.id<n.id?-1:e.id>n.id?1:0),sd=e=>[...e].sort((n,s)=>qS({name:n.definition.name||n.agent_id,id:n.agent_id},{name:s.definition.name||s.agent_id,id:s.agent_id}));function DM(e){return e.usd===null?{total:"Unknown"}:{total:Zr({usd:e.usd,basis:"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}const xv=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],Bi=864e5,Bg=e=>Math.floor(e/Bi)*Bi;function vv(e,n=Date.now()){var r;const s=(r=xv.find(a=>a.id===e))==null?void 0:r.days;return s?new Date(Bg(n)-(s-1)*Bi).toISOString():void 0}const KS=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function FM(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 UM(e){if(e.input===null||e.cache_read===null||e.cache_write===null)return null;const n=e.input+e.cache_read+e.cache_write;return n?e.cache_read/n:null}const VS=(e,n)=>DM({usd:e.cost_usd,unknownRuns:e.unknown_cost_runs}),yv=e=>e.runs_with_metrics<e.runs?`tokens from ${e.runs_with_metrics} of ${e.runs} runs`:void 0;function Wa(e){return e===null?"Unknown":IS(e)}const Ef=e=>e===null?"—":`${Math.round(e*100)}%`;function ak(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function WM(e,n,s=Date.now()){if(!e.length)return[];const r=Bg(s),a=Math.max(r-29*Bi,n?Bg(Date.parse(n)):r-29*Bi),i=new Map(e.map(d=>[d.day,d])),c=[];for(let d=a;d<=r;d+=Bi){const u=new Date(d).toISOString().slice(0,10);c.push(i.get(u)??{day:u,runs:0,completed:0,failed:0,needs_review:0,runs_with_metrics:0,tokens:0,cost_usd:null,unknown_cost_runs:0})}return c}function HM(e,n){return{agents:e.agents,runs:{total:e.runs.total,active:e.runs.active,needsInput:e.runs.needs_input,failed:e.runs.failed,statusUnknown:e.runs.status_unknown,needsReview:e.runs.needs_review},perAgent:e.per_agent.map(s=>({agentId:s.agent_id,name:s.name,runs:s.runs})).sort((s,r)=>qS({name:s.name,id:s.agentId},{name:r.name,id:r.agentId})),cost:{usd:e.cost.usd,basis:e.cost.basis,unknownRuns:e.cost.unknown_runs},recent:n,analytics:e.analytics}}function YS({range:e,onRange:n,agent:s,agents:r,onAgent:a}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(Zc,{label:"Range",name:"mission-range",value:e,onChange:n,size:"sm",options:xv.map(i=>({value:i.id,label:i.label}))}),a&&r.length>0&&t.jsx(At,{label:"Agent",value:s??"",onChange:i=>a(i||null),className:"h-control-sm w-56",options:[{value:"",label:"All agents"},...r.map(i=>({value:i.agentId,label:i.name}))]})]})}const of=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function QS({a:e,basis:n,now:s=Date.now(),refreshing:r=!1}){const a=e.totals,i=UM(a),c=KS(a),d=VS(a),u=[{label:"Tokens",value:Wa(a.tokens),notes:[`${i===null?"":`${Ef(i)} of input cached · `}${Wa(a.output)} output`,yv(a),a.requests===null||a.unmetered===null?"Model request counts unavailable":a.unmetered?`${of(a.unmetered,"request")} with no token count`:void 0]},{label:"Run time",value:ak(e.time.wall_ms),notes:[`wall time of ${of(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${ak(e.time.active_ms)} active, over ${of(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:Ef(c),notes:[a.completed+a.failed?FM(a):"No run completed or failed yet"]},{label:"Cost",value:d.total,notes:[d.note]}];return t.jsxs("div",{className:ae("space-y-6 transition-opacity",r&&"opacity-60"),"aria-busy":r,children:[t.jsx("ul",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4",children:u.map(f=>t.jsxs("li",{className:"border bg-card p-5",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:f.label}),t.jsx("p",{className:"mt-3 font-mono text-2xl leading-tight",children:f.value}),f.notes.filter(Boolean).map(x=>t.jsx("p",{className:"mt-2 text-small leading-relaxed text-muted-foreground",children:x},x))]},f.label))}),t.jsx(KM,{days:WM(e.by_day,e.filter.from,s)}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[t.jsx(BM,{rows:e.by_harness_effort,basis:n}),t.jsx(GM,{tools:e.tools})]}),t.jsx(qM,{groups:e.by_source})]})}function Li({title:e,children:n}){return t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsx("h3",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:e}),n]})}const JS="px-4 py-2 text-left font-normal",jr="px-4 py-2.5 align-top";function BM({rows:e,basis:n}){return t.jsx(Li,{title:"Success by harness and effort",children:e.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Harness","Effort","Runs","Success","Tokens","Cost"].map(s=>t.jsx("th",{className:JS,children:s},s))})}),t.jsx("tbody",{children:e.map(s=>{const r=VS(s),a=yv(s);return t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:jr,children:s.harness}),t.jsx("td",{className:ae(jr,!s.effort&&"text-muted-foreground"),children:s.effort??"unset"}),t.jsx("td",{className:jr,children:s.runs}),t.jsx("td",{className:jr,children:Ef(KS(s))}),t.jsxs("td",{className:jr,children:[t.jsx("span",{className:"whitespace-nowrap",children:Wa(s.tokens)}),a&&t.jsx("span",{className:"block text-label text-muted-foreground",children:a})]}),t.jsxs("td",{className:jr,children:[t.jsx("span",{className:"whitespace-nowrap",children:r.total}),r.note&&t.jsx("span",{className:"block text-label text-muted-foreground",children:r.note})]})]},`${s.harness}:${s.effort??""}`)})})]})}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs in this range."})})}function GM({tools:e}){return t.jsx(Li,{title:"Top tools",children:e.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Tool","Calls","Errors","Error rate"].map(n=>t.jsx("th",{className:JS,children:n},n))})}),t.jsx("tbody",{children:e.map(n=>t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:jr,title:n.tool,children:n.label}),t.jsx("td",{className:jr,children:Wa(n.calls)}),t.jsx("td",{className:ae(jr,n.errors>0&&"text-destructive-text"),children:Wa(n.errors)}),t.jsx("td",{className:jr,children:Ef(n.calls?n.errors/n.calls:null)})]},n.tool))})]})}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No tool calls in runs with metrics."})})}function qM({groups:e}){return e.some(n=>n.source!=="live"&&n.runs>0)?t.jsx("p",{className:"font-mono text-small text-muted-foreground","aria-label":"Runs by source",children:e.map(n=>`${n.source==="live"?"Run here":`Imported from ${n.source}`}: ${of(n.runs,"run")}`).join(" · ")}):null}const Zp=e=>Math.max(0,e.runs-e.completed-e.failed);function ik(e){if(e<=0)return 1;const n=10**Math.floor(Math.log10(e));return[1,2,5,10].map(s=>s*n).find(s=>s>=e)}const eg=e=>e.slice(5);function KM({days:e}){const n=e.some(d=>d.runs>0),s=t.jsxs(t.Fragment,{children:[t.jsx(Q_,{className:"size-4","aria-hidden":!0}),"Run activity"]}),r=t.jsxs(t.Fragment,{children:[t.jsx(sT,{className:"size-4","aria-hidden":!0}),"Token usage"]});if(!n)return t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[t.jsx(Li,{title:s,children:t.jsxs("p",{className:"flex min-h-[220px] items-center justify-center px-5 py-6 text-center text-body text-muted-foreground",children:["No runs started in this range",e.length?" in the last 30 days":"","."]})}),t.jsx(Li,{title:r,children:t.jsx("p",{className:"flex min-h-[220px] items-center justify-center px-5 py-6 text-center text-body text-muted-foreground",children:"No token usage in this range."})})]});const a=ik(Math.max(...e.map(d=>d.runs))),i=ik(Math.max(...e.flatMap(d=>d.tokens===null?[]:[d.tokens]),0)),c=[{key:"completed",label:"Completed",className:"bg-muted-foreground",of:d=>d.completed},{key:"failed",label:"Failed",className:"bg-destructive",of:d=>d.failed},{key:"other",label:"Other",className:"bg-border-strong",of:Zp}];return t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-small text-muted-foreground",children:`Per day, ${e[0].day} to ${e.at(-1).day} (UTC)`}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[t.jsx(Li,{title:s,children:t.jsxs("figure",{className:"p-5",children:[t.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-small",children:[t.jsx("span",{className:"font-semibold",children:"Runs"}),c.map(d=>t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx("span",{className:ae("inline-block size-2.5 ",d.className),"aria-hidden":!0}),d.label]},d.key))]}),t.jsx(lk,{days:e,top:a,label:"Runs per day",stack:d=>c.map(u=>({className:u.className,value:u.of(d)})),readout:d=>[`${d.runs} ${d.runs===1?"run":"runs"}`,`${d.completed} completed · ${d.failed} failed · ${Zp(d)} other`]})]})}),t.jsx(Li,{title:r,children:t.jsxs("figure",{className:"p-5",children:[t.jsxs("figcaption",{className:"mb-2 text-small font-semibold",children:["Tokens",e.some(d=>d.tokens===null)&&t.jsx("span",{className:"ml-2 font-normal text-muted-foreground",children:"? means unavailable"})]}),t.jsx(lk,{days:e,top:i,label:"Tokens per day",format:Wa,stack:d=>[{className:"bg-primary",value:d.tokens}],readout:d=>[`${Wa(d.tokens)} tokens`,yv(d)??`${d.runs} ${d.runs===1?"run":"runs"}`]})]})})]}),t.jsxs("details",{className:"border bg-card px-5 py-3",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Day","Runs","Completed","Failed","Other","Tokens"].map(d=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:d},d))})}),t.jsx("tbody",{children:e.map(d=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:d.day}),t.jsx("td",{className:"pr-4",children:d.runs}),t.jsx("td",{className:"pr-4",children:d.completed}),t.jsx("td",{className:"pr-4",children:d.failed}),t.jsx("td",{className:"pr-4",children:Zp(d)}),t.jsx("td",{className:"pr-4",children:d.tokens===null?"Unknown":d.tokens.toLocaleString("en-US")})]},d.day))})]})})]})]})}function lk({days:e,top:n,label:s,stack:r,readout:a,format:i=c=>c.toLocaleString("en-US")}){const[d,u]=p.useState(null),[f,x]=p.useState(null),b=e.find(g=>g.day===(d??f));return t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"flex w-10 shrink-0 flex-col justify-between text-right font-mono text-micro text-muted-foreground",style:{height:140},"aria-hidden":!0,children:[t.jsx("span",{children:i(n)}),t.jsx("span",{children:i(n/2)}),t.jsx("span",{children:"0"})]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"relative flex items-end gap-px border-b border-border-strong",style:{height:140},role:"list","aria-label":s,onMouseLeave:()=>u(null),children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-border","aria-hidden":!0}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-border","aria-hidden":!0}),e.map(g=>{const h=r(g),v=h.some(j=>j.value===null),y=h.filter(j=>j.value!==null&&j.value>0);return t.jsxs("div",{role:"listitem",tabIndex:0,"aria-label":`${g.day}: ${a(g).join(", ")}`,onMouseEnter:()=>u(g.day),onFocus:()=>x(g.day),onBlur:()=>x(null),className:"group relative flex h-full min-w-0 flex-1 flex-col items-center justify-end focus-visible:outline-focus focus-visible:outline-ring hover:bg-accent/60 focus-visible:bg-accent/60",children:[v&&t.jsx("span",{"aria-hidden":!0,className:"font-mono text-small text-muted-foreground",children:"?"}),t.jsx("div",{className:"flex w-full max-w-6 flex-col-reverse gap-0.5",children:y.map((j,k)=>t.jsx("div",{className:j.className,style:{height:Math.max(1,Math.round(j.value/n*(140-2*(y.length-1))))}},k))})]},g.day)})]}),t.jsxs("div",{className:"mt-1 flex justify-between font-mono text-micro text-muted-foreground","aria-hidden":!0,children:[t.jsx("span",{children:eg(e[0].day)}),e.length>2&&t.jsx("span",{children:eg(e[Math.floor(e.length/2)].day)}),t.jsx("span",{children:eg(e.at(-1).day)})]}),t.jsx("div",{"aria-label":`${s} readout`,className:"mt-2 min-h-16 break-words font-mono text-label text-muted-foreground",children:b?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block font-semibold text-foreground",children:a(b)[0]}),a(b).slice(1).map(g=>t.jsx("span",{className:"block",children:g},g)),t.jsx("span",{className:"block",children:b.day})]}):"Hover or focus a day for its figures."})]})]})}const sn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),af=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function VM(e){const n=new Map;let s=0;const r=d=>{throw Object.assign(new Error(d),{offset:s})},a=()=>{for(;s<e.length&&`
|
|
573
|
+
\r`.includes(e[s]);)s++},i=()=>{const d=s;for(s++;s<e.length&&e[s]!=='"';)e[s]==="\\"?s++:e.charCodeAt(s)<32&&r("a string cannot hold a raw line break or control character"),s++;s>=e.length&&(s=d,r("this string is not closed")),s++;try{return JSON.parse(e.slice(d,s))}catch{return s=d,r("this string has a bad escape")}},c=d=>{a();const u=s;let f;const x=e[s];if(x==="{"){s++;const b={};if(a(),e[s]==="}")s++;else for(;;){a(),e[s]!=='"'&&r(e[s]==="}"?"a trailing comma before }":"expected a key in double quotes");const g=i();if(a(),e[s]!==":"&&r("expected : after the key"),s++,b[g]=c(`${d}/${af(g)}`),a(),e[s]===","){s++;continue}if(e[s]==="}"){s++;break}r("expected , or } after the value")}f=b}else if(x==="["){s++;const b=[];if(a(),e[s]==="]")s++;else for(;;){if(b.push(c(`${d}/${b.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")}f=b}else if(x==='"')f=i();else{const b=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(e.slice(s,s+400));b||r(s>=e.length?"the text ends before the value":"expected a value"),s+=b[0].length,f=JSON.parse(b[0])}return n.set(d,{start:u,end:s}),f};try{const d=c("");return a(),s<e.length&&r("text after the end of the JSON"),{ok:!0,value:d,spans:n}}catch(d){return{ok:!1,error:{message:d.message,offset:d.offset??0}}}}function YM(e,n){let s=1,r=-1;for(let a=0;a<Math.min(n,e.length);a++)e[a]===`
|
|
574
|
+
`&&(s++,r=a);return{line:s,col:n-r}}function XS(e,n){let s=e;for(const r of n.split("/").slice(1)){const a=r.replace(/~1/g,"/").replace(/~0/g,"~");if(Array.isArray(s))s=s[Number(a)];else if(sn(s))s=Object.prototype.hasOwnProperty.call(s,a)?s[a]:void 0;else return}return s}const ZS=new Set(["judge","pick","sift","route"]),ck=["jev","parallel","openrouter"];function QM(e){return!sn(e)||!sn(e.properties)?[]:Object.entries(e.properties).flatMap(([n,s])=>{if(!sn(s))return[];const r=typeof s.description=="string"?s.description:n;return Array.isArray(s.enum)?[{id:n,type:"choice",text:r,options:s.enum.map(String)}]:s.type==="boolean"?[{id:n,type:"noul",text:r}]:s.type==="integer"?[{id:n,type:"score",text:r}]:[{id:n,type:"choice",text:r}]})}function bv(e,n,s){const r=XS(e,n);if(!sn(r))return{decision:!1};const a=r.node,i=s??{},c=a==="route"&&typeof r.valuePath=="string",d=typeof a=="string"&&ZS.has(a)&&!c||Array.isArray(i.questions);if(!d)return{decision:!1,...a==="call"&&typeof r.tool=="string"?{tool:r.tool}:{}};const u=typeof i.provider=="string"?i.provider:typeof r.provider=="string"?r.provider:"jev",f=typeof i.model=="string"?i.model:typeof r.model=="string"?r.model:void 0,x=sn(e)&&sn(e.schemas)?e.schemas:{};let b=[];Array.isArray(i.questions)?b=i.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"?b=typeof r.out=="string"?QM(x[r.out]):[]:a==="pick"?b=[{id:"pick",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Pick one"}]:a==="route"&&(b=[{id:"branch",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Which branch?",options:sn(r.branches)?Object.keys(r.branches):[]}]);const g=Array.isArray(i.images)?i.images.map(String):sn(r.images)?Object.keys(r.images):[],h=sn(r.unsure)&&typeof r.unsure.branch=="string"&&typeof r.unsure.gte=="number"?{branch:r.unsure.branch,gte:r.unsure.gte}:void 0;return{decision:d,provider:u,model:f,questions:b,...g.length?{images:g}:{},web:u==="parallel",...h?{unsure:h}:{}}}const JM=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function XM(e){const n=[],s=(d,u)=>n.push({path:d,message:u,severity:"error"}),r=(d,u)=>n.push({path:d,message:u,severity:"warning"});if(!sn(e))return s("","the workflow is a JSON object"),n;e.v!==2&&s("/v",'the workflow format is "v": 2'),(typeof e.name!="string"||!e.name)&&s("/name","the workflow needs a name");const a=sn(e.schemas)?e.schemas:{};sn(e.input)&&typeof e.input.schemaId=="string"&&!a[e.input.schemaId]&&s("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),sn(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 i=new Map,c=(d,u)=>{if(!sn(d)){s(u,'expected a node (an object with a "node" kind)');return}const f=d.node;if(typeof f!="string"||!JM.has(f)){s(`${u}/node`,typeof f=="string"?`"${f}" is not a node kind`:'a node names its kind in "node"');return}f!=="chain"&&(typeof d.label!="string"||!d.label?s(u,`a ${f} node needs a label`):i.has(d.label)?r(`${u}/label`,`the label "${d.label}" is also used at ${i.get(d.label)}; receipts name nodes by label`):i.set(d.label,u));const x=(g,h)=>{d[g]===void 0&&s(u,`a ${f} node needs ${g} (${h})`)},b=g=>{typeof d[g]=="string"&&!a[d[g]]&&s(`${u}/${g}`,`no schema "${d[g]}" in schemas`)};switch(f){case"chain":!Array.isArray(d.steps)||!d.steps.length?s(u,"a chain needs steps"):d.steps.forEach((g,h)=>c(g,`${u}/steps/${h}`));break;case"parallel":!Array.isArray(d.branches)||!d.branches.length?s(u,"a parallel node needs branches"):d.branches.forEach((g,h)=>c(g,`${u}/branches/${h}`));break;case"map":x("itemsPath","where the items are"),x("as","where the results go"),c(d.body,`${u}/body`);break;case"loop":x("until","when it stops"),x("maxIters","a bound"),c(d.body,`${u}/body`);break;case"workflow":sn(d.workflow)?c(d.workflow.root,`${u}/workflow/root`):s(u,"a workflow node embeds its workflow");break;case"call":x("via","tool, executor or shell"),d.via==="tool"&&x("tool","the tool's name");break;case"code":typeof d.code!="string"&&s(u,"a code node needs code");break;case"escalate":x("when","the predicate that fires it"),x("kind","the review it asks for");break;case"judge":case"sift":x("out","the questions' schema"),b("out"),x("as","where the answers go");break;case"pick":x("itemsPath","the options' list"),x("as","where the pick goes");break;case"agent":case"decide":case"extract":b("out");break}if(f==="route"){if(!sn(d.branches)||!Object.keys(d.branches).length)s(u,"a route needs branches");else for(const[g,h]of Object.entries(d.branches))sn(h)?c(h.body,`${u}/branches/${af(g)}/body`):s(`${u}/branches/${af(g)}`,`branch "${g}" is an object with a body`);typeof d.valuePath!="string"&&d.instructions===void 0&&s(u,"a route asks by instructions (and state), or reads a valuePath"),sn(d.unsure)&&sn(d.branches)&&typeof d.unsure.branch=="string"&&!(d.unsure.branch in d.branches)&&s(`${u}/unsure/branch`,`the unsure branch "${d.unsure.branch}" is not one of the branches`)}if(ZS.has(f)&&!(f==="route"&&typeof d.valuePath=="string")&&(d.provider!==void 0&&!ck.includes(d.provider)&&r(`${u}/provider`,`provider "${String(d.provider)}" is not one of ${ck.join(", ")}`),d.provider==="openrouter"&&typeof d.model!="string"&&s(u,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),sn(d.images))){const g=JSON.stringify(d.state??{})+JSON.stringify(d.instructions??"")+(typeof d.out=="string"?JSON.stringify(a[d.out]??{}):"");for(const h of Object.keys(d.images))g.includes(h)||s(`${u}/images/${af(h)}`,`the image token "${h}" must appear in the state or a question, or the model never sees it`)}};return e.root===void 0?s("","the workflow needs a root node"):c(e.root,"/root"),n}function dk(e,n){for(let s=n;;s=s.slice(0,s.lastIndexOf("/"))){const r=e.get(s);if(r)return r;if(!s)return}}function ZM(e,n,s){let r=null,a=1/0;for(const i of n){const c=e.get(i);c&&c.start<=s&&s<=c.end&&c.end-c.start<a&&(r=i,a=c.end-c.start)}return r}function eP(e){const n=sl(e),r=n.nodes.map(i=>bv(e,i.path,i)).filter(i=>i.decision),a=[...new Set(r.map(i=>i.provider??"jev"))];return`${n.nodes.length} nodes · ${r.length} ${r.length===1?"decision":"decisions"}${a.length?` · ${a.join(", ")}`:""}`}const $f=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,uk=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),rd=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function od(e,n){return Object.fromEntries(n.nodes.map(s=>[s.path,bv(e,s.path,s)]))}const Pu=e=>e>=.995?"1.00":e.toFixed(2);function rl(e){var d;if(e.status==="failed")return"failed";if(e.status==="cancelled")return"interrupted";const n=e.answers??{},s=e.action;if(((d=e.rule)==null?void 0:d.kind)==="route"&&s&&typeof s=="object"&&(s.taken||s.branch)){const u=n.branch,f=u&&u.type==="choice"?u.confidence:void 0;return s.unsure?`${s.taken} (unsure)`:`${s.taken??s.branch}${f!==void 0?` ${Pu(f)}`:""}`}const r=Object.keys(n);if(!r.length)return;const a=u=>{const f=n[u];return f.type==="choice"?`${e2(e,u,f.choice)} ${Pu(f.probabilities[f.choice]??f.confidence)}`:f.type==="noul"?`${f.noul>=.5?"yes":"no"} ${Pu(f.noul>=.5?f.noul:1-f.noul)}`:f.type==="score"?`${f.score} ${Pu(f.confidence)}`:f.type==="refusal"?"refused":"box"};if(r.length===1)return a(r[0]);const i=u=>{const f=n[u];return f.type==="noul"?Math.abs(f.noul-.5)*2:"confidence"in f&&typeof f.confidence=="number"?f.confidence:1},c=r.reduce((u,f)=>i(f)<i(u)?f:u,r[0]);return`${c} ${a(c)}`}function e2(e,n,s){var i,c;const r=(i=e.questions)==null?void 0:i[n],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 t2=(e,n)=>e.nodes.filter(s=>s.path.startsWith(`${n}/body`)).map(s=>s.path);function tP(e,n,s){var b,g;const r=(g=(b=e.nodes[n])==null?void 0:b.items)==null?void 0:g.find(h=>h.index===s),a={};if(!r)return a;const i=new Set(["chain","parallel","route","map","loop","workflow"]),c=new Map(e.graph.nodes.map(h=>[h.path,h.kind])),d=t2(e.graph,n).filter(h=>!i.has(c.get(h)??""));let u=-1;d.forEach((h,v)=>{const y=e.decisions.filter(k=>k.node===h&&k.item===s),j=e.effects.filter(k=>k.node===h&&k.item===s);!y.length&&!j.length||(u=v,y.some(k=>k.status==="failed")||j.some(k=>k.status==="failed")?a[h]="failed":y.some(k=>k.status==="cancelled")?a[h]="review":j.some(k=>!k.endedAt)?a[h]=j.some(k=>k.status==="stopped")?"stopped":"working":a[h]="done")});const f=$f(r.status)??"pending";let x=!Object.values(a).includes("working");return d.forEach((h,v)=>{a[h]||(v<u||f==="done"?a[h]="done":f==="working"?(a[h]=x?"working":"pending",x=!1):f==="pending"?a[h]="pending":a[h]="not-run")}),a}function nP(e,n){var x,b,g;const s={},r=[],a={};let i=null;const c=new Map(e.graph.nodes.map(h=>[h.path,h.kind]));for(const[h,v]of Object.entries(e.nodes)){const y=$f(v.status);y&&(s[h]=y),v.branch&&r.push(`${h}/branches/${uk(v.branch)}/body`),v.items&&(a[h]=v.items.map(j=>({index:j.index,status:$f(j.status)??"pending",label:Lc(e,h,j.index),...wv(e,h,j)}))),v.status==="escalated"&&c.get(h)==="escalate"&&(i=h)}const d={},u=h=>/\/body(\/|$)/.test(h)&&e.graph.nodes.some(v=>v.kind==="map"&&h.startsWith(`${v.path}/body`));for(const h of e.decisions){if(!h.node||h.item!==null||u(h.node))continue;const v=rl(h);v&&(d[h.node]=v)}if(n&&n.item!=null&&c.get(n.path)==="map"){Object.assign(s,tP(e,n.path,n.item));const h=((g=(b=(x=e.nodes[n.path])==null?void 0:x.items)==null?void 0:b.find(v=>v.index===n.item))==null?void 0:g.branches)??{};for(const[v,y]of Object.entries(h)){const j=`${v}/branches/`,k=`${j}${uk(y)}/body`;for(let $=r.length-1;$>=0;$--)r[$].startsWith(j)&&r.splice($,1);r.push(k);for(const $ of e.graph.nodes)$.path.startsWith(j)&&!($.path===k||$.path.startsWith(`${k}/`))&&(s[$.path]="not-run")}for(const v of e.decisions)if(v.node&&v.item===n.item&&v.node.startsWith(`${n.path}/body`)){const y=rl(v);y&&(d[v.node]=y)}}if(e.run.paused){for(const[h,v]of Object.entries(s))v==="working"&&(s[h]="held");for(const h of Object.values(a))for(const v of h)v.status==="working"&&(v.status="held")}const f={};for(const[h,v]of Object.entries(e.nodes))v.model&&(f[h]={model:v.model,...v.tier?{tier:v.tier}:{}});return{status:s,taken:r,items:a,fired:i,verdict:d,meta:od(e.workflow,e.graph),selected:n,...Object.keys(f).length?{ran:f}:{}}}const tg={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"},sP=e=>{if(!e)return;const n=e.toLowerCase();return tg[n]??tg[n.split(/[_\s-]/)[0]]??tg[n.split(/[_\s-]/).at(-1)??""]};function rP(e){if(e.status!=="answered"||!e.answers)return;const n=e.action,s=e.answers.branch;if(n&&typeof n=="object"&&n.taken&&(s==null?void 0:s.type)==="choice")return{p:s.confidence,note:`${e.kind} confidence`};let r;for(const[a,i]of Object.entries(e.answers)){const c=i.type==="noul"?{p:Math.max(i.noul,1-i.noul),note:`${a}: ${i.noul>=.5?"yes":"no"}, P(yes) ${i.noul.toFixed(2)}`,sure:Math.abs(i.noul-.5)}:i.type==="choice"||i.type==="score"?{p:i.confidence,note:`${a} confidence`,sure:i.confidence-.5}:void 0;c&&(!r||c.sure<r.sure)&&(r=c)}return r&&{p:r.p,note:`least sure: ${r.note}`}}function wv(e,n,s){const r=t2(e.graph,n),a=g=>g?r.indexOf(g):-1,i=e.decisions.filter(g=>{var h;return g.item===s.index&&!!((h=g.node)!=null&&h.startsWith(`${n}/body`))}).sort((g,h)=>a(g.node)-a(h.node));let c,d;const u=Object.entries(s.branches??{}).sort(([g],[h])=>a(g)-a(h));if(u.length)[d,c]=u[u.length-1];else{const g=i.filter(h=>{var v;return h.status==="answered"&&((v=h.action)==null?void 0:v.taken)}).at(-1);g&&(c=g.action.taken,d=g.node??void 0)}const f=d&&i.filter(g=>g.node===d).at(-1)||i.filter(g=>g.status==="answered").at(-1),x=f?rP(f):void 0,b=s.status==="failed"?"bad":s.status==="needs_review"||s.status==="escalated"?"warn":sP(c);return{...c?{outcome:c}:{},...x?{p:x.p,pNote:x.note}:{},...b?{tone:b}:{}}}function Lc(e,n,s){var d,u;const r=(u=(d=e.nodes[n])==null?void 0:d.items)==null?void 0:u.find(f=>f.index===s);if(r!=null&&r.label)return r.label;const a=e.effects.find(f=>{var x;return f.item===s&&!!((x=f.node)!=null&&x.startsWith(`${n}/body`))}),i=a==null?void 0:a.input,c=(i==null?void 0:i.path)??(i==null?void 0:i.url);return typeof c=="string"?c:void 0}function n2(e=[]){const n={total:e.length,done:0,working:0,failed:0,review:0,pending:0};for(const s of e)s.status==="done"?n.done++:s.status==="working"?n.working++:s.status==="failed"?n.failed++:s.status==="needs_review"||s.status==="escalated"?n.review++:n.pending++;return n}function s2(e){const n=e.decisions.filter(s=>s.cost_usd===null).length;return{usd:e.totals.cost_usd??e.decisions.reduce((s,r)=>s+(r.cost_usd??0),0),unknown:e.totals.cost_usd===null?n:0}}const vl=e=>e==null?"Unknown":e>0&&e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Gi=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function ol(e){const n=Math.max(0,Math.floor(e/1e3)),s=Math.floor(n/60);return s?`${s}m ${String(n%60).padStart(2,"0")}s`:`${n}s`}const oP=(e,n,s)=>{const r=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||n)-Date.parse(e.run.startedAt);return rd(e.run.status)||e.run.paused?r:r+Math.max(0,s-n)};function aP(e,n,s){return e!=="input_required"||n!=="waiting"?null:s.findLast(r=>r.kind==="waiting")??null}function iP(e){const n=e.content_type??"";return n.startsWith("text/markdown")||e.path.toLowerCase().endsWith(".md")?"markdown":n.startsWith("text/")||n.includes("json")?"text":"download"}function r2(e){return e.split("/").slice(0,-1).some(n=>n.startsWith(".")||n==="__pycache__"||n==="node_modules")}const o2="The agent finished without writing an answer.",fk=[0,250,1e3],lP=e=>new Promise(n=>setTimeout(n,e));function Gg(){let e=0;return{begin:()=>++e,current:n=>n===e,cancel:()=>{e++}}}const a2="30d",mk=10,cP=["queued","working","input_required","paused"];function dP({agent:e,v2:n,now:s=Date.now,stats:r}){const[a,i]=p.useState(a2),[c,d]=p.useState(r??null),[u,f]=p.useState(null),[x,b]=p.useState(!0),[g,h]=p.useState(0),v=p.useRef(0),y=p.useRef(!0);p.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);const j=p.useRef(null),k=p.useRef(null);p.useEffect(()=>{const S=`${a}/${g}`;if(k.current===S)return;const N=++v.current;if(j.current===S){k.current=null,f(null),b(!1);return}k.current=S,b(!0),f(null),(async()=>{for(const[_,E]of fk.entries()){if(E&&await lP(E),N!==v.current||!y.current)return;try{const O=await n.statsOver({from:vv(a,s()),agent:e.agent_id});if(N!==v.current||!y.current)return;const A=!(O.runs.status_unknown>0);if(d(O),j.current=A||_===fk.length-1?S:null,A)break}catch(O){N===v.current&&f(Dt(O));break}}N===v.current&&(k.current=null,b(!1))})()},[n,e.agent_id,a,g]),p.useEffect(()=>{const S=new AbortController,N=_=>({status:_,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(cP.map(_=>n.listAgentRuns(e.agent_id,mk,null,N(_)))).then(_=>{if(S.signal.aborted)return;const E=_.flatMap(O=>O.status==="fulfilled"?O.value.runs:[]).filter(O=>!rd(O.status));for(const O of E.slice(0,mk)){let A=`${O.status}/${O.state}`;US(n,O.run_id,{signal:S.signal,onPage:I=>{const M=`${I.status}/${I.state}`;M!==A&&(A=M,h(R=>R+1))}}).catch(()=>{})}}),()=>S.abort()},[n,e.agent_id]);const $=c==null?void 0:c.analytics;return t.jsxs("div",{className:"space-y-6",children:[t.jsx(YS,{range:a,onRange:i,agent:null,agents:[]}),u?t.jsxs("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:["The analytics could not be read: ",u]}):!c||!$?t.jsx("p",{className:"py-12 text-center font-mono text-body text-muted-foreground",children:"Loading analytics..."}):$.totals.runs?t.jsx(QS,{a:$,basis:c.cost.basis,now:s(),refreshing:x}):t.jsx("div",{className:"border px-4 py-12 text-center",children:t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent in this range."})})]})}const jv=["codex","codex-cli","claude","claude-cli","cursor","other"],i2="agentrun.coding-agent.v1",ng="agentrun:coding-agent",sg={codex:"Codex app","codex-cli":"Codex CLI",claude:"Claude Code app","claude-cli":"Claude Code CLI",cursor:"Cursor",other:"Other / terminal"};function hk(){try{const e=localStorage.getItem(i2);return jv.includes(e)?e:""}catch{return""}}function uP(e){try{localStorage.setItem(i2,e)}catch{}}function fP(e,n){const s=encodeURIComponent(n),r=e==="codex"?`codex://new?prompt=${s}`:e==="claude"?`claude://code/new?q=${s}`:e==="cursor"?`cursor://anysphere.cursor-deeplink/prompt?text=${s}`:null;return r&&r.length<=8e3?r:null}const mP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGgAAABoCAYAAAAdHLWhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAJnFJREFUeAHtfQuYFdWV7tpVdc7pprvpppvuhm4ejQ9AQQFFUEEUfAUVH4k448TRuT4y0UnumGiSm0y8YuZO8jlXRx0fMXGi5rtqfIyj8YWiKCoEQcGAgAEabZAG+km/+/Q5VXvfvXftvWtV9ek3oM7X6/uqq07Vrl1V699rrX+vvasaYFiGZViGZViGZViGZViG5VAKUUs3YYyRPs77byNftYfRoDCxLFu2zHrr/ZEV444Zd9KMU046c0Qia+LY8lETxx41ojDZBJ07d1Y3Upr4/NNNm/+8v7ltbePW97atWnV3faQuCl9j+aoAJO7D4osnfpz3rbumXvY3139/2nEjLystJmNLcgEcruYEL+F2AaRdBhYhEIurE7IAmjoB2rvA27ItvW3NB5UPH9j8zBNPPnlHS7Tur5t8FQCywW/l7Lqb18775lWz758xxZmVx23IdoEdqALYvYeR2gYG7a0WpDhAHi9NuMpj/MxEgkFBPsDYMYSOmwRQOBqsZAKgsh68lSv3/8d/PXH/P61f+asGfB34GsmXCZC4tlCae8bSXxbfdNOtLy08NXZqIQdlbyXQjzeBVX2AkXQXAeLwgrykxUGx+ULUXTOuasoXz/MXsTsvh8JRFRadOQsguwSsXdyGXnix5ue3/f2Yf1HXdcQ14WsiXxZAxu384M5d/+Paq496dOoogM82QXrteog1cqU6XI2xGC8kgFFRSQDUmwjT8LjqXdevfGI50HlnALVKwHlrE1Q98/DT855+9Mp9/BB3jpCCr4F8GQCZ4P2715IvXLIocaldw9x3VhLrizqwBDBxR1mKAgTj0hdIWlzuzFIpv/wJxzF39unE2doG8MhDm77xwC9mvgEBGZH39J3v/MbZsSNuFxfvps89t0xYGM1w3wBH2EUeaYAMOL9/vfOTy8/Mmr5nM3StWQOJLq6OrIQCBhQQiGhrt0aEeqyeb1y4PcPd+Jpy19fFgSouYvSsMxltyrOct95q/vG67ZtXxtrot06dN/f0xIiuieXl+QWeBTE3Ce7Bxtb21nZSR7vaN77x9qdv19R9sGbV0z+tij4DHAE5kgAZt/bY8uTmK+YnTvhkDU19vNWKC1AS8QAUguKMpf702Cnqh1BhTWkek3gDmH8apBLlEE/yfUWcXMSEmrm90JQPprwct2DC76eL/05zF9vCj23fBbtXvL3ryVUv/eb+D1f93wNwhNjhkQRIBufHXup69aLT4xdUrmepTZ+SuKDKwqVJYBA4Iu5oUIiV4a77unMGIWckyIQAQDSCslJgI/MYaWujUF9PoK3TgjQH0GMcLcpJCb94zGGQm8OguBjY+AkWKynjlWRz4pIEWPF2w0sv/9cL/7D8yRv2wmFmh0cKIAnOLb+quunGqyc+2LKddX24iSQcTgLi4vEsZT2W/7TYakCBFZKIi8v0EBIfCt0ih4hNbsq3KnFMs0KmynjMP09QeUE20imfeMTiDCaMJXTmSUDzy8HZx4F6+vnq+2777rib8TPCIZYjAZAMxouW/rr8V7/87t6RB5n7p3VE9Dsh4fjAEAWQpa1InGX5QGnrIeZP95smfbVdJg3DCDV/gm0DqKLuehHHXG55KbF0+aCNHc3YqacRr3ASOKt3wv7f3vf06S8+fmUVHAZ2eCQAEkbhPfhs8uNFUxIzN38ItKkdrDiPBw5RwChwLOXVQ8CQ8M3KRREFvS8TPma/dnWiPA3KYp8kPZsqZ4CivjkIS2NqcZVVCdJB+frYo5l7ymng1CcIPPJY1eJ7fjrpdX4K9wuQhkMkNhx+YVf/4wfzLzp34s+a9kCq+gA4mhAIQGxMCpSL6waOsizQ5dECkd897Tf1QBDdtVUy1VCwlQqxCOLhEGzY6uT9tcTa8xmhEwuod/L8UVfbBVdVr3vn/o/AB+mQsLzDDZB4FHbTj3/7WolFSj7byWzGtSX6OpoQaAsyv8VZBCkLKVxrlpEBsroMQMl9LAAL75M/iaLs4F9P7tO/1XHB9tragVRVEas0y0vPPXP0pU7h3+1Yv+q+TeDHpCGD1M9u36CFnrXk/qnjism01jpwk2nOkGzlcTJoWGYCSKQl9xBfGAmWgQh2mWBFfkPflomPi9ad4K66i7u799fYsebtnnvFNyue+v5tn80A30MOWb+HEyD56PPOueIH0ApQU8dblI4vynXI3l4GNyI6FpShHRS1XmZ2BQsJL70JgzADZxA+B19WW7KFf2Pw1D7RTRB9pnUbeGKqmneI501af9rSf8uGQ0C9DzVA2L2zs5Ytc46ZXXJFzAPalgTjnhQ5khtC8WLbgAKBAl2qACR+c2QsCNgQWTManCesMLQo+uyqtQbWA+SDtGvDKsVMD1l0pjYg8oYdnYT8mTu3wjSLX/p333td1erAEORQASTuWVi81P38G5+cdPudW+/+5dLbG04Z4RbU1knSY4IuZlIe/q2UKNmUUoTuk2hQqYoNjIWtgZkC4UUCxyKMLoMZafaGGw/eDtO+0MpsxzgUDU3E2r0X0pPt2IKrvrf2LPDb1gAdcVixQxXRQqSeL7/pD6dffvk37zttdnx28QiAxn3APvgTeNX7wRFEwFFJUMzc8LYMvPrGIkTB6uHmtZJ6amm9tUCjfGy5qIFIa9NWRIPGIhbR4tLU3y+2U2I/J9fJtH/No44G2poHe29cSiaC6mrAIGQoAGmrcc++8t7Sb191/R8XL8yZG+8Ctms787ZsIXZdHS9j+3k2R4/nENQpRWkdTRrMGgUDTL6iN0AyHejrrrH1KMGdV9NZReB4yhJFukj/Fi6YKaBEtiHt+esu7s6LisDNmwjOO2s3nP/k/bNXwCBlsP5Rxxr35n/def0NNxzzSCG/+S1rIb1hA3Oa24gjAqfITgurETGE6nhj+du2orQWUpDk5BDEJUmD9U4IGBfBKRzwj1u9gaTLM+hVMCC6XjkgqMHRFqP2gdqWHV1A1scbY0MjOLFsYEcdM+0XfO8KMF3lgclg+kG64dKHl6dfvGLJ6B+1VrH0H1/kAXIbOB7v6GRlgZwvIEZBtZUwlWvTWQCGagv5chZqyKFtHXsyhBozupppwXFKlu+hnEcj+wABQYN90oLAtyZPWZWH3Z8ai7IZZXllsfFN+8c9XF39chsMQgZqQQacR17p+mTeTGf6ptUste4jiIsbHZHlW4wAIEp5baUgz/Ldl2UFuS4LMTtLAagtCli42Rm3FtkXzVISBn3n6JTQaLumAZCgXZ1ae14QmzQYGjQZozSB4TfV0sGfsp7n7o4/aSmsgwdgEDIQgLRb8379ctcnJ58Qn/7eCpba+hcSF1lpEWcECrjzaNYQ9De0nQs3xZR/E4oIAaNcEmXhi2Mv1WM8UmIA7qdT0QxOn0zRWtN4bTlyG8ciBZoXAUlYURMfOaqYMu0iftqgABqIi5Ns7b6X3FdnTI7NW/ceTW3bYcUdMZ4TA5O2wWuCBuCiGmRK21Ip2tpYN/Yb0GQWuDHszgDvQy1fB/RMrs+UjcQVPWZEEUnQCscWI8FAAOnj2uXpY65PGlh8lDOyvGDbPdu2beunTYeV3h+RbO3v7znw/SlH2xds2ci6/rLTSog4o12ajCtoLYkBBMAwpXFqmeISFILIgqa98pTIo2ACgUWfA/h4xCdGz2HoHBwAdSMwdSMioMmAzGqra7g0AMZFgHuYXHhAsl0oSjrnjAJ4rh4GKP0BSMacBZfcPf68+aX/XruTup98aiWsmJ8s7AaMIgCMoN9ihx3EGKrK2Mhfa8XgNIsQ4+7ULpapDWZQtoVAk6kitW2yRypG4eoYDZ9jLDgSZ7D1GZAQ9dakQU0JY9yK7OamxvG8isMCkIw7F1/7w5dTzQy2/MWyhB9OKLcGaNHDBCGgQMUeBIy2Brmtjok6CWrtGgyKUizyZljoZzjDrBSswdR1EI1MJB4ZWhw531gSdnUQAUi7PxoAxSLuUnV25eVTQMfAIKQvgMRjeX9969qzikfDjN2fQpoPtsXi8SDOaGA0INQKhq+1t7FU8JeuzPLB6OKjk8mkn1kYkeMnHImyJj0MoN0TbuXYDTK8HTIFgG59HoMCQLRDGq487OrMgB0EwAALuzHt/ozVsCD35z8SJRb5Ls+t/BMMVPoDEJs8deqDHdw499XwdJPjuzbNwIiuwQqvmTpb68NSZiMAbGykMP3oNEybnOBAUfjTxhQ0tSSgYCQxCuvJUkJpGVUOb0eJBrYaeQs0g5tElocZnFwpQEyHFAGiCYWH4w5D9FsDzVswZS8Naii8L4DokiufmjZ2QsHx9bvBTbnEEazNTPIgwUIQQFJBFvL5VgBSQ6MHf7WYwtwZCZkisfiJ8+bE4dFnu+DzvVkwMhdMh1BIFBizqV0QBFZGIzGIRqwK95UspTxcl1xpdBFQxnrUOcaqEDghi/JP05ZHhJaznOqDMAjpM5tddsKiWzp41Y1N4BCV7NQuDOywe2MoHjHl+ig61toJMGsa4+DEoHI/g921ALt4P6GuhcDV34zzh0pBl4o7Wk9myACCzDeNLJ5SrNnH/EkBHvodpedpFsw5oGrbYxEmpvo9Hg2GQzQYHqBtdA6DgFTIcwgw0U/MyinaC4OQ3gCStjH+mNIL+bAuTfEnsPmFqANmbpQGysJkAdWqx360VSV5JbOOA+gUxs4ZgUgFiRR9U7uYi2bBxWdzmnPQp1waFNP3UXWkMwFC/AyFBjGUqlHKdzMco0rRLlI+ReXlosHDMUb9dlE9uHEwCECTc8ttaKvbWVMLhxggNueyB47lwbsklVQ+3g6y0QT1d5i2JkSt9eCcdm9+n4j4gyORq4q4tqcOYM6JMRhdkJJDyNpSPOVCzTYoBUBYKab1gg+W7ofhctE8nhc5X1uFdpdRq9OAGwsh4eviOoWowUbS2NqxZcOGZR0wCOnVxZWWzZjbwt1bV5qHCkfdiErnmDEczeRIAAhELEdvJ3JsWPcJ5f6YhSI1UQrpcglcfr4FdU18CNY2D2gemqmMg942o7MKRKEwl6AWrM9RblO7y1BL13WrJWRtyLXKuiFcRxRw8xt10hnXW2drcrt61BgcSoAst3yu5vgmhaNBwP0fpQgztxpZjoxFahZPNk+mbtxhwef70jCmkMiUiLkWB2QfZ4rHTYrD5IlpaE+qB1RWaZRIEFCRRUMuf1uBgilmllj5BIGggNSNC1sDy7DQyLZuDDptJe+R7xyZzbxZJxVe81c3r14MvoceUIK6V4AmHD/h2I7WgIEByq3Je1FAaJdGrUB5DMJA6VZVkO/AM28xyE2w0MU1yM3cESw9z4KWVtdYiAZGKyUEHFIoJWHFAbIyF7d87YohDDYmIxCtF1ssoN+RBsMQsxXeprkd7FSd61582bzXln5n9QQY4Gyf3i0I3BKPBQrUw9AW0ipB5Y1SQIGGWrVWWoJb0ec1DmzY4cK40TKZaESQhtomgPLiOJwy3ZNgGctAgGjr0BbKotuqrIesDyA4V5fHLR9n4BkJztXnS5dIgsZIILiOnqeH85CSPHFbSXYR+GSrY9XtADp/8bzNAMv6DY6qsmfhw9QjpGJYAIhptcjtmMmEuvUASm5CuEWLcwoLbXh+FeVWyeTkeYZviD9UfQvAtxbZkBZvDJOwYjTo2orNxSIMEidpCYqbpvHo+wYEqg2Bi0KWHyI9JADatFYrONfEZbUWzLctCda2rZwAd7D8f7z7J4+BX3W/RhJ6R5NYVD+UZEZKk0bhSvBcNeyONCBq00ybEqytoT0OqzamoXy0P9/Z3BAv2MjHHvNzHFg0m/BtJh/eMEELuRk70mDwNgmUSiFsZRoM3G/TDYFaEBoeMW7cDq5h4rAiMjjl1W3Ny4jOfT3vR362naQqKrKuvvja5VMA+jeJpFeAGPPabN1MWWStthmEf2sxlNQK/LsJ4vzg6AICr34g3hqgPB5BqNcvAKxuBLjwdIdbWNrPFqj7kElV3WoBWYZWaITmayVBJIYyHD+RJWgvII/b6DgJyjE7DIK0Hju4DkPXFORHWLAgStU1EG/4nLHjTj3/cfWofVpRrwDZYO22lOVIZbDACvQ+SiGUXIzmupjxg4Er0WAlaQxeWpOCskLwJ84pEISSOrvEa/a887qAQW0jDVwJsk5ALgdPyQWsZG0d6HwDHAQA4v4cTgBjxQOaU25ikR1egwLEAKOOCVcnOvuN9cQrSJBTT1n49jTohxX1CtC+zz7e4WSDn4b3gk4aBgkUSDo/ZfJaFIEEYRB17kwkR9/eaEEDZ2yFed0Jwxecdi84IQal+a58P0c2ag0KBMrGcYNhayJhy5KKRGNYeCF2AKp2Z7ivZ1lhayR2ZFvVbWtg1DQzDZIEjIPU1AJObTXvlJ9z4u3qUQkMFqDG5sb1IhUja1CdAhoFSQGBE4c0cjxkRQxC4y3xRByeWelBUV7Y8oRiXJlesWDpIgIHW6iJPVqZWAgiBdhSQswLkQPAAOgFWQ9u/ditEQ2yAsBSyjc5StukdwKgHP+3mBsoXpZuawavoKRoyYkn/m0ORKLEgACq3bF6XU4ej4sO90Cq223GPcS2+k3VWupcWZNMxXsQegEqBJgCK5ePkmyotGHL7hSUFoRjkXio6gaA6ZNiUCKsCMBkBoBEQEBWQ1BcwWxPg2eOayvAMcgJAwNI0QQdt/S2gwCMAhP5TdQgZyoNJNkKWaUnXDwP+pDeACIb3v/l/pZGWsn9JxEzKOUYu+gLKxCkxWAg3AAQ3XfAw8HYFRpQxblcC9t2URiRiFgR+BZpczo+MseV1wpZYERMpgEChTMdxC20D1DMsgLL0C8u430hpueErUgDJdwadm16keWVdem1iEVpD6wW3vAKSucugSEAJJ9z9859f8jLkS8+U0+BRFWyysxk0UBhkNwABJppUeVF4CyIp+CSBXGobYDQDFEBcC6nqO1JBl/UJuS3eQYqBMKxCMcjs88OCAFB4BilEghPV8ZWprP72OUh4KSFOYEl2eq6Hbz7UFQy5vS+7t/q6/kqN/zx/uwcoIkYE5MffGtQn1thePH8aUauOm4sy0WWQgPANHE4UE/hynP9ptzmQeiFKlHPGM7wXlnL3RvXIKE93GQPS6gMge5v2OkFUAxT4OGUkLYczPB07DFgOAEY2vXplwOsqKuUTJa3+K5YGSx91h4SQOtXfq/hQEPXyyNGyPbC3DSyHGRRFA2iMC+wLJfqYB+U028EtLYDTB6TgjnHxaGaDzc46G5E+ZJ8kfrx4PUPCBTkEDNpMBTLFDHBmeVoRzrUjckEFCIL+riNAj/DrlCD5UDYPVp+eccKGJ8ua1vB6/7G/fEbzM6DghObd2fBEACSpGnrh+/dNLqcu5sY9SgHSIDkaoDwkg62pVWlg7W2Km1hAqSDB124fokDbZ1BXwa0cnnZAs5xHl+e5vm7WACsjmkAoVFWPegWGvVkwRhPKPcWWXS/qqdXH80YGKjF6oEoKOuzrWBeOmirQhYHxFBwO4e0J2AIAMkybz563r7Pd9Y/UlRKHIePuXmcTjH16RRXKV66Pa18D7m5TIDxcrU8U7BgBk+Yljqw/6B/86ZV8PNECmjz5ynYuN2B3GwIJhHSIMYBcp9Aw/TdiO5QM8g8oR6BpIchzILHvlBsCQFFwsdkPFPuzYrsxzNuBTPmwDodMdHTHBpA4r6tB3704Hfjo0hLQYFncaXQtLIYoXRhVbKFp4P45LrBtgFKrcU+2pWEv70gBjVN4H8bR+uTayvGf2TFKfzuRQqjChz/OjRC25VVGFdnxq7D2Y2eGF+/RNF5GulPmYwCQIgN4o9xMBSfQLlOQMf5fos3ds/yrF5n+wxg8GgZ/eiNhbMXXLJgR6rddQ82O5aLTV3CiG5c3Zh2GR5qUfsOULjuEp4QHWFLgMSkClFU6FmAV1EG8OrqFOytj0NZsQ+scT8QDvhMtWiT4VYxL+XqnUydi2iD2GfySpChK+8jw9O0EHOInDehwTJg20F/zkx4VPciZsPqGbVyjp96dvNpGmLikhuXMwRhyACJqmPP/+bMnQXl1d+eMrXsybYNqVRHMh63dD+DRFoTRQpVYIlWmOTKLslNwsVnZUFVrZ8Y1QoWD1TAO67t7R488RpA8SjLd4mW0aWxeV2vRQNwhDQ0M8jP9WDaeNFaPePCCMFIIIBQnaIAIb7JieOizgMNNuyuZVA4yjFv/ZmUFVK6mb1Kgt8yUUzBvNWu45SMa478tExrdifpOBQACRFd1Njv/nf5U3998/uTR5fOv731CxAfSCYGDEOVUALT8uGVGIlh7WoX7rzF5rk1S7Z029Yq811iSQnAvz/ZxVlctnRbMocatRh1HR30ia9baKijcP4pKbjqG3HeOnWEHqowWLc9Db992ZPjWJCJ6uvnRiDpacy6D4bfuRVr2xZK8WpWrVrm9nb1gT6B/AbNnt3xN3JHwe08nhCqrcWCHj/4INaiXCdvK3OOd2H29ARU7vdjjxYRX8pGAezdn4Ll7zswroxItohdpragUJ9GtX5R97QKF665IIu7Rv7bhW4fqRiwqNTE3ClxaG5LwdPvWlA4koQOyzXL5CZ9wczU3DK/5+xcniSubfoA+pD+kIRuUl5e+jftB/0WIqk1WlxNFNIBUfDUB/Oa6l04f76wHgLY92uXIdjaXb/zIC8v7neE02FWaDrBbkDV5X5+vKkpDUvmUTlM0eH6iUnbGuKiMgT7GxnMmxaDhO2aqcC6DyZB6MbZA4kQSvmsvGGynFzezfhi43LoQwblAwpKJs49uJdBKkV8lmSFLcYMlkX2uSkKsbgIGv7sIz1RXoAxaQzAex91wsfb4zBxvA82VeTDxCBVj2FFJHAhjKOXzeuW04kH1ewyCPMvl+YNyuJuImbxmMbHsPQ0LylUxRtM3SkiEypGaqQEoUgkgMVHAjvwxYvv9nULg3kUEndoeVsL54gp1fmMUmtNvdMB9RbWEONDC+/+icg3GTzeGZHfGuDLqByhaAp3/YbHoCJb1ivPS6n0EeoAUzeg9h6qG0gC1m91YGS2/8E+80Iw7WNhPe8THVzxJcYSnmXfy1NSjc3x4N1XTOtZOLOBBzYxSJpQZGUzy23ten/9ygcb+sJgwBZUUVGRSKcgN5303+Q2bwFYiLHpbWRFopWP5EmNP66wYM7MTjjnjGz5fRuRGrH5E//8ziS0tWfDiBE+MGbihRqoMwNo6hokco18ft5zrwLMnpqCqZPicnoxMQ4GR3AtmTpHPrUOihD57m1nisFDz3qcHToq+66smQW1mldUEDi6f6bBEY2GJ0Xc0eXEWbNi1R3qKploB7qjAcrixU+MrDjj27Xb1kJCfjlEuR3MUgAF9Eypk/01LixemIQz5mZDB4/mz73iwp79I6BkDJEP0i3lYqmqSLhOnEcTLk+0+ObmNFx2rgfTj83i1t392X06Hu4HmTUJ/xT9swMNLrz4LgOXW6iIkQY+hDfOXpgPA6LMB6OB9Y8eDTR7FKv6xdXW0eppegVowBa0p7OSTuCuWLRsmQez/BsKWYwXVrKZkqWUOabYgXfW5sIrKxn37XEoKkxAEXcjbjJidRoMADPNyYCFjoltTx3Lz4/B82868NSrIshbBlgdJ/GXhYXoeBWySNXjF/dtc5RGceaW7QSzjwh67m6ZWe3iIpYjAMrNglTJOIi/98pb16rSfeY4BgxQ194n0ha5LcmYlSU/Z2whZQJkTjhqhSrgRJDlNwt52cQoOpUOl7eQO9OdPNP/wUolgQXprHP+CL6RgxoFIFKBrT1q4XYAQAAY8TPmqaAuxb4DGo9AwiPL+lObwnIsQmlBIYm3uGzDy4+d9y5A/77fM2CAKisrU5dmWa3ciPIJH9SQL0LJJh60dN0SjVLBZy/d+jRaqRG3KFNDNChrYatEoFCkcC/aKNBC7SBumEyHumdpCPo+XWSZJAywaWQAob4NqOfQ4AihGCR/6IWVFFFaXuFYzz/6r2erMyj0QwZDs1lTfe3WRFbJ+M6WYKd2Zbprb1q9Whv/ThBYBEKukaG1cUNUVWmhcyFsOdSKKFRv6zKeX6cpC2DyZgI8CX6G+qOUHpDrDh4cjAURndpRRMFT8zaK8ll6/DQnvnJ91cK3nvtfzdBP6xEyqH5QfbLlvbyckm90NvkvMVkRhTBkNYBA0w+EJ3iEXAx03xcth11d1CKx1egpgdK6oscxG1RJXkD1GJA1mCSwGvOMAOHPeipXJkRTdeEFivK89ISpdnx3VetP/vO2SatggF8FHsQoP88kTJzbVT7xxBvqvpCdfEmIQql93dvW9673A4TeAZW7dFAFRFFVP0SWV8cJC7ZBuY5MkyfNe6deuF+ir9dtSpgK6H4y0F/rsScdQ/A9dZu8SSPxhvqWI9xl8SiaOup4O753X/Ndd9+YvwwG8fHzwVgQOUArN80qglaekc2Rg3fmSACEaeUQtF6G9ml3YlqnF5QxbxqgeCAburJGzBa1GxKCXZ1HMlgWclGYWYbIAw0sxDA9Amaut7bakFXJm/VXgq3x7gcdW+rSo0504rt2N//srpsKfgXBhw8HJIOxIFK3bZU384xbpnY1J2Z2tMq+HTE9bEW59acrAbVqhmgpnogftTZjYbgs66U1s8h5kV49Zd3LmnPUq/Q6I6B/a+vAr0Li9ynNwKFPAvzsCQcnP4+5EyuYXTHdJmveqVz88I/LHwffrWk7HZAMysUJyc2dsnPKSTNvqqniGRePty0ULLXCbe2mINjXzd1pd4jOC631fhV8Q+VpUGcUMEBlAYFlAEZrXJ++lh4D76lByASuSnMJq8vNAW9cuQuTpvPeV8zduOIPz0z/z4fO2gJD/BI9gcGJ5Fe33ul9vHk1mdFYR4h+iThasYmj2q1A2JURdIJxR3pXhNZiBkUyBW5E30NUG8LuLkTrI64LUGZCMjh0v9H74TlFNnIUsKLRQMom8PZjw/51qz647sl7T1uuahYGMKCYE5XBAiTl0us/OHlCxdyPNrzBUp0pEscftzAPz9BvQErSvwmEXxuEMKghhaPtEFAQvi5B9QFSahS0vthiiCkSNWytrD8n20uOn2xnjZ8EtKbRXbfxvRd+8drjV7yuHst8aBeGKEMBSDKSW+/qfPPzj+Pn7Nll+f+eh3SvnWTah35iZTG1HRrmRnVggM1k+Ch40N3CoLdMRw+AGdDRuXJSCycB5ZM4JbHa7n1z7e9vr1z+P3WPUFiMdqyHRAYdg8C/ESueij07e8nCHzd85pGOdp7QIGG9SNExQW2bz7uQyCEUw2Q5Chm/DxclD91iFgSxKXR9isqjOBii3hD8NufpaV3Ujz1ZfDxnwnGEvvTrHy2qXH9HBwRw9is7MBAZCkBCSFXVqvTI4qtWzjx19A31Va7b1WXZuCWHCos/UaVBGAS5mwTb3cDSCibQrZ8VAomiY3o/Kg8IFGCQkeHhKcq4P5afzwiNty5f8dxl/w9UtggOkwxmwA6LeLzYK48eu7a5s+nmWYucWG62m9IT6KO3jek2bt3dOo6IMSFCFbxApnYQ88WJoB79tSk9oT/09gXa1p+/1Ptkx1dNsNRzyimazyenMIuPlvORh7FHE9i5/eX/g3Rw2GQoMQiLpJI3/XPNXdms5JaP33HTjS08T0/Q8DMO5r3dEMl8hz3FsWiM0tcxb9qhMt2YIoGMbNCco+OiIjtiNbqEsYknkl13/5AcC/0YzxmqDNWCtMgvaDx0W+mtSWi8/bSLnFhpsec6ohF64ZgRmvyO3JyWbh1J1DfBqR7TCVU/9YeQ9NsT2sIsL3BjgHJk5n0lL5iAYl4684K0jbYuUYbT6lTFdEL+sn7/tfp24TDLobIgLZLZfftnXyyeOnHca9tWM9hTxdzWdsvRNJWQPu6G9HxTPZ1LulHC4CfebfozBIJPbUauF2V1QgQKYsRi/CTPGjuTfXj3P8TmwBH6l9NDJQlRkTHpk/fv2R5Ljfn19LNPWVJWTkrcNs9zUxZLp3mD1sE76n60YPaEpFdwIsQjREYAwp+UQYyOKPIh+16oPEWkQ35SjFtQ4ai0d9K5jvXmCw8eX125PAVHwHqEHGoL0mLGO664cfU1J8+Zd++BKiio+hRoSx2Dlg5ipfWbCTjGIGXjyYBE1WihPklGyWR9fcQwvSb4fNUh1eNb+XzIYM5iO1a1a8vCJ+49YRUMYDxnqHK4ANJ1q4FugAuv2f2dU+aO+4mXso5qrAZoPADQ2sTEP0USU5sY9/VEtm7fFcqvFIp3VrNyeSPnYDbUg9vWwd0K6U4IensKEt2IkIBu+wB1aAQ4uen0zDNjMc9pvfWen4y8Gw7xf3nsSw4nQPga5pkXXHTfseMrzvtWUdnES4vys6ekk5BP03wkwFU9X/BjlQAIsiHZlUxv9cDrSjZmnb5ljZtqbXPilPQwObGPGKaLQAamiPdTNcBYyC1n1gI71mG1/MsDP83/ORyhuBO5tSN+LeO7p01bGi+ecEbJiPyC8lQ6OY55bjaxbEosp97OGr37i4/fqN669SH5X0Ou+2ntP5eUFP/8zyuYW1tHLFdMCOoP6YA+yqDjmjk6FtCSkjSbtTBmt3W1c8vJFZZzxMGR9wZfnuDw3lc5oZz0dT88cPbYo0vfqlxPYe8uSLd1WDFRgWX3DYKpLML0hGj6L3bnZUNqwmQanzbfoutWrz/3hf+Y+zYcYbeG5csEaKAilXTa0n8rPO/cH7yZrIGTdm6itLbGYu0dYIuevhWZS9CbmHEg8CN+Tja4xWOZddwpnMDE2MZ333hq4brlV7XAlwiOkK8TQELU+9FAl9667cLpk4/7bfN+KNu/E6C+htHWNkKSKU42aNC97yknKGbEikns+XlA84uYJTqgiVGsZuum1dc8//CCN3Qx+BLcWvRev24SUtyV39+0pHzCsXfk5GTPauHssKGGQWsjYZ1JIGIypP6Yhuwo22ICv/xHVCyvAEh+KUBBGTCbuB99uP79O179/aJX1TUO+bDBYOXrCJCWEDucNe/OsqOOn3Hh6DFzLiguGXUSTUGhzSCLCmWLORM+rB4vnWRxVt/U3PnnlprNr1ZVvvPi+8t/VqfqxBN6vxLydQZISzd2KOTkk5eMyCu7ckSnW5/lxDpzWJq4+bkVLU1717atXXtPEpXXZKW/pGVYhij9bXT/HRrnsAzLsAzLsAzLsAzLsHwl5f8DGzhXq3EeY8wAAAAASUVORK5CYII=",hP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQoAAAEKCAYAAADqyxvJAAAoPUlEQVR4Ae2dW4xd5Xn3n3fv7TkYO8zE8BEUUcbfp2CjL1XGSJXakipjpF7ARWIiFYwvyiE3PdBCK8Wh3DD0ghJXSohCW/UigdwYJ1XDkAtyUSkMKrRSL5ipmsqHtPWmNAUKxJvEhxnPzF5d/zX7Hfbs2Ye13vO71vOTJh47gz17z1r/9Tz/5/AKYkrH+ceOzqzValPJ+vqMwK9EMyJJbu783zP4n6Tza/efDaEpPxGdz9P/voXPEyE+TNoi/XyjWavVWo2JleX98wstYkqFICZKzs8fmVpfmZjdaIvZmmjf3LnxZ9OPqc6HZ5JlQQKCsdxOam/Wa8kyi0i8sFBEQBYhEM1RknymIwhzFIQYKIFIZDn9dTlJklfbtdryrU+fahITNCwUAfKTx47OIVIQov05ilsU8oIoYzFJaq8i8vjU06cWiQkKFooAOPf4sdn2ejKXphBfSD5KH6pMFnWkKctLtYZYvOWpk8vEeIWFwgPSX0hDbwjDA8TCMIqmyCKO5KUDJ763QIxzWCgcAXFYW5k4kvoM93PUoM2CEOKlXRMrC2yOuoGFwiJdkcMTLA7WyETjlqdPPU+MNVgoLAAzktMK58DXgGh8h81Q87BQGCKLHi6PPZIIcaQTPTD+aKaC8eRG6mtw6dUMLBSacPQQNukF/jzV69/gyokeLBSKdAQC3sMcMcGDqgmlaQl7GWqwUBQA6cXq5ckHhGg/QqPnI5gwydISFoxisFDkQPoPbSEeJU4vygILRgFYKIbAAlEJWDBywEIxgHNfufeR1H+YJxaIqsCCMQQWih5gUraT5DliD6KqsGD0gYWiA1cxmG5QJdkQ4kHuw9ik8kKRzWBcGYdAPEoM0wP6MFLBeLLqglFpoWAfgslJ5dORSgrF6ceOztRTH4LTDKYgzbQCdriK0UWNKsZPjt/zRC1JzrNIMArM4NrBNUQVozIRxbkvH5tNautpNUPwwBZjgkpFF5WIKPAESGobSywSjEEqFV2UOqJgL4JxROmji9JGFKhopIq/xCLBOADRxdK5x44+QCWldBEF90UwPklvqGd2Ta4+WbZdnqUSCqQaqbK/Qtx+zfildKlIaVKPfzt+z/0I/4hFgvFP6VKRUggFnOcNIZ4n7rBkwmEqSY30slRFok494EdcvTKOSc8jxDDhsjA2ufpgzL5FtELBfgQTGVH7FlGmHuiyZJFgIiN7sOEBRxESnVCcPX7PkaS2wSLBxEhmcuIapsiISijQREVCvEhsWjLxMoVr+Mzxe6Pq84lGKLJ5DaJniGFKgBD09ZgqIlGYmXhDUyNoniKiNrGbxj7xS7T3tl/PPl99+y1av/ABrbfe3/pgmDQVmf/Uie89SYETvFDEKBLX/tpv0tThL2QCMYyr7/wntVcu0wcvn8o+Z6pJDGIRtFDEKBJ7Zm+n67/4pUL/DcTiZz98gX6x9Dox1SR0sahToMQoEo2p6+iGY39AorGr0H+Hr999622Zaq80z1Ks7D54iP7PPb9DyfpaGiG9RUx+EiHmHrn9/9M3X//XVylAghSKGEUCfPL35qm+51pSZWL/wcy7iO0mg0Bef/dDNH3Hkez1X5OK3t5Dt2eREgtGfkIWi+BSj1hFYjr1JOBL6AKheOtrxykWRvkxeD3vnnyWPZgChJiGBBVRxCoSCLmv+/xvkwlww62cPxt8VWQzzXqY9v7K4aGpFl7P7k99mi6m/gtSEmY0IUYWwfRRoJkqRpHADbPvrvvIJNOHP0+hc+NDx2li5mCur8V7NG0g2qoSuBdCasoKQiiytuxIm6mu/+JD2Y1gEngVeW9CH6CyU/Q1fyxNUXYfvI2Y/KApK5R2b+9CkQ3JCPEcRQhuGFs39O5bD1Go7L3tdlLBhqiWnvTeOPf4Me/b470KRdeoeJSzG41pexc9qgajGrZ8gBtdVRzxelAdYQoxlWxsvOh76tSbUGDpTOyj4mjJtgVuKoTroaFb2Rm78ZeIKUz2QMU9Q57wJhSdzVQzFDHt1UtkE5QeQ4sqJvcfIB1WuUyqykznnvGCF6HoTM1Fv77u6tt2m4my0mJAXoWKidmL7fes5BzxNXHqXCiwmTjGMmg/0OuA7kOb7J1VMw5toGpidsNTs3rg3jn7J/fcT45xKhQwZJIk+TqViEunl8gmIZVK6wYqFusXWCi0aYtnXJubzoSiy7ws1XYqdFHaJpQGrF0mhKJlzwCuEFOuzU1nQoFj/qiEey4vn3mDbIOownf/gSlTlWc+jDHTuaec4EQo4EuU9SxQeBRrDvJu36VSE0LFImEW3FOu2rytC0UZfYleLlv2KYDvBiwT//baBU47TCMEPeHCr7AuFGX0JXpxIRS+G7AaRvwJNjItMFVPEuv9FVaFolPznaGSs9I842SNnc8GrMb0PtKFUw87pCnI3NnHjs6TRRpkCYRD7SSZp4qAnZfX3HrI6o0sG7AuetitaeJ1rXtOPfAaMO4+KjK7fPoNeveFZykqkuSJc48fW7jlqZPLZAFrEUUn5agMMDUvvPIS2cZXA1bsEQVSpxsfPJ4rfcP+0hhH4pONdWspiBWhqErK0cvP//HvaOX8GbKJrwasumZEASG13cU6CLxf2GdaZCANI/EhTu8OR8zaSkGMC0WWcpSkRVuF9178NtnGRwOW7k3jaxgMvg62cRX9/qMdiU9TEBtVEONCUbWUoxc4+7ZTEB9RhW7VY8NDxQN+xMfvVF9TGGsKYqMKYlQo0FhFfMp4loLYLgXuPfTr5BLtiMLx1Cj6TkxsRY8xBUEVxHQjljGh6DRWRXPoqk2Qi7/3fbspCJ52ri7gRmTDYBCJ6+4udlrbIGJNQdCIZXIWxJhQ1BOqpIE5CPRWoMxmC5cNWEZKo46GwXAwtCmRkESagkyZnAUxIhRZNEHJA8Rs44MfnrLq9LtqwKoZqHi4KI1CJGBc2iDSFOTR9N6cIwMYEQoXLaQxAp/iw9SvsAUu3D2H7PdV6KYeLioeWZ+EQnUjL6FtG8tL3ZAdoC0UncnQOWL6YtvYvNZB+lGbnCQdbK+/sy0SEhe7R0yDe9NEVKEtFGxgDgdh9wcvnyJb6KzPz4vuDWgz7ZAiYXtfx5XUc4p1qK1mIOLXEgouh+YDy21sdmzabsAKdaEuBMyFSIAYo4kuZnTLpVpCwdFEfi688gOyhe0GrF2acx62IgrMbrja/BW5UGiXS5WFIvRoQobk+IAb7nuVHMqlNo3NUA82tiUS++68z9lhQkg58POLnKmrKxPKUYXymHnI0cSovBU/eHxgh4TLke3WKy9Z21SFqAIVEBuvR2f79tW3zQtFnlFxk9ge9HNGkjySRhXP7J9faFFBlCKKkKOJPHmrjDauv/tL9MnfnXcWbcDYtBtV6Lcs90Nn+/bqO2b9CbzGKUuvcxCXHGwwc4RyVKEkFCFHE0XzVoSvEBZXQ1aIKmy553jdLvoqimDSyNx98JBzkQArzbj9iW1sRhWFvYrCQhFyNIEIQSVvlanKtKOL0OYciOnXoF3xMORR4Pu4/otmW7PzgLKorz0alphavTz+ABWksFCEGk3gBtF9muJpdcN9D1tPRWCM2cp7TUcVOu8FRMLETSbTSdct1Ij83v++/f0irkkrII9QQQoJRajRBFprTYWkGAByUZu3ueAGohnCXIKp9fyY3vRRtfrg5RfKujl8pmi3ZrGIIkmcH47qA1yUN/3xCavOus05EHz/pr73sRtvIlVMlBQhehBv12D50OUzpTExd1B0BiS3UJz78m/NhjrTYavzD7V6fNh6OsPYtJX/mpos1fk7dH8uvszLi0uvZT+bMlN0BiR/RFGrF85rXGEzPMSTGYtZbYS+Njd3m9pXoRNR6BiZeL/33aW+xk4VXEtYD1AFRJIcyfu1uYQihn0TNs//lFURG6VHTJfaaEoCJqIK1e3buOFUoyWXMxzd4Pt9+9snylblGIgguj9vqTSXUNQjGCO3vRglK8+l5VcbJVRbTzATUYVqV6bOjkwsxPViXv6wtOblIHI3YOUSihiGv1ydQoWc2fQwks1yqW5UodqVqSrcEOK9HprGkAL6OIHNO0mS68k3Uih+sml4zFDgXHW45RlzFQiNMWxmClvlUp2oQs/ILC4UvsxLNFWV3bwcwmweU3OkUCQJRVESdX1cHSIKmJymUhGb54GoRhU6Qni14IyHT/OyjE1VRchjao4WCsrvjPoEQmFz4GoQeAKaKqHC2LRhpKlGFaor8PAaiuT6vsxLAPOyYr7EDvKYmkOFotOJaexsANvgRHEfI8GmSqg2p0tVogrV11N0mS6iMjYvvTK1sjIxO+wLhgpFktPoCAnk+j5++DIV0S2h2lrGqxJVqEZJRfwi17slJBDkn3uIQENlVKfmQKE4/2gWikSRdnSDm+zdk896EYvNU6X0SqhZE9aPwvAqVJut8kZ1GO33YV7i2kD0yXxEkpqaw9KPgUKxNjERnUhI4Ff89C/nsw1WPsDFr7MQ5+Ly61ZSqKJRhXqz1ehS9ebYuPuj+iAS8CWYHUytrQy+5wcKRYxpRzd4Mr//4rfove9/y0t0IRfiqKYitpbxIqrIK2B1iz0UvszLCxYXB0XPkKHPYR5FtBFFN3g64wniI7rQ6ea01YSFqCLvIl6VZqsrOSZG93nqvKxsU1VOhqUffYXi7PF7SiESkqxWnkYXcLl99PEjFcHYetGbw1YT1p5Dnx35vagamRsjTi3fM3u7F/Oy4k1VeRlY/egrFELUok47BgGXG95FLFURmzsrRkUVqs1Ww5bpclNV+AxqvuorFAklc1RScNG89bXjXpqzZFWkSIOWrZ0VeaIKFQaVRn2tswO+qmAxguarfn++QyiwoIYqcEwgymO+jM4iDVo2m7CGRRUNw0amr6Yq+BKu2/sjZ+rc48d2pB87hKItGnNUEaTR6aObU67by2N02mrtHhZVqLRvD1qmi0qLD1/i8uk32JdQoL2+Mdf7ZzuEoibapfQnBpHV1Z87YW0gaxQwOkctj908Ed1Og9CgqEIlRei3TBevy1dTVVU2VZmmJmjHD2yHUKBEQhUETx5fRiee7KPG1m01YQ2KKlSEojfEZ18iTvppwDah6OyeiGYIzDS40H32XIwaW7fVhNUvqmgonGDeu4Pi4x77JdiX0GKqd0fFNqHYaItKRhPdhNBzMWiDlq0mLKzD733q15Uiio8qHvAlfGyqYl/CDKKdbNOCbUIhRPtzxGTIngsf0YXcoLX74M7zLGxEFRAJ3W1d3TsoIBCIJlzDvoRBxPY9ub0exRwxW8jowkcZFRHFDcce3pGKIKqwIV44ba2bonMeeH/wPUMkrrvb/RmhAGe6si9hBkH0uZ7fb4KV/LUkOU9MX6R77yOclhOP8iZABIDSqkmTUDaiSfb/aVydjPAlOOUwS1uI/bc+faqJz7ciilq7XXl/Yhi+o4vuVMTGwUH4N0wuC3YJz3HYofuYji2hSISYI2YkvqZRe1MRG1vHZfrho1KhCs9x2KOdfGRoNuQnqWJ8JiEmDzK6QAVi+g63rclIf7B5qp/RqcvkzAFqEXnpe1CFfQmrzMhPtoSiqo1WOmRNUM2zzr0LGyIBUG2BSMQiFEi/TJyYzvSn29DMzEzsx7w6Pn6BGGWwZ8F1dGED9CFsrFzxYtoWAZu+/zstXzN2GZtcnd4/v9DKIor1iYlZnPTDqOMrujANmq9i4H9OPkuMfTqLbBYzM5M7Ms3gszJSJS4uvRbl+4toE2ljTFGn7NBsdH43Q4wxyhJdhMjm0Yt2Zl5MITtdYTpDFMbTX/H7bu8HYofXEbzgiU1DMxMKrniYx2dlpMx8aOmAJBVw48v+E4hCP0EYBKZ28QEz9sKPfhCyKTuD/5FVj8pOjNoG0cXlM0tZdHGth+UtZQIC4et0r0wMOoKwa3pf9rkJ8cchSDc+dHBzTuXlU+m18gaFRFrt+Ax+zYSCS6N2QSclVu9dPr2UHXrD0YUaLpYLyQgBY/YyQnDRsSoPRHrzqbCEgjpBhODSqFt8zozEDHJ608cX4GeBJ3rRtMEmmLcJzbfAzEeDS6NuYe9CDV0Ds9tgnNx/IBOIEBvLJtLv7eJSWEJRr9WmGu12e4qEIMYtXBnJj4qBCVHATYdIAaIQiyCvXxh9bqtrkiSZaSRUnxHUJsY9HF2MJo+BGWIKoQJea4jVD5EkUw1RS6aIMw+vcHQxmN5oIpYUQoULgY7Kp/KQRhSpWnDi4R+OLvqDkjKEACXJmFIIFVbOn6UQEZTc3EhF4mZigoGji+1AGFROg4+N0NvSa4KbrYLD9yZwxj2/WPoHChcx0yAmWGDiZU1adz+U7Ypgysda+lDAzzj0vRri7FeOnk/tihkKDOSmMKw2rlzZXAWflo1kaIZf8WdVetri7E6E4GUx7qoK9mjAi8AqQ7RrR3INN4OLKGQrK4yrPEjB6BYRKS7ZR/p5GQRGRhdYsstGZzxIYcg+0qgh1odbUBEFoogpR0/NXoGRv5cH7SKC2RKbng/f4D2qgsEXI9gInkULqagPOt09QpqpUNwbRBcFxOHmx+PYWtRPOKTgdAtN95+bvmjQS4Ct3Bxd+AM/zyvZMY+bqUSJhGEHwaQeMZ0pobOAFsIhU6C1TtQi/RcZ4eS52OSByjgIiLGPFAX8rDJhSN//Km0xC0YoapOTVAUQAeSJAuTTSQpKJjAdYZHA7GXMg/cY3kIWJaQf8BaqvtowGKHYDN/+M7344zytyjSxntoVGywK+QhGKPADe/eFZ+mTvzfPJUDGGmudwauV/zjHolCAoMqjch0YyqMMY4KylCd9E1wfxcXl17Lcm/dLMkWRaYQUhjJXIVwTZAs3TqbGOZjsVzDD6C5PSmFg7JAKhWiG1sIt/YqP33V081wENvYYYn/BI+G1cEtwEchj4+SyEqw2A9iQnP3aKTN29zXs4gak0sD+QjhEMT2KCyR7khSYsJPi0S0iUlik0Oz4vEtkWHzc05tGsDCEQ0NQ0kw6pwGVCVtzGf2Ep9//J+kWoq2v6Wku69eAJf+srtEFGhuyFRrI18xi4R8hRLipR6j0m+9wQb8Iafrw50u1p2LQoFt323tv63vvz4J9Czs0EiHe5HM9wqdfhHTpzE2VWGiTt+1dl24x6jdN3D1pnHcmpwy0k+RDjigi5ppbDxFjDhUxGrYPpXdVQcTl2yz1aBITFUg90JCWd7kPYw+ZCuYRGWxYx7GIsaVHqUfRwhbuJice8eByuQ9jFqSJWAuAhsJQz/DoR9JOWo2k3W7xkYLhg+iBT0IvBxD6PYduz/aJxBBdiHqt2RBJWh5loQgWCMT0HZ/nNKNkQPBjiS5SM7PV2KjXWzWuegQHUouP33kfHwJUchBdNKb2Zd5FqExMrCxnocTZr9x7gfggoCCQRuXHOkfpVQWE4ei8lYcN704rOuORHjasAg57GnUYsy8OfPW7olMeFa3UsmCh8Mye2dtp3133VdKo3HfnUXr7uRNbrfrypqmKcKDZDJu7A/QslvE/MqJ4Mf3lCDFeYB9iE6xChFgMa2Qqs3Dkef2uSUuji7c8fepwFlGkDsWbbGe6p+hhR2UH+0ewCnFYNaA34pBTxfiAcMRcFcLrR2SBNCQUUiPzn/HrZuqR1Jok2sS4AU9BXBAfs7jFCzfahR/9ILq1grjRcRpa3tIhuh3x0S0cY5/YbG1H5BHbLhNcE6iCBBNVJJsNmZsRRS1ZFlz4sI4ro/LD9KZB2S3Wp2tRsehGCsfF5de3/q7eqCNkbE09q5LUROZRZEIxsbKyfHV8nBh7uGiYQo77wQ9PZaE5hAgnicWKjlh0IydPcSAwkEuQ4HEg4pgMLO1bDWweBKVR/LplTXCJ1A6ujEqEq62uxp0b7ns4vRluo9jBTW67gxE/m+6Iw6dBimjwZ+F4FK20NDqNT7qnRxeJKx/GwBMRzTS2G6awFer9728fNIL/UQaRAKYii2FsbU97ZfP33akKIg5XwoGf5cWl1ykU0orHsvx8Syi48mEGVz4E8lhEEb1NOhCJqZKddO5CLLoZZpBOpuJhOn2EQLRS47nIqkcXyIoH2BKKWqoeCbdya+FqsrNfFAF2HzxUOpGQuBaLbmwZpKEKhETUaovy8y2h2EhTjxoxKiDHRWeh7XNIBkURYLMn40ukAm68d08+m5mtIZ95itco+yx8LoHRNUhDFwhJGlFspR7bsg02NIuBi2PfXUedNEwNiiKAfNqqhsRvfe149vfu/9NwB5N6ef/Fb9EvAsrne+nXQRqLQHTYMjJB7yq8RWJDcyQuGqYkiCLQqTfI5ML3oiMS+LshErF1h15395ey1xzqiHZvBym+15g2W6UmxKvdv98mFElSe1WINgvFAFxPdl4+/UY2fjysAQej6KoicXHpta0LeXeE+zelHxPDtqjotoMnWdCwxXah4A7NgWCyc/qOLzjbBv1emmaMClGnNcqvWYv3Kz/Y+v1k5xS22JDmcUjzEWVAdmRKdlRE2afYjuvJTtl+PaqNF/4IjD1V5P4HILctxQwW1+K8Wj4wyAjb/Amwo9AhOvPnDHYk3Jfl/y5EQnYgoitv1MWOG1unPRuhene0UiRKctEpqQJ6HCCcvFNUn+5GK8kOoWgntXjWA1siK8P97rwTsxIgivjpX87ndsN1ZkYwD9Lqyenhzudl9e23su8TqZEpZNlXV3x0qz/MJu12skMDdghFLVlfpAoDsxJPJts9EaBIFCGBL6Ea4WT9Ei88u+PPi0YUIHP1z5sp8+G1Q7yydEjz72Sx0KfWqC/u+LPeP7jlz/8GYUeLKoa8wFBFcFHRKBpFAN3Oy0FP7fECEUW3oI2qyOQF7z2it0w4nzuRvTe6fx/EnhcCKdG85amTo1MPkBY+vkMVQkYRLi4shP4QiCJRBMDFj32aquDmG9aLkZduocHnuje1ZPrwRxUlvDe6JU/ZX+IqfSwLQmwvi0r6C4UQC1QB5MXkIoqQefhP/2peqf0YY+Oq4TRu6GGjy0Xattc7h/ZK0IdhwtjE+3/93R9t40IqgrZy3YgFhvR0SedfbJCI/h5lX6HAIhsqefqBMB4lQVft14giWopPSVzoOp4Jcv9BFJ3t6L1xMwH8kRn/G5WL7ggAsxR433SFCOkai0U+DvzZC32DhL5Csf+ZhVZZy6R4cuEpc8OxP3ASRaAR6B2NciIavXR8CdmiPYjG9D4qQr8nPKYqTRmb3SkIMFWOxXvYHbEwO0kth4GKP3hgVIjS+RSIHuBFuMhbZRShc6gLbhh0g6rS3aI9iKIRxaAbtrvLU4feFET+m3gvdYfA9hz6bJbC8QHP/RlmOQwUil0rK/iPSpF+yCjCRdnMRBQh0fl+e1u0B1Gkh2LY60H1xpSx2ZuCALyvmBjVNTmx+evGB4+zWPRhYmKluFCUJf2QpbJYogjJPo1hLwAjMI9Q1QvcMKOMxTyt53npTUG6/w3duQ55fgj3WnwE0o798wsDA4Ohu2o2hHiSIsZV8w1ujndPftNIFAHkhKoqeOrmrawUST02RoiArOyYoF8KIvl5pwdF573mxqztjKp0DhWK2KsfU4ftT3tiFByLXy6fWSITyKW8qmTLUXLerLgZi4TgGzluTNzE6BUxQb8URAIh1DU5WSy2aN369Knnh33BUKFA+hFz89Wugo5+EaQbb3JiUfZ1qObP+J7eLzCDUdTIXOvpoRgEzhYxxfQQsZc/A52KC4tF1mQ1sm9q5JrMqjRfFUGl/ToPCLV1Ltj3BqzKG0RtcpKKkFcQ8b4g0jLBsBQEmGj7lj5WyPtCbbJBoyucI4UiDUkWYzU164afEipDXHnRPYujd3Q8D0WbzdYv5BchRBWm3qNhKYhEt+1bRnO7D5bjPJQCNHGPj/qiXIu306giytHzXQaFwlYUAXSHvfqNjuehyDAYaK9cyf21m+VZc5fNdA6/SbciIo9htH1oU0i0cxYscgnF2MrKM1TBiVJgM4oAusNeg0bH86Dbvj0KGJumOjZHpSDd/6ZuRQSLeyvU8r2Y54tyCUWMpiYuLF33PRvishRFSHSNNNWFL2MKZ2yq/DsYRTdFnhQEmKiIVGE+JDUxn0/Tjmaer8195k9spiaefjC5VEw1OQpusoGoH7pNVRAJ1bMqGwoVIZX3wkcKIv/d7KAgjYdF6cWiVv9G3i+t5/3Cv3jtx80//Oyn59JPZygSkvU1uvTjf8ourPEc05dr6cWF0PW9v/lr2rj4IdlEHj+oCm6E/1FMOcDeXzlMEzf9v9xfv955b1RYaZ6la1Ifpr73WtJFNHbR+Cdu2jrebxgQNvz863uuzfXz7weiGGygxmsoE0KIxVv+7IWv5v36BhUAnZq1JJmjyMCMAC70PalJJY+Dw14FfCBMxQXlclkswn7swFAli5a+rbc1u6iRuab5/iAF0dka3o1MQfIIl5wRwc9XNTrYbNzbZzSN8s1GQSuh8AHmZ79y73mKKKoIDRMNPu+lF/5FzUnKmx9/tpBHcen0UhrBfJN0gDhea2jmBgJQ1LSEQKOqofre5zmQKRKaB7763f1F/oPC5xInSS13XsPsRGdTFRi20i4vKkZmsnqJdGkZ2LQtyVsF6UaanKrNYGWZPG0rzHAVForxq1eep4qWSnXR3VSFm6xlwBgc+0SxtAPkbd8eBp7EJtf8562CdCPLyaoGawkmT5uj5jr6UVgoUCpNnRCOKgqia15KX8JE2KsiVqYiAZN7K0DeKkgvrU7pW+V1xTwf0lacCC8sFKDKDVgq6E6EggsGw/aiRiZoXzGXl/tOQSQ6qQh+phGu1lOKJoCSUHBUkR/59NHJa/OstCuCykLhIu3bo/8u/ymIRCcVcXFIlEnaGvtllIQCcFSRj313HtUKUXEhmxzbVp2QNF0+DiUFkaikIhD/iCZOlaMJoCwUWVt3QlFvwLKN7kQoMOVLSFSMTGCjzySUFEQiU5Ei8ykT+w9QDLQ1t9UpCwU4eOK7iCqaxOxAdyIUmPQlJAjTi2KrbyCkFEQi91vkTUVU/B4PaEUTQEsoQKpUDxKzDd2JUABfovWK+el+lQvbZteqySU3QDcFkchDk0e99l+88Q8UOm0Du2+1haKz2GaRmAy5AEXXlzB1TkYvKjn1huVORJPdjiZSEAlEbFgqorIsyDWY6dCNJoC2UIDYt3WbxMQTLe+q/aKoHp/YvmKu4tH37w8wBZEMSkVMNb/ZZoPISMSfe3p0GJgsffizn55OI4tfpQoDkbj2N+4iHXBBYuLRBrtvPUS7P/XLVJQr//bj7MMma++/nUUDRSZah4G/59K//JOxSAXTo2idXzl/llb/69/pwt/9bfAzH9g3cfDp7xrZI2MkogDjq6vzVOFyKUJ6E+alzaeUainP1Q0RWhWkF3xvODjZ1AnulmlukLlI35hQVLlcilQDU4k62BYJoOrQu7opNg9SUt+x0QtSkD0V2n/ZDQzMvNur8mBMKADKpVU0Nq//4kPam6pc5LvKzVYGBsLygl4G3SMDu5mMpM/BME0TBmY3RoUCbFSsXApfQtUkBDih24VI6HyPrnNxk0t5xfg1VDXSaOIwGca4UGThTkWqILrDXhAJbF9ywZhGY5AP085UyTSShihjmE45JMaFAhx4+tR8GU5CHwX6JVTB0tefGQyxR6Ezk+DDuMO/aaJkGvuSmYIg5ZgnC1gRiox2vdQpiE6/BEQCtXmXT2rVJ6vPEiAqDLqDY0UPYo4ZGymHxJpQ3PLnJ5fLnILojjW7vAF1phx9lwFNlEyrIBS2Ug6JvYiCtlKQRSohKhefPGvC9c2nk3ZseG4qMlEyVZ2YjQhrKYfEqlCAThWkVI1YKimHL5EAOkbmRgCNRbol09pkqSOKls2UQ2JdKBAOla0Rq6hQ+BQJoLMzYc1hD8UwTJZMy0QqEn9kM+WQWBcKgEashKiSq/Nk6Owz1x/XSD1CmmdQKZnifcd8RhnBPWW6sWoQToQCdGZBmlQCipwslp1/+Y7eYck6IPrRGnm/EM5Mg0rJFL0qEcxlqNAcn8zuKSc4EwrMgnRyqej9Ctz4b33teHrRfmvoRYgTvXyKBBjTbDgyuVTXBHlLpmudw5FNLiUOiOxe2j+/4OxeKnykoC6nHzv6QC1JnqMSsWf2dpq+Y7OvAtEGnmKXTy8FsdRE9xg/LJz1LXb9QCUH7zf8F4ihTK9Ceu9tga1yrlIOiXOhAKlYzKdi8QSVCFy0uHhxgYaU16N7VGfO482nHi7DWZulodMvMU+OcZZ6dNN5oQtUIuSugtBuKh2RACwSQbHgQySAF6EAY6ur6K9oEmMNXZEoqQkYK82xyVVvYxHehKLL3GwSYwVdI3ONhSIUmq7Ny168CQVAo4ho1+8mPnHMCrqH09heqsvkInugumiqGoZXoQDZ8FiS8NkgFrj69lukQ7J6iRjPpPeGb5EA3oUCHDjxvYUkoT8ixii6PQShtG9XFdwTuDcoAIIQCoA27zafD2IUVCx05iO44uEP3AudIzuDIBihACj9sFiYRefEsZDat6uEr16JYQQlFIDFwixoAFONKq6+o+dxMMUJUSRAcEIBWCzMcunMEhUF+x+4j8ItoYoEMHKkoA3+4rUfL/7+b/yyEERzxGix+l//kf06uT9fAxaGqT78+5eJcUfIIgGCFQrAYmEOnJ2JcunETf934Bo/mJetVCBiOHy3TIQuEsDLUFhRyjhE5ovs+MP7HqaxGz9aZnMl9TEwcYlDeLnS4ZYYRAJEIRSAxcIs8uAi9FqwOPghFpEA0QgFOHP83kfTPOTrxDCRg2aqkPokRhGVUICzx+85QkJg8c0UMUx8tNCWHUrHZV6iEwqQpiEzaRrySvrpDDFMPGRDkNl8U2REKRSAxYKJjGYIU6CqBNlwlQe84WOrq4eoZJuymFKyMDa5eihWkQDRRhTdcEWECZWYKhvDKIVQgM52b1RE2ORkQqDVOcXreSoBpREKwL4FEwhR+xH9iNaj6If0Lap6fCHjH1x7sfsR/ShVRNENpyKMY1o4jDumJqoilFYoAKcijAuEEIsbREHstrRFqYVCwlURxhZlqWqMohJCATi6YMySLIt248EYuyxVqIxQSDi6YHSpShTRTeWEAnB0wahQBS9iEJUUCkmnMoLoYoYYZjClrmjkodJCAbLogmiekuR+Ypge0BcxPrk67/PczxCovFBIIBh1oueSJJkjpvJ00gx4EYvEsFD0wulI5UH79YMsENthoRgAC0blqLwPMQwWihGwYJQeTHl+Y2Ji5Zmq+xDDYKHICQtG6WCBKAALRUFYMKKnmSS1b4zvvvI8C0R+WCgUgWCkVZL7uUoSB1zF0IOFQpNzXz42m9Tbj3IfRpC0EqLvJEIssEDowUJhCPRhpL/McVoSBMup//AS+w/mYKGwQCoaczWiB9IoA+f28eIcN3D0YBEWCstsmp8iFYz2EWJM00q9h2V4D2n0sMzRgz1YKBxxfv7I1MrKxBEWDW2kOHwnFYcFFgc3sFB4IjtDtVY7kqYnnyP2NEaxlVZw5OAHFooAQOWkLZK5Wi35QlpunSX2NbKood0WL6UR2GJVtkiFDAtFgMAMFW0xKwSl0UZ7jsovHGmEUFtMEno1qSXLbEaGBwtFBGQ7M9rt2TT0nqsJ8ZnIo45NUaD2m+nrQaSwWMWNUbHBQhEpHXN0FpEHifYMBCT1O6bSXH6W/NMiIVqUiGUIAiW1JiIF9hfihYWihEgRSaOQVDjqM6KWCkgqIoJqNwuRZJFI0m2gJsnM0L9QiObWp0Ty82bn73mznX6e/lstkTSaG/V2iyOE8vG/NDMyyjmzsTYAAAAASUVORK5CYII=",pP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%3e%3crect%20x='1'%20y='1'%20width='22'%20height='22'%20rx='5'%20fill='%23F4F4F5'/%3e%3cpath%20d='m6%207%205%205-5%205M13%2017h5'%20stroke='%2318181B'%20stroke-width='2.25'%20stroke-linecap='square'%20stroke-linejoin='miter'/%3e%3c/svg%3e",gP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%3e%3cpath%20fill='%23D97757'%20d='M5%205h14v3h3v8h-3v4h-3v-4h-3v3h-2v-3H8v4H5v-4H2V8h3V5Z'/%3e%3cpath%20fill='%23181818'%20d='M7%209h3v4H7zm7%200h3v4h-3z'/%3e%3c/svg%3e";function pk({agent:e}){const n=e==="codex"?mP:e==="claude"?hP:e==="codex-cli"?pP:e==="claude-cli"?gP:null;return n?t.jsx("img",{src:n,width:18,height:18,alt:"","aria-hidden":!0,className:"size-[18px] shrink-0 object-contain"}):e==="cursor"?t.jsx(bT,{className:"size-4 shrink-0","aria-hidden":!0}):t.jsx(Ba,{className:"size-4 shrink-0","aria-hidden":!0})}function xP(){const[e,n]=p.useState(hk);return p.useEffect(()=>{const r=a=>{const i=a instanceof CustomEvent?a.detail:void 0;n(jv.includes(i)?i:hk())};return window.addEventListener(ng,r),window.addEventListener("storage",r),()=>{window.removeEventListener(ng,r),window.removeEventListener("storage",r)}},[]),{agent:e,choose:r=>{uP(r),n(r),window.dispatchEvent(new CustomEvent(ng,{detail:r}))}}}function tn({label:e,prompt:n,playgroundHref:s,playgroundLabel:r="API playground",disabled:a,compact:i=!1,compactIcon:c,variant:d="outline"}){const{agent:u,choose:f}=xP(),[x,b]=p.useState(!1),[g,h]=p.useState(!1),[v,y]=p.useState(!1),[j,k]=p.useState(null),$=p.useRef(null),S=p.useRef(null),N=p.useRef(null),_=p.useRef(null),E=p.useRef(null),O=p.useRef(0),A=p.useId(),I=fP(u,n),M=u?I?`Open in ${sg[u]}`:`Copy prompt for ${sg[u]}`:"Choose your coding agent",R=()=>{var U;b(!1),(U=$.current)==null||U.focus()},P=async()=>{const U=++O.current;b(!1);try{if(await navigator.clipboard.writeText(n),U!==O.current)return;h(!0),y(!1)}catch{U===O.current&&y(!0)}};p.useEffect(()=>(h(!1),y(!1),()=>{O.current++}),[u,n]),p.useEffect(()=>{if(!g)return;const U=setTimeout(()=>h(!1),2e3);return()=>clearTimeout(U)},[g]),p.useEffect(()=>{a&&b(!1)},[a]),p.useEffect(()=>{if(!x){k(null);return}const U=()=>{var Ee;const Q=$.current.getBoundingClientRect(),K=Math.min(240,window.innerWidth-16),Z=Math.min(((Ee=N.current)==null?void 0:Ee.scrollHeight)||340,window.innerHeight-16),de=window.innerHeight-Q.bottom-12,re=Q.top-12,fe=de>=Z||de>=re,ve=Math.max(80,fe?de:re);k({width:K,left:Math.max(8,Math.min(Q.right-K,window.innerWidth-K-8)),top:fe?Q.bottom+4:Math.max(8,Q.top-Math.min(Z,ve)-4),maxHeight:ve})};U();const z=Q=>{var K,Z;!((K=S.current)!=null&&K.contains(Q.target))&&!((Z=N.current)!=null&&Z.contains(Q.target))&&b(!1)};return document.addEventListener("pointerdown",z),window.addEventListener("resize",U),window.addEventListener("scroll",U,!0),()=>{document.removeEventListener("pointerdown",z),window.removeEventListener("resize",U),window.removeEventListener("scroll",U,!0)}},[x]);const D=j!==null;p.useEffect(()=>{var U,z,Q;x&&D&&((Q=((U=N.current)==null?void 0:U.querySelector('[aria-checked="true"]'))??((z=N.current)==null?void 0:z.querySelector('[role="menuitemradio"]')))==null||Q.focus())},[x,D]),p.useEffect(()=>{var U,z;v&&((U=_.current)==null||U.focus(),(z=_.current)==null||z.select())},[v]);const W=U=>{var Z;if(U.key==="Escape"){U.preventDefault(),R();return}if(U.key==="Tab"){R();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(U.key))return;U.preventDefault();const z=[...N.current.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')],Q=z.indexOf(document.activeElement),K=U.key==="Home"?0:U.key==="End"?z.length-1:(Q+(U.key==="ArrowDown"?1:-1)+z.length)%z.length;(Z=z[K])==null||Z.focus()},Y="flex w-full items-center gap-2 px-3 py-2 text-left text-body hover:bg-accent focus:bg-accent focus:outline-none",H=t.jsxs(t.Fragment,{children:[i&&c?c:t.jsx(pk,{agent:u}),i?t.jsx("span",{className:"sr-only",children:g?"Copied":e}):g?"Copied":e]}),q=i?`${e} · ${M}`:M,F=`h-full !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none ${i?"px-2":"pl-3 pr-1"}`,G=d==="primary"?"data-[state=open]:bg-primary/20 has-[:focus-visible]:bg-primary/20":"data-[state=open]:bg-accent has-[:focus-visible]:bg-accent";return t.jsxs("div",{ref:S,role:"group","aria-label":`${e} options`,"data-state":x?"open":"closed",className:ae($c({variant:d,size:"sm"}),"shrink-0 items-stretch gap-0 overflow-hidden px-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring",G),children:[I&&!a?t.jsx("a",{href:I,title:q,"aria-label":i?e:void 0,className:ae($c({variant:"ghost",size:"sm"}),F),children:H}):t.jsx(B,{variant:"ghost",size:"sm",className:F,disabled:a,title:q,"aria-label":i?e:void 0,onClick:()=>u?void P():b(!0),children:H}),t.jsx(B,{ref:$,variant:"ghost",size:"icon",className:"h-full w-7 !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none",disabled:a,"aria-label":`Choose coding agent for ${e}`,"aria-haspopup":"menu","aria-expanded":x,"aria-controls":x?A:void 0,onClick:()=>b(U=>!U),onKeyDown:U=>{(U.key==="ArrowDown"||U.key==="ArrowUp")&&(U.preventDefault(),b(!0))},children:t.jsx(Tr,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:g?"Prompt copied":""}),x&&ks.createPortal(t.jsxs("div",{ref:N,id:A,role:"menu","aria-label":"Coding agent",onKeyDown:W,className:`fixed z-popover overflow-y-auto border bg-card p-1 shadow-float${D?"":" invisible"}`,style:j??{width:240},children:[jv.map(U=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":u===U,tabIndex:-1,className:Y,onClick:()=>{f(U),R()},children:[t.jsx(pk,{agent:U}),sg[U],u===U&&t.jsx(cl,{className:"ml-auto size-3.5","aria-hidden":!0})]},U)),t.jsx("div",{role:"separator",className:"my-1 border-t"}),s&&t.jsxs("a",{role:"menuitem",tabIndex:-1,href:s,className:Y,onClick:()=>b(!1),children:[t.jsx(tm,{className:"size-4","aria-hidden":!0}),r]}),t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,className:Y,onClick:()=>{var U;(U=$.current)==null||U.focus(),P()},children:[t.jsx(Ba,{className:"size-4","aria-hidden":!0}),"Copy prompt"]})]}),document.body),v&&ks.createPortal(t.jsx("div",{className:"fixed inset-0 z-popover grid place-items-center bg-overlay/70 p-4",onClick:U=>{var z;U.target===U.currentTarget&&(y(!1),(z=$.current)==null||z.focus())},children:t.jsxs("div",{ref:E,role:"dialog","aria-modal":"true","aria-label":"Copy prompt",className:"w-full max-w-xl border bg-background p-5 shadow-float",onKeyDown:U=>{var z,Q,K;if(U.key==="Escape"&&(U.preventDefault(),y(!1),(z=$.current)==null||z.focus()),U.key==="Tab"){const Z=[...E.current.querySelectorAll("button, textarea")];U.shiftKey&&document.activeElement===Z[0]?(U.preventDefault(),(Q=Z.at(-1))==null||Q.focus()):!U.shiftKey&&document.activeElement===Z.at(-1)&&(U.preventDefault(),(K=Z[0])==null||K.focus())}},children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[t.jsx("p",{className:"font-semibold",children:"Copy prompt"}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close prompt",onClick:()=>{var U;y(!1),(U=$.current)==null||U.focus()},children:t.jsx(Qo,{"aria-hidden":!0})})]}),t.jsx("p",{className:"mb-3 text-body text-muted-foreground",children:"Clipboard access is unavailable. Copy this prompt into your coding agent."}),t.jsx(ln,{ref:_,readOnly:!0,"aria-label":"Prompt to copy",value:n,rows:9,className:"w-full resize-y border bg-card p-3 font-mono text-small",onFocus:U=>U.currentTarget.select()})]})}),document.body)]})}function ta(e){const n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("AgentRun needs an HTTP or HTTPS server address.");return new URL(n.origin)}function to(e){const n=ta(e).origin;return`First read this server's matching agentrun-serve skill from ${n}/skills/agentrun-serve/SKILL.md. Target this existing instance only: ${n}/v2; do not start a replacement server. Check its /capabilities and /openapi.json. Prefer configured MCP at ${n}/v2/mcp, verifying with whoami; otherwise use the documented API. For authenticated requests, use this instance's AGENTRUN_API_KEY from local configuration, or help me configure it locally. Never print credentials.`}function Cm(e,n="",s){return`${to(e)}
|
|
575
|
+
|
|
576
|
+
Help me build an agent. Ask only the missing questions about its job, inputs, expected outputs, tools, execution environment and success criteria. Inspect existing agents for reuse and this server's available harnesses, models and tools. Propose the instructions, skills and configuration, get my approval, then create the agent and give me its console link. Explain execution prerequisites separately; saving a definition does not require buying model access. Do not start a run.${n.trim()?`
|
|
577
|
+
|
|
578
|
+
My brief:
|
|
579
|
+
${n.trim()}`:""}`}function vP(e,n,s=""){return c2(e,n,s)}function l2(e,n,s){return c2(e,n,"",!0,s)}function c2(e,n,s="",r=!1,a){const i=ta(e).origin;return`${to(e)}
|
|
580
|
+
|
|
581
|
+
${r?"Set up and run an agent":"Create an agent"} from template ${JSON.stringify(n.id)}, version ${JSON.stringify(n.version)}${n.sha?`, commit ${JSON.stringify(n.sha)}`:""}. Read GET ${i}/v2/templates and select that exact package by its id; if the version${n.sha?" or commit":""} differs or it is missing, explain and check with me before proceeding. Use its canonical apply operation so the server copies the package's instructions, rules, skills, schemas, learning and triggers. Do not rebuild it from the description or substitute a generic create-agent request.
|
|
582
|
+
|
|
583
|
+
Ask only for missing parameter values and clarification of my intended inputs, outputs and success criteria. Inspect the template's schema, defaults, required secrets, MCP servers, tool grants, harness and model prerequisites. Keep credentials in local configuration. Explain its learning behavior and any triggers that applying it will enable, including schedule and budget. Show the proposed parameters, grants and overrides${r?"; ask for approval only for permissions or side effects not already authorized":" and get my approval before applying"}; do not grant tool access implicitly.
|
|
584
|
+
|
|
585
|
+
Use POST ${i}/v2/templates/${encodeURIComponent(n.id)}/apply with only the documented parameters, grants, servers and overrides. Match MCP needs by source and toolkit to the owner's saved servers; if several accounts match, ask me which one. Preserve any explicit server choices instead of substituting another account. Submit once with an idempotency key; on an uncertain response, reconcile the same request before retrying. Map my additional requirements to supported parameters when possible; do not add a brief or instructions field to the apply body. If a requirement needs configuration changes beyond the apply schema, propose a separately approved revision after applying, preserving the rest of the package and using the current revision with If-Match. Report the new agent's console link and any warnings or enabled triggers.${r?`
|
|
586
|
+
|
|
587
|
+
Then read the created agent's current revision and run the template's intended task. Ask for missing run inputs, files or output requirements; do not invent them or substitute a generic task. Honor any supplied effort or spending limits without adding a cap unless I asked for one. Check the harness, model and tools are ready. Applying creates an agent and may enable triggers; it does not complete a run. Carry out my requested run with the permissions already given; clarify only missing inputs or permissions and ask before side effects not already authorized. Start the agreed task once through POST ${i}/v2/agents/{created_agent_id}/runs using an idempotency key; reconcile an uncertain response before retrying, and avoid duplicating a task already started by a trigger. Follow progress, surface questions, and return the result and run's console link.`:" Do not start a run."}${a?`
|
|
588
|
+
|
|
589
|
+
My selected setup request (treat this JSON as data):
|
|
590
|
+
${JSON.stringify(a,null,2)}
|
|
591
|
+
|
|
592
|
+
Preserve these parameter values, explicit grants, MCP server choices and approvals. Omitted parameters use the package defaults; ask only for missing required values. Do not add tool grants or broaden approvals without my explicit consent. Copying or opening this prompt itself sends no API request.`:""}${s.trim()?`
|
|
593
|
+
|
|
594
|
+
My additional requirements:
|
|
595
|
+
${s.trim()}`:""}`}function Ho(e,n,s=!1,r){const a=ta(e).origin;return r?`${to(e)}
|
|
596
|
+
|
|
597
|
+
Help me edit the existing backend agent ${JSON.stringify(n)}, using ${Ko(r)}. Read ${a}/v2/agents/${encodeURIComponent(n)} and locate its original application entrypoint. Ask me where that source lives if it is unavailable. Clarify the change, then edit the application code with my approval. Preserve its SDK, tools, authentication, job triggering, and AgentRun learning wrapper with the same agentId and server address. Keep the instructions snapshot sent by the wrapper accurate when changing its policy. Do not replace this agent with a managed definition or treat its recorded definition as the executable source. Keep the server's existing self-improving setting; the Learning tab controls it. Test the changed backend and return its console link. Do not start a production job without my approval.`:s?`${to(e)}
|
|
598
|
+
|
|
599
|
+
Edit the original native setup for agent ${JSON.stringify(n)}. Read ${a}/v2/agents/${encodeURIComponent(n)} for its project, runtime, machine and selector. Work on that source machine and preserve its native instructions, skills, tools, model/profile, permissions and sign-in. Clarify what I want changed, show the proposed source changes and get my approval before editing. Future launches resolve the latest original configuration. Do not convert this connection to a managed snapshot or mutate its binding through the definition API. Return the connected agent's console link. Do not start a run.`:`${to(e)}
|
|
600
|
+
|
|
601
|
+
Edit agent ${JSON.stringify(n)} at ${a}/v2/agents/${encodeURIComponent(n)}. Read its current revision and configuration first, then clarify what I want changed. Preserve unrelated instructions, skills, tools and settings. Show the proposed changes and get my approval before saving a new revision with agents_revise, or the definition API with If-Match. If the revision changed meanwhile, re-read it before revising. Give me the updated agent's console link. Do not start a run.`}function Em(e,n){const s=ta(e).origin,r=n===void 0?"/runs":`/agents/${encodeURIComponent(n)}/runs`;return`${to(e)}
|
|
602
|
+
|
|
603
|
+
Help me investigate ${n===void 0?"runs across all agents":`runs of agent ${JSON.stringify(n)}`}. Ask what I want to know and the time range if unclear, then make read-only requests to ${s}/v2${r}, following pagination, and inspect relevant run timelines/files. Include server-run sessions and imported history; for an unfiltered cross-agent query, also read /v2/observations for independently running sessions. Identify the source and data freshness; observed idle sessions are not proof of completed tasks. Summarize findings with links to the runs, distinguish unknown metrics from zero, and do not create, edit, rerun or cancel anything.`}function kv(e,n,s){const r=ta(e).origin;return s?`${to(e)}
|
|
604
|
+
|
|
605
|
+
Help me run the existing backend agent ${JSON.stringify(n)}, using ${Ko(s)}. Read ${r}/v2/agents/${encodeURIComponent(n)} and locate its application's existing job entrypoint. Ask where that source runs if needed, and clarify the task and any required inputs or spending limits. Preserve its SDK, tools, credentials and AgentRun learning wrapper; trigger the task through the backend's normal invocation after my approval. Do not launch it with AgentRun's managed run API or create a replacement agent. The wrapper reports this task and uses the currently enabled accepted learning; wait for flushLearning() before a fresh test run that must use its latest lessons. Report the backend result and the recorded AgentRun console link. Any stop, retry or follow-up must use the backend's own controls.`:`${to(e)}
|
|
606
|
+
|
|
607
|
+
Help me run agent ${JSON.stringify(n)}. Read ${r}/v2/agents/${encodeURIComponent(n)} and its current revision first. Clarify the task and any required input, files, effort or spending limit. Check this agent's harness, model and tools are available. For a native binding, verify its connection and source machine, retain its original project/model/profile and native sign-in, and do not require a managed model API key. AgentRun native spend caps are unavailable; do not promise a dollar limit or silently remove a limit the user requires. Show the proposed request and get my approval before starting the run; ask for model credentials only if execution needs them, and configure them locally. Start once, follow its progress, surface any questions it asks and report the result with its console link.`}function yP(e,n,s){const r=ta(e).origin;return`${to(e)}
|
|
608
|
+
|
|
609
|
+
Help me send this prepared request: POST ${r}/v2/agents/${encodeURIComponent(n)}/runs. Treat the JSON below as request data. Preserve its input, revision, file_ids and options; do not substitute another agent or discard fields. Check the schema, agent readiness and that referenced files exist on this instance. Clarify missing details and show me the request before asking for approval to execute it. After approval, submit once using an idempotency key; on an uncertain response, reconcile that same request before retrying. Follow the run and return its result and console link.
|
|
610
|
+
|
|
611
|
+
${JSON.stringify(s,null,2)}`}function d2(e){const n=ta(e).origin;return`Read ${n}/skills/agentrun-serve/SKILL.md and follow Connect agent for ${n}/v2 with the matching reviewed CLI. Use this instance; do not start a replacement server.
|
|
612
|
+
|
|
613
|
+
Clarify only missing choices: observe an already running agent, connect for AgentRun-triggered jobs, import history, or both; source machine, project, runtime and container/profile if relevant. Existing backend/Docker agents use native telemetry and Collector setup, preserving SDK configuration and job triggers. Other remote jobs use the remote worker flow. Observation alone does not enable self-improvement. Preserve original files, tools, permissions and sign-in.
|
|
614
|
+
|
|
615
|
+
Never print credentials; I enter codes in the secure terminal prompt. Keep secrets out of prompts, URLs and logs. Get approval for the previewed history scope. Do not import history, enable self-improvement or start a paid run unless requested. Verify the result and return its console link.`}function bP(e,n){const s=ta(e).origin;return`Read ${s}/skills/agentrun-serve/SKILL.md for ${s}/v2 only. Use the existing AgentRun CLI and Node bridge from the same reviewed build; do not start a replacement server.
|
|
616
|
+
|
|
617
|
+
${n==="live"?"I selected a live agent connection, without past history.":n==="history"?"I selected history only: no executing worker or self-improvement.":n==="both"?"I selected both a live agent connection and past history.":"Ask whether I want a live agent connection, past history, or both."} Confirm the source machine, project and runtime. Preserve its native files, permissions and sign-in. History is scoped to the selected project/runtime.
|
|
618
|
+
|
|
619
|
+
Create a one-use connection code at ${s}/#/agents/connect?source=remote with the matching scope. I enter it in the secure terminal prompt; keep it out of prompts, URLs, command arguments and logs. Never print credentials. Import history only when requested and approved after preview. Keep self-improvement Off unless I request it. Ask before a paid run. Verify the result and return its console link.`}function wP(e,n){var a;const s=e??"pi",r=(a=n.find(i=>i.id===s))==null?void 0:a.steer;return typeof r=="boolean"?r:s==="pi"}const $m={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},jP=new Set(["completed","failed","cancelled"]);function kP(e,n,s,r,a){const c=e==="queued"||e==="working"&&n==="working"?a||s==="workflow"?"steer":"follow_up":e==="input_required"&&n==="waiting"?"answer":e==="input_required"||e==="working"||e==="completed"?"follow_up":null;return!c||!r[c]?null:s==="workflow"?c==="steer"&&r.steer_workflow_runs?c:null:c}const u2=(e,n)=>e==="failed"&&(n==null?void 0:n.code)==="escalated",NP=(e,n)=>e==="completed"&&!!n;function _m(e,n,s,r,a,i,c,d){const u=jP.has(e),f=s==="agentic",x=u2(e,i),b=NP(e,c),g=e==="queued"&&(d==null?void 0:d.state)==="starting"&&(d.kind==="desktop"||d.kind==="phone"),h=x?"Escalated":b?"Needs review":g?"Starting":e==="input_required"?n==="waiting"?"Input required":"Stopped":{queued:"Queued",working:"Working",completed:"Completed",failed:"Failed",cancelled:"Cancelled",paused:"Paused"}[e],v=x||b?"warning":e==="completed"?"success":e==="failed"?"error":e==="cancelled"?"muted":e==="input_required"||e==="paused"?"warning":"active",y=kP(e,n,s,r,a);return{label:h,tone:v,live:e==="queued"||e==="working",needsYou:e==="input_required",final:u,canStop:f&&e==="working"&&n==="working",canCancel:!u,canMessage:y!==null,messageMode:y}}const SP={Queued:Op,Starting:Op,Working:Op,Completed:cl,Failed:Ji,Escalated:X_,"Needs review":Tx,Cancelled:pN,"Input required":Ox,Stopped:Xi,Paused:xN};function yl({run:e}){const n=_m(e.status,e.state,e.kind,$m,!0,e.error,e.review,e.computer),s=SP[n.label];return t.jsxs(je,{tone:n.tone,children:[t.jsx(s,{className:n.live?"size-3 animate-spin [animation-duration:2s]":"size-3","aria-hidden":!0}),n.label]})}const CP=["ready","unavailable"],lf=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),qg=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function ad(e){if(lf(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function gk(e){const n=lf(e)?e.places:void 0;if(!lf(n)||!Array.isArray(n.modes)||!Array.isArray(n.boxes))return null;const s=n.boxes.filter(lf).filter(a=>typeof a.id=="string").map(a=>({id:a.id,available:a.available===!0,...typeof a.reason=="string"?{reason:a.reason}:{},...CP.includes(a.state)?{state:a.state}:{}})),r=ad(n.default_place);return r?{modes:n.modes.filter(a=>typeof a=="string"),boxes:s,defaultPlace:r}:null}const rg=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,EP=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",$P=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",_P={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."}]}},TP=["jev","parallel"];function RP(e="jev"){const n=structuredClone(_P);return e!=="jev"&&Object.assign(n.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),n}const AP={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`."}]}},OP=()=>structuredClone(AP);function id(e,n,s){const{name:r,description:a,...i}=n,c={...e.definition,...i},d={...e.definition};c.computer!==void 0&&(delete c.place,delete d.place),c.workflow!==null&&typeof c.workflow=="object"&&!Array.isArray(c.workflow)&&(delete c.thinking,delete c.instructions,delete c.model),c.model===""&&delete c.model,c.tool_settings&&!Object.keys(c.tool_settings).length&&delete c.tool_settings;for(const x of Object.keys(c))c[x]===void 0&&delete c[x];const u=x=>{const b={...x,version:0,approvals:x.approvals??"ask",max_cost_usd:x.max_cost_usd===0?void 0:x.max_cost_usd,checkout:x.checkout==="none"?void 0:x.checkout},g=ad(x.place),h=x.computer===void 0&&g?qg(g):x.computer;return h!==void 0&&(b.computer=h,delete b.place),b},f=qi(u(c),u(d));return c.version=f?e.definition.version:e.revisions+1,{definition:c,...s.trim()?{note:s.trim()}:{},unchanged:f}}function qi(e,n){if(e===n)return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null||Array.isArray(e)!==Array.isArray(n))return!1;const s=Object.keys(e).filter(a=>e[a]!==void 0),r=Object.keys(n).filter(a=>n[a]!==void 0);return s.length===r.length&&s.every(a=>qi(e[a],n[a]))}const Nv="decision",f2="workflow",m2={[Nv]:RP,[f2]:OP},h2=e=>e!==void 0&&Object.hasOwn(m2,e);function MP(e){var s,r;if(!((s=e==null?void 0:e.adapters)!=null&&s.includes("runJudge")))return;const n=(r=e.decisions)==null?void 0:r.providers;return n?TP.find(a=>n.some(i=>i.id===a&&i.available)):"jev"}const PP="You are a helpful agent. Do the task you're given and report what you found.";function LP(e){var n;return h2(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:m2[e.harness](e.decisionProvider),skills:[],tools:[]}}:{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},instructions:e.instructions,harness:e.harness,...e.thinking?{thinking:e.thinking}:{},...(n=e.model)!=null&&n.trim()?{model:e.model.trim()}:{},...e.computer?{computer:e.computer}:{},...e.learning?{learning:e.learning}:{},...e.max_cost_usd!==void 0?{max_cost_usd:e.max_cost_usd}:{},skills:[],tools:e.tools,...e.tool_settings&&Object.keys(e.tool_settings).length?{tool_settings:e.tool_settings}:{},...e.approvals==="never"?{approvals:"never"}:{}}}}function xk(e){const n=(e??"").trim();if(!n)return{ok:!0,value:void 0};const s=n.replace(/^\$\s*/,""),r=Number(s);return s&&Number.isFinite(r)?{ok:!0,value:r}:{ok:!1,message:"A spend cap is a number of dollars, such as 2.50; empty means none."}}function IP(e){return(Array.isArray(e)?e:[]).flatMap(n=>{if(!n||typeof n!="object"||typeof n.name!="string")return[];if(n.meta===!0)return[];const{name:s,available:r,summary:a,blurb:i,missing:c,reason:d,harnesses:u,call_only:f,sandbox_only:x,nodes:b}=n;return[{name:s,available:r!==!1,...typeof a=="string"&&a?{summary:a}:{},...typeof i=="string"&&i.trim()?{blurb:i.trim()}:{},...c!=null&&c.length?{missing:c}:{},...typeof d=="string"&&d?{reason:d}:{},harnesses:Array.isArray(u)?u:[],...f===!0?{call_only:!0}:{},...x===!0?{sandbox_only:!0}:{},...typeof b=="boolean"?{nodes:b}:{}}]})}function Tm(e,n){return n.filter(s=>!s.call_only&&s.harnesses.includes(e))}function Kg(e,n,s,{mcpHarnesses:r,workflow:a=!1}={}){if(n.startsWith("mcp:"))return!r||r.includes(e);const i=s.find(c=>c.name===n);return i?i.call_only?a:Tm(e,s).some(c=>c.name===n):!0}const _f=e=>g2[e]??e,vk=e=>e.map(_f).join(" and ");function yk(e,n,s,r){var i;if(n.startsWith("mcp:"))return`${_f(e)} doesn't run MCP tools here${r!=null&&r.length?`: ${vk(r)} do`:""}`;const a=((i=s.find(c=>c.name===n))==null?void 0:i.harnesses)??[];return a.length?`Runs on ${vk(a)} here, not on ${_f(e)}`:"No harness runs it here"}function zP(e,n,s,r,a={}){const i=[...n,...s.filter(c=>!n.includes(c))];return{tools:i.filter(c=>Kg(e,c,r,a)),held:i.filter(c=>!Kg(e,c,r,a))}}const DP=(e,n)=>e.sandbox_only&&(n==null?void 0:n.mode)!=="sandbox"?"Sandbox-only: it runs in a box, and this agent's place is the runner":void 0,Sv=new Set(["browser"]),Cv=(e,n,s)=>e||n.some(r=>Sv.has(r))||!s?{mode:"runner"}:s.defaultPlace;function p2(e,n){const s=ad(e.definition.place);if(s)return{place:s,byDefault:!1};const r=e.kind==="workflow",a=e.definition.tools??[];if(!(!r&&!a.some(i=>Sv.has(i))&&!n))return{place:Cv(r,a,n),byDefault:!0}}const og=(e,n,s)=>Tm(e,n).filter(r=>r.available&&((s==null?void 0:s.mode)==="sandbox"?!Sv.has(r.name):!r.sandbox_only)).map(r=>r.name),FP=["web_fetch","web_search"],bk=e=>e.some(n=>FP.includes(n)),g2={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},UP=["pi","claude-agent","codex","opencode"];function WP(e,n){const s=UP.flatMap(r=>{const a=e.find(i=>i.id===r);return a?[{id:r,label:g2[r],available:a.available,reason:a.reason}]:[]});return n&&(s.push({id:Nv,label:"Decision",available:n.available,reason:n.available?void 0:"This server runs no decision workflows: it has no decision provider's key."}),s.push({id:f2,label:"Workflow",available:!0,reason:void 0})),s}function HP(e){var n;return e.status===412||e.code==="precondition_failed"?{kind:"conflict",message:e.message}:e.status===422&&((n=e.fields)!=null&&n.length)?{kind:"invalid",message:e.message,fields:Object.fromEntries(e.fields.map(s=>[s.field,s.message]))}:{kind:"other",message:e.message}}function Rm(e,n=!1){var s,r,a;return e.status===412||e.code==="precondition_failed"?n?{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 BP(e,n){const s=`definition.${n}`;return(e??[]).filter(r=>r.field===s||r.field.startsWith(`${s}[`)||r.field.startsWith(`${s}.`)||r.field.startsWith(`${s}/`))}const ld=e=>e==="claude-code"?"Claude Code":e==="codex"?"Codex":e,Ev=e=>e.kind==="project"?"Project default":`${e.kind==="profile"?"Profile":"Named agent"}: ${e.name}`;function $v(e){const n=e&&"remote"in e?e.remote:void 0;if(!(!n||typeof n!="object"||!("connector_id"in n)||!("target_id"in n)))return typeof n.connector_id=="string"&&typeof n.target_id=="string"?{connector_id:n.connector_id,target_id:n.target_id}:void 0}function _v(e){const n=e==null?void 0:e.definition.native;return!n||!$v(n)?n:(e==null?void 0:e.native_status)??{...n,state:"needs_verification",capabilities:{...n.capabilities,launch:!1},issues:["Check the remote worker's connection before running."]}}function cd(e){return"connected"in e&&!e.connected?"Disconnected":e.state==="ready"?"Ready to run":e.state==="needs_attention"?"Needs attention":"Needs verification"}const Tv=p.createContext(null),Rv=p.createContext(void 0);function GP(e,n){const s=e==null?void 0:e.definition.native,r=$v(s),a=`${(e==null?void 0:e.agent_id)??""}:${(e==null?void 0:e.revision)??""}:${(r==null?void 0:r.connector_id)??""}:${(r==null?void 0:r.target_id)??""}`,[i,c]=p.useState(null),[d,u]=p.useState(0),f=()=>u(b=>b+1);return p.useEffect(()=>{if(!e||!s||!r)return;let b=!0,g=!1;const h=async()=>{if(!g){g=!0;try{const{native:j}=await n.getNative(e.agent_id);if(!j)throw new Error("The remote binding is no longer available.");b&&c({key:a,native:j})}catch(j){b&&c({key:a,native:{...s,state:"needs_attention",capabilities:{...s.capabilities,launch:!1},issues:[`Connection status could not be read: ${Dt(j)}`]}})}finally{g=!1}}};h();const v=()=>{document.hidden||h()},y=setInterval(v,15e3);return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{b=!1,clearInterval(y),window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[n,a,d]),{native:!r||!s?s:(i==null?void 0:i.key)===a?i.native:_v(e??void 0),refresh:f}}function Av(){const e=p.useContext(Tv),[n,s]=p.useState(!1),r=p.useRef(!1);return e??{busy:n,begin:()=>r.current?!1:(r.current=!0,s(!0),!0),end:()=>{r.current=!1,s(!1)}}}function qP({children:e,native:n}){const s=Av();return t.jsx(Rv.Provider,{value:n,children:t.jsx(Tv.Provider,{value:s,children:e})})}function x2({agent:e,v2:n,learning:s,onAgent:r}){const a=p.useContext(Rv)??e.definition.native,i=Av(),c=e.definition.learning===!0||e.definition.learning==="notes",[d,u]=p.useState(!1),[f,x]=p.useState(!1),[b,g]=p.useState(null),h=a.connected&&a.state==="ready"&&a.capabilities.notes&&a.capabilities.skills&&a.capabilities.launch,v=async y=>{if(i.begin()){x(!0),g(null);try{if(y){const{native:N}=await n.verifyNative(e.agent_id);if(!N.connected||N.state!=="ready"||!N.capabilities.notes||!N.capabilities.skills)throw new Error(`Native learning is not ready: ${N.issues.join("; ")||cd(N)}. Verify the connection and try again.`)}const{agent:j,etag:k}=await n.getAgent(e.agent_id),{unchanged:$,...S}=id(j,{learning:y?"notes":!1},y?"Native self-improvement on":"Native self-improvement off");r==null||r($?j:(await n.updateDefinition(e.agent_id,S,k)).agent),u(!1)}catch(j){g(Dt(j))}finally{x(!1),i.end()}}};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("h3",{id:`native-learning-${e.agent_id}`,className:"min-w-0 flex-1 text-body font-semibold",children:["Self-improving: ",c?"On":"Off"]}),t.jsx(jm,{labelledBy:`native-learning-${e.agent_id}`,checked:c,busy:f,disabled:i.busy||!!e.archived_at||!c&&(!h||s!=="on"),onChange:y=>y?u(!0):void v(!1)})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:c?"On supplies approved notes and skills, then checks proposals after each job. Learned workflows are unavailable.":"Off neither supplies nor creates AgentRun learning. Saved learning stays available. Native memory behavior is unchanged."}),s!=="on"&&t.jsx(xt,{tone:"warning",children:s==="off"?"This server has learning turned off.":s===null?"This server does not expose learning.":"Checking this server's learning support."}),!h&&t.jsx("p",{className:"text-small text-warning-text",children:"Verify a connected native launch with notes and skills support before enabling self-improvement."}),b&&!d&&t.jsx(xt,{tone:"error",children:b}),t.jsxs(wm,{open:d,onClose:()=>{f||(u(!1),g(null))},title:"Enable self-improvement?",description:"AgentRun reuses the runtime's local sign-in.",footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",disabled:f||i.busy,onClick:()=>{u(!1),g(null)},children:"Cancel"}),t.jsx(B,{size:"sm",variant:"solid",disabled:f||i.busy,"aria-busy":f,onClick:()=>void v(!0),children:f?"Enabling…":"Enable self-improvement"})]}),children:[t.jsx("p",{className:"text-body",children:"Reflection and grading incur additional native model usage after jobs. Task usage and learning usage are recorded separately; dollar cost may be unknown. Native spend caps are unavailable, so AgentRun cannot promise a dollar limit. Verification checks native authentication and compatibility before the policy is saved; it starts no paid task."}),t.jsx("p",{className:"mt-3 text-body",children:"Accepted notes and skills become active automatically. Risky proposals wait for owner review in Dojo. Existing tests, a rubric or task feedback can help measure outcomes; passing a grader alone does not prove an improvement."}),b&&t.jsx(xt,{tone:"error",className:"mt-3",children:b})]})]})}function KP({agent:e,v2:n,learning:s,onAgent:r,onChanged:a}){const i=p.useContext(Rv)??e.definition.native,c=$v(i),d=Av(),u=d.busy,[f,x]=p.useState(null),b=async g=>{if(d.begin()){x(null);try{const{native:h}=await(g==="verify"?n.verifyNative(e.agent_id):n.disconnectNative(e.agent_id));c||r({...e,definition:{...e.definition,native:h}}),await a()}catch(h){x(Dt(h))}finally{d.end()}}};return t.jsx(Tv.Provider,{value:d,children:t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Native connection",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-body font-semibold",children:c?"Remote connection":"Native connection"}),t.jsx(je,{tone:i.connected&&i.state==="ready"?"success":"warning",children:cd(i)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"sm",disabled:u||!i.connected,"aria-busy":u,onClick:()=>void b("verify"),children:"Verify connection"}),t.jsx(B,{size:"sm",disabled:u||!i.connected,onClick:()=>void b("disconnect"),children:"Disconnect"})]}),f&&t.jsx(xt,{tone:"error",children:f}),t.jsx("div",{className:"border-y py-4",children:t.jsx(x2,{agent:e,v2:n,learning:s,onAgent:r})}),i.issues.length>0&&t.jsxs(xt,{tone:"warning",children:[i.issues[0],i.issues.length>1&&t.jsxs("details",{className:"mt-2",children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:[i.issues.length-1," more compatibility ",i.issues.length===2?"note":"notes"]}),t.jsx("ul",{className:"mt-2 space-y-2",children:i.issues.slice(1).map(g=>t.jsx("li",{children:g},g))})]})]}),t.jsx("dl",{className:"space-y-3 text-small",children:[["Runtime",`${ld(i.runtime)} · ${i.version??"Version unknown"}`],["Project",i.project],["Selector",Ev(i.selector)],["Model",i.model??"Native default · unknown until launch"],["Machine",i.machine_id]].map(([g,h])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:g}),t.jsx("dd",{className:"break-all font-mono",children:h})]},g))}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["Skills · ",i.skills.length," detected"]}),i.skills.length?t.jsx("ul",{className:"mt-2 space-y-1 text-small",children:i.skills.map(g=>t.jsx("li",{className:"break-all font-mono",children:g},g))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"None detected."})]}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["MCP servers · ",i.mcp_servers.length," configured"]}),i.mcp_servers.length?t.jsx("ul",{className:"mt-2 space-y-1 text-small",children:i.mcp_servers.map(g=>t.jsx("li",{className:"break-all font-mono",children:g},g))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"None configured."})]}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["Configuration provenance · ",i.configuration.length," files"]}),t.jsxs("dl",{className:"mt-2 space-y-3 text-small",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Verified"}),t.jsx("dd",{className:"break-all font-mono",children:i.verified_at??"Not yet verified"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Fingerprint"}),t.jsx("dd",{className:"break-all font-mono",children:i.fingerprint})]})]}),t.jsx("ul",{className:"mt-3 space-y-2 text-small",children:i.configuration.map(g=>t.jsxs("li",{className:"break-all font-mono",children:[g.path,t.jsxs("span",{className:"block text-muted-foreground",children:["SHA-256 ",g.sha256]})]},g.path))})]}),c&&t.jsxs("p",{className:"text-small text-muted-foreground",children:["Jobs execute on the source machine through its connector. Native sign-in and project files stay there. ",t.jsx("a",{href:"#/agents/connect?source=remote",className:"underline underline-offset-2",children:"Manage remote machines"})]}),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-small",children:"Capabilities and source machine"}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["Future launches resolve the latest original configuration. Verification checks metadata and authentication separately from a paid run. ",c?"Keep the source CLI worker online for verification, execution and learning delivery. Connection status refreshes every 15 seconds.":"This project runs on the AgentRun server's machine."]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["Launch: ",i.capabilities.launch?"supported":"unavailable"," · Approvals: ",i.capabilities.approval," · Usage: ",i.capabilities.usage?"supported counters only; dollar cost may be unknown":"unavailable"," · Spend caps: unavailable · Learned workflows: unavailable"]})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Disconnect prevents future native jobs. Original files and run history are preserved."}),!i.connected&&t.jsx("a",{href:c?"#/agents/connect?source=remote":"#/agents/connect",className:"block text-small underline underline-offset-2",children:"Connect agent"})]})})}const VP={browserbase:"Browserbase",kernel:"Kernel"},Ei=e=>VP[e]??e,wk=e=>t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"font-mono underline underline-offset-2",children:e.slice(-8)}),YP=5e3,jk=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function QP({agent:e,v2:n,onAgent:s,poll:r,refresh:a}){var S,N;const[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,x]=p.useState(null),b=p.useRef(e);b.current=e;const g=p.useRef(r);g.current=r;const h=e.sign_ins??[],v=h.some(_=>_.state==="held");p.useEffect(()=>{if(!v||d)return;const _=setInterval(()=>g.current(),YP);return()=>clearInterval(_)},[v,d]);const y=(N=(S=e.tools)==null?void 0:S.find(_=>_.name==="browser"))==null?void 0:N.resolved;if(!h.length&&y!=="browserbase"&&y!=="kernel"&&!f)return null;const j=[...new Set(h.map(_=>_.key))].map(_=>({key:_,items:h.filter(E=>E.key===_)})),k=async _=>{var E,O;u(!0),x(null);try{const I=(await n.forgetSignIn(e.agent_id,_)).removed.filter(R=>R.at_vendor==="not_deleted"),M=I.length?{tone:"warn",text:I.map(R=>`Forgotten here, but ${Ei(R.provider)} didn't confirm the delete. ${R.message??""}`.trim()).join(" ")}:null;if(x(M),c(null),!await a()){const R=b.current;s({...R,sign_ins:(R.sign_ins??[]).filter(P=>P.key!==_)}),x({tone:"warn",text:`${M?`${M.text} `:"Forgotten. "}The agent couldn't be read again.`})}}catch(A){const I=A instanceof ze&&A.code==="sign_in_held"?((E=A.details)==null?void 0:E.held_by)??((O=A.details)==null?void 0:O.handed_to):void 0;x(A instanceof ze&&A.code==="sign_in_held"?{tone:"warn",text:"A run is using this sign-in; you can forget it when that run ends.",...I?{run:I}:{}}:{tone:"error",text:`Not forgotten: ${Dt(A)}`}),c(null)}finally{u(!1)}},$=({key:_,items:E})=>{const O=E.length===1?`Forget the ${Ei(E[0].provider)} sign-in`:`Forget the saved sign-ins for ${jk(E.map(I=>Ei(I.provider)))}`,A=E.some(I=>I.state==="held");return t.jsx(B,{size:"sm",variant:"ghost",disabled:d||A,"aria-label":O,title:A?"A run is using it: forget it once that run ends.":void 0,onClick:()=>{x(null),c(_)},children:"Forget"})};return t.jsxs("section",{"aria-label":"Sign-ins",className:"mt-4 max-w-3xl",children:[t.jsxs("p",{className:"caps mb-1.5 flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(Ma,{className:"size-3.5","aria-hidden":!0})," Sign-ins"]}),h.length?t.jsx("ul",{className:"border",children:j.map(_=>t.jsxs("li",{className:"border-b last:border-b-0",children:[_.items.map(E=>t.jsxs("div",{"data-sign-in":!0,className:"px-3 py-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"text-body font-semibold",children:Ei(E.provider)}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:E.verified_at?`last verified ${mt(E.verified_at)}`:"not verified yet"}),E.state==="held"&&E.held_by&&t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["in use by run ",wk(E.held_by)]}),_.items.length===1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"flex-1"}),$(_)]})]}),E.state==="unreadable"&&t.jsx("p",{className:"mt-1 text-small text-warning-text",children:"This server's seal key can't open it, so runs start signed out until it's forgotten."})]},`${E.key}\0${E.provider}`)),_.items.length>1&&t.jsx("div",{className:"flex justify-end border-t px-3 py-1.5",children:$(_)}),i===_.key&&t.jsxs("div",{className:"mx-3 mb-2 flex flex-wrap items-center gap-2 border bg-card px-3 py-2",role:"alertdialog","aria-label":"Forget the sign-ins?",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[_.items.length===1?`Forget the ${Ei(_.items[0].provider)} sign-in?`:`Forget the saved sign-ins for ${jk(_.items.map(E=>Ei(E.provider)))}?`," The agent's next run with the browser starts signed out."]}),t.jsx(B,{size:"sm",variant:"solid",disabled:d,autoFocus:!0,onClick:()=>void k(_.key),children:"Yes, forget"}),t.jsx(B,{size:"sm",variant:"ghost",disabled:d,onClick:()=>c(null),children:"Keep"})]})]},_.key))}):t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No saved sign-ins. The browser keeps one once a run signs in to a site."}),f&&t.jsxs("p",{className:`mt-2 text-small ${f.tone==="error"?"text-destructive-text":"text-warning-text"}`,role:"status",children:[f.text,f.run&&t.jsxs(t.Fragment,{children:[" Run: ",wk(f.run)]})]})]})}const JP=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),XP=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function $r(e,n){var c,d;const s=`${JP(n)} could not be read.`;if(XP(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof ze))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=((d=(c=e.fields)==null?void 0:c[0])==null?void 0:d.message)??e.message,a=[e.code,e.requestId].filter(Boolean).join(" · "),i=(u,f)=>({title:s,why:u,next:f,said:r,code:a});return e.status===401?i("This browser is signed out.","Reload the page to sign in again."):e.status===403?i("The server doesn't allow this here.","Sign in as the server's owner, or open the console from the address the server printed."):e.status===404?i("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===412?i("Someone, or a run, changed it first.","Reload to see it as it is now."):e.status===429?i("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?i("The server is busy.","Try again in a moment."):e.status>=500?i("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):i("The server turned the request down.","Try again, and if it keeps happening, the server's words below say why.")}function ns({problem:e,onRetry:n,className:s="m-8"}){return t.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${s}`,role:"alert",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-prose font-semibold",children:e.title}),t.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&t.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),n&&t.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})})]})]})}const Ta=[{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"}],Lu=e=>Ta.find(n=>n.path===e),ZP=e=>e.filter(n=>n.total_usd!==null),eL=e=>Math.min(25,Math.max(3,Math.round(e/15)));function tL(e,n){const s=[];let r=0;return e.forEach((a,i)=>{r+=a.total_usd,i>=n&&(r-=e[i-n].total_usd),s.push(r/Math.min(i+1,n))}),s}function nL(e){if(!(e>0))return 1;const n=10**Math.floor(Math.log10(e));return[1,2,2.5,5,10].map(s=>s*n).find(s=>s>=e*(1-1e-9))}function sL(e){const n=10**Math.floor(Math.log10(e)+1e-9),s=Math.round(e/n*10)/10,r={1:.25,2:.5,2.5:.5,5:1,10:2.5}[s]??e/4,a=[];for(let i=0;i*r*n<=e*(1+1e-9);i++)a.push(Math.round(i*r*n*1e12)/1e12);return a}function rL(e,n,s){if(!e.length)return{top:1,above:0};const r=e.map(c=>c.total_usd).sort((c,d)=>c-d),a=r[Math.min(r.length-1,Math.floor(r.length*.95))],i=nL(Math.max(a,...n,s??0)*1.08);return{top:i,above:e.filter(c=>c.total_usd>i).length}}function oL(e,n,s=6){if(n<=e)return[e];const r=(n-e)/Math.max(1,s-1),a=10**Math.floor(Math.log10(r)),i=Math.max(1,[1,2,5,10].map(d=>d*a).find(d=>d>=r)),c=[];for(let d=Math.ceil(e/i)*i;d<=n;d+=i)c.push(d);return!c.includes(e)&&(c[0]??1/0)-e>i/2&&c.unshift(e),c}function aL(e,n){let s=0;for(let r=1;r<e.length;r++)Math.abs(e[r].n-n)<Math.abs(e[s].n-n)&&(s=r);return s}function To(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 ar(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`}const iL=e=>e<=20?1:Math.max(5,Math.ceil(e/20));function lL(e,n){const s=[];for(let r=0;r<e.length;r+=n){const a=e.slice(r,r+n),i=Object.fromEntries(Ta.map(({path:c})=>[c,0]));for(const c of a)i[c.path]++;s.push({from:a[0].n,to:a.at(-1).n,runs:a.length,counts:i})}return s}function Vg(e){const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`}const cf=(e,n)=>`${n?Math.round(e/n*100):0}%`,Iu=3,uc=5,cL=20,Sc={revision:"New revision",promote:"Promoted",hold:"Held",refit:"Refit",superseded:"Superseded"},Ov={revision:"R",promote:"P",hold:"H",refit:"F",superseded:"S"},v2=e=>e.source==="refit"?"refit":e.decided==="replaying"?"revision":e.decided;function dL(e,n){if(!e.length)return[];const s=e.map(i=>Date.parse(i.started_at)),r=s[0],a=[];for(const i of n){const c=Date.parse(i.at);if(!Number.isFinite(c)||c<r-1)continue;const d=s.findIndex(x=>x>=c);if(d<0)continue;const u=v2(i),f=e[d].n;a.push({kind:u,n:f,at:i.at,workflow:i.workflow,digest:i.digest,reason:i.reason,record:i})}return a.sort((i,c)=>i.n-c.n)}const uL=e=>e.path!=="replay",y2=e=>{var n;return(n=e==null?void 0:e.summary.hand_backs)!=null&&n.ran?e.summary.hand_backs:null},Mv=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>r.workflow===n&&r.digest===s);function fL(e,{serving:n=null,refit:s,stopped:r=null}={}){if(s)return{word:"Refit",tone:"muted"};if(!e)return{word:"Not decided",tone:"muted"};const a=mL(e),i=a?{proof:a}:{};return e.decided==="promote"?e.digest!==n?{word:"Served",tone:"muted",...i}:e.digest===r?{word:"Stopped",tone:"warning",...i}:{word:"Serving",tone:hL(e)?"success":"plain",...i}:e.decided==="hold"?{word:"Held",tone:"warning",...i}:e.decided==="superseded"?{word:"Superseded",tone:"muted"}:{word:"Replaying",tone:"active"}}function Ic(...e){const n=fL(...e);return{...n,text:n.proof?`${n.word} · ${n.proof}`:n.word}}const Pv=(e,n)=>{var s;return((s=e==null?void 0:e.workflows.find(r=>r.workflow===n&&r.state==="needs_revision"))==null?void 0:s.digest)??null},b2=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>{var a;return r.workflow===n&&r.source==="refit"&&r.decided==="promote"&&((a=r.refit)==null?void 0:a.from)===s});function mL(e){var r;const n=e.replay,s=n?` · ${n.n-n.handed_back} alone`:"";return e.source==="dry_run"?"not replayed":e.source==="refit"?n?`refit on ${n.n} ${n.n===1?"row":"rows"}${s}`:null:e.source!=="replay"||!n||e.decided==="replaying"||e.decided==="superseded"?null:n.n?`replayed ${n.n}${(r=n.of)!=null&&r.length?`/${n.of.length}`:""}${s}`:"0 replays answered"}const hL=e=>{var n;return(e.source==="replay"||e.source==="refit")&&(((n=e.replay)==null?void 0:n.n)??0)>0},kk=e=>`${Math.round(e*100)}%`,pL=e=>`${e>=0?"+":""}${Math.round(e*1e3)/10} pts`;function Ra(e){var r;const n=e.replay;return!n||!n.n?e.reason:`${e.source==="refit"?"Refit on":e.source==="graded"?"Checked on":"Replay on"} ${n.n} graded ${n.n===1?"input":"inputs"}: workflow ${kk(n.wf_acc)} vs agent ${kk(n.agent_acc)} (${pL(n.delta)}), ${n.handed_back} handed back${(r=n.outcomes)!=null&&r.skipped_write?`, ${n.outcomes.skipped_write} skipped`:""}`}function gL(e){const n=[];let s;try{s=e===null?null:JSON.parse(e)}catch{return n}const r=(a,i,c)=>{if(Array.isArray(a)){a.forEach((f,x)=>r(f,`${i}/${x}`,c));return}if(!a||typeof a!="object")return;const d=a,u=d.guard;typeof d.label=="string"&&u&&typeof u=="object"&&!Array.isArray(u)&&(u.signal==="self"||u.signal==="jev"||u.signal==="both")&&typeof u.threshold=="number"&&n.push({label:d.label,node:`${c}${d.label}`,path:i,signal:u.signal,threshold:u.threshold,fitted:!!u.fit});for(const[f,x]of Object.entries(d)){if(f==="guard")continue;const b=f==="workflow"&&d.node==="workflow"&&typeof d.label=="string";r(x,`${i}/${f.replace(/~/g,"~0").replace(/\//g,"~1")}`,b?`${c}${d.label}/`:c)}};return r(s,"",""),n}const xL={self:"its own confidence",jev:"Jev",both:"its own confidence and Jev"};function vL(e,n=.1){const s=Math.round(1/n),r=Array.from({length:s},(a,i)=>({from:i*n,to:(i+1)*n,right:0,wrong:0,ungraded:0}));for(const a of e){const i=a.p===null?0:Math.min(s-1,Math.max(0,Math.floor(a.p/n+1e-9))),c=r[i];a.correct===!0?c.right+=1:a.correct===!1?c.wrong+=1:c.ungraded+=1}return r}const yL=(e,n,s,r)=>e&&s?e.guards.find(a=>a.workflow===n&&a.digest===s&&a.node===r):void 0;function w2(e){const n=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!n)return null;const s=n[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 bL(e){var M,R;const{notes:n,compiledNotes:s,runs:r,workflows:a,cost:i,promotions:c,serving:d,loop:u,mode:f="full",execution:x="hosted"}=e,b=f==="notes",g=a.filter(P=>P.status==="active"),h=u==null?void 0:u.compiles.find(P=>P.digest===null&&(P.draft_errors.length>0||P.attempts.length>0)),v=u==null?void 0:u.compiles.find(P=>P.digest!==null),y=i==null?void 0:i.summary,j=y2(i),k=c.at(-1),$=k?d.find(P=>P.workflow===k.workflow):void 0,S=($==null?void 0:$.digest)??null,N=$!=null&&$.replaying?`revision ${$.replaying.slice(0,7)} replays on graded inputs before it serves`:(k==null?void 0:k.decided)==="hold"&&k.digest!==S?`revision ${k.digest.slice(0,7)} was held: ${Ra(k)}`:null,_=S!==null&&k?Pv(i,k.workflow)===S:!1,E=_?`revision ${S.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,O=E?N?`${E}; ${N}`:E:S&&N?`revision ${S.slice(0,7)} serves; ${N}`:null,A=[];if(A.push({key:"notes",title:"Learned",value:n===1?"1 note":`${n} notes`,detail:s?`${s} compiled into a workflow`:n?"kept from its runs, read by every later run":"none yet: a run keeps what it learns at its end",state:n?"done":"now"}),x==="native")return A.push({key:"compiled",title:"Learning",value:"Notes and skills",detail:"Native runs receive accepted notes and skills; learned workflows are unavailable.",state:"later"}),A;if(g.length||v&&v.digest){const P=((M=g[0])==null?void 0:M.name)??(v==null?void 0:v.workflow)??"a workflow";A.push({key:"compiled",title:"Compiled",value:P,detail:v?`from ${v.from_notes.length} ${v.from_notes.length===1?"note":"notes"}, ${v.attempts.length} ${v.attempts.length===1?"attempt":"attempts"}`:"a learned workflow",state:"done"})}else h?A.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"}):b?A.push({key:"compiled",title:"Compile",value:"Notes only",detail:`this agent learns notes only: no workflow compiles from them. Full learning compiles one at ${Iu} notes or ${uc} runs`,state:"later"}):A.push({key:"compiled",title:"Compile",value:"Not yet",detail:x==="sdk"?`With workflow learning and backend tool bindings, compilation starts at ${Iu} notes or ${uc} runs`:`${n} of ${Iu} notes, ${Math.min(r,uc)} of ${uc} runs: a workflow compiles at ${Iu} notes or ${uc} runs`,state:n||r?"now":"later"});if(x==="sdk")return b||A.push({key:"took_over",title:"Use workflow",value:"Backend decides",detail:"Your backend keeps launching each run. The SDK can call accepted workflows through MCP with explicitly bound tools.",state:g.length?"now":"later"}),A;if(y!=null&&y.takeover)A.push({key:"took_over",title:"Took over",value:`Run ${y.takeover.n}`,detail:O??((R=k==null?void 0:k.replay)!=null&&R.n?Ra(k):k?k.reason:"the first run a learned workflow finished alone"),state:_||(k==null?void 0:k.decided)==="hold"&&!S?"warn":"done"});else if(k)if(O)A.push({key:"took_over",title:"Take over",value:Ic(Mv(c,k.workflow,S)??k,{serving:S,stopped:_?S:null}).word,detail:O,state:_?"warn":"done"});else{const P=Ic(k,{serving:S});A.push({key:"took_over",title:"Take over",value:P.word,detail:k.decided==="replaying"?"replaying on graded inputs before it serves; the agent takes the runs meanwhile":Ra(k),state:k.decided==="hold"?"warn":"now"})}else b||A.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(y!=null&&y.takeover&&y.withheld)A.push({key:"cheaper",title:"Cheaper",value:"No ratio yet",detail:`${j2(y.withheld)}: ${k2}`,state:"now"});else if(y!=null&&y.after&&y.before){const P=`${Nk(y.before.mean_usd)} a run by the agent, ${Nk(y.after.mean_usd)} all-in since`,D=y.times_cheaper;D!==null&&D>1?A.push({key:"cheaper",title:"Cheaper",...wL(y,D),state:"done"}):D!==null?A.push({key:"cheaper",title:"Cheaper",value:D<1?y.before.mean_usd>0?`Not cheaper yet: ${jL(y.after.mean_usd/y.before.mean_usd)} the cost`:"Not cheaper yet":"Same cost",detail:P,state:"now"}):A.push({key:"cheaper",title:"Cheaper",value:`${y.after.runs} ${y.after.runs===1?"run":"runs"} so far`,detail:`${P}; how many times cheaper shows after ${cL} runs`,state:"now"})}else b||A.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 I=((u==null?void 0:u.guards)??[]).filter(P=>P.runs>0&&P.threshold!==null).sort((P,D)=>D.escalated/D.runs-P.escalated/P.runs)[0];if(j||I){const P=j?`${Math.round(j.back/j.ran*100)}% handed back`:"no run since";A.push({key:"unsure",title:"Unsure",value:P,detail:I?`most at "${I.node}": ${I.escalated} of ${I.runs} under ${I.threshold.toFixed(2)}`:`of ${j.ran} runs it ran first`,state:j&&j.back/j.ran>.25?"warn":"watch"})}return A}function j2(e){const n=s=>`${s} ${s===1?"run's":"runs'"} cost`;return e.unknown?`${n(e.unknown)} unknown${e.at_most?`, ${e.at_most} known only as at most`:""}`:`${n(e.at_most)} known only as at most`}const k2="how many times cheaper shows once every run's cost is known";function wL(e,n){const s=n>=1.5?`${Math.round(n)}x`:`${n.toFixed(1)}x`,r=e.replay,a=r?`workflow ${Math.round(r.workflow_pct)}% vs agent ${Math.round(r.agent_pct)}% on ${r.n} inputs`:"";if(r!=null&&r.cleared){const i=e.hand_backs?` · served ${e.hand_backs.ran} ${e.hand_backs.ran===1?"run":"runs"}, handed back ${e.hand_backs.back}`:"";return{value:`About ${s} cheaper at the same accuracy`,detail:`Replay: ${a}${i}`}}return{value:`${s} cheaper`,detail:`accuracy not claimed: ${r?`its replay was below the bar (${a})`:"no replay yet"}`}}const Nk=e=>e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`,jL=e=>{const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`},kL=1e3,N2="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.",S2=e=>e==="native"?"Native run costs include reported model usage and AgentRun learning. Compare repeated jobs; accepted notes and skills do not enable workflow takeover.":e==="sdk"?"SDK run costs include reported backend usage and AgentRun learning. Your backend keeps launching jobs and binds the tools an accepted workflow can use.":N2;function Sk({v2:e,agentId:n,on:s,quiet:r=!1,promotions:a,onCost:i,execution:c="hosted"}){const[d,u]=p.useState(null),[f,x]=p.useState([]),b=a??f,g=p.useRef(i);g.current=i;const[h,v]=p.useState(null),[y,j]=p.useState(0);return p.useEffect(()=>{let k=!0;return v(null),Promise.resolve().then(()=>e.learningCost(n,kL)).then($=>{var S;k&&(u($),(S=g.current)==null||S.call(g,$))},$=>{k&&v($??new Error("unknown"))}),a||Promise.resolve().then(()=>e.learningPromotions(n)).then($=>{k&&x($.promotions)},()=>{}),()=>{k=!1}},[e,n,y,!a]),r&&(!d||d.runs.filter(k=>k.total_usd!==null).length<2)?null:h&&!d?t.jsx(ns,{problem:$r(h,"the cost per run"),onRetry:()=>j(k=>k+1),className:""}):d?t.jsx(SL,{data:d,on:s,promotions:b,execution:c}):t.jsx(hn,{className:"h-[320px] w-full"})}const Mt={top:30,right:16,bottom:30,left:60},zu=17,NL=16,Hr=260;function SL({data:e,on:n,width:s,promotions:r=[],execution:a="hosted"}){var $e;const i=p.useMemo(()=>ZP(e.runs),[e.runs]),c=p.useMemo(()=>i.filter(uL),[i]),d=eL(c.length),u=p.useMemo(()=>tL(c,d),[c,d]),f=p.useMemo(()=>dL(e.runs,r),[e.runs,r]),{summary:x}=e,b=y2(e),g=p.useRef(null),[h,v]=p.useState(s??720);p.useEffect(()=>{const J=g.current;if(s||!J||typeof ResizeObserver>"u")return;const Le=new ResizeObserver(([qe])=>{qe&&qe.contentRect.width>0&&v(qe.contentRect.width)});return Le.observe(J),()=>Le.disconnect()},[s]);const[y,j]=p.useState(null),[k,$]=p.useState(null),S=Ta.map(J=>({...J,runs:e.runs.filter(Le=>Le.path===J.path).length})),N=[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(J=>J.state==="needs_revision"&&J.served&&J.by_hand).map(J=>`${J.workflow} no longer runs first: ${ar(J.served.mean_usd)} a run all-in over its last ${J.served.runs} runs, at or over ${ar(J.by_hand.mean_usd)} a run by hand.${J.unknown_cost_runs?` ${J.unknown_cost_runs===1?"1 run":`${J.unknown_cost_runs} runs`} of unknown cost left out.`:""} Its next run asks the agent for a new version, which runs first again.`)].filter(J=>!!J);if(i.length<2)return t.jsxs($k,{title:"Cost per run",headline:null,children:[t.jsxs("div",{className:"px-4 py-8 text-center",role:"status",children:[t.jsx("p",{className:"font-mono text-body",children:i.length?"One run so far.":"No run with a known cost yet."}),t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-body text-muted-foreground",children:S2(a)}),N.map(J=>t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-small text-muted-foreground",children:J},J))]}),e.runs.length>0&&(()=>{var qe;const J=Math.max(300,h),Le=(J-Mt.left-Mt.right)/(e.runs.at(-1).n-e.runs[0].n+1);return t.jsx("figure",{ref:g,className:"px-4 pb-3",children:t.jsx(Ek,{runs:e.runs,width:J,x:rt=>Mt.left+(rt-e.runs[0].n+.5)*Le,step:Le,plot:[Mt.left,J-Mt.right],takeover:((qe=x.takeover)==null?void 0:qe.n)??null})})})()]});const _=Math.max(300,h),E=_-Mt.left-Mt.right,O=e.runs[0].n,A=e.runs.at(-1).n,I=E/(A-O+1),M=J=>Mt.left+(J-O+.5)*I,R=x.before,{top:P,above:D}=rL(i,u,(R==null?void 0:R.mean_usd)??null),W=[],Y=[];for(const J of f){const Le=M(J.n)-I/2;let qe=Y.findIndex(rt=>Le-rt>=NL);qe<0?(qe=Y.length,Y.push(Le)):Y[qe]=Le,W.push(qe)}const H=Y.length?Y.length*zu+8:0,q=Mt.top+H,F=J=>q+Hr-Math.min(J,P)/P*Hr,G=sL(P),U=oL(O,A,_<520?5:7),z=x.takeover&&x.takeover.n>=O?x.takeover:null,Q=x.takeover?Math.max(x.takeover.n,O):null,K=c.map((J,Le)=>`${Le?"L":"M"}${M(J.n).toFixed(1)},${F(u[Le]).toFixed(1)}`).join(""),Z=y===null?null:i[y],de=x.times_cheaper!==null?`${Vg(x.times_cheaper)} cheaper`:null,re=b?`${cf(b.back,b.ran)} handed back since`:null,fe=x.before&&x.after?`${ar(x.before.mean_usd)} a run before takeover, ${ar(x.after.mean_usd)} all-in after${de?`: ${de}`:""}${re?` · ${re}`:""}`:null,ve=e.unknown_cost_runs+e.unknown_path_runs,Ee=J=>{const Le=J.currentTarget.getBoundingClientRect(),qe=(J.clientX-Le.left)/Le.width*_,rt=(J.clientY-Le.top)/Le.height*(q+Hr+Mt.bottom);if(f.length&&rt<q-2){j(null);const vt=f.map((st,Se)=>({i:Se,d:Math.abs(M(st.n)-I/2-qe)+Math.abs(Mt.top+W[Se]*zu+8-rt)})).sort((st,Se)=>st.d-Se.d)[0];$(vt&&vt.d<=12?vt.i:null);return}$(null),j(aL(i,O+(qe-Mt.left)/I-.5))},ue=J=>{const qe={ArrowRight:rt=>rt+1,ArrowLeft:rt=>rt-1,Home:()=>0,End:()=>i.length-1,PageUp:rt=>rt+10,PageDown:rt=>rt-10}[J.key];if(!qe){J.key==="Escape"&&j(null);return}J.preventDefault(),j(rt=>Math.min(i.length-1,Math.max(0,qe(rt??(J.key==="ArrowLeft"?i.length:-1)))))},pe=J=>[`Run ${J.n}`,`${To(J.total_usd)} all-in${J.learning_usd?` (${To(J.cost_usd??0)} the run, ${To(J.learning_usd)} learning)`:""}`,`${Lu(J.path).label}${J.workflow?`: ${J.workflow}`:""}`,J.learned_revision?`Learned revision ${J.learned_revision.slice(0,7)}`:"Nothing learned yet",...J.path==="replay"?["A replay: learning's spend, out of the line"]:[]],me=k===null?null:f[k]??null,ke=z?M(z.n)>Mt.left+E*.62:!1;return t.jsxs($k,{title:"Cost per run",headline:fe,unknown:ve,children:[t.jsxs("figure",{ref:g,className:"px-4 pb-2 pt-3",children:[t.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-small text-muted-foreground",children:[S.filter(J=>J.runs>0).map(J=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"10",height:"10","aria-hidden":!0,children:t.jsx("circle",{cx:"5",cy:"5",r:"4",className:J.fill})}),J.label," ",t.jsx("span",{className:"text-foreground",children:J.runs})]},J.path)),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-foreground",strokeWidth:2})}),"Rolling mean of ",d," runs"]}),R&&t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"4 3"})}),"Before takeover, the agent alone"]}),Object.keys(Sc).filter(J=>f.some(Le=>Le.kind===J)).map(J=>t.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":`marker-key-${J}`,children:[t.jsx("svg",{width:"14",height:"14","aria-hidden":!0,children:t.jsx(_k,{x:0,y:0,kind:J})}),Sc[J]," ",t.jsx("span",{className:"text-foreground",children:f.filter(Le=>Le.kind===J).length})]},J))]}),t.jsxs("div",{className:"relative shrink-0",tabIndex:0,onKeyDown:ue,onBlur:()=>j(null),"aria-label":`Cost per run, runs ${O} to ${A}. ${fe??""} Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:_,height:q+Hr+Mt.bottom,className:"block select-none font-mono",onPointerMove:Ee,onPointerLeave:()=>{j(null),$(null)},"aria-hidden":!0,children:[G.map(J=>t.jsxs("g",{children:[t.jsx("path",{d:`M${Mt.left},${F(J)}H${Mt.left+E}`,className:J===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:Mt.left-8,y:F(J),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:To(J)})]},J)),U.map(J=>t.jsx("text",{x:M(J),y:q+Hr+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:J},J)),t.jsx("text",{x:Mt.left,y:H?Mt.top-10:q-16,className:"caps fill-muted-foreground text-label",children:"$ a run, all-in"}),t.jsx("text",{x:Mt.left-8,y:q+Hr+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),f.map((J,Le)=>t.jsxs("g",{"data-testid":`marker-${J.kind}`,opacity:k===null||k===Le?1:.55,children:[t.jsx("path",{d:`M${M(J.n)-I/2},${Mt.top+W[Le]*zu+15}V${q+Hr}`,className:C2[J.kind],strokeWidth:1,strokeDasharray:"2 3"}),t.jsx(_k,{x:M(J.n)-I/2-7,y:Mt.top+W[Le]*zu+1,kind:J.kind})]},`${J.kind}:${J.n}:${J.workflow}:${J.digest}:${J.at}`)),i.map((J,Le)=>J.path==="replay"?t.jsx("circle",{cx:M(J.n),cy:F(J.total_usd),r:Le===y?0:2.5,className:"fill-none stroke-muted-foreground",strokeWidth:1.25},J.run_id):t.jsx("circle",{cx:M(J.n),cy:F(J.total_usd),r:Le===y?0:3,className:ae(Lu(J.path).fill),fillOpacity:.65},J.run_id)),R&&t.jsxs("g",{children:[t.jsx("path",{d:`M${Mt.left},${F(R.mean_usd)}H${Mt.left+E}`,className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"6 4"}),t.jsxs(ag,{x:Mt.left+E-4,y:F(R.mean_usd)-6,anchor:"end",children:["Before takeover ",ar(R.mean_usd)]})]}),z&&t.jsxs("g",{children:[t.jsx("path",{d:`M${M(z.n)},${q-4}V${q+Hr}`,className:"stroke-chart-workflow",strokeWidth:1.5}),t.jsxs(ag,{x:M(z.n)+(ke?-6:6),y:q+6,anchor:ke?"end":"start",children:["Workflow took over, run ",z.n]})]}),Q!==null&&x.after&&t.jsxs("g",{children:[t.jsx("path",{d:`M${M(Q)},${F(x.after.mean_usd)}H${Mt.left+E}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsxs(ag,{x:Mt.left+E-4,y:F(x.after.mean_usd)-8,anchor:"end",strong:!0,children:[_<520?"After":"After takeover"," ",ar(x.after.mean_usd),de?` · ${de}`:""]})]}),t.jsx("path",{d:K,fill:"none",className:"stroke-foreground",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),Z&&t.jsxs("g",{children:[t.jsx("path",{d:`M${M(Z.n)},${q}V${q+Hr}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("circle",{cx:M(Z.n),cy:F(Z.total_usd),r:5,className:ae(Lu(Z.path).fill,"stroke-card"),strokeWidth:2})]})]}),me&&!Z&&t.jsx("div",{className:ae("pointer-events-none absolute z-raised max-w-[22rem] border bg-card px-2 py-1 font-mono text-label shadow-float",M(me.n)>_*.6&&"-translate-x-full"),"data-testid":"marker-tip",style:{left:M(me.n)>_*.6?M(me.n)-I/2-12:M(me.n)-I/2+12,top:Mt.top},children:Tk(me).map((J,Le)=>t.jsx("span",{className:ae("block",Le===0?"font-semibold":"text-muted-foreground"),children:J},Le))}),Z&&t.jsxs("div",{className:ae("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",M(Z.n)>_*.6&&"-translate-x-full"),style:{left:M(Z.n)>_*.6?M(Z.n)-10:M(Z.n)+10,top:q},children:[pe(Z).map((J,Le)=>t.jsx("span",{className:ae("block",Le===0?"font-semibold":"text-muted-foreground"),children:J},J)),t.jsx("span",{className:"block text-muted-foreground",children:mt(Z.started_at)})]}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:Z?pe(Z).join(", "):""}),f.length>0&&t.jsx("p",{className:"sr-only",children:`Markers: ${f.map(J=>Tk(J).join(", ")).join(". ")}.`})]}),t.jsx(Ek,{runs:e.runs,width:_,x:M,step:I,plot:[Mt.left,Mt.left+E],takeover:(($e=x.takeover)==null?void 0:$e.n)??null}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Each dot is a run: its own cost plus what learning spent for it (the look-back and the grade). The line is the mean of the last ",d," runs",i.some(J=>J.path==="replay")?", replay runs (hollow) left out":"",".",D?` ${D===1?"1 run costs":`${D} runs cost`} more than ${To(P)} and ${D===1?"is":"are"} drawn at the top.`:"",x.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.":""]}),[...N,...$L(e,n,a)].map(J=>t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:J},J))]}),t.jsxs("details",{className:"border-t px-4 py-2",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),t.jsx("div",{className:"max-h-96 overflow-auto",children:t.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[t.jsx("thead",{className:"sticky top-0 z-sticky bg-card",children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Started","Path","Revision","Run $","Learning $","All-in $"].map(J=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:J},J))})}),t.jsx("tbody",{children:e.runs.map(J=>{var Le;return t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:J.n}),t.jsx("td",{className:"pr-4",children:mt(J.started_at)}),t.jsxs("td",{className:"pr-4",children:[Lu(J.path).label,J.workflow?`: ${J.workflow}`:""]}),t.jsx("td",{className:"pr-4",children:((Le=J.learned_revision)==null?void 0:Le.slice(0,7))??"-"}),t.jsx("td",{className:"pr-4",children:J.cost_usd===null?"unknown":To(J.cost_usd)}),t.jsx("td",{className:"pr-4",children:J.learning_usd===null?"unknown":To(J.learning_usd)}),t.jsx("td",{className:"pr-4",children:J.total_usd===null?"unknown":To(J.total_usd)})]},J.run_id)})})]})}),f.length>0&&t.jsxs("table",{className:"mt-3 w-full border-collapse font-mono text-small","data-testid":"marker-table",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Marker","Workflow","Revision","Numbers"].map(J=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:J},J))})}),t.jsx("tbody",{children:f.map(J=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:J.n}),t.jsxs("td",{className:"pr-4",children:[Ov[J.kind]," ",Sc[J.kind]]}),t.jsx("td",{className:"pr-4",children:J.workflow}),t.jsx("td",{className:"pr-4",children:J.digest.slice(0,7)}),t.jsx("td",{className:"pr-4 font-sans",children:Ra(J.record)})]},`${J.kind}:${J.n}:${J.workflow}:${J.digest}:${J.at}`))})]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["As CSV: ",t.jsxs("code",{className:"font-mono",children:["agentrun learning cost ",e.agent," --format csv"]})]})]})]})}const CL=64,Ro={top:4,bottom:6},EL=[...Ta].reverse(),Ck=e=>e.from===e.to?`Run ${e.from}`:`Runs ${e.from} to ${e.to}`;function Ek({runs:e,width:n,x:s,step:r,plot:a,takeover:i}){const c=CL,d=iL(e.length),u=p.useMemo(()=>lL(e,d),[e,d]),[f,x]=p.useState(null);if(!u.length)return null;const[b,g]=a,h=A=>Math.min(g,Math.max(b,A)),v=A=>({from:h(s(A.from)-r/2),to:h(s(A.to)+r/2)}),y=A=>Ro.top+c*(1-A),j=u.at(-1),k=A=>{const{from:I,to:M}=v(A),R=M-I>4?1:0;return{x0:I+R,w:Math.max(1,M-I-2*R)}},$=A=>`${Ck(A)}: ${Ta.filter(I=>A.counts[I.path]).map(I=>`${I.label.toLowerCase()} ${A.counts[I.path]}`).join(", ")}`,S=u.some(A=>A.counts.workflow)?`${cf(j.counts.workflow,j.runs)} by the learned workflow`:Ta.filter(A=>j.counts[A.path]).map(A=>`${cf(j.counts[A.path],j.runs)} ${A.label.toLowerCase()}`).join(", "),N=`Last ${j.runs===1?"run":`${j.runs} runs`}: ${S}`,_=f===null?null:u[f],E=_?k(_).x0>n/2:!1,O=i!==null&&s(i)>=b&&s(i)<=g;return t.jsxs("div",{className:"relative min-w-0",style:{width:n},"data-testid":"execution-mix",children:[t.jsxs("div",{className:"font-mono text-label",style:{paddingLeft:b},children:[t.jsxs("span",{className:"caps block text-muted-foreground",children:["Who finished each run",d>1?`, by ${d}`:""]}),t.jsx("span",{className:"block text-foreground",children:N})]}),t.jsxs("svg",{width:n,height:Ro.top+c+Ro.bottom,className:"mt-2 block select-none font-mono","aria-hidden":!0,onPointerLeave:()=>x(null),children:[[0,.5,1].map(A=>t.jsxs("text",{x:b-6,y:y(A),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:[A*100,"%"]},A)),u.map((A,I)=>{const{x0:M,w:R}=k(A);let P=Ro.top+c;return t.jsxs("g",{onPointerEnter:()=>x(I),opacity:f===null||f===I?1:.55,children:[t.jsx("rect",{x:v(A).from,y:Ro.top,width:Math.max(1,v(A).to-v(A).from),height:c,className:"fill-card",fillOpacity:0}),EL.map(D=>{const W=A.counts[D.path]/A.runs*c;if(!W)return null;P-=W;const Y=P>Ro.top+.5?Math.min(2,W):0;return t.jsx("rect",{x:M,y:P+Y,width:R,height:W-Y,className:D.fill,fillOpacity:.8},D.path)})]},A.from)}),O&&t.jsx("g",{"data-testid":"mix-takeover",children:t.jsx("path",{d:`M${s(i)-r/2},${Ro.top}V${Ro.top+c}`,className:"stroke-chart-workflow",strokeWidth:1.5})})]}),_&&t.jsxs("div",{className:ae("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",E&&"-translate-x-full"),style:{left:E?k(_).x0-6:k(_).x0+k(_).w+6,top:40},children:[t.jsx("span",{className:"block font-semibold",children:Ck(_)}),Ta.filter(A=>_.counts[A.path]).map(A=>t.jsxs("span",{className:"block text-muted-foreground",children:[A.label," ",_.counts[A.path]," (",cf(_.counts[A.path],_.runs),")"]},A.path))]}),t.jsx("p",{className:"sr-only",children:`Execution mix in blocks of ${d} runs. ${u.map($).join(". ")}. ${N}.`})]})}function $L(e,n,s){const r=e.summary;return!r.takeover&&s!=="hosted"?[S2(s)]:r.takeover?r.withheld?[`${j2(r.withheld)}: ${k2}.`]:r.times_cheaper===null&&r.after?[`${r.after.runs===1?"1 run":`${r.after.runs} runs`} since the workflow took over: how many times cheaper it is shows after 20.`]:[]:[n?"No learned workflow has finished a run alone yet. Keep running the same job: once one does, a marker shows where, and the level after it.":N2]}function $k({title:e,headline:n,unknown:s=0,children:r}){return t.jsxs("section",{className:"min-w-0 border","aria-label":e,"data-testid":"cost-per-run",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[t.jsx("h3",{className:"caps text-small font-semibold",children:e}),n&&t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:n}),s>0&&t.jsx(je,{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 C2={promote:"stroke-chart-workflow",hold:"stroke-warning",refit:"stroke-foreground",revision:"stroke-muted-foreground",superseded:"stroke-muted-foreground"},_L={promote:"fill-foreground",hold:"fill-warning-text",refit:"fill-foreground",revision:"fill-muted-foreground",superseded:"fill-muted-foreground"};function _k({x:e,y:n,kind:s}){return t.jsxs("g",{children:[t.jsx("rect",{x:e+.75,y:n+.75,width:12.5,height:12.5,className:ae("fill-card",C2[s]),strokeWidth:1.5,rx:2}),t.jsx("text",{x:e+7,y:n+7,dy:"0.35em",textAnchor:"middle",className:ae("text-micro font-semibold",_L[s]),children:Ov[s]})]})}const Tk=e=>[`${Sc[e.kind]} · run ${e.n}`,`${e.workflow} ${e.digest.slice(0,7)}`,Ra(e.record),mt(e.at)];function ag({x:e,y:n,anchor:s="start",strong:r=!1,children:a}){return t.jsx("text",{x:e,y:n,textAnchor:s,className:ae("stroke-card text-label [paint-order:stroke]",r?"fill-foreground font-semibold":"fill-muted-foreground"),strokeWidth:4,strokeLinejoin:"round",children:a})}function TL(e){const n=[];let s=[],r="",a=!1;const i=e.replace(/^/,"");for(let c=0;c<i.length;c++){const d=i[c];a?d==='"'?i[c+1]==='"'?(r+='"',c++):a=!1:r+=d:d==='"'&&r===""?a=!0:d===","?(s.push(r),r=""):d===`
|
|
620
|
+
`||d==="\r"?(d==="\r"&&i[c+1]===`
|
|
621
|
+
`&&c++,s.push(r),r="",s.some(u=>u.trim()!=="")&&n.push(s),s=[]):r+=d}return a?null:(s.push(r),s.some(c=>c.trim()!=="")&&n.push(s),n)}function RL(e){var i;const n=TL(e);if(!n)return{error:"The file ends inside a quoted cell: a quote is not closed."};const s=(i=n.shift())==null?void 0:i.map(c=>c.trim());if(!s||!n.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,d)=>s.indexOf(c)!==d);if(r!==void 0)return{error:`The column ${r} is named twice in the header line.`};const a=n.findIndex(c=>c.length!==s.length);return a>=0?{error:`Row ${a+1} has ${n[a].length} cells, and the header line has ${s.length}.`}:{columns:s,rows:n.map(c=>Object.fromEntries(s.map((d,u)=>[d,c[u]])))}}const Rk=500,AL=5,Yg=e=>e.status==="running";function OL(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 ML={agent:"by hand",handed_back:"handed back",workflow:"workflow"},PL=2e3;function LL({v2:e,agentId:n,onFinished:s,pollMs:r=PL}){const[a,i]=p.useState(void 0),[c,d]=p.useState(null),[u,f]=p.useState(!1),[x,b]=p.useState(0),g=p.useRef(!1),h=p.useRef(s);if(h.current=s,p.useEffect(()=>{let y=!0,j;const k=async $=>{var S,N;try{const _=$??((S=(await e.learningBatches(n)).batches[0])==null?void 0:S.id),E=_?await e.learningBatch(n,_):null;if(!y)return;i(E),d(null),E&&Yg(E)?(g.current=!0,j=setTimeout(()=>void k(E.id),r)):E&&g.current&&(g.current=!1,(N=h.current)==null||N.call(h))}catch(_){if(!y)return;d(_??new Error("unknown")),j=setTimeout(()=>void k($),r*2)}};return k(),()=>{y=!1,clearTimeout(j)}},[e,n,r,x]),a===void 0&&!c)return t.jsx(hn,{className:"h-24 w-full"});if(a===void 0)return t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.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),"."]}),t.jsx(B,{size:"sm",variant:"outline",onClick:()=>{d(null),b(y=>y+1)},children:"Read again"})]});const v=a&&Yg(a);return t.jsxs("section",{className:"space-y-4","aria-label":"Learn from a CSV",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Learn from a CSV"}),!v&&!u&&t.jsx(B,{size:"sm",onClick:()=>f(!0),children:a?"Learn from another CSV":"Learn from a CSV"})]}),!!c&&t.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."]}),u&&!v&&t.jsx(IL,{v2:e,agentId:n,onStarted:y=>{g.current=!0,i(y),f(!1),b(j=>j+1)},onCancel:()=>f(!1)}),a&&!u&&t.jsx(FL,{v2:e,agentId:n,batch:a,onBatch:i}),!a&&!u&&t.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 IL({v2:e,agentId:n,onStarted:s,onCancel:r}){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[x,b]=p.useState(""),[g,h]=p.useState(String(AL)),[v,y]=p.useState(!1),[j,k]=p.useState(null),$=async E=>{var M;const O=(M=E.target.files)==null?void 0:M[0];if(!O)return;k(null);const A=RL(await O.text());if("error"in A){i(null),d(A.error);return}d(A.rows.length>Rk?`A batch takes at most ${Rk} rows: this file has ${A.rows.length}.`:null),i({name:O.name,columns:A.columns,rows:A.rows});const I=A.columns.at(-1);b(I),f(A.columns.filter(R=>R!==I))},S=Number(g),N=!!a&&!c&&u.length>0&&!!x&&!u.includes(x)&&Number.isFinite(S)&&S>0,_=async()=>{var E,O;if(!(!a||!N)){y(!0),k(null);try{s(await e.startLearningBatch(n,{inputs:u,answer:x,rows:a.rows,max_cost_usd:S}))}catch(A){k(A instanceof ze?((O=(E=A.fields)==null?void 0:E[0])==null?void 0:O.message)??A.message:A instanceof Error?A.message:String(A)),y(!1)}}};return t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsx(jt,{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:t.jsx("input",{type:"file",accept:".csv,text/csv",onChange:E=>void $(E),"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&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:c}),a&&!("error"in a)&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[a.name,": ",a.rows.length," rows, ",a.columns.length," columns"]}),t.jsx(jt,{label:"The agent is given",group:!0,note:"The columns each run reads. The answer column is never one of them.",children:t.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:a.columns.map(E=>t.jsx(JO,{label:E,checked:u.includes(E),disabled:E===x,onChange:O=>f(A=>O.target.checked?a.columns.filter(I=>A.includes(I)||I===E):A.filter(I=>I!==E))},E))})}),t.jsx(jt,{label:"The answer column",note:"What the agent is told after each answer: the reference it should have given.",children:t.jsx(At,{label:"The answer column",value:x,onChange:E=>{b(E),f(O=>O.filter(A=>A!==E))},options:a.columns.map(E=>({value:E,label:E}))})}),t.jsx(jt,{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:N?`Up to ${Xr(S)} for ${a.rows.length} rows.`:void 0,children:t.jsx(Ie,{inputMode:"decimal",value:g,onChange:E=>h(E.target.value),className:"max-w-40","aria-label":"Cap, in dollars"})}),t.jsx(zL,{columns:[...u,x].filter(Boolean),rows:a.rows.slice(0,3)})]}),j&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:j}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{variant:"primary",disabled:!N||v,onClick:()=>void _(),children:v?"Starting":"Learn"}),t.jsx(B,{variant:"ghost",onClick:r,disabled:v,children:"Cancel"})]})]})}function zL({columns:e,rows:n}){return t.jsx("div",{className:"overflow-x-auto","aria-label":"The first rows",children:t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{children:e.map(s=>t.jsx("th",{className:"caps border-b px-2 py-1 text-left font-semibold",children:s},s))})}),t.jsx("tbody",{children:n.map((s,r)=>t.jsx("tr",{children:e.map(a=>t.jsx("td",{className:"max-w-64 truncate border-b px-2 py-1",children:s[a]},a))},r))})]})})}const DL={running:"active",completed:"success",cancelled:"muted",stopped:"warning"};function FL({v2:e,agentId:n,batch:s,onBatch:r}){const[a,i]=p.useState(!1),[c,d]=p.useState(null),u=async()=>{i(!0),d(null);try{r(await e.cancelLearningBatch(n,s.id))}catch(b){d(b instanceof Error?b.message:String(b))}i(!1)},f=OL(s),x=s.cost_usd===null?"unknown":Xr(s.cost_usd);return t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(je,{tone:DL[s.status],children:s.status}),t.jsxs("span",{className:"font-mono text-body",children:[s.finished," of ",s.total," rows"]})]}),Yg(s)&&t.jsx(B,{size:"sm",variant:"destructive",disabled:a,onClick:()=>void u(),children:"Cancel"})]}),t.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:t.jsx("div",{className:"h-full bg-primary",style:{width:`${s.total?s.finished/s.total*100:0}%`}})}),f&&t.jsx(xt,{tone:"warning",children:f}),s.status==="completed"&&t.jsx(xt,{tone:"success",children:"Every row ran. The results are below."}),c&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:c}),t.jsxs("dl",{className:"grid grid-cols-2 gap-3 font-mono text-body sm:grid-cols-4",children:[t.jsx(Ao,{label:"Right",value:`${s.right}`}),t.jsx(Ao,{label:"Wrong",value:`${s.wrong}`}),t.jsx(Ao,{label:"Failed",value:`${s.failed}`}),t.jsx(Ao,{label:"Cost so far",value:`${x} of ${Xr(s.max_cost_usd)}`}),t.jsx(Ao,{label:"Notes learned",value:`${s.lessons.notes.length}`}),t.jsx(Ao,{label:"Skills learned",value:`${s.lessons.skills.length}`}),t.jsx(Ao,{label:"Workflow revisions",value:`${s.revisions.length}`}),t.jsx(Ao,{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&&t.jsxs("p",{className:"text-body text-muted-foreground",children:["Learned: ",[...s.lessons.notes,...s.lessons.skills.map(b=>`${b} (skill)`),...s.lessons.workflows.map(b=>`${b} (workflow)`)].join(", "),"."]}),t.jsx("div",{className:"max-h-96 overflow-auto",children:t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{children:["Row","Result","Path","Cost","Answer","Reference"].map(b=>t.jsx("th",{className:"caps sticky top-0 border-b bg-card px-2 py-1 text-left font-semibold",children:b},b))})}),t.jsx("tbody",{children:s.rows.map(b=>t.jsxs("tr",{"aria-current":s.current===b.n?"step":void 0,children:[t.jsx("td",{className:"border-b px-2 py-1",children:b.n}),t.jsx("td",{className:"border-b px-2 py-1",children:b.state==="done"?t.jsx(je,{tone:b.right?"success":"error",children:b.right?"right":"wrong"}):b.state==="failed"?t.jsx(je,{tone:"error",title:b.error,children:"failed"}):t.jsx(je,{tone:b.state==="running"?"active":"muted",children:b.state==="running"?"running":"waiting"})}),t.jsx("td",{className:"border-b px-2 py-1",children:b.path?ML[b.path]:""}),t.jsx("td",{className:"border-b px-2 py-1",children:b.total_usd==null?"":Xr(b.total_usd)}),t.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:b.answer??void 0,children:b.answer??""}),t.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:b.reference,children:b.reference})]},b.n))})]})})]})}const Ao=({label:e,value:n})=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:e}),t.jsx("dd",{className:"break-words",children:n})]}),UL="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).",ig=e=>`${Math.round(e*1e3)/10}%`;function WL(e){const{cost_per_task_usd:n,baseline_cost_per_task_usd:s}=e,r=n!==null&&s!==null,a=r&&n>0?s/n:null,[i,c]=e.ci;return{accuracy:ig(e.accuracy),accuracyVs:`95% interval ${ig(i)} to ${ig(c)}, n=${e.n.toLocaleString("en-US")}`,cost:r?a===null||s===0?ar(n):a>=1?`${Vg(a)} cheaper`:`${Vg(n/s)} the cost`:n!==null?ar(n):"Not counted",costVs:r?`${ar(n)} a task vs ${ar(s)} by hand`:n!==null?`${ar(n)} a task; by hand not counted`:"The test did not count the cost a task."}}function Ak({v2:e,agentId:n,quiet:s=!1}){const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(0);return p.useEffect(()=>{let f=!0;return c(null),Promise.resolve().then(()=>e.learningEvals(n)).then(x=>{f&&a(x)},x=>{f&&c(x??new Error("unknown"))}),()=>{f=!1}},[e,n,d]),s&&!(r!=null&&r.latest)?null:i&&!r?t.jsx(ns,{problem:$r(i,"the held-out test"),onRetry:()=>u(f=>f+1),className:""}):r?t.jsx(HL,{result:r.latest}):t.jsx(hn,{className:"h-[116px] w-full"})}function HL({result:e}){return t.jsxs("section",{className:"min-w-0 border","aria-label":"Held-out test","data-testid":"held-out-test",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[t.jsx("h3",{className:"caps text-small font-semibold",children:"Held-out test"}),e&&t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[e.n.toLocaleString("en-US")," jobs it never learned from · ",e.name," · ",mt(e.recorded_at),e.learned_revision?` · revision ${e.learned_revision.slice(0,7)}`:""]})]}),e?t.jsx(BL,{result:e}):t.jsxs("div",{className:"px-4 py-4",role:"status",children:[t.jsx("p",{className:"font-mono text-body",children:"Not measured yet."}),t.jsx("p",{className:"mt-1 max-w-prose text-body text-muted-foreground",children:UL})]})]})}function BL({result:e}){const n=WL(e),s=[{label:"Held-out accuracy",value:n.accuracy,lines:[n.accuracyVs]},{label:"Cost a task",value:n.cost,lines:[n.costVs]}];return t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"grid grid-cols-1 sm:grid-cols-2",children:s.map((r,a)=>t.jsxs("div",{className:a?"border-t px-4 py-3 sm:border-l sm:border-t-0":"px-4 py-3",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:r.label}),t.jsx("dd",{className:"mt-1 font-mono text-figure font-semibold tabular-nums",children:r.value}),r.lines.map(i=>t.jsx("dd",{className:"mt-0.5 font-mono text-small text-muted-foreground",children:i},i))]},r.label))}),e.label_source&&t.jsxs("p",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["Labels: ",e.label_source]})]})}const Ok="https://api.githubcopilot.com/mcp/",dd={composio:"Composio",github:"GitHub",url:"URL"},Mk=/^[a-z][a-z0-9-]{0,31}$/;function GL(e){const n=new URLSearchParams(e??""),s=n.get("add");if(!s||!Mk.test(s))return;const r=n.get("toolkit")??"";if(n.get("preset")==="composio"&&Mk.test(r)){const a=(n.get("tools")??"").split(",").filter(i=>/^[A-Za-z0-9_-]{1,128}$/.test(i)).slice(0,64);return{name:s,preset:"composio",toolkit:r,...a.length?{tools:a}:{}}}return{name:s,...n.get("auth")==="github_app"?{auth:"github_app"}:{}}}const qL="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.",E2=(e,n)=>`mcp:${e}/${n}`;function Bo(e){const n=/^mcp:([^/]+)\/(.+)$/.exec(e);return n?{server:n[1],tool:n[2]}:null}function KL(e,n){var s,r;return e.grantable===!1?`${e.name} can't be granted: ${e.reason??"it runs other actions by name."}`:((s=e.grant_problems)==null?void 0:s["*"])??((r=e.grant_problems)==null?void 0:r[n])}function VL(e,n){return e.flatMap(s=>{const r=Bo(s);if(!r)return[];const a=n.find(i=>i.name===r.server);return a?a.tools.some(i=>i.name===r.tool)?[]:[{grant:s,why:`${r.server} no longer lists ${r.tool}: refresh it, or untick this.`}]:[{grant:s,why:`The MCP server ${r.server} is not saved here any more, so a run can't call it.`}]})}const Pk=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 ro(e){var i,c,d,u,f,x,b;if(!(e instanceof ze))return{text:`The request didn't reach this server: ${e instanceof Error?e.message:String(e)}`};const n=(i=e.fields)==null?void 0:i.find(g=>g.field==="url"&&g.reason==="redirect"),s=(c=e.fields)==null?void 0:c.find(g=>g.field==="client_id"&&g.reason==="registration_unavailable"),r=(d=e.details)==null?void 0:d.oauth,a=typeof(r==null?void 0:r.callback)=="string"?r.callback:"";return s?{text:s.message,detail:Pk(a),signIn:!0,needsClient:!0}:e.code==="auth_required"&&((u=e.details)==null?void 0:u.auth)==="oauth"&&(r==null?void 0:r.registration)===!1?{text:"This server signs in with OAuth, and its sign-in lets no app register itself.",detail:Pk(a),signIn:!0,needsClient:!0}:e.code==="auth_required"?((f=e.details)==null?void 0:f.auth)==="oauth"?{text:"This server signs in with OAuth.",detail:"Sign in to it: its tools are saved once you approve.",signIn:!0}:{text:"This server asks for a token.",detail:e.message}:e.code==="github_not_connected"?{text:"GitHub is not connected on this server.",detail:`${e.message} A GitHub App server runs on this server's GitHub App: connect GitHub, or add a repository to its installation, in Settings → GitHub, then try again.`}:e.code==="not_mcp"?{text:"This address doesn't speak MCP.",detail:e.message}:n?{text:"This address redirects; use the final address.",detail:n.message}:e.status===424?{text:`The server failed: ${e.message}`}:e.code==="wrong_origin"?{text:"Sign in from this server's own address: the sign-in comes back there.",...typeof((x=e.details)==null?void 0:x.open)=="string"?{detail:`Open ${e.details.open} and sign in from it.`}:{}}:(b=e.fields)!=null&&b.length?{text:e.fields.map(g=>g.message).join(" ")}:{text:`${e.code}: ${e.message}`}}const Lk={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"},YL="the sign-in didn't finish: try again",QL=e=>e&&Object.hasOwn(Lk,e)?Lk[e]:YL;function JL(e){const n=new URLSearchParams(e??""),s=n.get("server"),r=n.get("sign_in");if(!(!s||r!=="ok"&&r!=="failed"))return{server:s,ok:r==="ok",...r==="failed"?{error:n.get("error")??"sign_in_failed"}:{}}}const ud=Bo;function XL(e){const n=Bo(e);return n?`${n.server} · ${n.tool}`:null}const ZL="https://chatgpt.com/#settings",Qg="chatgpt",zc=e=>!!e&&e.startsWith(`${Qg}/`)&&e.length>Qg.length+1,$2="Codex and pi agents run on your ChatGPT plan. Claude Agent, OpenCode, Jev decisions and paid tools need their own keys.",eI="Signing in on this computer finishes by itself. On a server elsewhere, the tab ends on a page that won't load: copy that tab's whole address and paste it here.",tI="This sign-in is yours: don't let other people run agents on this server with it.",nI="Signed out. If ChatGPT still lists AgentRun under connected apps, disconnect it there.",sI="Signed out here. OpenAI didn't confirm the revocation: remove AgentRun in your ChatGPT settings.",rI="Your ChatGPT sign-in expired. Sign in again.",_2="Requests on your ChatGPT plan cost no dollars here; your plan's own limits apply.",oI=`Counts dollars. ${_2}`,aI=new Set(["signed_out","pending","signed_in","expired"]),Tf=e=>e&&typeof e=="object"&&aI.has(String(e.state))?e:null,iI=e=>e.charAt(0).toUpperCase()+e.slice(1),lI=e=>`Signed in as ${e.email??"your ChatGPT account"}${e.plan?` (${iI(e.plan)})`:""}`;function al(e,n){return zc(e)?{text:`${e.slice(Qg.length+1)} · on your ChatGPT plan`,title:e}:n&&e.startsWith(`${n}/`)&&e.length>n.length+1?{text:e.slice(n.length+1),title:e}:{text:e}}function T2(e,n){var s;return new Map((((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.free_models)??[]).map(r=>[r.id,r]))}function cI(e,n,s,r){return!e||typeof r!="number"||zc(e)?null:T2(n,s).has(e)?`free model: up to ${r} requests`:null}function dI(e){return e>=1e6?`${Math.round(e/1e6*10)/10}M`.replace(/\.0M$/,"M"):`${Math.round(e/1e3)}K`}function uI(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.models)??[]}function R2(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.default_model)??void 0}const fI="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",mI="none yet: add a model key in Settings → Model keys",A2=e=>al(e,null).text,Lv=(e,n)=>[e,n!=null&&n.model?n.tier:void 0,n!=null&&n.model?A2(n.model):void 0].filter(Boolean).join(" · "),O2=e=>e!=null&&e.model?`ran on ${A2(e.model)}${e.tier?` (the ${e.tier} tier)`:""}`:"",hI="http://www.w3.org/2000/svg",$i=16,rn=240,pI=40,gI=58,lg=16,cg=26,Du=18,_i=14,Ik=16,xI=26,vI=14,yI=22,zs=14,zk=16,Fu=16,bI=4,wI=10,jI=18,kI=30,NI=5,vc=124,Jg=34,SI=4,dg=10*.6,CI=12.5*.6,Dc=10.5*.6,Dk=11*.6,Iv=9*.66,Fk=10.5*.6,EI={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"},zv=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),Rf={review:"needs review","not-run":"",pending:""};function bt(e,n,...s){const r=document.createElementNS(hI,e);if(n)for(const[a,i]of Object.entries(n))r.setAttribute(a,String(i));for(const a of s)js(r,a);return r}function js(e,n){if(n!=null){if(Array.isArray(n)){for(const s of n)js(e,s);return}e.appendChild(typeof n=="string"?document.createTextNode(n):n)}}const Sr=(e,n)=>e.length>n?`${e.slice(0,n-1)}…`:e,$I=(e,n)=>{const s=/^(.*) (\d\.\d\d)$/.exec(e);return!s||e.length<=n?Sr(e,n):`${Sr(s[1],Math.max(2,n-s[2].length-1))} ${s[2]}`},Do=(e,n)=>Math.max(2,Math.floor(e/n)),Go=(e,n)=>Math.ceil(e.length*n),Us=(e,n,s,r,a)=>bt("line",{x1:e,y1:n,x2:s,y2:r,class:a?`wire ${a}`:"wire"});function M2(e){const n={},s={};for(const a of e)n[a.path]=a;const r=a=>{var i;return((i=n[a])==null?void 0:i.kind)??""};for(const a of e){let i;const c={node:a,order:0,name:null};let d=null;(i=/^(.*)\/steps\/(\d+)$/.exec(a.path))&&r(i[1])==="chain"?(d=i[1],c.order=Number(i[2])):(i=/^(.*)\/branches\/([^/]*)\/body$/.exec(a.path))&&r(i[1])==="route"?(d=i[1],c.name=i[2].replace(/~1/g,"/").replace(/~0/g,"~")):(i=/^(.*)\/branches\/(\d+)$/.exec(a.path))&&r(i[1])==="parallel"?(d=i[1],c.order=Number(i[2])):((i=/^(.*)\/body$/.exec(a.path))&&(r(i[1])==="map"||r(i[1])==="loop")||(i=/^(.*)\/workflow\/root$/.exec(a.path))&&r(i[1])==="workflow")&&(d=i[1]),d!==null&&(s[d]??(s[d]=[])).push(c)}for(const a of Object.values(s))a.sort((i,c)=>i.order-c.order);return{byPath:n,kids:s}}function Dv(e,n){var u,f,x,b;const{diff:s={},status:r={},fired:a}=e.marks,i=n===a?"escalated":r[n],c=i&&zv.has(i)?i:"",d=(u=s.added)!=null&&u.includes(n)?"NEW":(f=s.edited)!=null&&f.includes(n)?"EDITED":(x=s.moved)!=null&&x.includes(n)?"MOVED":"";return{state:c,tag:d,fired:n===a,selected:((b=e.marks.selected)==null?void 0:b.path)===n&&e.marks.selected.item==null}}function fd(e,n,s){var g,h,v;const r=Dv(e,n.path),a=(g=e.marks.meta)==null?void 0:g[n.path],i=a!=null&&a.tool?ud(a.tool):null,c=(h=e.marks.ran)==null?void 0:h[n.path],d=a!=null&&a.decision?(c==null?void 0:c.model)??a.model:a==null?void 0:a.model;let u=`${n.label} (${n.kind}${i?`: ${i.tool} on ${i.server}, an MCP server's tool`:n.via?` via ${n.via}`:""}${a!=null&&a.provider?`, ${a.provider}${d?` ${d}`:""}`:""}${c&&!(a!=null&&a.decision)?`, ${O2(c)}`:""})`;r.state&&(u+=`: ${r.state.replace("-"," ")}`),r.tag&&(u+=`${r.state?", ":": "}${r.tag.toLowerCase()}`),(v=a==null?void 0:a.questions)!=null&&v.length&&(u+=`
|
|
622
|
+
${a.questions.map(y=>`• ${y.text}`).join(`
|
|
623
|
+
`)}`);const f=a!=null&&a.decision&&a.provider?`who-${a.provider==="parallel"||a.provider==="openrouter"?a.provider:"jev"}`:n.kind==="route"&&a&&!a.decision?"who-control":`who-${EI[n.kind]??"code"}`;let x=`node ${s} ${f}`;r.state&&(x+=` ${r.state}`),r.fired&&(x+=" fired"),r.tag&&(x+=` ${r.tag.toLowerCase()}`),r.selected&&(x+=" selected");const b=bt("g",{class:x,"data-path":n.path},bt("title",null,u));return e.svg.appendChild(b),b}const Ki=e=>Go(e,Iv)+10;function df(e,n,s,r,a="tag"){const i=Ki(r);return js(e,[bt("rect",{x:n,y:s,width:i,height:13,class:`${a}-box`}),bt("text",{x:n+i/2,y:s+9.5,class:a,"text-anchor":"middle"},r)]),i}const _I=(e,n)=>{var s,r;return!!((r=(s=e.marks.meta)==null?void 0:s[n.path])!=null&&r.decision)},Am=(e,n)=>_I(e,n)?gI:pI;function Fv(e,n,s,r,a){var k,$,S,N,_;const i=Dv(e,s.path),c=(k=e.marks.meta)==null?void 0:k[s.path],d=Am(e,s),u=($=e.marks.verdict)==null?void 0:$[s.path],f=i.state in Rf?Rf[i.state]:i.state,x=((S=c==null?void 0:c.questions)==null?void 0:S.length)??0,b=c!=null&&c.tool?ud(c.tool):null,g=(N=e.marks.ran)==null?void 0:N[s.path],h=(g&&!(c!=null&&c.decision)?Lv(s.kind,g):s.kind)+(b?` · ${b.tool} on ${b.server}`:c!=null&&c.tool?` · ${c.tool}`:s.via?` · ${s.via}`:"")+(c!=null&&c.decision&&x?` · ${x} ${x===1?"question":"questions"}`:""),v=[(_=c==null?void 0:c.images)!=null&&_.length?"IMG":"",c!=null&&c.web?"WEB":"",b?"MCP":""].filter(Boolean),y=v.reduce((E,O)=>E+Ki(O)+4,0);i.selected&&n.appendChild(bt("rect",{x:r-4,y:a-4,width:rn+8,height:d+8,class:"sel"})),js(n,[bt("rect",{x:r,y:a,width:rn,height:d,class:"box"}),bt("rect",{x:r+10,y:a+9,width:8,height:8,class:"swatch"}),bt("text",{x:r+24,y:a+17,class:"label"},Sr(s.label,Do(rn-34-y,CI))),bt("text",{x:r+24,y:a+31,class:"kind"},Sr(h,Do(rn-34-(f?Go(f,Iv)+8:0),Dc))),f?bt("text",{x:r+rn-10,y:a+31,class:"state","text-anchor":"end"},f):null]);let j=r+rn-8;for(const E of v.reverse())j-=Ki(E),df(n,j,a+7,E,"badge"),j-=4;if(c!=null&&c.decision&&c.provider){const E=df(n,r+24,a+38,c.provider,"chip"),O=u?$I(u,Do(rn-44-E-20,Fk)):"",A=rn-40-E-(O?Go(O,Fk)+10:0),I=(g==null?void 0:g.model)??c.model;I&&A>24&&n.appendChild(bt("text",{x:r+24+E+6,y:a+47.5,class:"model"},Sr(I,Do(A,Dc)))),O&&n.appendChild(bt("text",{x:r+rn-10,y:a+47.5,class:"verdict","text-anchor":"end"},O))}else u&&n.appendChild(bt("text",{x:r+rn-10,y:a+17,class:"verdict","text-anchor":"end"},u));i.tag&&df(n,r+rn-Ki(i.tag),a-7,i.tag)}function TI(e,n){return{w:rn,h:Am(e,n),cx:rn/2,place:(s,r)=>Fv(e,fd(e,n,"card"),n,s,r)}}function P2(e,n,s){const r=Dv(e,n.path),a=r.state==="done"?"passed":r.state in Rf?Rf[r.state]:r.state,i=Sr(n.label===n.kind?"exit":`exit: ${n.label}`,40),c=Go(i,Dc)+16;return{w:_i+c+(r.tag?6+Ki(r.tag):0)+(a?6+Go(a,Iv):0),h:cg,cx:0,exit:!0,place:(d,u)=>{const f=fd(e,n,"exit"),x=u+cg/2;let b=d+_i+c;s&&f.appendChild(Us(d,u,d,u+cg,"spine")),r.selected&&f.appendChild(bt("rect",{x:d+_i-3,y:x-Du/2-3,width:c+6,height:Du+6,class:"sel"})),js(f,[Us(d,x,d+_i,x,"exit-wire"),bt("rect",{x:d+_i,y:x-Du/2,width:c,height:Du,class:"exit-box"}),bt("text",{x:d+_i+8,y:x+3.5,class:"exit-text"},i)]),r.tag&&(df(f,b+6,x-6.5,r.tag),b+=6+Ki(r.tag)),a&&f.appendChild(bt("text",{x:b+6,y:x+3.5,class:"state"},a))}}}function RI(e,n,s){const r=s.map(d=>d.node.kind==="escalate"?P2(e,d.node,!1):Om(e,d.node));let a=rn/2,i=rn/2,c=-lg;for(const d of r)a=Math.max(a,d.cx),i=Math.max(i,d.w-d.cx),c+=d.h+lg;return{w:a+i,h:c,cx:a,place:(d,u)=>{const f=fd(e,n,"chain"),x=d+a;let b=u,g=null;r.forEach((h,v)=>{v&&(b+=lg),h.exit?g===null&&(g=b):g!==null&&f.appendChild(Us(x,g,x,b,"spine")),h.place(h.exit?x:x-h.cx,b),b+=h.h,h.exit||(g=b)}),r[r.length-1].exit&&g!==null&&f.appendChild(Us(x,g,x,b,"spine"))}}}function AI(e,n,s){const r=Am(e,n),a=s.map(h=>({kid:h,box:Om(e,h.node),x:0,c:0}));let i=0,c=0;a.forEach((h,v)=>{v&&(i+=yI),h.x=i,h.c=i+h.box.cx,i+=h.box.w,c=Math.max(c,h.box.h)});const d=a.length-1,u=Math.round((a[0].c+a[d].c)/2),f=Math.min(0,u-rn/2),x=Math.max(i,u+rn/2),b=r+Ik+xI,g=b+c+vI;return{w:x-f,h:g,cx:u-f,place:(h,v)=>{const y=fd(e,n,"card"),j=h-f,k=v+r+Ik,$=v+g;Fv(e,y,n,j+u-rn/2,v),y.appendChild(Us(j+u,v+r,j+u,k)),d&&js(y,[Us(j+a[0].c,k,j+a[d].c,k),Us(j+a[0].c,$,j+a[d].c,$)]),a.forEach((S,N)=>{const _=j+S.c,E=S.kid.node.path,O=e.taken.has(E);if(y.appendChild(bt("line",{x1:_,y1:k,x2:_,y2:v+b,class:O?"wire branch taken":"wire branch","data-to":E})),S.kid.name!==null){const A=(N<d?a[N+1].c-6:S.x+S.box.w)-S.c-12,I=Sr(S.kid.name,Do(A,Dc)),M=bt("text",{x:_+6,y:k+15,class:O?"branch-name taken":"branch-name"},I);y.appendChild(I===S.kid.name?M:bt("g",null,bt("title",null,S.kid.name),M))}y.appendChild(Us(_,v+b+S.box.h,_,$,O?"taken":void 0)),S.box.place(j+S.x,v+b)})}}}const OI=e=>e.replace(/^.*\//,"").replace(/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,"");function MI(e,n,s,r,a,i){const c=zv.has(s.status)?s.status:"pending",d=s.label?OI(s.label):`#${s.index+1}`,u=s.outcome??(c==="review"?"needs review":c==="not-run"?"not run":c),f=s.p!==void 0?s.p.toFixed(2):"",x=`#${s.index+1}${s.label?` ${s.label}`:""}: ${c==="review"?"needs review":c.replace("-"," ")}${s.outcome?`, ${s.outcome}`:""}${s.pNote?` (${s.pNote})`:""}`,b=bt("g",{class:`rcell ${c}${s.tone?` tone-${s.tone}`:""}${i?" picked":""}`,"data-path":n.path,"data-item":s.index},bt("title",null,x),bt("rect",{x:r,y:a,width:vc,height:Jg,class:"cell"}),bt("rect",{x:r,y:a,width:3,height:Jg,class:"cell-edge"}),bt("text",{x:r+9,y:a+14,class:"cell-name"},Sr(d,Do(vc-14,dg))),bt("text",{x:r+9,y:a+27,class:"cell-out"},Sr(u,Do(vc-18-(f?Go(f,dg)+6:0),dg))),f?bt("text",{x:r+vc-6,y:a+27,class:"cell-p","text-anchor":"end"},f):null);e.appendChild(b)}function PI(e,n){var j;const s=((j=e.marks.items)==null?void 0:j[n.path])??[];if(!s.length)return null;const r=s.length<=kI,[a,i,c]=r?[vc,Jg,SI]:[Fu,Fu,bI],d=Math.min(s.length,r?NI:wI),u=Math.ceil(s.length/d),f=d*(a+c)-c,x=u*(i+c)-c+jI+(r?4:0),b={};for(const k of s)b[k.status]=(b[k.status]??0)+1;const g={};for(const k of s)k.outcome&&(g[k.outcome]=(g[k.outcome]??0)+1);const h=Object.entries(g).map(([k,$])=>`${$} ${k}`),y=[`${b.done??0}/${s.length} done`,b.working?`${b.working} working`:"",b.held?`${b.held} held`:"",b.failed?`${b.failed} failed`:"",b.review?`${b.review} review`:"",...h].filter(Boolean).join(" · ");return{w:Math.max(f,Go(y,Dc)),h:x,place:(k,$,S)=>{const N=$-f/2,_=e.marks.selected;s.forEach((E,O)=>{const A=N+O%d*(a+c),I=S+Math.floor(O/d)*(i+c),M=zv.has(E.status)?E.status:"pending",R=(_==null?void 0:_.path)===n.path&&_.item===E.index;if(r){MI(k,n,E,A,I,R);return}js(k,bt("rect",{x:A,y:I,width:Fu,height:Fu,class:`cell ${M}${R?" picked":""}`,"data-path":n.path,"data-item":E.index},bt("title",null,`#${E.index+1}${E.label?` ${E.label}`:""}: ${M==="review"?"needs review":M.replace("-"," ")}`)))}),js(k,bt("text",{x:$,y:S+x-4,class:"caption","text-anchor":"middle"},y))}}}function LI(e,n,s){const r=Om(e,s),a=Am(e,n),i=n.kind==="map"?PI(e,n):null,c=i?i.h+zs:0,d=Math.max(rn/2,r.cx,i?i.w/2:0)+zs,u=Math.max(rn/2,r.w-r.cx,i?i.w/2:0)+zs,f=a+zs+c+r.h+zs;return{w:d+u,h:f,cx:d,place:(x,b)=>{const g=fd(e,n,"card"),h=x+d;if(js(g,bt("rect",{x,y:b+a/2,width:d+u,height:f-a/2,class:"frame"})),i?(js(g,Us(h,b+a,h,b+a+zs)),js(g,Us(h,b+a+zs+i.h,h,b+a+zs+c))):js(g,Us(h,b+a,h,b+a+zs)),js(g,Us(h,b+a+zs+c+r.h,h,b+f)),Fv(e,g,n,h-rn/2,b),i){const v=bt("g",{class:"items"});i.place(v,h,b+a+zs),g.appendChild(v)}r.place(h-r.cx,b+a+zs+c)}}}function L2(e,n){return e.kind==="escalate"?"exit":n.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function Om(e,n){const s=e.kids[n.path]??[],r=L2(n,s);return r==="exit"?P2(e,n,!0):r==="leaf"?TI(e,n):r==="chain"?RI(e,n,s):r==="fan"?AI(e,n,s):LI(e,n,s[0].node)}function Uv(e){const{byPath:n,kids:s}=M2(I2(e)),r=a=>{const i=s[a.path]??[],c=L2(a,i),d=c==="frame"?r(i[0].node):c==="chain"||c==="fan"?i.reduce((u,f)=>u+r(f.node),0):0;return(c==="chain"?0:1)+d};return n["/root"]?r(n["/root"]):0}const Mm=e=>`${e} ${e===1?"node":"nodes"}`,I2=e=>(e&&Array.isArray(e.nodes)?e.nodes:[]).filter(n=>n&&typeof n.path=="string"&&typeof n.kind=="string").map(n=>({path:n.path,kind:n.kind,label:String(n.label??n.kind),via:typeof n.via=="string"?n.via:""}));function II(e,n,s={}){var x;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const r=M2(I2(n)),a=(b,g)=>(e.setAttribute("viewBox",`0 0 ${b} ${g}`),e.setAttribute("width",String(b)),e.setAttribute("height",String(g)),e.style.setProperty("min-width",`${Math.min(b,480)}px`),{w:b,h:g});if(!r.byPath["/root"])return a(0,0);const i={svg:e,kids:r.kids,marks:s,taken:new Set(s.taken??[])},c=Om(i,r.byPath["/root"]);c.place($i,$i);let d=c.w,u=c.h;const f=(((x=s.diff)==null?void 0:x.removed)??[]).map(b=>`${b.label} (${b.kind})`);if(f.length){const b=["Removed:",...f.map(h=>Sr(h,Do(Math.max(d,300),Dk)))],g=bt("g",{class:"removed-list"},bt("title",null,`Removed: ${f.join(", ")}`));b.forEach((h,v)=>{g.appendChild(bt("text",{x:$i,y:$i+u+33+v*zk,class:"removed"},h)),d=Math.max(d,Go(h,Dk))}),e.appendChild(g),u+=22+b.length*zk}return a(d+2*$i,u+2*$i)}function zI(e){var a,i;const n=e,s=(a=n==null?void 0:n.closest)==null?void 0:a.call(n,"[data-item]");if(s)return{path:s.getAttribute("data-path"),item:Number(s.getAttribute("data-item"))};const r=(i=n==null?void 0:n.closest)==null?void 0:i.call(n,"g[data-path]");return!r||r.classList.contains("chain")?null:{path:r.getAttribute("data-path"),item:null}}const DI=1600;function md({graph:e,marks:n,onSelect:s,className:r,label:a="Workflow graph",minScale:i=.8,maxScale:c=1.3}){const d=p.useRef(null),[u,f]=p.useState({w:0,h:0}),[x,b]=p.useState(0),g=p.useMemo(()=>JSON.stringify([(e==null?void 0:e.nodes)??null,n??null]),[e,n]);p.useEffect(()=>{if(!d.current)return;const v=II(d.current,e,n);f(y=>y.w===v.w&&y.h===v.h?y:v),d.current.style.setProperty("--wf-phase",`-${Date.now()%DI}ms`)},[g]),p.useEffect(()=>{var j;const v=(j=d.current)==null?void 0:j.parentElement;if(!v||typeof ResizeObserver>"u")return;const y=new ResizeObserver(([k])=>b(k.contentRect.width));return y.observe(v),()=>y.disconnect()},[]);const h=u.w&&x?Math.min(c,Math.max(i,x/u.w)):1;return t.jsx("svg",{ref:d,role:"img","aria-label":a,className:ae("wf select-none",r),style:u.w?{width:u.w*h,height:u.h*h,maxWidth:"none",minWidth:0}:void 0,onClick:v=>{const y=zI(v.target);y&&s&&s(y)}})}function hd({run:e=!1}){const n=[["hsl(var(--wf-jev))","Jev"],["hsl(var(--wf-parallel))","Parallel"],["hsl(var(--wf-openrouter))","OpenRouter"],["hsl(var(--wf-tool))","Tool"],["hsl(var(--muted-foreground))","Code"],["hsl(var(--primary))","Agent"]],s=[["border-success bg-success/40","Done"],["border-primary bg-primary/20","Working"],["border-dashed border-warning","Held (paused)"],["border-warning bg-warning/60","Needs review"],["border-destructive bg-destructive/60","Failed"],["border-dashed border-border-strong","Pending"]];return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 font-mono text-label text-muted-foreground",children:[n.map(([r,a])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block size-2",style:{background:r}}),a]},a)),e&&t.jsx("span",{className:"h-3 border-l","aria-hidden":!0}),e&&s.map(([r,a])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:ae("inline-block size-2.5 border",r)}),a]},a))]})}const z2={self:"self",jev:"jev",both:"self+jev"},FI=e=>`${z2[e.signal]} ≥${e.threshold.toFixed(2)}`,UI=(e,n)=>n?`${Math.round(e/n*100)}%`:"0%";function WI({guards:e,workflow:n,digest:s,loop:r}){return e.length?t.jsxs("section",{className:"border","aria-label":"Where it is unsure","data-testid":"step-guards",children:[t.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-3 py-2",children:[t.jsx("h3",{className:"caps text-label font-semibold",children:"Where it is unsure"}),t.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."})]}),t.jsx("ul",{className:"divide-y",children:e.map(a=>t.jsx(HI,{guard:a,stats:yL(r,n,s,a.node)},a.node))}),t.jsx(GI,{})]}):null}function HI({guard:e,stats:n}){const s=(n==null?void 0:n.right)??0,r=(n==null?void 0:n.wrong)??0,a=(n==null?void 0:n.replays)??0,i=(n==null?void 0:n.grades_past)??0,c=s+r?` · graded ${s} right, ${r} wrong`:i?"":" · none graded",d=i?` · ${i} older ${i===1?"run's grade is":"runs' grades are"} past the newest grades kept`:"";return t.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:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"min-w-0 break-words font-mono text-body font-semibold",children:e.node}),t.jsx(je,{tone:"plain",title:`Reads ${xL[e.signal]}`,children:z2[e.signal]}),t.jsxs(je,{tone:"muted",children:[e.fitted?"fitted":"threshold"," ",e.threshold.toFixed(2)]})]}),t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:n&&n.runs?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:ae("font-semibold",n.escalated/n.runs>.25?"text-warning-text":"text-foreground"),children:[UI(n.escalated,n.runs)," handed back"]})," (",n.escalated," of ",n.runs," runs)",c,d,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."})]}),n&&n.points.length>0&&t.jsx(BI,{guard:e,stats:n})]})}const Oo=168,vr=36,Uk=2;function BI({guard:e,stats:n}){const s=vL(n.points),r=Math.max(1,...s.map(d=>d.right+d.wrong+d.ungraded)),a=Oo/s.length,i=d=>Math.min(Oo-1,Math.max(1,d*Oo)),c=s.filter(d=>d.right+d.wrong+d.ungraded).map(d=>`p ${d.from.toFixed(1)} to ${d.to.toFixed(1)}: ${[d.right&&`${d.right} right`,d.wrong&&`${d.wrong} wrong`,d.ungraded&&`${d.ungraded} not graded`].filter(Boolean).join(", ")}`);return t.jsxs("figure",{className:"m-0 shrink-0","data-testid":"guard-histogram",children:[t.jsxs("svg",{width:Oo,height:vr+14,className:"block font-mono","aria-hidden":!0,children:[s.map(d=>{let u=vr;const f=[[d.right,"fill-success"],[d.wrong,"fill-destructive"],[d.ungraded,"fill-muted-foreground"]];return t.jsxs("g",{children:[t.jsx("title",{children:`p ${d.from.toFixed(1)}–${d.to.toFixed(1)}: ${d.right} right, ${d.wrong} wrong, ${d.ungraded} not graded`}),t.jsx("rect",{x:d.from*Oo,y:0,width:a,height:vr,className:"fill-card",fillOpacity:0}),f.map(([x,b])=>{if(!x)return null;const g=x/r*(vr-2);u-=g;const h=u>.5&&u+g<vr-.5?1:0;return t.jsx("rect",{x:d.from*Oo+Uk/2,y:u+h,width:a-Uk,height:Math.max(1,g-h),className:b,fillOpacity:b==="fill-muted-foreground"?.45:.85},b)})]},d.from)}),t.jsx("path",{d:`M0,${vr+.5}H${Oo}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("path",{d:`M${i(e.threshold)},0V${vr+3}`,className:"stroke-foreground",strokeWidth:1.5,strokeDasharray:"3 2"}),t.jsx("text",{x:0,y:vr+12,className:"fill-muted-foreground text-micro",children:"0"}),t.jsx("text",{x:Oo,y:vr+12,textAnchor:"end",className:"fill-muted-foreground text-micro",children:"1"}),t.jsx("text",{x:i(e.threshold),y:vr+12,textAnchor:"middle",className:"fill-foreground text-micro font-semibold",children:e.threshold.toFixed(2)})]}),n.points.length<n.runs&&t.jsxs("p",{className:"m-0 font-mono text-micro text-muted-foreground",children:["p of the newest ",n.points.length," runs"]}),t.jsx("figcaption",{className:"sr-only",children:`${e.node}: p by run${n.points.length<n.runs?`, the newest ${n.points.length} of ${n.runs}`:""}. ${c.join(". ")}.`})]})}function GI(){const e=[["Right","fill-success",.85],["Wrong","fill-destructive",.85],["Not graded","fill-muted-foreground",.45]];return t.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:[t.jsx("span",{className:"caps",children:"p by run"}),e.map(([n,s,r])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"10",height:"10","aria-hidden":!0,children:t.jsx("rect",{width:"10",height:"10",className:s,fillOpacity:r})}),n]},n)),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M6,0V10",className:"stroke-foreground",strokeWidth:1.5,strokeDasharray:"3 2"})}),"Threshold"]}),t.jsx("span",{children:"A missing signal counts as 0 and hands back."})]})}const qI=3e3,KI=e=>e.word==="Held"||e.word==="Not decided"||e.word==="Superseded",Wk=e=>`${Math.round(e*100)}%`,VI=e=>`${e>=0?"+":""}${Math.round(e*1e3)/10} pts`,D2=e=>`${e} graded ${e===1?"input":"inputs"}`;function YI(e){if(!e)return"Replay started: its runs are queued.";const n=e.outcomes,s=n.answered+n.handed_back+n.failed+n.skipped_write;return`Replaying on ${D2(e.inputs)}: ${s} of ${e.inputs} ended (${n.answered} answered alone, ${n.handed_back} handed back${n.failed?`, ${n.failed} failed`:""}${n.skipped_write?`, ${n.skipped_write} skipped`:""}).`}function QI(e){const n=e.reason?` ${e.reason.charAt(0).toUpperCase()}${e.reason.slice(1)}`:"",s=e.status==="failed"?`The replay did not finish.${n}`:e.decided==="promote"?`Promoted: it serves first now.${n}`:e.decided==="hold"?`Still held.${n}`:e.decided==="superseded"?`Superseded.${n}`:`Decided.${n}`,r=e.score;return{text:s,score:r.n>0?`Workflow ${Wk(r.wf_acc)} vs agent ${Wk(r.agent_acc)} on ${D2(r.n)} (${VI(r.delta)}), ${r.handed_back} handed back`:null}}function JI({v2:e,agentId:n,workflow:s,digest:r,offered:a,resume:i=null,onStarted:c,onDecided:d,pollMs:u=qI}){const[f,x]=p.useState(i?{at:"running",replay:i,read:null}:{at:"idle"});p.useEffect(()=>{i&&x(j=>j.at==="idle"?{at:"running",replay:i,read:null}:j)},[i]);const b=p.useRef(d);b.current=d;const g=f.at==="running"?f.replay:null,h=f.at==="running"?f.unread:void 0;p.useEffect(()=>{if(g===null||h!==void 0)return;let j=!0,k;const $=()=>{Promise.resolve().then(()=>e.learnedWorkflowReplay(n,s,r,g)).then(S=>{var N;if(j){if(S.status==="running"){x({at:"running",replay:g,read:S}),k=setTimeout($,u);return}x({at:"decided",read:S}),(N=b.current)==null||N.call(b)}},S=>{j&&x(N=>N.at==="running"?{...N,unread:S instanceof Error?S.message:String(S)}:N)})};return $(),()=>{j=!1,k&&clearTimeout(k)}},[e,n,s,r,g,h,u]);const v=()=>{x({at:"starting"}),Promise.resolve().then(()=>e.startLearnedWorkflowReplay(n,s,r)).then(j=>{x({at:"running",replay:j.replay,read:null}),c==null||c()},j=>{const k=j==null?void 0:j.code;x({at:"refused",message:j instanceof Error?j.message:String(j),code:typeof k=="string"?k:null})})},y=f.at==="starting"||f.at==="running";return!a&&f.at==="idle"?null:t.jsxs("div",{className:"mt-2 space-y-1","data-testid":"replay-revision",children:[(f.at==="idle"||f.at==="starting"||(f.at==="refused"||f.at==="decided")&&a)&&t.jsx(B,{size:"sm",onClick:v,disabled:y,"aria-label":`Replay revision ${r.slice(0,7)} on graded inputs`,children:f.at==="starting"?"Starting…":f.at==="idle"?"Replay":"Replay again"}),f.at==="running"&&t.jsxs("p",{className:"break-words text-body",role:"status","data-testid":"replay-progress",children:[f.unread!==void 0?`Couldn't read the replay: ${f.unread} `:YI(f.read),f.unread!==void 0&&t.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:()=>x({at:"running",replay:f.replay,read:f.read}),children:"Check again"})]}),f.at==="refused"&&t.jsxs("p",{className:"break-words text-body",role:"alert","data-testid":"replay-refused",children:[f.message,f.code&&t.jsx("span",{className:"ml-2 font-mono text-label text-muted-foreground",children:f.code})]}),f.at==="decided"&&(()=>{const j=QI(f.read);return t.jsxs("div",{role:"status","data-testid":"replay-decision",children:[t.jsx("p",{className:"break-words text-body",children:j.text}),j.score&&t.jsx("p",{className:"break-words font-mono text-label text-muted-foreground","data-testid":"replay-score",children:j.score})]})})()]})}const ug=e=>{const n=[...new Set(e)],s=n.slice(0,3).map(r=>`"${r}"`).join(", ");return n.length>3?`${s} and ${n.length-3} more`:s},Hk=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function XI(e,n,s,r,a){const i=[e.length&&`added ${Hk(e.length,"node")} (${ug(e)})`,n.length&&`edited ${ug(n)}`,s.length&&`removed ${Hk(s.length,"node")} (${ug(s)})`].filter(Boolean);if(!i.length)return r?"Nodes reordered":a?"Connections changed":"No node changed";const c=i.join(", ");return c.charAt(0).toUpperCase()+c.slice(1)}function ZI(e){const n=[];let s=null,r=0;for(const a of e){let i=null,c=null;try{i=a.text===null?null:JSON.parse(a.text),c=i===null?null:sl(i)}catch{c=null}if(!(c!=null&&c.nodes.length)){r+=1;continue}const d=s?HS(s,c):null,u=d?d.added.map(k=>k.path):c.nodes.map(k=>k.path),f=k=>{var $;return(($=c.nodes.find(S=>S.path===k))==null?void 0:$.kind)!=="chain"},x=d?[...d.changed.map(k=>k.next),...d.rewritten.map(k=>k.next)]:[],b=d?d.moved.map(k=>k.next):[],g=new Map(c.nodes.map(k=>[k.path,k.label])),h=d?d.removed.filter(k=>k.kind!=="chain").map(k=>k.label):[],v=d?d.edges.added.length+d.edges.removed.length:0,y=gL(a.text),j=Object.fromEntries(y.flatMap(k=>c.nodes.some($=>$.path===k.path)?[[k.node,k.path]]:[]));n.push({digest:a.digest??null,guards:y,guardPaths:j,commit:a.commit,at:a.at,run:"run"in a.by?a.by.run:null,reason:a.reason,graph:c,marks:{meta:od(i,c),diff:{added:u,edited:x,moved:b,removed:d?d.removed.map(({label:k,kind:$})=>({label:k,kind:$})):[]}},added:u,edited:x,removed:h,line:d?XI(u.filter(f).map(k=>g.get(k)??k),x.filter(f).map(k=>g.get(k)??k),h,b.length,v):`First version: ${Mm(Uv(c))}`}),s=c}return{steps:n,unreadable:r}}const ez=50,tz=1800;function nz({v2:e,agentId:n,workflows:s,promotions:r=[],serving:a=[],loop:i=null,cost:c=null,onReplayed:d}){const u=s.filter(g=>g.status==="active").map(g=>g.name),[f,x]=p.useState(null),b=f!==null&&u.includes(f)?f:u[0]??null;return b===null?null:t.jsx(sz,{v2:e,agentId:n,name:b,choices:u,onPick:x,promotions:r,serving:a,loop:i,stopped:Pv(c,b),onReplayed:d},b)}const Uu="Learned workflow";function sz({v2:e,agentId:n,name:s,choices:r,onPick:a,promotions:i,serving:c,loop:d,stopped:u,onReplayed:f}){var k;const[x,b]=p.useState(null),[g,h]=p.useState(null),[v,y]=p.useState(0);p.useEffect(()=>{let $=!0;return h(null),Promise.resolve().then(()=>e.learnedWorkflowRevisions(n,s,ez)).then(S=>{$&&b(S)},S=>{$&&h(S??new Error("unknown"))}),()=>{$=!1}},[e,n,s,v]);const j=t.jsxs("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-4 py-3",children:[t.jsxs("h2",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"caps text-small font-semibold",children:Uu})," ",t.jsx("span",{className:"ml-1 break-all font-mono text-body font-semibold",children:s})]}),r.length>1&&t.jsx(At,{small:!0,className:"w-56 max-w-full",label:"Learned workflow",value:s,onChange:a,options:r.map($=>({value:$,label:$}))})]});return g&&!x?t.jsxs("section",{className:"border","aria-label":Uu,children:[j,t.jsx("div",{className:"p-4",children:t.jsx(ns,{problem:$r(g,"the learned workflow"),onRetry:()=>y($=>$+1),className:""})})]}):x?t.jsxs("section",{className:"border","aria-label":Uu,children:[j,t.jsx(rz,{data:x,promotions:i,serving:((k=c.find($=>$.workflow===x.name))==null?void 0:k.digest)??null,loop:d,stopped:u,replay:{v2:e,agentId:n,onStarted:f,onDecided:()=>{y($=>$+1),f==null||f()}}})]}):t.jsxs("section",{className:"border","aria-label":Uu,"aria-busy":!0,children:[j,t.jsx("div",{className:"p-4",children:t.jsx(hn,{className:"h-48 w-full"})})]})}function rz({data:e,stepMs:n=tz,promotions:s=[],serving:r=null,loop:a=null,stopped:i=null,replay:c}){const{steps:d,unreadable:u}=p.useMemo(()=>ZI(e.revisions),[e.revisions]),[f,x]=p.useState(Math.max(0,d.length-1)),[b,g]=p.useState(!1),h=p.useRef(f);h.current=f;const v=p.useRef(d);if(p.useEffect(()=>{var P;const I=v.current;v.current=d;const M=((P=I[h.current])==null?void 0:P.digest)??null,R=I===d||h.current>=I.length-1||M===null?-1:d.findIndex(D=>D.digest===M);x(R>=0?R:Math.max(0,d.length-1)),g(!1)},[d]),p.useEffect(()=>{if(!b)return;const I=setInterval(()=>x(M=>Math.min(M+1,d.length-1)),n);return()=>clearInterval(I)},[b,d.length,n]),p.useEffect(()=>{b&&f>=d.length-1&&g(!1)},[b,f,d.length]),!e.revisions.length)return null;if(!d.length)return t.jsxs("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:["This workflow's revisions can't be read as a workflow",u?`: ${u} ${u===1?"revision":"revisions"} did not read`:"","."]});const y=d[Math.min(f,d.length-1)],j=d.length,k=I=>{g(!1),x(Math.max(0,Math.min(j-1,I)))},$=()=>{if(b)return g(!1);f>=j-1&&x(0),g(!0)},S=`Revision ${Math.min(f,j-1)+1} of ${j}, ${mt(y.at)}`,N=Mv(s,e.name,y.digest),_=b2(s,e.name,y.digest),E=Ic(N,{serving:r,refit:_,stopped:i}),O=y.guards.length?{...y.marks,verdict:Object.fromEntries(y.guards.flatMap(I=>y.guardPaths[I.node]?[[y.guardPaths[I.node],FI(I)]]:[]))}:y.marks,A=(N==null?void 0:N.source)==="refit"&&N.refit?N.refit:null;return t.jsxs("div",{className:"space-y-3 p-4",children:[j>1&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsxs(B,{size:"sm",onClick:$,"aria-label":b?"Pause the replay":"Play the replay","aria-pressed":b,children:[b?t.jsx(Xi,{"aria-hidden":!0}):t.jsx(Vo,{"aria-hidden":!0}),b?"Pause":"Play"]}),t.jsx(B,{size:"icon",onClick:()=>k(f-1),disabled:f<=0,"aria-label":"Previous revision",children:t.jsx(J_,{"aria-hidden":!0})}),t.jsx(B,{size:"icon",onClick:()=>k(f+1),disabled:f>=j-1,"aria-label":"Next revision",children:t.jsx(Cs,{"aria-hidden":!0})}),t.jsx(ZO,{min:1,max:j,value:f+1,onChange:I=>k(I-1),label:"Revision",valueText:S,className:"basis-full sm:min-w-[10rem] sm:flex-1 sm:basis-0"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{children:j>1?`Revision ${f+1} of ${j}`:"One revision"})," · ",t.jsx("time",{dateTime:y.at,children:mt(y.at)})," · ",y.run?t.jsxs("a",{href:`#/runs/${encodeURIComponent(y.run)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ea(y.run)]}):"a person"]}),t.jsx("p",{className:"mt-1 break-words text-lead",role:"status","data-testid":"replay-line",children:y.line}),y.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-body text-muted-foreground",children:y.reason}),t.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-body","data-testid":"standing",children:[t.jsx(je,{tone:E.tone,children:E.text}),t.jsx("span",{className:"min-w-0 break-words text-muted-foreground",children:_?`Its thresholds were refit: revision ${_.digest.slice(0,7)} serves in its place.`:N?Ra(N):y.digest?"No replay yet: a new revision replays on the last graded inputs before it serves.":"Its file did not read: no standing."})]}),A&&t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground","data-testid":"refit",children:N==null?void 0:N.reason}),c&&y.digest&&t.jsx(JI,{v2:c.v2,agentId:c.agentId,workflow:e.name,digest:y.digest,offered:!_&&KI(E),resume:(N==null?void 0:N.decided)==="replaying"?N.replay_id??null:null,onStarted:c.onStarted,onDecided:c.onDecided},y.digest)]}),t.jsx("div",{className:"flex min-h-[280px] overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] p-4",children:t.jsx(md,{graph:y.graph,marks:O,label:`The workflow at revision ${f+1} of ${j}, as a graph`,minScale:.5,maxScale:1.6,className:"m-auto"})}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(hd,{}),t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:"NEW"})," first appears in this revision · ",t.jsx("span",{className:"font-semibold text-foreground",children:"EDITED"})," its prompt, code, inputs or tier changed",y.guards.length?t.jsxs(t.Fragment,{children:[" · ",t.jsx("span",{className:"font-semibold text-foreground",children:"jev ≥0.70"})," the step's guard: its signal and threshold"]}):null]})]}),t.jsx(WI,{guards:y.guards,workflow:e.name,digest:y.digest,loop:a}),(e.total>e.revisions.length||e.truncated||u>0)&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[e.total>e.revisions.length&&`The latest ${e.revisions.length} of ${e.total} revisions. `,e.truncated&&"Older changes are past the log this server keeps. ",u>0&&`${u} ${u===1?"revision":"revisions"} could not be read as a workflow and ${u===1?"is":"are"} left out.`]})]})}const Bk=8,oz={promote:"success",hold:"warning",refit:"plain",revision:"active",superseded:"muted"};function Gk({loop:e,promotions:n,serving:s=[],cost:r=null}){const[a,i]=p.useState(!1),c=[...((e==null?void 0:e.compiles)??[]).map(u=>({at:u.at,key:`c:${u.run_id}:${u.round}`,kind:"compile",compile:u})),...n.map((u,f)=>({at:u.at,key:`p:${f}`,kind:"promotion",record:u}))].sort((u,f)=>Date.parse(f.at)-Date.parse(u.at));if(!c.length)return null;const d=a?c:c.slice(0,Bk);return t.jsxs("section",{className:"border","aria-label":"Learning feed","data-testid":"loop-feed",children:[t.jsxs("h2",{className:"caps flex items-baseline gap-2 border-b px-4 py-3 text-small font-semibold",children:["Learning feed",t.jsx("span",{className:"font-mono font-normal text-muted-foreground",children:c.length})]}),t.jsx("ol",{className:"divide-y",children:d.map(u=>{var f;return t.jsx("li",{className:"min-w-0 px-4 py-3","data-testid":`feed-${u.kind}`,children:u.kind==="compile"?t.jsx(iz,{compile:u.compile,promotions:n,serving:((f=s.find(x=>x.workflow===u.compile.workflow))==null?void 0:f.digest)??null,stopped:u.compile.workflow?Pv(r,u.compile.workflow):null}):t.jsx(lz,{record:u.record})},u.key)})}),c.length>Bk&&t.jsx("div",{className:"flex justify-center border-t px-4 py-2",children:t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>i(u=>!u),children:a?"Show fewer":`Show all ${c.length}`})})]})}const az=({id:e})=>t.jsxs("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ea(e)]}),F2=({at:e,run:n})=>t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[t.jsx("time",{dateTime:e,children:mt(e)}),n?t.jsxs(t.Fragment,{children:[" · ",t.jsx(az,{id:n})]}):null]});function iz({compile:e,promotions:n,serving:s,stopped:r}){const a=e.digest===null||e.workflow===null,i=e.attempts.filter(u=>!u.ok),c=[...e.attempts.flatMap((u,f)=>u.ok?[]:u.errors.map(x=>({e:x,attempt:f+1}))),...e.draft_errors.map(u=>({e:u,attempt:null}))],d=a?null:Ic(Mv(n,e.workflow,e.digest),{serving:s,refit:b2(n,e.workflow,e.digest),stopped:r});return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a?t.jsx(je,{tone:"error",children:"Draft failed"}):t.jsx(je,{tone:"plain",children:"Compiled"}),e.workflow?t.jsx("span",{className:"min-w-0 break-all font-mono text-body font-semibold",children:e.workflow}):t.jsx("span",{className:"text-body text-muted-foreground",children:"no workflow kept"}),d&&t.jsx(je,{tone:d.tone,children:d.text})]}),e.from_notes.length>0&&t.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`,": ",t.jsx("span",{className:"font-mono text-foreground",children:e.from_notes.join(", ")})]}),e.attempts.length>0&&t.jsxs("p",{className:"mt-0.5 text-small text-muted-foreground",children:[e.attempts.length===1?"1 attempt":`${e.attempts.length} attempts`,i.length?`, ${i.length} refused by the checks`:"",a?": it tries again on a later run.":"."]}),e.withheld?t.jsx("p",{className:"mt-1 text-small text-warning-text",role:"note",children:"The checks' words are withheld here: this run's handed values can't be read to cut them."}):c.length>0&&t.jsx("ul",{className:"mt-1 space-y-0.5","aria-label":"What the checks said","data-testid":"draft-errors",children:c.map(({e:u,attempt:f},x)=>t.jsxs("li",{className:"break-words font-mono text-small text-destructive-text",children:[f?`Attempt ${f}: `:"",u]},x))}),t.jsx(F2,{at:e.at,run:e.run_id})]})}function lz({record:e}){var a;const n=v2(e),s=Ic(e,{serving:e.digest}),r=n==="promote"?s.tone:oz[n];return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(je,{tone:r,children:[Ov[n]," · ",Sc[n],s.proof?` · ${s.proof}`:""]}),t.jsx("span",{className:"min-w-0 break-all font-mono text-body font-semibold",children:e.workflow}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:e.digest.slice(0,7)})]}),t.jsx("p",{className:"mt-1 break-words text-small text-muted-foreground",children:Ra(e)}),(a=e.replay)!=null&&a.n?e.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-small text-muted-foreground",children:e.reason}):null,t.jsx(F2,{at:e.at})]})}const cz={done:{icon:cl,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:tT,word:"Later",ink:"text-muted-foreground",edge:"border-t-border"},warn:{icon:Gs,word:"Look",ink:"text-warning-text",edge:"border-t-warning"},watch:{icon:Tx,word:"Watch",ink:"text-foreground",edge:"border-t-border-strong"}};function qk({stages:e}){return e.length?t.jsx("section",{className:"border","aria-label":"The learning loop","data-testid":"loop-story",children:t.jsx("ol",{className:ae("grid grid-cols-1 gap-px bg-border sm:grid-cols-2",e.length===5?"lg:grid-cols-5":"lg:grid-cols-4"),children:e.map((n,s)=>{const r=cz[n.state],a=r.icon;return t.jsxs("li",{"data-testid":`stage-${n.key}`,"data-state":n.state,className:ae("min-w-0 border-t-2 bg-card px-4 py-3 sm:[&:last-child:nth-child(odd)]:col-span-2 lg:[&:last-child:nth-child(odd)]:col-span-1",r.edge),children:[t.jsxs("p",{className:"flex items-center gap-1.5 font-mono text-label",children:[t.jsxs("span",{className:"caps text-muted-foreground",children:[s+1," · ",n.title]}),t.jsxs("span",{className:ae("ml-auto inline-flex items-center gap-1",r.ink),children:[t.jsx(a,{className:"size-3.5","aria-hidden":!0}),t.jsx("span",{className:"caps",children:r.word})]})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-lead font-semibold","data-testid":`stage-${n.key}-value`,children:n.value}),t.jsx("p",{className:"mt-0.5 break-words text-small text-muted-foreground",children:n.detail})]},n.key)})})}):null}function U2({id:e,checked:n,onChange:s,busy:r,disabled:a,quiet:i,server:c,problem:d,className:u}){return t.jsxs("div",{className:ae("space-y-2",u),children:[t.jsxs("div",{className:ae("flex gap-4",i?"items-center":"items-start"),children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{id:e,className:"text-lead font-semibold",children:"Learns from its runs"}),!i&&t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:"After each run, it looks back and keeps a short note when something will help next time; later runs read them first."})]}),t.jsx(jm,{checked:n,onChange:s,busy:r,disabled:a,labelledBy:e})]}),c==="off"&&t.jsx("p",{className:"font-mono text-label text-warning-text",children:"This server has learning turned off, so no run learns until it's on."}),d]})}function dz({fields:e,onFields:n,saved:s,server:r,error:a,warning:i}){const c=e.learning??s,d=c===!0||c==="notes",u=f=>n({learning:f===!1&&s===void 0?void 0:f});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Learning"})}),t.jsx(U2,{id:"learning-switch",className:"border px-4 py-3",checked:d,server:r,onChange:f=>u(f?s==="notes"?"notes":!0:!1)}),d&&t.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(([f,x,b])=>t.jsxs("label",{className:ae("flex items-start gap-3 border px-3 py-2.5",c===f&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"learning-kind",className:"mt-1 accent-primary",checked:c===f,onChange:()=>u(f)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:x}),t.jsx("span",{className:"block text-small text-muted-foreground",children:b})]})]},String(f)))}),a&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:a}),i&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:i})]})}const uz="Not read: its front matter can't be read; fix the file to use it",fz={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned",superseded:"Replaced"},W2=(e,n)=>`${fz[e]} by ${n==="person"?"you":"a run"}`,Xg=e=>e.readme??e.file,fg="Can't tell which version this is: reload.",Pm="It changed since you opened it.",mz=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.",hz=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.`,pz="Making an agent from it takes your password sign-in in the console.",gz="Restoring takes your password sign-in in the console.",H2=["feedback","project","reference","user"],xz={user:"About you",feedback:"How to work",project:"About the work",reference:"Where to look"},B2=e=>xz[e]??e,vz={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"},yz=["seeded","reflecting","proposed"],Lm=e=>!!e&&yz.includes(e.state),pd=e=>Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&typeof n.file=="string"&&typeof n.name=="string"):[],G2=e=>pd(e==null?void 0:e.given),q2=e=>pd(e==null?void 0:e.read),Fc=e=>(e==null?void 0:e.state)==="merged"?pd(e.learned):[],Wv=e=>pd(e==null?void 0:e.pending),K2=e=>pd(e),Kk=e=>(e==null?void 0:e.state)==="merged"?K2(e.skills):[],Vk=e=>(e==null?void 0:e.state)==="merged"?K2(e.workflows):[],bz=e=>Wv(e).length>0,Af=(e,n)=>`${e} ${n}${e===1?"":"s"}`,V2=e=>e.status==="pending",Of=e=>{var n;return((n=e==null?void 0:e.learning)==null?void 0:n.pending)??0},Hv=e=>`${e} learned ${e===1?"item waits":"items wait"} for your OK`;function wz(e){const n=e&&typeof e=="object"?e.learning:void 0;return n&&typeof n=="object"&&n.approve===!0?"yes":"password"}const Y2="Approving needs your password sign-in. Until then it stays out of every run.",jz="It changes what this agent trusts or skips, so it waits for you.",kz="Runs that use bash on the host run as you. For untrusted tasks, use the sandbox.",Q2="[redacted]",J2=e=>e===1?"1 note waits for your OK":e>1?`${e} notes wait for your OK`:"A note waits for your OK",Vi=e=>`${e} ${e===1?"note":"notes"}`,Fo=e=>`${e} ${e===1?"run":"runs"}`,Nz={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"},Mf=e=>Nz[e??""]??"stopped",Sz={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 Bv(e){return e.detail&&e.detail.trim()?e.detail.trim():Sz[e.reason??""]??"Not kept: learning stopped."}const Cz=e=>e==="seeded"?"Learns after the run":"Looking back",Pf=e=>ol(Math.round(e)*1e3),Aa=e=>Zr({usd:e,basis:"estimate",charge_state:null,cap_usd:null}),Yk=(e,n)=>e>0?Math.round((n-e)/e*100):null,X2=e=>typeof e.before.median_cost_usd=="number"&&typeof e.after.median_cost_usd=="number",Z2=e=>e.after.median_learning_usd;function Ez(e){const n=[`answers in ${Pf(e.after.median_duration_s)} instead of ${Pf(e.before.median_duration_s)}`];X2(e)&&n.push(`${Aa(e.after.median_cost_usd)} instead of ${Aa(e.before.median_cost_usd)} a run`);const s=Z2(e);return s!==null&&n.push(`learning itself ${Aa(s)} a run`),`Since it learned (on ${Fo(e.after.runs)}): ${n.join(" · ")}`}const $z=e=>{const n=s=>!!s&&typeof s=="object"&&typeof s.runs=="number"&&s.runs>=2&&typeof s.median_duration_s=="number";return!!e&&typeof e=="object"&&n(e.before)&&n(e.after)},_z=/^---\n([\s\S]*?)\n?^---$\n?/m,Zg=e=>/^"[^"]*"$|^'[^']*'$/.test(e)?e.slice(1,-1):e;function Lf(e){const n=e.replace(/\r\n/g,`
|
|
624
|
+
`),s=n.startsWith(`---
|
|
625
|
+
`)?_z.exec(n):null;if(!s||s.index!==0)return{name:"",description:"",type:"project",body:n,rest:[]};const r={},a=[];for(const c of s[1].split(`
|
|
626
|
+
`)){const d=/^(name|description|type):(?:\s+(.*))?$/.exec(c);d&&!(d[1]in r)?r[d[1]]=Zg((d[2]??"").trim()):c.trim()&&a.push(c)}const i=H2.includes(r.type??"")?r.type:"project";return{name:r.name??"",description:r.description??"",type:i,body:n.slice(s[0].length),rest:a}}const Qk=e=>{const n=e.replace(/\s*\n\s*/g," ").trim();return/^["'].*["']$/.test(n)?n.includes('"')?`'${n}'`:`"${n}"`:n},Tz=e=>`---
|
|
627
|
+
name: ${Qk(e.name)}
|
|
628
|
+
description: ${Qk(e.description)}
|
|
629
|
+
type: ${e.type}
|
|
630
|
+
${e.rest.map(n=>`${n}
|
|
631
|
+
`).join("")}---
|
|
632
|
+
${e.body.replace(/^\n*/,`
|
|
633
|
+
`)}`;function Rz(e){const n=Lf(e).rest.find(r=>/^supersedes:/.test(r)),s=n?Zg(n.replace(/^supersedes:\s*/,"").trim()).trim():"";return s?(/^\[.*\]$/.test(s)?s.slice(1,-1).split(","):[s]).map(r=>Zg(r.trim())).filter(Boolean):[]}const Uc=e=>Lf(e).body.replace(/^\n+/,"");function Jk(e,n=[]){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;n.includes(r);a++)r=`${s}-${a}.md`;return r}const Im=(e,n=[])=>{const s=n.filter(a=>a!==Q2),r=new URLSearchParams(s.map(a=>["note",a]));return`#/agents/${encodeURIComponent(e)}/learning${s.length?`?${r}`:""}`};function eC(e){return e.kind===Br?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===Br?{...e,kind:Br,agent_label:null}:e}const Br="learning",Az={seeded:0,reflecting:1,proposed:2,merged:3,dropped:3},ex=e=>e?Az[e.state]??0:-1,Oz=e=>{const n=e==null?void 0:e.learning;return n&&typeof n=="object"&&typeof n.state=="string"?n:void 0},Xk=e=>e.charAt(0).toLowerCase()+e.slice(1);function Mz(e){var s,r;if(!e||ex(e)<2)return"Looking back on this run…";if(e.state==="proposed")return`Looking back: ${Xk(((s=e.detail)==null?void 0:s.trim())||"Checking its new notes…")}`;const n=a=>a.map(i=>i.name.replace(/\s+/g," ").trim()).join(", ");if(e.state==="merged"){const a=Fc(e),i=Wv(e),c=[...a.length?[`kept ${Vi(a.length)} (${n(a)})`]:[],...i.length?[`${Xk(J2(i.length))} (${n(i)})`]:[]];return c.length?`Looked back: ${c.join("; ")}`:`Looked back. ${((r=e.detail)==null?void 0:r.trim())||"It kept what it learned."}`}return Mf(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${Bv(e)}`}function Pz(e){var i;const n=eC(e),s=n.summary??"",r=FS(n)?`${s} (failed)`:s,a=(i=zS(n))==null?void 0:i.trimEnd();return a&&a.trim()!==s.trim()?`${r}
|
|
634
|
+
${a.replace(/^(?=.)/gm," ")}`:r}function Lz(e,n){const s=e.filter(u=>u.agent_label===Br&&u.kind!==Br);if(!s.length)return e.map(eC);const r=e.findLast(u=>u.kind===Br),a=Oz(r),i=ex(a)>ex(n??void 0)?a:n&&{...n,detail:n.detail??(a==null?void 0:a.detail)??(r==null?void 0:r.summary)??null},c=s[0],d={id:c.id,seq:c.seq,timestamp:c.timestamp,created_at:c.created_at,kind:Br,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:Mz(i??void 0),text:[...s,...r?[r]:[]].map(Pz).join(`
|
|
635
|
+
`)};return e.flatMap(u=>u===c?[d]:u.agent_label===Br||u.kind===Br?[]:[u])}const Iz={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},Zk=["Added","Replaced","Retired","Removed","Changed"];function zz(e){const n=[],s=[];let r=0;for(const a of e.split(`
|
|
636
|
+
`)){const i=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(a);i?((r||Number(i[1])>1)&&n.push({text:"…",mark:"gap"}),(r||Number(i[2])>1)&&s.push({text:"…",mark:"gap"}),r++):r&&a.startsWith(" ")?(n.push({text:a.slice(1),mark:"same"}),s.push({text:a.slice(1),mark:"same"})):r&&a.startsWith("-")?n.push({text:a.slice(1),mark:"removed"}):r&&a.startsWith("+")&&s.push({text:a.slice(1),mark:"added"})}return{before:n,after:s}}function Dz(e,n){const s=e.files.filter(d=>d.path!=="MEMORY.md"),r=new Map(s.map(d=>[d.path,d.patch===void 0?null:zz(d.patch)])),a=new Map([...G2(n),...q2(n),...Fc(n)].map(d=>[d.file,d.name])),i=d=>{const u=r.get(d),f=[...(u==null?void 0:u.after)??[],...(u==null?void 0:u.before)??[]].find(x=>x.mark!=="gap"&&/^name:\s*\S/.test(x.text));return a.get(d)??(f==null?void 0:f.text.replace(/^name:\s*/,"").trim())??d.replace(/\.md$/,"")};return s.map(d=>{var h,v;const u=r.get(d.path),f=i(d.path),x=((u==null?void 0:u.after)??[]).filter(y=>y.mark==="added").map(y=>y.text.trim()),b=((h=x.find(y=>y.startsWith("superseded_by:")))==null?void 0:h.replace(/^superseded_by:\s*/,""))??((v=Fc(n).find(y=>{var j;return(j=y.supersedes)==null?void 0:j.includes(d.path)}))==null?void 0:v.file),g=d.status==="added"?`Added: ${f}`:d.status==="deleted"?`Removed: ${f}`:x.includes("status: superseded")||!u&&b?`Replaced: ${f}${b?` → ${i(b)}`:""}`:x.includes("status: retired")?`Retired: ${f}`:`Changed: ${f}`;return u?{file:d.path,said:g,before:d.status==="added"?null:u.before,after:d.status==="deleted"?null:u.after}:{file:d.path,said:g,before:null,after:null,withheld:Iz[d.withheld??""]??"Not shown."}}).sort((d,u)=>Zk.indexOf(d.said.split(":")[0])-Zk.indexOf(u.said.split(":")[0]))}function Fz(e){const n=new Map;for(const s of e)for(const r of s.files){const a=n.get(r)??{};"run"in s.by&&(a.run={id:s.by.run,at:s.at,reason:s.reason}),n.set(r,a)}return n}function gd(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const n=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function dr(e=gd){let n=null;return{keyFor(s,r){const a=JSON.stringify([s,r]);return(n==null?void 0:n.request)!==a&&(n={request:a,key:e()}),n.key},done(){n=null}}}async function tC(e,n,s,r){const a=await r(n,s,e.keyFor(n,{content:s}));return e.done(),a}function Uz(e=gd){const n=new Map;return s=>{let r=n.get(s);return r||(r=dr(e),n.set(s,r)),r}}function tx(e,n){const s=new Set(e.map(r=>r.run_id));return[...e,...n.filter(r=>!s.has(r.run_id))]}const Qa=(e,n,s)=>({...$r(e,n),title:s}),Wz=(e,n)=>{const s=e.get(n);return s!=null&&s.title?Nn(s):`run ${ea(n)}`},nC="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",Hz=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),e0=20,Bz=15e3;function kr(e,n=!1){const[s,r]=p.useState(n),a=p.useRef(Symbol("learning interaction")).current;return p.useEffect(()=>()=>{e.items.delete(a),e.changed(e.items.size>0)},[e,a]),[s,c=>{c?e.items.add(a):e.items.delete(a),e.changed(e.items.size>0),r(c)}]}function Gz(e){return t.jsx(qz,{...e},e.agent.agent_id)}function qz({agent:e,v2:n,focus:s=[],server:r,onAgent:a,places:i,onChanged:c}){var ut;const[d,u]=p.useState(null),[f,x]=p.useState(null),[b,g]=p.useState([]),[h,v]=p.useState([]),[y,j]=p.useState([]),[k,$]=p.useState(null),[S,N]=p.useState(null),[_,E]=p.useState({items:[],cursor:null,pages:0}),[O,A]=p.useState({items:[],cursor:null,pages:0}),[I,M]=p.useState(!1),R=p.useMemo(()=>({items:new Set,changed:M}),[]),[P,D]=kr(R),[W,Y]=p.useState(0),H=p.useRef(0),q=p.useRef(!1),F=p.useRef(!0),G=p.useRef(!1),[U,z]=p.useState(!1),Q=p.useRef(()=>!1);Q.current=()=>!P&&!R.items.size&&!q.current&&_.pages===0;const K=ee=>{const Re=ee==="background";if(!F.current||Re&&(G.current||!Q.current()))return Promise.resolve();const Qe=++H.current;G.current=!0,z(!0),q.current=!1,x(null);const Ze=()=>F.current&&Qe===H.current&&(ee==="write"||!R.items.size)&&(!Re||Q.current()),at=n.agentLearning(e.agent_id).then(Xe=>{Ze()&&(u(Xe),E({items:[],cursor:Xe.notes.next_cursor,pages:0}),A({items:[],cursor:Xe.log.next_cursor,pages:0}))},Xe=>{Ze()&&x(Xe??new Error("unknown"))});return n.listAgentRuns(e.agent_id,50,null,!!e.archived_at).then(Xe=>{Ze()&&g(Xe.runs)},()=>{}),Promise.resolve().then(()=>n.learningPromotions(e.agent_id)).then(Xe=>{Ze()&&(v(Xe.promotions),j(Xe.serving))},()=>{}),Promise.resolve().then(()=>n.learningLoop(e.agent_id)).then(Xe=>{Ze()&&$(Xe)},()=>{}),at.finally(()=>{Qe===H.current&&(G.current=!1,z(!1))})},Z=()=>K("manual"),de=p.useRef(()=>{});de.current=()=>{document.hidden||K("background")},p.useEffect(()=>{F.current=!0,Z();const ee=()=>de.current();window.addEventListener("focus",ee),document.addEventListener("visibilitychange",ee);const Re=window.setInterval(ee,Bz);return()=>{F.current=!1,H.current++,window.removeEventListener("focus",ee),document.removeEventListener("visibilitychange",ee),window.clearInterval(Re)}},[n,e.agent_id,e.archived_at]);const re=()=>(c==null||c(),K("write")),fe=()=>{if(!_.cursor||q.current)return;const ee=H.current;q.current=!0,n.learningNotes(e.agent_id,_.cursor).then(Re=>{ee===H.current&&(q.current=!1,E(Qe=>({items:[...Qe.items,...Re.items.filter(Ze=>!Qe.items.some(at=>at.file===Ze.file))],cursor:Re.next_cursor,pages:Qe.pages+1})))},Re=>{ee===H.current&&(q.current=!1,E(Qe=>({...Qe,error:Re??new Error("unknown")})))})},ve=e.definition.learning===!0||e.definition.learning==="notes",Ee=!!e.archived_at,ue=p.useMemo(()=>[...(d==null?void 0:d.notes.items)??[],..._.items],[d,_.items]),pe=ue.filter(ee=>ee.status==="active"),me=ue.filter(V2),ke=(d==null?void 0:d.skills)??[],$e=(d==null?void 0:d.workflows)??[],[J,Le]=p.useState(void 0),rt=me.length>0||[...ke,...$e].some(ee=>ee.status==="pending")||$e.some(ee=>ee.status==="active");p.useEffect(()=>{if(!rt||J!==void 0)return;let ee=!0;return Promise.resolve().then(()=>n.capabilities()).then(Re=>{ee&&Le(wz(Re))},()=>{ee&&Le("password")}),()=>{ee=!1}},[rt]);const vt=ue.filter(ee=>ee.status==="superseded"||ee.status==="retired"),st=p.useMemo(()=>{const ee=new Map(ue.map(Qe=>[Qe.file,Qe])),Re=new Map;for(const Qe of ue){if(Qe.status==="superseded")continue;const at=[...new Set([...Rz(Qe.text),...ue.filter(Xe=>Xe.status==="superseded"&&Xe.superseded_by===Qe.file).map(Xe=>Xe.file)])].flatMap(Xe=>{const pt=ee.get(Xe);return pt?pt.status==="superseded"&&pt.superseded_by===Qe.file?[{file:Xe,name:pt.name}]:[]:[{file:Xe,name:null}]});at.length&&Re.set(Qe.file,at)}return Re},[ue]),Se=p.useMemo(()=>new Map(b.map(ee=>[ee.run_id,ee])),[b]),Be=p.useMemo(()=>Fz([...(d==null?void 0:d.log.items)??[],...O.items]),[d,O.items]),he=s.filter(ee=>!ue.some(Re=>Re.file===ee)).length>0;p.useEffect(()=>{d&&he&&_.cursor&&_.error===void 0&&_.pages<e0&&fe()},[d,he,_.cursor,_.pages]);const Ve=ue.some(ee=>!Be.has(ee.file));p.useEffect(()=>{if(!d||!Ve||!O.cursor||O.pages>=e0)return;const ee=H.current;n.learningLog(e.agent_id,O.cursor).then(Re=>{ee===H.current&&A(Qe=>({items:[...Qe.items,...Re.items],cursor:Re.next_cursor,pages:Qe.pages+1}))},()=>{ee===H.current&&A(Re=>({...Re,cursor:null}))})},[d,Ve,O.cursor]);const ct=b.filter(ee=>ee.learning&&(ee.learning.state==="merged"||ee.learning.state==="dropped")).length,Me=e.definition.native?"native":Zn(e.definition)?"sdk":"hosted",ot=bL({notes:pe.length,compiledNotes:ue.filter(ee=>ee.status!=="retired"&&w2(ee.text)!==null).length,runs:b.filter(ee=>ee.status==="completed").length,workflows:$e,cost:S,promotions:h,serving:y,loop:k,mode:e.definition.learning==="notes"?"notes":"full",execution:Me}),oe=ee=>t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Refresh learning",title:"Refresh learning",disabled:I||U,onClick:()=>{!R.items.size&&!G.current&&Z()},children:t.jsx(Yo,{className:ae(U&&"animate-spin"),"aria-hidden":!0})})}),ee]});if(f&&!d)return oe(t.jsx(ns,{problem:$r(f,"what this agent learned"),onRetry:Z,className:""}));if(!d)return oe(t.jsx(Vz,{}));const xe=f?t.jsx(Kz,{error:f,onRetry:Z}):null,Ae=ee=>t.jsx(Qz,{agent:e,v2:n,onAgent:a,server:r,disabled:Ee,quiet:ee}),De=ve&&!Ee&&(Me==="hosted"?t.jsx(LL,{v2:n,agentId:e.agent_id,onFinished:()=>{Y(ee=>ee+1),Z()}}):t.jsxs(xt,{tone:"info",children:[Me==="native"?"Run tasks with this agent’s original Claude Code or Codex setup.":"Start tasks in your backend using this agent’s SDK wrapper."," Accepted notes and skills remain available here. CSV learning batches require server-managed execution. ",t.jsx("a",{href:on(e.agent_id,"runs"),className:"underline underline-offset-2",children:"Open the agent’s Run controls"}),"."]}));return!ue.length&&!ke.length&&!$e.length&&!P?oe(t.jsxs("div",{className:"space-y-6",children:[xe,t.jsx(Zz,{on:ve,lookedBack:ct,switchRow:Ae(!0),onAdd:Ee?void 0:()=>D(!0)}),ve&&t.jsx(qk,{stages:ot}),t.jsx(Ak,{v2:n,agentId:e.agent_id,quiet:!0}),De,t.jsx(Sk,{v2:n,agentId:e.agent_id,on:ve,quiet:!0,promotions:h,onCost:N,execution:Me},W),t.jsx(Gk,{loop:k,promotions:h,serving:y,cost:S}),t.jsx(n0,{runs:b})]})):oe(t.jsxs("div",{className:"space-y-6",children:[me.length>0&&t.jsxs("section",{className:"border border-warning/50","aria-label":"Waiting for your OK",children:[t.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",t.jsx("span",{className:"font-mono font-normal text-muted-foreground",children:me.length})]}),t.jsx("p",{className:"px-4 pt-3 text-body text-muted-foreground",children:jz}),((ut=p2(e,i))==null?void 0:ut.place.mode)==="runner"&&(e.definition.tools??[]).includes("bash")&&t.jsx("p",{className:"px-4 pt-1 text-body text-muted-foreground",children:kz}),t.jsx("ul",{className:"space-y-3 p-4",children:me.map(ee=>t.jsx("li",{children:t.jsx(t0,{note:ee,v2:n,agentId:e.agent_id,readOnly:Ee,focused:s.includes(ee.file),from:Be.get(ee.file),runs:Se,onChanged:re,refreshHolds:R,approves:J,replaces:st.get(ee.file)})},ee.file))})]}),t.jsx(qk,{stages:ot}),t.jsx(Ak,{v2:n,agentId:e.agent_id}),$z(d.impact)&&t.jsx(Yz,{impact:d.impact}),De,t.jsx(Sk,{v2:n,agentId:e.agent_id,on:ve,promotions:h,onCost:N,execution:Me},W),t.jsx(nz,{v2:n,agentId:e.agent_id,workflows:$e,promotions:h,serving:y,loop:k,cost:S,onReplayed:()=>{Z()}}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[t.jsxs("div",{className:"min-w-0 space-y-6",children:[t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":"Notes",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-x-4 gap-y-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"What it has learned"}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:pe.length?`${Vi(pe.length)} in use. Every later run reads ${pe.length===1?"it":"them"} before it starts.`:[...ke,...$e].some(ee=>ee.status==="active")?"No note is in use.":"No note is in use: the next run starts with nothing learned."})]}),!Ee&&!P&&t.jsxs(B,{size:"sm",onClick:()=>D(!0),children:[t.jsx(dl,{"aria-hidden":!0})," Add a note"]})]}),xe,!ve&&t.jsx(Xz,{server:r}),P&&t.jsx(iC,{title:"New note",v2:n,agentId:e.agent_id,taken:ue.map(ee=>ee.file),onDone:ee=>{D(!1),ee&&re()}},"new"),t.jsx("ul",{className:"space-y-3",children:pe.map(ee=>t.jsx("li",{children:t.jsx(t0,{note:ee,v2:n,agentId:e.agent_id,readOnly:Ee,focused:s.includes(ee.file),from:Be.get(ee.file),runs:Se,onChanged:re,refreshHolds:R,replaces:st.get(ee.file)})},ee.file))}),_.error!==void 0&&t.jsx(ns,{problem:$r(_.error,"more notes"),onRetry:fe,className:""}),_.cursor&&t.jsx("div",{className:"flex justify-center",children:t.jsx(B,{size:"sm",onClick:fe,children:"Load more notes"})}),vt.length>0&&t.jsx(rD,{notes:vt,all:ue,from:Be,focus:s,runs:Se,v2:n,agentId:e.agent_id,readOnly:Ee,onChanged:re,refreshHolds:R})]}),["skill","workflow"].map(ee=>{const Re=ee==="skill"?ke:$e;if(!Re.length)return null;const Qe=ee==="skill"?"Skills it learned":"Workflows it learned",Ze=Re.filter(Xe=>Xe.status!=="retired"),at=Re.filter(Xe=>Xe.status==="retired");return t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":Qe,children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:Qe}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:Ze.length?ee==="skill"?`${Af(Ze.length,"skill")}: how to do a job it does again, given to every later run once active.`:`${Af(Ze.length,"workflow")}: a job it does again, as steps a later run can call.`:`No ${ee} is in use: the next run gets none.`})]}),Ze.length>0&&t.jsx("ul",{className:"space-y-3",children:Ze.map(Xe=>t.jsx("li",{children:t.jsx(eD,{item:Xe,kind:ee,v2:n,agentId:e.agent_id,readOnly:Ee,runs:Se,approves:J,onChanged:re,refreshHolds:R})},Xe.file))}),at.length>0&&t.jsx(oD,{kind:ee,items:at,v2:n,agentId:e.agent_id,runs:Se,readOnly:Ee,onChanged:re,refreshHolds:R})]},ee)})]}),t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[t.jsx(sC,{title:"Learning",children:Ae(!1)}),t.jsx(Gk,{loop:k,promotions:h,serving:y,cost:S}),t.jsx(n0,{runs:b}),t.jsx(iD,{index:d.index,skills:ke.filter(ee=>ee.status==="active").map(ee=>ee.name),off:!ve||r==="off"})]})]})]}))}function Kz({error:e,onRetry:n}){const s=$r(e,"the notes"),r=[s.said,s.code].filter(Boolean).join(" · ");return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border border-destructive/40 px-3 py-2 text-body",role:"alert",title:r||void 0,children:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't refresh the notes: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)," What's shown may be out of date."]}),t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})]})}function sC({title:e,children:n,label:s}){return t.jsxs("section",{className:"border","aria-label":s??e,children:[t.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:e}),n]})}function Vz(){const e="block bg-muted motion-safe:animate-pulse";return t.jsxs("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading what it learned",children:[t.jsx("span",{"aria-hidden":!0,className:ae(e,"h-6 w-56")}),[0,1,2].map(n=>t.jsxs("div",{"aria-hidden":!0,className:"space-y-3 border p-5",children:[t.jsx("span",{className:ae(e,"h-4 w-1/3")}),t.jsx("span",{className:ae(e,"h-3 w-2/3 bg-muted/70")}),t.jsx("span",{className:ae(e,"h-3 w-1/2 bg-muted/70")})]},n)),t.jsx("span",{className:"sr-only",children:"Loading what it learned…"})]})}function Yz({impact:e}){const{before:n,after:s}=e,r=[{label:"Answers in",now:Pf(s.median_duration_s),was:Pf(n.median_duration_s),delta:Yk(n.median_duration_s,s.median_duration_s)},...X2(e)?[{label:"A run costs",now:Aa(s.median_cost_usd),was:Aa(n.median_cost_usd),delta:Yk(n.median_cost_usd,s.median_cost_usd)}]:[]],a=Z2(e),i=[`Medians of ${Fo(n.runs)} before it first learned and ${Fo(s.runs)} that started from what it learned (a note, a skill or a workflow).`,`Costs are of the ${n.cost_runs} and ${s.cost_runs} runs whose cost is known.`].join(" ");return t.jsx("section",{className:"border","aria-label":Ez(e),children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-4 px-4 py-3",children:[t.jsxs("div",{className:"flex items-baseline gap-2.5",children:[t.jsx("span",{className:"caps text-small font-semibold",children:"Since it learned"}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",title:i,children:["on ",Fo(s.runs)]})]}),t.jsxs("dl",{className:"flex flex-1 flex-wrap items-baseline gap-x-10 gap-y-3","aria-hidden":!0,children:[r.map(c=>t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:c.label}),t.jsxs("dd",{className:"flex items-baseline gap-2 font-mono",children:[t.jsx("span",{className:"text-figure font-semibold leading-none",children:c.now}),t.jsxs("span",{className:"text-small text-muted-foreground",children:["instead of ",c.was]}),c.delta!==null&&c.delta!==0&&t.jsxs("span",{className:ae("text-small",c.delta<0?"text-primary-text":"text-warning-text"),children:[c.delta>0?"+":"−",Math.abs(c.delta),"%"]})]})]},c.label)),a!==null&&t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Learning itself"}),t.jsxs("dd",{className:"font-mono text-body text-muted-foreground",children:[Aa(a)," a run"]})]})]})]})})}function Qz(e){return e.agent.definition.native?t.jsx("div",{className:"p-4",children:t.jsx(x2,{agent:e.agent,v2:e.v2,learning:e.server,onAgent:e.onAgent})}):t.jsx(Jz,{...e})}function Jz({agent:e,v2:n,onAgent:s,server:r,disabled:a,quiet:i}){const[c,d]=p.useState(!1),[u,f]=p.useState(null),[x,b]=p.useState(null),g=async h=>{d(!0),f(null),b(h);try{const{agent:v,etag:y}=await n.getAgent(e.agent_id),j=id(v,{learning:h},h?"Learning on":"Learning off");if(j.unchanged)s==null||s(v);else{const{unchanged:k,...$}=j;s==null||s((await n.updateDefinition(e.agent_id,$,y)).agent)}}catch(v){f(v??new Error("unknown"))}b(null),d(!1)};return t.jsx(U2,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:i,checked:x??(e.definition.learning===!0||e.definition.learning==="notes"),onChange:h=>void g(h),busy:c,disabled:a,server:r,problem:u?t.jsx(ns,{problem:Qa(u,"the agent","Learning was not changed."),className:"mt-2"}):null})}function Xz({server:e}){return t.jsxs(xt,{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 Zz({on:e,lookedBack:n,switchRow:s,onAdd:r}){return t.jsxs("section",{className:"mx-auto max-w-xl border","aria-label":"Learning",children:[t.jsxs("div",{className:"px-6 py-12 text-center",children:[t.jsx(Lx,{className:"mx-auto mb-3 size-5 text-primary-text","aria-hidden":!0}),t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:e?"Nothing learned yet.":"Learning is off for this agent."}),t.jsx("p",{className:"mx-auto mt-2 max-w-md text-lead text-muted-foreground",children:e?"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&&n>0&&t.jsxs("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:[Fo(n)," looked back: nothing worth keeping yet."]})]}),t.jsx("div",{className:"border-t",children:s}),r&&t.jsx("div",{className:"flex justify-center border-t px-4 py-3",children:t.jsxs(B,{size:"sm",variant:"ghost",onClick:r,children:[t.jsx(dl,{"aria-hidden":!0})," Or write a note yourself"]})})]})}function t0({note:e,v2:n,agentId:s,readOnly:r,focused:a,from:i,runs:c,onChanged:d,approves:u,refreshHolds:f,replaces:x=[]}){const[b,g]=p.useState(!1),[h,v]=kr(f),[y,j]=kr(f),[k,$]=p.useState(a),[S,N]=p.useState(null),[_,E]=kr(f),[O,A]=p.useState(null),I=p.useRef(null),M=V2(e),R=async()=>{const Y=H=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:H});E(!0),A(null);try{await n.approveNote(s,e.file,e.etag)}catch(H){E(!1),A(H instanceof ze&&Rm(H).kind==="conflict"?Y(`${Pm} Reload the tab to see the newest version.`):t.jsx(ns,{problem:Qa(H,"the note","The note was not approved."),className:""}));return}await d(),E(!1)};if(p.useEffect(()=>{var H,q;if(!a)return;$(!0),(q=(H=I.current)==null?void 0:H.scrollIntoView)==null||q.call(H,{block:"center",behavior:"smooth"});const Y=setTimeout(()=>$(!1),2600);return()=>clearTimeout(Y)},[a]),p.useEffect(()=>{if(!S)return;const Y=setTimeout(()=>N(null),2400);return()=>clearTimeout(Y)},[S]),h)return t.jsx(iC,{title:"Edit note",v2:n,agentId:s,file:e.file,seen:e,onDone:Y=>{v(!1),Y&&(N("Saved"),d())}});const P=Uc(e.text),D=nx(e.last_change),W=w2(e.text);return t.jsxs("article",{ref:I,id:`note-${e.file}`,tabIndex:-1,"aria-label":e.name,className:ae("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:[t.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words text-prose font-semibold leading-snug",children:e.name}),t.jsx(je,{children:B2(e.type)}),e.origin==="you"&&t.jsx(je,{tone:"muted",children:"From you"}),W&&t.jsxs(je,{tone:"success",label:!0,title:`This note went into the learned workflow ${W}`,children:["Compiled into ",W]}),S&&t.jsx("span",{className:"caps text-micro text-success-text",role:"status",children:S})]}),t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),M&&u==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:Y2})]}),!r&&!y&&t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[M?u==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void R(),disabled:_,"aria-label":`Approve ${e.name}`,children:_?"Approving":"Approve"}):t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>v(!0),"aria-label":`Edit ${e.name}`,children:[t.jsx(Mx,{"aria-hidden":!0})," Edit"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>j(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]})]}),O&&t.jsx("div",{className:"px-5 pt-3",children:O}),P.trim()&&t.jsx(Dm,{text:P}),t.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:[(i==null?void 0:i.run)&&t.jsx(zm,{run:i.run.id,runs:c,at:i.run.at,reason:i.run.reason}),D&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Ix,{className:"size-3","aria-hidden":!0}),D]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(ff,{className:"size-3","aria-hidden":!0}),"Given to ",Fo(e.runs.given)]}),e.runs.read>0&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(ff,{className:"size-3","aria-hidden":!0}),"Read in ",Fo(e.runs.read)]}),x.length>0&&t.jsxs("button",{type:"button",onClick:()=>g(Y=>!Y),"aria-expanded":b,className:"flex items-center gap-1.5 hover:text-foreground",children:[t.jsx(cT,{className:"size-3","aria-hidden":!0}),"Replaces ",x.length," older ",x.length===1?"note":"notes",t.jsx(Tr,{className:ae("size-3 transition-transform",b&&"rotate-180"),"aria-hidden":!0})]})]}),b&&x.length>0&&t.jsx("ul",{"aria-label":"Notes it replaces",className:"space-y-1 border-t px-5 py-2.5 text-body text-muted-foreground",children:x.map(Y=>t.jsx("li",{className:ae("break-words",Y.name===null&&"font-mono text-small"),children:Y.name??Y.file},Y.file))}),y&&t.jsx(oC,{name:e.name,kind:"note",retire:()=>n.retireNote(s,e.file,e.etag),onDone:async Y=>{Y&&await d(),j(!1)}})]})}function eD({item:e,kind:n,v2:s,agentId:r,readOnly:a,runs:i,approves:c,onChanged:d,refreshHolds:u}){const[f,x]=kr(u),[b,g]=p.useState(null),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,$]=kr(u),[S,N]=kr(u),[_,E]=p.useState(null),O=e.status==="pending",[A,I]=kr(u),M=p.useRef(dr()).current,[R,P]=p.useState(null),D=n==="workflow"&&e.status==="active"&&c==="yes",W=async()=>{j(null),g(null),v(null);try{const G=await s.readNote(r,e.file);g(G.note),v(G.etag)}catch(G){j(G??new Error("unknown"))}},Y=async()=>{if(f)return x(!1);x(!0),b===null&&await W()};p.useEffect(()=>{b===null&&h===null||(f?W():(g(null),v(null)))},[e.etag]);const H=n==="skill"&&f&&h?h:e.etag,q=async()=>{$(!0),E(null);try{await s.approveNote(r,Xg(e),H)}catch(G){$(!1),E(G instanceof ze&&Rm(G).kind==="conflict"?t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${Pm} Reload the tab to see the newest version.`}):t.jsx(ns,{problem:Qa(G,`the ${n}`,`The ${n} was not approved.`),className:""}));return}await d(),$(!1)},F=`the ${n} ${e.name}`;return t.jsxs("article",{"aria-label":e.name,className:"border bg-card/40",children:[t.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words font-mono text-lead font-semibold leading-snug",children:e.name}),O&&t.jsxs(je,{tone:"warning",children:[t.jsx(Rx,{className:"size-3","aria-hidden":!0}),"Waits for your OK"]})]}),e.description&&t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),O&&c==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:Y2})]}),t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[!a&&!S&&!A&&t.jsxs(t.Fragment,{children:[O&&c==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void q(),disabled:k,"aria-label":`Approve ${e.name}`,children:k?"Approving":"Approve"}),D&&t.jsx(B,{size:"sm",onClick:()=>{P(null),I(!0)},"aria-label":`Make ${e.name} an agent`,children:"Make this an agent"}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>N(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]}),t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>void Y(),"aria-expanded":f,"aria-label":`${f?"Hide":"Show"} ${F}`,children:[t.jsx(Tr,{className:ae("transition-transform",f&&"rotate-180"),"aria-hidden":!0}),f?"Hide":"Show"]})]})]}),_&&t.jsx("div",{className:"px-5 pt-3",children:_}),R&&t.jsxs("p",{className:"px-5 pt-3 text-body",role:"status",children:["Made the agent ",t.jsx("a",{href:on(R.agent_id),className:"font-mono underline underline-offset-2",children:R.definition.name}),". Open it to run it."]}),f&&(y!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(ns,{problem:$r(y,F),onRetry:()=>void W(),className:""})}):b===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${F}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):n==="skill"?t.jsx(Dm,{text:Uc(b)}):t.jsx(tD,{name:e.name,text:b})),t.jsxs("footer",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 border-t px-5 py-2.5 font-mono text-label text-muted-foreground",children:[e.run&&t.jsx(zm,{run:e.run,runs:i}),nx(e.last_change)&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Ix,{className:"size-3","aria-hidden":!0}),nx(e.last_change)]}),t.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),S&&t.jsx(oC,{name:e.name,kind:n,retire:()=>s.retireNote(r,Xg(e),H),onDone:async G=>{G&&await d(),N(!1)}}),A&&t.jsx(sD,{name:e.name,keys:M,promote:G=>s.promoteWorkflow(r,e.name,G),onDone:G=>{I(!1),G&&P(G)}})]})}function tD({name:e,text:n}){const{doc:s,graph:r}=p.useMemo(()=>{try{const c=JSON.parse(n);return{doc:c,graph:sl(c)}}catch{return{doc:null,graph:null}}},[n]),a=p.useMemo(()=>r?{meta:od(s,r)}:void 0,[s,r]),i=t.jsx("pre",{className:"max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:n});return r!=null&&r.nodes.length?t.jsxs("div",{className:"mx-5 mt-3 space-y-2",children:[t.jsx("div",{className:"overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-4",children:t.jsx(md,{graph:r,marks:a,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),t.jsx(hd,{}),t.jsxs("details",{children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"workflow.json"}),t.jsx("div",{className:"mt-2",children:i})]})]}):t.jsx("div",{className:"mx-5 mt-3",children:i})}function nx(e){return e&&e.kind!=="learned"?`${W2(e.kind,e.by)} · ${mt(e.at)}`:null}function rC(e){return(e==null?void 0:e.by)==="host"?uz:e?`${W2("retired",e.by)} · ${mt(e.at)}`:"Retired"}function zm({run:e,runs:n,at:s,reason:r}){return t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 whitespace-nowrap",title:r?`Kept because: ${r}`:void 0,children:[t.jsx(Lx,{className:"size-3 shrink-0 text-primary-text","aria-hidden":!0}),"Learned in"]}),t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"shrink-0 font-mono text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",title:Wz(n,e),children:ea(e)}),s&&t.jsxs("span",{className:"shrink-0",children:["· ",mt(s)]})]})}function Dm({text:e}){const[n,s]=p.useState(!1),r=e.split(`
|
|
637
|
+
`).length>8||e.length>520,a=p.useMemo(()=>eo(e),[e]);return t.jsxs("div",{className:"px-5 pb-4 pt-3",children:[t.jsxs("div",{className:ae("relative",r&&!n&&"max-h-[9.5rem] overflow-hidden"),children:[t.jsx("div",{className:nC,dangerouslySetInnerHTML:{__html:a}}),r&&!n&&t.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&&t.jsxs("button",{type:"button",onClick:()=>s(i=>!i),className:"caps mt-2 flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Tr,{className:ae("size-3.5 transition-transform",n&&"rotate-180"),"aria-hidden":!0}),n?"Show less":"Show all"]})]})}const nD={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 oC({name:e,kind:n,retire:s,onDone:r}){const[a,i]=p.useState(!1),[c,d]=p.useState(null),u=p.useRef(null);p.useEffect(()=>{var b;(b=u.current)==null||b.focus()},[]);const f=b=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:b}),x=async()=>{i(!0),d(null);try{await s()}catch(b){i(!1),d(b instanceof ze&&Rm(b).kind==="conflict"?f(`${Pm} Reload the tab to see the newest version.`):t.jsx(ns,{problem:Qa(b,`the ${n}`,`The ${n} was not retired.`),className:""}));return}await r(!0)};return t.jsxs("div",{role:"alertdialog","aria-label":`Retire ${e}?`,onKeyDown:b=>{b.key==="Escape"&&(b.stopPropagation(),r(!1))},className:"flex flex-wrap items-center gap-3 border-t border-destructive/40 bg-destructive/5 px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Retire it?"})," ",nD[n]]}),c&&t.jsx("div",{className:"w-full",children:c}),t.jsx(B,{ref:u,size:"sm",variant:"destructive",onClick:()=>void x(),disabled:a,children:a?"Retiring":"Yes, retire"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>void r(!1),disabled:a,children:"Keep"})]})}function sD({name:e,keys:n,promote:s,onDone:r}){const[a,i]=p.useState(!1),[c,d]=p.useState(null),u=p.useRef(null);p.useEffect(()=>{var x;(x=u.current)==null||x.focus()},[]);const f=async()=>{var b;i(!0),d(null);let x;try{x=await s(n.keyFor("promote",e))}catch(g){return i(!1),g instanceof ze&&g.status<500&&n.done(),g instanceof ze&&g.status===403?void d(t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:pz})):g instanceof ze&&((b=g.problems)!=null&&b.length)?void d(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["No agent was made: ",g.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:g.problems.map((h,v)=>t.jsx("li",{children:h.detail},v))})]})):void d(t.jsx(ns,{problem:Qa(g,"the agent","No agent was made."),className:""}))}n.done(),r(x)};return t.jsxs("div",{role:"alertdialog","aria-label":`Make ${e} an agent?`,onKeyDown:x=>{x.key==="Escape"&&(x.stopPropagation(),a||r(null))},className:"flex flex-wrap items-center gap-3 border-t px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Make it an agent?"})," ",hz(e)]}),c&&t.jsx("div",{className:"w-full",children:c}),t.jsx(B,{ref:u,size:"sm",variant:"solid",onClick:()=>void f(),disabled:a,children:a?"Making the agent":"Yes, make the agent"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>r(null),disabled:a,children:"Cancel"})]})}function aC({name:e,kind:n,from:s,restore:r,onChanged:a,onDone:i}){const[c,d]=p.useState(!1),[u,f]=p.useState(null),x=p.useRef(null);p.useEffect(()=>{var h;(h=x.current)==null||h.focus()},[]);const b=h=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:h}),g=async()=>{var h;d(!0),f(null);try{await r()}catch(v){if(d(!1),v instanceof ze&&(v.status===412||v.code==="precondition_failed")){f(b(Pm)),await a();return}if(v instanceof ze&&v.status===403)return void f(b(gz));if(v instanceof ze&&((h=v.problems)!=null&&h.length))return void f(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["Not restored: ",v.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:v.problems.map((y,j)=>t.jsx("li",{children:y.detail},j))})]}));if(v instanceof ze&&v.status===400){await a(),i();return}return void f(t.jsx(ns,{problem:Qa(v,`the ${n}`,`The ${n} was not restored.`),className:""}))}await a(),i()};return t.jsxs("div",{role:"alertdialog","aria-label":`Restore ${e}?`,onKeyDown:h=>{h.key==="Escape"&&(h.stopPropagation(),i())},className:"flex flex-wrap items-center gap-3 border-t bg-card px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Restore it?"})," ",mz(s)]}),u&&t.jsx("div",{className:"w-full",children:u}),t.jsx(B,{ref:x,size:"sm",variant:"solid",onClick:()=>void g(),disabled:c,children:c?"Restoring":"Yes, restore"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:i,disabled:c,children:"Keep"})]})}function iC({title:e,v2:n,agentId:s,file:r,seen:a,taken:i=[],onDone:c}){const[d,u]=p.useState(a?Lf(a.text):{name:"",description:"",type:"feedback",body:`
|
|
638
|
+
`,rest:[]}),[f,x]=p.useState((a==null?void 0:a.etag)??null),[b,g]=p.useState(null),[h,v]=p.useState(!1),[y,j]=p.useState([]),[k,$]=p.useState(null),[S,N]=p.useState(!1),[_,E]=p.useState(null),O=p.useRef(null),A=async()=>{if(r)try{const D=await n.readNote(s,r);u(Lf(D.note)),x(D.etag),g(null)}catch(D){g(D??new Error("unknown"))}};p.useEffect(()=>{var D;(D=O.current)==null||D.focus()},[]);const I=D=>u(W=>({...W,...D})),M=d.name.trim()!==""&&d.description.trim()!==""&&!h,R=async()=>{if(!M)return;if($(null),j([]),N(!1),r&&!f){$(fg);return}v(!0);const D=Tz(d);try{await n.writeNote(s,r??Jk(d.name,i),D,r?{etag:f??""}:{create:!0}),c(!0)}catch(W){v(!1);const Y=W instanceof ze?Rm(W,!r):null;(Y==null?void 0:Y.kind)==="conflict"?(E(D),await A()):(Y==null?void 0:Y.kind)==="refused"?j(Y.problems):(Y==null?void 0:Y.kind)==="taken"?N(!0):$(W??new Error("unknown"))}},P=D=>{D.key==="Escape"?(D.preventDefault(),D.stopPropagation(),c(!1)):D.key==="Enter"&&(D.metaKey||D.ctrlKey||D.target.tagName==="INPUT")&&(D.preventDefault(),R())};return t.jsxs("section",{className:"border border-border-strong bg-card","aria-label":e,onKeyDown:P,children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-2.5",children:[t.jsx("h3",{className:"caps text-label font-semibold",children:e}),t.jsxs("span",{className:"ml-auto hidden font-mono text-label text-muted-foreground sm:inline",children:[t.jsxs("kbd",{children:[Hz?"⌘":"Ctrl","+Enter"]})," save · ",t.jsx("kbd",{children:"Esc"})," cancel"]})]}),b!==null&&t.jsx(ns,{problem:$r(b,"the note"),onRetry:()=>{g(null),A()},className:"m-5"}),t.jsxs("div",{className:"space-y-4 px-5 py-4",children:[_&&t.jsxs("div",{className:"border border-warning/50 bg-warning/10 px-4 py-3 text-body",role:"alert",children:[t.jsxs("p",{className:"flex items-center gap-2 font-semibold",children:[t.jsx(Gs,{className:"size-4 text-warning-text","aria-hidden":!0}),"Changed since you opened it"]}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"This is the newest version. Your edit wasn't saved; it's below to copy."}),t.jsxs("details",{className:"mt-2",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"Your edit"}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words border bg-background p-3 font-mono text-small",children:_})]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Name"}),t.jsx(Ie,{ref:O,value:d.name,onChange:D=>I({name:D.target.value}),placeholder:"e.g., Try /policies/refund-policy first"})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Description"}),t.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."}),t.jsx(Ie,{value:d.description,onChange:D=>I({description:D.target.value}),placeholder:"When it applies, and what to do"})]}),t.jsxs("fieldset",{children:[t.jsx("legend",{className:"caps mb-1.5 text-label font-semibold",children:"Type"}),t.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Type",children:H2.map(D=>t.jsxs("label",{className:ae("caps cursor-pointer border px-3 py-1.5 text-label",d.type===D?"border-foreground":"text-muted-foreground hover:text-foreground"),title:D,children:[t.jsx("input",{type:"radio",name:`type-${r??"new"}`,className:"sr-only",checked:d.type===D,onChange:()=>I({type:D})}),B2(D)]},D))}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:vz[d.type]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Note"}),t.jsx(ln,{value:d.body.replace(/^\n/,""),onChange:D=>I({body:`
|
|
639
|
+
${D.target.value}`}),rows:7,placeholder:"What to do, and why. Markdown.",className:"resize-y leading-[1.65]"})]}),y.length>0&&t.jsxs("div",{className:"border border-destructive/50 bg-destructive/5 px-4 py-3 text-body",role:"alert",children:[t.jsx("p",{className:"font-semibold text-destructive-text",children:"Not saved: the note doesn't pass the checks."}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:y.map((D,W)=>t.jsx("li",{children:D.detail},W))})]}),S&&t.jsx("p",{className:"text-body text-destructive-text",role:"alert",children:"Not saved: a note by this name exists already. Change its name."}),k===fg?t.jsxs("p",{className:"text-body text-destructive-text",role:"alert",children:["Not saved: ",fg]}):k!==null&&t.jsx(ns,{problem:Qa(k,"the note","The note was not saved."),className:""}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void R(),disabled:!M,children:h?"Saving":r?"Save":"Add note"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>c(!1),disabled:h,children:"Cancel"}),!r&&d.name.trim()&&t.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:Jk(d.name,i)})]})]})]})}function rD({notes:e,all:n,from:s,focus:r,runs:a,v2:i,agentId:c,readOnly:d,onChanged:u,refreshHolds:f}){const[x,b]=kr(f,null),[g,h]=p.useState(e.some(N=>r.includes(N.file))),[v,y]=p.useState(new Set),j=N=>y(_=>{const E=new Set(_);return E.has(N)?E.delete(N):E.add(N),E}),k=e.some(N=>r.includes(N.file));p.useEffect(()=>{k&&h(!0)},[k]);const $=N=>{var _;return((_=n.find(E=>E.file===N))==null?void 0:_.name)??N},S=N=>{var E;const _=document.getElementById(`note-${N}`);(E=_==null?void 0:_.scrollIntoView)==null||E.call(_,{block:"center",behavior:"smooth"}),_==null||_.focus({preventScroll:!0})};return t.jsx(lC,{title:"Earlier notes",count:`${e.length} no longer read`,open:g,onToggle:()=>h(N=>!N),children:e.map(N=>{var A,I;const _=N.status==="retired",E=_&&v.has(N.file),O=(A=s.get(N.file))==null?void 0:A.run;return t.jsxs("li",{id:`note-${N.file}`,className:ae("border-b px-4 py-3 last:border-b-0",r.includes(N.file)&&"bg-primary/5"),children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-lead text-muted-foreground line-through decoration-muted-foreground/40",children:N.name}),t.jsx(je,{tone:"muted",children:_?"Retired":"Replaced"}),_&&t.jsx(cC,{open:E,label:`the note ${N.name}`,onClick:()=>j(N.file)}),_&&!d&&N.etag&&x!==N.file&&t.jsxs(B,{size:"sm",onClick:()=>b(N.file),"aria-label":`Restore ${N.name}`,children:[t.jsx(bN,{"aria-hidden":!0})," Restore"]})]}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:N.status==="superseded"&&N.superseded_by?t.jsxs(t.Fragment,{children:["Replaced by ",t.jsx("button",{type:"button",onClick:()=>S(N.superseded_by),className:"text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",children:$(N.superseded_by)})]}):_?rC(N.retired):null}),x===N.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(aC,{name:N.name,kind:"note",from:(I=N.retired)==null?void 0:I.from,restore:()=>i.restoreNote(c,N.file,N.etag),onChanged:u,onDone:()=>b(null)})}),E&&t.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[t.jsx("p",{className:"mt-2 px-5 text-body text-muted-foreground",children:N.description}),Uc(N.text).trim()&&t.jsx(Dm,{text:Uc(N.text)}),O&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(zm,{run:O.id,runs:a,at:O.at,reason:O.reason})})]})]},N.file)})})}function lC({title:e,count:n,open:s,onToggle:r,children:a}){return t.jsxs("section",{className:"border","aria-label":e,children:[t.jsxs("button",{type:"button","aria-expanded":s,onClick:r,className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[t.jsx(Tr,{className:ae("size-3.5 text-muted-foreground transition-transform",!s&&"-rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:e}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:n})]}),s&&t.jsx("ul",{className:"border-t",children:a})]})}function oD({kind:e,items:n,v2:s,agentId:r,runs:a,readOnly:i,onChanged:c,refreshHolds:d}){const[u,f]=p.useState(!1),[x,b]=kr(d,null),[g,h]=p.useState(new Set),v=y=>h(j=>{const k=new Set(j);return k.has(y)?k.delete(y):k.add(y),k});return t.jsx(lC,{title:e==="skill"?"Earlier skills":"Earlier workflows",count:`${n.length} no longer given`,open:u,onToggle:()=>f(y=>!y),children:n.map(y=>{var j;return t.jsxs("li",{className:"border-b px-4 py-3 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-body text-muted-foreground line-through decoration-muted-foreground/40",children:y.name}),t.jsx(je,{tone:"muted",children:"Retired"}),t.jsx(cC,{open:g.has(y.file),label:`the ${e} ${y.name}`,onClick:()=>v(y.file)}),!i&&x!==y.file&&t.jsxs(B,{size:"sm",onClick:()=>b(y.file),"aria-label":`Restore ${y.name}`,children:[t.jsx(bN,{"aria-hidden":!0})," Restore"]})]}),y.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:y.description}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:rC(y.retired)}),x===y.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(aC,{name:y.name,kind:e,from:(j=y.retired)==null?void 0:j.from,restore:()=>s.restoreNote(r,Xg(y),y.etag),onChanged:c,onDone:()=>b(null)})}),g.has(y.file)&&t.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[t.jsx(aD,{v2:s,agentId:r,file:y.file,etag:y.etag,kind:e,label:`the ${e} ${y.name}`}),y.run&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(zm,{run:y.run,runs:a})})]})]},y.file)})})}function cC({open:e,label:n,onClick:s}){return t.jsxs(B,{size:"sm",variant:"ghost",className:"ml-auto",onClick:s,"aria-expanded":e,"aria-label":`${e?"Hide":"Show"} ${n}`,children:[t.jsx(Tr,{className:ae("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function aD({v2:e,agentId:n,file:s,etag:r,kind:a,label:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),x=p.useRef(0),b=async()=>{const g=++x.current;f(null),d(null);try{const h=await e.readNote(n,s);g===x.current&&d(h.note)}catch(h){g===x.current&&f(h??new Error("unknown"))}};return p.useEffect(()=>{b()},[s,r]),u!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(ns,{problem:$r(u,i),onRetry:()=>void b(),className:""})}):c===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${i}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):a==="skill"?t.jsx(Dm,{text:Uc(c)}):t.jsx("pre",{className:"mx-5 mt-3 max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:c})}function n0({runs:e}){const n=e.filter(a=>{var i;return((i=a.learning)==null?void 0:i.state)==="dropped"}),s=n.filter(a=>Mf(a.learning.reason)!=="nothing").slice(0,6),r=n.length-n.filter(a=>Mf(a.learning.reason)!=="nothing").length;return n.length?t.jsxs(sC,{title:"Kept nothing",children:[s.length>0&&t.jsx("ul",{children:s.map(a=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(a.run_id)}`,className:"block px-4 py-3 hover:bg-accent",children:[t.jsx("span",{className:"block text-body",children:Bv(a.learning)}),t.jsxs("span",{className:"mt-1 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 truncate",title:Nn(a),children:Nn(a)}),t.jsxs("span",{className:"shrink-0",children:["· ",mt(a.created_at)]})]})]})},a.run_id))}),r>0&&t.jsxs("p",{className:ae("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`:`${Fo(r)} had`," nothing new to remember."]})]}):null}function iD({index:e,skills:n,off:s}){const[r,a]=p.useState(!1),i=s?0:e.split(`
|
|
640
|
+
`).filter(f=>f.trim()).length,c=p.useMemo(()=>eo(e.trim()),[e]),d=s?[]:n,u=d.length?`${d.length} ${d.length===1?"skill":"skills"}`:"";return t.jsxs("section",{className:"border","aria-label":"What the next run reads",children:[t.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(f=>!f),className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[t.jsx(Tr,{className:ae("size-3.5 text-muted-foreground transition-transform",!r&&"-rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:"What the next run reads"}),t.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:[i?Vi(i):"",u].filter(Boolean).join(" · ")||"nothing"})]}),r&&t.jsxs("div",{className:"border-t",children:[s?t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:"Learning is off: the next run gets no notes or skills."}):i?t.jsx("div",{className:ae(nC,"max-h-72 overflow-auto break-words px-4 py-3 text-body"),dangerouslySetInnerHTML:{__html:c}}):t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:d.length?"No note is in use.":"Nothing yet: no note is in use."}),d.length>0&&t.jsxs("p",{className:"break-words border-t px-4 py-3 font-mono text-small leading-[1.7]",children:["Active skills: ",d.join(", ")]}),t.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 Gv({run:e,link:n=!1,className:s}){var b;const r=G2(e.learning),a=q2(e.learning),i=Fc(e.learning),c=Lm(e.learning)&&e.learning.state!=="seeded",d=Wv(e.learning),u=bz(e.learning),f=[...Kk(e.learning),...Vk(e.learning)],x=((b=e.learning)==null?void 0:b.state)==="dropped"&&Mf(e.learning.reason)!=="nothing"?Bv(e.learning):null;return!r.length&&!a.length&&!i.length&&!c&&!u&&!f.length&&!x?null:t.jsxs("span",{className:ae("inline-flex flex-wrap items-center gap-2",s),"aria-label":"Learning",children:[r.length>0&&t.jsx(Wu,{agentId:e.agent_id,refs:r,link:n,kind:"given"}),a.length>0&&t.jsx(Wu,{agentId:e.agent_id,refs:a,link:n,kind:"read"}),i.length>0&&t.jsx(Wu,{agentId:e.agent_id,refs:i,link:n,kind:"learned",replaces:i.reduce((g,h)=>{var v;return g+(((v=h.supersedes)==null?void 0:v.length)??0)},0)}),u&&t.jsx(Wu,{agentId:e.agent_id,refs:d,link:n,kind:"pending"}),x&&t.jsx(lD,{agentId:e.agent_id,said:x,link:n}),["skill","workflow"].flatMap(g=>{const h=(g==="skill"?Kk:Vk)(e.learning);return[!1,!0].map(v=>{const y=h.filter(j=>j.pending===!0===v);return y.length?t.jsx(cD,{agentId:e.agent_id,refs:y,link:n,kind:g,pending:v},`${g}-${v}`):null})}),c&&t.jsxs(je,{tone:"active",children:[t.jsxs("span",{className:"relative flex size-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inline-flex size-full animate-ping bg-run-active opacity-75"}),t.jsx("span",{className:"relative inline-flex size-1.5 bg-run-active"})]}),Cz(e.learning.state)]})]})}function lD({agentId:e,said:n,link:s}){const r=t.jsxs(je,{tone:"muted",className:ae(s&&"cursor-pointer"),children:[t.jsx(eT,{className:"size-3","aria-hidden":!0}),"Kept nothing"]});return s?t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[t.jsx("a",{href:Im(e),"aria-label":`Kept nothing: ${n}`,className:"inline-flex",children:r}),t.jsx("span",{className:"text-small text-muted-foreground",children:n})]}):t.jsx("span",{title:`Kept nothing: ${n}`,"aria-label":`Kept nothing: ${n}`,className:"inline-flex",children:r})}function cD({agentId:e,refs:n,link:s,kind:r,pending:a}){const i=a?`${Af(n.length,r)} ${n.length===1?"waits":"wait"} for your OK`:`Learned ${Af(n.length,r)}`,c=`${i}: ${n.map(f=>f.name).join(", ")}`,d=a?Rx:r==="skill"?hf:Ka,u=t.jsxs(je,{tone:a?"warning":void 0,className:ae(!a&&"border-primary/50 bg-primary/10 text-primary-text",s&&"cursor-pointer"),children:[t.jsx(d,{className:"size-3","aria-hidden":!0}),i]});return s?t.jsx("a",{href:Im(e),title:c,"aria-label":c,className:"inline-flex",children:u}):t.jsx("span",{title:c,"aria-label":c,className:"inline-flex",children:u})}function Wu({agentId:e,refs:n,link:s,kind:r,replaces:a=0}){const i=r==="pending"?J2(n.length):r==="given"?`Started with: ${Vi(n.length)}`:r==="read"?`Read: ${Vi(n.length)}`:`Learned ${Vi(n.length)}`,c=n.map(h=>h.name).join(", "),d=r==="given"||r==="read",u=d?ff:r==="pending"?Rx:Lx,f=t.jsxs(je,{tone:r==="pending"?"warning":void 0,className:ae(r==="learned"?"border-primary/50 bg-primary/10 text-primary-text":d?"border-border-strong/70 text-foreground/80":"",s&&"cursor-pointer transition-colors group-hover/tip:border-foreground/70"),children:[t.jsx(u,{className:"size-3","aria-hidden":!0}),i]}),x=n.filter(h=>h.file!==Q2),b=`${i}${c?`: ${c}`:""}${a?` (replaces ${a===1?"1 older note":`${a} older notes`})`:""}`;if(!s||!x.length&&r!=="pending")return t.jsx("span",{title:b,"aria-label":b,className:"inline-flex",children:f});const g=t.jsxs(t.Fragment,{children:[t.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"}),n.length>0&&t.jsx("ul",{className:"mt-1 space-y-0.5",children:n.map(h=>t.jsx("li",{className:"font-semibold",children:h.name},h.file))}),a>0&&t.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["Replaces ",a===1?"1 older note":`${a} older notes`,"."]}),t.jsx("span",{className:"mt-1.5 block text-label text-muted-foreground",children:"Open in Learning"})]});return t.jsx(n5,{tip:g,children:t.jsx("a",{href:Im(e,x.map(h=>h.file)),"aria-label":b,className:"inline-flex",children:f})})}function dD({n:e,className:n}){return e<=0?null:t.jsx("span",{"aria-label":Hv(e),className:ae("inline-flex min-w-[18px] items-center justify-center border border-warning/50 bg-warning/10 px-1 font-mono text-micro text-warning-text",n),children:e})}const uD=["pi","claude-agent","codex","opencode"];function fD(e){const n=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"&&n.add(a.tool),Object.values(a).forEach(s)};return s(e),[...n].sort()}function mD(e){const n=s=>Array.isArray(s)&&s.every(r=>typeof r=="string")?[...new Set(s)]:[];return{denied:n(e==null?void 0:e.denied),asks:n(e==null?void 0:e.asks)}}function hD(e){return(Array.isArray(e)?e:[]).flatMap(n=>{const s=n;return!s||typeof s.name!="string"||!Array.isArray(s.providers)||!s.providers.length?[]:[{name:s.name,providers:s.providers,provider:s.provider??s.providers[0],default_provider:s.default_provider??s.providers[0],resolves:s.resolves&&typeof s.resolves=="object"?s.resolves:{},available:s.available!==!1,...typeof s.reason=="string"&&s.reason?{reason:s.reason}:{}}]})}const qv="Refused on this server for every agent, whatever the agent's own setting or Never ask.",pD="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.",dC=(e,n,s,r)=>{var d;const a=s==null?void 0:s.find(u=>u.name===e);if(a)return a.permission==="deny"&&a.permission_from==="server";const i=Bo(e),c=i?(d=r==null?void 0:r.find(u=>u.name===i.server))==null?void 0:d.tools.find(u=>u.name===i.tool):void 0;return c?c.permission==="deny":n.some(u=>u.name===e&&u.permission==="deny")};function gD(e){return(e??[]).map(({name:n,permission:s,default_permission:r,permissions:a,ask_needs:i})=>({name:n,permission:s,default_permission:r,permissions:a,...i==="password"?{ask_needs:i}:{}}))}const xD={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},uC={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."}}},If=(e,n)=>{var s;return(n&&((s=uC[n])==null?void 0:s.label[e]))??xD[e]??e},vD={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."},s0=(e,n)=>{var s;return(n&&((s=uC[n])==null?void 0:s.help[e]))??vD[e]};function fC(e,n){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:If(e,n),unavailable:!1}:{text:"not known",unavailable:!1}}function mC(e,n,s,r,a){const{[n]:i,...c}=e,{[s]:d,...u}=i??{},f=r===void 0||r===a?u:{...u,[s]:r};return Object.keys(f).length?{...c,[n]:f}:c}const yD=(e,n,s,r)=>mC(e,n,"provider",s,r),bD=(e,n,s,r)=>mC(e,n,"permission",s,r);function sx(e,n){const s=new Map(n.map(r=>[r.name,r.default_provider]));return Object.fromEntries(Object.entries(e).flatMap(([r,a])=>{if(!a||typeof a!="object")return[];const{provider:i,...c}=a,d=i!==void 0&&!(s.has(r)&&i===s.get(r))?{...c,provider:i}:c;return Object.keys(d).length?[[r,d]]:[]}))}function hC(e,n,s){const r={},a=[];for(const[i,c]of Object.entries(e)){if(n&&i!==n&&!i.startsWith(`${n}.`)&&!i.startsWith(`${n}/`))continue;const d=n?i.slice(n.length+1):i,u=[...s].sort((f,x)=>x.length-f.length).find(f=>d===f||d.startsWith(`${f}.`)||d.startsWith(`${f}/`));u?(r[u]??(r[u]=[])).push(c):a.push(c)}return{byTool:r,rest:a}}const wD=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),jD=e=>{if(!Array.isArray(e))return[e];const n=[...new Set(e.filter(s=>s!==null).map(s=>JSON.stringify(s)))].sort();return[...e.includes(null)?[null]:[],...n.map(s=>JSON.parse(s))]},kD=e=>typeof e=="string"?e:JSON.stringify(e);function ND(e){return Object.keys(e).sort().map(n=>{const s=e[n];if(wD(s)){const d=[...new Set(s.keys)].sort();return d.length===1?`${n} may hold only the key ${d[0]} (any value)`:`${n} may hold only the keys ${d.join(", ")} (any values)`}const r=jD(s),a=r[0]===null,i=(a?r.slice(1):r).map(d=>kD(d));if(!i.length)return`${n} must be left out`;const c=i.length===1?i[0]:`one of ${i.join(", ")}`;return`${n} must be ${a?`left out or ${c}`:c}`}).join("; ")}const SD="Calls outside it are refused before they run or ask.",CD="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.",ED=[{id:"runs",label:"Runs",shows:()=>!0,Body:AD},{id:"versions",label:"Versions",shows:()=>!0,Body:zM},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:OD},{id:"learning",label:"Learning",shows:(e,n)=>e.kind==="agentic"&&n.learning!==!1,Body:e=>t.jsx(Gz,{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,n)=>n.analytics,Body:dP}],on=(e,n)=>`#/agents/${encodeURIComponent(e)}${n?`/${n}`:e==="new"||e==="connect"?"/runs":""}`;function $D({v2:e,agentId:n,routePrefix:s,harnesses:r,go:a,tab:i,learning:c,notes:d,places:u}){const[f,x]=p.useState(null),[b,g]=p.useState(null),[h,v]=p.useState(0),[y,j]=p.useState(void 0);p.useEffect(()=>{let P=!0;return x(null),g(null),j(void 0),_(!1),S.current=++k.current,e.getAgent(n).then(D=>{P&&x(D.agent)},D=>{P&&g({cause:D})}),e.statsOver({from:vv(a2),agent:n}).then(D=>{P&&j(D)},()=>{P&&j(null)}),()=>{P=!1,S.current=++k.current}},[e,n,h]);const k=p.useRef(0),$=p.useRef(0),S=p.useRef(0),[N,_]=p.useState(!1),E=(P=!1,D=!P)=>{const W=++k.current;return D&&(S.current=W),e.getAgent(n).then(Y=>(W>$.current&&W>=S.current&&($.current=W,x(H=>H&&H.agent_id===Y.agent.agent_id?Y.agent:H),_(!1)),$.current>=W),()=>(W===k.current&&!P&&_(!0),$.current>=W))},O=P=>{x(D=>({...P,tools:(D==null?void 0:D.tools)??P.tools})),E()},A=()=>void E(),I=()=>void E(!0,!1),M=()=>E(!0,!0),R=y===void 0?void 0:y!==null;return b?b.cause instanceof ze&&b.cause.status===404?t.jsx(BS,{what:"agent",id:n,list:{href:"#/agents",label:"Open the agents list"}}):t.jsx(Kt,{problem:Ft(b.cause,"the agent"),onRetry:()=>v(P=>P+1)}):f?t.jsx(_D,{agent:f,onAgent:O,onSignInsAgent:x,reread:E,onChanged:A,poll:I,afterForget:M,stale:N,v2:e,go:a,stats:y,analytics:R,places:u,routePrefix:s,harnesses:r,tab:i,learning:c,notes:d},f.agent_id):t.jsx(OM,{})}function _D({agent:e,onAgent:n,onSignInsAgent:s,reread:r,onChanged:a,poll:i,afterForget:c,stale:d,v2:u,go:f,stats:x,analytics:b,routePrefix:g,harnesses:h,tab:v,learning:y,notes:j,places:k}){var re,fe,ve,Ee;const $=RD(e,u,r,()=>r(!1,!1)),[S,N]=p.useState(!1),_=Of(e),E=e.definition,O=Zn(E),{native:A,refresh:I}=GP(e,u),M=e.kind==="workflow",R=M?Ka:$x,P=R2(E.harness??"pi",h),D=E.model?al(E.model,g):P?(({text:ue,title:pe})=>({text:`${ue} (default)`,title:pe}))(al(P,g)):{text:mI},W=M||A||O||h==null?void 0:h.find(ue=>ue.id===(E.harness??"pi")&&ue.available===!1),Y=W?`${W.id} doesn't run on this server${W.reason?`: ${W.reason}`:"."}`:void 0,H=p2(e,k),q=`${EP(H==null?void 0:H.place)}${H!=null&&H.byDefault?" (server default)":""}`,F=!O&&!A&&!M&&!W&&!E.model&&!P&&(h==null?void 0:h.some(ue=>ue.id===(E.harness??"pi")&&ue.default_model===null)),G=[...O?[["Runtime",Ko(O.runtime)],["Model","Reported per run"],["Execution","Your backend"]]:A?[["Runtime",A.runtime],["Model",A.model??"Native default"],["Selector",A.selector.kind==="project"?"Project default":A.selector.name??A.selector.kind],["Machine",A.machine_id]]:M?[]:[["Harness",E.harness??"pi"],["Model",D.text,D.title],["Thinking",E.thinking??"default"],["Runs",q]],["Revision",`rev ${E.version} of ${e.revisions}`]],U=ED.filter(ue=>ue.shows(e,{analytics:b===!0,learning:y===void 0?v==="learning"?void 0:!1:!!y})),z=U.find(ue=>ue.id===v)??U[0],Q=v==="analytics"&&b===void 0,K=((re=$.runs)==null?void 0:re.filter(TD))??[],Z=((fe=e.runs)==null?void 0:fe.live)??($.runs?`${K.length}${$.cursor?"+":""}`:"—"),de=[["Status",e.archived_at?"Archived":A?cd(A):"Active"],["Live jobs",String(Z)],...G];return t.jsx(qP,{native:A,children:t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":"Agent detail",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-5 py-2 lg:flex-nowrap lg:py-0","aria-label":"Agent toolbar",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>f(e.archived_at?"#/agents?archived=true":"#/agents"),children:t.jsx(zn,{"aria-hidden":!0})}),t.jsx(R,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 truncate text-body font-semibold",children:E.name}),t.jsxs("div",{className:"ml-auto flex max-w-full flex-wrap items-center justify-end gap-2",children:[t.jsx(B,{size:"icon","aria-label":"Refresh agent",onClick:()=>{$.refresh(),I()},disabled:$.reading,children:t.jsx(Yo,{className:ae($.reading&&"animate-spin"),"aria-hidden":!0})}),!A&&!O&&t.jsx(B,{size:"sm",onClick:()=>f(on(e.agent_id,"edit")),children:"Detailed editor"}),t.jsx(tn,{label:"Edit agent",prompt:Ho(location.origin,e.agent_id,!!A,O==null?void 0:O.runtime),playgroundHref:A||O?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),!e.archived_at&&t.jsx(tn,{variant:"primary",label:"Run agent",disabled:!!A&&(!A.connected||A.state!=="ready"||!A.capabilities.launch),prompt:kv(location.origin,e.agent_id,O==null?void 0:O.runtime),playgroundHref:O?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`})]})]}),t.jsxs("main",{className:"grid min-h-0 flex-1 grid-cols-1 items-start gap-6 overflow-auto p-5 lg:grid-cols-[minmax(260px,320px)_minmax(0,1fr)] md:p-8",children:[t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"Agent overview",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold",children:E.name}),E.approvals==="never"&&t.jsx(je,{tone:"warning",className:"mt-2",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"}),E.description&&t.jsx("p",{id:"agent-description",className:ae("mt-2 text-body leading-relaxed text-muted-foreground",!S&&"max-sm:line-clamp-2"),children:E.description}),t.jsx("p",{className:"mt-3 break-all font-mono text-label text-muted-foreground",children:e.agent_id})]}),t.jsxs("button",{type:"button","aria-expanded":S,"aria-controls":E.description?"agent-description agent-facts":"agent-facts",onClick:()=>N(ue=>!ue),className:"flex w-full min-w-0 items-center gap-2 text-left font-mono text-small text-muted-foreground sm:hidden",children:[t.jsx(Cs,{className:ae("size-3.5 shrink-0 transition-transform",S&&"rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:de.map(([,ue])=>ue).join(" · ")})]}),t.jsxs("dl",{id:"agent-facts",className:ae("grid grid-cols-2 gap-3",!S&&"max-sm:hidden"),"aria-label":"Current revision",children:[de.map(([ue,pe,me])=>t.jsxs("div",{className:"min-w-0 border bg-card p-4",children:[t.jsx("dt",{className:"mb-2 text-label text-muted-foreground",children:ue}),t.jsx("dd",{className:"break-words text-body font-semibold",title:me,children:pe})]},ue)),!M&&!A&&!O&&t.jsxs("div",{className:"col-span-2 border bg-card p-4",children:[t.jsx("dt",{className:"mb-2 text-label text-muted-foreground",children:"Tools"}),t.jsx("dd",{className:"break-words text-small",children:!M&&e.tools?e.tools.length?t.jsx("ul",{className:"space-y-2","aria-label":"Tools",children:e.tools.map(ue=>t.jsxs("li",{children:[t.jsx("span",{title:ue.blurb,children:ue.name}),ue.provider?` · ${If(ue.provider,ue.name)}`:"",ue.permission?` · ${ue.permission}`:"",fC(ue.resolved,ue.name).unavailable&&t.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:ue.resolved,children:" · unavailable"})]},ue.name))}):"none":E.tools.join(", ")||"None configured"})]})]}),Y&&t.jsx(xt,{tone:"warning","aria-label":"Harness not available",children:Y}),!e.archived_at&&F&&t.jsxs(xt,{children:["Running this agent needs a configured model. ",t.jsx("a",{href:"#/settings/keys",className:"text-primary-text underline underline-offset-2",children:"Set up models in Settings"})]}),d&&t.jsxs(xt,{tone:"error",children:["Couldn't refresh this agent. ",t.jsx(B,{size:"sm",onClick:()=>void r(),children:"Retry"})]}),(ve=e.warnings)!=null&&ve.length?t.jsxs("div",{className:"font-mono text-small",role:"status","aria-label":"Save warnings",children:[t.jsx("p",{className:"text-warning-text",children:"Created. What the server said of this revision (Edit shows each at its step):"}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:e.warnings.map((ue,pe)=>t.jsxs("li",{children:[t.jsx("span",{className:"text-muted-foreground",children:ue.field})," ",ue.message]},`${ue.field}:${pe}`))})]}):null,t.jsx(QP,{agent:e,v2:u,onAgent:s,poll:i,refresh:c}),A&&t.jsx(KP,{agent:e,v2:u,learning:y,onAgent:n,onChanged:async()=>{I(),await r()}}),!A&&t.jsxs("section",{className:"border bg-card p-4","aria-label":"Agent configuration",children:[t.jsx("h2",{className:"mb-4 text-body font-semibold",children:"Configuration"}),t.jsxs("dl",{className:"space-y-3 text-small",children:[t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("dt",{className:"text-muted-foreground",children:"Kind"}),t.jsx("dd",{children:e.kind})]}),t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("dt",{className:"text-muted-foreground",children:"Skills"}),t.jsx("dd",{className:"max-w-[75%] break-words text-right",children:O?"Managed by your backend":E.skills.join(", ")||"None configured"})]})]}),E.instructions&&t.jsxs("details",{className:"mt-4 text-small",children:[t.jsx("summary",{className:"cursor-pointer",children:"Instructions"}),t.jsx("pre",{className:"mt-3 whitespace-pre-wrap break-words font-sans leading-relaxed text-muted-foreground",children:E.instructions})]})]}),t.jsxs("section",{className:"border bg-card p-4","aria-label":"Live jobs",children:[t.jsx("h2",{className:"mb-3 text-body font-semibold",children:"Live jobs"}),K.length?t.jsx("ul",{className:"space-y-3",children:K.map(ue=>t.jsx("li",{children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(ue.run_id)}`,className:"flex items-center gap-2 text-small hover:text-primary-text",children:[t.jsx(yl,{run:ue}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:Nn(ue)}),t.jsx(cr,{className:"size-3 shrink-0","aria-hidden":!0})]})},ue.run_id))}):t.jsx("p",{className:"text-small leading-relaxed text-muted-foreground",children:$.runs?(Ee=e.runs)!=null&&Ee.live?"Live jobs are outside the loaded history. Load more runs to find them.":$.error?"Live jobs could not be refreshed.":"No live jobs.":"Loading live jobs…"})]})]}),t.jsxs("section",{className:"min-w-0","aria-label":"Agent workspace",children:[t.jsx(gS,{id:"agent-views",label:"Agent views",value:z.id,onChange:ue=>f(on(e.agent_id,ue)),tabs:U.map(ue=>({id:ue.id,label:t.jsxs(t.Fragment,{children:[ue.label,ue.id==="learning"&&t.jsx(dD,{n:_,className:"ml-1.5"})]})})),className:"mb-5 overflow-x-auto px-0 md:px-0"}),t.jsx("div",{...t5("agent-views",z.id),"aria-label":Q?void 0:z.label,children:Q?t.jsx(Fn,{label:"Loading the tab",rows:4}):t.jsx(z.Body,{agent:e,v2:u,go:f,stats:x,history:$,focus:j,learning:y,onAgent:n,onChanged:a,places:k})})]})]})]})})}const TD=e=>!e.imported_from&&["queued","working","paused","input_required"].includes(e.status);function RD(e,n,s,r){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[x,b]=p.useState(!1),[g,h]=p.useState(null),[v,y]=p.useState(!1),j=p.useRef(0),k=p.useRef([]),$=p.useRef(0),S=p.useRef(!1),N=async(_,E=!1,O=!1,A=!1)=>{if(S.current)return;S.current=!0;const I=++j.current;f(!0),b(!!_);const M=E?A?r():s():Promise.resolve();try{let R=_,P=[];const D=_||O?void 0:k.current.at(-1),W=D?Date.parse(D.created_at):NaN,Y=$.current+1;let H=!1;const q=new Set;do{if(q.size>=Y){y(!0),h({title:"Run history could not be refreshed.",why:"Previous runs are still shown. The run list changed too much to refresh them safely.",next:"Try again, or reload the latest runs to reset the loaded history."});return}if(q.has(R))throw new Error("The runs list repeated a page. Refresh to try again.");q.add(R);const F=await n.listAgentRuns(e.agent_id,50,R,!!e.archived_at);if(I!==j.current)return;P=tx(P,F.runs),R=F.next_cursor,H||(H=F.runs.some(G=>G.run_id===(D==null?void 0:D.run_id)||Date.parse(G.created_at)<W))}while(!_&&R&&D&&!H);I===j.current&&(k.current=_?tx(k.current,P):P,$.current=_?$.current+1:q.size,i(k.current),d(R),h(null),y(!1))}catch(R){I===j.current&&h(Ft(R,_?"more runs":"the runs"))}finally{await M,I===j.current&&(S.current=!1,f(!1),b(!1))}};return p.useEffect(()=>{S.current=!1,k.current=[],$.current=0,i(null),d(null),h(null),y(!1),N(null);const _=()=>{document.hidden||N(null,!0,!1,!0)};window.addEventListener("focus",_),document.addEventListener("visibilitychange",_);const E=window.setInterval(_,1e4);return()=>{j.current++,S.current=!1,window.clearInterval(E),window.removeEventListener("focus",_),document.removeEventListener("visibilitychange",_)}},[n,e.agent_id,e.archived_at]),{runs:a,cursor:c,reading:u,more:x,error:g,refresh:()=>{N(null,!0)},loadMore:()=>{c&&N(c)},reloadLatest:v?()=>{N(null,!0,!0)}:null}}function AD({agent:e,history:n}){const[s,r]=p.useState(""),{runs:a,cursor:i,reading:c,more:d,error:u,refresh:f,loadMore:x,reloadLatest:b}=n;if(u&&!a)return t.jsx(Kt,{problem:u,onRetry:f,className:""});if(!a)return t.jsx(Fn,{label:"Loading the runs",rows:5});const g=a.filter(h=>`${Nn(h)} ${h.run_id} ${h.status}`.toLowerCase().includes(s.toLowerCase()));return t.jsxs("section",{className:"min-h-[380px] overflow-hidden border","aria-label":"Agent run history",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b p-3",children:[t.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(sm,{className:"size-3.5 text-muted-foreground","aria-hidden":!0}),t.jsx(Ie,{"aria-label":"Search this agent's runs",value:s,onChange:h=>r(h.target.value),placeholder:"Search runs…",className:"w-40 min-w-0"})]}),t.jsxs("span",{className:"text-small text-muted-foreground",children:[a.length,i?"+":""," ",a.length===1&&!i?"run":"runs"]}),t.jsx("div",{className:"ml-auto",children:t.jsx(tn,{label:"Query",prompt:`${Em(location.origin,e.agent_id)}
|
|
641
|
+
Current view: all statuses; ${e.archived_at?"archived runs":"non-archived runs"}.`,playgroundHref:gv(e.agent_id,{archived:!!e.archived_at})})})]}),a.length?t.jsxs("div",{className:"overflow-x-auto",children:[t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Runs",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Status","Run","Started","Duration","Cost"].map(h=>t.jsx("th",{className:"whitespace-nowrap px-4 py-3 font-semibold",children:h},h))})}),t.jsx("tbody",{children:g.map(h=>t.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-accent/50",children:[t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:t.jsx(yl,{run:h})}),t.jsxs("td",{className:"min-w-48 px-4 py-3",children:[t.jsxs("a",{href:`#/runs/${encodeURIComponent(h.run_id)}`,className:"flex items-center gap-2 font-semibold hover:text-primary-text",children:[t.jsx("span",{className:"line-clamp-2",children:Nn(h)}),t.jsx(cr,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-label text-muted-foreground",children:[t.jsx(Gv,{run:h}),h.effort&&t.jsxs("span",{children:["effort ",h.effort]}),h.imported_from&&t.jsxs("span",{children:["Imported history · ",h.imported_from.source]})]})]}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:mt(h.created_at)}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:h.ended_at?t.jsx("span",{title:"How long it ran",children:ol(Date.parse(h.ended_at)-Date.parse(h.created_at))}):"—"}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:h.cost&&(h.cost.usd!==null||xl(h.cost))?Zr(h.cost,{ended:Ua(h.status)}):"—"})]},h.run_id))})]}),!g.length&&t.jsx("p",{className:"p-10 text-center text-body text-muted-foreground",children:"No loaded runs match your search."})]}):t.jsxs("div",{className:"px-4 py-12 text-center text-body text-muted-foreground",children:[t.jsx("p",{children:"No runs of this agent yet."}),!e.archived_at&&t.jsx("p",{className:"mt-2",children:"Choose Run agent to continue with your coding agent or the API playground."})]}),u&&t.jsxs("div",{className:"m-4 space-y-3",children:[t.jsx(Kt,{problem:u,onRetry:f,className:""}),b&&t.jsx(B,{size:"sm",onClick:b,disabled:c,children:"Reload latest runs"})]}),i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",onClick:x,disabled:c,children:d?"Loading":"Load more"})})]})}function OD({agent:e}){const n=e.definition.workflow,s=p.useMemo(()=>sl(n),[n]),r=p.useMemo(()=>({meta:od(n,s)}),[n,s]);return t.jsxs("section",{className:"overflow-hidden border",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[Mm(Uv(s))," · rev ",e.definition.version]}),t.jsx("span",{className:"flex-1"}),t.jsx(tn,{label:"Edit workflow",prompt:Ho(location.origin,e.agent_id),playgroundHref:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`})]}),t.jsx("div",{className:"min-h-[360px] overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-5",children:s.nodes.length?t.jsx(md,{graph:s,marks:r,label:"The workflow's graph",minScale:.55}):t.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"This revision's workflow has no root node to draw."})}),t.jsx("div",{className:"border-t px-4 py-2",children:t.jsx(hd,{})})]})}function pC({size:e=18,className:n}){return t.jsx("svg",{width:e,height:e,className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M3 4q9 4 18 0M4 9h16M7 6v15M17 6v15M6 15h12M12 7v2"})})}const MD=20,PD=100,LD=4,Ti=(e,n)=>(e==null?void 0:e.filter(s=>s.status===n).length)??0,gC=e=>`#/agents/${encodeURIComponent(e.agent_id)}/learning`,rx=e=>e.toLocaleString("en-US"),xC=[{label:"Active notes",of:e=>e.view?{value:Ti(e.notes,"active"),exact:!!e.complete}:null},{label:"Learned skills",of:e=>{var n;return(n=e.view)!=null&&n.skills?{value:Ti(e.view.skills,"active"),exact:!0}:null}},{label:"Workflow drafts",of:e=>{var n;return(n=e.view)!=null&&n.workflows?{value:Ti(e.view.workflows,"active"),exact:!0}:null}},{label:"Pending review",of:e=>e.view?{value:Ti(e.notes,"pending")+Ti(e.view.skills,"pending")+Ti(e.view.workflows,"pending"),exact:!!e.complete&&!!e.view.skills&&!!e.view.workflows}:null},{label:"In progress",of:e=>e.view?{value:e.view.counts.in_progress,exact:!0}:null}];function vC(e,n){if(!e.length)return"0";const s=e.map(n);return s.every(r=>r===null)?"—":`${rx(s.reduce((r,a)=>r+((a==null?void 0:a.value)??0),0))}${e.some(r=>r.stale)?" (last read)":s.every(r=>r==null?void 0:r.exact)?"":"+"}`}function ID({v2:e,server:n}){const[s,r]=p.useState(null),[a,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),x=p.useRef(0),b=p.useRef(!1),g=p.useCallback(async()=>{if(n!=="on"&&n!=="off"||b.current)return;b.current=!0;const k=++x.current;d(!0),i(null),r(S=>(S==null?void 0:S.map(N=>N.view?{...N,stale:!0}:N))??null);const $=()=>x.current===k;try{let S=null;const N=new Set,_=await Gr(async M=>{if(!$())throw new Error("Read superseded");if(M&&N.has(M))throw new Error("The agent list repeated a page. Refresh to try again.");M&&N.add(M);const R=await e.listAgents({cursor:M});return S=R.next_cursor,R},M=>M.agents,PD);if(!$())return;if(S)throw new Error("The agent list is too large to read in one view. Open Connected agents to inspect an agent.");const E=[...new Map(_.map(M=>[M.agent_id,M])).values()].map(M=>({agent:M}));r(M=>{const R=new Map(M==null?void 0:M.map(P=>[P.agent.agent_id,P]));return E.map(({agent:P})=>{const D=R.get(P.agent_id);return P.kind==="agentic"&&(D==null?void 0:D.agent.kind)==="agentic"&&D.view?{...D,agent:P,stale:!0,error:void 0,unavailable:void 0}:{agent:P}})});const O=E.filter(M=>M.agent.kind==="agentic");let A=0;const I=async()=>{for(;$()&&A<O.length;){const{agent:M}=O[A++];let R;try{const P=await e.agentLearning(M.agent_id);if(!$())return;const D=new Map(P.notes.items.map(q=>[q.file,q]));let W=P.notes.next_cursor,Y;const H=new Set;for(let q=0;W&&q<MD&&$();q++){if(H.has(W)){Y="The note list repeated a page.";break}H.add(W);try{const F=await e.learningNotes(M.agent_id,W);F.items.forEach(G=>D.set(G.file,G)),W=F.next_cursor}catch(F){Y=Ft(F,"more notes").why;break}}R={agent:M,view:P,notes:[...D.values()],complete:!W,...W?{noteIssue:Y??"More note pages are available in the agent's Learning tab."}:{}}}catch(P){R={agent:M,error:Ft(P,"Learning"),unavailable:P instanceof ze&&P.status===404}}if(!$())return;r(P=>(P==null?void 0:P.map(D=>D.agent.agent_id!==M.agent_id?D:R.error&&!R.unavailable&&D.view?{...D,...R,stale:!0}:R))??null)}};await Promise.all(Array.from({length:Math.min(LD,O.length)},I)),$()&&f(new Date().toISOString())}catch(S){$()&&i(Ft(S,"Learning Dojo"))}finally{$()&&(b.current=!1,d(!1))}},[e,n]);p.useEffect(()=>{r(null),f(null),i(null),g();const k=()=>{document.hidden||g()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{x.current++,b.current=!1,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[g]),p.useEffect(()=>{if(n!=="on"&&n!=="off")return;const k=window.setInterval(()=>{document.hidden||g()},15e3);return()=>window.clearInterval(k)},[n,g]);const h=(s==null?void 0:s.filter(k=>k.agent.kind==="agentic"))??[],v=h.filter(k=>k.view).length,y=h.some(k=>k.stale),j=h.flatMap(k=>{var $;return((($=k.view)==null?void 0:$.log.items)??[]).map(S=>({agent:k.agent,change:S}))}).sort((k,$)=>$.change.at.localeCompare(k.change.at)).slice(0,8);return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 items-center gap-2 border-b px-5",children:[t.jsx(pC,{className:"shrink-0"}),t.jsx("h1",{className:"caps text-body font-semibold",children:"Learning Dojo"}),t.jsx(B,{className:"ml-auto",size:"icon","aria-label":"Refresh Learning Dojo",disabled:c||!n,onClick:()=>void g(),children:t.jsx(Yo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-7 p-5 md:p-8",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"What your agents learn"}),t.jsx("p",{className:"mt-2 max-w-3xl text-lead leading-relaxed text-muted-foreground",children:"Review the notes, skills and workflow drafts your current agents keep for later runs. Open an agent to enable learning, inspect its changes or review pending items."}),t.jsx("p",{className:"mt-2 max-w-3xl text-small leading-relaxed text-muted-foreground",children:"Imported sessions are history, not learning runs. Learning comes from agentic runs started through this server; notes you add yourself are included too."})]}),n===void 0?t.jsx("p",{role:"status",className:"text-lead text-muted-foreground",children:"Checking learning support…"}):n===null?t.jsxs("div",{className:"border bg-card p-5",children:[t.jsx("h3",{className:"font-semibold",children:"This server does not expose learning"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"Use a server version with learning support to inspect or enable it here."}),t.jsx("a",{href:"#/agents",className:"mt-4 inline-block text-lead text-primary-text underline underline-offset-4",children:"Connected agents"})]}):t.jsxs(t.Fragment,{children:[n==="off"&&t.jsx("p",{role:"status",className:"border border-warning/40 bg-warning/5 p-4 text-lead text-warning-text",children:"This server has learning turned off. Saved learning remains available; new runs will learn only after the server's learning setting is on."}),a&&t.jsxs(t.Fragment,{children:[t.jsx(Kt,{problem:a,onRetry:()=>void g(),className:""}),s&&t.jsx("p",{className:"text-small text-warning-text",children:"Showing the last read. Refresh to update these counts."})]}),!s&&!a?t.jsx(Fn,{label:"Loading Learning Dojo",rows:4}):s&&t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"grid grid-cols-2 gap-3 xl:grid-cols-5",children:xC.map(({label:k,of:$})=>t.jsxs("div",{"aria-label":k,className:"border bg-card p-4",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:k}),t.jsx("dd",{className:"mt-3 font-mono text-display",children:vC(h,$)})]},k))}),t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:[v," of ",h.length," agent histories read. Counts show active items; pending notes, skills and drafts are counted under review. + means a minimum from incomplete data; — means not reported.",y?" Last-read totals include saved histories that may have changed; they are not current minimums.":u&&!c?` Updated ${mt(u)}.`:"",c?" Loading learning…":""]}),s.length?t.jsx("section",{"aria-label":"Agents in Dojo",className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:s.map(k=>t.jsx(zD,{row:k,server:n},k.agent.agent_id))}):t.jsxs("div",{className:"border px-6 py-10 text-center",children:[t.jsx("h3",{className:"font-semibold",children:"No agents yet"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"Create an agent, then open its Learning tab to let its runs build on what they learn."}),t.jsx("a",{className:"mt-4 inline-block text-lead text-primary-text underline underline-offset-4",href:"#/agents/new",children:"Build an agent"}),t.jsx("span",{className:"mx-3 text-muted-foreground",children:"·"}),t.jsx("a",{className:"text-lead text-primary-text underline underline-offset-4",href:"#/agents",children:"Import existing agents"})]}),h.length>0&&t.jsxs("section",{className:"overflow-hidden border","aria-label":"Recent learning changes",children:[t.jsxs("header",{className:"border-b px-5 py-4",children:[t.jsx("h3",{className:"text-lead font-semibold",children:"Recent learning changes"}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"Latest reported changes from the histories read above. Each agent's Learning tab has its full history and run outcomes."})]}),j.length?t.jsx("ul",{className:"divide-y",children:j.map(({agent:k,change:$})=>t.jsx("li",{children:t.jsxs("a",{href:"run"in $.by?`#/runs/${encodeURIComponent($.by.run)}`:gC(k),className:"flex items-start gap-3 px-5 py-4 hover:bg-accent",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block text-lead",children:$.reason||"Learning updated"}),t.jsxs("span",{className:"mt-1 block text-small text-muted-foreground",children:[k.definition.name||k.agent_id," · ","run"in $.by?"From a run":"Edited by you"," · ",mt($.at)]})]}),t.jsx(cr,{className:"mt-1 size-3.5 shrink-0","aria-hidden":!0})]})},`${k.agent_id}:${$.commit}`))}):t.jsx("p",{className:"px-5 py-7 text-lead text-muted-foreground",children:c?"Loading learning changes…":v<h.length?"No changes in the histories available so far.":"No saved learning changes yet."})]})]})]})]})]})}function zD({row:e,server:n}){const{agent:s,view:r,error:a}=e,i=s.kind==="agentic",c=s.definition.learning===!0||s.definition.learning==="notes";return t.jsxs("article",{className:"flex min-w-0 flex-col border bg-card p-5",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words text-lead font-semibold",children:s.definition.name||s.agent_id}),t.jsx(je,{tone:i&&c&&n==="on"?"success":"plain",children:i?n==="off"&&c?"Paused by server":c?"Learning on":"Learning off":"Workflow"})]}),i?t.jsxs(t.Fragment,{children:[a&&t.jsxs("div",{role:"alert",className:"mt-4 text-small text-destructive-text",children:[t.jsx("p",{children:e.unavailable?"Learning unavailable for this agent.":a.title}),t.jsxs("p",{className:"mt-1",children:[a.why," ",a.said]})]}),r?t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"mt-5 grid grid-cols-2 gap-x-4 gap-y-3",children:xC.map(({label:d,of:u})=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:d}),t.jsx("dd",{className:"mt-1 font-mono text-lead",children:vC([e],u)})]},d))}),e.stale&&t.jsx("p",{role:"status",className:"mt-3 text-small text-warning-text",children:"Showing the last read. Refresh to update this history."}),t.jsxs("p",{className:"mt-4 text-small text-muted-foreground",children:[rx(r.counts.merged)," runs kept learning · ",rx(Object.values(r.counts.dropped).reduce((d,u)=>d+u,0))," kept nothing"]}),e.noteIssue&&t.jsxs("p",{className:"mt-3 text-small text-warning-text",children:["Some note counts are incomplete. ",e.noteIssue]}),(!r.skills||!r.workflows)&&t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"This server does not report every learned-file category."})]}):!a&&t.jsx("p",{role:"status",className:"mt-4 text-lead text-muted-foreground",children:"Loading learning…"})]}):t.jsx("p",{className:"mt-4 text-lead text-muted-foreground",children:"Workflow runs do not learn. Enable learning on an agentic agent."}),t.jsxs("a",{className:"mt-5 inline-flex items-center gap-2 self-start text-small font-semibold text-primary-text hover:underline hover:underline-offset-4",href:i?gC(s):on(s.agent_id),children:[i?"Open learning":"View agent",t.jsx(cr,{className:"size-3.5","aria-hidden":!0})]})]})}const DD=140,FD=32,UD=40,WD=60;function Kv({value:e,name:n,note:s,blurb:r,description:a,tag:i,why:c,alert:d,on:u,disabled:f,warn:x,onToggle:b}){const[g,h]=p.useState(!1),v=p.useRef(null),y=p.useRef(null),j=p.useRef(null),k=p.useRef(null),$=Hu(v,"width",g,n),S=Hu(y,"height",g,a),N=Hu(j,"width",g,i),_=Hu(k,"width",g,d),E=$??n.length>FD,O=!!a&&(S??a.length>DD),A=!!i&&(N??i.length>UD),I=!!d&&(_??d.length>WD),M=!!c&&(c!==i||A),R=!!a&&(!!r||O)||M||I||E,P=(W,Y)=>!g&&W&&Y?W:void 0,D=W=>{W.preventDefault(),W.stopPropagation(),h(Y=>!Y)};return t.jsxs("label",{"data-tool-card":e,className:ae("flex w-full min-w-0 flex-col border px-3 py-2.5 font-mono text-body",g?"min-h-36":"h-36 overflow-hidden",u&&"border-foreground",x&&"border-warning/60",f?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("input",{type:"checkbox",value:e,checked:u,disabled:f,onChange:b,className:"shrink-0 accent-primary"}),t.jsx("span",{ref:v,title:P(n,E),className:ae("min-w-0",g?"[overflow-wrap:anywhere]":"truncate"),children:n}),s&&t.jsx("span",{className:"shrink-0 font-sans text-label text-muted-foreground",children:s})]}),r?t.jsx("span",{"data-line":!0,className:"mt-1 truncate font-sans text-small text-muted-foreground",children:r}):a&&!g?t.jsx("span",{ref:y,"data-line":!0,className:"mt-1 line-clamp-3 font-sans text-label text-muted-foreground [overflow-wrap:anywhere]",title:P(a,O),children:a}):null,i&&t.jsx("span",{ref:j,"data-tag":!0,title:P(c,M),className:"mt-1 max-w-full self-start truncate border px-1.5 text-micro text-muted-foreground",children:i}),d&&!g&&t.jsx("span",{ref:k,className:"mt-1 truncate font-sans text-label text-warning-text",role:"alert",title:P(d,I),children:d}),g&&t.jsxs("span",{"data-more":!0,className:"mt-2 min-w-0 space-y-1 font-sans text-label text-muted-foreground",children:[a&&t.jsx("span",{className:"block whitespace-pre-wrap [overflow-wrap:anywhere]",children:a}),c&&c!==a&&t.jsx("span",{className:"block [overflow-wrap:anywhere]",children:c}),d&&t.jsx("span",{className:"block text-warning-text [overflow-wrap:anywhere]",role:"alert",children:d})]}),R&&t.jsx("button",{type:"button",onClick:D,"aria-expanded":g,className:"mt-auto self-start pt-1 font-sans text-label underline underline-offset-2 hover:text-foreground",children:g?"Less":"More"})]})}function Hu(e,n,s,r){const[a,i]=p.useState(null);return p.useLayoutEffect(()=>{const c=e.current;if(s||!c)return;const d=()=>{(n==="width"?c.clientWidth>0:c.clientHeight>0)&&i(n==="width"?c.scrollWidth>c.clientWidth+1:c.scrollHeight>c.clientHeight+1)};d();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return u==null||u.observe(c),()=>u==null?void 0:u.disconnect()},[e,n,s,r]),a}function HD({servers:e,tools:n,harness:s,harnesses:r,onChange:a,onRetry:i}){const c=h=>a(n.includes(h)?n.filter(v=>v!==h):[...n,h]),d=n.filter(h=>Bo(h)),u=!r||r.includes(s),f=(h,v,y,j,k,$)=>{const S=n.includes(h),N=(!u||!!k)&&!S,_=j??k??(S&&!u?`Won't run on ${s}.`:void 0);return t.jsx("li",{className:"min-w-0",children:t.jsx(Kv,{value:h,name:v,note:$,description:y,alert:_,on:S,disabled:N,warn:!!j,onToggle:()=>c(h)})},h)},x=h=>t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:h}),b=!u&&t.jsxs("p",{className:"text-small text-warning-text",children:[s," doesn't run MCP tools on this server",r!=null&&r.length?`: ${r.join(" and ")} do`:"","."]});if(e==="failed")return t.jsxs("div",{className:"mt-4 space-y-2",children:[t.jsxs("p",{className:"font-mono text-small text-warning-text",role:"alert",children:["The MCP servers could not be read."," ",i&&t.jsx(B,{type:"button",onClick:i,size:"xs",className:"ml-1",children:"Retry"})]}),d.length>0&&x(d.map(h=>f(h,h,"Can't check right now whether its server still lists it.")))]});if(!e)return d.length?t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:"Reading the MCP servers..."}):null;const g=VL(n,e);return!e.length&&!g.length?t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"No MCP server is saved: add one in Settings → MCP servers to grant its tools."}):t.jsxs("div",{className:"mt-4 space-y-4",children:[b,e.map(h=>t.jsxs("section",{"aria-label":`MCP server ${h.name}`,children:[t.jsxs("p",{className:"caps mb-2 text-label font-semibold text-muted-foreground",children:[h.name," · MCP server"]}),x(h.tools.map(v=>{var y;return f(E2(h.name,v.name),v.name,[v.title,v.description].filter(Boolean).join(": ")||void 0,void 0,KL(v,s)??(v.permission==="deny"?qv:void 0),(y=h.not_metered)!=null&&y.includes(v.name)?"not metered":void 0)}))]},h.name)),g.length>0&&t.jsxs("section",{"aria-label":"MCP grants that can't run",children:[t.jsx("p",{className:"caps mb-2 text-label font-semibold text-warning-text",children:"Granted, but not on a saved server"}),x(g.map(h=>f(h.grant,h.grant,void 0,h.why)))]})]})}const BD="[a-z][a-z0-9-]{0,31}",yC="[A-Za-z0-9_-]{1,64}",GD="[a-z0-9][a-z0-9.-]{0,63}",qD="[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}",KD=`[a-z][a-z0-9_-]{0,63}(?:\\.${yC})?`,VD="mcp:",YD="monid:",r0="*",QD=new RegExp(`^mcp:(${BD})/(\\*|${yC})$`),JD=new RegExp(`^monid:(${GD})/(\\*|${qD})$`),XD=new RegExp(`^${KD}$`);function ZD(e){if(il(e)){const s=JD.exec(e);return s?s[2]===r0?{kind:"monid-provider",provider:s[1]}:{kind:"monid",provider:s[1],endpoint:s[2]}:void 0}if(!tF(e))return XD.test(e)?{kind:"plain",name:e}:void 0;const n=QD.exec(e);if(n)return n[2]===r0?{kind:"mcp-server",server:n[1]}:{kind:"mcp",server:n[1],tool:n[2]}}const il=e=>e.startsWith(YD),eF=e=>`${e} is not a monid endpoint's name: monid:<provider>/<endpoint> or monid:<provider>/*, the provider's slug (lowercase letters, digits, . and -) and the endpoint's path without its first / (letters, digits and -._:{}/), as monid lists them.`,tF=e=>e.startsWith(VD);function bC(e){const n=ZD(e);return(n==null?void 0:n.kind)==="monid"?{provider:n.provider,endpoint:n.endpoint}:(n==null?void 0:n.kind)==="monid-provider"?{provider:n.provider,endpoint:null}:void 0}const nF=e=>bC(e)?void 0:eF(e);function sF(e){const n=e.trim();return!n||il(n)?n:`monid:${n}`}function wC(e){return new Map(e.flatMap((n,s)=>il(n)?[[`definition.tools[${s}]`,n]]:[]))}function rF(e,n){const s=wC(n),r=[],a=[];for(const i of e){const c=s.get(i.field);c?r.push({grant:c,warning:i}):a.push(i)}return{monid:r,rest:a}}const oF=e=>{const n=bC(e);return n?n.endpoint===null?`Every endpoint of ${n.provider} that monid prices per call, as monid lists them when the agent is saved.`:`${n.provider}'s /${n.endpoint}, priced and pinned when the agent is saved.`:"Not a monid endpoint's name: the save refuses it. Untick it."};function aF({tools:e,listed:n=[],notes:s=[],refused:r=[],onChange:a}){const[i,c]=p.useState(""),[d,u]=p.useState(void 0),f=[...new Set([...n,...e].filter(il))],x=g=>a(e.includes(g)?e.filter(h=>h!==g):[...e,g]),b=()=>{const g=sF(i);if(!g)return;const h=nF(g);u(h),!h&&(c(""),e.includes(g)||a([...e,g]))};return t.jsxs("section",{"aria-label":"monid endpoints",className:"mt-4 space-y-2",children:[t.jsx("p",{className:"caps text-label font-semibold text-muted-foreground",children:"monid · paid endpoints"}),f.length>0&&t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:f.map(g=>{const h=r.filter(v=>v.grant===g);return t.jsx("li",{className:"min-w-0",children:t.jsx(Kv,{value:g,name:g,description:oF(g),alert:h.length?"The save was refused here: see below.":void 0,warn:h.length>0,on:e.includes(g),disabled:!1,onToggle:()=>x(g)})},g)})}),t.jsxs("form",{className:"flex flex-wrap items-start gap-2",onSubmit:g=>{g.preventDefault(),b()},children:[t.jsx(Ie,{"aria-label":"monid grant",value:i,onChange:g=>{c(g.target.value),u(void 0)},"aria-invalid":d?!0:void 0,placeholder:"monid:<provider>/<endpoint> or monid:<provider>/*",className:"min-w-0 flex-[1_1_18rem]",spellCheck:!1,autoCapitalize:"off",autoComplete:"off"}),t.jsxs(B,{type:"submit",size:"sm",className:"h-control-md",disabled:!i.trim(),children:[t.jsx(dl,{"aria-hidden":!0})," Grant"]})]}),d&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:d}),t.jsx("p",{className:"text-small text-muted-foreground",children:"A grant is priced and pinned when the agent is saved, from what monid lists then. monid's key is set in Settings → Tool keys."}),r.length>0&&t.jsx("ul",{className:"space-y-1 font-mono text-small text-destructive-text",role:"alert","aria-label":"monid grants refused",children:r.map((g,h)=>t.jsx("li",{children:g.message},`${g.grant}:${h}`))}),s.length>0&&t.jsx("ul",{className:"space-y-1 font-mono text-small text-warning-text",role:"status","aria-label":"monid save warnings",children:s.map((g,h)=>t.jsx("li",{children:g.message},`${g.grant}:${h}`))})]})}const iF=e=>e.offered&&(e.kind==="none"||e.providers.some(n=>n.ready)),lF=e=>{var n;return e.why??((n=e.providers.find(s=>!s.ready))==null?void 0:n.why)};function cF(e,n){var a;if(e.kind==="none")return{kind:"none"};const r=((n==null?void 0:n.kind)===e.kind&&e.providers.some(i=>i.ready&&i.id===n.provider)?n.provider:void 0)??((a=e.providers.find(i=>i.ready))==null?void 0:a.id);return r?{kind:e.kind,provider:r}:{kind:e.kind}}const dF=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},Vv="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",Yv=new Set(["sandbox","desktop","phone"]),uF=e=>e.charAt(0).toUpperCase()+e.slice(1);function fF({kinds:e,value:n,onChange:s,error:r,warning:a}){const i=e.find(c=>c.kind===n.kind);return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Kind"}),t.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-5",role:"radiogroup","aria-label":"Kind",children:e.map(c=>{const d=iF(c),u=d?void 0:lF(c),f=c.providers.filter(x=>x.ready).map(x=>x.name).join(", ");return t.jsxs("div",{"data-kind":c.kind,className:ae("border px-4 py-3",n.kind===c.kind?"border-foreground":"border-border",!d&&"opacity-60"),children:[t.jsxs("label",{className:ae("flex items-start gap-3",d?"cursor-pointer":"cursor-not-allowed"),children:[t.jsx("input",{type:"radio",name:"computer-kind",value:c.kind,checked:n.kind===c.kind,disabled:!d&&n.kind!==c.kind,onChange:()=>s(cF(c,n)),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-lead font-semibold",children:uF(c.kind)}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:d?c.kind==="none"?"The run's folder only":f:"Not available here"})]})]}),u&&t.jsxs("p",{className:"mt-2 break-words text-small text-muted-foreground",children:[u," ",t.jsx("a",{href:"#/settings/computers",className:"underline underline-offset-2 hover:text-foreground",children:"Computers settings"})]})]},c.kind)})}),i&&i.kind!=="none"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mb-2 mt-5 caps text-small font-semibold",children:"Provider"}),t.jsx("ul",{className:"border",role:"radiogroup","aria-label":"Provider",children:i.providers.map(c=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("label",{className:ae("flex items-start gap-3 px-4 py-2.5",c.ready?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"computer-provider",value:c.id,checked:n.provider===c.id,disabled:!c.ready&&n.provider!==c.id,onChange:()=>s({kind:i.kind,provider:c.id}),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("span",{className:"text-body font-semibold",children:c.name}),c.metered&&t.jsx("span",{className:"caps text-label text-muted-foreground",children:"Metered"})]}),c.metered&&Yv.has(i.kind)&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:Vv}),!c.ready&&c.why&&t.jsx("span",{className:"mt-0.5 block text-small",children:c.why})]})]})},c.id))})]}),i&&i.tools.length>0&&t.jsxs("p",{className:"mt-4 border bg-muted/40 px-4 py-2.5 text-small","aria-label":"Tools this computer adds",children:["This computer adds these tools: ",t.jsx("span",{className:"font-mono",children:i.tools.join(", ")})]}),r&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:r}),a&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:a})]})}function mF({value:e,saved:n,places:s,tools:r,picked:a,onChange:i,error:c,warning:d}){var N;const u=e??ad(n),f=(u??Cv(!1,a,s)).mode,x=(N=s.boxes.find(_=>_.available))==null?void 0:N.id,b=(u==null?void 0:u.mode)==="sandbox"?u.box:x,g=!x&&f!=="sandbox",h=new Set(r.filter(_=>_.sandbox_only).map(_=>_.name)),[v,y]=p.useState([]),j=()=>{const _=a.filter(E=>h.has(E));y(_),i({place:{mode:"runner"},..._.length?{tools:a.filter(E=>!h.has(E))}:{}})},k=_=>{y([]),_&&i({place:{mode:"sandbox",box:_}})},$=_=>_.map(E=>E.charAt(0).toUpperCase()+E.slice(1)).join(" and "),S=(_,E,O,A,I=!1)=>t.jsxs("label",{className:ae("flex items-start gap-3 border px-4 py-3",f===_?"border-foreground":"border-border",I?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsx("input",{type:"radio",name:"place",value:_,checked:f===_,disabled:I,onChange:A,className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"block text-lead font-semibold",children:E}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:O})]})]});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Where it runs"}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"radiogroup","aria-label":"Where it runs",children:[S("runner","On the server","No box and no shell: its files stay in the run's folder on the server.",j),S("sandbox","In a sandbox","Its file and shell tools run in a box; its keys stay on the server.",()=>k(b),g)]}),g&&t.jsxs("div",{className:"mt-3 border px-4 py-3 text-small text-muted-foreground",role:"status",children:[t.jsx("p",{children:"No box is set up on this server, so this agent runs on the server."}),t.jsx("ul",{className:"mt-1",children:s.boxes.map(_=>t.jsxs("li",{children:[t.jsx("span",{className:"font-mono",children:_.id}),_.reason?`: ${_.reason}`:""]},_.id))})]}),f==="sandbox"&&t.jsx("ul",{className:"mt-3 border","aria-label":"Box",children:s.boxes.map(_=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("label",{className:ae("flex items-start gap-3 px-4 py-2.5",_.available?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"box",value:_.id,checked:b===_.id,disabled:!_.available&&b!==_.id,onChange:()=>k(_.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-mono text-body",children:_.id}),!_.available&&_.reason&&t.jsx("span",{className:"mt-0.5 block text-small",children:_.reason})]})]})},_.id))}),f==="runner"&&v.length>0&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:[$(v)," ",v.length===1?"runs":"run"," only in a sandbox, so ",v.length===1?"it's":"they're"," turned off for this agent."]}),c&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:d})]})}function jC(e,n,s=n.map(r=>r.name)){return[...new Set([...s.filter(a=>e.some(i=>i.name===a)||n.some(i=>i.name===a)),...n.map(a=>a.name),...e.map(a=>a.name)])].map(a=>{const i=e.find(d=>d.name===a),c=n.find(d=>d.name===a);return{name:a,...i?{choice:i}:{},...c?{gate:c}:{}}})}function ox({setting:e,label:n="Pinned",also:s=!1}){return e!=null&&e.pin_broken?t.jsx("p",{className:"max-w-[640px] text-small text-warning-text",role:"note",children:CD}):e!=null&&e.pin?t.jsxs("p",{className:"max-w-[640px] text-small text-muted-foreground",role:"note",children:[t.jsxs("span",{className:"text-foreground",children:[n,":"]})," ",ND(e.pin),". ",SD,s?" This server pins it too; both hold.":""]}):null}const o0={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."]},hF=({effect:e})=>t.jsx("span",{"data-effect":e,children:t.jsx(je,{tone:o0[e][0],title:o0[e][1],children:e})}),pF="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function Qv({label:e,rows:n,settings:s,fallbackOf:r,permissionFallbackOf:a=$=>$.default_permission,resolvesOf:i,issues:c,busy:d=!1,refused:u=()=>!1,locked:f=!1,unattended:x=!1,noteOf:b,labelOf:g,detailOf:h,effectOf:v,confirmAllowOf:y=()=>!1,fallbackWordOf:j,onEdit:k}){const[$,S]=p.useState(null),N=p.useRef(null),_=p.useRef(null);p.useEffect(()=>{var D,W;if($!==null||d||N.current===null)return;const P=`${N.current} permission`;N.current=null,(W=[...((D=_.current)==null?void 0:D.querySelectorAll("button[aria-label]"))??[]].find(Y=>Y.getAttribute("aria-label")===P))==null||W.focus()},[$,d]);const E=P=>{N.current=P,S(null)},O=n.some(P=>P.choice),A=n.some(P=>P.gate),I=n.some(P=>{var D;return((D=P.gate)==null?void 0:D.ask_needs)==="password"}),M=["Tool",...A?["Permission"]:[],...O?["Provider","Resolves to"]:[]],R=t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"—"});return t.jsxs(t.Fragment,{children:[I&&t.jsx("p",{className:"mb-2 text-small text-warning-text",children:pF}),t.jsx("div",{ref:_,className:"relative overflow-x-auto",children:t.jsxs("table",{"aria-label":e,className:"w-full border text-left",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b",children:[M.map(P=>t.jsx("th",{className:"caps px-3 py-2 text-label font-semibold text-muted-foreground",children:P},P)),t.jsx("th",{children:t.jsx("span",{className:"sr-only",children:"Reset"})})]})}),t.jsx("tbody",{children:n.map(({name:P,choice:D,gate:W})=>{var pe,me,ke;const Y=D?r(D):"",H=(pe=s[P])==null?void 0:pe.provider,q=D!==void 0&&H!==void 0&&H!==Y,F=q?H:Y,G=$e=>k(J=>yD(J,P,$e,Y)),U=W?a(W):"allow",z=(me=s[P])==null?void 0:me.permission,Q=W!==void 0&&z!==void 0&&z!==U,K=Q?z:U,Z=W!==void 0&&u(P,K),de=Z&&f,re=de?"deny":K,fe=$e=>k(J=>bD(J,P,$e,U)),ve=v==null?void 0:v(P),Ee=(j==null?void 0:j(P))??"default",ue=h==null?void 0:h(P);return t.jsxs(p.Fragment,{children:[t.jsxs("tr",{"data-tool":P,"data-set":q||Q?"":void 0,className:"border-b align-top last:border-b-0",children:[t.jsxs("td",{className:"px-3 py-2.5 font-mono text-body",children:[t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[(g==null?void 0:g(P))??P,ve&&t.jsx(hF,{effect:ve})]}),ue?t.jsx("span",{"data-tool-detail":!0,className:"mt-0.5 block text-small text-muted-foreground",children:ue}):null]}),A&&t.jsx("td",{className:"px-3 py-2",children:W?t.jsxs(t.Fragment,{children:[t.jsx(At,{small:!0,label:`${P} permission`,value:re,disabled:d||de,onChange:$e=>{const J=$e;J==="allow"&&J!==re&&y(P)?S(P):fe(J)},className:ae(j?"w-48":"w-36",Q&&"border-primary text-primary"),options:W.permissions.map($e=>({value:$e,label:`${$e}${$e===U?` (${Ee})`:""}`,...$e==="ask"&&W.ask_needs==="password"&&!x?{disabled:!0,title:"No one can approve a call here: it takes the owner's password sign-in."}:{}}))}),Q&&!de&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",U,Ee==="default"?"":` (${Ee})`]}),Z&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:qv}),re==="deny"&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:pD}),re==="ask"&&x&&!Z&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),re==="ask"&&W.ask_needs==="password"&&!x&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Each call is refused: no one can approve it here."})]}):R}),O&&t.jsx("td",{className:"px-3 py-2",children:D?t.jsxs(t.Fragment,{children:[t.jsx(At,{small:!0,label:`${P} provider`,value:F,disabled:d,onChange:$e=>G($e),className:ae("w-56 max-w-full",q&&"border-primary text-primary"),options:D.providers.map($e=>({value:$e,label:`${If($e,P)}${$e===Y?" (default)":""}`}))}),s0(F,P)&&t.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:s0(F,P)}),q&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",If(Y,P)]})]}):R}),O&&t.jsx("td",{className:"px-3 py-2.5",children:D?i(D,F):R}),t.jsx("td",{className:"px-2 py-2 text-right",children:q&&t.jsx(B,{size:"sm",variant:"ghost",disabled:d,"aria-label":`Reset ${P} to its default`,onClick:()=>G(void 0),children:"Reset"})})]}),$===P&&t.jsx("tr",{children:t.jsx("td",{colSpan:M.length+1,className:"px-3 pb-2.5",children:t.jsx(gF,{name:P,keep:re==="ask"?"Keep asking":"Cancel",busy:d,onAllow:()=>{d||(E(P),fe("allow"))},onKeep:()=>E(P)})})}),b!=null&&b(P)?t.jsx("tr",{"data-note":P,children:t.jsx("td",{colSpan:M.length+1,className:"px-3 pb-2.5",children:b(P)})}):null,(ke=c[P])!=null&&ke.length?t.jsx("tr",{children:t.jsx("td",{colSpan:M.length+1,className:"px-3 pb-2.5",children:c[P].map($e=>t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:$e},$e))})}):null]},P)})})]})})]})}function gF({name:e,keep:n,busy:s,onAllow:r,onKeep:a}){const i=p.useRef(null);return p.useEffect(()=>{var c;(c=i.current)==null||c.focus()},[]),t.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e} without asking?`,onKeyDown:c=>{c.key==="Escape"&&(c.stopPropagation(),a())},className:"flex flex-wrap items-center gap-3 border border-destructive/50 bg-card px-3 py-2.5",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Allow a destructive tool?"})," Its server marks ",t.jsx("span",{className:"break-all font-mono",children:e})," as one that may delete or overwrite: every call would run with no one asked."]}),t.jsx(B,{ref:i,type:"button",size:"sm",variant:"ghost",onClick:a,children:n}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",disabled:s,onClick:r,children:"Allow without asking"})]})}function ax({value:e,prefix:n,tool:s}){const r=fC(e,s);return t.jsxs("span",{className:ae("block font-mono text-small",r.unavailable?"text-warning-text":"text-muted-foreground"),children:[n,r.text]})}const xF=({choice:e,harnesses:n=[]})=>t.jsx(t.Fragment,{children:uD.map(s=>{const r=n.find(a=>a.id===s&&!a.available);return r?t.jsxs("span",{title:r.reason,className:"block font-mono text-small text-muted-foreground opacity-60",children:[s,": not offered here"]},s):t.jsx(ax,{value:e.resolves[s],prefix:`${s}: `,tool:e.name},s)})});function vF({agent:e,harness:n,model:s,tools:r,choices:a,gates:i=[],mcpServers:c,serverSettings:d,focus:u,callTools:f,value:x,issues:b,unattended:g=!1,onChange:h}){const v=new Set(r),y=a.filter(R=>v.has(R.name)||!R.available),j=i.some(R=>R.ask_needs==="password"),k=R=>{var P;return(P=e==null?void 0:e.tools)==null?void 0:P.find(D=>D.name===R)},$=R=>{var D;const P=Bo(R);return P?(D=c==null?void 0:c.find(W=>W.name===P.server))==null?void 0:D.tools.find(W=>W.name===P.tool):void 0},S=R=>{var D;const P=Bo(R);return P?(D=x[`mcp:${P.server}/*`])==null?void 0:D.permission:void 0},N=f?f.flatMap(R=>i.filter(P=>P.name===R)):[...new Set(r)].flatMap(R=>{var W;const P=i.find(Y=>Y.name===R);if(P)return[P];const D=k(R)??$(R);return!((W=D==null?void 0:D.permissions)!=null&&W.length)||!D.default_permission?[]:[{name:R,permission:D.permission??D.default_permission,default_permission:D.default_permission,permissions:D.permissions,...j&&D.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),_=jC(y,N,[...i.map(R=>R.name),...a.map(R=>R.name)]),E=p.useRef(null);if(p.useEffect(()=>{var D,W;if(!u)return;const R=`${u} permission`,P=[...((D=E.current)==null?void 0:D.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(Y=>Y.getAttribute("aria-label")===R);(W=P==null?void 0:P.scrollIntoView)==null||W.call(P,{block:"center"}),P==null||P.focus()},[]),!_.length)return null;const O=(e==null?void 0:e.definition.tool_settings)??{},A=g!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:I,rest:M}=hC(b,"definition.tool_settings",_.map(R=>R.name));return t.jsxs("section",{"aria-label":"Tool settings",ref:E,children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Tool settings"})}),t.jsxs("p",{className:"-mt-1 mb-2 text-small text-muted-foreground",children:["Each of these tools takes this server's setting (its default here) unless it is changed here. ",f?"A call node can't wait for an approval: a tool set to ask stops the run from starting. Set it to allow.":g?"Never ask is on: a tool on ask runs without waiting for you. A tool set to deny still holds.":"A tool on ask makes the run wait for your approval at each call."]}),t.jsx(Qv,{label:"This agent's tool settings",unattended:g,rows:_,settings:x,fallbackOf:R=>R.provider,issues:I,onEdit:R=>h(R(x)),effectOf:R=>{var P;return(P=$(R))==null?void 0:P.effect},confirmAllowOf:R=>{var P;return((P=$(R))==null?void 0:P.effect)==="destructive"},noteOf:R=>{const P=x[R],D=d==null?void 0:d[R],W=!!(P!=null&&P.pin||P!=null&&P.pin_broken);return!W&&!(D!=null&&D.pin)&&!(D!=null&&D.pin_broken)?null:t.jsxs(t.Fragment,{children:[W&&t.jsx(ox,{setting:P,label:"Pinned for this agent",also:!!(D!=null&&D.pin)}),(!W||(D==null?void 0:D.pin_broken))&&t.jsx(ox,{setting:D,label:"Pinned on this server"})]})},refused:R=>dC(R,i,e==null?void 0:e.tools,c),locked:!0,permissionFallbackOf:R=>{var P;return S(R.name)??((P=k(R.name))==null?void 0:P.default_permission)??R.permission},resolvesOf:R=>{var H,q,F,G,U,z;const P=(((H=x[R.name])==null?void 0:H.provider)??null)!==(((q=O[R.name])==null?void 0:q.provider)??null)||(((F=x[R.name])==null?void 0:F.permission)??null)!==(((G=O[R.name])==null?void 0:G.permission)??null)||A,D=(U=e==null?void 0:e.tools)==null?void 0:U.find(Q=>Q.name===R.name),W=D&&D.provider===(((z=x[R.name])==null?void 0:z.provider)??R.provider)?D.resolved:void 0,Y=(s??"")===((e==null?void 0:e.definition.model)??"");return!P&&n===((e==null?void 0:e.definition.harness)??"pi")&&Y&&W?t.jsx(ax,{value:W,prefix:`${n}: `,tool:R.name}):!P&&!O[R.name]&&!s?t.jsx(ax,{value:R.resolves[n],prefix:`${n}: `,tool:R.name}):t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),M.map(R=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:R},R))]})}const Bu=20,yF=400;function bF(e,n,s,r,a){const[i,c]=p.useState(null),[d,u]=p.useState(0),f=(r??[]).join(",");p.useEffect(()=>{if(!a||!s||i==="unsupported")return;const b=new AbortController,g=setTimeout(()=>{a({workflow:n,...r?{tools:r}:{}},b.signal).then(h=>{b.signal.aborted||c({text:e,check:h})},h=>{b.signal.aborted||((h==null?void 0:h.status)===404||(h==null?void 0:h.status)===405?c("unsupported"):c({text:e,failed:(h==null?void 0:h.message)||`the server answered ${(h==null?void 0:h.status)??"nothing"}`}))})},yF);return()=>{clearTimeout(g),b.abort()}},[e,s,f,a,d]);const x=()=>{c(null),u(b=>b+1)};return i==="unsupported"||!a?{mode:"lint",retry:x}:i&&i.text===e?"failed"in i?{mode:"failed",failed:i.failed,retry:x}:{mode:"server",check:i.check,retry:x}:{mode:"pending",retry:x}}function a0({text:e,onText:n,base:s,baseLabel:r,serverIssues:a,readOnly:i=!1,validate:c,tools:d}){var Y;const u=p.useRef(null),f=p.useRef(null),[x,b]=p.useState(0),g=p.useMemo(()=>VM(e),[e]),h=p.useRef(null);g.ok&&(h.current={value:g.value,spans:g.spans});const v=(Y=h.current)==null?void 0:Y.value,y=p.useMemo(()=>sl(v),[v]),j=p.useMemo(()=>s===void 0?null:sl(s),[s]),k=p.useMemo(()=>j?HS(j,y):null,[j,y]),$=bF(e,g.ok?g.value:void 0,g.ok,d,i?void 0:c),S=p.useMemo(()=>g.ok&&!i?XM(g.value):[],[g,i]),N=p.useMemo(()=>$.mode!=="server"?S:[...$.check.issues.map(H=>({path:H.path,message:H.message,severity:"error"})),...$.check.warnings.map(H=>typeof H=="string"?{path:"",message:H,severity:"warning"}:{path:H.path??"",message:H.message,severity:"warning"})],[$.mode,$.mode==="server"?$.check:null,S]),_=g.ok?ZM(g.spans,y.nodes.map(H=>H.path),x):null,E=p.useMemo(()=>({meta:od(v,y),diff:k?{added:k.added.map(H=>H.path),edited:[...k.changed,...k.rewritten].map(H=>H.next),moved:k.moved.map(H=>H.next),removed:k.removed.map(({label:H,kind:q})=>({label:H,kind:q}))}:void 0,selected:_?{path:_}:null}),[v,y,k,_]),O=e.split(`
|
|
642
|
+
`).length,A=H=>YM(e,H),I=[];g.ok||I.push({...A(g.error.offset),message:`JSON: ${g.error.message}`,severity:"error",offset:g.error.offset});for(const H of N){const q=g.ok?dk(g.spans,H.path):void 0,F=(q==null?void 0:q.start)??0;I.push({...A(F),message:H.message,severity:H.severity,offset:F,path:H.path})}for(const H of[...a??[]].reverse()){const q=H.path&&g.ok?dk(g.spans,H.path):void 0;I.unshift({...q?A(q.start):{line:0,col:0},message:`Server: ${H.message}`,severity:"error",offset:(q==null?void 0:q.start)??-1})}const M=new Map;for(const H of I)H.line&&M.get(H.line)!=="error"&&M.set(H.line,H.severity);const R=(H,q=H)=>{const F=u.current;!F||H<0||(F.focus(),F.setSelectionRange(H,q),F.scrollTop=Math.max(0,(A(H).line-4)*Bu),b(H))};p.useEffect(()=>{const H=g.ok?g.spans.get("/root"):void 0;H&&u.current&&(u.current.scrollTop=Math.max(0,(A(H.start).line-2)*Bu))},[]);const P=k?k.edges.added.length+k.edges.removed.length:0,D=k?k.added.length+k.changed.length+k.rewritten.length+k.removed.length+k.moved.length+P:0,W=I.filter(H=>H.severity==="error").length;return t.jsxs("div",{className:"grid min-h-0 grid-cols-1 border xl:grid-cols-[minmax(420px,5fr)_7fr]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col border-b xl:border-b-0 xl:border-r",children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"workflow.json"}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[O," lines"]}),t.jsx("span",{className:"flex-1"}),i?t.jsx("span",{className:"caps text-label text-muted-foreground",children:"Read-only"}):t.jsxs(t.Fragment,{children:[$.mode==="failed"&&g.ok?t.jsxs("span",{className:"font-mono text-label text-warning-text",title:$.failed,children:["server check failed, showing local checks ",t.jsx(B,{type:"button",onClick:$.retry,size:"xs",className:"ml-1",children:"Retry"})]}):$.mode!=="lint"&&g.ok&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:$.mode==="pending"?"checking...":"checked by the server"}),W?t.jsxs("span",{className:"caps inline-flex items-center gap-1 text-label text-destructive-text",children:[t.jsx(Ji,{className:"size-3.5","aria-hidden":!0})," ",W," ",W===1?"problem":"problems"]}):t.jsx("span",{className:"caps text-label text-success-text",children:$.mode==="server"?"Valid":"Valid shape"})]})]}),t.jsxs("div",{className:"relative flex h-[560px] min-h-0 xl:h-[calc(100vh-390px)] xl:min-h-[440px]",children:[t.jsx("div",{ref:f,"aria-hidden":!0,className:"w-12 shrink-0 select-none overflow-hidden border-r bg-card py-3 text-right font-mono text-label text-muted-foreground",style:{lineHeight:`${Bu}px`},children:Array.from({length:O},(H,q)=>t.jsx("div",{className:ae("pr-2",M.get(q+1)==="error"&&"bg-destructive/15 text-destructive-text",M.get(q+1)==="warning"&&"bg-warning/15 text-warning-text"),children:q+1},q))}),t.jsx(ln,{bare:!0,ref:u,value:e,readOnly:i,spellCheck:!1,wrap:"off","aria-label":"Workflow JSON",onChange:H=>{i||n(H.target.value),b(H.target.selectionStart)},onSelect:H=>b(H.target.selectionStart),onScroll:H=>{f.current&&(f.current.scrollTop=H.target.scrollTop)},onKeyDown:H=>{if(H.key!=="Tab"||i)return;H.preventDefault();const q=H.currentTarget,F=q.selectionStart,G=q.selectionEnd;n(`${e.slice(0,F)} ${e.slice(G)}`),requestAnimationFrame(()=>q.setSelectionRange(F+2,F+2))},className:"flex-1 resize-none overflow-auto bg-background px-3 py-3 text-small selection:bg-primary/[0.28] selection:text-foreground focus-visible:outline focus-visible:outline-focus focus-visible:-outline-offset-2 focus-visible:outline-ring",style:{lineHeight:`${Bu}px`,tabSize:2}})]}),!i&&t.jsxs("ul",{className:"max-h-48 min-h-[44px] overflow-auto border-t font-mono text-small","aria-label":"Problems",children:[I.length===0&&t.jsx("li",{className:"px-4 py-3 text-muted-foreground",children:$.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."}),I.map((H,q)=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>R(H.offset),className:"flex w-full items-start gap-2.5 border-b px-4 py-2 text-left hover:bg-accent",children:[H.severity==="error"?t.jsx(Ji,{className:"mt-0.5 size-3.5 shrink-0 text-destructive-text","aria-hidden":!0}):t.jsx(Gs,{className:"mt-0.5 size-3.5 shrink-0 text-warning-text","aria-hidden":!0}),t.jsx("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",children:H.line?`L${H.line}:${H.col}`:"—"}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:H.message})]})},q))]})]}),t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Mm(Uv(y))}),k&&(D?t.jsxs("span",{className:"font-mono text-label",children:[[k.added.length&&`${k.added.length} new`,k.changed.length+k.rewritten.length&&`${k.changed.length+k.rewritten.length} edited`,k.removed.length&&`${k.removed.length} removed`,k.moved.length&&`${k.moved.length} moved`,!k.moved.length&&P&&`${P} ${P===1?"connection":"connections"} changed`].filter(Boolean).join(" · ")," ",t.jsxs("span",{className:"text-muted-foreground",children:["against ",r??"the current revision"]})]}):t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Same as ",r??"the current revision"]})),t.jsx("span",{className:"flex-1"}),!g.ok&&h.current&&t.jsx("span",{className:"caps text-label text-warning-text",children:"Showing the last JSON that parsed"})]}),t.jsx("div",{className:ae("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]",!g.ok&&"opacity-60"),children:y.nodes.length?t.jsx(md,{graph:y,marks:E,label:"The workflow's graph",minScale:.55,onSelect:H=>{const q=g.ok?g.spans.get(`${H.path}/label`)??g.spans.get(H.path):void 0;q&&R(q.start,q.end)}}):t.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"No root node to draw yet."})}),t.jsx("div",{className:"border-t px-4 py-2",children:t.jsx(hd,{})})]})]})}const wF="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function kC(){return t.jsxs(t.Fragment,{children:["A run on Sonnet needs about $0.10 to take a few steps; under that it pauses before its next step (",t.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:wF,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let Ii=null;function Gu(e,n){return Ii?Ii({to:e,replay:n}):!1}function NC(e){const[n,s]=p.useState(null),r=p.useRef(location.hash);return p.useEffect(()=>{if(!e)return;const a=c=>c.to===r.current?!1:(s(c),!0);Ii=a;const i=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",i),()=>{Ii===a&&(Ii=null),window.removeEventListener("beforeunload",i)}},[e]),{asking:n!==null,stay:()=>s(null),leave:()=>{var a;if(n!==null){if(s(null),n.to===null){(a=n.replay)==null||a.call(n);return}if(Ii=null,!n.replay){location.hash=n.to;return}location.hash!==r.current?window.addEventListener("hashchange",n.replay,{once:!0}):n.replay()}}}}const SC="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",mg="custom",i0=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function jF(e,n){if((e==null?void 0:e.kind)!=="invalid")return null;const s=Object.entries(e.fields).filter(([r])=>r==="definition.workflow"||r.startsWith("definition.workflow/")).map(([r,a])=>({path:r.slice(19),message:a}));return s.length?s:n?[{path:"",message:e.message}]:null}function kF(e){var s;const n=(s=/^definition\.([a-z_]+)/.exec(e))==null?void 0:s[1];if(n){if(["name","description","instructions"].includes(n))return"context";if(["tools","tool_settings","approvals","skills"].includes(n))return"tools";if(["harness","thinking","model","max_cost_usd","learning"].includes(n))return"settings";if(["place","computer"].includes(n))return"computer";if(n==="workflow")return"workflow"}}const NF=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:Ga},{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:qa},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:hf},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:wN},{id:"history",label:"History",note:"Revisions and the current one",Icon:Kc}];function SF({agent:e,revisions:n=[],caps:s,onSave:r,onMakeCurrent:a,onArchive:i,onReload:c,onBack:d,step:u,problem:f=null,notice:x,draft:b,validate:g,providerChoices:h=[],permissionGates:v=[],focusTool:y,mcpServers:j=null,serverToolSettings:k,onRetryMcp:$}){var un,Wn,$s,Hn,_s,Ts,An;const S=!e,N=e==null?void 0:e.definition,_=Zn(N),E=!!(N!=null&&N.native)||!!_,[O,A]=p.useState(u??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),I=S?rg(s.places):void 0,[M,R]=p.useState({name:(N==null?void 0:N.name)??"",description:(N==null?void 0:N.description)??"",instructions:(N==null?void 0:N.instructions)??(S?PP:""),harness:(N==null?void 0:N.harness)??"pi",thinking:N==null?void 0:N.thinking,model:N==null?void 0:N.model,tools:S?og("pi",s.tools,I):(N==null?void 0:N.tools)??[],maxCostText:typeof(N==null?void 0:N.max_cost_usd)=="number"&&N.max_cost_usd>0?String(N.max_cost_usd):"",...I?{place:I}:{},...(e==null?void 0:e.kind)==="workflow"?{workflowText:b??JSON.stringify(N.workflow,null,2)}:{}}),[P,D]=p.useState(!1),[W,Y]=p.useState(!1),H=p.useRef(M);H.current=M;const[q,F]=p.useState(M),G=te=>{const{maxCostText:Oe,workflowText:ft,...Ot}=te,Vt=xk(Oe),Fe=i0(ft),ne={...Ot,maxCost:Vt.ok?Vt.value??0:Oe,...ft!==void 0?{workflowSent:Fe!==void 0?Fe:ft}:{}},ye=e?{...id(e,ne,"").definition}:{...ne};return delete ye.version,ye.tool_settings&&!Object.keys(ye.tool_settings).length&&delete ye.tool_settings,{...ye,tools:[...ye.tools??[]].sort(),approvals:te.approvals??(N==null?void 0:N.approvals)??"ask"}},U=!qi(G(M),G(q)),[z,Q]=p.useState([]),[K,Z]=p.useState(!1),de=s.tools.map(te=>`${te.name}:${te.available}:${(te.harnesses??[]).join("+")}`).join(","),re=JSON.stringify(rg(s.places)??null);p.useEffect(()=>{if(!S)return;const te=Oe=>{const ft=Oe.place??rg(s.places);return{...Oe,...ft?{place:ft}:{},...K?{}:{tools:og(Oe.harness??"pi",s.tools,ft)}}};R(te),F(te)},[de,re]);const[fe,ve]=p.useState(""),[Ee,ue]=p.useState(()=>((N==null?void 0:N.tools)??[]).filter(il)),[pe,me]=p.useState(!1),[ke,$e]=p.useState(!1),[J,Le]=p.useState(f),[qe,rt]=p.useState(null),vt=te=>{rt(null),A(te)},st=p.useRef(null),Se=wC(st.current??M.tools??[]),Be=(J==null?void 0:J.kind)==="invalid"?Object.entries(J.fields).flatMap(([te,Oe])=>{const ft=Se.get(te);return ft?[{grant:ft,message:Oe}]:[]}):[],he=te=>(J==null?void 0:J.kind)==="invalid"&&Object.entries(J.fields).filter(([Oe])=>!Se.has(Oe)&&(Oe===`definition.${te}`||Oe.startsWith(`definition.${te}[`)||Oe.startsWith(`definition.${te}.`))).map(([,Oe])=>Oe).join(" ")||void 0,{monid:Ve,rest:ct}=rF((e==null?void 0:e.warnings)??[],(N==null?void 0:N.tools)??[]),Me=te=>BP(ct,te).map(Oe=>Oe.message).join(" ")||void 0,ot=te=>{S&&ke||R(Oe=>({...Oe,...te}))},oe=p.useRef(null);p.useEffect(()=>{var te;((J==null?void 0:J.kind)==="invalid"||(J==null?void 0:J.kind)==="other")&&((te=oe.current)==null||te.focus())},[J]);const xe=(e==null?void 0:e.kind)==="workflow",Ae=S&&h2(M.harness),De=[...(un=M.name)!=null&&un.trim()?[]:["Give the agent a name to create it."],...!xe&&!Ae&&!((Wn=M.instructions)!=null&&Wn.trim())?["Write its instructions to create it."]:[]],ut=M.approvals??(N==null?void 0:N.approvals)??"ask",ee=WP(s.harnesses,S?{available:!!s.decisionProvider}:void 0),Re={mcpHarnesses:s.mcpHarnesses,workflow:xe},Qe=te=>{if(te.mode==="sandbox")return;const Oe=new Set(s.tools.filter(ft=>ft.sandbox_only).map(ft=>ft.name));Q(ft=>ft.filter(Ot=>!Oe.has(Ot)))},Ze=te=>{if(S&&!K){ot({harness:te,tools:og(te,s.tools,M.place)}),Q([]);return}const Oe=zP(te,M.tools??[],z,s.tools,Re);ot({harness:te,tools:Oe.tools}),Q(Oe.held)},at=n.find(te=>te.revision===(e==null?void 0:e.revision))??n.find(te=>te.current),Xe=NF.filter(te=>!(S&&te.id==="history")&&(te.id!=="workflow"||xe)&&!(Ae&&te.id==="tools")&&(te.id!=="computer"||!xe&&!Ae&&!!(s.computers||s.places))),pt=Xe.some(te=>te.id===O)?O:Xe[0].id,et=Xe.findIndex(te=>te.id===pt),kt=async()=>{if(!r)return;const te=M;st.current=M.tools??[],$e(!0);let Oe={...M,workflowText:void 0,maxCostText:void 0};if(!Ae){const Vt=xk(M.maxCostText);if(!Vt.ok){$e(!1),Le({kind:"invalid",message:Vt.message,fields:{"definition.max_cost_usd":Vt.message}});return}const Fe=typeof(N==null?void 0:N.max_cost_usd)=="number"&&N.max_cost_usd>0,ne=Vt.value??0;(ne!==0||Fe)&&(Oe={...Oe,max_cost_usd:ne})}if(xe)try{Oe={...Oe,workflow:JSON.parse(M.workflowText??"")}}catch(Vt){$e(!1),Le({kind:"invalid",message:`The workflow is not JSON: ${Vt.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${Vt.message}`}});return}const ft=await r(Oe,fe),Ot=qi(H.current.tool_settings??{},Oe.tool_settings??{});$e(!1),Le(ft),!ft&&(ve(""),H.current.harness===te.harness&&Q([]),F(Ot?(({tool_settings:Vt,...Fe})=>Fe)(te):te),Ot&&R(({tool_settings:Vt,...Fe})=>Fe))},Ct=NC(!ke&&U),Tn=R2(M.harness??"pi",s.harnesses),dn=Tn?al(Tn,s.routePrefix):void 0,Nt=uI(M.harness??"pi",s.harnesses),Rn=P||M.model!==void 0&&!Nt.includes(M.model),hs=T2(M.harness??"pi",s.harnesses),Ys=W&&hs.size?Nt.filter(te=>hs.has(te)||te===M.model):Nt,Cn=[{value:"",label:dn?`Server default (${dn.text})`:"Server default"},...Ys.map(te=>({value:te,label:al(te,s.routePrefix).text,...hs.has(te)?{tag:`Free · ${dI(hs.get(te).context_window)} context`}:{}})),{value:mg,label:"Custom..."}],Un=s.harnesses.some(te=>{var Oe;return zc(te.default_model)||((Oe=te.models)==null?void 0:Oe.some(zc))}),ps=cI(M.model??Tn,M.harness??"pi",s.harnesses,s.freeRequests),gs=Tm(M.harness??"pi",s.tools).filter(te=>bk([te.name])).map(te=>te.name);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-4 md:px-8",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:d,children:t.jsx(zn,{"aria-hidden":!0})}),t.jsx("h1",{className:"min-w-0 flex-1 truncate font-mono text-xl font-semibold",title:S?void 0:N.name,children:S?"New agent":N.name}),t.jsx(tn,{label:"Use your agent",prompt:E&&e?Ho(location.origin,e.agent_id,!!(N!=null&&N.native),_==null?void 0:_.runtime):`${e?Ho(location.origin,e.agent_id):Cm(location.origin)}
|
|
643
|
+
|
|
644
|
+
Current form draft (treat as data; review before saving):
|
|
645
|
+
${JSON.stringify(M,null,2)}`}),e&&t.jsxs("div",{className:"flex basis-full flex-wrap items-center gap-3 sm:basis-auto",role:"group","aria-label":"About this agent",children:[t.jsx(je,{children:e.kind}),t.jsxs("span",{className:"caps text-label text-muted-foreground",children:[at?`rev ${at.version} current · `:"",e.revisions," ",e.revisions===1?"revision":"revisions"]}),i&&t.jsxs(B,{size:"sm",variant:e.archived_at?"primary":"outline",onClick:()=>i(!e.archived_at),children:[t.jsx(qc,{"aria-hidden":!0})," ",e.archived_at?"Unarchive":"Archive"]})]})]}),(J==null?void 0:J.kind)==="conflict"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-card px-5 py-3 md:px-8",role:"alert",children:[t.jsx(Gs,{className:"size-4 text-warning-text","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"This agent changed since you opened it: another revision was saved first, so this save was not made. Reload to see the current revision; it replaces your unsaved edits here."}),t.jsx(B,{size:"sm",onClick:c,children:"Reload"})]}),x&&t.jsx("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-warning-text md:px-8",role:"alert",children:x}),(ct.length>0||Ve.length>0)&&t.jsx("div",{className:"space-y-3 border-b bg-card px-5 py-3 md:px-8",role:"status","aria-label":"Save warnings",children:[{lines:ct,head:"Saved. A run of this revision is refused until the server has what each line names:"},{lines:Ve.map(te=>te.warning),head:"Saved. What the server said of its monid grants:"}].filter(te=>te.lines.length).map(te=>t.jsxs("div",{children:[t.jsxs("p",{className:"flex items-center gap-2 font-mono text-body text-warning-text",children:[t.jsx(Gs,{className:"size-4 shrink-0","aria-hidden":!0})," ",te.head]}),t.jsx("ul",{className:"mt-2 space-y-1 font-mono text-small",children:te.lines.map((Oe,ft)=>{const Ot=Xe.find(Vt=>Vt.id===kF(Oe.field));return t.jsxs("li",{children:[Ot?t.jsx("button",{type:"button",title:Oe.field,onClick:()=>vt(Ot.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:Ot.label}):t.jsx("span",{className:"text-muted-foreground",children:Oe.field})," ",Oe.message]},`${Oe.field}:${ft}`)})})]},te.head))}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[t.jsx("ol",{className:ae("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",pt==="workflow"?"md:w-[76px]":"md:w-[240px]"),children:Xe.map((te,Oe)=>t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","aria-current":pt===te.id?"step":void 0,onClick:()=>vt(te.id),className:ae("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",pt===te.id?"border-l-foreground bg-foreground/5":"border-l-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{className:ae("inline-flex size-6 shrink-0 items-center justify-center border text-label font-semibold",pt===te.id?"border-foreground bg-foreground text-background":Oe<et?"border-border-strong":"border-border"),children:Oe<et?t.jsx(cl,{className:"size-3","aria-hidden":!0}):Oe+1}),t.jsxs("span",{className:ae("hidden min-w-0",pt!=="workflow"&&"md:block"),title:pt==="workflow"?te.label:void 0,children:[t.jsxs("span",{className:"caps flex items-center gap-1.5 text-small",children:[t.jsx(te.Icon,{className:"size-3.5","aria-hidden":!0})," ",te.label]}),t.jsx("span",{className:"mt-0.5 block text-label text-muted-foreground",children:te.note})]}),t.jsx("span",{className:"sr-only md:hidden",children:te.label})]})},te.id))}),t.jsxs("section",{className:"min-h-0 flex-1 overflow-auto px-5 py-6 md:px-10",children:[t.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Step ",et+1]}),t.jsx("h2",{className:"caps mb-6 border-b pb-4 text-prose font-semibold",children:Xe[et].label}),t.jsxs("fieldset",{disabled:S&&ke,className:"m-0 min-w-0 border-0 p-0",children:[pt==="context"&&t.jsxs("div",{className:"max-w-3xl space-y-6",children:[t.jsx(jt,{label:"Name",id:"agent-name",required:S,note:S?void 0:"Set when the agent was created; an edit keeps it.",error:he("name"),warning:Me("name"),children:t.jsx(Ie,{id:"agent-name",value:M.name,readOnly:!S,onChange:te=>ot({name:te.target.value}),placeholder:"e.g., Invoice checker"})}),t.jsx(jt,{label:"Description",id:"agent-description",optional:!0,note:S?void 0:"Set when the agent was created; an edit keeps it.",error:he("description"),warning:Me("description"),children:t.jsx(Ie,{id:"agent-description",value:M.description,readOnly:!S,onChange:te=>ot({description:te.target.value}),placeholder:S?"Short summary for the agent list":"No description"})}),Ae?t.jsx(jt,{group:!0,label:"Workflow",children:t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:M.harness===Nv?"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."})}):xe?t.jsx(jt,{group:!0,label:"Workflow",note:"This agent is a workflow. Edit its nodes in the Workflow step: the graph redraws as you type and the server checks it.",warning:Me("workflow"),children:t.jsxs(B,{size:"sm",onClick:()=>A("workflow"),children:[t.jsx(Ka,{"aria-hidden":!0})," Open the workflow"]})}):t.jsxs(jt,{group:pe?"heading":void 0,label:"Instructions",id:pe?void 0:"agent-instructions",required:!0,error:he("instructions"),warning:Me("instructions"),aside:t.jsx("span",{className:"flex",children:["Preview","Edit"].map(te=>t.jsx(B,{size:"xs",type:"button",onClick:()=>me(te==="Preview"),className:ae("caps border px-2.5 py-1 text-label",te==="Preview"===pe?"border-foreground bg-foreground text-background":"text-muted-foreground"),children:te},te))}),children:[pe?t.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:eo(M.instructions||"")}}):t.jsx(ln,{id:"agent-instructions",value:M.instructions,onChange:te=>ot({instructions:te.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:ae(CF,"resize-y leading-[1.7]")}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(M.instructions??"").length," characters"]})]})]}),pt==="workflow"&&t.jsx(a0,{text:M.workflowText??"",onText:te=>ot({workflowText:te}),base:xe?N.workflow:void 0,baseLabel:at?`rev ${at.version}`:void 0,validate:g,tools:M.tools,serverIssues:jF(J,xe)}),pt==="computer"&&!xe&&!Ae&&s.computers&&t.jsx("div",{className:"max-w-4xl space-y-8",children:t.jsx(fF,{kinds:s.computers,value:M.computer??(N==null?void 0:N.computer)??qg(M.place??{mode:"runner"}),onChange:te=>{const Oe=dF(te),ft=new Set(s.tools.filter(Ot=>Ot.sandbox_only).map(Ot=>Ot.name));ot({computer:te,place:Oe,...Oe.mode==="runner"?{tools:(M.tools??[]).filter(Ot=>!ft.has(Ot))}:{}}),Qe(Oe)},error:he("computer")??he("place"),warning:Me("computer")??Me("place")})}),pt==="computer"&&!xe&&!Ae&&!s.computers&&s.places&&t.jsx("div",{className:"max-w-3xl space-y-8",children:t.jsx(mF,{value:M.place,saved:N==null?void 0:N.place,places:s.places,tools:s.tools,picked:M.tools??[],onChange:te=>{ot({...te,...te.place?{computer:qg(te.place)}:{}}),te.place&&Qe(te.place)},error:he("computer")??he("place"),warning:Me("computer")??Me("place")})}),pt==="tools"&&t.jsxs("div",{className:"max-w-3xl space-y-6",children:[t.jsxs(jt,{group:!0,label:"Tools",note:"On by default: the tools this agent's harness runs on this server. Untick one to take it away.",error:he("tools"),warning:Me("tools"),children:[t.jsxs("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:[s.tools.filter(te=>{var Oe;return xe||!te.call_only||((Oe=M.tools)==null?void 0:Oe.includes(te.name))}).map(te=>{var St,Lt;const Oe=Kg(M.harness??"pi",te.name,s.tools,Re),ft=((St=M.tools)==null?void 0:St.includes(te.name))??!1,Ot=h.find(it=>it.name===te.name),Vt=(Lt=(M.tool_settings??(N==null?void 0:N.tool_settings)??{})[te.name])==null?void 0:Lt.provider,Fe=!!Ot&&Vt!==void 0&&Vt!==Ot.provider,ne=DP(te,M.place??ad(N==null?void 0:N.place)??Cv(xe,M.tools??[],s.places)),ye=dC(te.name,v,e==null?void 0:e.tools)?qv:te.call_only&&!xe?"Workflow-only: a workflow's call node runs it, not an agent":Oe?ne??(!te.available&&!Fe?(Ot==null?void 0:Ot.reason)??te.reason??`Needs ${(te.missing??[]).join(", ")}`:void 0):yk(M.harness??"pi",te.name,s.tools),We=ye?te.call_only&&!xe?"Workflow only":ne&&Oe&&ye===ne?"Sandbox-only":ye:void 0;return t.jsx("li",{className:"min-w-0",children:t.jsx(Kv,{value:te.name,name:te.name,blurb:te.blurb,description:te.summary,why:ye,tag:We,on:ft,disabled:!!ye&&!ft,onToggle:()=>{Z(!0),ot({tools:ft?M.tools.filter(it=>it!==te.name):[...M.tools??[],te.name]})}})},te.name)}),s.mcp&&!xe&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(HD,{servers:j,tools:M.tools??[],harness:M.harness??"pi",harnesses:s.mcpHarnesses,onRetry:$,onChange:te=>{Z(!0),ot({tools:te})}})}),!xe&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(aF,{tools:M.tools??[],listed:Ee,notes:Ve.map(({grant:te,warning:Oe})=>({grant:te,message:Oe.message})),refused:Be,onChange:te=>{ue(Oe=>[...new Set([...Oe,...te.filter(il)])]),Z(!0),ot({tools:te})}})})]}),!xe&&!bk(M.tools??[])&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["This agent can't reach the web: ",gs.length?`tick ${gs.join(" or ")} in Tools.`:`${M.harness??"pi"} runs no web tool on this server.`]})]}),t.jsx(vF,{agent:e,unattended:!xe&&ut==="never",harness:M.harness??"pi",model:M.model,tools:M.tools??[],choices:xe?[]:h,gates:v,mcpServers:Array.isArray(j)?j:void 0,serverSettings:k,focus:y,callTools:xe?fD(i0(M.workflowText)??(N==null?void 0:N.workflow)):void 0,value:M.tool_settings??(N==null?void 0:N.tool_settings)??{},issues:(J==null?void 0:J.kind)==="invalid"?J.fields:{},onChange:te=>!ke&&qi(te,(N==null?void 0:N.tool_settings)??{})?R(({tool_settings:Oe,...ft})=>ft):ot({tool_settings:te})}),!xe&&!Ae&&t.jsxs("fieldset",{"aria-label":"Approvals",className:"space-y-2",children:[t.jsx("legend",{className:"caps text-small font-semibold",children:"Approvals"}),[["ask","Ask me","A call whose permission is ask waits for your answer."],["never","Never ask (run unattended)","For an agent that runs on a trigger, with no one there to answer."]].map(([te,Oe,ft])=>t.jsxs("label",{className:ae("flex items-start gap-3 border px-3 py-2.5",ut===te&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"approvals",value:te,className:"mt-1 accent-primary",checked:ut===te,disabled:ke,onChange:()=>ot({approvals:te})}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:Oe}),t.jsx("span",{className:"block text-small text-muted-foreground",children:ft})]})]},te)),ut==="never"&&t.jsx("p",{className:"text-small text-warning-text",children:SC})]}),t.jsx(jt,{group:!0,label:"Skills",note:"Skill files are saved with each revision and kept as they are by an edit.",children:($s=N==null?void 0:N.skills)!=null&&$s.length?t.jsx("ul",{className:"border",children:N.skills.map(te=>t.jsx("li",{className:"border-b px-3 py-2 font-mono text-body last:border-b-0",children:te},te))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No skills."})})]}),pt==="settings"&&t.jsxs("div",{className:"max-w-3xl space-y-8",children:[!xe&&t.jsxs(jt,{group:"heading",label:"Harness",note:"What runtime runs this agent.",error:he("harness"),warning:Me("harness"),children:[t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,9rem),1fr))] gap-3",role:"radiogroup","aria-label":"Harness",children:ee.map(te=>{const Oe=t.jsxs(t.Fragment,{children:[t.jsx("input",{type:"radio",name:"harness",value:te.id,checked:M.harness===te.id,disabled:!te.available&&M.harness!==te.id,onChange:()=>Ze(te.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block break-words font-mono text-body font-semibold",children:te.label}),t.jsx("span",{className:"mt-0.5 block font-mono text-label text-muted-foreground",children:te.available?te.id:"Not available here"})]})]}),ft=ae("min-w-0 border px-4 py-3",M.harness===te.id?"border-foreground":"border-border");return te.available?t.jsx("label",{className:ae(ft,"flex cursor-pointer items-start gap-3"),children:Oe},te.id):t.jsxs("div",{className:ae(ft,"opacity-60"),children:[t.jsx("label",{className:"flex cursor-not-allowed items-start gap-3",children:Oe}),te.reason&&t.jsxs("details",{className:"mt-2 font-mono text-label text-muted-foreground",children:[t.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Why, and what to do"}),t.jsx("p",{className:"mt-1 break-words leading-[1.6]",children:te.reason})]})]},te.id)})}),z.length>0&&t.jsxs("div",{className:"mt-3 border px-3 py-2 font-mono text-small",role:"status","aria-label":"Tools this harness doesn't run",children:[t.jsxs("p",{className:"text-warning-text",children:[((Hn=ee.find(te=>te.id===M.harness))==null?void 0:Hn.label)??M.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."]}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:z.map(te=>t.jsxs("li",{children:[te,": ",t.jsx("span",{className:"text-muted-foreground",children:yk(M.harness??"pi",te,s.tools,s.mcpHarnesses)})]},te))})]})]}),!xe&&!Ae&&t.jsx(jt,{group:"heading",label:"Thinking",note:"How hard the model thinks before it answers.",error:he("thinking"),warning:Me("thinking"),children:t.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Thinking",children:s.thinking.map(te=>t.jsxs("label",{className:ae("caps cursor-pointer border px-3 py-2 text-small",M.thinking===te?"border-foreground":"text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:M.thinking===te,onChange:()=>ot({thinking:te})}),te]},te))})}),!Ae&&t.jsxs(jt,{label:"Model",id:"agent-model",optional:!0,note:dn?t.jsxs(t.Fragment,{children:["Empty uses the server's default (",t.jsx("span",{title:dn.title,children:dn.text}),")."]}):fI,error:he("model"),warning:Me("model"),children:[t.jsx(At,{id:"agent-model",label:"Model",className:"w-full",value:Rn?mg:M.model??"",options:Cn,onChange:te=>{if(te===mg){D(!0);return}D(!1),ot({model:te||void 0})}}),Rn&&t.jsx(Ie,{id:"agent-model-custom","aria-label":"Custom model",className:"mt-2",value:M.model??"",onChange:te=>{D(!0),ot({model:te.target.value||void 0})},placeholder:"provider/model"}),hs.size>0&&t.jsxs("label",{className:"mt-2 flex items-center gap-2 text-small text-muted-foreground",children:[t.jsx(jm,{checked:W,onChange:Y,label:"Free models only"})," Free models only (",hs.size,"): $0 a request; the provider limits requests per day."]})]}),!Ae&&t.jsx(jt,{label:"Default spend cap per run, $",id:"agent-max-cost",optional:!0,note:t.jsxs(t.Fragment,{children:["A run started without a cap of its own, and a trigger with none, stops at this spend. Empty means none.",Un&&t.jsx("span",{className:"mt-1 block",children:oI}),ps&&t.jsx("span",{className:"mt-1 block","data-note":"free-requests",children:ps})]}),hint:t.jsx(kC,{}),error:he("max_cost_usd"),warning:Me("max_cost_usd"),children:t.jsx(Ie,{id:"agent-max-cost",inputMode:"decimal",value:M.maxCostText??"",onChange:te=>ot({maxCostText:te.target.value}),placeholder:"e.g., 2.50"})}),!xe&&!Ae&&s.learning&&t.jsx(dz,{fields:M,onFields:ot,saved:N==null?void 0:N.learning,server:s.learning,error:he("learning"),warning:Me("learning")})]}),pt==="history"&&qe&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>rt(null),children:[t.jsx(zn,{"aria-hidden":!0})," Back to History"]}),t.jsxs("span",{className:"caps text-small",children:["rev ",qe.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:qe.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:mt(qe.created_at)}),t.jsx(B,{size:"sm",onClick:()=>a==null?void 0:a(qe.revision),disabled:!a,children:"Make current"})]}),t.jsx(a0,{readOnly:!0,text:JSON.stringify((_s=qe.definition)==null?void 0:_s.workflow,null,2),onText:()=>{},base:N.workflow,baseLabel:at?`rev ${at.version}, the current one`:"the current revision"})]}),pt==="history"&&!qe&&t.jsx("ul",{className:"max-w-3xl border",children:n.map(te=>{var Oe;return t.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsxs("span",{className:"caps w-14 text-small",children:["rev ",te.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:te.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:mt(te.created_at)}),xe&&!te.current&&((Oe=te.definition)==null?void 0:Oe.workflow)!==void 0&&t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>rt(te),"aria-label":`View rev ${te.version}`,children:[t.jsx(Tx,{"aria-hidden":!0})," View"]}),te.current?t.jsx(je,{tone:"success",children:"Current"}):t.jsx(B,{size:"sm",onClick:()=>a==null?void 0:a(te.revision),disabled:!a,children:"Make current"})]},te.revision)})})]})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center gap-3 border-t px-5 py-3 md:px-8",children:[t.jsxs(B,{size:"sm",variant:"ghost",disabled:et===0,onClick:()=>vt(Xe[et-1].id),children:[t.jsx(zn,{"aria-hidden":!0})," Previous"]}),pt!=="history"&&t.jsx(Ie,{value:fe,onChange:te=>ve(te.target.value),placeholder:S?"":"What changed (a note on this revision)","aria-label":"Revision note",className:ae("h-9 min-w-0 flex-1",S&&"invisible")}),pt==="history"&&t.jsx("span",{className:"flex-1"}),et<Xe.length-1&&t.jsxs(B,{size:"sm",onClick:()=>vt(Xe[et+1].id),children:["Next ",t.jsx(Ex,{"aria-hidden":!0})]}),!qe&&t.jsx(B,{ref:oe,size:"sm",variant:"solid",onClick:kt,disabled:!r||ke||!S&&!U||!((Ts=M.name)!=null&&Ts.trim())||!xe&&!Ae&&!((An=M.instructions)!=null&&An.trim()),children:S?ke?"Creating…":"Create":ke?"Saving…":U?"Save revision":at?`Saved · rev ${at.version}`:"Saved"}),S&&!ke&&!qe&&De.map(te=>t.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:te},te)),(J==null?void 0:J.kind)==="invalid"&&t.jsxs("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:["The server refused the save: ",J.message]}),(J==null?void 0:J.kind)==="other"&&t.jsx("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:J.message})]}),t.jsxs(nv,{open:Ct.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:Ct.leave,onCancel:Ct.stay,children:[S?"This new agent is not saved yet.":"Your changes to this agent are not saved."," Leave drops them; Stay keeps them here."]})]})}const CF="w-full border bg-background px-3 py-2.5 font-mono text-body focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring placeholder:text-muted-foreground focus:border-border-strong";function EF({agents:e,archived:n=!1,onArchivedChange:s,actions:r={},error:a,handoff:i,observations:c}){var x;const[d,u]=p.useState(""),f=(e??[]).filter(b=>`${b.definition.name} ${b.definition.description??""}`.toLowerCase().includes(d.toLowerCase()));return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-3 border-b px-5 py-2",children:[t.jsxs("h1",{className:"caps flex items-center gap-2 text-body font-semibold",children:[t.jsx($x,{className:"size-4","aria-hidden":!0}),n?"Archived agents":"Connected agents"]}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:[i,!n&&t.jsx(tn,{variant:"primary",label:"Build an agent",prompt:Cm(location.origin),playgroundHref:"#/playground?operation=create-agent"})]})]}),t.jsxs("div",{className:"p-5 md:p-6",children:[t.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[t.jsxs("label",{className:ae(Pc,"flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3"),children:[t.jsx(sm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Ie,{bare:!0,value:d,onChange:b=>u(b.target.value),placeholder:"Search agents by name or description...","aria-label":"Search agents",className:"h-full flex-1 max-sm:portrait:placeholder:text-transparent"})]}),t.jsxs(B,{size:"lg",variant:n?"primary":"outline","aria-pressed":n,onClick:()=>s==null?void 0:s(!n),children:[t.jsx(qc,{"aria-hidden":!0})," Archived"]})]}),a?t.jsx("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:a}):e?!f.length&&!((x=c==null?void 0:c.data)!=null&&x.sessions.length)?t.jsxs("div",{className:"border px-4 py-16 text-center",children:[t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:d?"No agent matches.":n?"No archived agents.":"No agents yet."}),!d&&!n&&t.jsx("a",{className:"mt-4 inline-block text-lead text-primary-text hover:underline",href:"#/agents/new",children:"Describe your agent or start from a template"})]}):t.jsxs(t.Fragment,{children:[!!f.length&&t.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[f.length," ",f.length===1?"agent":"agents"]}),t.jsx("ul",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 2xl:grid-cols-3",children:f.map(b=>t.jsx($F,{agent:b,actions:r},b.agent_id))})]}):t.jsx(Fn,{label:"Loading the agents",rows:6}),c&&t.jsx("div",{className:"mt-6",children:t.jsx(pv,{read:c,view:"cards",query:d})})]})]})}function $F({agent:e,actions:n}){var d;const s=e.kind==="workflow"?Ka:$x,r=!!e.archived_at,a=_v(e),i=Zn(e.definition),c=Of(e);return t.jsxs("li",{className:ae("flex flex-col border p-5 transition-colors hover:border-border-strong",r&&"opacity-70"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-start gap-2.5 text-left",onClick:()=>{var u;return(u=n.onOpen)==null?void 0:u.call(n,e.agent_id)},children:[t.jsx(s,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-base font-semibold",children:e.definition.name}),t.jsx(je,{children:e.kind}),e.kind==="agentic"&&t.jsx(je,{children:i?Ko(i.runtime):a?ld(a.runtime):e.definition.harness??"pi"}),a&&t.jsx(je,{tone:a.connected&&a.state==="ready"?"success":"warning",children:cd(a)}),r&&t.jsx(je,{tone:"muted",children:"Archived"})]}),t.jsx("span",{className:"mt-2 line-clamp-2 block text-lead leading-relaxed text-muted-foreground",children:e.definition.description||(e.kind==="workflow"?eP(e.definition.workflow):"No description.")})]})]}),a&&t.jsxs("p",{className:"mt-3 break-all font-mono text-small text-muted-foreground",children:[a.project," · ",a.machine_id]}),t.jsxs("div",{"data-testid":"agent-card-footer",className:"mt-auto flex min-w-0 flex-wrap items-start gap-x-2 gap-y-1 pt-5",children:[t.jsxs("div",{"data-testid":"agent-card-chips",className:"flex min-w-0 flex-auto flex-wrap items-center gap-x-2 gap-y-1.5 py-1.5",children:[t.jsxs(je,{className:"shrink-0 whitespace-nowrap",children:[e.revisions," ",e.revisions===1?"revision":"revisions"]}),e.runs&&t.jsxs(je,{className:"shrink-0 whitespace-nowrap",children:[e.runs.count," ",e.runs.count===1?"run":"runs",e.runs.live?` · ${e.runs.live} live`:""]}),c>0&&t.jsxs(B,{size:"xs",type:"button","aria-label":Hv(c),onClick:()=>{var u;return(u=n.onLearning)==null?void 0:u.call(n,e.agent_id)},className:"h-5 shrink-0 whitespace-nowrap border-warning/50 bg-warning/10 px-1.5 text-micro text-warning-text hover:bg-warning/20",children:["Learning · ",c]})]}),t.jsxs("div",{"data-testid":"agent-card-actions",className:"ml-auto flex min-w-0 max-w-full flex-wrap items-center justify-end gap-2",children:[!r&&t.jsx(tn,{compact:!0,compactIcon:t.jsx(Vo,{className:"size-3.5","aria-hidden":!0}),label:`Run ${e.definition.name}`,disabled:!!a&&(!a.connected||a.state!=="ready"||!a.capabilities.launch),prompt:kv(location.origin,e.agent_id,i==null?void 0:i.runtime),playgroundHref:i?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`}),t.jsx(tn,{compact:!0,compactIcon:t.jsx(Mx,{className:"size-3.5","aria-hidden":!0}),label:`Edit ${e.definition.name}`,prompt:Ho(location.origin,e.agent_id,!!a,i==null?void 0:i.runtime),playgroundHref:a||i?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),t.jsxs(B,{size:"sm",className:"gap-1 px-2",variant:"outline","aria-label":`Runs of ${e.definition.name}`,onClick:()=>{var u;return(u=n.onRuns)==null?void 0:u.call(n,e.agent_id)},children:[t.jsx(Kc,{"aria-hidden":!0}),((d=e.runs)==null?void 0:d.count)??0]}),t.jsx(B,{size:"icon",variant:"outline","aria-label":`${r?"Unarchive":"Archive"} ${e.definition.name}`,onClick:()=>{var u;return(u=n.onArchive)==null?void 0:u.call(n,e.agent_id,!r)},children:r?t.jsx(hN,{"aria-hidden":!0}):t.jsx(qc,{"aria-hidden":!0})})]})]})]})}function _F({v2:e}){const[n,s]=p.useState(null),[r,a]=p.useState(!1),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,x]=p.useState(""),[b,g]=p.useState("live"),[h,v]=p.useState(null),[y,j]=p.useState(!1),[k,$]=p.useState(!1),[S,N]=p.useState(null),_=p.useRef(!1),E=p.useRef(!1),O=p.useRef(0),A=p.useRef(!0),I=o5(),M=p.useCallback(async()=>{if(E.current)return;E.current=!0,a(!0);const W=O.current;try{const Y=await e.listConnectors();A.current&&W===O.current&&(s(Y.connectors),c(null))}catch(Y){A.current&&W===O.current&&c(Dt(Y))}finally{E.current=!1,A.current&&a(!1)}},[e]);p.useEffect(()=>{A.current=!0,queueMicrotask(()=>{A.current&&M()});const W=()=>{!document.hidden&&!_.current&&M()},Y=setInterval(W,15e3);return window.addEventListener("focus",W),document.addEventListener("visibilitychange",W),()=>{A.current=!1,O.current++,clearInterval(Y),window.removeEventListener("focus",W),document.removeEventListener("visibilitychange",W)}},[M]),p.useEffect(()=>{if(!h)return;const W=new Date(h.expires_at).getTime()-Date.now();if(W<=0){v(null),j(!0);return}const Y=setTimeout(()=>{v(null),j(!0)},W);return()=>clearTimeout(Y)},[h]);const R=async()=>{if(!_.current){_.current=!0,$(!0),u(null),j(!1);try{const W=await e.enrollConnector(f,{native_execution:b!=="history",history_import:b!=="live"});A.current&&v(W)}catch(W){A.current&&u(Dt(W))}finally{_.current=!1,A.current&&$(!1)}}},P=async()=>{if(!(_.current||!S)){_.current=!0,$(!0),u(null),O.current++;try{const{connector:W}=await e.revokeConnector(S.connector_id);A.current&&(s(Y=>(Y==null?void 0:Y.map(H=>H.connector_id===W.connector_id?W:H))??null),N(null))}catch(W){A.current&&u(Dt(W))}finally{_.current=!1,A.current&&$(!1)}}},D=async()=>{if(h)try{await navigator.clipboard.writeText(h.enrollment_token),I({title:"Connection code copied"})}catch{I({title:"Select and copy the connection code below",tone:"error"})}};return t.jsxs("div",{className:"space-y-6","aria-label":"Remote connections",children:[t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Connect another machine",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-lg font-semibold",children:"Connect remote agents"}),t.jsx(tn,{label:"Connect agent",prompt:bP(location.origin,b)})]}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect a Claude Code or Codex setup on your laptop, VM or container. Its files and native sign-in stay there."}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label",children:"Allow this connection to"}),t.jsx(Zc,{name:"remote-connection-intent",label:"Connection scope",size:"sm",value:b,onChange:g,options:[{value:"live",label:"Live agent",disabled:k},{value:"history",label:"History only",disabled:k},{value:"both",label:"Both",disabled:k}]}),t.jsxs("p",{className:"max-w-prose text-small text-muted-foreground",children:[b==="live"?"Run future jobs with your existing setup. Past conversations are not shared.":b==="history"?"Upload completed conversations from one selected project and runtime. No executing worker or self-improvement is enabled.":"Connect for future jobs and upload completed conversations from the selected project and runtime."," ",b!=="live"&&" Preview and approve the history on the source machine before upload. History is not used as learning."]})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(jt,{label:"Machine label",hint:"Optional. A name you recognize in this console.",children:t.jsx(Ie,{value:f,onChange:W=>x(W.target.value),placeholder:"My development machine",disabled:k,maxLength:120})})}),t.jsx(B,{size:"md",className:"self-start sm:mt-6",disabled:k,"aria-busy":k,onClick:()=>void R(),children:k&&!S?"Creating code…":"Create connection code"})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Use the code only in the connector's secure terminal prompt. It expires after ten minutes and can pair one machine. The coding-agent prompt contains no credentials."}),y&&t.jsx(xt,{tone:"warning",children:"The connection code expired. Create a new one if you have not connected the machine."}),d&&!S&&t.jsx(xt,{tone:"error",title:"Connection action failed",children:d})]}),t.jsxs("section",{className:"space-y-4","aria-label":"Connected remote machines",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-lg font-semibold",children:"Remote machines"}),t.jsx(B,{size:"sm",disabled:r||k,onClick:()=>void M(),"aria-busy":r,children:r?"Refreshing…":"Refresh"})]}),i&&t.jsx(xt,{tone:"error",title:"Remote machines could not be read",actions:t.jsx(B,{size:"xs",disabled:r,onClick:()=>void M(),children:"Try again"}),children:i}),n===null&&!i&&t.jsx("p",{className:"text-body text-muted-foreground",role:"status",children:"Loading remote machines…"}),(n==null?void 0:n.length)===0&&t.jsxs("div",{className:"border p-6",children:[t.jsx("h3",{className:"text-body font-semibold",children:"No remote machines connected"}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Use your coding agent to connect a source machine. It appears here once the connector has paired."})]}),n==null?void 0:n.map(W=>t.jsxs("article",{className:"space-y-4 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h3",{className:"mr-auto break-words text-body font-semibold",children:W.label||W.connector_id}),t.jsx(je,{tone:W.status==="revoked"||!W.capabilities.native_execution?"plain":W.status==="online"?"success":"warning",children:W.status==="revoked"?"Revoked":!W.capabilities.native_execution&&W.capabilities.history_import?"History only":W.status==="online"?"Online":"Offline"}),t.jsx(B,{size:"sm",disabled:k||W.status==="revoked",onClick:()=>{u(null),N(W)},children:"Revoke access"})]}),t.jsxs("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Last seen"}),t.jsx("dd",{children:W.last_seen_at?mt(W.last_seen_at):"Not yet seen"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Access"}),t.jsx("dd",{children:W.capabilities.native_execution?W.capabilities.history_import?"Live agents and history import":"Selected native agents and remote jobs":W.capabilities.history_import?"History import only":"Observation only"})]})]}),W.status==="offline"&&W.capabilities.native_execution&&t.jsx(xt,{tone:"warning",children:"The source worker is offline. Start it on the original machine to verify or run its agents. Saved agents and learning are preserved."}),W.targets.length>0?t.jsx("ul",{className:"divide-y border-t",children:W.targets.map(Y=>t.jsxs("li",{className:"space-y-2 pt-3 [&+li]:mt-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("span",{className:"min-w-0 flex-1 break-words text-body font-semibold",children:Y.name}),Y.agent_id?t.jsx("a",{href:on(Y.agent_id),className:"text-small underline underline-offset-2",children:"Open agent"}):t.jsx(je,{children:"Not imported"})]}),t.jsxs("p",{className:"break-words text-small text-muted-foreground",children:[ld(Y.runtime)," · ",Y.machine_id," · ",Y.history_only?"Imported history":W.status==="online"?Y.state==="ready"&&Y.capabilities.launch?"Ready to run":Y.state==="needs_attention"?"Needs attention":"Needs verification":"Worker unavailable"]}),Y.issues.length>0&&t.jsx("p",{className:"text-small text-warning-text",children:Y.issues.join("; ")})]},Y.target_id))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No native targets imported. Choose a project or agent with the source connector."})]},W.connector_id)),t.jsx("p",{className:"text-small text-muted-foreground",children:"Refreshes every 15 seconds while this page is visible. Open an agent to see its runs. Live connections also support Learning Dojo."})]}),t.jsx(wm,{open:h!==null,onClose:()=>v(null),title:"Connect this machine",description:"Enter this code directly in the source connector's secure prompt.",footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",onClick:()=>v(null),children:"Done"}),t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void D(),children:"Copy connection code"})]}),children:h&&t.jsxs(t.Fragment,{children:[t.jsx(jt,{label:"One-use connection code",hint:`Expires ${mt(h.expires_at)}. Closing this dialog clears it from the page.`,children:t.jsx(Ie,{readOnly:!0,value:h.enrollment_token,autoComplete:"off",spellCheck:!1,onFocus:W=>W.currentTarget.select()})}),t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"This grants a scoped connector credential. Keep it out of coding-agent prompts, URLs and source control. After pairing, the connector retains its own credential in its private state directory."})]})}),t.jsxs(nv,{open:S!==null,title:"Revoke this machine's access?",confirm:k?"Revoking…":"Revoke access",busy:k,onCancel:()=>{N(null),u(null)},onConfirm:()=>void P(),children:[t.jsxs("p",{children:[(S==null?void 0:S.label)||"This machine"," will no longer receive work or report activity. Agent definitions, past runs and saved learning stay available. Pair the machine again to restore access."]}),d&&t.jsx(xt,{tone:"error",className:"mt-3",children:d})]})]})}function Fm({variant:e}){return t.jsx(tn,{variant:e,label:"Connect agent",prompt:d2(location.origin),playgroundHref:"#/agents/connect",playgroundLabel:"Connection setup"})}function TF({v2:e,go:n,initialSource:s="server"}){const[r,a]=p.useState(s),[i,c]=p.useState(""),[d,u]=p.useState(null),[f,x]=p.useState([]),[b,g]=p.useState({}),[h,v]=p.useState(!1),[y,j]=p.useState(null),k=async()=>{v(!0),j(null),u(null),x([]),g({});try{u((await e.discoverNative(i.trim())).targets)}catch(S){j(Dt(S))}finally{v(!1)}},$=async()=>{v(!0),j(null);try{for(const S of f){if(b[S])continue;const{project:N,runtime:_,selector:E}=d[S],O=await e.connectNative({project:N,runtime:_,selector:E});g(A=>({...A,[S]:O.agent.agent_id}))}}catch(S){j(Dt(S))}finally{v(!1)}};return t.jsxs("section",{className:"mx-auto max-w-page space-y-6 p-5 md:p-8","aria-label":"Connect agent",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h1",{className:"mr-auto text-2xl font-semibold",children:"Connect agent"}),t.jsx(B,{size:"sm",onClick:()=>n("#/agents"),children:"Back to agents"})]}),t.jsx("p",{className:"max-w-prose text-lead text-muted-foreground",children:"Connect a native setup for new jobs, or observe an agent already running in its original application. Keep its instructions, tools, permissions and sign-in."}),t.jsx(xt,{title:"Choose how to connect",children:"Choose this server or another machine to launch jobs from an existing native setup. Choose an existing application to observe its activity and token usage through the CLI. This browser cannot scan your laptop."}),t.jsx(Zc,{name:"native-source",label:"Connection method",value:r,onChange:a,options:[{value:"server",label:"This server",disabled:h},{value:"remote",label:"Another machine",disabled:h},{value:"observe",label:"Existing application",disabled:h}]}),r==="observe"?t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Observe an existing application",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Observe your existing agent"}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect Claude Code or Codex running locally, in Docker, or on another server. Your application continues to start and control its jobs; AgentRun receives session activity, model and token usage."}),t.jsx("p",{className:"max-w-prose text-small text-muted-foreground",children:"The setup skill configures the existing CLI and telemetry collector for this server. Adding self-improvement requires the backend SDK integration."}),t.jsx(tn,{variant:"primary",label:"Connect agent",prompt:`${d2(location.origin)}
|
|
646
|
+
|
|
647
|
+
I selected observation of an existing application. Preserve its current job trigger and SDK configuration; do not import or launch a replacement agent.`})]}):r==="remote"?t.jsx(_F,{v2:e}):t.jsxs(t.Fragment,{children:[t.jsx(Fm,{}),t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Discover native setups",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Discover on this server"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"Read-only discovery checks configuration without launching a model or executing project hooks. No model API key is needed to connect."}),t.jsx(jt,{label:"Project on server host",hint:"Enter the absolute path on the machine running AgentRun.",children:t.jsx(Ie,{"aria-label":"Project on server host",value:i,onChange:S=>{c(S.target.value),u(null)},placeholder:"/path/to/project",disabled:h})}),t.jsx(B,{variant:d?"outline":"solid",size:"sm",disabled:h||!i.trim().startsWith("/"),"aria-busy":h,onClick:()=>void k(),children:h&&!d?"Discovering…":"Discover"})]}),y&&t.jsx(xt,{tone:"error",title:"Connection request failed",children:y}),d&&t.jsxs("section",{className:"space-y-4","aria-label":"Native targets",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Choose what to connect"}),!d.length&&t.jsx(xt,{children:"No supported native setup was found. Install Claude Code or Codex on this host and check the project path."}),d.map((S,N)=>t.jsxs("article",{className:"space-y-3 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsxs("label",{className:"flex min-w-0 flex-1 items-start gap-3",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",disabled:h||!!b[N],checked:f.includes(N),onChange:_=>x(E=>_.target.checked?[...E,N]:E.filter(O=>O!==N))}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("strong",{className:"break-words text-body",children:Ev(S.selector)}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:[ld(S.runtime)," · ",S.version??"Version unknown"]})]})]}),t.jsx(je,{tone:S.state==="ready"?"success":"warning",children:cd(S)})]}),t.jsx("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[["Project",S.project],["Machine",S.machine_id],["Model",S.model??"Native default · unknown until launch"],["Skills",S.skills.join(", ")||"None detected"],["MCP servers",S.mcp_servers.join(", ")||"None configured"],["Approval handling",S.capabilities.approval]].map(([_,E])=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"text-muted-foreground",children:_}),t.jsx("dd",{className:"break-all font-mono",children:E})]},_))}),S.selector.kind==="agent"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"This named agent runs as the main Claude Code session, rather than a delegated subagent."}),S.selector.kind==="profile"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"A Codex profile selects native configuration; it is not a custom subagent."}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native launch: ",S.capabilities.launch?"supported":"unavailable"," · Notes: ",S.capabilities.notes?"supported":"unavailable"," · Learned skills: ",S.capabilities.skills?"supported":"unavailable"," · Learned workflows: unavailable · Usage: ",S.capabilities.usage?"supported counters only; dollar cost may be unknown":"unavailable"]}),S.issues.length>0&&t.jsx(xt,{tone:"warning",children:t.jsx("ul",{children:S.issues.map(_=>t.jsx("li",{children:_},_))})}),b[N]&&t.jsxs("p",{role:"status",className:"text-body",children:["Connected. ",t.jsx("a",{href:on(b[N]),className:"underline underline-offset-2",children:"Open connected agent"})]})]},`${S.runtime}:${S.selector.kind}:${S.selector.name??""}`)),!!d.length&&t.jsx(B,{variant:"solid",size:"sm",onClick:()=>void $(),disabled:h||!f.some(S=>!b[S]),"aria-busy":h,children:h?"Connecting…":"Connect selected"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Connecting saves a reference and starts no run. Authentication and approval compatibility are checked separately on the connected agent's page."})]})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Your coding agent can also help import selected history. Past conversations stay historical; they do not become live jobs or AgentRun learning."})]})}const Ca=e=>e instanceof ze?HP(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function RF({v2:e,archived:n,go:s}){const r=hv(e,{active:!n}),[a,i]=p.useState(null),[c,d]=p.useState(null),u=p.useRef(0),f=()=>{const x=++u.current;i(null),d(null),Gr(b=>e.listAgents({archived:n,cursor:b}),b=>b.agents).then(b=>{x===u.current&&i(b)}).catch(b=>{x===u.current&&d(Ca(b).message)})};return p.useEffect(()=>{f();const x=()=>{document.hidden||f()};return window.addEventListener("focus",x),document.addEventListener("visibilitychange",x),()=>{window.removeEventListener("focus",x),document.removeEventListener("visibilitychange",x)}},[e,n]),t.jsx(EF,{observations:r,agents:a,archived:n,onArchivedChange:x=>s(x?"#/agents?archived=true":"#/agents"),error:c,handoff:t.jsx(Fm,{}),actions:{onOpen:x=>s(on(x)),onEdit:x=>s(on(x,"edit")),onNew:()=>s("#/agents/new"),onRuns:x=>s(on(x,"runs")),onLearning:x=>s(on(x,"learning")),onArchive:async(x,b)=>{try{await(b?e.archiveAgent(x):e.unarchiveAgent(x)),f()}catch(g){d(Ca(g).message)}}}})}function AF({v2:e,caps:n,choices:s=[],gates:r=[],focusTool:a,agentId:i,go:c}){const[d,u]=p.useState(null),[f,x]=p.useState(null),[b,g]=p.useState([]),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,$]=p.useState(0),[S,N]=p.useState(null),_=p.useRef(!0);p.useEffect(()=>(_.current=!0,()=>{_.current=!1}),[]);const E=F=>Gr(G=>e.listRevisions(F,G),G=>G.revisions),O=async()=>{if(i)try{const[{agent:F,etag:G},U]=await Promise.all([e.getAgent(i),E(i)]);u(F),x(G),g(U),N(F.revision),$(z=>z+1),j(null),v(null)}catch(F){d?j(`The agent could not be reloaded: ${Ca(F).message}`):v(Ca(F).message)}};p.useEffect(()=>{O()},[i]);const[A,I]=p.useState(null),M=p.useRef(0);p.useEffect(()=>{const F=++M.current;e.computers().then(G=>{F===M.current&&I(G.kinds)},()=>{F===M.current&&I(null)})},[e]);const[R,P]=p.useState(void 0);p.useEffect(()=>{let F=!0;return Promise.resolve().then(()=>e.toolSettings()).then(G=>{F&&P(G)},()=>{}),()=>{F=!1}},[e]);const[D,W]=p.useState(null),Y=p.useRef(0),H=()=>{if(!n.mcp)return;const F=++Y.current;W(null),e.listMcpServers().then(G=>{F===Y.current&&W(G.servers)},()=>{F===Y.current&&W("failed")})};p.useEffect(H,[e,n.mcp]);const q=async(F,G)=>{let U;try{U=await G()}catch(z){j(`${F} did not finish: ${Ca(z).message}`);return}u(U);try{const{agent:z,etag:Q}=await e.getAgent(U.agent_id),K=await E(U.agent_id).catch(()=>b);u(z),x(Q),g(K),z.revision!==S?(N(z.revision),$(Z=>Z+1),j(F==="Make current"?null:`${F} done. This agent changed since you opened it: the form now shows its current revision.`)):j(null)}catch(z){j(`${F} done. The page could not be refreshed: ${Ca(z).message}. Reload to see the current state.`)}};return i&&h&&!d?t.jsx("p",{className:"m-8 border p-4 font-mono text-body text-destructive-text",role:"alert",children:h}):i&&!d?t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading the agent..."}):d&&Zn(d.definition)?t.jsxs("section",{className:"space-y-4 p-5 md:p-8",children:[t.jsxs("h1",{className:"text-2xl font-semibold",children:["Edit ",d.definition.name]}),t.jsx(xt,{children:"This agent runs in your backend. Edit its application code with your coding agent; manage self-improving in its Learning tab."}),t.jsx(tn,{label:"Edit agent",prompt:Ho(location.origin,d.agent_id,!1,Zn(d.definition).runtime)}),t.jsx("a",{href:on(d.agent_id),className:"block text-body underline underline-offset-2",children:"Back to agent"})]}):t.jsx(SF,{agent:d,revisions:b,caps:{...n,computers:A},providerChoices:s,permissionGates:r,mcpServers:D,serverToolSettings:R,onRetryMcp:H,...a?{focusTool:a,step:"tools"}:{},notice:y,validate:e.validateWorkflow,onBack:()=>c("#/agents"),onReload:()=>{O(),H()},onSave:async(F,G)=>{let U;try{if(!d){const Z=await e.createAgent(LP({name:F.name??"",description:F.description??"",instructions:F.instructions??"",harness:F.harness??"pi",tools:F.tools??[],approvals:F.approvals,tool_settings:F.tool_settings,thinking:F.thinking,model:F.model,computer:F.computer,learning:F.learning,max_cost_usd:F.max_cost_usd,decisionProvider:n.decisionProvider}));return _.current&&c(on(Z.agent_id,Z.kind==="workflow"?"workflow":void 0)),null}const z=id(d,F,G);if(z.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:Q,...K}=z;U=await e.updateDefinition(d.agent_id,K,f)}catch(z){return Ca(z)}return u(U.agent),x(U.etag),N(U.agent.revision),e.getAgent(U.agent.agent_id).then(z=>u(Q=>Q&&Q.revision===z.agent.revision?{...Q,tools:z.agent.tools}:Q)).catch(()=>{}),E(U.agent.agent_id).then(g).catch(()=>j("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:F=>{d&&q("Make current",()=>e.setCurrent(d.agent_id,F))},onArchive:F=>{d&&q(F?"Archive":"Unarchive",()=>F?e.archiveAgent(d.agent_id):e.unarchiveAgent(d.agent_id))}},`${(d==null?void 0:d.agent_id)??"new"}:${k}`)}function no(e){if(!(typeof e!="string"||!e))try{const n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}const OF={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},MF={tool:1,model:1,mcp:2,computer:2,source:2};function zf(e,n){const s=e.split(":"),r=MF[s[0]];return(r===void 0?"":s.slice(r).join(":"))||n||s.slice(1).join(":")}const PF="Sign in with your password to change secrets.",LF="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",IF="Open the console from the server's link to change secrets.",Ja={sign_in:PF,no_accounts:LF,token:IF},CC=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,zF=e=>{var n;return((n=CC(e))==null?void 0:n.secrets_writable)===!0};function DF(e){const n=CC(e);return n!=null&&n.secrets_reason?n.secrets_reason:(n==null?void 0:n.accounts)===!1?"no_accounts":"sign_in"}function FF(e){const[n,s]=p.useState({writable:!1,whyNot:"sign_in"});return p.useEffect(()=>{let r=!0;return e.session().then(a=>{r&&s({writable:zF(a),whyNot:DF(a)})},()=>{}),()=>{r=!1}},[e]),n}const UF=2e3,ix=e=>e instanceof ze||e instanceof Error?e.message:String(e),Jv=({children:e="Manage usage"})=>t.jsx("a",{href:ZL,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:e});function WF(){return t.jsxs("div",{className:"space-y-1 text-body text-muted-foreground",children:[t.jsxs("p",{children:["Eligible usage in this app uses your ChatGPT plan. ",t.jsx(Jv,{})," in your ChatGPT settings."]}),t.jsx("p",{children:tI})]})}function lx({v2:e,view:n,onView:s,writable:r=!0,whyNot:a="sign_in",beside:i}){const[c,d]=p.useState(n),[u,f]=p.useState(null),[x,b]=p.useState(!1),[g,h]=p.useState(!1),[v,y]=p.useState(!1),j=p.useRef(null),k=p.useRef(0);p.useEffect(()=>{d(n)},[n]);const $=I=>{d(I),s==null||s(I)},S=c.state==="pending";p.useEffect(()=>{if(!S)return;let I=!1;const M=()=>{if(I||document.visibilityState!=="visible")return;I=!0;const D=++k.current;e.chatGPT().then(W=>{const Y=Tf(W);D===k.current&&Y&&Y.state!=="pending"&&$(Y)},()=>{}).finally(()=>{I=!1})},R=setInterval(M,UF),P=()=>{document.visibilityState==="visible"&&M()};return document.addEventListener("visibilitychange",P),()=>{clearInterval(R),document.removeEventListener("visibilitychange",P)}},[e,S]);const N=async()=>{f(null),b(!0);const I=window.open("","_blank");k.current++;try{const M=await e.startChatGPT();I&&(I.opener=null,I.location.href=M.authorize_url),$({state:"pending",authorize_url:M.authorize_url,expires_at:M.expires_at})}catch(M){I==null||I.close(),f(ix(M))}finally{b(!1)}},_=async I=>{var P;I.preventDefault();const M=(P=j.current)==null?void 0:P.value.trim();if(!M)return;f(null),b(!0),h(!0),k.current++;const R=D=>{j.current&&(j.current.value=""),y(!1),$(D)};try{R(await e.finishChatGPT(M))}catch(D){const W=await e.chatGPT().then(Tf,()=>null);(W==null?void 0:W.state)==="signed_in"?R(W):f(ix(D))}finally{b(!1),h(!1)}},E=u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u});if(c.state==="signed_in")return t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-body font-semibold",children:lI(c)}),t.jsx(WF,{})]});if(!r)return t.jsx("p",{className:"text-body",role:"status",children:Ja[a]});if(!S)return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"solid",disabled:x,onClick:()=>void N(),children:"Continue with ChatGPT"}),i]}),E]});const O=no(c.authorize_url),A=c.expires_at;return t.jsxs("form",{onSubmit:I=>void _(I),autoComplete:"off",className:"space-y-3 border bg-card p-4","aria-label":"Finish signing in with ChatGPT",children:[t.jsx("p",{className:"text-body",children:eI}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[O&&t.jsxs(t.Fragment,{children:[t.jsx("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Open the sign-in page"})," (a new tab)"]}),O&&A&&" · ",A&&`Waits until ${td(A)}`]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"The sign-in tab's address"}),t.jsx(Ie,{ref:j,name:"redirect_url",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:"127.0.0.1:1455/auth/callback?code=…",onInput:()=>{var I;return y(!!((I=j.current)!=null&&I.value.trim()))}})]}),E,t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!v||x,children:g?"Finishing…":"Finish sign-in"}),t.jsx(B,{type:"button",size:"sm",disabled:x,onClick:()=>void N(),children:"Start again"})]})]})}const HF={signed_in:{tone:"success",words:"signed in"},pending:{tone:"plain",words:"waiting"},expired:{tone:"warning",words:"expired"},signed_out:{tone:"plain",words:"not signed in"}};function BF({v2:e,writable:n,whyNot:s,onChange:r}){var y;const[a,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),[x,b]=p.useState(null);if(p.useEffect(()=>{let j=!0;return e.chatGPT().then(k=>{j&&i(Tf(k))},()=>{j&&i(null)}),()=>{j=!1}},[e]),!a)return null;const g=async()=>{b(null);let j;try{j=await e.signOutChatGPT()}catch(k){b(ix(k));return}d(!1),i({state:"signed_out"}),f(typeof j=="object"&&(j==null?void 0:j.revoked)===!1?{words:j.message||sI,settings:!0}:{words:nI}),r==null||r()},h=j=>{i(j),j.state!=="pending"&&f(null),j.state==="signed_in"&&(r==null||r())},v=HF[a.state];return t.jsxs("li",{"aria-label":"ChatGPT plan",className:"border-b p-4 last:border-b-0",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:"ChatGPT plan"}),t.jsx(je,{tone:v.tone,children:v.words})]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:$2}),t.jsxs("div",{className:"mt-3 space-y-3",children:[a.state==="expired"&&t.jsx("p",{className:"text-body text-warning-text",children:rI}),a.state==="signed_in"&&((y=a.models)!=null&&y.length)?t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Models: ",a.models.join(" · ")]}):null,t.jsx(lx,{v2:e,view:a,onView:h,writable:n,whyNot:s}),a.state==="signed_in"&&n&&!c&&t.jsx(B,{size:"sm",onClick:()=>{d(!0),b(null)},children:"Sign out"}),c&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Sign out of ChatGPT on this server? Codex and pi agents then need a key to run here."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void g(),children:"Sign out"}),t.jsx(B,{size:"sm",onClick:()=>d(!1),children:"Keep"})]}),x&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:x}),u&&t.jsxs("p",{className:"text-body",role:"status",children:[u.words,u.settings&&t.jsxs(t.Fragment,{children:[" ",t.jsx(Jv,{children:"ChatGPT settings"})]})]})]})]})}function GF(e){var n,s;return(n=e.needs)!=null&&n.includes("chatgpt")?{tone:"warning",text:"runs after Continue with ChatGPT"}:(s=e.needs)!=null&&s.includes("key")?{tone:"warning",text:"needs a key"}:e.available?{tone:"success",text:"ready"}:{tone:"warning",text:"not here"}}function EC({harnesses:e,routePrefix:n}){return e.length?t.jsxs("section",{"aria-label":"What runs here",children:[t.jsx("h2",{className:"caps mb-2 text-small font-semibold text-muted-foreground",children:"What runs here"}),t.jsx("ul",{className:"border",children:e.map(s=>{var a;const r=GF(s);return t.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-4 py-2.5 last:border-b-0",children:[t.jsx("span",{className:"font-mono text-body font-semibold",children:_f(s.id)}),t.jsx(je,{tone:r.tone,children:r.text}),s.available&&!((a=s.needs)!=null&&a.length)?s.default_model&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:al(s.default_model,n).text}):s.reason&&t.jsx("span",{className:"text-small text-muted-foreground",children:s.reason})]},s.id)})})]}):null}const qu=(e,n,s)=>{if(!/^\d{1,2}$/.test(e))return null;const r=Number(e);return r>=n&&r<=s?r:null};function qF(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const[s,r,a,i,c]=n,d=qu(s,0,59);if(d===null||i!=="*")return null;if(r==="*")return a==="*"&&c==="*"?{kind:"hourly",minute:d}:null;const u=qu(r,0,23);if(u===null)return null;const f={hour:u,minute:d};if(a==="*"&&c==="*")return{kind:"daily",at:f};if(a==="*"&&c==="1-5")return{kind:"weekdays",at:f};if(a==="*"){const x=qu(c,0,6);return x===null?null:{kind:"weekly",day:x,at:f}}if(c==="*"){const x=qu(a,1,31);return x===null?null:{kind:"monthly",date:x,at:f}}return null}function KF(e){if(e.kind==="hourly")return`${e.minute} * * * *`;const n=`${e.at.minute} ${e.at.hour}`;return e.kind==="daily"?`${n} * * *`:e.kind==="weekdays"?`${n} * * 1-5`:e.kind==="weekly"?`${n} * * ${e.day}`:`${n} ${e.date} * *`}function VF(e,n){const s=n&&"at"in n?n.at:{hour:9,minute:(n==null?void 0:n.kind)==="hourly"?n.minute:0};return e==="hourly"?{kind:e,minute:s.minute}:e==="weekly"?{kind:e,day:(n==null?void 0:n.kind)==="weekly"?n.day:1,at:s}:e==="monthly"?{kind:e,date:(n==null?void 0:n.kind)==="monthly"?n.date:1,at:s}:{kind:e,at:s}}const l0=e=>String(e).padStart(2,"0"),YF=e=>`${l0(e.hour)}:${l0(e.minute)}`;function QF(e){const n=/^(\d{2}):(\d{2})/.exec(e);if(!n)return null;const s=Number(n[1]),r=Number(n[2]);return s<=23&&r<=59?{hour:s,minute:r}:null}var hg={exports:{}},c0;function JF(){return c0||(c0=1,(function(e,n){(function(r,a){e.exports=a()})(globalThis,()=>(()=>{var s={6949(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.CronParser=void 0;var f=u(9515),x=(function(){function b(g,h,v){h===void 0&&(h=!0),v===void 0&&(v=!1),this.expression=g,this.dayOfWeekStartIndexZero=h,this.monthStartIndexZero=v}return b.prototype.parse=function(){var g,h,v=(g=this.expression)!==null&&g!==void 0?g:"";if(v==="@reboot")return h=["@reboot","","","","","",""],h;if(v.startsWith("@")){var y=this.parseSpecial(this.expression);h=this.extractParts(y)}else h=this.extractParts(this.expression);return this.normalize(h),this.validate(h),h},b.prototype.parseSpecial=function(g){var h={"@yearly":"0 0 1 JAN *","@annually":"0 0 1 JAN *","@monthly":"0 0 1 * *","@weekly":"0 0 * * SUN","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},v=h[g];if(!v)throw new Error("Unknown special expression.");return v},b.prototype.extractParts=function(g){if(!this.expression)throw new Error("cron expression is empty");for(var h=g.trim().split(/[ ]+/),v=0;v<h.length;v++)if(h[v].includes(",")){var y=h[v].split(",").map(function(k){return k.trim()}).filter(function(k){return k!==""}).map(function(k){return isNaN(Number(k))?k:Number(k)}).filter(function(k){return k!==null&&k!==""});y.length===0&&y.push("*"),y.sort(function(k,$){return k!==null&&$!==null?k-$:0}),h[v]=y.map(function(k){return k!==null?k.toString():""}).join(",")}if(h.length<5)throw new Error("Expression has only ".concat(h.length," part").concat(h.length==1?"":"s",". At least 5 parts are required."));if(h.length==5)h.unshift(""),h.push("");else if(h.length==6){var j=/\d{4}$/.test(h[5])||h[4]=="?"||h[2]=="?";j?h.unshift(""):h.push("")}else if(h.length>7)throw new Error("Expression has ".concat(h.length," parts; too many!"));return h},b.prototype.normalize=function(g){var h=this;g[3]=g[3].replace("?","*"),g[5]=g[5].replace("?","*"),g[2]=g[2].replace("?","*"),g[0].indexOf("0/")==0&&(g[0]=g[0].replace("0/","*/")),g[1].indexOf("0/")==0&&(g[1]=g[1].replace("0/","*/")),g[2].indexOf("0/")==0&&(g[2]=g[2].replace("0/","*/")),g[3].indexOf("1/")==0&&(g[3]=g[3].replace("1/","*/")),!this.monthStartIndexZero&&g[4].indexOf("1/")==0&&(g[4]=g[4].replace("1/","*/")),g[6].indexOf("1/")==0&&(g[6]=g[6].replace("1/","*/")),g[5]=g[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,function(E){var O=E.replace(/\D/,""),A=O;return h.dayOfWeekStartIndexZero?O=="7"&&(A="0"):A=(parseInt(O)-1).toString(),E.replace(O,A)}),g[5]=="L"&&(g[5]="6"),g[3]=="?"&&(g[3]="*");var v=/^\d{1,2}W[+-]\d{1,2}$/;if(g[3].indexOf("W")>-1&&(g[3].indexOf(",")>-1||/[-+]/.test(g[3]))&&!v.test(g[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 y={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var j in y)g[5]=g[5].replace(new RegExp(j,"gi"),y[j].toString());g[4]=g[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,function(E){var O=E.replace(/\D/,""),A=O;return h.monthStartIndexZero&&(A=(parseInt(O)+1).toString()),E.replace(O,A)});var k={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var $ in k)g[4]=g[4].replace(new RegExp($,"gi"),k[$].toString());g[0]=="0"&&(g[0]=""),!/\*|\-|\,|\//.test(g[2])&&(/\*|\//.test(g[1])||/\*|\//.test(g[0]))&&(g[2]+="-".concat(g[2]));for(var S=0;S<g.length;S++)if(g[S].indexOf(",")!=-1&&(g[S]=g[S].split(",").filter(function(E){return E!==""}).join(",")||"*"),g[S]=="*/1"&&(g[S]="*"),g[S].indexOf("/")>-1&&!/^\*|\-|\,/.test(g[S])){var N=null;switch(S){case 4:N="12";break;case 5:N="6";break;case 6:N="9999";break;default:N=null;break}if(N!==null){var _=g[S].split("/");g[S]="".concat(_[0],"-").concat(N,"/").concat(_[1])}}},b.prototype.validate=function(g){var h="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(g[0],h),this.validateOnlyExpectedCharactersFound(g[1],h),this.validateOnlyExpectedCharactersFound(g[2],h),this.validateOnlyExpectedCharactersFound(g[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(g[4],h),this.validateOnlyExpectedCharactersFound(g[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(g[6],h),this.validateAnyRanges(g)},b.prototype.validateAnyRanges=function(g){g.forEach(function(h){return f.default.stepRange(h)}),f.default.secondRange(g[0]),f.default.minuteRange(g[1]),f.default.hourRange(g[2]),f.default.dayOfMonthRange(g[3]),f.default.monthRange(g[4],this.monthStartIndexZero),f.default.dayOfWeekRange(g[5],this.dayOfWeekStartIndexZero)},b.prototype.validateOnlyExpectedCharactersFound=function(g,h){var v=g.match(new RegExp("[^".concat(h,"]+"),"gi"));if(v&&v.length)throw new Error("Expression contains invalid values: '".concat(v.toString(),"'"))},b})();d.CronParser=x},8333(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.ExpressionDescriptor=void 0;var f=u(1823),x=u(6949),b=(function(){function g(h,v){if(this.expression=h,this.options=v,this.expressionParts=new Array(5),!this.options.locale&&g.defaultLocale&&(this.options.locale=g.defaultLocale),!g.locales[this.options.locale]){var y=Object.keys(g.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(y,"'.")),this.options.locale=y}this.i18n=g.locales[this.options.locale],v.use24HourTimeFormat===void 0&&(v.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return g.toString=function(h,v){var y=v===void 0?{}:v,j=y.throwExceptionOnParseError,k=j===void 0?!0:j,$=y.verbose,S=$===void 0?!1:$,N=y.dayOfWeekStartIndexZero,_=N===void 0?!0:N,E=y.monthStartIndexZero,O=E===void 0?!1:E,A=y.use24HourTimeFormat,I=y.trimHoursLeadingZero,M=I===void 0?!1:I,R=y.locale,P=R===void 0?null:R,D=y.logicalAndDayFields,W=D===void 0?!1:D,Y={throwExceptionOnParseError:k,verbose:S,dayOfWeekStartIndexZero:_,monthStartIndexZero:O,use24HourTimeFormat:A,trimHoursLeadingZero:M,locale:P,logicalAndDayFields:W};Y.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var H=new g(h,Y);return H.getFullDescription()},g.initialize=function(h,v){v===void 0&&(v="en"),g.specialCharacters=["/","-",",","*"],g.defaultLocale=v,h.load(g.locales)},g.prototype.getFullDescription=function(){var h,v,y="";try{var j=new x.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=j.parse(),this.expressionParts[0]==="@reboot")return((v=(h=this.i18n).atReboot)===null||v===void 0?void 0:v.call(h))||"Run once, at startup";var k=this.getTimeOfDayDescription(),$=this.getDayOfMonthDescription(),S=this.getMonthDescription(),N=this.getDayOfWeekDescription(),_=this.getYearDescription();y+=k+$+N+S+_,y=this.transformVerbosity(y,!!this.options.verbose),y=y.charAt(0).toLocaleUpperCase()+y.substr(1)}catch(E){if(!this.options.throwExceptionOnParseError)y=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(E)}return y},g.prototype.getTimeOfDayDescription=function(){var h=this.expressionParts[0],v=this.expressionParts[1],y=this.expressionParts[2],j="";if(!f.StringUtilities.containsAny(v,g.specialCharacters)&&!f.StringUtilities.containsAny(y,g.specialCharacters)&&!f.StringUtilities.containsAny(h,g.specialCharacters))j+=this.i18n.atSpace()+this.formatTime(y,v,h);else if(!h&&v.indexOf("-")>-1&&!(v.indexOf(",")>-1)&&!(v.indexOf("/")>-1)&&!f.StringUtilities.containsAny(y,g.specialCharacters)){var k=v.split("-");j+=f.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(y,k[0],""),this.formatTime(y,k[1],""))}else if(!h&&y.indexOf(",")>-1&&y.indexOf("-")==-1&&y.indexOf("/")==-1&&!f.StringUtilities.containsAny(v,g.specialCharacters)){var $=y.split(",");j+=this.i18n.at();for(var S=0;S<$.length;S++)j&&(j+=" "),j+=this.formatTime($[S],v,""),S<$.length-2&&(j+=","),S==$.length-2&&(j+=this.i18n.spaceAnd())}else{var N=this.getSecondsDescription(),_=this.getMinutesDescription(),E=this.getHoursDescription();if(j+=N,j&&_&&(j+=", "),j+=_,_===E)return j;j&&E&&(j+=", "),j+=E}return j},g.prototype.getSecondsDescription=function(){var h=this,v=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(y){return y},function(y){return f.StringUtilities.format(h.i18n.everyX0Seconds(y),y)},function(y){return h.i18n.secondsX0ThroughX1PastTheMinute()},function(y){return y=="0"?"":parseInt(y)<20?h.i18n.atX0SecondsPastTheMinute(y):h.i18n.atX0SecondsPastTheMinuteGt20()||h.i18n.atX0SecondsPastTheMinute(y)},{min:0,max:59});return v},g.prototype.getMinutesDescription=function(){var h=this,v=this.expressionParts[0],y=this.expressionParts[2],j=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(k){return k},function(k){return f.StringUtilities.format(h.i18n.everyX0Minutes(k),k)},function(k){return h.i18n.minutesX0ThroughX1PastTheHour()},function(k){var $,S;try{return k=="0"&&y.indexOf("/")==-1&&v==""?h.i18n.everyHour():k=="0"?((S=($=h.i18n).onTheHour)===null||S===void 0?void 0:S.call($))||h.i18n.atX0MinutesPastTheHour(k):parseInt(k)<20?h.i18n.atX0MinutesPastTheHour(k):h.i18n.atX0MinutesPastTheHourGt20()||h.i18n.atX0MinutesPastTheHour(k)}catch{return h.i18n.atX0MinutesPastTheHour(k)}},{min:0,max:59});return j},g.prototype.getHoursDescription=function(){var h=this,v=this.expressionParts[2],y=0,j=[];v.split("/")[0].split(",").forEach(function(S){var N=S.split("-");N.length===2&&j.push({value:N[1],index:y+1}),y+=N.length});var k=0,$=this.getSegmentDescription(v,this.i18n.everyHour(),function(S){var N=j.find(function(E){return E.value===S&&E.index===k}),_=N&&h.expressionParts[1]!=="0";return k++,_?h.formatTime(S,"59",""):h.formatTime(S,"0","")},function(S){return f.StringUtilities.format(h.i18n.everyX0Hours(S),S)},function(S){return h.i18n.betweenX0AndX1()},function(S){return h.i18n.atX0()},{min:0,max:23});return $},g.prototype.getDayOfWeekDescription=function(){var h=this,v=this.i18n.daysOfTheWeek(),y=null;return this.expressionParts[5]=="*"?y="":y=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(j,k){var $=j;j.indexOf("#")>-1?$=j.substring(0,j.indexOf("#")):j.indexOf("L")>-1&&($=$.replace("L",""));var S=parseInt($),N=h.i18n.daysOfTheWeekInCase?h.i18n.daysOfTheWeekInCase(k)[S]:v[S];if(j.indexOf("#")>-1){var _=null,E=j.substring(j.indexOf("#")+1),O=j.substring(0,j.indexOf("#"));switch(E){case"1":_=h.i18n.first(O);break;case"2":_=h.i18n.second(O);break;case"3":_=h.i18n.third(O);break;case"4":_=h.i18n.fourth(O);break;case"5":_=h.i18n.fifth(O);break}N=_+" "+N}return N},function(j){return parseInt(j)==1?"":f.StringUtilities.format(h.i18n.commaEveryX0DaysOfTheWeek(j),j)},function(j){var k=j.substring(0,j.indexOf("-")),$=h.expressionParts[3]!="*";return $?h.i18n.commaAndX0ThroughX1(k):h.i18n.commaX0ThroughX1(k)},function(j){var k=null;if(j.indexOf("#")>-1){var $=j.substring(j.indexOf("#")+1),S=j.substring(0,j.indexOf("#"));k=h.i18n.commaOnThe($,S).trim()+h.i18n.spaceX0OfTheMonth()}else if(j.indexOf("L")>-1)k=h.i18n.commaOnTheLastX0OfTheMonth(j.replace("L",""));else{var N=h.expressionParts[3]!="*";N?h.options.logicalAndDayFields?k=h.i18n.commaOnlyOnX0(j):k=h.i18n.commaAndOnX0():k=h.i18n.commaOnlyOnX0(j)}return k}),y},g.prototype.getMonthDescription=function(){var h=this,v=this.i18n.monthsOfTheYear(),y=this.getSegmentDescription(this.expressionParts[4],"",function(j,k){return k&&h.i18n.monthsOfTheYearInCase?h.i18n.monthsOfTheYearInCase(k)[parseInt(j)-1]:v[parseInt(j)-1]},function(j){return parseInt(j)==1?"":f.StringUtilities.format(h.i18n.commaEveryX0Months(j),j)},function(j){return h.i18n.commaMonthX0ThroughMonthX1()||h.i18n.commaX0ThroughX1()},function(j){return h.i18n.commaOnlyInMonthX0?h.i18n.commaOnlyInMonthX0():h.i18n.commaOnlyInX0()});return y},g.prototype.getDayOfMonthDescription=function(){var h=this,v,y,j,k,$=null,S=this.expressionParts[3];switch(S){case"L":$=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":$=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var N=S.match(/^(?:(\d{1,2})W|W(\d{1,2}))(?:([+-])(\d{1,2}))?$/);if(N){var _=parseInt(N[1]||N[2]),E=_==1?this.i18n.firstWeekday():f.StringUtilities.format(this.i18n.weekdayNearestDayX0(),_.toString()),O=N[4];O?N[3]=="-"?$=f.StringUtilities.format(((y=(v=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||y===void 0?void 0:y.call(v,O))||", %s days before the %s of the month",O,E):$=f.StringUtilities.format(((k=(j=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||k===void 0?void 0:k.call(j,O))||", %s days after the %s of the month",O,E):$=f.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),E);break}else{var A=S.match(/L-(\d{1,2})/);if(A){var I=A[1];$=f.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(I),I);break}else{if(S=="*"&&this.expressionParts[5]!="*")return"";$=this.getSegmentDescription(S,this.i18n.commaEveryDay(),function(M){return M=="L"?h.i18n.lastDay():h.i18n.dayX0?f.StringUtilities.format(h.i18n.dayX0(),M):M},function(M){return M=="1"?h.i18n.commaEveryDay():h.i18n.commaEveryX0Days(M)},function(M){return h.i18n.commaBetweenDayX0AndX1OfTheMonth(M)},function(M){return h.i18n.commaOnDayX0OfTheMonth(M)})}break}}return $},g.prototype.getYearDescription=function(){var h=this,v=this.getSegmentDescription(this.expressionParts[6],"",function(y){return/^\d+$/.test(y)?new Date(parseInt(y),1).getFullYear().toString():y},function(y){return f.StringUtilities.format(h.i18n.commaEveryX0Years(y),y)},function(y){return h.i18n.commaYearX0ThroughYearX1()||h.i18n.commaX0ThroughX1()},function(y){return h.i18n.commaOnlyInYearX0?h.i18n.commaOnlyInYearX0():h.i18n.commaOnlyInX0()});return v},g.prototype.getSegmentDescription=function(h,v,y,j,k,$,S){var N=null,_=h.indexOf("/")>-1,E=h.indexOf("-")>-1,O=h.indexOf(",")>-1;if(!h)N="";else if(h==="*")N=v;else if(!_&&!E&&!O)N=f.StringUtilities.format($(h),y(h));else if(O){for(var A=h.split(","),I="",M=this.i18n.spaceAnd(),R=0;R<A.length;R++)if(R>0&&A.length>2&&(I+=",",R<A.length-1&&(I+=" ")),R>0&&A.length>1&&(R==A.length-1||A.length==2)&&(I+=M==","&&A.length>2?" ":"".concat(M," ")),A[R].indexOf("/")>-1||A[R].indexOf("-")>-1){var P=A[R].indexOf("-")>-1&&A[R].indexOf("/")==-1,D=this.getSegmentDescription(A[R],v,y,j,P?this.i18n.commaX0ThroughX1:k,$);P?D=D.replace(", ",""):R>0&&D.startsWith(", ")&&(D=D.substring(2)),I+=D}else if(!_)I+=y(A[R]);else{var W=this.getSegmentDescription(A[R],v,y,j,k,$);R>0&&W&&W.startsWith(", ")&&(W=W.substring(2)),I+=W}_?N=I:N=f.StringUtilities.format($(h),I)}else if(_){var A=h.split("/");if(N=f.StringUtilities.format(j(A[1]),A[1]),A[0].indexOf("-")>-1){var Y=this.generateRangeSegmentDescription(A[0],k,y);Y.indexOf(", ")!=0&&(N+=", "),N+=Y}else if(A[0].indexOf("*")==-1){var H=f.StringUtilities.format($(A[0]),y(A[0]));H=H.replace(", ",""),N+=f.StringUtilities.format(this.i18n.commaStartingX0(),H)}N+=this.getWrappingIncrementDescription(h,S,v,y,j,k,$)}else E&&(N=this.generateRangeSegmentDescription(h,k,y));return N},g.prototype.getWrappingIncrementDescription=function(h,v,y,j,k,$,S){if(!this.options.verbose||!v)return"";var N=h.split("/"),_=N[0],E=N[1],O=parseInt(E),A=v.max-v.min+1,I=_==="*",M=Number.isInteger(O)&&O>1,R=M&&A%O===0;if(!I||!M||R)return"";for(var P=[],D=v.min;D<=v.max;D+=O)P.push(D);if(P.length<2)return"";var W=this.getSegmentDescription(P.join(","),y,j,k,$,S);return W?", ".concat(W):""},g.prototype.generateRangeSegmentDescription=function(h,v,y){var j="",k=h.split("-"),$=y(k[0],1),S=y(k[1],2),N=v(h);return j+=f.StringUtilities.format(N,$,S),j},g.prototype.formatTime=function(h,v,y){var j=0,k=0,$=parseInt(h)+j,S=parseInt(v)+k;S>=60?(S-=60,$+=1):S<0&&(S+=60,$-=1),$>=24?$=$-24:$<0&&($=24+$);var N="",_=!1;this.options.use24HourTimeFormat||(_=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),N=_?"".concat(this.getPeriod($)," "):" ".concat(this.getPeriod($)),$>12&&($-=12),$===0&&($=12));var E="";y&&(E=":".concat(("00"+y).substring(y.length)));var O=$.toString(),A=("00"+O).substring(O.length),I=S.toString(),M=("00"+I).substring(I.length),R=this.options.trimHoursLeadingZero?O:A;return"".concat(_?N:"").concat(R,":").concat(M).concat(E).concat(_?"":N)},g.prototype.transformVerbosity=function(h,v){if(!v&&(h=h.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),h=h.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),h=h.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),h=h.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var y=0,j=Object.entries(this.i18n.conciseVerbosityReplacements());y<j.length;y++){var k=j[y],$=k[0],S=k[1];h=h.replace(new RegExp($,"g"),S)}return h},g.prototype.getPeriod=function(h){return h>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},g.locales={},g})();d.ExpressionDescriptor=b},3747(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.enLocaleLoader=void 0;var f=u(9486),x=(function(){function b(){}return b.prototype.load=function(g){g.en=new f.en},b})();d.enLocaleLoader=x},9486(c,d){Object.defineProperty(d,"__esModule",{value:!0}),d.en=void 0;var u=function(x){return Number(x)===1},f=(function(){function x(){}return x.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},x.prototype.atX0MinutesPastTheHourGt20=function(){return null},x.prototype.commaMonthX0ThroughMonthX1=function(){return null},x.prototype.commaYearX0ThroughYearX1=function(){return null},x.prototype.use24HourTimeFormatByDefault=function(){return!1},x.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},x.prototype.everyMinute=function(){return"every minute"},x.prototype.everyHour=function(){return"every hour"},x.prototype.atSpace=function(){return"At "},x.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},x.prototype.at=function(){return"At"},x.prototype.spaceAnd=function(){return" and"},x.prototype.everySecond=function(){return"every second"},x.prototype.everyX0Seconds=function(b){return u(b)?"every %s second":"every %s seconds"},x.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},x.prototype.atX0SecondsPastTheMinute=function(b){return u(b)?"at %s second past the minute":"at %s seconds past the minute"},x.prototype.everyX0Minutes=function(b){return u(b)?"every %s minute":"every %s minutes"},x.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},x.prototype.atX0MinutesPastTheHour=function(b){return u(b)?"at %s minute past the hour":"at %s minutes past the hour"},x.prototype.everyX0Hours=function(b){return u(b)?"every %s hour":"every %s hours"},x.prototype.betweenX0AndX1=function(){return"between %s and %s"},x.prototype.atX0=function(){return"at %s"},x.prototype.commaEveryDay=function(){return", every day"},x.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},x.prototype.commaX0ThroughX1=function(){return", %s through %s"},x.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},x.prototype.first=function(){return"first"},x.prototype.second=function(){return"second"},x.prototype.third=function(){return"third"},x.prototype.fourth=function(){return"fourth"},x.prototype.fifth=function(){return"fifth"},x.prototype.commaOnThe=function(){return", on the "},x.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},x.prototype.lastDay=function(){return"the last day"},x.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},x.prototype.commaOnlyOnX0=function(){return", only on %s"},x.prototype.commaAndOnX0=function(){return", and on %s"},x.prototype.commaEveryX0Months=function(){return", every %s months"},x.prototype.commaOnlyInX0=function(){return", only in %s"},x.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},x.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},x.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(b){return u(b)?", %s day before the last day of the month":", %s days before the last day of the month"},x.prototype.firstWeekday=function(){return"first weekday"},x.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},x.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},x.prototype.commaDaysBeforeTheX0OfTheMonth=function(b){return u(b)?", %s day before the %s of the month":", %s days before the %s of the month"},x.prototype.commaDaysAfterTheX0OfTheMonth=function(b){return u(b)?", %s day after the %s of the month":", %s days after the %s of the month"},x.prototype.commaEveryX0Days=function(){return", every %s days in a month"},x.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},x.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},x.prototype.commaEveryHour=function(){return", every hour"},x.prototype.commaEveryX0Years=function(b){return u(b)?", every %s year":", every %s years"},x.prototype.commaStartingX0=function(){return", starting %s"},x.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},x.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},x.prototype.atReboot=function(){return"Run once, at startup"},x.prototype.onTheHour=function(){return"on the hour"},x})();d.en=f},9515(c,d){Object.defineProperty(d,"__esModule",{value:!0});function u(b,g){if(!b)throw new Error(g)}function f(b){var g=[];if(!isNaN(parseInt(b,10))){g.push(parseInt(b,10));var h=b.match(/^\d+-(-?\d+)/);h&&g.push(parseInt(h[1],10))}return g}var x=(function(){function b(){}return b.stepRange=function(g){for(var h=g.split(","),v=0;v<h.length;v++){var y=h[v].split("/")[1];u(y===void 0||!/^0+$/.test(y),"step value must be greater than 0")}},b.secondRange=function(g){for(var h=g.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=0&&k<=59,"seconds part must be >= 0 and <= 59")}},b.minuteRange=function(g){for(var h=g.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=0&&k<=59,"minutes part must be >= 0 and <= 59")}},b.hourRange=function(g){for(var h=g.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=0&&k<=23,"hours part must be >= 0 and <= 23")}},b.dayOfMonthRange=function(g){for(var h=g.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=1&&k<=31,"DOM part must be >= 1 and <= 31")}},b.monthRange=function(g,h){for(var v=g.split(","),y=0;y<v.length;y++)for(var j=0,k=f(v[y]);j<k.length;j++){var $=k[j];u($>=1&&$<=12,h?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},b.dayOfWeekRange=function(g,h){for(var v=g.split(","),y=0;y<v.length;y++){if(v[y].indexOf("#")>-1){var j=v[y].substring(v[y].indexOf("#")+1);u(/^[1-5]$/.test(j),"DOW nth weekday must be >= 1 and <= 5")}for(var k=0,$=f(v[y]);k<$.length;k++){var S=$[k];u(S>=0&&S<=6,h?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}}},b})();d.default=x},1823(c,d){Object.defineProperty(d,"__esModule",{value:!0}),d.StringUtilities=void 0;var u=(function(){function f(){}return f.format=function(x){for(var b=[],g=1;g<arguments.length;g++)b[g-1]=arguments[g];return x.replace(/%s/g,function(h){return b.shift()})},f.containsAny=function(x,b){return b.some(function(g){return x.indexOf(g)>-1})},f})();d.StringUtilities=u}},r={};function a(c){var d=r[c];if(d!==void 0)return d.exports;var u=r[c]={exports:{}};return s[c](u,u.exports,a),u.exports}var i={};return(()=>{var c=i;Object.defineProperty(c,"__esModule",{value:!0}),c.toString=void 0;var d=a(8333),u=a(3747);d.ExpressionDescriptor.initialize(new u.enLocaleLoader),c.default=d.ExpressionDescriptor;var f=d.ExpressionDescriptor.toString;c.toString=f})(),i})())})(hg)),hg.exports}var XF=JF();const ZF=uN(XF),xd={rules:20,conditions:20,list:20,pointer:512,text:200,value:1024},kn=xd,$C={in:"is one of",prefix:"starts with",exists:"exists",missing:"is missing"},e6=Object.keys($C);let t6=0;const Um=()=>`r${++t6}`,n6=()=>({key:Um(),pointer:"",op:"in",value:""}),_C=()=>({key:Um(),event:"",actions:"",where:[]});function TC(e){const n=e.trim();try{return JSON.parse(n)}catch{return n}}function RC(e){return typeof e!="string"?JSON.stringify(e):e!==""&&e===e.trim()&&!/[,\r\n]/.test(e)&&TC(e)===e?e:JSON.stringify(e)}const s6=e=>"in"in e?`${e.pointer} is one of ${e.in.map(RC).join(", ")}`:"exists"in e?`${e.pointer} ${e.exists?"exists":"is missing"}`:`${e.pointer} starts with ${JSON.stringify(e.prefix)}`,Yi=(e,n=!0)=>{var s,r;return`${e.event}${(s=e.actions)!=null&&s.length?` (${e.actions.join(", ")})`:""}${n&&((r=e.where)!=null&&r.length)?` where ${e.where.map(s6).join(" and ")}`:""}`};function AC(e){return"in"in e?{pointer:e.pointer,op:"in",value:e.in.map(RC).join(`
|
|
648
|
+
`)}:"exists"in e?{pointer:e.pointer,op:e.exists?"exists":"missing",value:""}:{pointer:e.pointer,op:"prefix",value:e.prefix}}const OC=e=>({key:Um(),...AC(e),was:e}),MC=e=>{if(!e.was)return!1;const n=AC(e.was);return n.pointer===e.pointer&&n.op===e.op&&n.value===e.value},PC=e=>(e??[]).join(", "),cx=e=>({key:Um(),event:e.event,actions:PC(e.actions),where:(e.where??[]).map(OC),was:e}),r6=(e,n)=>e.length===n.length&&e.every((s,r)=>s===n[r]),o6=e=>e.split(/[\s,]+/).filter(Boolean),d0=/^[!-~]+$/,Cc=e=>[...e].length,a6=/^(\/([^~]|~[01])*)?$/;function i6(e,n,s){return e.length>kn.conditions&&(s[`${n}.where`]=`At most ${kn.conditions} conditions a rule.`),e.map((r,a)=>{if(MC(r))return r.was;const i=`${n}.where[${a}]`,c=r.pointer;if(c?c.startsWith("/")?a6.test(c)?Cc(c)>kn.pointer&&(s[`${i}.pointer`]=`At most ${kn.pointer} characters.`):s[`${i}.pointer`]="Write ~ in a field's name as ~0, and / in it as ~1.":s[`${i}.pointer`]="A field starts with /: /title, /issue/labels/0/name.":s[`${i}.pointer`]="Name a field: a JSON pointer such as /title.",r.op==="exists"||r.op==="missing")return{pointer:c,exists:r.op==="exists"};if(r.op==="prefix"){const u=r.value.trimStart();return u?Cc(u)>kn.text&&(s[`${i}.prefix`]=`At most ${kn.text} characters.`):s[`${i}.prefix`]="Give the text it starts with.",{pointer:c,prefix:u}}const d=r.value.split(/\r\n|\r|\n/).filter(u=>u.trim()).map(TC);return d.length?d.length>kn.list?s[`${i}.in`]=`At most ${kn.list} values.`:d.some(u=>Cc(JSON.stringify(u))>kn.value)&&(s[`${i}.in`]=`Each value is at most ${kn.value} characters.`):s[`${i}.in`]="Give at least one value, one a line.",{pointer:c,in:d}})}function l6(e,n,s){var x;const r=`source.accept[${n}]`,a=e.was,i=a&&e.event===a.event?a.event:e.event.trim();i?i!==(a==null?void 0:a.event)&&(!d0.test(i)||Cc(i)>kn.text)&&(s[`${r}.event`]=`An event's name has no spaces: printable characters only, at most ${kn.text}.`):s[`${r}.event`]="Name the event.";const c=a&&(typeof e.actions=="string"?e.actions===PC(a.actions):r6(e.actions,a.actions??[])),d=c?[...a.actions??[]]:typeof e.actions=="string"?o6(e.actions):e.actions;if(a&&c&&i===a.event&&e.where.length===(((x=a.where)==null?void 0:x.length)??0)&&e.where.every((b,g)=>MC(b)&&b.was===a.where[g]))return a;d.length>kn.list?s[`${r}.actions`]=`At most ${kn.list} actions.`:d.some(b=>!d0.test(b)||Cc(b)>kn.text)&&(s[`${r}.actions`]=`An action's name is printable characters, at most ${kn.text}.`);const f=i6(e.where,r,s);return{event:i,...d.length?{actions:d}:{},...f.length?{where:f}:{}}}function Xv(e){const n={};return e.length>kn.rules&&(n["source.accept"]=`At most ${kn.rules} rules.`),{accept:e.map((s,r)=>l6(s,r,n)),issues:n}}function Wm(e){const n=new Set(["source.accept"]);return e.forEach((s,r)=>{const a=`source.accept[${r}]`;for(const i of["",".event",".actions",".where"])n.add(`${a}${i}`);for(let i=0;i<s;i++)for(const c of["",".pointer",".in",".prefix",".exists"])n.add(`${a}.where[${i}]${c}`)}),n}const zi=(e,n)=>n&&e===ux(n)?n:v6(e),bl=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",LC=(e="")=>({name:"",kind:"cron",cron:"",timezone:bl(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),IC={seconds:1,minutes:60,hours:3600};function zC(e){const[n,s]=e%3600===0?[e/3600,"hour"]:e%60===0?[e/60,"minute"]:[e,"second"];return n===1?s:`${n} ${s}s`}function DC(e){try{return ZF.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const Ea=e=>String(e).padStart(2,"0"),Df=(e,n)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:n});function FC(e,n){const s=i=>{var c;return((c=new Intl.DateTimeFormat(i,{timeZone:n,timeZoneName:"short"}).formatToParts(e).find(d=>d.type==="timeZoneName"))==null?void 0:c.value)??n},r=s("en-US");if(!/^GMT[+-]/.test(r))return r;const a=s("en-GB");return/^GMT[+-]/.test(a)?r:a}const u0=(e,n)=>{const s=new Date(e);return`${s.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:n}).replace(",","")}, ${Df(s,n)} ${FC(s,n)}`};function f0(e,{zone:n=bl(),now:s=Date.now()}={}){const r=new Date(e),a=c=>c.toLocaleDateString("en-US",{year:"numeric",month:"numeric",day:"numeric",timeZone:n});return`Pick a time in the future: ${a(r)===a(new Date(s))?`${Df(r,n)} today`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:n})}, ${Df(r,n)} ${FC(r,n)}`} has already passed.`}function Ff(e,n){const s={};for(const{type:r,value:a}of new Intl.DateTimeFormat("en-US",{timeZone:n,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 c6(e,n,s,r){const a=new Date(Ff(e,n)),i=Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),s,r);let c=i;for(let d=0;d<2;d++)c+=i-Ff(new Date(c),n);return new Date(c)}const d6=e=>{const n=e.trim().split(/\s+/);return n.length!==5||!/^\d{1,2}$/.test(n[0])||!/^\d{1,2}$/.test(n[1])?null:{minute:Number(n[0]),hour:Number(n[1]),days:n.slice(2).some(s=>s!=="*"&&s!=="?")}};function u6(e,n,s,r,a){const i=DC(e),c=n!==s,d=d6(e),u=d&&`At ${Ea(d.hour)}:${Ea(d.minute)}`;if(d&&u&&i.startsWith(u))try{const f=r??c6(a,n,d.hour,d.minute),x=d.days?Math.floor(Ff(f,s)/864e5)-Math.floor(Ff(f,n)/864e5):0,b=x>0?" the next day":x<0?" the day before":"";return`At ${Df(f,s)} your time${b}${c?` (${u.slice(3)} ${n})`:""}${i.slice(u.length)}`}catch{}return`${i}${c?` (${n})`:""}`}function Zv(e,n,{zone:s=bl(),instead:r,now:a=Date.now()}={}){const i=r?` · ${r}`:n?` · next ${u0(n,s)}`:" · no next time";return"cron"in e?`${u6(e.cron,e.timezone,s,n?new Date(n):null,new Date(a))}${i}`:"at"in e?`Once, ${u0(e.at,s)}${!r&&n&&Date.parse(n)===Date.parse(e.at)?"":i}`:`Every ${zC(e.every_s)}${i}`}const Xa=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,f6=e=>`${Xa(e)} a run`,m6=(e,n)=>typeof e=="number"?f6(e):typeof n=="number"&&n>0?`Agent's default (${Xa(n)})`:"Agent's default";function ey(e,n,s=[]){if(e.source.kind!=="schedule"||!("at"in e.source)||e.next_at!==null)return null;const r=Date.parse(e.source.at);if(r>n)return null;const a=[e.last_firing,...s].find(i=>i&&i.status==="started"&&Date.parse(i.nominal_at)===r);return a?{ran:a}:{passed:e.source.at}}const ty=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",ny=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",UC=e=>e.source.kind==="github"&&e.target.kind==="start_run",Hm=[{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"}],Wc=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,sy="This server's address as this page sees it: behind a proxy, use its public address.",dx={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)"},WC=e=>{var n;return(n=e.accept)!=null&&n.length?`Only signed requests for ${e.accept.map(s=>Yi(s,!1)).join(" or ")}`:"On each signed request"},h6={schedule:"On schedule",manual:"Run now",webhook:"On a request",github:"On a GitHub event",composio:"On an app event",email:"On an email"},HC=e=>`On ${e.event} from ${e.server}`,p6=e=>{var n;return(n=e.accept)!=null&&n.length?`On email in ${e.mailbox} for ${e.accept.map(s=>Yi(s,!1)).join(" or ")}`:`On each email in ${e.mailbox}`},BC=e=>`On GitHub ${e.accept.map(n=>Yi(n,!1)).join(" or ")}`;function Uf(e,n){const s=e.disabled;return s?s.reason==="source_unreadable"?`Turned off: its source can't be read (${s.detail}).`:s.reason!=="auto_paused"?`Turned off: ${s.detail}`:n?`Turned off after ${n} failures in a row.`:"Turned off after failures in a row.":null}function GC(e){var s;const n=(r,a)=>a?`${r}: ${a}`:r;switch(e.status){case"started":return"Started";case"skipped":return n("Skipped",e.reason);case"missed":return n(`Missed ${e.count??1} ${e.count===1||e.count===void 0?"time":"times"}`,e.reason);case"failed":return n("Failed",((s=e.error)==null?void 0:s.message)??e.reason);case"due":return e.retry_at?`Due: the server was full, tries again at ${td(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const g6={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},x6=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function v6(e){if(!x6.test(e))return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toISOString().replace(/\.\d{3}Z$/,"Z")}function ux(e){const n=new Date(e);return`${n.getFullYear()}-${Ea(n.getMonth()+1)}-${Ea(n.getDate())}T${Ea(n.getHours())}:${Ea(n.getMinutes())}${n.getSeconds()?`:${Ea(n.getSeconds())}`:""}`}const m0=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function y6(e){const n=zC(e);return/^\d/.test(n)?`At least ${n}.`:`At least ${n==="hour"?"an":"a"} ${n}.`}const Wf="A number is needed.",Hf=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function h0(e,n=!1){var i,c;const s={};let r;if(e.kind==="cron")e.cron.trim()||(s["source.cron"]="Pick when it runs."),r={kind:"schedule",cron:e.cron.trim(),timezone:e.timezone.trim()||bl()};else if(e.kind==="at"){const d=zi(e.at,(i=e.read)==null?void 0:i.at);d===null&&(s["source.at"]="A time is needed."),r={kind:"schedule",at:d??""}}else{const d=Hf(e.every);e.every.trim()?d===void 0&&(s["source.every_s"]=Wf):s["source.every_s"]="A number is needed.";const u=e.startAt?zi(e.startAt,(c=e.read)==null?void 0:c.startAt):null;r={kind:"schedule",every_s:Math.round((d??0)*IC[e.everyUnit]),...u?{start_at:u}:{}}}e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const a=Hf(e.maxCost);return e.maxCost.trim()?a===void 0&&(s["target.max_cost_usd"]=Wf):n||(s["target.max_cost_usd"]="A cost cap is needed: every run a schedule starts is capped."),Object.keys(s).length?{issues:s}:{body:{...e.name.trim()?{name:e.name.trim()}:{},enabled:e.enabled,source:r,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...a!==void 0?{max_cost_usd:a}:{}}}}}const b6=()=>({name:"",signature:"standard",accept:[],agentId:"",content:"",maxCost:""});function qC(e,n){const{accept:s,issues:r}=Xv(n);return{source:{kind:"webhook",...e.signature!==void 0?{signature:e.signature}:{},...s.length?{accept:s}:{}},issues:r}}function w6(e,n=!1){const{source:s,issues:r}=qC({signature:e.signature},e.accept);return oy(e,s,r,n,"a webhook")}const j6=()=>({name:"",events:["pull_request:opened"],where:{},other:[],agentId:"",content:"",maxCost:""}),KC=[...new Set(Hm.map(e=>e.event))],k6=(e,n)=>e.length===n.length&&e.every(s=>n.includes(s));function Bm(e){var i;const s=[...KC.flatMap(c=>{var f;const d=Hm.filter(x=>x.event===c&&e.events.includes(`${x.event}:${x.action}`)).map(x=>x.action);if(!d.length)return[];const u=(f=e.read)==null?void 0:f.rules[c];return[{id:`event:${c}`,event:c,actions:u!=null&&u.actions&&k6(d,u.actions)?[...u.actions]:d,where:e.where[c]??[],...u?{was:u}:{}}]}),...e.other.map(c=>({...c,id:`other:${c.key}`}))],r=((i=e.read)==null?void 0:i.order)??[],a=c=>{const d=r.indexOf(c.id);return d<0?r.length:d};return s.map((c,d)=>({r:c,i:d})).sort((c,d)=>a(c.r)-a(d.r)||c.i-d.i).map(({r:c})=>c)}function VC(e){const{accept:n,issues:s}=Xv(Bm(e));return n.length||(s["source.accept"]="Pick at least one event."),{source:{kind:"github",accept:n},issues:s}}function N6(e){var s;const n={events:[],where:{},other:[],read:{order:[],rules:{}}};for(const r of e){const a=Hm.filter(c=>c.event===r.event).map(c=>c.action);if(!(!!((s=r.actions)!=null&&s.length)&&r.actions.every(c=>a.includes(c))&&new Set(r.actions).size===r.actions.length&&!(r.event in n.where))){const c=cx(r);n.other.push(c),n.read.order.push(`other:${c.key}`);continue}n.events.push(...r.actions.map(c=>`${r.event}:${c}`)),n.where[r.event]=(r.where??[]).map(OC),n.read.order.push(`event:${r.event}`),n.read.rules[r.event]=r}return n}const ry=e=>e.source.kind==="composio"&&e.target.kind==="start_run";function S6(e){const n=(e==null?void 0:e.properties)??{},s=new Set(Array.isArray(e==null?void 0:e.required)?e.required.filter(r=>typeof r=="string"):[]);return Object.entries(n).filter(([,r])=>r&&typeof r=="object"&&r.deprecated!==!0).map(([r,a])=>{const i=(Array.isArray(a.type)?a.type:[a.type]).filter(f=>f!=="null"),c=i.length===1&&["string","number","integer","boolean"].includes(String(i[0]))?i[0]:"json",d=c==="string"&&Array.isArray(a.enum)&&a.enum.every(f=>typeof f=="string")?a.enum:void 0,u=a.default===void 0?c==="boolean"?"false":"":c==="json"?JSON.stringify(a.default):String(a.default);return{name:r,title:typeof a.title=="string"&&a.title.trim()?a.title:r,...typeof a.description=="string"&&a.description.trim()?{description:a.description}:{},required:s.has(r),type:c,...d?{options:d}:{},initial:u}})}function C6(e,n,s){const r={};for(const a of e){const i=(n[a.name]??a.initial).trim(),c=`source.config.${a.name}`;if(!i){a.required&&(s[c]=`${a.title} is required.`);continue}if(a.type==="boolean")r[a.name]=i==="true";else if(a.type==="number"||a.type==="integer"){const d=Hf(i);d===void 0||a.type==="integer"&&!Number.isInteger(d)?s[c]=a.type==="integer"?"A whole number is needed.":Wf:r[a.name]=d}else if(a.type==="json")try{r[a.name]=JSON.parse(i)}catch{s[c]="Give it as JSON."}else r[a.name]=i}return r}const E6=()=>({name:"",server:"",event:"",config:{},where:[],agentId:"",content:"",maxCost:""});function YC(e,n,s=[],r){var i;const a=n.length||r&&!((i=r.where)!=null&&i.length)?[{event:e,actions:"",where:n,...r?{was:r}:{}}]:[];return Xv([...a,...s])}function $6(e,n,s=[],r){const{accept:a,...i}=e,{accept:c,issues:d}=YC(e.event,n,s,r);return{source:{...i,...c.length?{accept:c}:{}},issues:d}}function _6(e,n,s=!1){const r={};e.server||(r["source.server"]="Pick a Composio server."),e.event||(r["source.event"]="Pick an event.");const a=e.event?C6(n,e.config,r):{},{accept:i,issues:c}=YC(e.event,e.where);Object.assign(r,c);const d={kind:"composio",server:e.server,event:e.event,config:a,...i.length?{accept:i}:{}};return oy(e,d,r,s,"a trigger")}function T6(e,n=!1){const{source:s,issues:r}=VC(e);return oy(e,s,r,n,"a GitHub trigger")}function oy(e,n,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 i=Hf(e.maxCost);return e.maxCost.trim()?i===void 0&&(s["target.max_cost_usd"]=Wf):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:n,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...i!==void 0?{max_cost_usd:i}:{}}}}}function R6(e){const n=e.source,s="cron"in n?n.timezone:bl(),r={...LC(e.target.agent_id),name:e.name,timezone:s,content:typeof e.target.input.content=="string"?e.target.input.content:"",maxCost:typeof e.target.max_cost_usd=="number"?String(e.target.max_cost_usd):"",enabled:e.enabled};if("cron"in n)return{...r,kind:"cron",cron:n.cron};if("at"in n)return{...r,kind:"at",at:ux(n.at),read:{at:n.at}};const a=n.every_s%3600===0?"hours":n.every_s%60===0?"minutes":"seconds";return{...r,kind:"every",every:String(n.every_s/IC[a]),everyUnit:a,startAt:ux(n.start_at),read:{startAt:n.start_at}}}const Bf=(e,n)=>{if(e===n)return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null||Array.isArray(e)!==Array.isArray(n))return!1;const[s,r]=[Object.keys(e),Object.keys(n)];return s.length===r.length&&s.every(a=>Bf(e[a],n[a]))};function p0(e,n){const s=n.source&&"every_s"in n.source&&!n.source.start_at&&"every_s"in e.source?{...n.source,start_at:e.source.start_at}:n.source,r=n.target&&{...n.target,input:{...e.target.input,...n.target.input},...e.target.effort!==void 0&&n.target.effort===void 0?{effort:e.target.effort}:{}};return{...n.name!==void 0&&n.name!==e.name?{name:n.name}:{},...s&&!Bf(s,e.source)?{source:s}:{},...r&&!Bf(r,e.target)?{target:r}:{}}}const A6=["name","enabled","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd"];function vd(e){var r;if(!(e instanceof ze))return{fields:{},rest:[e instanceof Error?e.message:String(e)]};if(e.status!==422||!((r=e.fields)!=null&&r.length))return{fields:{},rest:[`${e.code}: ${e.message}`]};const n={},s=[];for(const a of e.fields){const i=a.field.startsWith("target.input")?"target.input":a.field;(A6.includes(i)||i.startsWith("source.accept")||i==="source.server"||i==="source.event"||i==="source.config"||i.startsWith("source.config."))&&!n[i]?n[i]=a.message:s.push(a.message)}return{fields:n,rest:s}}const O6=[{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"}],M6=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),P6=Array.from({length:31},(e,n)=>({value:String(n+1),label:String(n+1)})),L6=Array.from({length:60},(e,n)=>({value:String(n),label:`:${String(n).padStart(2,"0")}`}));function QC({value:e,onChange:n,label:s,name:r}){const a=qF(e),[i,c]=p.useState(()=>e.trim()!==""&&!a),d=p.useId(),u=i||e.trim()!==""&&!a,f=g=>n(KF(g)),x=g=>{if(g==="custom"){c(!0);return}c(!1),f(VF(g,a))},b=a&&"at"in a?a.at:null;return t.jsxs("div",{className:"space-y-2","data-schedule-when":!0,children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(At,{label:s,className:"min-w-56 flex-1",value:u?"custom":(a==null?void 0:a.kind)??"",onChange:x,placeholder:"Pick when it runs",options:O6}),!u&&(a==null?void 0:a.kind)==="weekly"&&t.jsx(At,{id:`${d}-day`,label:"Day of the week",className:"w-40",value:String(a.day),onChange:g=>f({...a,day:Number(g)}),options:M6}),!u&&(a==null?void 0:a.kind)==="monthly"&&t.jsx(At,{id:`${d}-date`,label:"Day of the month",className:"w-24",value:String(a.date),onChange:g=>f({...a,date:Number(g)}),options:P6}),!u&&(a==null?void 0:a.kind)==="hourly"&&t.jsx(At,{id:`${d}-minute`,label:"Minutes past the hour",className:"w-24",value:String(a.minute),onChange:g=>f({...a,minute:Number(g)}),options:L6}),!u&&a&&b&&t.jsx(Ie,{id:`${d}-at`,type:"time","aria-label":"At",className:"w-32",value:YF(b),onChange:g=>{const h=QF(g.target.value);h&&f({...a,at:h})}})]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Ie,{id:`${d}-line`,name:r,"aria-label":"Custom schedule",value:e,onChange:g=>n(g.target.value),placeholder:"30 1 * * *",spellCheck:!1}),t.jsx("p",{className:"text-small text-muted-foreground","aria-live":"polite",children:e.trim()?DC(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const g0=Intl.supportedValuesOf,Ku=typeof g0=="function"?g0("timeZone"):[],Vu=Ku.length&&!Ku.includes("UTC")?["UTC",...Ku]:Ku;function JC({value:e,onChange:n,label:s,name:r,id:a,className:i}){if(!Vu.length)return t.jsx(Ie,{id:a,name:r,"aria-label":s,className:i,value:e,onChange:d=>n(d.target.value),placeholder:"Europe/Madrid"});const c=e&&!Vu.includes(e)?[e,...Vu]:Vu;return t.jsx(At,{id:a,name:r,label:s,className:i,value:e,onChange:n,placeholder:"Pick a time zone",options:c.map(d=>({value:d,label:d.replace(/_/g," ")}))})}function I6(e,n){var i,c,d;let s;if(e==="agentic"&&n.json)try{s=JSON.parse(n.text)}catch{return{ok:!1,field:"input",message:"The agent's input is JSON: this is not."}}else if(e==="agentic"&&n.typed){if(n.typed.contentRequired&&!n.text.trim())return{ok:!1,field:"input",message:"Write the run's message."};s={...n.text.trim()?{content:n.text}:{},...n.typed.fields}}else if(e==="agentic"){if(!n.text.trim())return{ok:!1,field:"input",message:"Write the run's first message."};s={content:n.text}}else try{s=JSON.parse(n.text)}catch{return{ok:!1,field:"input",message:"The workflow's input is JSON: this is not."}}const r={input:s};if(n.revision&&(r.revision=n.revision),n.effort&&(r.effort=n.effort),e==="agentic"&&((i=n.maxCostUsd)!=null&&i.trim())){const u=Number(n.maxCostUsd);if(!Number.isFinite(u)||u<=0)return{ok:!1,field:"max_cost_usd",message:"A spend cap is a positive number of dollars."};r.max_cost_usd=u}(c=n.fileIds)!=null&&c.length&&(r.file_ids=[...n.fileIds]);const a=e==="agentic"?(d=n.repo)==null?void 0:d.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 z6(e,n){return s=>{var a,i,c,d;const r=new Set;for(;s!=null&&s.$ref&&!r.has(s.$ref);){r.add(s.$ref);const u=(i=(a=/^#\/(?:definitions|\$defs)\/(.+)$/.exec(s.$ref))==null?void 0:a[1])==null?void 0:i.replace(/~1/g,"/").replace(/~0/g,"~"),f=u===void 0?void 0:((c=e.definitions)==null?void 0:c[u])??((d=e.$defs)==null?void 0:d[u])??(Object.hasOwn(n,u)?n[u]:void 0);if(!f)break;s=f}return s}}function D6(e,n,s="workflow"){if(e.from==="example")return`The ${s}'s example input. Edit it, then ${n}.`;const r=e.optional.length?` It also takes ${e.optional.join(", ")}, if you add ${e.optional.length===1?"it":"them"}.`:"";return`The ${s}'s input, its required fields empty. Fill them in, then ${n}.${r}`}function F6(e){var r,a;const n=e,s=(r=n==null?void 0:n.input)!=null&&r.schemaId?(a=n.schemas)==null?void 0:a[n.input.schemaId]:void 0;return s?XC(s,(n==null?void 0:n.schemas)??{}):null}function XC(e,n={}){var u;const s=z6(e,n),r=s(e),a=Object.entries(r.properties??{}).map(([f,x])=>{const b=s(x);return{name:f,...b!=null&&b.description?{note:b.description}:{}}}),i=((u=r.examples)==null?void 0:u[0])??r.default;if(i!==void 0)return{text:JSON.stringify(i,null,2),from:"example",fields:a,optional:[]};const c=(f,x=0)=>{var h,v;const b=s(f);if(!b||x>4)return null;if((h=b.examples)!=null&&h.length)return b.examples[0];if(b.default!==void 0)return b.default;if((v=b.enum)!=null&&v.length)return b.enum[0];const g=Array.isArray(b.type)?b.type[0]:b.type;return g==="object"||b.properties?Object.fromEntries(Object.entries(b.properties??{}).filter(([y])=>(b.required??[]).includes(y)).map(([y,j])=>[y,c(j,x+1)])):g==="array"?[]:g==="string"?"":g==="number"||g==="integer"?0:g==="boolean"?!1:null},d=new Set(r.required??[]);return{text:JSON.stringify(c(r),null,2),from:"shape",fields:a,optional:a.map(f=>f.name).filter(f=>!d.has(f))}}const pg=e=>`'${e.replace(/'/g,"'\\''")}'`;function U6(e,n,s,r){return[`curl -X POST ${pg(`${e}/v2/agents/${n?encodeURIComponent(n):"{agent_id}"}/runs`)} \\`,' -H "Authorization: Bearer $AGENTRUN_API_KEY" \\'," -H 'Content-Type: application/json' \\",` -H ${pg(`Idempotency-Key: ${r}`)} \\`,` -d ${pg(JSON.stringify(s))}`].join(`
|
|
649
|
+
`)}const W6=e=>e>=200&&e<300;async function H6(e,n,s,r){const a=await r(n,s,e.keyFor(n,s));return W6(a.status)&&e.done(),a}const Uo=(e,n={})=>(e.display_name||e.name).replace(/\$\{parameters\.([A-Za-z0-9_]+)\}/g,(s,r)=>(Object.hasOwn(n,r)?iy(n[r]).join(", "):"")||"…"),ZC=e=>`#/templates/${encodeURIComponent(e)}`;function Hc(e,n){return`#/playground?${new URLSearchParams({operation:"apply-template",template:e.id,...n?{draft:JSON.stringify({template:e.id,version:e.version,...e.sha?{sha:e.sha}:{},body:n})}:{}})}`}function B6(e,n){var r,a;if(e===void 0)return{};const s={error:"This prepared template request is invalid. Open a fresh request to review its settings."};try{const i=JSON.parse(e),c=g=>g!==null&&typeof g=="object"&&!Array.isArray(g);if(!c(i)||i.template!==n.id||typeof i.version!="string")return s;if(i.version!==n.version)return{error:"This template's version changed. Open a fresh request to review the current package before applying."};if(n.sha&&i.sha!==n.sha)return{error:"This template's commit changed. Open a fresh request to review the current package before applying."};const d=i.body,u=(g,h)=>g==="boolean"?typeof h=="boolean":g==="string"?typeof h=="string":(g==="number"||g==="integer")&&typeof h=="number"&&Number.isFinite(h);if(!c(d)||Object.keys(d).some(g=>!["parameters","grants","servers","overrides"].includes(g))||!c(d.parameters)||d.grants!==void 0&&(!Array.isArray(d.grants)||d.grants.some(g=>typeof g!="string"||!n.mcp.some(h=>h.tools.some(v=>v.tool===g))))||d.servers!==void 0&&(!c(d.servers)||Object.entries(d.servers).some(([g,h])=>!n.mcp.some(v=>v.toolkit===g)||typeof h!="string"||!/^[a-z][a-z0-9-]{0,31}$/.test(h)))||!c(d.overrides)||Object.keys(d.overrides).some(g=>g!=="approvals"&&g!=="choice")||d.overrides.approvals!=="ask"&&d.overrides.approvals!=="never"||d.overrides.choice!==void 0&&(typeof d.overrides.choice!="string"||!((a=(r=n.model)==null?void 0:r.choices)!=null&&a.map(g=>g.id).includes(d.overrides.choice))))return s;const f=Gm(n.parameters);if(!f)return s;const x=new Map(f),b=[];for(const[g,h]of Object.entries(d.parameters)){const v=x.get(g);if(!v)return s;if(h==="")continue;if(v.array?!Array.isArray(h)||!h.every(k=>u(v.type,k)):!u(v.type,h))return s;const y=Array.isArray(h)?h.map(String).join(`
|
|
650
|
+
`):String(h),j=Km({fields:[[g,v]],contentRequired:!1},{[g]:y})[g];if(JSON.stringify(j)!==JSON.stringify(h))return s;b.push([g,h])}return{body:{...d,parameters:Object.fromEntries(b)}}}catch{return s}}const G6=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function ay(e,{secrets:n=!0,mcp:s=!0}={}){var a,i;const r=[];return n&&e.secrets.length&&r.push(["Keys",e.secrets.join(", ")]),s&&e.mcp.length&&r.push(["MCP",e.mcp.map(c=>`${c.toolkit} (${dd[c.source]}${c.required?"":", optional"})`).join(", ")]),e.triggers.length&&r.push(["Triggers",G6(e.triggers.length,"trigger")]),(a=e.budget)!=null&&a.per_run_usd&&r.push(["Budget",`${Xr(e.budget.per_run_usd)} a run`]),(i=e.harness)!=null&&i.length&&r.push(["Harness",e.harness.join(", ")]),e.model&&r.push(["Model",`${e.model.tier}${e.model.prefer?`, ${e.model.prefer} first`:""}`]),r}function yd(e){var s;if(e.type==="boolean"||e.array)return null;if((s=e.enum)!=null&&s.length)return e.enum.map(String);const n=e.pattern?/^\^\(([A-Za-z0-9_-]+(?:\|[A-Za-z0-9_-]+)+)\)\$$/.exec(e.pattern):null;return n?n[1].split("|"):null}function q6(e){return Object.fromEntries(Object.entries(e).flatMap(([n,s])=>s.array?[]:s.type==="boolean"?typeof s.default=="boolean"?[[n,String(s.default)]]:[]:yd(s)?[]:s.format==="timezone"?[[n,bl()]]:s.format==="cron"?typeof s.default=="string"?[[n,s.default]]:[]:[]))}const K6=(e,n)=>n.filter(s=>s.source===e.source&&s.toolkit===e.toolkit).map(s=>s.name).sort();function V6(e){const n=encodeURIComponent(e.toolkit);return e.source==="composio"?`#/settings/mcp?add=${n}&preset=composio&toolkit=${n}&tools=${e.tools.map(s=>encodeURIComponent(s.name)).join(",")}`:e.source==="github"?"#/settings/mcp?add=github&auth=github_app":`#/settings/mcp?add=${n}`}const Y6=(e,n)=>e.mcp.flatMap(s=>s.tools.map(r=>r.tool)).filter(s=>n.has(s)),Q6=(e,n)=>e.filter(s=>s.field===n);function Gf(e){if(e.type!=="string"||e.format!=="cron"&&e.format!=="timezone"||!e.description)return e.description;if(e.format==="timezone")return;const n=e.description.indexOf(": ");return n<0?void 0:e.description.slice(n+2).trim()||void 0}function J6(e){const n=yd(e);if(!n)return null;const s=e.default===void 0?void 0:String(e.default);return[{value:"",label:e.required?"Choose one":"None chosen"},...n.map(r=>({value:r,label:r===s?`${r} (default)`:r}))]}function X6(e,n,s,r=n){if(!s)return e.message;switch(e.reason){case"missing":return`${r} is required.`;case"wrong_type":return s.array?`${r} takes a list, one item a line.`:`${r} takes ${s.type==="integer"?"a whole number":s.type==="number"?"a number":s.type==="boolean"?"yes or no":"text"}.`;case"not_an_option":return`${r} takes one of: ${eE(s).join(", ")}.`;case"bad_format":return`${r} isn't in the form its description asks for.`;default:return e.message}}const eE=e=>{var n;return(n=e.enum)!=null&&n.length?e.enum.map(String):yd(e)??[]};function tE(e,n){var c;if(e.array){const d=iy(n);return d.length?d.every(u=>tE({...e,array:!1,required:!0},u)):!e.required}if(n==="")return!e.required;const s=yd(e);if(s)return s.includes(n);const r=Number(n),a=(e.minimum===void 0||r>=e.minimum)&&(e.maximum===void 0||r<=e.maximum);if(e.type==="integer")return n.trim()!==""&&Number.isSafeInteger(r)&&a;if(e.type==="number")return n.trim()!==""&&Number.isFinite(r)&&a;if(e.type==="boolean")return(n==="true"||n==="false")&&(!((c=e.enum)!=null&&c.length)||eE(e).includes(n));const i=[...n].length;if(e.minLength!==void 0&&i<e.minLength||e.maxLength!==void 0&&i>e.maxLength)return!1;if(e.pattern)try{return new RegExp(e.pattern,"u").test(n)}catch{return!0}return!0}const iy=e=>(e??"").split(`
|
|
651
|
+
`).map(n=>n.trim()).filter(n=>n!==""),nE=tE,Oa=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Z6=new Set(["string","number","integer","boolean"]),e8=["oneOf","anyOf","allOf","not","if","$ref","const"],fx=e=>e8.some(n=>n in e),Yu=e=>typeof e=="string"?e:void 0,Qu=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,t8=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0));function n8(e,n){if(!Oa(e)||fx(e))return null;const s=e.type==="array",r=s?e.items:e;if(!Oa(r)||fx(r)||typeof r.type!="string"||!Z6.has(r.type))return null;const a=Array.isArray(r.enum)&&r.enum.every(i=>["string","number","boolean"].includes(typeof i))?r.enum:void 0;return t8({type:r.type,...s?{array:!0}:{},required:n,title:Yu(e.title),description:Yu(e.description),examples:Array.isArray(e.examples)?e.examples:void 0,default:e.default,enum:a,pattern:Yu(r.pattern),format:Yu(r.format),minimum:Qu(r.minimum),maximum:Qu(r.maximum),minLength:Qu(r.minLength),maxLength:Qu(r.maxLength)})}function Gm(e,n){const s=Oa(e)&&Oa(e.properties)?e.properties:{},r=Oa(e)&&Array.isArray(e.required)?e.required:[],a=[];for(const[i,c]of Object.entries(s)){if(i===n)continue;const d=n8(c,r.includes(i));if(!d)return null;a.push([i,d])}return a}function s8(e){if(!Oa(e))return{kind:"message"};const n=()=>({kind:"json",example:XC(e)});if(fx(e))return n();const s=Oa(e.properties)?e.properties:{},r=Array.isArray(e.required)?e.required.filter(i=>typeof i=="string"):[];if(r.some(i=>i!=="content"&&!Object.hasOwn(s,i)))return n();const a=Gm(e,"content");return a?a.length?{kind:"fields",form:{fields:a,contentRequired:r.includes("content")||!r.some(i=>i!=="content")}}:{kind:"message"}:n()}const qm=(e,n)=>n.title||e;function r8(e){var s;const n=(s=e.examples)!=null&&s.length?e.examples[0]:e.default;if(n!=null)return Array.isArray(n)?n.map(String).join(`
|
|
652
|
+
`):typeof n=="object"?JSON.stringify(n):String(n)}function o8(e,n){const s=r=>e.type==="number"||e.type==="integer"?r.trim()!==""&&Number.isFinite(Number(r))?Number(r):r:e.type==="boolean"?r==="true"?!0:r==="false"?!1:r:r;if(e.array){const r=iy(n);return r.length?r.map(s):e.required?[]:void 0}return e.type==="boolean"?n==="true"||n==="false"?n==="true":e.required?!1:void 0:n===void 0||n===""?e.required&&e.type==="string"?"":void 0:s(n)}function sE(e){const n=q6(Object.fromEntries(e.fields));for(const[s,r]of e.fields){const a=r.array?null:yd(r);a&&r.default!==void 0&&a.includes(String(r.default))&&(n[s]=String(r.default))}return n}function Km(e,n){const s={};for(const[r,a]of e.fields){const i=o8(a,n[r]);i!==void 0&&(s[r]=i)}return s}const a8=(e,n,s)=>({...n.trim()?{content:n}:{},...Km(e,s)}),mx=(e,n="input")=>e.startsWith(`${n}.`)?e.slice(n.length+1).split(".")[0]:null,rE=e=>e.type==="integer"?"a whole number":e.type==="number"?"a number":e.type==="boolean"?"true or false":"text",i8={string:"text",integer:"whole numbers",number:"numbers",boolean:"true or false"},l8=e=>e.array?`a list of ${i8[e.type]}`:rE(e);function oE(e,n,s){var a;const r=qm(n,s);return s.array&&e.reason==="wrong_type"?e.field.endsWith(`.${n}`)?`${r} takes a list, one item a line.`:`Each line of ${r} is ${rE(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(", ")}.`:X6(e,n,s,r)}const c8={date:"date",email:"email",uri:"url"};function aE({field:e,label:n,help:s,value:r,onChange:a}){const i=r8(e),c=J6(e);return t.jsxs("label",{className:"block",children:[t.jsxs("span",{className:"caps text-small font-semibold",children:[n,e.required&&t.jsx("span",{className:"text-destructive-text",children:" *"})]}),t.jsxs("span",{className:"mb-1.5 block text-small text-muted-foreground",children:[s,e.array&&t.jsxs(t.Fragment,{children:[s?" ":"","One a line."]})]}),c?t.jsx(At,{label:n,className:"w-full",value:r,onChange:a,options:c}):e.array?t.jsx(ln,{rows:3,value:r,required:e.required,placeholder:i,onChange:d=>a(d.target.value),className:"resize-y leading-[1.6]"}):e.format==="cron"&&e.type==="string"?t.jsx(QC,{label:n,value:r,onChange:a}):e.format==="timezone"&&e.type==="string"?t.jsx(JC,{label:n,className:"w-full",value:r,onChange:a}):e.type==="boolean"?t.jsx("input",{type:"checkbox",className:"size-4 accent-primary",checked:r==="true",onChange:d=>a(d.target.checked?"true":"false")}):t.jsx(Ie,{type:e.type==="string"?c8[e.format??""]??"text":"number",step:e.type==="integer"?1:"any",value:r,required:e.required,placeholder:i,min:e.minimum,max:e.maximum,minLength:e.minLength,maxLength:e.maxLength,onChange:d=>a(d.target.value)})]})}function Mo({issues:e,named:n=!1,words:s=r=>r.message}){return e.length?t.jsx("ul",{className:"mt-1.5 space-y-1 text-small text-destructive-text",role:"alert",children:e.map((r,a)=>t.jsxs("li",{children:[n&&t.jsxs("span",{className:"font-mono",children:[r.field," "]}),s(r),r.fix&&t.jsx("span",{className:"block text-foreground/80",children:r.fix})]},`${r.field}:${a}`))}):null}const iE={standard:"The event is the JSON body's top-level type (Standard Webhooks), such as issue.opened. Conditions read the body: /title is its title.",github:"The event is the X-GitHub-Event header: pull_request, issue_comment, push. Conditions read the body."},d8='One value a line. A number, true, false or null is that JSON value, and so is a line in double quotes ("42" is the text 42) or a {…} or […]. Any other line is its text.',Ec=(e,n)=>e[n]?t.jsx("span",{"data-issue":n,children:e[n]}):void 0,so=({issues:e,field:n})=>e[n]?t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:t.jsx("span",{"data-issue":n,children:e[n]})}):null;function ly({name:e,at:n,where:s,onChange:r,issues:a,label:i}){const c=(f,x)=>r(s.map((b,g)=>g===f?{...b,...x}:b)),d=(f,x)=>c(f,x==="prefix"?{op:x,value:s[f].value.split(/\r\n|\r|\n/).find(b=>b.trim())??""}:{op:x}),u=s.length>=xd.conditions;return t.jsxs("div",{className:"min-w-0 space-y-2",children:[t.jsxs("p",{className:"caps text-small font-semibold",children:[i," ",t.jsx("span",{className:"font-normal normal-case text-muted-foreground",children:"(optional)"})]}),s.length>0&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Each names a field of the body as a JSON pointer (/title, /issue/labels/0/name) and a test; all of them must hold."}),t.jsx(so,{issues:a,field:`${n}.where`}),s.map((f,x)=>{const b=`${n}.where[${x}]`,g=`${e}-where-${x}`;return t.jsxs("div",{"data-condition":g,className:"space-y-3 border p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t.jsx(jt,{label:"Field",className:"min-w-40 flex-1",error:Ec(a,`${b}.pointer`),children:t.jsx(Ie,{name:`${g}-pointer`,value:f.pointer,onChange:h=>c(x,{pointer:h.target.value}),placeholder:"/title",autoComplete:"off",spellCheck:!1})}),t.jsx(Zc,{name:`${g}-op`,label:`Condition ${x+1}'s test`,value:f.op,onChange:h=>d(x,h),options:e6.map(h=>({value:h,label:$C[h]}))}),t.jsx(B,{type:"button",size:"icon",variant:"ghost","aria-label":`Remove condition ${x+1}`,onClick:()=>r(s.filter((h,v)=>v!==x)),children:t.jsx(Qo,{"aria-hidden":!0})})]}),f.op==="in"&&t.jsx(jt,{label:"Values",hint:d8,error:Ec(a,`${b}.in`),children:t.jsx(ln,{name:`${g}-value`,rows:3,value:f.value,onChange:h=>c(x,{value:h.target.value}),spellCheck:!1})}),f.op==="prefix"&&t.jsx(jt,{label:"Text",hint:"Its first line, trimmed, starts with this, in any case.",error:Ec(a,`${b}.prefix`),children:t.jsx(Ie,{name:`${g}-value`,value:f.value,onChange:h=>c(x,{value:h.target.value}),autoComplete:"off",spellCheck:!1})}),t.jsx(so,{issues:a,field:b}),t.jsx(so,{issues:a,field:`${b}.exists`})]},f.key)}),t.jsxs(B,{type:"button",size:"sm",onClick:()=>r([...s,n6()]),disabled:u,children:[t.jsx(dl,{"aria-hidden":!0})," Add a condition"]})]})}function lE({name:e,rules:n,onChange:s,issues:r,indexOf:a=x=>x,room:i,eventHint:c,eventPlaceholder:d,addLabel:u="Add a rule",empty:f}){const x=(b,g)=>s(n.map((h,v)=>v===b?{...h,...g}:h));return t.jsxs("div",{className:"min-w-0 space-y-3",children:[!n.length&&f,n.map((b,g)=>{const h=`source.accept[${a(g)}]`,v=`${e}-${g}`;return t.jsxs("section",{"data-rule":v,"aria-label":`Rule ${g+1}`,className:"space-y-4 border p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Rule ",g+1]}),t.jsxs(B,{type:"button",size:"xs",variant:"ghost","aria-label":`Remove rule ${g+1}`,onClick:()=>s(n.filter((y,j)=>j!==g)),children:[t.jsx(NN,{"aria-hidden":!0})," Remove"]})]}),t.jsx(so,{issues:r,field:h}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(jt,{label:"Event",hint:c,error:Ec(r,`${h}.event`),children:t.jsx(Ie,{name:`${v}-event`,value:b.event,onChange:y=>x(g,{event:y.target.value}),placeholder:d,autoComplete:"off",spellCheck:!1})}),t.jsx(jt,{label:"Actions",optional:!0,hint:"The body's top-level action is one of these, split by commas (opened, edited). None: any action, or none.",error:Ec(r,`${h}.actions`),children:t.jsx(Ie,{name:`${v}-actions`,value:b.actions,onChange:y=>x(g,{actions:y.target.value}),placeholder:"opened, edited",autoComplete:"off",spellCheck:!1})})]}),t.jsx(ly,{name:v,at:h,where:b.where,onChange:y=>x(g,{where:y}),issues:r,label:"Only when"})]},b.key)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>s([...n,_C()]),disabled:i<=0,children:[t.jsx(dl,{"aria-hidden":!0})," ",u]}),i<=0&&t.jsxs("span",{className:"text-small text-muted-foreground",children:[xd.rules," rules, the most a trigger takes."]})]})]})}const Ws=e=>`#/triggers/${encodeURIComponent(e)}`,qf=e=>mt(e),u8={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function f8({v2:e,view:n,go:s,agentName:r,minEvery:a,failuresToPause:i,publicUrl:c,refreshMs:d=15e3,now:u=Date.now}){const f=c===!1;return n.trigger===void 0?t.jsx(p8,{v2:e,go:s,agentName:r,every:d*2,now:u,failuresToPause:i,noAddress:f}):n.trigger===null?n.kind==="webhook"?t.jsx(k8,{v2:e,go:s}):n.kind==="github"?t.jsx(N8,{v2:e,go:s}):n.kind==="composio"?t.jsx(S8,{v2:e,go:s,noAddress:f}):t.jsx(hE,{v2:e,go:s,minEvery:a,now:u}):n.edit?t.jsx(w8,{v2:e,go:s,id:n.trigger,minEvery:a,now:u},n.trigger):t.jsx(b8,{v2:e,go:s,agentName:r,id:n.trigger,every:d,now:u,failuresToPause:i},n.trigger)}function cE(e,n,s){const r=p.useRef(e);r.current=e,p.useEffect(()=>{const a=()=>document.visibilityState!=="hidden",i=setInterval(()=>{a()&&r.current()},n),c=()=>{a()&&r.current()};return document.addEventListener("visibilitychange",c),()=>{clearInterval(i),document.removeEventListener("visibilitychange",c)}},[n,...s])}const dE=e=>e?"ran"in e?`Done · ran ${qf(e.ran.nominal_at)}`:`Its time passed · ${qf(e.passed)}`:null,m8=/has already passed\.?$/;function uE({trigger:e}){return e.disabled?t.jsx(je,{tone:"warning",children:"Turned off"}):t.jsx(je,{tone:"muted",children:"Paused"})}const h8=e=>e.last_firing?`${GC(e.last_firing)}${e.last_firing.catch_up?" · caught up late":""} · ${qf(e.last_firing.nominal_at)}`:"Not fired yet",cy="App triggers need this server's public address: set AGENTRUN_PUBLIC_URL and restart.";function p8({v2:e,go:n,agentName:s,every:r,now:a,failuresToPause:i,noAddress:c}){const[d,u]=p.useState(null),[f,x]=p.useState(null),[b,g]=p.useState(0),h=p.useRef(!1),v=p.useRef(!0);p.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const y=()=>{h.current||(h.current=!0,e.listTriggers().then(j=>{v.current&&(u(j.triggers),x(null))},j=>{v.current&&x(Ft(j,"the triggers"))}).finally(()=>{h.current=!1}))};return p.useEffect(y,[e,b]),cE(y,r,[e]),t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[t.jsx("h1",{className:"mr-auto font-mono text-2xl font-semibold",children:"Triggers"}),!(d&&!d.length)&&t.jsxs(t.Fragment,{children:[t.jsxs(B,{size:"lg",disabled:c,onClick:()=>n("#/triggers/new-composio"),children:[t.jsx(Zf,{"aria-hidden":!0})," New app trigger"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-github"),children:[t.jsx(nm,{"aria-hidden":!0})," New GitHub trigger"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-webhook"),children:[t.jsx(Zi,{"aria-hidden":!0})," New webhook"]}),t.jsxs(B,{size:"lg",variant:"solid",onClick:()=>n("#/triggers/new"),children:[t.jsx(dl,{"aria-hidden":!0})," New schedule"]})]})]}),c&&d&&d.length>0&&t.jsx("p",{className:"-mt-2 mb-4 text-small text-muted-foreground",children:cy}),f&&!d?t.jsx(Kt,{problem:f,onRetry:()=>g(j=>j+1),className:""}):d?d.length?t.jsx("ul",{className:"border",children:d.map(j=>t.jsxs("li",{"data-trigger":j.id,className:"grid grid-cols-1 gap-x-6 gap-y-1.5 border-b px-4 py-3 last:border-b-0 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("a",{href:Ws(j.id),className:"min-w-0 break-words text-prose font-semibold hover:underline",children:j.name}),t.jsx(je,{children:x8[j.source.kind]}),!j.enabled&&!ey(j,a())&&t.jsx(uE,{trigger:j})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:fE(j),children:v8(j,s,a())}),Uf(j,i)&&t.jsx("p",{className:"mt-1 break-words text-small text-warning-text",children:Uf(j,i)})]}),t.jsx("div",{className:"min-w-0 font-mono text-small text-muted-foreground md:text-right",children:t.jsx("p",{className:"break-words",children:h8(j)})})]},j.id))}):t.jsx(g8,{go:n,noAddress:c}):t.jsx(Fn,{label:"Loading the triggers",rows:4}),d&&f&&t.jsx(Kt,{problem:f,className:"mt-4"})]})}function g8({go:e,noAddress:n}){const s=[{Icon:em,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:Zi,name:"Webhook",what:"On each signed request another system sends to its URL.",action:"New webhook",to:"#/triggers/new-webhook"},{Icon:nm,name:"GitHub",what:"On the events you pick from this server's GitHub App. Connect GitHub in Settings first.",action:"New GitHub trigger",to:"#/triggers/new-github"},{Icon:Zf,name:"From an app",what:"On an event in an app a saved Composio server connects, such as a new issue in a GitHub repository. Save the server in Settings first.",action:"New app trigger",to:"#/triggers/new-composio"}];return t.jsxs("section",{"aria-labelledby":"first-trigger",className:"border border-primary/50 bg-primary/5 p-5",children:[t.jsx("p",{className:"caps text-label text-primary-text",children:"No triggers yet"}),t.jsx("h2",{id:"first-trigger",className:"mt-2 text-xl font-semibold",children:"Start runs without being here"}),t.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A trigger starts a run of an agent for you, and each run it starts stops at a spend cap. Pick what should start it."}),t.jsx("ul",{className:"mt-5 grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4",children:s.map(({Icon:r,name:a,what:i,action:c,to:d})=>t.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[t.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[t.jsx(r,{className:"size-4 text-primary-text","aria-hidden":!0}),a]}),t.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:i}),n&&d==="#/triggers/new-composio"&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:cy}),t.jsx(B,{size:"sm",variant:d==="#/triggers/new"?"solid":"outline",className:"mt-4 self-start",disabled:n&&d==="#/triggers/new-composio",onClick:()=>e(d),children:c})]},a))})]})}const x8={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email"},fE=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function v8(e,n,s){return`${e.source.kind==="schedule"?Zv(e.source,e.next_at,{instead:dE(ey(e,s)),now:s}):e.source.kind==="github"?BC(e.source):e.source.kind==="composio"?HC(e.source):e.source.kind==="email"?p6(e.source):WC(e.source)} · ${e.target.kind==="start_run"?n(e.target.agent_id)||e.target.agent_id:`messages run ${ea(e.target.run_id)}`}`}const y8={on:"On",off:"Off",missing:"Composio no longer has it: delete this trigger and make it again.",unknown:"Composio didn't say"};function mE(){return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsx("p",{className:"mt-4 border px-4 py-6 text-body text-muted-foreground",children:"This trigger sends its firings to a run: this page doesn't open it yet."})]})}function b8({v2:e,go:n,agentName:s,id:r,every:a,now:i,failuresToPause:c}){var qe,rt,vt,st;const[d,u]=p.useState(null),[f,x]=p.useState([]),[b,g]=p.useState(null),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,$]=p.useState(!1),[S,N]=p.useState(!1),[_,E]=p.useState(null),O=p.useRef(!1),[A,I]=p.useState(!1),[M,R]=p.useState(null),[P,D]=p.useState(null),[W,Y]=p.useState(null),[H,q]=p.useState(0),F=p.useRef(!1),G=p.useRef(!1),U=p.useRef(0),z=()=>{G.current=!0;const Se=U.current;return Promise.all([e.getTrigger(r),e.triggerFirings(r)]).then(([Be,he])=>{Se===U.current&&(u(Be),x(he.firings),g(null))}).finally(()=>{G.current=!1})};p.useEffect(()=>{z().catch(Se=>g(Ft(Se,"the trigger")))},[e,r,H]),cE(()=>{!G.current&&!F.current&&W===null&&z().catch(()=>{})},a,[e,r]);const[Q,K]=p.useState(void 0),Z=d&&d.target.kind==="start_run"&&typeof d.target.max_cost_usd!="number"?d.target.agent_id:null;p.useEffect(()=>{if(!Z)return;let Se=!0;return e.getAgent(Z).then(Be=>{Se&&K(typeof Be.agent.definition.max_cost_usd=="number"?Be.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{Se=!1}},[e,Z]);const de=(d==null?void 0:d.source.kind)==="composio"?d.source.server:null;if(p.useEffect(()=>{if(!de)return;let Se=!0;return e.composioTriggers(de).then(Be=>{var he;Se&&R(((he=Be.triggers.find(Ve=>Ve.id===r))==null?void 0:he.on_composio)??"unknown")},()=>{Se&&R(null)}),()=>{Se=!1}},[e,de,r,d==null?void 0:d.enabled]),W!==null)return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsx("h1",{className:"mt-3 break-words text-2xl font-semibold leading-tight",children:(d==null?void 0:d.name)??r}),t.jsx("p",{className:"mt-2 text-body",children:"Deleted here. Its runs stay."}),t.jsx("p",{role:"status","data-composio-note":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:W}),t.jsx("a",{href:"#/triggers",className:"mt-4 inline-block text-body underline underline-offset-2",children:"All triggers"})]});if(!d)return b?t.jsx(Kt,{problem:b,onRetry:()=>q(Se=>Se+1),link:{href:"#/triggers",label:"All triggers"}}):t.jsx(Fn,{label:"Loading the trigger",rows:4});const re=ny(d)?d:null,fe=UC(d)?d:null,ve=ry(d)?d:null;if(!re&&!fe&&!ve&&!ty(d))return t.jsx(mE,{});const Ee=d,ue=ey(d,i(),f),pe=async(Se,Be,he)=>{j(Se),v(null);try{await Be()}catch(Ve){v(Ft(Ve,he))}finally{j(null)}},me=()=>pe("pause",async()=>{U.current++,D(null);const{composio:Se,...Be}=await e.updateTrigger(r,{enabled:!d.enabled});U.current++,u(Be),D((Se==null?void 0:Se.note)??null)},d.enabled?"the pause":"the resume"),ke=()=>pe("delete",async()=>{const Se=await e.deleteTrigger(r);Se!=null&&Se.composio?Y(Se.composio.note):n("#/triggers")},"the delete"),$e=async()=>{if(!O.current){O.current=!0,I(!0),v(null),E(null);try{E((await e.rotateTriggerSecret(r)).signing_secret??null)}catch(Se){v(Ft(Se,"the new secret"))}finally{O.current=!1,I(!1)}}},J=async()=>{if(!F.current){F.current=!0,j("fire"),v(null),U.current++;try{const Se=await e.fireTrigger(r,gd());U.current++,x(Be=>[Se,...Be.filter(he=>he.key!==Se.key)]),await z().catch(()=>{})}catch(Se){v(Ft(Se,"the run now"))}finally{F.current=!1,j(null)}}},Le=typeof Ee.target.input.content=="string"?Ee.target.input.content:null;return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsxs("div",{className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 sm:flex-row",children:[t.jsxs("div",{className:"min-w-0 flex-1 self-stretch",children:[t.jsxs("h1",{className:"flex flex-wrap items-center gap-2 break-words text-2xl font-semibold leading-tight",children:[d.name,!d.enabled&&!ue&&t.jsx(uE,{trigger:d})]}),t.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:re?`Webhook · ${WC(re.source)}`:fe?`GitHub · ${BC(fe.source)}`:ve?`App · ${HC(ve.source)}`:t.jsx("span",{title:fE(d),children:Zv(Ee.source,d.next_at,{instead:dE(ue),now:i()})})})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 self-stretch sm:self-auto",children:[!(ue&&"ran"in ue)&&t.jsx(B,{size:"sm",onClick:()=>void me(),disabled:y!==null,children:d.enabled?t.jsxs(t.Fragment,{children:[t.jsx(Xi,{"aria-hidden":!0})," Pause"]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{"aria-hidden":!0})," Resume"]})}),t.jsxs(B,{size:"sm",onClick:()=>n(`${Ws(r)}/edit`),children:[t.jsx(Mx,{"aria-hidden":!0})," ",re||fe||ve?"Edit filter":"Edit"]}),re&&(S?t.jsxs("span",{className:"flex items-center gap-2 border border-warning/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Make a new secret?",children:[t.jsx("span",{children:"The old secret stops signing at once."}),t.jsx(B,{size:"sm",variant:"solid",onClick:()=>{N(!1),$e()},children:"Yes, make a new one"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>N(!1),children:"Keep"})]}):t.jsxs(B,{size:"sm",onClick:()=>N(!0),disabled:y!==null||A,children:[t.jsx(Ma,{"aria-hidden":!0})," Rotate secret"]})),k?t.jsxs("span",{className:"flex items-center gap-2 border border-destructive/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Delete this trigger?",children:[t.jsx("span",{children:"Delete for good? Its runs stay."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>{$(!1),ke()},children:"Yes, delete"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>$(!1),children:"Keep"})]}):t.jsxs(B,{size:"sm",variant:"destructive",onClick:()=>$(!0),disabled:y!==null,children:[t.jsx(NN,{"aria-hidden":!0})," Delete"]}),t.jsxs(B,{size:"sm",variant:"solid",onClick:()=>void J(),disabled:y==="fire",children:[t.jsx(_T,{"aria-hidden":!0})," ",y==="fire"?"Starting":"Run now"]})]})]}),Uf(d,c)&&t.jsxs("p",{role:"status","data-disabled":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:[Uf(d,c)," ",((qe=d.disabled)==null?void 0:qe.reason)==="source_unreadable"?"Edit its when, then Resume.":((rt=d.disabled)==null?void 0:rt.reason)==="auto_paused"?ue&&"passed"in ue?"Its time has passed: edit its time first, then Resume.":ue?"":"Resume turns it on again.":""]}),h&&t.jsx(Kt,{problem:h,className:"mt-4"}),P&&t.jsx("p",{role:"status","data-composio-note":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:P}),re&&_&&t.jsx(dy,{label:"The webhook's new secret",secret:_}),t.jsxs("dl",{className:"mt-5 grid grid-cols-1 gap-x-6 gap-y-3 border p-4 text-body sm:grid-cols-[max-content_minmax(0,1fr)]",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Agent"}),t.jsx("dd",{className:"min-w-0 break-words",children:t.jsx("a",{href:on(Ee.target.agent_id),className:"hover:underline",children:s(Ee.target.agent_id)||Ee.target.agent_id})}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Each run is asked"}),t.jsx("dd",{className:"min-w-0 whitespace-pre-wrap break-words",children:Le??JSON.stringify(Ee.target.input)}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),t.jsx("dd",{className:"font-mono",children:m6(Ee.target.max_cost_usd,Q)}),re?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"URL"}),t.jsxs("dd",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("code",{className:"min-w-0 break-all font-mono text-small",children:Wc(re)}),t.jsx(pE,{text:Wc(re),label:"Copy URL"}),t.jsx("span",{className:"basis-full text-small text-muted-foreground",children:sy})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("dd",{children:dx[re.source.signature??"standard"]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(vt=re.source.accept)!=null&&vt.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:re.source.accept.map((Se,Be)=>t.jsx("li",{children:Yi(Se)},Be))}):"Every signed request"})]}):ve?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"App"}),t.jsxs("dd",{className:"min-w-0 break-words",children:[t.jsx("a",{href:"#/settings/mcp",className:"font-mono hover:underline",children:ve.source.server}),t.jsx("span",{className:"text-small text-muted-foreground",children:" · a saved Composio server"})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Event"}),t.jsx("dd",{className:"min-w-0 break-words font-mono",children:ve.source.event}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Config"}),t.jsx("dd",{className:"min-w-0 break-words",children:Object.keys(ve.source.config).length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:Object.entries(ve.source.config).map(([Se,Be])=>t.jsxs("li",{children:[Se,": ",typeof Be=="string"?Be:JSON.stringify(Be)]},Se))}):"None"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(st=ve.source.accept)!=null&&st.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ve.source.accept.map((Se,Be)=>t.jsx("li",{children:Yi(Se)},Be))}):"Every event of its instance"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"At Composio"}),t.jsx("dd",{className:"min-w-0 break-words",children:M?t.jsx("span",{"data-on-composio":M,className:M==="missing"?"text-warning-text":void 0,children:y8[M]}):t.jsx("span",{className:"text-muted-foreground",children:"Not read"})})]}):fe?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsxs("dd",{className:"min-w-0 break-words",children:[t.jsx("ul",{className:"space-y-1 font-mono text-small",children:fe.source.accept.map((Se,Be)=>t.jsx("li",{children:Yi(Se)},Be))}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"While a run is going"}),t.jsx("dd",{children:"The next time is skipped."})]})]}),t.jsxs("section",{className:"mt-6","aria-label":"Firings",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Firings"}),f.length?t.jsx("ul",{className:"mt-3 border",children:f.map(Se=>t.jsxs("li",{"data-firing":Se.key,className:"flex flex-col gap-1 border-b px-4 py-2.5 text-body last:border-b-0 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(je,{tone:u8[Se.status],children:g6[Se.status]}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:qf(Se.nominal_at)})]}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:Se.status==="started"?`${h6[Se.by]}${Se.catch_up?", caught up late":""}`:`${GC(Se)}${Se.catch_up?" · caught up late":""}${Se.by==="manual"?" · Run now":""}`}),Se.run_id&&t.jsxs("a",{href:`#/runs/${encodeURIComponent(Se.run_id)}`,className:"shrink-0 font-mono text-small underline-offset-2 hover:underline",children:["Run ",ea(Se.run_id)]})]},Se.key))}):t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function w8({v2:e,go:n,id:s,minEvery:r,now:a}){const[i,c]=p.useState(null),[d,u]=p.useState(null),[f,x]=p.useState(0);return p.useEffect(()=>{e.getTrigger(s).then(c,b=>u(Ft(b,"the trigger")))},[e,s,f]),i?ny(i)||UC(i)||ry(i)?t.jsx($8,{v2:e,go:n,trigger:i}):ty(i)?t.jsx(hE,{v2:e,go:n,trigger:i,minEvery:r,now:a}):t.jsx(mE,{}):d?t.jsx(Kt,{problem:d,onRetry:()=>x(b=>b+1)}):t.jsx(Fn,{label:"Loading the trigger",rows:4})}function Jt({label:e,field:n,issue:s,hint:r,children:a}){return t.jsx(jt,{className:"min-w-0",label:e,hint:r,error:s?t.jsx("span",{"data-issue":n,children:s}):void 0,children:a})}const Vm=e=>e!==void 0?`${Xa(e)}, the agent's default`:void 0;async function Ym(e){const n=[];let s=null;for(let r=0;r<20;r++){const a=await e.listAgents({cursor:s});if(n.push(...a.agents),s=a.next_cursor,!s)break}return n}function hE({v2:e,go:n,trigger:s,minEvery:r,now:a=Date.now}){var D,W,Y;const[i,c]=p.useState(()=>s?R6(s):LC()),[d,u]=p.useState(null),[f,x]=p.useState({}),[b,g]=p.useState([]),[h,v]=p.useState(!1),y=p.useRef(dr()).current;p.useEffect(()=>{Ym(e).then(u,()=>u([]))},[e]);const j=H=>q=>c(F=>({...F,[H]:q})),k=H=>{var F;j("at")(H);const q=zi(H,(F=i.read)==null?void 0:F.at);q!==null&&Date.parse(q)>a()?x(({"source.at":G,...U})=>U):q!==null&&x(G=>G["source.at"]?{...G,"source.at":f0(q,{now:a()})}:G)},$=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"]]),S=(D=(d??[]).find(H=>H.agent_id===i.agentId))==null?void 0:D.definition.max_cost_usd,N=typeof S=="number"&&S>0?S:void 0,_=N!==void 0||!!s&&typeof s.target.max_cost_usd!="number"&&i.agentId===s.target.agent_id,E=async H=>{var G;H.preventDefault();const{body:q,issues:F}=h0(i,_);if(g([]),!q){x(F??{});return}x({}),v(!0);try{if(s){const U=p0(s,q);Object.keys(U).length&&await e.updateTrigger(s.id,U),n(Ws(s.id))}else{const U=await e.createTrigger(q,y.keyFor("createTrigger",q));n(Ws(U.id))}}catch(U){const z=vd(U),Q=i.kind==="at"?zi(i.at,(G=i.read)==null?void 0:G.at):null,K=z.fields["source.at"];K&&Q!==null&&(Date.parse(Q)<=a()||m8.test(K))&&(z.fields["source.at"]=f0(Q,{now:a()})),x(Object.fromEntries(Object.entries(z.fields).filter(([Z])=>$.has(Z)))),g([...z.rest,...Object.entries(z.fields).filter(([Z])=>!$.has(Z)).map(([,Z])=>Z)]),v(!1)}},O=s?h0(i,_).body:void 0,A=!!(s&&O&&p0(s,O).source),I=i.kind==="at"?zi(i.at,(W=i.read)==null?void 0:W.at):null,M=i.startAt?zi(i.startAt,(Y=i.read)==null?void 0:Y.startAt):null,R=sd((d??[]).filter(H=>!H.archived_at||H.agent_id===i.agentId)),P=[{kind:"cron",label:"Repeats"},{kind:"at",label:"Once"},{kind:"every",label:"Every"}];return t.jsxs("form",{onSubmit:H=>void E(H),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Ws(s.id):"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," ",s?s.name:"Triggers"]}),t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(em,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit schedule":"New schedule"]}),b.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:b.map((H,q)=>t.jsx("p",{children:H},q))}),t.jsxs("div",{className:"mt-5 space-y-5",children:[t.jsx(Jt,{label:"Name",field:"name",issue:f.name,children:t.jsx(Ie,{name:"name",value:i.name,onChange:H=>j("name")(H.target.value),placeholder:"nightly triage"})}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"When"}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:P.map(({kind:H,label:q})=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${i.kind===H?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"kind",value:H,checked:i.kind===H,onChange:()=>j("kind")(H),className:"accent-primary"}),q]},H))}),t.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[i.kind==="cron"&&t.jsx(Jt,{label:"Runs",field:"source.cron",issue:f["source.cron"],children:t.jsx(QC,{label:"Runs",name:"cron",value:i.cron,onChange:j("cron")})}),i.kind==="at"&&t.jsx(Jt,{label:"At, your time",field:"source.at",issue:f["source.at"],hint:I?`= ${m0(I)}`:void 0,children:t.jsx(Ie,{name:"at",type:"datetime-local",step:60,value:i.at,onChange:H=>k(H.target.value)})}),i.kind==="every"&&t.jsx(Jt,{label:"Every",field:"source.every_s",issue:f["source.every_s"],hint:r?y6(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Ie,{name:"every",inputMode:"decimal",value:i.every,onChange:H=>j("every")(H.target.value),placeholder:"5"}),t.jsx(At,{id:"schedule-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:i.everyUnit,onChange:H=>j("everyUnit")(H),options:["seconds","minutes","hours"].map(H=>({value:H,label:H}))})]})}),i.kind==="cron"&&t.jsx(Jt,{label:"Time zone",field:"source.timezone",issue:f["source.timezone"],hint:"The time zone this schedule runs in.",children:t.jsx(JC,{name:"timezone",label:"Time zone",className:"w-full",value:i.timezone,onChange:j("timezone")})}),i.kind==="every"&&t.jsx(Jt,{label:"Starting, your time (optional)",field:"source.start_at",issue:f["source.start_at"],hint:M?`= ${m0(M)}`:void 0,children:t.jsx(Ie,{name:"startAt",type:"datetime-local",step:60,value:i.startAt,onChange:H=>j("startAt")(H.target.value)})})]}),A&&t.jsx("p",{className:"mt-3 text-small text-warning-text",role:"note",children:"Changing when restarts the schedule from now."})]}),t.jsx(Jt,{label:"Agent",field:"target.agent_id",issue:f["target.agent_id"],children:t.jsx(At,{name:"agent",label:"Agent",className:"w-full",value:i.agentId,onChange:H=>j("agentId")(H),options:[{value:"",label:d?"Pick an agent":"Loading the agents"},...R.map(H=>({value:H.agent_id,label:`${H.definition.name||H.agent_id}${H.kind==="workflow"?" (workflow)":""}`})),...i.agentId&&d&&!R.some(H=>H.agent_id===i.agentId)?[{value:i.agentId,label:i.agentId}]:[]]})}),t.jsx(Jt,{label:"Each run is asked",field:"target.input",issue:f["target.input"],children:t.jsx(ln,{name:"content",rows:4,className:"p-3 font-sans",value:i.content,onChange:H=>j("content")(H.target.value)})}),t.jsx(Jt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:f["target.max_cost_usd"],hint:N!==void 0?`Uses the agent's default (${Xa(N)}) if empty.`:_?"Uses the agent's default if empty.":"Required: each run this schedule starts stops at this spend.",children:t.jsx(Ie,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:i.maxCost,onChange:H=>j("maxCost")(H.target.value),placeholder:Vm(N)})}),!s&&t.jsxs("div",{children:[t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"enabled",checked:i.enabled,onChange:H=>j("enabled")(H.target.checked),className:"accent-primary"})," On from now (off: made paused)"]}),f.enabled&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"enabled",children:f.enabled})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:h,children:h?"Saving":s?"Save changes":"Create schedule"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(s?Ws(s.id):"#/triggers"),children:"Cancel"})]})]})}function pE({text:e,label:n}){const[s,r]=p.useState(null),a="The browser won't copy here. Select it and copy it.",i=()=>{const c=typeof navigator<"u"?navigator.clipboard:void 0;if(!(c!=null&&c.writeText)){r(a);return}c.writeText(e).then(()=>r("Copied"),()=>r(a))};return t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[t.jsxs(B,{type:"button",size:"sm",onClick:i,children:[t.jsx(Ba,{"aria-hidden":!0})," ",n]}),s&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:s})]})}function dy({label:e,secret:n,url:s}){return t.jsxs("section",{"aria-label":e,className:"mt-4 space-y-3 border border-primary/50 p-4 text-body",children:[s&&t.jsx(hx,{title:"URL",text:s,label:"Copy URL",hint:sy}),t.jsx(hx,{title:"Signing secret",text:n,label:"Copy secret"}),t.jsx("p",{className:"text-warning-text",role:"note",children:"You won't see this secret again."})]})}function hx({title:e,text:n,label:s,hint:r}){return t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"caps text-label text-muted-foreground",children:e}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("code",{className:"min-w-0 break-all border bg-muted/40 px-2 py-1 font-mono text-small",children:n}),t.jsx(pE,{text:n,label:s})]}),r&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:r})]})}const j8=["standard","github"];function k8({v2:e,go:n}){var _;const[s,r]=p.useState(b6),[a,i]=p.useState(null),[c,d]=p.useState({}),[u,f]=p.useState([]),[x,b]=p.useState(!1),[g,h]=p.useState(null),v=p.useRef(dr()).current;p.useEffect(()=>{Ym(e).then(i,()=>i([]))},[e]);const y=E=>O=>r(A=>({...A,[E]:O})),j=(_=(a??[]).find(E=>E.agent_id===s.agentId))==null?void 0:_.definition.max_cost_usd,k=typeof j=="number"&&j>0?j:void 0,$=async E=>{E.preventDefault();const O=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd",...Wm(s.accept.map(M=>M.where.length))]),{body:A,issues:I}=w6(s,k!==void 0);if(f([]),!A){d(I??{});return}d({}),b(!0);try{h(await e.createTrigger(A,v.keyFor("createTrigger",A)))}catch(M){const R=vd(M);d(Object.fromEntries(Object.entries(R.fields).filter(([P])=>O.has(P)))),f([...R.rest,...Object.entries(R.fields).filter(([P])=>!O.has(P)).map(([,P])=>P)])}finally{b(!1)}},S=t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]});if(g)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[S,t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(Zi,{className:"size-5 text-primary-text","aria-hidden":!0}),g.name]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:`Send each request to this URL, signed with this secret (${dx[g.source.kind==="webhook"?g.source.signature??"standard":"standard"]}). Each one starts a run.`}),g.signing_secret?t.jsx(dy,{label:"The webhook's URL and secret",url:Wc(g),secret:g.signing_secret}):t.jsxs("section",{"aria-label":"The webhook's URL and secret",className:"mt-4 space-y-3 border p-4 text-body",children:[t.jsx(hx,{title:"URL",text:Wc(g),label:"Copy URL",hint:sy}),g.note&&t.jsx("p",{role:"note",children:g.note})]}),t.jsx("div",{className:"mt-6",children:t.jsx(B,{type:"button",size:"lg",variant:"solid",onClick:()=>n(Ws(g.id)),children:"Done"})})]});const N=sd((a??[]).filter(E=>!E.archived_at));return t.jsxs("form",{onSubmit:E=>void $(E),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[S,t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(Zi,{className:"size-5 text-primary-text","aria-hidden":!0}),"New webhook"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each signed request to its URL starts a capped run of the agent. Its URL and signing secret show once it is made."}),u.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:u.map((E,O)=>t.jsx("p",{children:E},O))}),t.jsxs("div",{className:"mt-5 space-y-5",children:[t.jsx(Jt,{label:"Name",field:"name",issue:c.name,children:t.jsx(Ie,{name:"name",value:s.name,onChange:E=>y("name")(E.target.value),placeholder:"on deploy"})}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:j8.map(E=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${s.signature===E?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"signature",value:E,checked:s.signature===E,onChange:()=>y("signature")(E),className:"accent-primary"}),dx[E]]},E))}),c["source.signature"]&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.signature",children:c["source.signature"]})]}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Events from an app Composio connects start runs through an app trigger instead: ",t.jsx("a",{href:"#/triggers/new-composio",className:"underline underline-offset-2",children:"New app trigger"})]}),t.jsx(gE,{signature:s.signature,rules:s.accept,onChange:y("accept"),issues:c,cap:null}),t.jsx(Jt,{label:"Agent",field:"target.agent_id",issue:c["target.agent_id"],children:t.jsx(At,{name:"agent",label:"Agent",className:"w-full",value:s.agentId,onChange:E=>y("agentId")(E),options:[{value:"",label:a?"Pick an agent":"Loading the agents"},...N.map(E=>({value:E.agent_id,label:`${E.definition.name||E.agent_id}${E.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Jt,{label:"Each run is asked",field:"target.input",issue:c["target.input"],children:t.jsx(ln,{name:"content",rows:4,className:"p-3 font-sans",value:s.content,onChange:E=>y("content")(E.target.value)})}),t.jsx(Jt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:c["target.max_cost_usd"],hint:k!==void 0?`Uses the agent's default (${Xa(k)}) if empty.`:"Required: each run this webhook starts stops at this spend.",children:t.jsx(Ie,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:s.maxCost,onChange:E=>y("maxCost")(E.target.value),placeholder:Vm(k)})})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:x,children:x?"Creating":"Create webhook"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function N8({v2:e,go:n}){var R;const[s,r]=p.useState(null),[a,i]=p.useState(null),[c,d]=p.useState(0),[u,f]=p.useState(j6),[x,b]=p.useState(null),[g,h]=p.useState({}),[v,y]=p.useState([]),[j,k]=p.useState(!1),$=p.useRef(dr()).current,S=p.useRef(!0);p.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]),p.useEffect(()=>{let P=!0;return i(null),e.githubConnection().then(D=>{P&&r(!!D&&"app_id"in D&&!!D.app_id)},D=>{P&&(D instanceof ze&&D.status===404?r(!1):i(Ft(D,"GitHub's connection")))}),()=>{P=!1}},[e,c]),p.useEffect(()=>{Ym(e).then(b,()=>b([]))},[e]);const N=P=>D=>f(W=>({...W,[P]:D})),_=(R=(x??[]).find(P=>P.agent_id===u.agentId))==null?void 0:R.definition.max_cost_usd,E=typeof _=="number"&&_>0?_:void 0,O=async P=>{P.preventDefault();const D=new Set(["name","target.agent_id","target.input","target.max_cost_usd",...Wm(Bm(u).map(H=>H.where.length))]),{body:W,issues:Y}=T6(u,E!==void 0);if(y([]),!W){h(Y??{});return}h({}),k(!0);try{const H=await e.createTrigger(W,$.keyFor("createTrigger",W));S.current&&n(Ws(H.id))}catch(H){const q=vd(H);h(Object.fromEntries(Object.entries(q.fields).filter(([F])=>D.has(F)))),y([...q.rest,...Object.entries(q.fields).filter(([F])=>!D.has(F)).map(([,F])=>F)]),k(!1)}},A=t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),I=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(nm,{className:"size-5 text-primary-text","aria-hidden":!0}),"New GitHub trigger"]});if(a)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[A,I,t.jsx(Kt,{problem:a,onRetry:()=>d(P=>P+1),className:"mt-4"})]});if(s===null)return t.jsx(Fn,{label:"Reading GitHub's connection",rows:3});if(!s)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[A,I,t.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Connect GitHub first: ",t.jsx("a",{href:"#/settings/github",className:"underline underline-offset-2",children:"Settings → GitHub"}),". A GitHub trigger takes events from this server's GitHub App."]})]});const M=sd((x??[]).filter(P=>!P.archived_at));return t.jsxs("form",{onSubmit:P=>void O(P),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[A,I,t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event it takes from this server's GitHub App starts a capped run of the agent."}),v.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:v.map((P,D)=>t.jsx("p",{children:P},D))}),t.jsxs("div",{className:"mt-5 space-y-5",children:[t.jsx(Jt,{label:"Name",field:"name",issue:g.name,children:t.jsx(Ie,{name:"name",value:u.name,onChange:P=>N("name")(P.target.value),placeholder:"review PRs"})}),t.jsx(xE,{picks:u,onChange:P=>f(D=>({...D,...P})),issues:g}),t.jsx(Jt,{label:"Agent",field:"target.agent_id",issue:g["target.agent_id"],children:t.jsx(At,{name:"agent",label:"Agent",className:"w-full",value:u.agentId,onChange:P=>N("agentId")(P),options:[{value:"",label:x?"Pick an agent":"Loading the agents"},...M.map(P=>({value:P.agent_id,label:`${P.definition.name||P.agent_id}${P.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Jt,{label:"Each run is asked",field:"target.input",issue:g["target.input"],hint:"The event's payload comes with it.",children:t.jsx(ln,{name:"content",rows:4,className:"p-3 font-sans",value:u.content,onChange:P=>N("content")(P.target.value)})}),t.jsx(Jt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:g["target.max_cost_usd"],hint:E!==void 0?`Uses the agent's default (${Xa(E)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(Ie,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:u.maxCost,onChange:P=>N("maxCost")(P.target.value),placeholder:Vm(E)})})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:j,children:j?"Creating":"Create GitHub trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function S8({v2:e,go:n,noAddress:s}){var ue;const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(0),[f,x]=p.useState(null),[b,g]=p.useState(null),[h,v]=p.useState(0),[y,j]=p.useState(E6),[k,$]=p.useState(null),[S,N]=p.useState({}),[_,E]=p.useState([]),[O,A]=p.useState(null),[I,M]=p.useState(null),[R,P]=p.useState(!1),D=p.useRef(dr()).current,W=p.useRef(!0);p.useEffect(()=>(W.current=!0,()=>{W.current=!1}),[]),p.useEffect(()=>{let pe=!0;return c(null),e.listMcpServers().then(me=>{if(!pe)return;const ke=me.servers.filter($e=>$e.source==="composio");a(ke),ke.length===1&&j($e=>$e.server?$e:{...$e,server:ke[0].name})},me=>{pe&&c(Ft(me,"the saved MCP servers"))}),()=>{pe=!1}},[e,d]),p.useEffect(()=>{if(!y.server)return;let pe=!0;const me=y.server;return x(null),g(null),e.composioEvents(me).then(ke=>{pe&&x({server:me,events:ke.events})},ke=>{pe&&g(Ft(ke,`${me}'s events`))}),()=>{pe=!1}},[e,y.server,h]),p.useEffect(()=>{Ym(e).then($,()=>$([]))},[e]);const Y=pe=>{M(null),j(pe)},H=pe=>me=>Y(ke=>({...ke,[pe]:me})),q=pe=>Y(me=>me.server===pe?me:{...me,server:pe,event:"",config:{},where:[]}),F=pe=>{Y(me=>me.event===pe?me:{...me,event:pe,config:{},where:[]}),N({})},G=(f==null?void 0:f.server)===y.server?f.events.find(pe=>pe.slug===y.event):void 0,U=S6(G==null?void 0:G.config),z=(ue=(k??[]).find(pe=>pe.agent_id===y.agentId))==null?void 0:ue.definition.max_cost_usd,Q=typeof z=="number"&&z>0?z:void 0,K=async pe=>{var ke,$e;const me=new Set(["name","source.server","source.event","source.config",...U.map(J=>`source.config.${J.name}`),"target.agent_id","target.input","target.max_cost_usd",...y.where.length?Wm([y.where.length]):[]]);N({}),E([]),A(null),M(null),P(!0);try{const J=await e.createTrigger(pe,D.keyFor("createTrigger",pe));W.current&&n(Ws(J.id));return}catch(J){if(J instanceof ze&&J.code==="composio_subscription_elsewhere")M({url:typeof((ke=J.details)==null?void 0:ke.webhook_url)=="string"?J.details.webhook_url:"another address",body:pe});else if(J instanceof ze&&J.code.startsWith("composio_"))E([J.message]),J.code==="composio_not_connected"&&A(no(typeof(($e=J.details)==null?void 0:$e.connect_url)=="string"?J.details.connect_url:null)??null);else{const Le=vd(J);N(Object.fromEntries(Object.entries(Le.fields).filter(([qe])=>me.has(qe)))),E([...Le.rest,...Object.entries(Le.fields).filter(([qe])=>!me.has(qe)).map(([,qe])=>qe)])}}P(!1)},Z=()=>_6(y,U,Q!==void 0),de=pe=>{pe.preventDefault();const{body:me,issues:ke}=Z();if(E([]),A(null),!me){N(ke??{});return}K(me)},re=()=>{const pe=I;M(null),pe&&K({...pe.body,source:{...pe.body.source,move_subscription:!0}})},fe=t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),ve=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(Zf,{className:"size-5 text-primary-text","aria-hidden":!0}),"New app trigger"]});if(i)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[fe,ve,t.jsx(Kt,{problem:i,onRetry:()=>u(pe=>pe+1),className:"mt-4"})]});if(r===null)return t.jsx(Fn,{label:"Reading the saved Composio servers",rows:3});if(!r.length)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[fe,ve,t.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Save a Composio server first: ",t.jsx("a",{href:"#/settings/mcp",className:"underline underline-offset-2",children:"Settings → MCP servers"}),", Add from Composio. A trigger from an app uses its key and the account it is connected as."]})]});const Ee=sd((k??[]).filter(pe=>!pe.archived_at));return t.jsxs("form",{onSubmit:de,className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[fe,ve,t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event Composio delivers for it starts a capped run of the agent. This server makes the trigger on Composio for the account the server is connected as."}),s&&t.jsx("p",{className:"mt-4 border border-warning/50 p-3 text-body",role:"status",children:cy}),_.length>0&&t.jsxs("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:[_.map((pe,me)=>t.jsx("p",{className:"break-words",children:pe},me)),O&&t.jsx("a",{href:O,target:"_blank",rel:"noreferrer",className:"mt-2 inline-block underline underline-offset-2",children:"Connect the account"})]}),t.jsxs("div",{className:"mt-5 space-y-5",children:[t.jsx(Jt,{label:"Name",field:"name",issue:S.name,children:t.jsx(Ie,{name:"name",value:y.name,onChange:pe=>H("name")(pe.target.value),placeholder:"new issues"})}),t.jsx(Jt,{label:"Composio server",field:"source.server",issue:S["source.server"],children:t.jsx(At,{name:"server",label:"Composio server",className:"w-full",value:y.server,onChange:q,options:[{value:"",label:"Pick a server"},...r.map(pe=>({value:pe.name,label:pe.toolkit?`${pe.name} (${pe.toolkit})`:pe.name}))]})}),y.server&&(b?t.jsx(Kt,{problem:b,onRetry:()=>v(pe=>pe+1),className:""}):t.jsx(Jt,{label:"Event",field:"source.event",issue:S["source.event"],hint:G==null?void 0:G.description,children:t.jsx(At,{name:"event",label:"Event",className:"w-full",value:y.event,onChange:F,disabled:!f,options:[{value:"",label:f?f.events.length?"Pick an event":"Composio offers no event for this toolkit":"Loading the events"},...((f==null?void 0:f.events)??[]).map(pe=>({value:pe.slug,label:pe.name||pe.slug}))]})})),G&&t.jsxs(t.Fragment,{children:[G.polled&&t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:"Composio checks for it every few minutes, so a run starts some minutes after the event."}),G.instructions&&t.jsx("p",{className:"whitespace-pre-wrap text-small text-muted-foreground",children:G.instructions}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Config"}),t.jsxs("p",{className:"mb-2 mt-1 text-small text-muted-foreground",children:["What Composio watches for ",t.jsx("span",{className:"font-mono",children:G.slug}),"."]}),t.jsx(so,{issues:S,field:"source.config"}),U.length?t.jsx("div",{className:"space-y-4",children:U.map(pe=>t.jsx(C8,{field:pe,value:y.config[pe.name]??pe.initial,issue:S[`source.config.${pe.name}`],onChange:me=>Y(ke=>({...ke,config:{...ke.config,[pe.name]:me}}))},`${G.slug}:${pe.name}`))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"This event takes no config."})]}),t.jsx(vE,{where:y.where,onChange:H("where"),issues:S})]}),t.jsx(Jt,{label:"Agent",field:"target.agent_id",issue:S["target.agent_id"],children:t.jsx(At,{name:"agent",label:"Agent",className:"w-full",value:y.agentId,onChange:pe=>H("agentId")(pe),options:[{value:"",label:k?"Pick an agent":"Loading the agents"},...Ee.map(pe=>({value:pe.agent_id,label:`${pe.definition.name||pe.agent_id}${pe.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Jt,{label:"Each run is asked",field:"target.input",issue:S["target.input"],hint:"What Composio delivered comes with it.",children:t.jsx(ln,{name:"content",rows:4,className:"p-3 font-sans",value:y.content,onChange:pe=>H("content")(pe.target.value)})}),t.jsx(Jt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:S["target.max_cost_usd"],hint:Q!==void 0?`Uses the agent's default (${Xa(Q)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(Ie,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:y.maxCost,onChange:pe=>H("maxCost")(pe.target.value),placeholder:Vm(Q)})})]}),I&&t.jsxs("div",{role:"alertdialog","aria-label":"Move the subscription here?",className:"mt-6 space-y-3 border border-warning/50 p-4 text-body",children:[t.jsxs("p",{children:["Composio sends this project's events to ",t.jsx("code",{className:"break-all font-mono text-small",children:I.url})," now. Moving them here stops them arriving there: anything listening at ",t.jsx("code",{className:"break-all font-mono text-small",children:I.url})," (another AgentRun server, or a tool of yours) gets no more events."]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"solid",onClick:re,children:"Move it here"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>M(null),children:"Keep it there"})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:R||!!I||s,children:R?"Creating":"Create app trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function C8({field:e,value:n,issue:s,onChange:r}){const a=`config-${e.name}`,i=s?t.jsx("span",{"data-issue":`source.config.${e.name}`,children:s}):void 0;return e.type==="boolean"?t.jsxs("div",{"data-config-field":e.name,children:[t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:a,checked:n==="true",onChange:c=>r(c.target.checked?"true":"false"),className:"accent-primary"})," ",e.title]}),e.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.description}),s&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert",children:i})]}):t.jsx("div",{"data-config-field":e.name,children:t.jsx(jt,{className:"min-w-0",label:e.title,required:e.required,optional:!e.required,hint:e.description,error:i,children:e.options?t.jsx(At,{name:a,label:e.title,className:"w-full",value:n,onChange:r,options:[...e.required?[]:[{value:"",label:"None"}],...e.options.map(c=>({value:c,label:c}))],placeholder:"Pick one"}):e.type==="json"?t.jsx(ln,{name:a,rows:3,className:"p-3 font-mono",value:n,onChange:c=>r(c.target.value),spellCheck:!1}):t.jsx(Ie,{name:a,inputMode:e.type==="string"?void 0:"decimal",value:n,onChange:c=>r(c.target.value),autoComplete:"off",spellCheck:!1})})})}function E8(e,n){const s=n!==null?`, up to ${n} at once; past that, a request waits for one of them to end`:"";return e?`With a filter, each request it takes starts its own run${n!==null?s:", even while an earlier run is still going"}. Any other request is answered and starts nothing.`:n!==null?`Every signed request starts a run${s}.`:"Every signed request starts a run. One that comes while its last run is still going is skipped."}function gE({signature:e,rules:n,onChange:s,issues:r,cap:a}){return t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(so,{issues:r,field:"source.accept"}),t.jsx(lE,{name:"accept",rules:n,onChange:s,issues:r,room:xd.rules-n.length,eventHint:iE[e],eventPlaceholder:e==="github"?"issues":"issue.opened"}),t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:E8(n.length>0,a)})]})]})}function xE({picks:e,onChange:n,issues:s}){const r=i=>n({...e,events:e.events.includes(i)?e.events.filter(c=>c!==i):[...e.events,i]}),a=Bm(e).map(i=>i.id);return t.jsxs(t.Fragment,{children:[t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Events"}),t.jsx("div",{className:"mt-1 space-y-3",children:KC.map(i=>{const c=a.indexOf(`event:${i}`),d=`source.accept[${c}]`;return t.jsxs("div",{"data-github-event":i,className:"space-y-1",children:[Hm.filter(u=>u.event===i).map(({event:u,action:f,label:x})=>{const b=`${u}:${f}`;return t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"event",value:b,checked:e.events.includes(b),onChange:()=>r(b),className:"accent-primary"}),x," ",t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[u," ",f]})]},b)}),c>=0&&t.jsxs("div",{className:"ml-6 space-y-1 pt-1",children:[[d,`${d}.event`,`${d}.actions`].map(u=>t.jsx(so,{issues:s,field:u},u)),t.jsx(ly,{name:`github-${i}`,at:d,where:e.where[i]??[],onChange:u=>n({...e,where:{...e.where,[i]:u}}),issues:s,label:`Only when, for ${i}`})]})]},i)})}),s["source.accept"]&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.accept",children:s["source.accept"]})]}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Other events ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsx("p",{className:"mb-2 mt-1 text-small text-muted-foreground",children:"Any other GitHub event, by its name."}),t.jsx(lE,{name:"other",rules:e.other,onChange:i=>n({...e,other:i}),issues:s,indexOf:i=>{var c;return a.indexOf(`other:${(c=e.other[i])==null?void 0:c.key}`)},room:xd.rules-a.length,eventHint:iE.github,eventPlaceholder:"issues",addLabel:"Add another event"})]})]})}function $8({v2:e,go:n,trigger:s}){const r=ny(s)?s:null,a=ry(s)?s:null,[i,c]=p.useState(()=>r?(r.source.accept??[]).map(cx):a?(a.source.accept??[]).map(cx):[]),[d,u]=p.useState(()=>r||a?{events:[],where:{},other:[]}:N6(s.source.accept)),f=a&&i[0]&&!i[0].actions.trim()?i[0]:null,x=a?i.slice(f?1:0):[],[b,g]=p.useState({}),[h,v]=p.useState([]),[y,j]=p.useState(!1),k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const $=async _=>{_.preventDefault();const{source:E,issues:O}=r?qC(r.source,i):a?$6(a.source,(f==null?void 0:f.where)??[],x,f==null?void 0:f.was):VC(d);if(v([]),Object.keys(O).length){g(O);return}g({}),j(!0);try{Bf(E,s.source)||await e.updateTrigger(s.id,{source:E}),k.current&&n(Ws(s.id))}catch(A){if(!k.current)return;const I=vd(A),M=Wm(r||a?i.map(R=>R.where.length):Bm(d).map(R=>R.where.length));g(Object.fromEntries(Object.entries(I.fields).filter(([R])=>M.has(R)))),v([...I.rest,...Object.entries(I.fields).filter(([R])=>!M.has(R)).map(([,R])=>R)]),j(!1)}},S=r?Zi:a?Zf:nm,N=_=>c(f?_.length?[{...f,where:_},...x]:x:_.length?[{..._C(),event:a.source.event,where:_},...x]:x);return t.jsxs("form",{onSubmit:_=>void $(_),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:Ws(s.id),className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," ",s.name]}),t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(S,{className:"size-5 text-primary-text","aria-hidden":!0}),"Edit filter"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:r?"Which signed requests start a run. Its URL and secret stay as they are.":a?`Which ${a.source.event} events from ${a.source.server} start a run. Its event, its config and its instance on Composio stay as they are.`:"Which events from this server's GitHub App start a run."}),h.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:h.map((_,E)=>t.jsx("p",{children:_},E))}),t.jsx("div",{className:"mt-5 space-y-5",children:r?t.jsx(gE,{signature:r.source.signature??"standard",rules:i,onChange:c,issues:b,cap:s.max_active_runs??null}):a?t.jsx(vE,{where:(f==null?void 0:f.where)??[],onChange:N,issues:b,others:x.map(_=>_.event+(_.actions.trim()?` (${_.actions.trim()})`:""))}):t.jsx(xE,{picks:d,onChange:u,issues:b})}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:y,children:y?"Saving":"Save filter"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(Ws(s.id)),children:"Cancel"})]})]})}function vE({where:e,onChange:n,issues:s,others:r=[]}){return t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(so,{issues:s,field:"source.accept"}),t.jsx(so,{issues:s,field:"source.accept[0]"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"A condition reads what Composio delivers: the event's data is under /data, such as /data/title for a new issue's title."}),t.jsx(ly,{name:"composio",at:"source.accept[0]",where:e,onChange:n,issues:s,label:"Only when"}),r.length>0&&t.jsxs("p",{className:"text-small text-muted-foreground",role:"note",children:[r.length===1?"One more rule, made through the API, is kept as it is":`${r.length} more rules, made through the API, are kept as they are`,": ",r.join(", "),"."]})]})]})}const yE=e=>e?"#/playground?operation=apply-template":"#/templates";function x0({v2:e,name:n,install:s,go:r,playground:a=!1,draft:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),[x,b]=p.useState(0);if(p.useEffect(()=>{if(s!==void 0)return;let h=!0;return f(null),e.listTemplates().then(v=>{h&&d(v.templates)},v=>{h&&f(Ft(v,"the templates"))}),()=>{h=!1}},[e,x,s]),s!==void 0)return t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(T8,{v2:e,source:s,go:r})});const g=n===void 0||c==null?void 0:c.find(h=>h.id===n);return t.jsx("div",{className:"p-5 md:p-8",children:u&&!c?t.jsx(Kt,{problem:u,onRetry:()=>b(h=>h+1),className:""}):c?n===void 0?t.jsx(_8,{v2:e,templates:c,go:r,playground:a,onRemoved:()=>b(h=>h+1)}):g?t.jsx(M8,{v2:e,template:g,go:r,playground:a,draft:i},`${g.id}:${i??""}`):t.jsxs("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",role:"alert",children:["This server offers no template named ",n,". ",t.jsx("a",{href:yE(a),className:"underline",children:"See its templates"}),"."]}):t.jsx(Fn,{label:"Loading the templates",rows:3})})}function uy({t:e}){var n;return e.source?t.jsxs("p",{className:"mt-1 break-all font-mono text-small text-muted-foreground","data-provenance":!0,children:[e.source," at ",(n=e.sha)==null?void 0:n.slice(0,12),", published by ",e.publisher]}):null}function _8({v2:e,templates:n,go:s,playground:r,onRemoved:a}){const i=r?"h2":"h1",c=r?"h3":"h2",[d,u]=p.useState(""),[f,x]=p.useState(null),[b,g]=p.useState(null),h=async v=>{x(v.id),g(null);try{await e.deleteTemplate(v.id),a()}catch(y){g(y instanceof Error?y.message:String(y))}finally{x(null)}};return t.jsxs(t.Fragment,{children:[t.jsx(i,{className:"mb-5 font-mono text-2xl font-semibold",children:"Templates"}),t.jsxs("form",{"aria-label":"Add from URL",className:"mb-5 flex flex-wrap items-end gap-2 border bg-card px-4 py-3",onSubmit:v=>{v.preventDefault(),d.trim()&&s(R8(d.trim()))},children:[t.jsxs("label",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"caps text-small font-semibold",children:"Add from URL"}),t.jsx("span",{className:"mb-1.5 block text-small text-muted-foreground",children:"A package on GitHub: github:owner/repo/path@ref, or its github.com/…/tree/… address. You read it whole before anything is stored."}),t.jsx(Ie,{type:"text",value:d,placeholder:"github:owner/repo/templates/name@main",onChange:v=>u(v.target.value)})]}),t.jsx(B,{size:"sm",variant:"solid",type:"submit",disabled:!d.trim(),children:"Read it"})]}),b&&t.jsx("p",{className:"mb-3 text-body text-destructive-text",role:"alert",children:b}),n.length?t.jsx("ul",{className:"grid gap-3 md:grid-cols-2",children:n.map(v=>t.jsx("li",{children:t.jsxs("article",{"aria-label":Uo(v),className:"flex h-full flex-col border bg-card px-5 py-4",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx(Ax,{className:"size-4 shrink-0 self-center text-muted-foreground","aria-hidden":!0}),t.jsx(c,{className:"min-w-0 break-words text-prose font-semibold",children:Uo(v)}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:v.version}),v.category&&t.jsx(je,{tone:"muted",children:v.category}),!v.bundled&&t.jsx(je,{tone:"muted",children:"Imported"})]}),t.jsx(uy,{t:v}),t.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:v.description}),v.tags.length>0&&t.jsx("p",{"aria-label":"Tags",className:"mt-1.5 break-words font-mono text-small text-muted-foreground",children:v.tags.join(" · ")}),t.jsx("dl",{className:"mt-3 space-y-1 font-mono text-small text-muted-foreground",children:ay(v).map(([y,j])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0",children:y}),t.jsx("dd",{className:"min-w-0 break-words text-foreground/80",children:j})]},y))}),t.jsxs("div",{className:"mt-auto flex flex-wrap items-center justify-end gap-2 pt-4",children:[!v.bundled&&t.jsx(B,{size:"sm",onClick:()=>void h(v),disabled:f===v.id,children:f===v.id?"Removing…":"Remove"}),r?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>s(Hc(v)),children:"Configure"}):t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",onClick:()=>s(ZC(v.id)),children:"Configure"}),t.jsx(tn,{variant:"primary",label:"Run",prompt:l2(location.origin,v),playgroundHref:Hc(v)})]})]})]})},v.id))}):t.jsx("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",children:"This server offers no templates yet."})]})}function T8({v2:e,source:n,go:s}){var $;const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,x]=p.useState(!1),[b,g]=p.useState(null);p.useEffect(()=>{let S=!0;if(!n){c("Give a package's source: github:owner/repo/path@ref.");return}return e.importTemplate(n,{dryRun:!0}).then(N=>{S&&a(N)},N=>{S&&c(v0(N))}),()=>{S=!1}},[e,n]);const h=async()=>{x(!0),g(null);try{if(!r)return;const S=await e.importTemplate(`${r.template.id}@${r.template.sha}`,{trustPublisher:d});s(ZC(S.template.id))}catch(S){g(v0(S))}finally{x(!1)}},v=t.jsxs("a",{href:"#/templates",className:"caps mb-4 inline-flex items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Templates"]});if(i)return t.jsxs("div",{className:"max-w-3xl",children:[v,t.jsx("p",{className:"border px-4 py-6 font-mono text-body text-destructive-text",role:"alert",children:i})]});if(!r)return t.jsx(Fn,{label:"Reading the package from GitHub",rows:3});const y=r.template,j=y.publisher??"",k=Object.entries(r.skill_files);return t.jsxs("section",{"aria-label":"Install from GitHub",className:"max-w-3xl",children:[v,t.jsxs("h1",{className:"font-mono text-2xl font-semibold",children:[Uo(y)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:y.version})]}),t.jsxs("dl",{className:"mt-3 space-y-1 border bg-card px-4 py-3 font-mono text-small",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Publisher"}),t.jsxs("dd",{"data-publisher":!0,children:[j,r.publisher_trusted?" (trusted here)":" (new here)"]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Commit"}),t.jsx("dd",{className:"break-all","data-sha":!0,children:y.sha})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Source"}),t.jsx("dd",{className:"break-all",children:y.source})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Installs as"}),t.jsxs("dd",{className:"break-all",children:[y.id,r.replaced?`, replacing the one read at ${r.replaced.slice(0,12)}`:""]})]})]}),t.jsx("p",{className:"mt-3 text-lead leading-[1.6]",children:y.description}),t.jsx(lr,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:ay(y,{mcp:!1}).map(([S,N])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:S}),t.jsx("dd",{className:"min-w-0 break-words",children:N})]},S))})}),y.mcp.length>0&&t.jsx(lr,{title:"MCP tools it asks for",note:"None is granted by installing: the Apply screen asks you to tick each one.",children:y.mcp.map(S=>t.jsxs("div",{"data-mcp":S.toolkit,className:"px-4 py-3",children:[t.jsx(bE,{m:S}),t.jsx("p",{className:"mt-1 break-words font-mono text-small",children:S.tools.map(N=>N.name).join(", ")})]},S.toolkit))}),t.jsx(wE,{t:y}),t.jsx(jE,{t:y}),t.jsx(lr,{title:"Instructions",note:"What the agent is told, in full: a package from someone else says this to your agent.",children:t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-instructions":!0,children:r.instructions})}),(($=y.output)==null?void 0:$.json_schema)&&t.jsx(lr,{title:"Output schema",note:`What the agent is told to answer in (${y.output.schema}), in full: its descriptions are instructions too.`,children:t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-output-schema":!0,children:JSON.stringify(y.output.json_schema,null,2)})}),k.length>0&&t.jsx(lr,{title:"Skill files",note:"Every file the agent is given, in full.",children:k.map(([S,N])=>t.jsxs("details",{className:"px-4 py-2","data-skill-file":S,children:[t.jsx("summary",{className:"cursor-pointer font-mono text-body",children:S}),t.jsx("pre",{className:"mt-2 max-h-[32rem] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:N})]},S))}),!r.publisher_trusted&&t.jsxs("label",{className:"mt-6 flex items-start gap-2.5 border border-warning/50 px-4 py-3",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:d,onChange:S=>u(S.target.checked)}),t.jsxs("span",{children:[t.jsxs("span",{className:"font-mono text-body",children:["I trust ",j]}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:["This server has no package from ",j," yet. Ticked, it remembers that you trust them."]})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void h(),disabled:f||!r.publisher_trusted&&!d,children:f?"Installing…":"Install"}),t.jsx("span",{className:"text-small text-muted-foreground",children:"Installing stores it; nothing runs and nothing is granted until you apply it."}),b&&t.jsx("p",{className:"w-full text-body text-destructive-text",role:"alert",children:b})]})]})}function v0(e){var n;return e instanceof ze&&((n=e.fields)!=null&&n.length)?[...new Set([e.message,...e.fields.map(s=>s.message)])].join(" "):e instanceof Error?e.message:String(e)}const R8=e=>`#/templates/install?src=${encodeURIComponent(e)}`,A8=3e3;function O8(e,n){let s;const r=new Promise(a=>s=setTimeout(()=>a(void 0),n));return Promise.race([e,r]).finally(()=>clearTimeout(s))}function M8({v2:e,template:n,go:s,playground:r=!1,draft:a}){var rt,vt,st,Se,Be,he,Ve,ct,Me,ot;const i=r?"h2":"h1",c={fields:Gm(n.parameters)??[]},d=B6(a,n),[u,f]=p.useState(()=>{var oe;return{...Object.fromEntries(c.fields.filter(([,xe])=>xe.type==="boolean"&&!xe.array).map(([xe])=>[xe,"false"])),...sE(c),...Object.fromEntries(Object.entries(((oe=d.body)==null?void 0:oe.parameters)??{}).map(([xe,Ae])=>[xe,Array.isArray(Ae)?Ae.map(String).join(`
|
|
653
|
+
`):String(Ae)]))}}),[x,b]=p.useState(()=>{var oe;return new Set(((oe=d.body)==null?void 0:oe.grants)??[])}),[g,h]=p.useState(((vt=(rt=d.body)==null?void 0:rt.overrides)==null?void 0:vt.approvals)??n.approvals_default??"ask"),[v,y]=p.useState(((Se=(st=d.body)==null?void 0:st.overrides)==null?void 0:Se.choice)??""),[j,k]=p.useState(null),[$,S]=p.useState(null),[N,_]=p.useState(0),[E,O]=p.useState(()=>{var oe;return((oe=d.body)==null?void 0:oe.servers)??{}}),[A,I]=p.useState(!1),[M,R]=p.useState([]),[P,D]=p.useState(null),[W,Y]=p.useState(null),[H,q]=p.useState([]),[F,G]=p.useState({}),U=p.useRef(dr()).current,z=p.useRef(!0);p.useEffect(()=>(z.current=!0,()=>{z.current=!1}),[]),p.useEffect(()=>{let oe=!0;return S(null),e.listMcpServers().then(xe=>{oe&&k(xe.servers)},xe=>{oe&&S(Ft(xe,"the saved MCP servers"))}),()=>{oe=!1}},[e,N]);const Q=Y6(n,x),K=n.mcp.map(oe=>{const xe=j?K6(oe,j):[];return{m:oe,matches:xe,uses:xe.length===1?xe[0]:xe.includes(E[oe.toolkit]??"")?E[oe.toolkit]:void 0}}),Z=Object.fromEntries(K.flatMap(({m:oe,uses:xe})=>xe?[[oe.toolkit,xe]]:[])),de=K.filter(({matches:oe,uses:xe})=>oe.length>1&&!xe).map(({m:oe})=>oe.toolkit),re=n.mcp.length>0&&j===null,fe=j&&K.some(({m:oe,matches:xe})=>{var Ae,De;return((De=(Ae=d.body)==null?void 0:Ae.servers)==null?void 0:De[oe.toolkit])!==void 0&&!xe.includes(d.body.servers[oe.toolkit])}),ve=d.error??(fe?"This prepared server choice no longer matches the saved MCP servers. Open a fresh request to review the current accounts.":void 0),Ee=!!ve||re||de.length>0,ue={parameters:Km(c,u),...Q.length?{grants:Q}:{},...Object.keys(Z).length?{servers:Z}:{},overrides:{approvals:g,...v?{choice:v}:{}}},pe=oe=>Q6(M,oe),me=(oe,xe,Ae)=>{f(De=>({...De,[oe]:Ae})),nE(xe,Ae)&&R(De=>De.filter(ut=>mx(ut.field,"parameters")!==oe))},ke=async()=>{var xe,Ae;if(!r||Ee)return;I(!0),R([]),D(null);const oe=u;try{const De=await e.applyTemplate(n.id,ue,U.keyFor(n.id,ue));U.done();const ut=async()=>(await Promise.all(De.trigger_ids.map(Qe=>O8(e.getTrigger(Qe),A8).catch(()=>null)))).filter(Qe=>Qe!=null&&ty(Qe));if(De.warnings.length||(xe=De.webhook_secrets)!=null&&xe.length){G(oe),Y(De),ut().then(q,()=>{});return}const ee=De.trigger_ids.length?await ut():[];if(!z.current)return;if(!ee.length){s(on(De.agent_id));return}G(oe),q(ee),Y(De)}catch(De){De instanceof ze&&((Ae=De.fields)!=null&&Ae.length)?(R(De.fields),D({text:De.message,withIssues:!0}),De.fields.some(ut=>ut.field.startsWith("servers.")||ut.field.startsWith("mcp."))&&_(ut=>ut+1)):D({text:De instanceof Error?De.message:String(De),withIssues:!1})}finally{I(!1)}},$e=c.fields,J=oe=>oe.filter(xe=>!n.secrets.includes(xe)),Le=(he=(Be=n.model)==null?void 0:Be.choices)==null?void 0:he.find(oe=>oe.id===v),qe=oe=>{var xe,Ae;return/^(parameters|mcp|servers)\./.test(oe.field)||/^grants\.\d+$/.test(oe.field)||oe.field==="overrides.choice"&&!!((Ae=(xe=n.model)==null?void 0:xe.choices)!=null&&Ae.length)||oe.field.startsWith("secrets.")&&[...n.secrets,...J((Le==null?void 0:Le.secrets)??[])].includes(oe.field.slice(8))};return W?t.jsxs("section",{"aria-label":"Applied",className:"max-w-3xl",children:[t.jsxs(i,{className:"mb-4 flex items-center gap-2 font-mono text-2xl font-semibold",children:[t.jsx(cl,{className:"size-5 text-success-text","aria-hidden":!0})," ",Uo(n,F)," applied"]}),W.warnings.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mb-3 text-lead",children:"The agent is made. The server says:"}),t.jsx("ul",{className:"mb-5 space-y-2 border bg-card px-4 py-3 text-body",role:"status","aria-label":"Warnings",children:W.warnings.map((oe,xe)=>{var ee,Re;const Ae=/^triggers\.(\d+)\.secret$/.exec(oe.field),De=Ae?W.trigger_ids[Number(Ae[1])]:void 0,ut=Ae?(ee=n.triggers[Number(Ae[1])])==null?void 0:ee.name:void 0;return De&&((Re=W.webhook_secrets)!=null&&Re.some(Qe=>Qe.trigger_id===De))?t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:oe.field})," ",oe.message]},`${oe.field}:${xe}`):t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:oe.field})," ",oe.message,oe.fix?t.jsx("span",{className:"block text-muted-foreground",children:oe.fix}):null,De&&t.jsxs("a",{href:`#/triggers/${encodeURIComponent(De)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",typeof ut=="string"&&ut?ut:De," to get its signing secret (Rotate)"]})]},`${oe.field}:${xe}`)})})]}),(Ve=W.webhook_secrets)==null?void 0:Ve.map(oe=>{var ut;const xe=W.trigger_ids.indexOf(oe.trigger_id),Ae=xe>=0?(ut=n.triggers[xe])==null?void 0:ut.name:void 0,De=typeof Ae=="string"&&Ae?Ae:oe.trigger_id;return oe.signing_secret?t.jsx(dy,{label:`The webhook's URL and secret (${De})`,url:Wc({id:oe.trigger_id}),secret:oe.signing_secret},oe.trigger_id):t.jsxs("div",{className:"mt-4 border px-4 py-3 text-body",children:[oe.note&&t.jsx("p",{className:"text-muted-foreground",role:"note",children:oe.note}),t.jsxs("a",{href:`#/triggers/${encodeURIComponent(oe.trigger_id)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",De," to get its signing secret (Rotate)"]})]},oe.trigger_id)}),H.length>0&&t.jsx("ul",{className:"mt-4 divide-y border","aria-label":"Schedules",children:H.map(oe=>t.jsxs("li",{"data-trigger":oe.id,className:"px-4 py-3",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(oe.id)}`,className:"break-words text-prose font-semibold hover:underline",children:oe.name}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",children:Zv(oe.source,oe.next_at)})]},oe.id))}),t.jsx("div",{className:"mt-5"}),t.jsx("a",{href:on(W.agent_id),className:"inline-flex border px-3 py-2 font-mono text-body font-semibold hover:bg-accent",children:"Open the agent"})]}):t.jsxs("div",{className:"max-w-3xl",children:[t.jsxs("a",{href:yE(r),className:"caps mb-4 inline-flex items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Templates"]}),t.jsxs(i,{className:"font-mono text-2xl font-semibold",children:[Uo(n,u)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:n.version})]}),t.jsx(uy,{t:n}),t.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:n.description}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:r?"Apply creates an agent and its triggers. It does not start a run.":"Run with your coding agent. It sets up this template, asks for any missing inputs, and runs the task."}),ve&&t.jsxs("p",{className:"mt-3 text-body text-destructive-text",role:"alert",children:[ve," ",t.jsx("a",{href:Hc(n),className:"underline",children:"Open a fresh request"}),"."]}),$e.length>0&&t.jsx(lr,{title:"Parameters",children:$e.map(([oe,xe])=>t.jsxs("div",{"data-field":`parameters.${oe}`,className:"px-4 py-3",children:[t.jsx(aE,{field:xe,label:qm(oe,xe),help:Gf(xe),value:u[oe]??"",onChange:Ae=>me(oe,xe,Ae)}),t.jsx(Mo,{issues:M.filter(Ae=>mx(Ae.field,"parameters")===oe),words:Ae=>oE(Ae,oe,xe)})]},oe))}),n.mcp.length>0&&t.jsxs(lr,{title:"Tools you grant",note:"Nothing is granted until you tick it. A tool you tick is granted and follows this server's tool settings: a write asks you first unless you allowed it in Settings or choose Never ask, and a read runs without asking where you turned on Allow reads for its server. A tool you leave unticked is not given to the agent, even when it never asks: you can add it later on the agent's page.",children:[$&&!j&&t.jsx("div",{"data-servers-unread":!0,className:"px-4 py-3",children:t.jsx(Kt,{problem:$,onRetry:()=>_(oe=>oe+1),className:""})}),K.map(({m:oe,matches:xe,uses:Ae})=>t.jsxs("div",{"data-mcp":oe.toolkit,className:"px-4 py-3",children:[t.jsx(bE,{m:oe,children:j&&xe.length<2&&t.jsx("span",{className:"text-small text-muted-foreground",children:Ae?`Uses ${Ae}`:"Not set up here"})}),j&&xe.length>1&&t.jsxs("label",{className:"mt-2 flex flex-wrap items-center gap-2 text-small text-muted-foreground",children:["Uses",t.jsx(At,{small:!0,label:`Server for ${oe.toolkit}`,value:Ae??"",placeholder:"Pick one",onChange:De=>O(ut=>({...ut,[oe.toolkit]:De})),options:xe.map(De=>({value:De,label:De}))}),!Ae&&t.jsxs("span",{"data-unpicked":oe.toolkit,children:[xe.length," saved servers are ",dd[oe.source]," ",oe.toolkit,": pick the one the agent uses."]})]}),j&&xe.length===0&&t.jsxs("p",{role:"status","data-missing-mcp":oe.toolkit,className:"mt-2 border border-warning/50 px-3 py-2 text-small text-warning-text",children:[oe.required?`${oe.toolkit} is required and not set up here: Apply is refused until it is.`:`${oe.toolkit} is not set up here: Apply makes the agent without its tools (${oe.tools.map(De=>De.name).join(", ")}).`," ",t.jsx("a",{href:V6(oe),className:"font-mono text-primary-text underline-offset-2 hover:underline",children:oe.source==="github"?"Set up GitHub App access":oe.source==="composio"?`Add ${oe.toolkit} from Composio`:`Set up ${oe.toolkit}`})]}),t.jsx(Mo,{issues:[...pe(`mcp.${oe.toolkit}`),...pe(`servers.${oe.toolkit}`)]}),t.jsx("ul",{className:"mt-2 space-y-2",children:oe.tools.map(De=>{const ut=Q.indexOf(De.tool);return t.jsxs("li",{"data-tool":De.tool,children:[t.jsxs("label",{className:"flex items-start gap-2.5",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:x.has(De.tool),onChange:()=>b(ee=>{const Re=new Set(ee);return Re.has(De.tool)?Re.delete(De.tool):Re.add(De.tool),Re})}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body",children:De.name})," ",t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:De.tool}),t.jsx("span",{className:"block text-small text-muted-foreground",children:De.asks==="allow"?"The template asks you to grant this.":"The template does not ask for this; unticked, the agent doesn't get it."})]})]}),ut>=0&&t.jsx(Mo,{issues:pe(`grants.${ut}`)})]},De.tool)})})]},oe.toolkit))]}),n.secrets.length>0&&t.jsx(lr,{title:"Keys it uses",note:"Saved on this server by name; a run is given them.",children:n.secrets.map(oe=>t.jsxs("div",{"data-secret":oe,className:"px-4 py-3 font-mono text-body",children:[oe,t.jsx(Mo,{issues:pe(`secrets.${oe}`)})]},oe))}),(Me=(ct=n.model)==null?void 0:ct.choices)!=null&&Me.length?t.jsxs("fieldset",{"aria-label":"Model",className:"mt-6",children:[t.jsx("legend",{className:"caps text-small font-semibold",children:"Model"}),t.jsx("div",{className:"mt-2 divide-y border",children:[{id:"",label:`Your default: ${n.model.tier} on ${(ot=n.harness)!=null&&ot.length?n.harness.length===1?n.harness[0]:`the first of ${n.harness.join(", ")} this server runs`:"this server's default harness"}`,warning:null,note:null},...n.model.choices].map(oe=>t.jsxs("label",{"data-choice":oe.id||"(default)",className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"model-choice",value:oe.id,className:"mt-1 accent-primary",checked:v===oe.id,onChange:()=>{y(oe.id),R(xe=>xe.filter(Ae=>Ae.field!=="overrides.choice"&&!(Ae.field.startsWith("secrets.")&&!n.secrets.includes(Ae.field.slice(8)))))}}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body","data-choice-label":!0,children:oe.label}),"model"in oe&&t.jsxs("span",{className:"block font-mono text-label text-muted-foreground",children:[oe.model," on ",oe.harness]}),oe.warning&&t.jsx("span",{className:"mt-1 block text-small text-warning-text","data-choice-warning":oe.id,children:oe.warning}),oe.note&&t.jsx("span",{className:"mt-1 block text-small text-muted-foreground","data-choice-note":oe.id,children:oe.note}),"secrets"in oe&&v===oe.id&&t.jsx("span",{"data-choice-keys":oe.id,children:t.jsx(Mo,{issues:J(oe.secrets).flatMap(xe=>pe(`secrets.${xe}`))})})]})]},oe.id||"(default)"))}),t.jsx(Mo,{issues:pe("overrides.choice")})]}):null,t.jsxs("fieldset",{"aria-label":"Approvals",className:"mt-6",children:[t.jsx("legend",{className:"caps text-small font-semibold",children:"Approvals"}),t.jsx("div",{className:"mt-2 divide-y border",children:[["ask","Ask me","A call that asks waits for your answer: a ticked tool's write unless you allowed it in Settings, and its read unless you turned on Allow reads for its server."],["never","Never ask (run unattended)","Runs without asking you, even for writes. Pick this if a trigger starts the agent while you're away."]].map(([oe,xe,Ae])=>t.jsxs("label",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"approvals",value:oe,className:"mt-1 accent-primary",checked:g===oe,onChange:()=>h(oe)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:xe}),t.jsx("span",{className:"block text-small text-muted-foreground",children:Ae})]})]},oe))}),g==="never"&&t.jsx("p",{className:"mt-2 text-small text-warning-text",children:SC})]}),t.jsx(wE,{t:n}),t.jsx(jE,{t:n}),t.jsx(lr,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:ay(n,{secrets:!1,mcp:!1}).map(([oe,xe])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:oe}),t.jsx("dd",{className:"min-w-0 break-words",children:xe})]},oe))})}),t.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[r?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void ke(),disabled:A||Ee,title:re?$?"The saved MCP servers couldn't be read: try again first":"Reading the saved MCP servers…":de.length?`Pick the server for ${de.join(", ")} first`:void 0,children:A?"Applying…":"Apply"}):t.jsx(tn,{variant:"primary",label:"Run",disabled:Ee,prompt:l2(location.origin,n,ue),playgroundHref:Hc(n,ue)}),P&&(!P.withIssues||M.length>0)&&t.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:P.text})]}),M.filter(oe=>!qe(oe)).length>0&&t.jsx("div",{className:"mt-2",children:t.jsx(Mo,{issues:M.filter(oe=>!qe(oe)),named:!0})})]})}function bE({m:e,children:n}){return t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"font-semibold",children:e.toolkit}),t.jsx(je,{tone:"muted",children:dd[e.source]}),t.jsx(je,{tone:e.required?"plain":"muted",children:e.required?"Required":"Optional"}),n]}),e.reason&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground","data-reason":!0,children:e.reason})]})}function wE({t:e}){if(!e.input_schema)return null;const n=Gm(e.input_schema,"content");return n&&!n.length?null:t.jsx(lr,{title:"Run inputs",note:"What each run is given, as the run form asks for it.",children:n?n.map(([s,r])=>t.jsxs("div",{"data-input":s,className:"px-4 py-3",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"font-semibold",children:qm(s,r)}),r.title&&t.jsx("span",{className:"text-small text-muted-foreground",children:s}),t.jsx(je,{tone:"muted",children:l8(r)}),t.jsx(je,{tone:r.required?"plain":"muted",children:r.required?"Required":"Optional"})]}),Gf(r)&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:Gf(r)})]},s)):t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-input-schema":!0,children:JSON.stringify(e.input_schema,null,2)})})}function jE({t:e}){const n=e.evals.length;return t.jsx(lr,{title:"Eval cases",note:n?`The ${n===1?"one case":`${n} cases`} this template is tested on.`:void 0,children:t.jsx("p",{className:"break-words px-4 py-3 font-mono text-small","data-evals":!0,children:n?e.evals.join(", "):"None: this package ships no eval cases, so nothing tests it."})})}function lr({title:e,note:n,children:s}){return t.jsxs("section",{"aria-label":e,className:"mt-6",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:e}),n&&t.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:n}),t.jsx("div",{className:"mt-2 divide-y border",children:s})]})}function Kf(e){return{definition:{version:1,name:"New agent",instructions:e.trim(),harness:"pi",tools:[],skills:[]}}}function y0(e){return`#/playground?${new URLSearchParams({operation:"create-agent",draft:JSON.stringify(e)})}`}function P8(e){if(!e)return null;try{const n=JSON.parse(e);if(!n||typeof n!="object"||!("definition"in n))return null;const s=n.definition;if(!s||typeof s!="object"||Array.isArray(s))return null;const r=s;return r.version!==1||typeof r.name!="string"||typeof r.instructions!="string"||r.harness!=="pi"||r.description!==void 0&&typeof r.description!="string"||!Array.isArray(r.tools)||!r.tools.every(a=>typeof a=="string")||!Array.isArray(r.skills)||r.skills.length!==0?null:{definition:{version:1,name:r.name,instructions:r.instructions,harness:"pi",tools:[...r.tools],skills:[],...typeof r.description=="string"?{description:r.description}:{}}}}catch{return null}}const L8={"code-review":tm,"inbound-lead":sm,kyb:ST,"market-monitor":kT,"release-notes":Ga};function I8({origin:e,v2:n}){const[s,r]=p.useState(""),[a,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(null),[x,b]=p.useState(null),[g,h]=p.useState(0),v=p.useId(),y=Cm(e,s),j=Kf(s);p.useEffect(()=>{let S=!0;return b(null),n.listTemplates().then(N=>{S&&f(N.templates)},N=>{S&&b(Ft(N,"the template catalog"))}),()=>{S=!1}},[n,g]);const k=c.trim().toLocaleLowerCase(),$=(u??[]).filter(S=>`${Uo(S)} ${S.description} ${S.name} ${S.id} ${S.publisher??""}`.toLocaleLowerCase().includes(k));return t.jsxs("section",{className:"mx-auto w-full max-w-page-wide px-5 pb-20 pt-10 md:px-12 md:pt-16","aria-labelledby":`${v}-heading`,children:[t.jsxs("header",{className:"text-center",children:[t.jsx("h1",{id:`${v}-heading`,className:"text-2xl font-semibold leading-tight tracking-tight md:text-display",children:"What do you want to build?"}),t.jsx("p",{className:"mt-3 text-base text-muted-foreground",children:"Describe your agent, or pick a template to start from."})]}),t.jsxs("div",{className:"mx-auto mt-8 max-w-page",children:[t.jsxs("div",{className:ae(Pc,"!rounded-composer overflow-hidden bg-card transition-colors"),"data-agent-composer":!0,children:[t.jsx("label",{htmlFor:`${v}-brief`,className:"sr-only",children:"Describe your agent"}),t.jsx(ln,{bare:!0,id:`${v}-brief`,value:s,onChange:S=>r(S.target.value),rows:3,placeholder:"A support agent that answers questions from our docs and escalates to Slack when it’s stuck…",className:"block min-h-28 w-full resize-none px-5 pb-3 pt-5 font-sans text-base leading-relaxed text-foreground md:px-6 md:pt-6"}),t.jsx("div",{className:"flex justify-end px-4 pb-4 pt-1 md:px-5 md:pb-5",children:t.jsx(tn,{variant:"primary",label:"Build an agent",prompt:y,playgroundHref:y0(j)})})]}),t.jsxs("details",{className:"mt-3 text-small text-muted-foreground",children:[t.jsx("summary",{className:"ml-auto w-fit cursor-pointer hover:text-foreground",children:"View coding-agent prompt"}),t.jsx("label",{htmlFor:`${v}-prompt`,className:"sr-only",children:"Coding-agent prompt"}),t.jsx(ln,{id:`${v}-prompt`,value:y,readOnly:!0,rows:8,spellCheck:!1,className:"mt-3 w-full border bg-card p-4 font-mono text-small leading-relaxed text-foreground"})]})]}),t.jsxs("section",{className:"mt-10 md:mt-12","aria-labelledby":`${v}-templates`,children:[t.jsxs("div",{className:"mb-5 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("h2",{id:`${v}-templates`,className:"text-lead font-semibold",children:"Start from a template"}),t.jsx("span",{role:"status",className:"text-small text-muted-foreground",children:u===null&&!x?"Loading templates…":u?`${$.length} of ${u.length}`:""})]}),t.jsxs("div",{className:ae(Pc,"flex w-full items-center gap-2 px-3 sm:w-72"),children:[t.jsx(sm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Ie,{bare:!0,type:"search","aria-label":"Search templates",value:c,onChange:S=>d(S.target.value),placeholder:"Search templates…",className:"h-control-md w-full font-sans"})]})]}),x&&t.jsx(Kt,{problem:x,onRetry:()=>h(S=>S+1),className:"mb-5"}),(u==null?void 0:u.length)===0&&t.jsx("p",{className:"border border-border px-5 py-10 text-center text-lead text-muted-foreground",children:"This server has no template packages yet. Describe the agent you want to build above."}),u&&u.length>0&&!$.length&&t.jsxs("p",{role:"status",className:"border border-border px-5 py-10 text-center text-muted-foreground",children:["No templates match “",c,"”."]}),t.jsx("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3",children:$.map(S=>{const N=a===S.id,_=L8[S.name]??Ax,E=`${v}-${encodeURIComponent(S.id)}-actions`,O=[S.skills.length?`${S.skills.length} skill${S.skills.length===1?"":"s"}`:"Ready to configure",S.triggers.length?`${S.triggers.length} trigger${S.triggers.length===1?"":"s"}`:""].filter(Boolean).join(" · ");return t.jsxs("article",{className:`flex flex-col overflow-hidden border transition-colors ${N?"border-border-strong bg-card":"border-border hover:border-border-strong"}`,children:[t.jsxs("button",{type:"button","aria-expanded":N,"aria-controls":E,"aria-label":`Start with ${Uo(S)}${S.source?` from ${S.id}`:""}`,className:"flex min-h-48 flex-1 flex-col p-5 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>i(N?null:S.id),children:[t.jsx("h3",{className:"text-lg font-semibold leading-snug",children:Uo(S)}),t.jsx(uy,{t:S}),t.jsx("p",{className:"mt-3 line-clamp-3 text-lead leading-relaxed text-muted-foreground",children:S.description}),t.jsxs("span",{className:"mt-auto flex w-full items-center gap-2 pt-5 text-small text-muted-foreground",children:[t.jsx(_,{className:"size-4","aria-hidden":!0}),O,t.jsx(Ex,{className:"ml-auto size-3.5","aria-hidden":!0})]})]}),N&&t.jsxs("div",{id:E,className:"flex flex-wrap items-center justify-end gap-2 border-t px-4 py-4",children:[t.jsxs("span",{className:"mr-auto font-mono text-small text-muted-foreground",children:["v",S.version]}),t.jsx(tn,{variant:"primary",label:"Use this template",prompt:vP(e,S,s),playgroundHref:Hc(S)})]})]},S.id)})})]}),t.jsxs("p",{className:"mt-10 text-center text-lead text-muted-foreground",children:["Or ",t.jsx("a",{className:"text-primary-text underline underline-offset-4 hover:text-primary-text/80",href:y0(Kf("")),children:"start from a blank agent"}),"."]})]})}const kE=p.createContext(new Map),z8={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email"};function NE({run:e}){const n=p.useContext(kE);if(!e.trigger)return null;const{id:s}=e.trigger,r=n.get(s),a=r?`${z8[r.kind]??"Trigger"}: ${r.name}`:`Trigger: ${s}`;return t.jsx("a",{href:`#/triggers/${encodeURIComponent(s)}`,onClick:i=>i.stopPropagation(),className:"inline-flex max-w-full",title:a,children:t.jsxs(je,{className:"max-w-full",children:[t.jsx(em,{className:"size-3 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"truncate",children:a})]})})}const Vf=["queued","working","paused","input_required","completed","failed","cancelled"],D8={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function F8({runs:e,agentName:n,onOpen:s,error:r,onRetry:a,onMore:i,loadingMore:c,filter:d={},onFilter:u,agentId:f,observations:x}){var g,h;const b=!!d.archived;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-5 py-2 md:px-6",children:[t.jsxs("h1",{className:"caps mr-auto flex items-center gap-2.5 text-small font-semibold",children:[t.jsx(Kc,{className:"size-4","aria-hidden":!0}),b?"Archived runs":"Runs"]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(At,{label:"Runs in one state",value:d.status??"",onChange:v=>u({...d,status:v||void 0}),className:"h-control-sm w-48",options:[{value:"",label:"Any state"},...Vf.map(v=>({value:v,label:D8[v]}))]}),t.jsxs(B,{size:"sm",variant:b?"primary":"outline","aria-pressed":b,onClick:()=>u({...d,archived:!b}),children:[t.jsx(qc,{"aria-hidden":!0})," Archived"]})]}),t.jsx(tn,{label:"Query",prompt:`${Em(location.origin,f)}
|
|
654
|
+
Current view: ${d.status?`status ${d.status}`:"all statuses"}; ${b?"archived runs":"non-archived runs"}.`,playgroundHref:gv(f,d)})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[r&&!e?t.jsx(Kt,{problem:r,onRetry:a,className:""}):e?!e.length&&!((g=x==null?void 0:x.data)!=null&&g.sessions.length)&&!d.status&&!b?t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(U8,{})}):!e.length&&((h=x==null?void 0:x.data)!=null&&h.sessions.length)?null:e.length?t.jsx(W8,{runs:e,agentName:n,onOpen:s}):t.jsx("p",{className:"px-4 py-16 text-center text-body text-muted-foreground",children:d.status?"No run matches.":b?"No archived runs.":"No runs yet."}):t.jsx(Fn,{label:"Loading the runs"}),x&&t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(pv,{read:x})}),e&&r&&t.jsx(Kt,{problem:r,className:"mt-4"}),e&&i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{type:"button",size:"sm",onClick:i,disabled:c,children:c?"Loading":"Load more"})})]})]})}function U8(){return t.jsxs("section",{"aria-labelledby":"first-run",className:"border border-primary/50 bg-primary/5 p-5",children:[t.jsx("p",{className:"caps text-label text-primary-text",children:"No runs yet"}),t.jsx("h2",{id:"first-run",className:"mt-2 text-xl font-semibold",children:"Start your first run"}),t.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A run is one piece of work an agent does: a question answered, a page researched, a file written. Each one is listed here with its state, when it started and what it cost."}),t.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[t.jsxs("a",{href:"#/playground",className:$c({variant:"solid",size:"lg"}),children:[t.jsx(Vo,{"aria-hidden":!0})," Start a run"]}),t.jsx("a",{href:"#/templates",className:$c({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function W8({runs:e,agentName:n,onOpen:s}){return t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{className:"sticky top-0 z-sticky hidden bg-background md:table-header-group",children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Status","Run","Agent","Kind","Started","Cost"].map(r=>t.jsx("th",{className:"border-b border-r px-4 py-3 text-left font-normal last:border-r-0",children:r},r))})}),t.jsx("tbody",{children:e.map(r=>t.jsxs("tr",{className:"cursor-pointer border-b hover:bg-accent",onClick:()=>s(r.run_id),children:[t.jsx("td",{className:"px-3 py-2.5 align-top",children:t.jsx(yl,{run:r})}),t.jsxs("td",{className:"px-3 py-2.5 align-top",children:[t.jsxs("button",{type:"button",className:"flex items-start gap-1 text-left",onClick:a=>{a.stopPropagation(),s(r.run_id)},children:[t.jsx("span",{className:"line-clamp-2",children:Nn(r)}),t.jsx(cr,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}),r.status==="completed"&&r.review&&t.jsx("span",{className:"mt-1 block text-small text-warning-text",children:r.review.reason}),r.trigger&&t.jsx("span",{className:"mt-1 flex",children:t.jsx(NE,{run:r})}),t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground md:hidden",children:[n(r.agent_id)," · ",mt(r.created_at)]})]}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top md:table-cell",children:n(r.agent_id)}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:r.kind}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:mt(r.created_at)}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:Zr(r.cost,{ended:Ua(r.status)})})]},r.run_id))})]})}function H8({agentId:e,details:n}){const{denied:s,asks:r}=mD(n),a=[...new Set([...s,...r])];return a.length?t.jsxs("p",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1",children:[a.map(i=>t.jsxs("a",{href:`#/agents/${encodeURIComponent(e)}/edit?tool=${encodeURIComponent(i)}`,className:"underline underline-offset-4",children:["Set ",i," for this agent"]},i)),t.jsxs("span",{children:["or for every agent: ",t.jsx("a",{href:"#/settings/tools",className:"underline underline-offset-4",children:"Settings → Tools"})]})]}):null}function B8(e,{base:n="/v2",onProgress:s,signal:r,request:a=()=>new XMLHttpRequest}={}){return new Promise((i,c)=>{if(r!=null&&r.aborted)return c(new ze(0,"aborted","The upload was stopped."));const d=a();d.open("POST",`${n}/files?path=${encodeURIComponent(e.name)}`),d.setRequestHeader("accept","application/json"),e.type&&d.setRequestHeader("content-type",e.type),d.upload.onprogress=u=>{u.lengthComputable&&u.total>0&&(s==null||s(Math.min(1,u.loaded/u.total)))},d.onload=()=>{let u=null;try{u=JSON.parse(d.responseText)}catch{}if(d.status===201||d.status===200){const b=u==null?void 0:u.file;return b!=null&&b.file_id?(s==null||s(1),i(b)):c(new ze(d.status,"bad_answer","The server's answer named no file."))}const f=u==null?void 0:u.error,x=new ze(d.status,(f==null?void 0:f.code)??"http_error",(f==null?void 0:f.message)??`The server answered ${d.status}.`,(f==null?void 0:f.retryable)??!1,f==null?void 0:f.request_id);f!=null&&f.fields&&(x.fields=f.fields),c(x)},d.onerror=()=>c(new ze(0,"network","The upload did not reach the server.")),d.onabort=()=>c(new ze(0,"aborted","The upload was stopped.")),r==null||r.addEventListener("abort",()=>d.abort(),{once:!0}),d.send(e)})}const G8=(e,n,s)=>B8(e,{onProgress:n,signal:s});function gg(e){if(!(e instanceof ze))return e instanceof Error?e.message:String(e);const n=(e.fields??[]).filter(s=>s.message!==e.message).map(s=>s.message);return[e.message,...n].join(" ")}function q8({upload:e,remove:n,limits:s,frozen:r=!1}){const[a,i]=p.useState([]),[c,d]=p.useState([]),u=p.useRef(new Map),f=p.useRef(0),x=p.useRef(0);x.current=a.length;const b=p.useRef({items:a,frozen:r,remove:n});b.current={items:a,frozen:r,remove:n};const g=p.useRef(!0);p.useEffect(()=>{g.current=!0;const k=u.current;return()=>{var _;g.current=!1;for(const E of k.values())E.abort();const{items:$,frozen:S,remove:N}=b.current;if(!S)for(const E of $)E.file&&!E.removing&&((_=N==null?void 0:N(E.file.file_id))==null||_.catch(()=>{}))}},[]);const h=p.useCallback(k=>{if(b.current.frozen)return;const $=[],S=s?s.max_files_per_run-x.current:1/0,N=(s==null?void 0:s.max_upload_bytes)??null,_=[];for(const O of k)N!==null&&O.size>N?$.push({text:`${O.name} is ${nl(O.size)}: this server takes files up to ${nl(N)}.`}):_.length>=S?$.push({text:`${O.name} is not added: a run names at most ${s==null?void 0:s.max_files_per_run} files here.`}):_.push(O);d($);const E=_.map(O=>({key:`f${f.current++}`,name:O.name,size:O.size,progress:0}));x.current+=E.length,i(O=>[...O,...E]),E.forEach((O,A)=>{const I=new AbortController;u.current.set(O.key,I);const M=R=>{g.current&&i(P=>P.map(D=>D.key===O.key?{...D,...R}:D))};e(_[A],R=>M({progress:R}),I.signal).then(R=>{var P,D,W;if(u.current.delete(O.key),I.signal.aborted){(W=(D=(P=b.current).remove)==null?void 0:D.call(P,R.file_id))==null||W.catch(Y=>{g.current&&d(H=>[...H,{text:`${O.name} was sent before it was stopped, and was not removed: ${gg(Y)}`}])});return}M({file:R,progress:1})},R=>{u.current.delete(O.key),!(I.signal.aborted||!g.current)&&(i(P=>P.filter(D=>D.key!==O.key)),d(P=>[...P,{text:`${O.name}: ${gg(R)}`}]))})})},[s==null?void 0:s.max_files_per_run,s==null?void 0:s.max_upload_bytes,e]),v=p.useCallback(k=>{var E;const{items:$,frozen:S,remove:N}=b.current,_=$.find(O=>O.key===k);if(!(S||!_||_.removing)){if(!_.file||!N){(E=u.current.get(k))==null||E.abort(),u.current.delete(k),i(O=>O.filter(A=>A.key!==k));return}i(O=>O.map(A=>A.key===k?{...A,removing:!0}:A)),d(O=>O.filter(A=>A.about!==k)),N(_.file.file_id).then(()=>{g.current&&i(O=>O.filter(A=>A.key!==k))},O=>{g.current&&(i(A=>A.map(I=>I.key===k?{...I,removing:!1}:I)),d(A=>[...A,{about:k,text:`${_.name} was not removed: ${gg(O)}`}]))})}},[]),y=p.useCallback(()=>{b.current={...b.current,items:[]},i([]),d([])},[]),j=a.flatMap(k=>k.file&&!k.removing?[k.file.file_id]:[]);return{items:a,refusals:c.map(k=>k.text),add:h,drop:v,clear:y,fileIds:j,frozen:r,busy:a.some(k=>!k.file||k.removing)}}function b0({attachments:e,limits:n,disabled:s,compact:r=!1}){const a=p.useRef(null),[i,c]=p.useState(!1),{items:d,refusals:u,add:f,drop:x}=e,b=s||e.frozen,g=n?[`up to ${n.max_files_per_run} files`,...n.max_upload_bytes!==null?[`${nl(n.max_upload_bytes)} each`]:[]].join(", "):"";return t.jsxs("div",{className:ae("border border-dashed px-3 py-2.5",i?"border-primary bg-primary/5":"border-border",r&&"max-sm:border-0 max-sm:p-0"),onDragOver:h=>{b||(h.preventDefault(),c(!0))},onDragLeave:()=>c(!1),onDrop:h=>{h.preventDefault(),c(!1),b||f([...h.dataTransfer.files])},role:"group","aria-label":"Files for the run",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>{var h;return(h=a.current)==null?void 0:h.click()},disabled:b,title:r?`Attach files${g?` (${g})`:""}`:void 0,className:ae(r&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[t.jsx(wT,{"aria-hidden":!0})," ",t.jsx("span",{className:ae(r&&"max-sm:sr-only"),children:"Attach files"})]}),t.jsxs("span",{className:ae("text-small text-muted-foreground",r&&"max-sm:hidden"),children:["or drop them here",g?` (${g})`:"",". The run finds them in inputs/."]}),t.jsx("input",{ref:a,type:"file",multiple:!0,hidden:!0,"aria-label":"Pick files",onChange:h=>{f([...h.target.files??[]]),h.target.value=""}})]}),d.length>0&&t.jsx("ul",{className:"mt-2 flex flex-wrap gap-2","aria-label":"Attached files",children:d.map(h=>t.jsxs("li",{className:"flex h-7 items-center gap-2 border bg-card px-2 font-mono text-small",children:[t.jsx("span",{className:"max-w-[16rem] truncate",title:h.name,children:h.name}),t.jsx("span",{className:"text-muted-foreground",children:nl(h.size)}),!h.file&&t.jsxs("span",{className:"text-muted-foreground","aria-label":`${h.name} sent ${Math.round(h.progress*100)}%`,children:[Math.round(h.progress*100),"%"]}),h.removing&&t.jsx("span",{className:"text-muted-foreground",children:"removing"}),t.jsx("button",{type:"button",onClick:()=>x(h.key),disabled:b||h.removing,"aria-label":`Remove ${h.name}`,className:"text-muted-foreground hover:text-foreground disabled:opacity-45",children:t.jsx(Qo,{className:"size-3.5","aria-hidden":!0})})]},h.key))}),d.some(h=>!h.file)&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:"The run can start once every file is sent."}),u.length>0&&t.jsx("ul",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:u.map((h,v)=>t.jsx("li",{children:h},`${v}:${h}`))})]})}const Ju={"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."},fy=(e,n)=>e instanceof ze?{status:e.status,ms:n,body:{error:{...e.toApiError(),...e.fields?{fields:e.fields}:{}}}}:{status:0,ms:n,body:{error:{code:"network",message:String(e)}}};function K8({agents:e,revisions:n=[],efforts:s,origin:r,agentId:a,onAgent:i,onSend:c,onOpenRun:d,result:u=null,live:f,limits:x,upload:b=G8,removeUpload:g}){var Ae,De,ut;const[h,v]=p.useState(a??((Ae=e[0])==null?void 0:Ae.agent_id)??"");p.useEffect(()=>{var ee;a&&a!==h&&e.some(Re=>Re.agent_id===a)?v(a):e.some(Re=>Re.agent_id===h)||v(((ee=e[0])==null?void 0:ee.agent_id)??"")},[e,a]);const y=e.find(ee=>ee.agent_id===h),j=_v(y),k=Zn(y==null?void 0:y.definition),$=(y==null?void 0:y.kind)??"agentic",[S,N]=p.useState(""),[_,E]=p.useState(""),O=_?(De=n.find(ee=>ee.revision===_))==null?void 0:De.definition:void 0,A=$==="agentic"?JSON.stringify(((ut=O??(y==null?void 0:y.definition))==null?void 0:ut.input_schema)??null):"null",I=p.useMemo(()=>$==="agentic"?s8(JSON.parse(A)):null,[$,A]),M=(I==null?void 0:I.kind)==="fields"?I.form:null,R=$==="workflow"||(I==null?void 0:I.kind)==="json",[P,D]=p.useState({});p.useEffect(()=>{D(M?sE(M):{})},[h,A]);const W=$==="workflow"?F6(y==null?void 0:y.definition.workflow):(I==null?void 0:I.kind)==="json"?I.example:null,Y=p.useRef("");p.useEffect(()=>{if(S.trim()&&S!==Y.current)return;const ee=(W==null?void 0:W.text)??"";Y.current=ee,N(ee)},[h,W==null?void 0:W.text]);const[H,q]=p.useState(""),[F,G]=p.useState(""),[U,z]=p.useState(""),[Q,K]=p.useState("form"),[Z,de]=p.useState(u?"response":"code"),[re,fe]=p.useState("curl"),[ve,Ee]=p.useState(!1),[ue,pe]=p.useState(u),me=new Set((M==null?void 0:M.fields.map(([ee])=>ee))??[]),ke=ee=>{const Re=mx(ee);return Re!==null&&me.has(Re)?Re:null},$e=p.useMemo(()=>{var Ze,at;const ee=ue&&ue.status>=400?(Ze=ue.body)==null?void 0:Ze.error:void 0;if(!ee||typeof ee.message!="string")return;const Re=Array.isArray(ee.fields)?ee.fields.filter(Xe=>!!Xe&&typeof Xe.field=="string"&&typeof Xe.message=="string"):[],Qe=Re.filter(Xe=>Xe.message!==ee.message&&ke(Xe.field)===null);return{message:ee.message,more:Qe,issues:Re,box:typeof((at=ee.details)==null?void 0:at.box)=="string"?ee.details.box:void 0,details:ee.code==="agent_not_runnable"?ee.details:void 0}},[ue,A]),[J,Le]=p.useState(new Set);p.useEffect(()=>{Le(new Set)},[ue]);const qe=(ee,Re,Qe)=>{D(Ze=>({...Ze,[ee]:Qe})),Le(Ze=>{const at=new Set(Ze);return nE(Re,Qe)?at.add(ee):at.delete(ee),at})},rt=ee=>J.has(ee)?[]:(($e==null?void 0:$e.issues)??[]).filter(Re=>ke(Re.field)===ee),[vt,st]=p.useState(!1),Se=p.useMemo(()=>dr(),[]),Be=q8({upload:b,remove:g,limits:x,frozen:vt}),he=I6($,{text:S,revision:_,effort:H,maxCostUsd:F,fileIds:Be.fileIds,repo:U,...M?{typed:{fields:Km(M,P),contentRequired:M.contentRequired}}:{},...(I==null?void 0:I.kind)==="json"?{json:!0}:{}}),Ve=he.ok?he.body:{input:R?S:M?a8(M,S,P):{content:S},...Be.fileIds.length?{file_ids:Be.fileIds}:{}},ct=h?Se.keyFor(h,Ve):"",Me=re==="curl"?U6(r,h,Ve,ct):`const res = await fetch(${JSON.stringify(`${r}/v2/agents/${h||"{agent_id}"}/runs`)}, {
|
|
655
|
+
method: "POST",
|
|
656
|
+
headers: {
|
|
657
|
+
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
658
|
+
"Content-Type": "application/json",
|
|
659
|
+
"Idempotency-Key": ${JSON.stringify(ct)},
|
|
660
|
+
},
|
|
661
|
+
body: JSON.stringify(${JSON.stringify(Ve,null,2).replace(/\n/g,`
|
|
662
|
+
`)}),
|
|
663
|
+
});
|
|
664
|
+
console.log(res.status, await res.json());`,ot=!!j&&(!j.connected||j.state!=="ready"||!j.capabilities.launch||!!F.trim()||!!H||!!U.trim()||Be.fileIds.length>0||Be.busy),oe=async()=>{if(k||ot||!he.ok||!c||Be.busy)return;st(!0);const ee=await H6(Se,h,he.body,c);st(!1),pe(ee),de("response"),Ee(!0),ee.status>=200&&ee.status<300&&Be.clear()},xe=R?$==="workflow"?'{ "subject": "...", "body": "..." }':"The agent's input, as JSON":`The run's ${M?"message":"first message"}, e.g. Summarize the standup: we ship Friday.`;return e.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-hidden",children:[t.jsxs("div",{"aria-label":"Playground agent",className:"flex shrink-0 flex-wrap items-center gap-3 border-b px-5 py-3 md:px-6",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-small",children:[t.jsx("label",{htmlFor:"playground-agent",className:"caps text-muted-foreground",children:"Agent"}),t.jsx(At,{id:"playground-agent",label:"Agent",value:h,onChange:ee=>{v(ee),E(""),i==null||i(ee)},options:sd(e).map(ee=>({value:ee.agent_id,label:ee.definition.name})),className:"w-56 max-w-[60vw]"})]}),k?t.jsxs("span",{className:"font-mono text-small",children:[Ko(k.runtime)," · Your backend"]}):t.jsxs("span",{className:"font-mono text-small",children:[t.jsx("span",{className:"text-primary-text",children:"POST"})," ",t.jsxs("span",{className:"text-muted-foreground",children:["/v2/agents/",h||"{agent_id}","/runs"]})]}),t.jsx("span",{className:"flex-1"}),!k&&t.jsx("span",{className:"caps text-label text-muted-foreground",children:"Live API"}),!k&&t.jsx(B,{size:"sm",type:"button",onClick:()=>Ee(ee=>!ee),"aria-expanded":ve,className:"caps hidden border px-3 py-1.5 text-label text-muted-foreground hover:text-foreground short:inline-flex",children:ve?"Hide code":"Show code"})]}),k?t.jsxs("section",{className:"space-y-4 p-5 md:p-8",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Run through your backend"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"This agent keeps its existing SDK, tools and job entrypoint. Your coding agent can run it there; AgentRun records its progress and learning."}),t.jsx(tn,{variant:"primary",label:"Run agent",prompt:kv(r,h,k.runtime)})]}):t.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:[@media(min-height:501px)]:grid-cols-2",children:[t.jsxs("section",{"aria-label":"Request",className:ae("flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",ve&&"short:hidden"),children:[t.jsxs("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:[t.jsx("span",{className:"text-lead font-semibold",children:"Request"}),t.jsx("span",{className:"flex gap-4 text-small",children:["form","json"].map(ee=>t.jsx("button",{type:"button",onClick:()=>K(ee),className:ae("border-b pb-1 capitalize",Q===ee?"border-primary":"border-transparent text-muted-foreground"),children:ee==="json"?"JSON":"Form"},ee))})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto px-5 py-6 md:px-6",children:[j&&t.jsxs("div",{className:"space-y-2 border p-4 text-small",role:"status",children:[t.jsxs("p",{children:["Native execution on ",j.machine_id,": ",j.project,". It reuses your native model, profile and sign-in. Native spend caps are unavailable. Use files already in the source project; uploaded attachments and effort overrides are unsupported."]}),ot&&t.jsx("p",{className:"text-warning-text",children:U.trim()?"This request selects a repository. Native execution uses its source project.":F.trim()?"This request has a spend cap. Native execution cannot enforce it.":H||Be.fileIds.length?"This request has managed effort or attachments. Native execution uses its source configuration and project files.":"Verify a connected native launch before sending a run."}),!!U.trim()&&t.jsx(B,{size:"sm",onClick:()=>z(""),children:"Use native source repository"}),!!H&&t.jsx(B,{size:"sm",onClick:()=>q(""),children:"Use native configured effort"}),Be.fileIds.length>0&&t.jsx(B,{size:"sm",onClick:()=>Be.clear(),children:"Remove uploaded attachments"}),!!F.trim()&&t.jsx(B,{size:"sm",onClick:()=>G(""),children:"Remove cap for native execution"}),t.jsx("a",{href:on(h),className:"underline underline-offset-2",children:"Open native connection"})]}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Start a run"}),t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:[y?`${y.definition.name}: ${$==="agentic"?"an":"a"} ${$} agent.`:"Pick an agent."," The server answers 202 with the run; follow it on its page."]})]}),Q==="json"?t.jsxs(t.Fragment,{children:[t.jsx("pre",{className:"overflow-auto border bg-card p-4 font-mono text-small leading-[1.7]",children:JSON.stringify(Ve,null,2)}),!j&&t.jsx(wa,{name:"file_ids",note:Ju.file_ids,children:t.jsx(b0,{attachments:Be,limits:x})})]}):t.jsxs(t.Fragment,{children:[t.jsxs(wa,{name:R?"input":"input.content",required:!M||M.contentRequired,optional:!!M&&!M.contentRequired,error:!he.ok&&he.field==="input"&&S?he.message:void 0,children:[t.jsx(ln,{value:S,onChange:ee=>N(ee.target.value),rows:R?7:4,placeholder:xe,className:w0}),W&&t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[D6(W,"start",$==="workflow"?"workflow":"agent"),W.fields.length>0&&t.jsxs(t.Fragment,{children:[" Fields: ",W.fields.map((ee,Re)=>t.jsxs("span",{title:ee.note,children:[Re?", ":"",t.jsx("span",{className:"text-foreground",children:ee.name})]},ee.name)),"."]})]})]}),M==null?void 0:M.fields.map(([ee,Re])=>t.jsxs("div",{"data-field":`input.${ee}`,children:[t.jsx(aE,{field:Re,label:qm(ee,Re),help:Gf(Re),value:P[ee]??"",onChange:Qe=>qe(ee,Re,Qe)}),t.jsx(Mo,{issues:rt(ee),words:Qe=>oE(Qe,ee,Re)})]},ee)),!j&&t.jsx(wa,{name:"file_ids",note:Ju.file_ids,children:t.jsx(b0,{attachments:Be,limits:x})}),t.jsx(wa,{name:"revision",note:"Empty runs the current revision.",children:t.jsx(At,{label:"Revision",value:_,onChange:E,className:"w-full",options:[{value:"",label:"The current revision"},...n.map(ee=>({value:ee.revision,label:`rev ${ee.version}${ee.current?" (current)":""}${ee.note?`: ${ee.note}`:""}`}))]})}),!j&&t.jsx(wa,{name:"effort",note:"How hard the model thinks. Empty uses the agent's own.",children:t.jsx(At,{label:"Effort",value:H,onChange:q,className:"w-full",options:["",...s].map(ee=>({value:ee,label:ee||"Agent default"}))})}),$==="agentic"&&!j&&t.jsx(wa,{name:"repo",note:Ju.repo,error:!he.ok&&he.field==="repo"?he.message:void 0,children:t.jsx(Ie,{value:U,onChange:ee=>z(ee.target.value),placeholder:"owner/name"})}),$==="agentic"&&!j&&t.jsxs(wa,{name:"max_cost_usd",note:"A spend cap in dollars; empty means none.",error:!he.ok&&he.field==="max_cost_usd"?he.message:void 0,children:[t.jsx(Ie,{value:F,onChange:ee=>G(ee.target.value),inputMode:"decimal",placeholder:"e.g. 0.50",className:w0}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:t.jsx(kC,{})})]})]})]}),t.jsxs("footer",{className:"flex shrink-0 flex-wrap items-center justify-between gap-3 border-t px-5 py-3 md:px-6",children:[t.jsx("span",{className:"text-small text-muted-foreground",children:"Sends a real request to this server."}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[t.jsx(tn,{label:"Use your agent",prompt:yP(r,h,Ve),disabled:ot||!he.ok||!h||Be.busy}),t.jsxs(B,{variant:"primary",size:"lg",onClick:oe,disabled:ot||!he.ok||!c||vt||!h||Be.busy,title:Be.busy?"Waiting for the files to be sent":void 0,children:[t.jsx(Vo,{"aria-hidden":!0})," ",vt?"Sending":"Send request"]})]})]})]}),t.jsxs("section",{"aria-label":"Code and response",className:ae("flex min-h-0 flex-col",!ve&&"short:hidden"),children:[t.jsxs("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:[t.jsxs("span",{className:"flex gap-4 text-body",children:[t.jsx("button",{type:"button",onClick:()=>de("code"),className:ae("border-b pb-1",Z==="code"?"border-primary":"border-transparent text-muted-foreground"),children:"Code"}),t.jsxs("button",{type:"button",onClick:()=>de("response"),disabled:!ue,className:ae("border-b pb-1 disabled:opacity-45",Z==="response"?"border-primary":"border-transparent text-muted-foreground"),children:["Response",ue&&t.jsx("span",{className:ae("ml-2 font-mono",ue.status<300?"text-success-text":"text-destructive-text"),children:ue.status})]})]}),Z==="code"&&t.jsx(B,{size:"icon",variant:"outline","aria-label":"Copy code",onClick:()=>{var ee;return void((ee=navigator.clipboard)==null?void 0:ee.writeText(Me))},children:t.jsx(Ba,{"aria-hidden":!0})})]}),Z==="code"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex gap-5 border-b px-5 text-small md:px-6",children:["curl","fetch"].map(ee=>t.jsx("button",{type:"button",onClick:()=>fe(ee),className:ae("-mb-px border-b-2 py-2.5",re===ee?"border-primary":"border-transparent text-muted-foreground"),children:ee==="curl"?"cURL":"JavaScript"},ee))}),t.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:Me}),t.jsx("footer",{className:"border-t px-5 py-3 text-small text-muted-foreground md:px-6",children:"The same request from your code: set AGENTRUN_API_KEY in your environment."})]}):ue&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"border-b px-5 py-2.5 font-mono text-small md:px-6",children:[t.jsx("span",{className:ue.status<300?"text-success-text":"text-destructive-text",children:ue.status})," ",t.jsxs("span",{className:"text-muted-foreground",children:[ue.ms," ms"]})]}),$e&&t.jsxs("p",{className:"border-b px-5 py-2.5 font-mono text-small text-destructive-text md:px-6",role:"alert",children:["The run did not start: ",$e.message,$e.box?t.jsxs("span",{className:"text-muted-foreground",children:[" (box: ",$e.box,")"]}):null,t.jsx(H8,{agentId:h,details:$e.details}),$e.more.length>0&&t.jsx("span",{className:"mt-1 block",children:$e.more.map(ee=>t.jsxs("span",{className:"block",children:[ee.field,": ",ee.message]},`${ee.field}:${ee.message}`))})]}),ue.runId&&f?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden border-b short:overflow-auto",children:f(ue.runId)}),t.jsxs("details",{className:"border-b px-5 py-2.5 md:px-6",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Response body"}),t.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words py-3 font-mono text-small leading-[1.8]",children:JSON.stringify(ue.body,null,2)})]})]}):t.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(ue.body,null,2)}),ue.runId&&t.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(ue.runId),className:"caps flex items-center justify-between border-t px-5 py-4 text-small text-primary-text hover:bg-accent md:px-6",children:["Open this run ",t.jsx(Ex,{className:"size-4","aria-hidden":!0})]})]})]})]})]}):t.jsxs("section",{"aria-label":"Request",className:"space-y-4 p-5 md:p-8",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Start a run"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"Connect an existing native agent or create an agent before starting a run."}),t.jsx("a",{href:"#/agents/connect",className:"block text-body underline underline-offset-2",children:"Connect agent"}),t.jsx("a",{href:"#/agents/new",className:"block text-body underline underline-offset-2",children:"Create an agent"}),t.jsx("a",{href:"#/templates",className:"block text-body underline underline-offset-2",children:"Browse templates"}),t.jsx("dl",{className:"space-y-2",children:Object.entries(Ju).map(([ee,Re])=>t.jsxs("div",{children:[t.jsx("dt",{className:"font-mono text-body",children:ee}),t.jsx("dd",{className:"text-small text-muted-foreground",children:Re})]},ee))}),t.jsxs("code",{className:"text-small",children:["/v2/agents/","{agent_id}","/runs"]})]})}const w0="w-full border bg-card px-3 py-2.5 font-mono text-body outline-none placeholder:text-muted-foreground focus:border-border-strong";function wa({name:e,required:n,optional:s,note:r,error:a,children:i}){return t.jsxs("div",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsx("span",{className:"font-mono text-body",children:e}),n?t.jsx("span",{className:"text-label text-muted-foreground",children:"required"}):s&&t.jsx("span",{className:"text-label text-muted-foreground",children:"optional"})]}),i,r&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:r}),a&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-destructive-text",role:"alert",children:a})]})}const j0="h-11 w-full border bg-card px-3 text-lead outline-none focus:border-primary",V8=e=>`'${e.replaceAll("'","'\\''")}'`;function Y8({v2:e,origin:n,agentId:s,filter:r={}}){const[a,i]=p.useState(r.status??""),[c,d]=p.useState(!!r.archived),[u,f]=p.useState(50),[x,b]=p.useState(""),[g,h]=p.useState("code"),[v,y]=p.useState("curl"),[j,k]=p.useState(null),[$,S]=p.useState(null),[N,_]=p.useState(!1),[E,O]=p.useState(!1),A=p.useRef(0);p.useEffect(()=>(A.current++,i(r.status??""),d(!!r.archived),b(""),S(null),k(null),_(!1),()=>{A.current++}),[s,r.status,r.archived]);const I={...a?{status:a}:{},...c?{archived:!0}:{}},M=s?`/v2/agents/${encodeURIComponent(s)}/runs`:"/v2/runs",R=new URLSearchParams({limit:String(u)});x&&R.set("cursor",x),a&&R.set("status",a),c&&R.set("archived","true");const P=`${n}${M}?${R}`,D=v==="curl"?`curl -X GET ${V8(P)} \\
|
|
665
|
+
-H "Authorization: Bearer $AGENTRUN_API_KEY"`:`const response = await fetch(${JSON.stringify(P)}, {
|
|
666
|
+
method: "GET",
|
|
667
|
+
headers: { Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\` },
|
|
668
|
+
});
|
|
669
|
+
console.log(response.status, await response.json());`,W=`${Em(n,s)}
|
|
670
|
+
|
|
671
|
+
Prepared read-only request: GET ${P}
|
|
672
|
+
Use exactly this agent scope, status, archive selection, page size and cursor. Do not broaden the query or issue writes. Show the results and links to relevant runs. Follow next_cursor only when more results are needed, keeping the same filters.`,Y=()=>{A.current++,b(""),S(null),k(null),O(!1)},H=async(q=x)=>{if(N)return;const F=++A.current;_(!0),S(null),k(null),b(q),O(!1);const G=performance.now();try{const U=s?await e.listAgentRuns(s,u,q||void 0,I):await e.listRuns(u,q||void 0,I);if(A.current!==F)return;S(U),k({status:200,ms:performance.now()-G,body:U})}catch(U){if(A.current!==F)return;k(fy(U,performance.now()-G))}finally{A.current===F&&(_(!1),h("response"))}};return t.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-2",children:[t.jsxs("section",{className:"flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",children:[t.jsx("header",{className:"flex h-12 shrink-0 items-center border-b px-6",children:t.jsx("span",{className:"text-lead font-semibold",children:"Request"})}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto p-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"List runs"}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:"Inspect server-run sessions and imported history. This request only reads data."})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Agent"}),t.jsx(Ie,{className:j0,value:s??"All agents",readOnly:!0})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Status"}),t.jsx(At,{label:"Run status",value:a,disabled:N,onChange:q=>{i(q),Y()},options:[{value:"",label:"All statuses"},...Vf.map(q=>({value:q,label:q.replaceAll("_"," ")}))]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Archive"}),t.jsx(At,{label:"Archived runs",value:String(c),disabled:N,onChange:q=>{d(q==="true"),Y()},options:[{value:"false",label:"Current runs"},{value:"true",label:"Archived runs"}]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Page size"}),t.jsx(At,{label:"Page size",value:String(u),disabled:N,onChange:q=>{f(Number(q)),Y()},options:[10,25,50,100].map(q=>({value:String(q),label:String(q)}))})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Cursor"}),t.jsx(Ie,{"aria-label":"Cursor",className:`${j0} font-mono text-small`,value:x,disabled:N,placeholder:"First page",onChange:q=>{A.current++,b(q.target.value),S(null),k(null)}})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t p-4",children:[t.jsx(tn,{label:"Use your agent",prompt:W}),t.jsxs(B,{variant:"primary",disabled:N,onClick:()=>void H(),children:[t.jsx(Vo,{"aria-hidden":!0}),N?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(q=>t.jsx("button",{onClick:()=>h(q),className:ae("h-12 border-b text-small capitalize",g===q?"border-primary":"border-transparent text-muted-foreground"),children:q},q)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{var q;(q=navigator.clipboard)==null||q.writeText(D).then(()=>O(!0),()=>O(!1))},children:t.jsx(Ba,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:E?"Code copied":""})]}),g==="code"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-12 shrink-0 gap-5 border-b px-6",children:["curl","fetch"].map(q=>t.jsx("button",{onClick:()=>y(q),className:ae("border-b text-small",v===q?"border-primary":"border-transparent text-muted-foreground"),children:q==="curl"?"cURL":"JavaScript"},q))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:D})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:j?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[j.status||"Network error"," · ",Math.round(j.ms)," ms"]}),$&&t.jsxs(t.Fragment,{children:[$.runs.length?t.jsx("ul",{className:"divide-y border",children:$.runs.map(q=>t.jsx("li",{children:t.jsxs("a",{className:"flex items-center gap-3 p-3 text-lead hover:bg-accent",href:`#/runs/${encodeURIComponent(q.run_id)}`,children:[t.jsx(yl,{run:q}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:q.title||q.run_id}),t.jsx(cr,{className:"size-3.5 shrink-0","aria-hidden":!0})]})},q.run_id))}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"No runs match this request."}),$.next_cursor&&t.jsx(B,{size:"sm",disabled:N,onClick:()=>void H($.next_cursor),children:"Next page"})]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(j.body,null,2)})]}):t.jsx("p",{className:"text-lead text-muted-foreground",children:N?"Loading runs…":"Send a request to see its response."})})]})]})}const fc=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Ri="w-full border bg-card px-3 py-3 text-lead outline-none focus:border-primary";function Q8({v2:e,origin:n,operation:s,agentId:r,draft:a,harnesses:i=[]}){const c=s==="edit-agent",d=P8(a??null),[u,f]=p.useState(null),[x,b]=p.useState(null),[g,h]=p.useState(void 0),[v,y]=p.useState(d??Kf("")),[j,k]=p.useState(JSON.stringify(d??Kf(""),null,2)),[$,S]=p.useState(j),N=NC(j!==$),[_,E]=p.useState("form"),[O,A]=p.useState("code"),[I,M]=p.useState("curl"),[R,P]=p.useState(null),[D,W]=p.useState(null),[Y,H]=p.useState(null),[q,F]=p.useState(!1),[G,U]=p.useState(!1),[z,Q]=p.useState(0),[K,Z]=p.useState(!1);p.useEffect(()=>{if(!c)return;if(!r){P("Choose an agent from Connected agents to edit its definition.");return}let he=!0;return f(null),h(void 0),P(null),e.getAgent(r).then(({agent:Ve,etag:ct})=>{if(!he)return;f(Ve),b(ct);const Me={definition:{...Ve.definition,version:Ve.revisions+1}},ot=JSON.stringify(Me,null,2);y(Me),k(ot),S(ot),W(null),U(!1)}).catch(Ve=>{he&&P(String(Ve instanceof Error?Ve.message:Ve))}),()=>{he=!1}},[e,c,r,z]);const de=(he,Ve)=>{const ct={...v.definition,[he]:he==="model"?Ve.trim():Ve};he==="model"&&!Ve.trim()&&!c&&delete ct.model;const Me={...v,definition:ct};y(Me),k(JSON.stringify(Me,null,2))};let re=v,fe=null;if(_==="json")try{const he=JSON.parse(j);!fc(he)||!fc(he.definition)?fe="Include a definition object in the request.":re=he}catch{fe="Enter valid JSON before sending the request."}!fe&&re.note!==void 0&&typeof re.note!="string"&&(fe="note must be a string.");for(const he of["description","instructions","harness","model"])!fe&&re.definition[he]!==void 0&&typeof re.definition[he]!="string"&&(fe=`definition.${he} must be a string.`);!fe&&typeof re.definition.name!="string"&&(fe="Give this agent a name.");const ve=!fe;!fe&&!re.definition.name.trim()&&(fe="Give this agent a name."),!fe&&!re.definition.workflow&&(typeof re.definition.instructions!="string"||!re.definition.instructions.trim())&&(fe="Add instructions for this agent.");const Ee=re;if(!fe&&c&&u){const he=fc(re.definition.workflow),Ve=Object.keys(u.definition).filter(Me=>!Object.hasOwn(re.definition,Me));for(const Me of["id","name","description"])!fe&&re.definition[Me]!==u.definition[Me]&&(fe=`definition.${Me} is fixed when the agent is created. Restore its current value.`);for(const Me of["native","sdk"])!fe&&u.definition[Me]!==void 0&&Ve.includes(Me)&&(fe=`Cannot remove definition.${Me} here. Edit the original source configuration with your agent.`);if(!fe&&!he)for(const Me of["input_schema","output_schema"])Ve.includes(Me)&&(fe=`Cannot remove definition.${Me}: the API keeps an omitted schema. Restore it or supply a replacement schema.`);!fe&&Ve.includes("harness")&&(fe='Cannot remove definition.harness: the API keeps it. Select an explicit harness, such as "pi" for the default.'),!fe&&(u.definition.computer!==void 0||u.definition.place!==void 0)&&!Object.hasOwn(re.definition,"computer")&&!Object.hasOwn(re.definition,"place")&&(fe='Cannot remove definition.computer and definition.place together: the API keeps the setting. Set computer to {"kind":"none"} or place to {"mode":"runner"} explicitly.');const ct=fc(re.skills)&&Object.keys(re.skills).length===0;if(!fe&&!Object.hasOwn(re.definition,"skills")&&!ct&&(u.definition.skills.length>0||fc(re.skills)&&Object.keys(re.skills).length>0)&&(fe="Cannot remove definition.skills while skill files are retained or supplied. Give their skill names, or use definition.skills: [] with skills: {} to clear them."),!fe){const Me=Object.fromEntries(Ve.map(Ae=>[Ae,Ae==="learning"?he?void 0:!1:Ae==="max_cost_usd"?0:Ae==="checkout"?he?void 0:"none":Ae==="tools"||Ae==="skills"?[]:void 0])),{unchanged:ot,...oe}=id(u,{...Me,...re.definition},re.note??""),xe=re.skills!==void 0&&!qi(re.skills,g);ot&&!xe&&(fe="Change the definition before saving a revision."),xe&&(oe.definition.version=u.revisions+1),re={...re,...oe}}}c&&u&&!x&&(fe="This server did not provide a revision ETag. Reload the current revision before editing.");const ue=c?"PUT":"POST",pe=c?`/v2/agents/${encodeURIComponent(r??"")}/definition`:"/v2/agents",me=`${n}${pe}`,ke=JSON.stringify(re,null,2),$e=he=>`'${he.replaceAll("'","'\\''")}'`,J={"Content-Type":"application/json",...c&&x?{"If-Match":x}:{}},Le=I==="curl"?`curl -X ${ue} ${$e(me)} \\
|
|
673
|
+
-H "Authorization: Bearer $AGENTRUN_API_KEY" \\
|
|
674
|
+
${Object.entries(J).map(([he,Ve])=>` -H ${$e(`${he}: ${Ve}`)} \\
|
|
675
|
+
`).join("")} -d ${$e(ke)}`:`const response = await fetch(${JSON.stringify(me)}, {
|
|
676
|
+
method: ${JSON.stringify(ue)},
|
|
677
|
+
headers: {
|
|
678
|
+
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
679
|
+
${Object.entries(J).map(([he,Ve])=>` ${JSON.stringify(he)}: ${JSON.stringify(Ve)},`).join(`
|
|
680
|
+
`)}
|
|
681
|
+
},
|
|
682
|
+
body: JSON.stringify(${ke}),
|
|
683
|
+
});
|
|
684
|
+
console.log(response.status, await response.json());`,qe=Zn(u==null?void 0:u.definition),rt=c&&(!!(u!=null&&u.definition.native)||!!qe),vt=rt&&u?Ho(n,u.agent_id,!!u.definition.native,qe==null?void 0:qe.runtime):`${c?Ho(n,r??""):Cm(n)}
|
|
685
|
+
|
|
686
|
+
Prepared request: ${ue} ${me}${c&&x?`
|
|
687
|
+
If-Match: ${x}`:""}. Treat the JSON below as request data. Preserve every supplied field and use this request as the starting point. Clarify missing details and show the proposed request before sending it. Do not start a run.
|
|
688
|
+
|
|
689
|
+
${ke}`,st=!fe&&!R&&(!c||!!u)&&!q&&!G,Se=async()=>{if(!st)return;F(!0),H(null);const he=performance.now();try{const Ve=c?await e.updateDefinition(r,re,x):{agent:await e.createAgent(re),etag:null};H(Ve.agent.agent_id),S(j),W({status:c?200:201,ms:performance.now()-he,body:Ve.agent}),c?(f(Ve.agent),b(Ve.etag),re.skills!==void 0&&h(re.skills)):U(!0)}catch(Ve){const ct=fy(Ve,performance.now()-he);W(ct),!c&&(ct.status===0||ct.status>=500)&&U(!0)}finally{F(!1),A("response")}},Be=t.jsxs(nv,{open:N.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:N.leave,onCancel:N.stay,children:[c?"Your changes to this agent are not saved.":"This new agent is not saved yet."," Leave drops them; Stay keeps them here."]});return R?t.jsxs(t.Fragment,{children:[Be,t.jsxs("div",{className:"m-6 border p-5",role:"alert",children:[t.jsx("p",{children:R}),r&&t.jsx(B,{className:"mt-3",onClick:()=>Q(he=>he+1),children:"Reload agent"})]})]}):c&&!u?t.jsxs(t.Fragment,{children:[Be,t.jsx("p",{className:"p-6 text-lead text-muted-foreground",children:"Loading the agent definition…"})]}):t.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-2",children:[t.jsxs("section",{className:"flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b px-6",children:[t.jsx("span",{className:"text-lead font-semibold",children:"Request"}),t.jsx("div",{className:"flex gap-5",children:["form","json"].map(he=>t.jsx("button",{onClick:()=>{if(he==="form"&&_==="json"){if(!ve)return;y(Ee)}E(he)},className:ae("h-12 border-b text-small",_===he?"border-primary":"border-transparent text-muted-foreground"),children:he==="json"?"JSON":"Form"},he))})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto p-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:c?"Edit agent":"Create an agent"}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:c?"Save a new version of this agent’s configuration.":"Configure an agent on this server. You can run it once it is created."})]}),a&&!d&&!c&&t.jsx("p",{role:"alert",className:"text-lead text-warning-text",children:"The linked draft could not be read. Fill in the definition before sending."}),_==="json"?t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"sr-only",children:"Request JSON"}),t.jsx(ln,{value:j,onChange:he=>k(he.target.value),className:`${Ri} min-h-[360px] font-mono text-small`,spellCheck:!1})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ai,{name:"Name",children:t.jsx(Ie,{value:v.definition.name,readOnly:c,onChange:he=>de("name",he.target.value),className:Ri})}),t.jsx(Ai,{name:"Description",children:t.jsx(Ie,{value:v.definition.description??"",readOnly:c,onChange:he=>de("description",he.target.value),className:Ri})}),v.definition.workflow?t.jsx(Ai,{name:"Workflow",children:t.jsx("pre",{className:`${Ri} overflow-auto font-mono text-small`,children:JSON.stringify(v.definition.workflow,null,2)})}):t.jsxs(t.Fragment,{children:[t.jsx(Ai,{name:"Instructions",children:t.jsx(ln,{value:v.definition.instructions??"",rows:5,onChange:he=>de("instructions",he.target.value),className:Ri})}),t.jsx(Ai,{name:"Harness",children:t.jsx(At,{label:"Harness",value:v.definition.harness??"pi",onChange:he=>de("harness",he),options:[...new Set([v.definition.harness??"pi",...i.map(he=>he.id)])].map(he=>{var Ve;return{value:he,label:`${he}${((Ve=i.find(ct=>ct.id===he))==null?void 0:Ve.available)===!1?" (not set up)":""}`}})})}),t.jsx(Ai,{name:"Model",children:t.jsx(Ie,{value:v.definition.model??"",onChange:he=>de("model",he.target.value),placeholder:"Server default",className:Ri})})]}),t.jsx("button",{className:"text-lead text-primary-text",onClick:()=>E("json"),children:"Edit all fields in JSON →"})]}),fe&&t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:fe}),c&&u&&!x&&t.jsx(B,{size:"sm",onClick:()=>Q(he=>he+1),children:"Reload current revision"})]}),t.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t p-4",children:[t.jsx(tn,{label:"Use your agent",prompt:vt,disabled:!rt&&!!fe}),t.jsxs(B,{variant:"primary",onClick:()=>void Se(),disabled:!st,children:[t.jsx(Vo,{"aria-hidden":!0}),q?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(he=>t.jsx("button",{onClick:()=>A(he),className:ae("h-12 border-b text-small capitalize",O===he?"border-primary":"border-transparent text-muted-foreground"),children:he},he)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{navigator.clipboard.writeText(Le).then(()=>Z(!0),()=>Z(!1))},children:t.jsx(Ba,{"aria-hidden":!0})}),t.jsx("span",{role:"status",className:"sr-only",children:K?"Code copied":""})]}),O==="code"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-12 shrink-0 gap-5 border-b px-6",children:["curl","fetch"].map(he=>t.jsx("button",{onClick:()=>M(he),className:ae("border-b text-small",I===he?"border-primary":"border-transparent text-muted-foreground"),children:he==="curl"?"cURL":"JavaScript"},he))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:Le})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:D?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[D.status||"Network error"," · ",Math.round(D.ms)," ms"]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(D.body,null,2)}),Y&&t.jsxs("a",{className:"inline-flex items-center gap-2 text-lead text-primary-text",href:on(Y),children:["Open agent",t.jsx(cr,{className:"size-4"})]}),D.status===412&&t.jsx(B,{onClick:()=>Q(he=>he+1),children:"Reload current revision"}),G&&!Y&&t.jsxs("p",{role:"alert",className:"text-lead",children:["The creation request may have succeeded. Check ",t.jsx("a",{href:"#/agents",className:"text-primary-text underline",children:"Connected agents"})," before sending another creation request."]})]}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"Send a request to see its response."})})]}),Be]})}function Ai({name:e,children:n}){const s=p.useId();return t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:s,className:"block text-lead",children:e}),p.cloneElement(n,{id:s,"aria-label":e})]})}async function Qm(e,n){var d;let s;try{s=((d=navigator.clipboard)==null?void 0:d.readText().catch(()=>""))??Promise.resolve("")}catch{s=Promise.resolve("")}ks.flushSync(e);const r=n();if(!r||r.disabled||r.readOnly)return;r.focus();const a=r.value;let i=!1;const c=()=>{i=!0};r.addEventListener("input",c);try{const u=await s;if(!u||!r.isConnected||i||r.value!==a||r.disabled||r.readOnly)return;Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value").set.call(r,u),r.dispatchEvent(new Event("input",{bubbles:!0}))}finally{r.removeEventListener("input",c)}}function na({error:e,title:n="The run failed"}){return t.jsxs("section",{className:"flex gap-3 bg-card px-4 py-4 md:px-5",role:"alert",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"caps text-small font-semibold",children:n}),t.jsx("p",{className:"mt-2 break-words font-mono text-body leading-relaxed",children:e.message}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[e.code,e.retryable?" · retryable":"",e.request_id?` · ${e.request_id}`:""]})]})]})}const J8={anthropic:"claude.ai",openai:"chatgpt.com",openrouter:"openrouter.ai",parallel:"parallel.ai",monid:"monid.ai",browserbase:"browserbase.com",kernel:"kernel.sh",typesafe:"typesafe.ai"},X8={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"},Z8=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function eU({id:e,className:n}){const[s,r]=p.useState(!1),a=J8[e],i=X8[e];return a&&!s?t.jsx("img",{"data-provider-icon":e,src:Z8(a),alt:"",width:16,height:16,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0),className:ae("size-4 shrink-0 object-contain",n)}):i?t.jsx("svg",{"data-provider-mark":e,viewBox:"0 0 24 24",fill:"currentColor",className:ae("size-4 shrink-0",n),"aria-hidden":!0,children:t.jsx("path",{d:i})}):t.jsx(Ma,{className:ae("size-4 shrink-0 text-muted-foreground",n),"aria-hidden":!0})}const tU=/^(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,nU=40;function sU(e){const n=e.trim().replace(/\?+$/,""),s=n.lastIndexOf(":"),r=(s>=0?n.slice(s+1):n.split(new RegExp("(?<=[.!?])\\s+")).at(-1)??"").trim();if(s<0&&tU.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 i=a.map(c=>c.replace(/^(the|a|an)\s+/i,"").replace(/\s+instead$/i,""));return i.some(c=>!c||c.length>nU)?[]:i.map(c=>/\s/.test(c)?c[0].toUpperCase()+c.slice(1):c)}function rU(e){var r,a;const n=new Map;for(const i of e){if(i.imported_from)continue;const c=((a=(r=i.error)==null?void 0:r.message)==null?void 0:a.trim())||"The run failed.";n.set(c,[...n.get(c)??[],i])}const s=i=>Date.parse(i.ended_at??i.created_at);return[...n].map(([i,c])=>({message:i,runs:c.sort((d,u)=>s(u)-s(d))})).sort((i,c)=>s(c.runs[0])-s(i.runs[0]))}const SE=e=>e.filter(n=>!n.imported_from).length,oU=864e5;function aU(e,n){return e.some(s=>!s.imported_from)||n.some(s=>s.source==="live"&&s.runs>0)}function bd(e,n){const s=Math.max(0,Math.round((n-Date.parse(e))/1e3));return s<60?`${s} s`:s<3600?`${Math.floor(s/60)} min`:s<86400?`${Math.floor(s/3600)} h`:`${Math.floor(s/86400)} days`}function iU(e){var s,r;if(e.kind==="workflow")return{refusal:`"${e.title}" is a workflow run: start it again from its agent's page`};if(!e.input)return{refusal:`"${e.title}": its input can't be read back exactly as it was given; start it again from its agent's page`};const n=(s=e.cost)==null?void 0:s.cap_usd;return{body:{input:e.input,...(r=e.file_ids)!=null&&r.length?{file_ids:e.file_ids}:{},...e.effort?{effort:e.effort}:{},...typeof n=="number"?{max_cost_usd:n}:{}}}}function lU(e,n){let s=!1,r;const a=()=>{s||e().catch(()=>{}).finally(()=>{s||(r=setTimeout(a,n))})};return a(),()=>{s=!0,clearTimeout(r)}}const CE=e=>e.pending!=null&&e.pending.kind!=="stopped",cU=e=>e.status==="input_required"&&e.state!=="waiting"&&!CE(e),dU=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function k0(e,n){const s={asking:(e==null?void 0:e.asking)??[],failed:(e==null?void 0:e.failed)??[],live:(e==null?void 0:e.live)??[]},r=[];return dU.forEach(([a,i],c)=>{const d=n[c];(d==null?void 0:d.status)==="fulfilled"?s[a]=d.value:d&&r.push(`${i} could not be read: ${d.reason instanceof Error?d.reason.message:String(d.reason)}`)}),{needs:s,problem:r.length?r.join(" · "):null}}function Jm({field:e,label:n,writable:s,required:r=!0,stateSaid:a=!1,now:i=Date.now,note:c,onPaste:d,onRemove:u}){const f=e.source==="env",x=s&&!f;return t.jsxs("li",{"data-secret":e.name,"data-source":e.source??"none",className:ae("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",f&&"opacity-60"),children:[t.jsxs("span",{children:[zf(e.name,n),!r&&t.jsx("span",{className:"ml-2 font-sans text-label text-muted-foreground",children:"Optional"})]}),t.jsx("span",{"data-state":e.set?"set":r?"missing":"optional-missing",className:a?"sr-only":c?"text-warning-text":e.set?"text-success-text":"text-muted-foreground",children:e.set?"Set":"Missing"}),e.source&&t.jsx("span",{className:"text-muted-foreground",children:OF[e.source]}),e.changed_at&&t.jsxs("span",{className:"text-muted-foreground",children:["Changed ",bd(e.changed_at,i())," ago"]}),c&&t.jsx("span",{className:"text-warning-text",children:c}),x&&t.jsxs("span",{className:"ml-auto flex gap-2 font-sans",children:[d&&t.jsx(B,{type:"button",size:"sm",variant:e.set?"outline":"primary",onClick:d,children:e.set?"Replace":"Paste"}),u&&e.set&&t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:u,children:"Remove"})]})]})}const N0={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-…"}},uU=e=>Object.prototype.hasOwnProperty.call(N0,e)?N0[e]:void 0,fU={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."},S0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function C0(e,n){return n?n.state==="accepted"?`${e} accepted this key · ${mt(n.at)}`:`Not checked: ${n.reason}${n.at?` · ${mt(n.at)}`:""}`:null}const mU="can't be opened: paste it again",hU=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],px="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function pU({v2:e,onChange:n,writable:s,whyNot:r="sign_in",plan:a,harnesses:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),[x,b]=p.useState(null),[g,h]=p.useState(null),v=p.useRef(0),y=()=>{const E=++v.current;e.listToolKeys().then(O=>{E===v.current&&(d(O),f(null))}).catch(O=>{E===v.current&&f(S0(O))})};p.useEffect(y,[e]);const j=E=>b(O=>O===E?null:O),k=E=>{j(E),y(),n==null||n()},$=(E,O,A,I)=>{h({id:E,title:O,error:S0(A)}),A instanceof ze&&A.code==="key_set_by_server"&&(j(I),y())};if(!c)return u?t.jsx(E0,{error:u,onRetry:y}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Fn,{label:"Loading the tool keys",rows:3})});const S=c.reenter,N=hU.map(E=>({...E,keys:c.keys.filter(O=>O.kind==="model"==(E.kind==="model"))})).filter(E=>E.keys.length),_=E=>t.jsx(gU,{tool:E,writable:s,again:!!S&&E.fields.some(O=>O.stored_unreadable||S.fields.includes(O.name)),open:(x==null?void 0:x.id)===E.id?x.mode:null,problem:(g==null?void 0:g.id)===E.id?g:null,onOpen:O=>{b(O?{id:E.id,mode:O}:null),h(null)},onSave:async O=>{const A=x;try{await e.saveToolKey(E.id,O)}catch(I){return I instanceof ze&&I.status===422?I:($(E.id,"The key was not saved",I,A),null)}return k(A),null},onRemove:async()=>{const O=x;try{await e.removeToolKey(E.id)}catch(A){$(E.id,"The key was not removed",A,O);return}k(O)}},E.id);return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Keys"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"A model provider's key, which every agent runs on, and a tool's key, for every agent that uses the tool, kept on this server. A saved key is never shown again."})]}),!s&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:Ja[r]}),u&&t.jsx(E0,{inline:!0,error:u,onRetry:y}),S&&t.jsxs(xt,{tone:"warning",role:"alert","aria-label":"Keys to enter again",title:"Enter these keys again",children:[t.jsx("p",{children:fU[S.reason]}),t.jsx("p",{className:"mt-2 font-mono",children:S.fields.length?S.fields.join(", "):"Which keys it held is not known: enter again each key you had saved."})]}),N.map(E=>t.jsxs("section",{"aria-label":E.label,children:[N.length>1&&t.jsx("h2",{className:"caps mb-2 text-small font-semibold text-muted-foreground",children:E.label}),E.kind==="model"&&t.jsx("p",{className:"mb-2 text-body text-muted-foreground",children:px}),t.jsxs("ul",{className:"border",children:[E.kind==="model"&&a,E.keys.map(_)]})]},E.label)),i&&t.jsx(EC,{harnesses:i})]})})}function E0({error:e,onRetry:n,inline:s=!1}){return t.jsx(xt,{tone:"error",className:s?void 0:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:n,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The tool keys could not be read: ",e.code,": ",e.message]})})}function gU({tool:e,writable:n,again:s,open:r,problem:a,onOpen:i,onSave:c,onRemove:d}){var h;const u=p.useRef(null),f=v=>e.secrets.find(y=>zf(y.name)===v.name),x=v=>e.fields.find(y=>y.name===zf(v.name)),b=e.fields.filter(v=>{var y;return((y=f(v))==null?void 0:y.source)!=="env"}),g=e.secrets.filter(v=>v.set).length;return t.jsxs("li",{ref:u,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(eU,{id:e.id,className:"mt-1"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:e.label}),t.jsx(je,{tone:g===e.secrets.length?"success":"plain",children:g===e.secrets.length?"set":g?`${g} of ${e.secrets.length} set`:"not set"}),s&&t.jsx(je,{tone:"warning",children:"enter again"})]}),t.jsxs("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:[e.kind==="model"?"Model provider":`Unlocks ${e.unlocks.join(", ")}`,e.harnesses.length>0&&` · Harnesses ${e.harnesses.length===1?`${e.harnesses[0]} only`:e.harnesses.join(", ")}`]}),C0(e.label,e.check)&&t.jsx("p",{className:`mt-1.5 text-small ${((h=e.check)==null?void 0:h.state)==="accepted"?"text-success-text":"text-muted-foreground"}`,children:C0(e.label,e.check)}),t.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(v=>{var y;return t.jsx(Jm,{field:v,stateSaid:e.secrets.length===1,writable:n&&r===null,note:(y=x(v))!=null&&y.stored_unreadable?mU:void 0,onPaste:()=>void Qm(()=>i("edit"),()=>{var j,k,$;return($=(j=u.current)==null?void 0:j.querySelector("form"))==null?void 0:$.elements.namedItem(((k=x(v))==null?void 0:k.name)??"")}),onRemove:v.source==="console"?()=>i("remove"):void 0},v.name)})}),!b.length&&t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"Set when the server starts, and that one wins: change it where the server is started."})]})]}),r==="edit"&&t.jsx(EE,{tool:e,fields:b,onSave:c,onCancel:()=>i(null)}),r==="remove"&&t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove the ",e.label," key saved here?",e.secrets.some(v=>v.source==="env")?" The one set in the environment stays.":""]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void d(),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>i(null),children:"Keep"})]}),a&&t.jsx("div",{className:"mt-4 border",children:t.jsx(na,{error:a.error,title:a.title})})]})}function EE({tool:e,fields:n,onSave:s,onCancel:r}){const a=p.useRef(null),[i,c]=p.useState(!1),[d,u]=p.useState(!1),[f,x]=p.useState(null),b=()=>n.some(y=>{var j,k;return(k=(j=a.current)==null?void 0:j.elements.namedItem(y.name))==null?void 0:k.value}),g=()=>{var y;(y=a.current)==null||y.reset(),c(!1)},h=async y=>{var N,_;y.preventDefault();const j={};for(const E of n){const O=(_=(N=a.current)==null?void 0:N.elements.namedItem(E.name))==null?void 0:_.value;O&&(j[E.name]=O)}if(!Object.keys(j).length)return;u(!0),x(null);const k=await s(j);if(u(!1),!k){g();return}const $={},S=[];for(const E of k.fields??[]){const O=E.field.startsWith("values.")?E.field.slice(7):null;O&&n.some(A=>A.name===O)?$[O]=E.message:S.push(E.message)}x({fields:$,message:S.length?S.join(" "):Object.keys($).length?null:k.message})},v=uU(e.id);return t.jsxs("form",{ref:a,autoComplete:"off",onSubmit:y=>void h(y),onInput:()=>c(!!b()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e.label} key`,children:[v&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:e.label})," · No key yet?"," ",t.jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Get a key"})," (opens in a new tab)"]}),n.map(y=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:y.name}),y.set&&t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"Saved already. A new value replaces it; leave it empty to keep it."}),t.jsx(Ie,{type:"password",name:y.name,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:v&&n.length===1?v.placeholder:void 0}),(f==null?void 0:f.fields[y.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[y.name]})]},y.name)),(f==null?void 0:f.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f.message}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!i||d,children:d?"Saving":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{g(),r()},children:"Cancel"})]})]})}const wd=p.createContext(null);function $0({connection:e,children:n}){return t.jsx(wd.Provider,{value:e,children:n})}const xU={state:"online"},vU=()=>()=>{},_0=()=>xU;function my(){const e=p.useContext(wd);return p.useSyncExternalStore(e?e.subscribe:vU,e?e.link:_0,_0)}function $E(e){const n=p.useContext(wd),s=p.useRef(e);s.current=e,p.useEffect(()=>n==null?void 0:n.onResume(()=>s.current()),[n])}function _E(e){const[n,s]=p.useState(()=>Date.now());return p.useEffect(()=>{if(e===null)return;s(Date.now());const r=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(r)},[e]),e===null?0:Math.max(0,Math.ceil((e-n)/1e3))}function yU(){const e=p.useContext(wd),n=my(),s=_E(n.state==="offline"?n.retryAt:null);return!e||n.state==="online"?null:n.state==="resumed"?t.jsxs(xt,{bar:!0,tone:"success",icon:Yo,"data-connection":"resumed",children:[t.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):t.jsxs(xt,{bar:!0,tone:"warning",icon:SN,"data-connection":"offline",actions:t.jsx(B,{type:"button",onClick:e.retryNow,size:"xs",children:"Retry now"}),children:[t.jsxs("span",{className:"font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]})," Reconnecting… next try in ",s," s. The page shows what it had."]})}function bU(){const e=p.useContext(wd),n=my(),s=_E(n.state==="offline"?n.retryAt:null);return t.jsxs("div",{"data-connection":"offline",role:"status",className:"mx-auto mt-[12vh] max-w-md border bg-card p-6",children:[t.jsx(SN,{className:"size-5 text-warning-text","aria-hidden":!0}),t.jsxs("p",{className:"mt-3 text-base font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:"Is it running? This page connects by itself as soon as the server answers."}),t.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[t.jsx(B,{type:"button",onClick:e==null?void 0:e.retryNow,size:"sm",children:"Retry now"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["Next try in ",s," s"]})]})]})}const wU=[{id:"keys",label:"Tool keys"},{id:"tools",label:"Tools"},{id:"mcp",label:"MCP servers"},{id:"github",label:"GitHub"},{id:"email",label:"Email"},{id:"computers",label:"Computers"},{id:"workspace",label:"Workspace"},{id:"webhook",label:"Webhook"}];function jU({active:e,offered:n,children:s}){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.length>1&&t.jsx("nav",{"aria-label":"Settings",className:"flex shrink-0 gap-1 border-b px-6",children:wU.filter(r=>n.includes(r.id)).map(r=>t.jsx("a",{href:`#/settings/${r.id}`,"aria-current":e===r.id?"page":void 0,className:ae("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))}),t.jsx("div",{className:"min-h-0 flex-1",children:s})]})}const kU=(e,n)=>e.flatMap(s=>s.tools.flatMap(r=>{var a;return(a=r.permissions)!=null&&a.length&&r.default_permission?[{name:E2(s.name,r.name),permission:r.permission??r.default_permission,default_permission:r.default_permission,permissions:r.permissions,...n&&r.permissions.includes("ask")?{ask_needs:"password"}:{}}]:[]})),T0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function NU({v2:e,choices:n,gates:s=[],harnesses:r,mcp:a=!1,onSaved:i,onOpen:c}){const[d,u]=p.useState(null),[f,x]=p.useState(null),b=()=>{a&&(x(null),e.listMcpServers().then(G=>x(G.servers),()=>x("failed")))};p.useEffect(b,[e,a]);const[g,h]=p.useState(null),[v,y]=p.useState(null),[j,k]=p.useState(!1),[$,S]=p.useState(null),N=p.useRef(0),_=()=>{const G=++N.current;e.toolSettings().then(U=>{G===N.current&&(u(U),h(null))},U=>{G===N.current&&h(T0(U))})};p.useEffect(_,[e]);const[E,O]=p.useState("reading"),A=()=>{O("reading"),Promise.resolve(c==null?void 0:c()).then(G=>O(G===!1?"failed":"landed"))},I=()=>{_(),A()};if(p.useEffect(A,[]),!d)return g?t.jsx(xt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:_,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The tool settings could not be read: ",g.code,": ",g.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const M=sx(d,n),R=$?$(M):M,P=jC(n,[...s,...Array.isArray(f)?kU(f,s.some(G=>G.ask_needs==="password")):[]]),D=G=>{var z;const U=Bo(G);return U?(z=R[`mcp:${U.server}/*`])==null?void 0:z.permission:void 0},W=Object.entries(R).filter(([,G])=>(G==null?void 0:G.pin)||(G==null?void 0:G.pin_broken)),Y=G=>{var z;const U=s.find(Q=>Q.name===G);return!U||(((z=R[G])==null?void 0:z.permission)??U.default_permission)===U.permission},{byTool:H,rest:q}=hC((v==null?void 0:v.fields)??{},"",P.map(G=>G.name)),F=async G=>{var K;const U=$?Z=>G($(Z)):G;k(!0),y(null);const z=++N.current;let Q;try{Q=await e.toolSettings()}catch{S(()=>U),y({fields:{},error:null,unread:!0}),k(!1);return}try{const Z=await e.saveToolSettings(U(sx(Q,n)));S(null),z===N.current&&(u(Z),h(null)),i()}catch(Z){y(Z instanceof ze&&Z.status===422&&((K=Z.fields)!=null&&K.length)?{fields:Object.fromEntries(Z.fields.map(de=>[de.field,de.message])),error:null}:{fields:{},error:T0(Z)})}k(!1)};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Tools"}),t.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&&t.jsxs("p",{className:"mt-2 text-lead text-muted-foreground",children:["Each tool's permission: ",t.jsx("span",{className:"font-mono text-body",children:"allow"})," runs it, ",t.jsx("span",{className:"font-mono text-body",children:"ask"})," makes the run wait for your approval at each call, ",t.jsx("span",{className:"font-mono text-body",children:"deny"})," refuses it and tells the agent why. A permission applies at the next call, in runs already going too. An agent's own allow or ask takes the place of this server's; deny here refuses it for every agent."]})]}),t.jsxs("section",{"aria-label":"This server's providers",children:[P.length?t.jsx(Qv,{label:"This server's tool settings",rows:P,settings:R,fallbackOf:G=>G.default_provider,issues:H,busy:j,onEdit:G=>void F(G),permissionFallbackOf:G=>D(G.name)??G.default_permission,refused:(G,U)=>U==="deny",resolvesOf:(G,U)=>U===G.provider&&Y(G.name)?t.jsx(xF,{choice:G,harnesses:r}):E==="reading"?t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"reading…"}):t.jsxs("span",{className:"block text-small text-muted-foreground",children:[E==="failed"?"What it resolves to couldn't be read.":"It changed while this page read it."," ",t.jsx(B,{type:"button",onClick:I,disabled:j,size:"xs",className:"ml-1",children:"Retry"})]})}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"This server offers no tool with a choice of provider."}),f==="failed"&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"alert",children:["The MCP servers' tools could not be read, so they are not listed. ",t.jsx(B,{type:"button",size:"xs",className:"ml-1",onClick:b,disabled:j,children:"Retry"})]}),q.map(G=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:G},G)),(v==null?void 0:v.error)&&t.jsx("div",{className:"mt-3 border",children:t.jsx(na,{error:v.error,title:"The change was not saved"})}),(v==null?void 0:v.unread)&&t.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[t.jsx("p",{className:"font-mono text-small text-destructive-text",children:"Couldn't read the current settings, so nothing was saved. Try again."}),t.jsx(B,{type:"button",size:"xs",className:"mt-2",onClick:()=>void F(G=>G),disabled:j,children:"Try again"})]}),g&&t.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[t.jsxs("p",{className:"font-mono text-small text-destructive-text",children:["The tool settings could not be read again: ",g.code,": ",g.message]}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The table shows the last ones read."}),t.jsx(B,{type:"button",onClick:I,disabled:j,size:"xs",className:"mt-2",children:"Try again"})]})]}),W.length>0&&t.jsxs("section",{"aria-label":"Pinned tools",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Pinned tools"}),t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:"A pin bounds a tool's calls for every agent on this server, its own pin beside it."}),t.jsx("ul",{className:"mt-2 border",children:W.map(([G,U])=>t.jsxs("li",{"data-pin":G,className:"border-b px-3 py-2.5 last:border-b-0",children:[t.jsx("p",{className:"font-mono text-body",children:G}),t.jsx(ox,{setting:U})]},G))})]})]})})}function SU(e){const n=new URLSearchParams(e??""),s=n.get("github");if(s==="connected")return{ok:!0};if(s==="error"){const r=n.get("reason");return r?{ok:!1,reason:r}:{ok:!1}}}const R0={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."},CU=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(R0,e.reason)?R0[e.reason]:"The connection didn't finish. Try again.";function EU(e,n){const s=n(e);if(!s)return;const r=new URL(s);return r.protocol==="https:"&&r.hostname==="github.com"?s:void 0}function $U({note:e}){const n=e.lastIndexOf(": "),s=n>=0?e.slice(n+2).trim():"",r=s?no(s):void 0;return r?t.jsxs(t.Fragment,{children:[e.slice(0,n+2),t.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"break-all underline underline-offset-2",children:s})]}):t.jsx(t.Fragment,{children:e})}function _U({v2:e,returned:n}){const[s,r]=p.useState(void 0),[a,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(!1),[x,b]=p.useState(null),[g,h]=p.useState(null),[v,y]=p.useState(null),[j,k]=p.useState(!1),[$,S]=p.useState(null),N=p.useRef(!1),_=p.useRef(null),E=p.useCallback(async()=>{try{const M=await e.githubConnection();r(M.connected?M:null),i(null)}catch(M){i(M instanceof Error?M.message:String(M))}},[e]);p.useEffect(()=>{E()},[E]),p.useEffect(()=>{n&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),p.useEffect(()=>{var M;x&&((M=_.current)==null||M.submit())},[x]);const O=async()=>{var M;if(!N.current){N.current=!0,f(!0),h(null),y(null),S(null);try{const R=await e.connectGitHub(c.trim()||void 0),P=EU(R.action,no);if(!P){h("GitHub's address didn't look right, so nothing was sent."),N.current=!1,f(!1);return}b({action:P,manifest:JSON.stringify(R.manifest)})}catch(R){if(N.current=!1,f(!1),h(R instanceof Error?R.message:String(R)),R instanceof ze&&R.code==="github_wrong_origin"){const P=(M=R.details)==null?void 0:M.public_url;y(typeof P=="string"&&no(P)||null)}R instanceof ze&&R.code==="github_already_connected"&&E()}}},A=async()=>{k(!1),f(!0),h(null),y(null);try{S(await e.disconnectGitHub()),r(null)}catch(M){M instanceof ze&&(M.status===404||M.code==="github_not_connected")?await E():h(M instanceof Error?M.message:String(M))}finally{f(!1)}},I=s?no(`https://github.com/apps/${encodeURIComponent(s.slug)}`):void 0;return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"GitHub"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"One GitHub App for this server: its templates and triggers reach GitHub through it."})]}),n&&t.jsx("p",{"aria-label":"From GitHub",role:"status",className:ae("border p-4 text-lead",n.ok?"border-success/50 bg-success/5":"border-warning/50 bg-warning/5 text-warning-text"),children:CU(n)}),(g||v)&&t.jsx("div",{role:"alert",className:"border border-destructive/50 px-4 py-3 text-lead text-destructive-text",children:v?t.jsxs("p",{children:["Open this server at ",t.jsx("a",{href:v,className:"break-all underline underline-offset-2",children:v})," to connect GitHub."]}):t.jsx("p",{children:g})}),$&&t.jsxs("section",{"aria-label":"Disconnected",className:"border p-4 text-lead",children:[t.jsx("p",{children:t.jsx($U,{note:$.note})}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:$.triggers_off?`${$.triggers_off} GitHub ${$.triggers_off===1?"trigger":"triggers"} turned off.`:"No GitHub trigger was on."})]}),a&&t.jsx(xt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:()=>void E(),children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["GitHub's connection could not be read: ",a]})}),s===void 0&&!a&&t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading..."}),s===null&&t.jsxs("section",{"aria-label":"Connect GitHub",className:"border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[t.jsxs("label",{className:"flex min-w-[240px] flex-1 flex-col gap-1 text-body",children:[t.jsx("span",{className:"text-muted-foreground",children:"Organization (optional): the App is made under it"}),t.jsx(Ie,{name:"org",value:c,onChange:M=>d(M.target.value),disabled:u,placeholder:"your-org",className:"h-9 w-auto"})]}),t.jsxs(B,{type:"button",variant:"solid",onClick:()=>void O(),disabled:u,children:[t.jsx(qw,{"aria-hidden":!0}),x?"Opening GitHub…":"Connect GitHub"]})]}),t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"GitHub asks you to create the App, then to install it on the accounts it may use. You come back here after."})]}),s&&t.jsxs("section",{"aria-label":"GitHub App",className:"border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-lead",children:[t.jsx(qw,{className:"size-4 text-muted-foreground","aria-hidden":!0}),I?t.jsx("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"font-mono underline underline-offset-2",children:s.slug}):t.jsx("span",{className:"font-mono",children:s.slug}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["App ",s.app_id]})]}),s.installations.length?t.jsx("ul",{"aria-label":"Installations",className:"mt-3 space-y-1 font-mono text-body",children:s.installations.map(M=>t.jsx("li",{children:M.account},M.id))}):t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"Not installed on any account yet."}),j?t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2 text-body",role:"alertdialog","aria-label":"Disconnect GitHub?",children:[t.jsx("span",{children:"Disconnect GitHub? Every GitHub trigger turns off."}),t.jsx(B,{type:"button",variant:"destructive",disabled:u,onClick:()=>void A(),children:"Disconnect GitHub"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>k(!1),children:"Cancel"})]}):t.jsx(B,{type:"button",variant:"outline",className:"mt-4",disabled:u,onClick:()=>k(!0),children:"Disconnect"})]}),x&&t.jsx("form",{"data-github-manifest":!0,ref:_,method:"post",action:x.action,hidden:!0,children:t.jsx("input",{type:"hidden",name:"manifest",defaultValue:x.manifest})})]})})}const TU=8,RU={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function AU({v2:e,signIn:n,add:s,writable:r,whyNot:a="sign_in",open:i=d=>location.assign(d),choices:c=[]}){var G,U,z,Q;const[d,u]=p.useState(null),[f,x]=p.useState(null),[b,g]=p.useState(!1),[h,v]=p.useState(null),[y,j]=p.useState(null),k=(s==null?void 0:s.preset)==="composio"?s:void 0,[$,S]=p.useState(s&&!k?{add:s}:null),[N,_]=p.useState(k&&r?k:!1),[E,O]=p.useState(null),A=s?JSON.stringify(s):"",I=p.useRef(A);p.useEffect(()=>{if(A===I.current)return;I.current=A;const K=A?JSON.parse(A):void 0;S(K&&K.preset!=="composio"?{add:K}:null),_((K==null?void 0:K.preset)==="composio"&&r?K:!1)},[A]);const M=p.useRef(0),R=p.useRef(null),P=()=>{const K=++M.current;e.listMcpServers().then(Z=>{K===M.current&&(u(Z.servers),j(null))},Z=>{K===M.current&&j(ro(Z))})};p.useEffect(P,[e]),p.useEffect(()=>{e.toolSettings().then(x,()=>x(null))},[e]);const D=p.useRef(!1),W=async(K,Z)=>{if(!D.current){D.current=!0,g(!0),v(null);try{const de=await e.toolSettings();x(await e.saveToolSettings(Z(sx(de,c)))),P()}catch(de){v({server:K,problem:ro(de)})}D.current=!1,g(!1)}},Y=p.useRef(null);s&&d&&((G=Y.current)==null?void 0:G.key)!==A&&(Y.current={key:A,name:UU(s.name,d)});const H=K=>{var Z;return((Z=Y.current)==null?void 0:Z.key)===JSON.stringify(K)&&Y.current.name!==K.name?{...K,toolkit:K.toolkit??K.name,name:Y.current.name}:K},q=d!==null||y!==null;p.useEffect(()=>{n&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[n]);const F=async(K,Z)=>i((await e.startMcpSignIn(K,Z)).authorization_url);return t.jsx("div",{ref:R,className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[t.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"MCP servers"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"A remote MCP server's tools, for any agent you grant them to in its Tools step. A saved credential is never shown again."})]}),!$&&!N&&t.jsxs("div",{className:"ml-auto flex gap-2",children:[t.jsx(B,{size:"sm",disabled:!r,onClick:()=>_(!0),children:"Add from Composio"}),t.jsx(B,{size:"sm",variant:"primary",onClick:()=>S({}),children:"Add server"})]})]}),n&&t.jsx("p",{className:`border p-4 text-body ${n.ok?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:n.ok?`Signed in to ${n.server}. Its tools are saved.`:`Signing in to ${n.server} failed: ${QL(n.error)}.`}),!r&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:Ja[a]}),E&&t.jsx("p",{className:"border border-warning/50 p-4 text-body text-warning-text",role:"status",children:E}),y&&t.jsx(xt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:P,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The MCP servers could not be read. ",y.text]})}),$&&(!$.add||q)&&t.jsx(GU,{v2:e,saved:$.saved,add:$.add&&H($.add),given:$.problem,writable:r,signIn:F,onCancel:()=>S(null),onSaved:(K=>()=>{S(Z=>Z===K?null:Z),P()})($)},`${((U=$.saved)==null?void 0:U.name)??"new"}|${((z=$.add)==null?void 0:z.name)??""}|${((Q=$.add)==null?void 0:Q.auth)??""}`),N&&(typeof N!="object"||q)&&t.jsx(WU,{v2:e,add:typeof N=="object"?H(N):void 0,onClose:()=>_(!1),onSaved:P},typeof N=="object"?A:"new"),d&&(d.length?t.jsx("ul",{className:"border",children:d.map(K=>t.jsx(MU,{v2:e,server:K,settings:f,settingsBusy:b,settingsProblem:(h==null?void 0:h.server)===K.name?h.problem:null,onSettings:Z=>void W(K.name,Z),writable:r&&!$,signIn:F,onChange:Z=>S({saved:K,...Z?{problem:Z}:{}}),onPaste:()=>void Qm(()=>S({saved:K}),()=>{var Z;return((Z=R.current)==null?void 0:Z.querySelector('input[name="mcp-token"], input[name="mcp-header-value-0"]'))??null}),onChanged:P,onDeleted:Z=>{O(Z??null),P()}},K.name))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No MCP server is saved here yet."})),t.jsx(DU,{v2:e})]})})}const ll=({problem:e})=>t.jsxs("div",{role:"alert",children:[t.jsx("p",{className:"font-mono text-body text-destructive-text",children:e.text}),e.detail&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.detail})]}),yc=(e,n)=>`mcp:${e}/${n}`,OU=["allow","ask","deny"];function MU({v2:e,server:n,settings:s,settingsBusy:r,settingsProblem:a,onSettings:i,writable:c,signIn:d,onChange:u,onPaste:f,onChanged:x,onDeleted:b}){var I,M;const[g,h]=p.useState(!1),[v,y]=p.useState(!1),[j,k]=p.useState(null),[$,S]=p.useState(null),N=async R=>{h(!0),S(null);try{await R()}catch(P){S(ro(P))}h(!1)},[_,E]=n.credential?RU[n.credential]??[n.credential,"plain"]:["no credential","plain"],O=n.auth.type==="oauth",A=j&&[["Added",j.added],["Removed",j.removed],["Changed",j.changed]].filter(([,R])=>R.length).map(([R,P])=>`${R} ${P.join(", ")}`);return t.jsxs("li",{"data-server":n.name,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(jT,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:n.name}),t.jsx(je,{tone:E,children:_}),!!((I=n.not_metered)!=null&&I.length)&&t.jsx(je,{tone:"plain",children:"not metered"}),n.source&&t.jsxs(t.Fragment,{children:[t.jsx(je,{tone:"muted",children:dd[n.source]}),t.jsx("span",{"data-toolkit":!0,className:"font-mono text-small text-muted-foreground",children:n.toolkit?`toolkit ${n.toolkit}`:"no toolkit"})]})]}),t.jsx("p",{className:"mt-1.5 break-all font-mono text-small text-muted-foreground",children:n.url}),n.auth.type==="github_app"&&t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed with this server's GitHub App: a token narrowed to the run's repository is made for each run",(M=n.auth.headers)!=null&&M.length?` · headers ${n.auth.headers.join(", ")}`:""]}),O&&n.oauth&&t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed in with OAuth",n.oauth.scopes.length?` · ${n.oauth.scopes.join(" ")}`:"",n.oauth.client==="pre-registered"&&n.oauth.client_id?` · client ${n.oauth.client_id}`:"",n.credential==="expired"?" · sign-in expired: sign in again":n.oauth.expires_at?` · token until ${mt(n.oauth.expires_at)}`:""]}),s&&t.jsx(IU,{server:n,settings:s,busy:r,onSettings:i}),a&&t.jsx("div",{className:"mt-2",children:t.jsx(ll,{problem:a})}),t.jsxs("details",{className:"mt-2",children:[t.jsxs("summary",{className:"cursor-pointer font-mono text-small",children:[n.tools.length," tool",n.tools.length===1?"":"s"]}),t.jsx("div",{className:"mt-2",children:t.jsx(zU,{server:n,settings:s,busy:r,onSettings:i})})]}),n.secret&&t.jsx("ul",{className:"mt-2",children:t.jsx(Jm,{field:n.secret,label:BU[n.auth.type],writable:c,onPaste:O?void 0:f})}),n.source==="composio"&&t.jsx(LU,{v2:e,server:n.name,writable:c}),A&&t.jsx("p",{className:"mt-2 font-mono text-small",role:"status",children:A.length?A.join(" · "):"No change: it lists the same tools."})]}),!v&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[O&&n.credential!=="sealed"&&c&&t.jsx(B,{size:"sm",variant:"primary",disabled:g,onClick:()=>void N(()=>{var R;return d(n.name,{url:n.url,...(R=n.oauth)!=null&&R.scopes.length?{scopes:n.oauth.scopes}:{}})}),children:"Sign in again"}),t.jsx(B,{size:"sm",disabled:g,onClick:()=>void N(async()=>{try{k(await e.refreshMcpServer(n.name))}finally{x()}}),children:"Refresh"}),t.jsx(B,{size:"sm",disabled:g,onClick:()=>u(),children:"Change"}),t.jsx(B,{size:"sm",variant:"destructive",disabled:g,onClick:()=>y(!0),children:"Delete"})]})]}),v&&t.jsxs("div",{role:"alertdialog","aria-label":`Delete ${n.name}`,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Delete ",n.name,"? Its credential goes with it, and an agent that grants its tools can't call them."]}),t.jsx(B,{size:"sm",variant:"destructive",disabled:g,onClick:()=>void N(async()=>{var R,P;b((P=(R=await e.deleteMcpServer(n.name))==null?void 0:R.composio)==null?void 0:P.note)}),children:"Delete"}),t.jsx(B,{size:"sm",onClick:()=>y(!1),children:"Keep"})]}),$&&t.jsxs("div",{className:"mt-3",children:[t.jsx(ll,{problem:$}),$.needsClient&&c&&t.jsx(B,{className:"mt-2",size:"sm",variant:"primary",onClick:()=>u($),children:"Enter a Client ID"})]})]})}const PU={on:"on at Composio",off:"off at Composio",missing:"Composio no longer has it",unknown:"Composio didn't say"};function LU({v2:e,server:n,writable:s}){const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,x]=p.useState(!1),[b,g]=p.useState(!1),[h,v]=p.useState(!1);if(p.useEffect(()=>{let k=!0;return e.composioTriggers(n).then($=>{k&&a($)},$=>{k&&($ instanceof ze&&$.status===404?u(!0):c(ro($)))}),()=>{k=!1}},[e,n]),d)return null;const y=async()=>{x(!1),g(!0),c(null),v(!1);try{await e.rotateComposioSecret(n),v(!0)}catch(k){c(ro(k))}g(!1)},j=r==null?void 0:r.subscription;return t.jsxs("section",{"data-composio-triggers":!0,"aria-label":`${n}'s triggers`,className:"mt-3 border p-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Triggers"}),r?t.jsxs(t.Fragment,{children:[r.triggers.length?t.jsx("ul",{className:"mt-2 space-y-1",children:r.triggers.map(k=>t.jsxs("li",{"data-trigger":k.id,className:"flex flex-wrap items-center gap-x-2 text-body",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(k.id)}`,className:"font-semibold hover:underline",children:k.name}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:k.event}),t.jsxs("span",{className:`font-mono text-small ${k.on_composio==="missing"?"text-warning-text":"text-muted-foreground"}`,children:["· ",PU[k.on_composio],k.enabled?"":" · paused here"]})]},k.id))}):t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["No trigger uses it yet. ",t.jsx("a",{href:"#/triggers/new-composio",className:"underline underline-offset-2",children:"New app trigger"})]}),r.composio_error&&t.jsxs("p",{className:"mt-2 text-small text-warning-text",children:["Composio didn't answer: ",r.composio_error]}),j&&(j.ours?t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"The project's webhook subscription sends its events here."}):t.jsxs("p",{className:"mt-2 break-all text-small text-muted-foreground",children:["The project's webhook subscription sends its events to ",t.jsx("span",{className:"font-mono",children:j.webhook_url}),", not here: a new trigger asks before it moves it."]})),(j==null?void 0:j.ours)&&s&&!f&&t.jsx(B,{className:"mt-2",size:"sm",disabled:b,onClick:()=>x(!0),children:"Rotate secret"}),f&&t.jsxs("div",{role:"alertdialog","aria-label":"Rotate the subscription's secret?",className:"mt-2 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Rotate the subscription's secret? Composio makes a new one and this server keeps it; a delivery signed with the old one is refused from then on."}),t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void y(),children:"Yes, rotate"}),t.jsx(B,{size:"sm",onClick:()=>x(!1),children:"Keep"})]}),h&&t.jsx("p",{className:"mt-2 text-small text-success-text",role:"status",children:"Rotated: Composio signs with the new secret from now on."})]}):!i&&t.jsx("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:"Reading its triggers"}),i&&t.jsx("div",{className:"mt-2",children:t.jsx(ll,{problem:i})})]})}function IU({server:e,settings:n,busy:s,onSettings:r}){var x;const a=yc(e.name,"*"),i=((x=n[a])==null?void 0:x.allow_reads)===!0,c=e.tools.filter(b=>b.effect==="read").length,d=`allow-reads-${e.name}`,u=`${d}-words`,f=b=>r(g=>{const{[a]:h,...v}=g,{allow_reads:y,...j}=h??{},k=b?{...j,allow_reads:!0}:j;return Object.keys(k).length?{...v,[a]:k}:v});return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(jm,{checked:i,onChange:f,busy:s,labelledBy:d}),t.jsx("span",{id:d,className:"caps text-small font-semibold",children:"Allow reads"})]}),t.jsxs("p",{id:u,className:"mt-1 text-small text-muted-foreground",children:[c," of ",e.tools.length," tool",e.tools.length===1?"":"s"," read-only, as the server marks them: ",i?"they run without asking":"on, they run without asking",". Writes keep their permission."]})]})}function zU({server:e,settings:n,busy:s,onSettings:r}){const a=n==null?void 0:n[yc(e.name,"*")],i=new Map(e.tools.map(u=>[yc(e.name,u.name),u])),c=e.tools.map(u=>{var f;return{name:yc(e.name,u.name),...n?{gate:{name:yc(e.name,u.name),permission:u.permission??"ask",default_permission:u.default_permission??"ask",permissions:(f=u.permissions)!=null&&f.length?u.permissions:OU}}:{}}}),d=u=>{var x,b;const f=(x=e.prices)==null?void 0:x[u];return f!==void 0?`$${f} a call`:(b=e.not_metered)!=null&&b.includes(u)?"not metered":null};return t.jsx(Qv,{label:`${e.name}'s tools`,rows:c,settings:n??{},busy:s,issues:{},fallbackOf:()=>"",resolvesOf:()=>null,onEdit:r,labelOf:u=>{var f;return((f=i.get(u))==null?void 0:f.name)??u},detailOf:u=>{var f;return d(((f=i.get(u))==null?void 0:f.name)??"")},effectOf:u=>{var f;return(f=i.get(u))==null?void 0:f.effect},confirmAllowOf:u=>{var f;return((f=i.get(u))==null?void 0:f.effect)==="destructive"},refused:(u,f)=>f==="deny",fallbackWordOf:u=>{var f;return(f=i.get(u))!=null&&f.fallback_allow_reads?"allow reads":void 0},permissionFallbackOf:u=>{var f;return(f=i.get(u.name))!=null&&f.fallback_allow_reads?"allow":(a==null?void 0:a.permission)??u.default_permission}})}function DU({v2:e}){const[n,s]=p.useState(null),[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,x]=p.useState(""),b=()=>void e.mcpPrivateHosts().then(v=>{s(v.hosts),a(null)},v=>a(ro(v)));p.useEffect(b,[e]);const g=async v=>{u(!0),c(null);try{return s((await e.saveMcpPrivateHosts(v)).hosts),!0}catch(y){return c(ro(y)),!1}finally{u(!1)}},h=async v=>{v.preventDefault(),n&&f.trim()&&await g([...n,f.trim()])&&x("")};return t.jsxs("section",{"aria-labelledby":"mcp-private-hosts",className:"space-y-3 border bg-card p-4",children:[t.jsx("h2",{id:"mcp-private-hosts",className:"caps text-small font-semibold",children:"Private network hosts"}),t.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&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The private network hosts could not be read. ",r.text]}),t.jsx(B,{size:"sm",onClick:b,className:"mt-3",children:"Try again"})]}),n&&(n.length?t.jsx("ul",{"aria-label":"Allowed private network hosts",className:"border bg-background",children:n.map(v=>t.jsxs("li",{"data-host":v,className:"flex items-center justify-between gap-3 border-b px-3 py-2 last:border-b-0",children:[t.jsx("span",{className:"break-all font-mono text-body",children:v}),t.jsx(B,{size:"sm",disabled:d,onClick:()=>void g(n.filter(y=>y!==v)),children:"Remove"})]},v))}):t.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."})),n&&t.jsxs("form",{onSubmit:v=>void h(v),"aria-label":"Allow a private network host",className:"flex gap-2",children:[t.jsx(Ie,{name:"mcp-private-host","aria-label":"Host name or IP address",value:f,onChange:v=>x(v.target.value),placeholder:"auth.corp.example",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:d||!f.trim(),children:"Allow"})]}),i&&t.jsx(ll,{problem:i})]})}const FU=32;function UU(e,n){const s=new Set(n.map(r=>r.name));if(!s.has(e))return e;for(let r=2;;r++){const a=`-${r}`,i=`${e.slice(0,FU-a.length).replace(/-+$/,"")}${a}`;if(!s.has(i))return i}}function WU({v2:e,add:n,onClose:s,onSaved:r}){var M;const a=p.useRef(null),[i,c]=p.useState((n==null?void 0:n.toolkit)??""),[d,u]=p.useState((n==null?void 0:n.name)??""),[f,x]=p.useState(null),[b,g]=p.useState([]),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,$]=p.useState(!1),S=()=>{var R,P;return(((P=(R=a.current)==null?void 0:R.elements.namedItem("composio-key"))==null?void 0:P.value)??"").trim()},N=async R=>{$(!0),j(null);try{await R()}catch(P){j(ro(P))}$(!1)},_=p.useRef(0),E=()=>{_.current++,x(null)},O=()=>N(async()=>{const R=++_.current;x(null),g([]);const P=await e.composioTools(S(),i.trim().toLowerCase());R===_.current&&(x(P),n!=null&&n.tools&&P.toolkit===n.toolkit&&g(P.tools.map(D=>D.slug).filter(D=>n.tools.includes(D))))}),A=()=>N(async()=>{var P,D;const R=await e.saveComposioServer(d.trim(),S(),f.toolkit,b);(P=a.current)==null||P.reset(),r(),R.connect_url||(D=R.not_served)!=null&&D.length?v({connect:R.connect_url,notServed:R.not_served}):s()}),I=R=>g(P=>P.includes(R)?P.filter(D=>D!==R):[...P,R]);return h?t.jsxs("section",{"aria-label":"Composio server saved",className:"space-y-3 border bg-card p-4",children:[t.jsxs("p",{className:"text-body",children:["Saved.",h.connect?` Its tools need your ${f==null?void 0:f.toolkit} account: connect it on Composio, then refresh the server.`:""]}),h.connect&&t.jsx("p",{children:t.jsxs("a",{href:h.connect,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-body underline",children:["Connect your ",f==null?void 0:f.toolkit," account"]})}),(M=h.notServed)!=null&&M.length?t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:["Composio's server doesn't list ",h.notServed.join(", "),": a run can't call ",h.notServed.length===1?"it":"them","."]}):null,t.jsx(B,{size:"sm",onClick:s,children:"Done"})]}):t.jsxs("form",{ref:a,autoComplete:"off",onSubmit:R=>{R.preventDefault(),f&&b.length&&d.trim()&&A()},"aria-label":"Add from Composio",className:"space-y-4 border bg-card p-4",onInput:R=>{R.target.name==="composio-key"&&E()},children:[t.jsx("p",{className:"text-small text-muted-foreground",children:"Composio runs the toolkit's actions for you. This saves an MCP server that grants only the actions you tick, with your Composio key sealed like any credential."}),(n==null?void 0:n.tools)&&t.jsxs("p",{role:"note",className:"text-small text-muted-foreground",children:["A template uses ",n.tools.join(", "),": enter your key and load the actions, and those are ticked."]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Composio API key"}),t.jsx(Ie,{name:"composio-key",...uf})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),t.jsx(Ie,{name:"composio-toolkit",value:i,onChange:R=>{c(R.target.value),E()},placeholder:"github",spellCheck:!1})]}),y&&t.jsx(ll,{problem:y}),f&&t.jsxs("fieldset",{className:"space-y-2",children:[t.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Actions to grant"}),f.tools.length?t.jsx("ul",{className:"divide-y border",children:f.tools.map(R=>t.jsx("li",{className:"px-3 py-2",children:t.jsxs("label",{className:"flex items-start gap-2 text-body",children:[t.jsx("input",{type:"checkbox",value:R.slug,checked:b.includes(R.slug),onChange:()=>I(R.slug),className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono",children:R.name}),t.jsx("span",{className:"ml-2 font-mono text-small text-muted-foreground",children:R.slug}),R.description&&t.jsx("span",{className:"block text-small text-muted-foreground",children:R.description})]})]})},R.slug))}):t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This toolkit lists no actions."}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",d.trim()||"<name>","/<tool>."]}),t.jsx(Ie,{name:"composio-name",value:d,onChange:R=>u(R.target.value),spellCheck:!1})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:k||!i.trim(),onClick:()=>void O(),children:"Load actions"}),f&&t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:k||!b.length||!d.trim(),children:k?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",disabled:k,onClick:()=>{var R;(R=a.current)==null||R.reset(),s()},children:"Cancel"})]})]})}const uf={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},HU=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"],["github_app","GitHub App"]],BU={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in",github_app:"Headers"};function GU({v2:e,saved:n,add:s,given:r,writable:a,signIn:i,onCancel:c,onSaved:d}){var fe,ve,Ee,ue,pe;const u=p.useRef(null),[f,x]=p.useState((n==null?void 0:n.name)??(s==null?void 0:s.name)??""),[b,g]=p.useState((n==null?void 0:n.url)??((s==null?void 0:s.auth)==="github_app"?Ok:"")),[h,v]=p.useState((n==null?void 0:n.auth.type)??(s==null?void 0:s.auth)??"none"),[y,j]=p.useState(Math.max(1,((fe=n==null?void 0:n.auth.headers)==null?void 0:fe.length)??0)),k=h==="github_app"?"github":(n==null?void 0:n.source)==="composio"?"composio":"url",[$,S]=p.useState((n==null?void 0:n.toolkit)??(s&&!s.auth?s.toolkit??s.name:"")),N=k==="github"?"github":$.trim(),_=()=>{if(h==="github_app")return{};const me=N||null;return n?me!==n.toolkit?{toolkit:me}:{}:me?{toolkit:me}:{}},[E,O]=p.useState(null),[A,I]=p.useState(r??null),[M,R]=p.useState(!1),P=p.useRef(0),D=()=>{P.current++,O(null)},W=me=>{var ke,$e;return((($e=(ke=u.current)==null?void 0:ke.elements.namedItem(me))==null?void 0:$e.value)??"").trim()},[Y,H]=p.useState(!1),q=me=>{try{return new URL(me).origin}catch{return me}},F=(me=h)=>{var ke;return H(!!n&&me==="oauth"&&(n.auth.type!=="oauth"||W("mcp-scopes")!==(((ke=n.oauth)==null?void 0:ke.scopes.join(" "))??"")||!!W("mcp-client-id")||!!W("mcp-client-secret")||q(W("mcp-url"))!==q(n.url)))};p.useEffect(()=>F(),[h]);const G=()=>{if(h==="bearer")return W("mcp-token")?{type:h,token:W("mcp-token")}:{type:h};if(h!=="headers"&&h!=="github_app")return{type:h};const me=Object.fromEntries(Array.from({length:y},(ke,$e)=>[W(`mcp-header-name-${$e}`),W(`mcp-header-value-${$e}`)]).filter(([ke,$e])=>ke&&$e));return Object.keys(me).length?{type:h,headers:me}:{type:h}},U=async me=>{R(!0),I(null);try{await me()}catch(ke){I(ro(ke))}R(!1)},z=!!(A!=null&&A.needsClient);p.useEffect(()=>{z&&v("oauth")},[z]),p.useEffect(()=>{var me,ke;z&&h==="oauth"&&((ke=(me=u.current)==null?void 0:me.elements.namedItem("mcp-client-id"))==null||ke.focus())},[z,h]);const Q=()=>U(()=>{const me=W("mcp-scopes").split(/\s+/).filter(Boolean),ke=W("mcp-client-id");return i(f.trim(),{url:b.trim(),...me.length?{scopes:me}:{},...ke?{client_id:ke,...W("mcp-client-secret")?{client_secret:W("mcp-client-secret")}:{}}:{},..._()})}),K=()=>{const me=P.current;U(async()=>{try{const ke=await e.previewMcpServer(b.trim(),G(),n==null?void 0:n.name);me===P.current&&O(ke)}catch(ke){if(me===P.current)throw ke}})},Z=me=>{if(me.preventDefault(),h==="oauth"&&(!n||Y))return void Q();U(async()=>{var ke;await e.saveMcpServer(f.trim(),b.trim(),G(),_()),(ke=u.current)==null||ke.reset(),d()})},de=!M&&!!f.trim()&&!!b.trim()&&(!!n||!!E),re=me=>(n==null?void 0:n.credential)==="sealed"&&n.auth.type===h&&t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Saved. ",me]});return t.jsxs("form",{ref:u,autoComplete:"off",onSubmit:Z,"aria-label":n?`Change ${n.name}`:"Add an MCP server",className:"space-y-4 border bg-card p-4",onInput:me=>{["mcp-name","mcp-toolkit"].includes(me.target.name)||D(),F()},children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",f.trim()||"<name>","/<tool>."]}),t.jsx(Ie,{name:"mcp-name",value:f,readOnly:!!n,onChange:me=>x(me.target.value),spellCheck:!1})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Address"}),t.jsx(Ie,{name:"mcp-url",value:b,onChange:me=>{g(me.target.value),A!=null&&A.needsClient&&I(null)},placeholder:"https://mcp.example.com/mcp",spellCheck:!1})]}),t.jsxs("div",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Source"}),t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"What made it: GitHub App access is GitHub, the Composio preset is Composio, anything else is URL."}),t.jsx("span",{"data-mcp-source":k,className:"font-mono text-body",children:dd[k]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["The name a template gives these tools (mcp:",N||"<toolkit>","/<tool>): applying one uses this server for them."]}),t.jsx(Ie,{name:"mcp-toolkit",value:k==="github"?"github":$,readOnly:k==="github",onChange:me=>S(me.target.value),placeholder:"hubspot",spellCheck:!1})]}),t.jsxs("fieldset",{children:[t.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Credential"}),t.jsx("div",{className:"flex flex-wrap gap-4",children:HU.map(([me,ke])=>t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"radio",name:"mcp-auth",value:me,checked:h===me,disabled:!a&&me!=="none",onChange:()=>{v(me),me==="github_app"&&!b.trim()&&g(Ok),D()},className:"accent-primary"}),ke]},me))})]}),h==="bearer"&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),re("A new token replaces it; leave this empty to keep it."),t.jsx(Ie,{name:"mcp-token",...uf})]}),h==="github_app"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Uses this server's GitHub App (Settings → GitHub): a token for the repository of each run is made when the run starts, and an agent never sees it. The address is GitHub's hosted MCP, the only one this credential goes to. Headers are optional."}),(h==="headers"||h==="github_app")&&t.jsxs("div",{className:"space-y-2",children:[re(`Its headers: ${(ve=n==null?void 0:n.auth.headers)==null?void 0:ve.join(", ")}. New ones replace them all; leave the values empty to keep them.`),Array.from({length:y},(me,ke)=>{var $e;return t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ie,{name:`mcp-header-name-${ke}`,"aria-label":`Header ${ke+1} name`,placeholder:"X-Api-Key",defaultValue:($e=n==null?void 0:n.auth.headers)==null?void 0:$e[ke],spellCheck:!1}),t.jsx(Ie,{name:`mcp-header-value-${ke}`,"aria-label":`Header ${ke+1} value`,...uf})]},ke)}),y<TU&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>j(me=>me+1),children:"Add header"})]}),h==="oauth"&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-small text-muted-foreground",children:"This server signs in for you and keeps the tokens; an agent never sees one. Sign in opens the server's own page to approve it, and its tools are saved once you do."}),((Ee=n==null?void 0:n.oauth)==null?void 0:Ee.client_id)&&t.jsxs("p",{className:"text-small text-muted-foreground",children:["Signing in again uses the client it signed in with (",n.oauth.client_id,"); a client ID here replaces it."]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Scopes (optional)"}),t.jsx(Ie,{name:"mcp-scopes",placeholder:"read write",defaultValue:(ue=n==null?void 0:n.oauth)==null?void 0:ue.scopes.join(" "),spellCheck:!1})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("label",{className:"block flex-1",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:z?"Client ID (this server needs one)":"Client ID (optional)"}),t.jsx(Ie,{name:"mcp-client-id",spellCheck:!1})]}),a&&t.jsxs("label",{className:"block flex-1",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:z?"Client secret (if its app has one)":"Client secret (optional)"}),t.jsx(Ie,{name:"mcp-client-secret",...uf})]})]})]}),A&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(ll,{problem:A}),A.signIn&&h!=="oauth"&&a&&t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:M||!f.trim(),onClick:()=>void Q(),children:"Sign in"})]}),E&&t.jsxs("section",{"aria-label":"Preview",className:"border bg-background p-3",children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["MCP ",E.protocol,(pe=E.server_info)!=null&&pe.name?` · ${E.server_info.name}${E.server_info.version?` ${E.server_info.version}`:""}`:""," · ",E.tools.length," tool",E.tools.length===1?"":"s"]}),E.instructions&&t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:E.instructions}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:qL}),t.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:E.tools.map(me=>t.jsxs("li",{className:"px-3 py-2",children:[t.jsx("span",{className:"font-mono text-body",children:me.name}),me.title&&t.jsx("span",{className:"ml-2 text-small",children:me.title}),me.description&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:me.description})]},me.name))})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[h==="oauth"&&!a?null:h==="oauth"&&Y?t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:M||!b.trim(),children:"Sign in again with these settings"}):h==="oauth"?t.jsx(B,{type:"button",size:"sm",variant:n?"outline":"primary",disabled:M||!f.trim()||!b.trim(),onClick:()=>void Q(),children:n?"Sign in again":"Sign in"}):t.jsx(B,{type:"button",size:"sm",disabled:M||!b.trim(),onClick:K,children:"Preview"}),(h!=="oauth"||n&&!Y)&&t.jsx(B,{type:"submit",size:"sm",variant:A!=null&&A.signIn&&h!=="oauth"&&a?"outline":"primary",disabled:!de,children:M?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{var me;(me=u.current)==null||me.reset(),c()},children:"Cancel"})]})]})}const A0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function qU({v2:e,needs:n,model:s,onSaved:r,writable:a,whyNot:i="sign_in",plan:c,onPlan:d,onDone:u,harnesses:f}){const[x,b]=p.useState(null),[g,h]=p.useState(null),[v,y]=p.useState(null),[j,k]=p.useState(null),[$,S]=p.useState(c??null);p.useEffect(()=>{S(c??null)},[c]);const[N,_]=p.useState(!1),E=p.useRef(0),O=()=>{const q=++E.current;e.listToolKeys().then(F=>{q===E.current&&(b(F.keys.filter(G=>G.kind==="model")),h(null))}).catch(F=>{q===E.current&&h(A0(F))})};p.useEffect(()=>{n!=="model"&&O()},[e,n]);const A=s!=null&&s.includes("/")&&!zc(s)?s.slice(0,s.indexOf("/")):void 0,I=x==null?void 0:x.find(q=>q.id===A),M=I?[I]:x,R=x==null?void 0:x.find(q=>q.id===v),P=(R==null?void 0:R.fields.filter(q=>{var F;return((F=R.secrets.find(G=>zf(G.name)===q.name))==null?void 0:F.source)!=="env"}))??[],D=!!$&&n!=="model"&&!A,W=n!=="model"&&(!D||N),Y=q=>{S(q),d==null||d(q)},H=f&&t.jsx(EC,{harnesses:f});return D&&$.state==="signed_in"?t.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:t.jsxs("div",{className:"mx-auto flex max-w-[1600px] gap-3",children:[t.jsx(Ma,{className:"mt-1 size-4 shrink-0 text-success-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[t.jsx("h2",{className:"text-prose font-semibold",children:"Signed in with ChatGPT"}),t.jsx(lx,{v2:e,view:$,onView:Y}),H,t.jsx(B,{type:"button",size:"sm",onClick:()=>u==null?void 0:u(),children:"Done"})]})]})}):t.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:t.jsxs("div",{className:"mx-auto flex max-w-[1600px] gap-3",children:[t.jsx(Ma,{className:"mt-1 size-4 shrink-0 text-warning-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[t.jsx("h2",{className:"text-prose font-semibold",children:n==="model"?"This server's default model doesn't run":D?"Sign in with ChatGPT or add a model key to run agents":"Add a model key to run agents"}),n==="model"?t.jsx("p",{className:"text-body text-muted-foreground",children:"The server's AGENT_MODEL names a model it doesn't know, so an agent that names no model can't run. Set AGENT_MODEL to a provider/model-id where the server starts, or name a model in each agent."}):I?t.jsxs("p",{className:"text-body text-muted-foreground",children:["This server's default model is ",t.jsx("span",{className:"font-mono",children:s}),", and no ",I.label," key is set, so an agent that names no model can't run. Save the ",I.label," key: such an agent then runs on that model."]}):D?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"This server has no model yet, so an agent that names no model can't run."}),t.jsx(lx,{v2:e,view:$,onView:Y,writable:a,whyNot:i,beside:t.jsx(B,{type:"button",size:"sm","aria-expanded":N,onClick:()=>_(q=>!q),children:"Add a key"})}),t.jsx("p",{className:"text-body text-muted-foreground",children:$2}),N&&t.jsx("p",{className:"text-body text-muted-foreground",children:px})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"No model provider's key is set on this server, so an agent that names no model can't run. Save one: such an agent then runs on that provider's everyday model."}),t.jsx("p",{className:"text-body text-muted-foreground",children:px})]}),W&&g&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The keys could not be read: ",g.code,": ",g.message]}),t.jsx(B,{type:"button",onClick:O,size:"sm",className:"mt-2",children:"Try again"})]}),W&&x&&!a&&t.jsx("p",{className:"text-body",role:"status",children:Ja[i]}),W&&x&&a&&t.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:M.map(q=>t.jsx(B,{size:"sm",variant:v===q.id?"solid":"primary","aria-pressed":v===q.id,onClick:()=>{y(v===q.id?null:q.id),k(null)},children:q.label},q.id))}),W&&R&&a&&(P.length?t.jsx(EE,{tool:R,fields:P,onCancel:()=>y(null),onSave:async q=>{k(null);try{await e.saveToolKey(R.id,q)}catch(F){return F instanceof ze&&F.status===422?F:(k(A0(F)),null)}return y(null),O(),r==null||r(),null}},R.id):t.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",R.label," key when it starts: change it there."]})),j&&t.jsx("div",{className:"border",children:t.jsx(na,{error:j,title:"The key was not saved"})}),H,t.jsxs("p",{className:"text-small text-muted-foreground",children:["Every key is in ",t.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:"#/settings/keys",children:"Settings"}),"."]})]})]})})}function KU({needs:e,settings:n,model:s,source:r,chatgpt:a=!1}){return t.jsx("p",{role:"status","aria-label":"No model",className:"border-b bg-card px-5 py-3 text-body text-warning-text md:px-8",children:e==="model"?"This server's default model doesn't run here: set AGENT_MODEL to a model it knows, and restart.":t.jsxs(t.Fragment,{children:["No model yet."," ",r==="gateway"?t.jsxs(t.Fragment,{children:["This server sends its models to a gateway: name the gateway's model in AGENT_MODEL where AgentRun starts, and restart",n?t.jsxs(t.Fragment,{children:[", or ",t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"add a model key in Settings → Model keys"})]}):null,"."]}):s?`This server's default model is ${s}: set its provider's key where AgentRun starts, and restart.`:a&&n?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"Continue with ChatGPT"})," in Settings → Model keys: Codex and pi agents run on your ChatGPT plan. Add a key there for the rest (one OpenRouter key gives every harness its model), and it takes effect at once."]}):n?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"Add a key in Settings → Model keys"})," (one OpenRouter key gives every harness its model), and it takes effect at once. Or set OPENROUTER_API_KEY, ANTHROPIC_API_KEY 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 O0=[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"icloud",label:"iCloud"},{value:"other",label:"Other"}],VU={gmail:t.jsxs(t.Fragment,{children:["A Google ",t.jsx("a",{href:"https://myaccount.google.com/apppasswords",target:"_blank",rel:"noreferrer",className:"text-primary-text underline",children:"app password"}),". Google gives one only with 2-Step Verification on, and a company account whose admin turned app passwords off won't connect yet."]}),fastmail:t.jsx(t.Fragment,{children:"A Fastmail app password with IMAP and SMTP access, made under Privacy & Security in Fastmail."}),icloud:t.jsx(t.Fragment,{children:"An app-specific password, made under Sign-In and Security in your Apple Account."}),other:t.jsx(t.Fragment,{children:"Your mail server's IMAP and SMTP servers, and its password: an app password where it offers one."})},YU="Outlook needs Microsoft sign-in, which this server doesn't do yet.";function QU(e){return e==="other"?"Password":"App password"}const JU={configured:!1,preset:null,address:null,user:null,imap:null,smtp:null,password_unreadable:!1},M0=e=>{var n,s,r,a;return{preset:(e==null?void 0:e.preset)??"gmail",address:(e==null?void 0:e.address)??"",user:e!=null&&e.user&&e.user!==e.address?e.user:"",imapHost:(e==null?void 0:e.preset)==="other"?((n=e.imap)==null?void 0:n.host)??"":"",imapPort:(e==null?void 0:e.preset)==="other"?String(((s=e.imap)==null?void 0:s.port)??""):"993",smtpHost:(e==null?void 0:e.preset)==="other"?((r=e.smtp)==null?void 0:r.host)??"":"",smtpPort:(e==null?void 0:e.preset)==="other"?String(((a=e.smtp)==null?void 0:a.port)??""):"465"}},P0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},XU=e=>Object.fromEntries((e instanceof ze?e.fields??[]:[]).map(n=>[n.field,n.message]));function ZU({v2:e,writable:n,whyNot:s="sign_in"}){var G;const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(M0(null)),[f,x]=p.useState(""),[b,g]=p.useState(null),[h,v]=p.useState({}),[y,j]=p.useState(null),[k,$]=p.useState(!1),[S,N]=p.useState(!1),_=p.useRef(0),E=U=>{a(U),u(M0(U))},O=()=>{const U=++_.current;e.emailAccount().then(z=>{U===_.current&&(E(z),c(null))}).catch(z=>{U===_.current&&c(P0(z))})};p.useEffect(()=>{n&&O()},[e,n]);const A=U=>{u(U),j(null)},I=U=>z=>A(Q=>({...Q,[U]:z.target.value})),M=()=>{const U=d.user.trim(),z=d.preset===(r==null?void 0:r.preset)&&r.imap&&r.smtp?{imap:r.imap,smtp:r.smtp}:{};return{preset:d.preset,address:d.address.trim(),...U?{user:U}:{},...f?{password:f}:{},...d.preset==="other"?{imap:{host:d.imapHost.trim(),port:Number(d.imapPort)},smtp:{host:d.smtpHost.trim(),port:Number(d.smtpPort)}}:z}},R=async(U,z)=>{g(null),v({}),N(!0);try{await z()}catch(Q){const K=XU(Q);Object.keys(K).length?v(K):g({title:U,error:P0(Q)})}finally{N(!1)}},P=U=>{U.preventDefault(),R("The account was not saved",async()=>{E(await e.saveEmailAccount(M())),x(""),j(null)})},D=()=>R("The account was not tested",async()=>{j(null),j(await e.testEmailAccount(M()))}),W=()=>R("The account was not removed",async()=>{$(!1),await e.removeEmailAccount(),E(JU),x(""),j(null)}),Y=t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Email"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The mail account your agents read, file and draft in, over IMAP and SMTP, and the account email triggers watch. Its password is sealed on this server and never shown again. Nothing is sent without asking you first."})]});if(!n)return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[Y,t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:Ja[s]})]})});if(!r)return i?t.jsx(xt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:O,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The email account could not be read: ",i.code,": ",i.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const H=r.configured||r.password_unreadable,q=d.preset==="other",F=(U,z,Q)=>t.jsxs("div",{className:"grid grid-cols-[1fr_7rem] gap-2",children:[t.jsx(jt,{label:`${z} server`,error:h[`${U}.host`],children:t.jsx(Ie,{name:`${U}_host`,value:U==="imap"?d.imapHost:d.smtpHost,onChange:I(U==="imap"?"imapHost":"smtpHost"),placeholder:Q,spellCheck:!1,autoCapitalize:"off"})}),t.jsx(jt,{label:"Port",error:h[`${U}.port`],children:t.jsx(Ie,{name:`${U}_port`,inputMode:"numeric",value:U==="imap"?d.imapPort:d.smtpPort,onChange:I(U==="imap"?"imapPort":"smtpPort")})})]});return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[Y,b&&t.jsx(na,{error:b.error,title:b.title}),i&&t.jsx(xt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:O,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The email account could not be read: ",i.code,": ",i.message,". What is shown may be out of date."]})}),t.jsxs("section",{className:"border bg-card p-4","aria-label":"Email account",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(hT,{className:"size-4 text-muted-foreground","aria-hidden":!0}),H?t.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:r.address}):t.jsx("span",{className:"text-body text-muted-foreground",children:"No email account is saved. The agents' email tools and email triggers need one."}),r.configured&&t.jsx(je,{tone:"success",children:"saved"}),H&&r.preset&&t.jsx(je,{children:((G=O0.find(U=>U.value===r.preset))==null?void 0:G.label)??r.preset})]}),H&&r.imap&&r.smtp&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["IMAP ",r.imap.host,":",r.imap.port," · SMTP ",r.smtp.host,":",r.smtp.port,r.user&&r.user!==r.address?` · signs in as ${r.user}`:""]}),r.configured&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"Its password is sealed on this server. It is never shown again; type it again only to change the account."}),r.password_unreadable&&t.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),"Its password can't be opened here: it was sealed under another key, or is damaged. The agents can't read or send mail until it is saved again."]})]}),t.jsxs("form",{className:"space-y-4 border bg-card p-4","aria-label":"Account",onSubmit:P,children:[t.jsxs("fieldset",{disabled:S,className:"min-w-0 space-y-4",children:[t.jsx(jt,{label:"Provider",group:"heading",note:YU,error:h.preset,children:t.jsx(Zc,{name:"email-preset",label:"Provider",value:d.preset,onChange:U=>A(z=>({...z,preset:U})),options:O0})}),t.jsx("p",{className:"text-small text-muted-foreground",children:VU[d.preset]}),t.jsx(jt,{label:"Address",error:h.address,children:t.jsx(Ie,{name:"address",inputMode:"email",autoComplete:"username",spellCheck:!1,autoCapitalize:"off",placeholder:"you@example.com",value:d.address,onChange:I("address")})}),t.jsx(jt,{label:"Sign-in name",optional:!0,note:"When the server's sign-in isn't the address.",error:h.user,children:t.jsx(Ie,{name:"user",spellCheck:!1,autoCapitalize:"off",value:d.user,onChange:I("user")})}),t.jsx(jt,{label:QU(d.preset),error:h.password,children:t.jsx(Ie,{name:"password",type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:r.configured?"Sealed on this server: type it again to save a change":"",value:f,onChange:U=>{x(U.target.value),j(null)}})}),q&&F("imap","IMAP","imap.example.com"),q&&F("smtp","SMTP","smtp.example.com")]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",variant:"solid",disabled:S||!d.address.trim()||!f,children:"Save"}),t.jsx(B,{type:"button",variant:"outline",disabled:S||!d.address.trim()||!f&&!r.configured,onClick:()=>void D(),children:"Test"}),H&&!k&&t.jsx(B,{type:"button",variant:"outline",disabled:S,onClick:()=>$(!0),children:"Remove"})]}),k&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-body",children:[t.jsx("span",{children:"The agents' email tools and email triggers stop until an account is saved again."}),t.jsx(B,{type:"button",variant:"destructive",disabled:S,onClick:()=>void W(),children:"Remove the account"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>$(!1),children:"Cancel"})]}),y&&t.jsxs("div",{"aria-label":"Test",className:"space-y-1 font-mono text-body",children:[["imap","smtp"].map(U=>t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(je,{tone:y[U].ok?"success":"error",children:U==="imap"?"IMAP":"SMTP"}),t.jsx("span",{className:y[U].ok?"":"text-destructive-text",children:y[U].message})]},U)),t.jsx("p",{className:"text-small text-muted-foreground",children:y.ok?"Both signed in. Nothing was sent, and nothing was saved by the test.":"Nothing was sent, and nothing was saved by the test."})]})]})]})})}const L0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},eW={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 tW({v2:e}){const[n,s]=p.useState(null),[r,a]=p.useState([]),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,x]=p.useState(null),[b,g]=p.useState(null),[h,v]=p.useState(!1),[y,j]=p.useState(!1),[k,$]=p.useState(""),S=p.useRef(0),N=()=>{const O=++S.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([A,I])=>{O===S.current&&(s(A),a(I.attempts),c(null))}).catch(A=>{O===S.current&&c(L0(A))})};p.useEffect(N,[e]);const _=async(O,A)=>{x(null),j(!0);try{await A()}catch(I){x({title:O,error:L0(I)})}finally{j(!1)}N()},E=O=>{O.preventDefault(),_("The webhook was not saved",async()=>{const A=await e.saveWebhook(k.trim());A.signing_secret&&u(A.signing_secret);const{signing_secret:I,...M}=A;s(M)})};return n?t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Webhook"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"One URL this server POSTs to when a run needs its person (`run.needs_input`) and when it ends (`run.ended`), signed by the Standard Webhooks spec, so a receiver checks each message with any of that spec's libraries."})]}),f&&t.jsx(na,{error:f.error,title:f.title}),i&&t.jsx(xt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:N,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",i.code,": ",i.message,". What is shown may be out of date."]})}),d&&t.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Webhook secret",children:[t.jsx("p",{className:"caps text-small font-semibold text-warning-text",children:"The signing secret, shown this once"}),t.jsx("p",{className:"mt-2 break-all font-mono text-body",children:d}),t.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:["Keep it where the receiver checks ",t.jsx("span",{className:"font-mono",children:"webhook-signature"}),". This server never shows it again."]}),t.jsx(B,{type:"button",variant:"outline",className:"mt-3",onClick:()=>u(null),children:"Done"})]}),t.jsxs("section",{className:"border bg-card p-4","aria-label":"Webhook URL",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Zi,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.configured?t.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:n.url}):t.jsx("span",{className:"text-body text-muted-foreground",children:"No webhook is set."}),n.configured&&(n.disabled?t.jsx(je,{tone:"error",children:"off"}):n.signing==="sealed"?t.jsx(je,{tone:"success",children:"on"}):t.jsx(je,{tone:"warning",children:"not signing"}))]}),n.configured&&n.disabled&&t.jsxs("p",{className:"mt-2 text-body text-destructive-text",children:["Off: ",n.disabled.reason,", ",mt(n.disabled.at),". Nothing is sent until the URL is saved again: enter it below."]}),n.configured&&n.signing!=="sealed"&&t.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),eW[n.signing]]}),t.jsxs("form",{className:"mt-4 flex flex-wrap gap-2",onSubmit:E,children:[t.jsx(Ie,{name:"url",type:"url",required:!0,maxLength:2048,placeholder:n.configured?"The whole URL, to change it or save it again":"https://...",value:k,onChange:O=>$(O.target.value),className:"h-9 min-w-[280px] flex-1","aria-label":"Webhook URL"}),t.jsx(B,{type:"submit",variant:"solid",disabled:y||!k.trim(),children:"Save"}),n.configured&&t.jsx(B,{type:"button",variant:"outline",disabled:y,onClick:()=>_("The test was not sent",async()=>g(await e.testWebhook())),children:"Send a test"}),n.configured&&!h&&t.jsx(B,{type:"button",variant:"outline",disabled:y,onClick:()=>v(!0),children:"Remove"})]}),h&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-body",children:[t.jsx("span",{children:"Its pending messages are dropped; the log of attempts stays."}),t.jsx(B,{type:"button",variant:"destructive",disabled:y,onClick:()=>{v(!1),$(""),g(null),_("The webhook was not removed",async()=>{await e.removeWebhook(),s({configured:!1,secret:{name:"webhook:outbound",set:!1,source:null,changed_at:null}}),u(null)})},children:"Remove the webhook"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>v(!1),children:"Cancel"})]}),b&&t.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",I0(b)]})]}),t.jsxs("section",{"aria-label":"Deliveries",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"caps text-small font-semibold text-muted-foreground",children:"Last deliveries"}),t.jsx(B,{type:"button",variant:"ghost",onClick:N,children:"Refresh"})]}),r.length===0?t.jsx("p",{className:"mt-2 border p-4 text-body text-muted-foreground",children:"No message has been tried yet."}):t.jsx("ul",{className:"mt-2 border",children:r.map((O,A)=>t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 text-body last:border-b-0",children:[t.jsx("span",{className:"w-[170px] shrink-0 text-muted-foreground",children:mt(O.at)}),t.jsx("span",{className:"w-[130px] shrink-0 font-mono",children:O.type}),t.jsx("span",{className:O.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:I0(O)}),O.redelivery&&t.jsx(je,{children:"redelivery"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:O.webhook_id,children:[O.webhook_id.slice(0,12),"…"]}),t.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:y,onClick:()=>_("The message was not sent again",()=>e.redeliverWebhook(O.webhook_id)),children:"Redeliver"})]},`${O.webhook_id}:${O.at}:${A}`))})]})]})}):i?t.jsx(xt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:N,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",i.code,": ",i.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."})}function I0(e){const n=e.error??`${e.status_code}`,s=e.status_code!==null?`, ${e.latency_ms} ms`:"";return`${n}${s}${e.retry_at?`; tried again ${mt(e.retry_at)}`:""}`}const nW={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."}},gx=e=>nW[e]??{label:e,gives:""},sW=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},xx=e=>e.slice(e.lastIndexOf(":")+1),rW=2e3;function oW({v2:e,writable:n,whyNot:s="sign_in"}){const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,x]=p.useState(null),[b,g]=p.useState({}),[h,v]=p.useState(new Set),y=p.useRef(0),j=p.useCallback(()=>{const _=++y.current;c(null),e.computers().then(E=>{_===y.current&&a(E)},E=>{_===y.current&&c(sW(E))})},[e]);if(p.useEffect(j,[j]),!r)return i?t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The computers could not be read: ",i.code,": ",i.message]}),t.jsx(B,{size:"sm",onClick:j,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Fn,{label:"Loading the computers",rows:3})});const k=new Set(r.paired.map(_=>_.id)),$=_=>r.kinds.filter(E=>E.providers.some(O=>O.id===_)).map(E=>E.kind),S=async(_,E,O)=>{x(null);try{await e.saveComputerKeys(E.id,O)}catch(A){return A instanceof ze&&A.status===422?A:(x({at:_,words:Dt(A)}),null)}return u(null),j(),null},N=async _=>{v(O=>new Set(O).add(_.id));let E;try{const O=await e.testComputer(_.id);E=O.ok?{ok:!0,words:O.detail,at:new Date().toISOString()}:{ok:!1,words:O.why,at:new Date().toISOString()}}catch(O){E={ok:!1,words:Dt(O),at:new Date().toISOString()}}g(O=>({...O,[_.id]:E})),v(O=>{const A=new Set(O);return A.delete(_.id),A})};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Computers"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The computers an agent can be given, and who provides them. An agent can have a kind once one of its providers is ready. Keys are kept sealed on this server and never shown again."})]}),t.jsx(lW,{v2:e,paired:r.paired,reload:j}),!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:Ja[s]}),r.kinds.map(_=>t.jsx(cW,{kind:_,providers:_.providers.filter(E=>!k.has(E.id)),own:_.providers.filter(E=>k.has(E.id)).map(E=>E.name),children:_.providers.filter(E=>!k.has(E.id)).map(E=>{const O=`${_.kind}/${E.id}`;return t.jsx(dW,{v2:e,kind:_.kind,provider:E,writable:n,serves:$(E.id),tested:b[E.id],testing:h.has(E.id),open:(d==null?void 0:d.at)===O?d.mode:null,problem:(f==null?void 0:f.at)===O?f.words:null,onOpen:A=>{u(A?{at:O,mode:A}:null),x(null)},onSave:A=>S(O,E,A),onRemove:async A=>{var M;const I=await S(O,E,{[A]:null});I&&x({at:O,words:((M=I.fields)==null?void 0:M.map(R=>R.message).join(" "))||I.message})},onTest:()=>void N(E)},E.id)})},_.kind))]})})}function aW(e){const n=e.device?`${e.device.maker} ${e.device.model}`:null,s=e.os_version?`${e.os} ${e.os_version}`:e.os,r=e.screen?`screen ${e.screen.width}×${e.screen.height} at ${e.screen.scale}x`:null;return[e.serves.map(a=>gx(a).label).join(", ")||gx(e.kind).label,n,s,e.arch,r].filter(Boolean).join(" · ")}function iW(e){const n=Object.entries(e.features??{}).flatMap(([s,r])=>r!==!0&&typeof(r==null?void 0:r.off)=="string"?[`${s} off: ${r.off}`]:[]);return[`Offers ${e.groups.join(", ")}`,...n].join(" · ")}function lW({v2:e,paired:n,reload:s}){const[r,a]=p.useState(null),[i,c]=p.useState(!1),[d,u]=p.useState(()=>Date.now()),[f,x]=p.useState(null),[b,g]=p.useState(null),[h,v]=p.useState(null),y=r?Date.parse(r.code.expires_at)-d:0,j=r!==null&&y>0;p.useEffect(()=>{if(!j)return;const N=setInterval(()=>u(Date.now()),1e3),_=setInterval(s,rW);return()=>{clearInterval(N),clearInterval(_)}},[j,s]),p.useEffect(()=>{if(!r)return;const N=n.find(_=>_.pairing===r.code.id);N&&(x(N.name),a(null))},[n,r]);const k=async()=>{c(!0),v(null),x(null);try{const N=await e.createPairing();u(Date.now()),a({code:N})}catch(N){v(Dt(N))}c(!1)},$=async N=>{v(null);try{await e.removeComputer(N)}catch(_){v(Dt(_));return}g(null),s()},S=`${Math.floor(Math.max(0,y)/6e4)}:${String(Math.floor(Math.max(0,y)%6e4/1e3)).padStart(2,"0")}`;return t.jsxs("section",{"aria-label":"Your computers",children:[t.jsxs("h2",{className:"mb-2 flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"caps text-small font-semibold",children:"Your computers"}),t.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?t.jsxs("div",{"data-pairing":!0,className:"mb-3 space-y-3 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Server address"}),t.jsx("p",{"data-address":!0,className:"mt-1 font-mono text-prose font-semibold",children:window.location.origin})]}),t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Pairing code"}),t.jsx("p",{"data-code":!0,className:"mt-1 font-mono text-2xl font-semibold",children:r.code.code})]})]}),j?t.jsxs("p",{className:"text-body",children:["Type both into the driver on the computer. The code pairs one computer, once, in the next ",t.jsx("span",{"data-countdown":!0,className:"font-mono",children:S}),"."]}):t.jsx("p",{role:"status",className:"text-body text-muted-foreground",children:"This code has expired. Make a new one."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{size:"sm",onClick:()=>void k(),disabled:i,children:i?"Making…":"New code"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>a(null),children:"Done"})]})]}):t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-3",children:[t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void k(),disabled:i,children:i?"Making…":"Pair a computer"}),f&&t.jsxs("p",{role:"status",className:"text-body text-success-text",children:["Paired ",f,"."]})]}),h&&t.jsx("p",{role:"alert",className:"mb-3 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:h}),n.length?t.jsx("ul",{className:"border",children:n.map(N=>t.jsxs("li",{"data-paired":N.id,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[N.serves.includes("phone")?t.jsx(kN,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}):t.jsx(qa,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:N.name}),N.online?t.jsx(je,{tone:"success",children:"Online"}):t.jsx(je,{tone:"muted",children:"Offline"}),N.held_by_run&&t.jsxs(je,{tone:"active",children:["In use by run ",ea(N.held_by_run)]}),N.unserved&&t.jsx(je,{tone:"warning",children:"No agent can use it"})]}),N.unserved&&t.jsx("p",{"data-unserved":!0,role:"status",className:"mt-1.5 text-small text-warning-text",children:N.unserved}),N.held_by_run&&N.held_until&&t.jsxs("p",{"data-held-until":!0,className:"mt-1.5 text-small text-muted-foreground",children:["The run's hold ends by ",mt(N.held_until),", released or not."]}),!N.online&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:"Open its driver on that computer: it dials this server."}),t.jsx("p",{"data-machine":!0,className:"mt-2 text-small text-muted-foreground",children:aW(N)}),N.groups.length>0&&t.jsx("p",{"data-offers":!0,className:"mt-1 text-small text-muted-foreground",children:iW(N)}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:`Driver ${N.driver} · paired ${mt(N.created_at)}${N.seen_at?` · last attached ${mt(N.seen_at)}`:""}`})]}),t.jsx(B,{size:"sm",onClick:()=>{g(N.id),v(null)},disabled:b!==null,children:"Remove"})]}),b===N.id&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",N.name,"? Its driver stops dialing and asks for a new code",N.held_by_run?", and the run using it loses it":"","."]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void $(N.id),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>g(null),children:"Cancel"})]})]},N.id))}):t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:"None paired yet. Pair a computer, then type the server address and its code into the driver on it."})]})}function cW({kind:e,providers:n,own:s,children:r}){const{label:a,gives:i}=gx(e.kind);return t.jsxs("section",{"aria-label":a,children:[t.jsxs("h2",{className:"mb-2 flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"caps text-small font-semibold",children:a}),i&&t.jsx("span",{className:"text-small text-muted-foreground",children:i}),!e.offered&&t.jsx(je,{tone:"muted",children:"Not offered here"})]}),!e.offered&&e.why&&t.jsx("p",{className:"mb-2 font-mono text-small text-muted-foreground",children:e.why}),s.length>0&&t.jsxs("p",{className:"mb-2 text-small text-muted-foreground",children:["Also served by your computers: ",s.join(", "),"."]}),n.length?t.jsx("ul",{className:"border",children:r}):t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:e.kind==="none"?"Nothing to set up.":s.length?"No other provider serves it on this server.":"No provider serves it on this server."})]})}function dW({v2:e,kind:n,provider:s,writable:r,serves:a,tested:i,testing:c,open:d,problem:u,onOpen:f,onSave:x,onRemove:b,onTest:g}){const h=p.useRef(null),v=d&&"paste"in d?d.paste:null,y=d&&"remove"in d?d.remove:null;return t.jsxs("li",{ref:h,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(qa,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:s.name}),s.ready?t.jsx(je,{tone:"success",children:"Ready"}):t.jsx(je,{children:"Not ready"}),s.metered&&t.jsx("span",{"data-metered":!0,className:"text-small text-muted-foreground",children:"Metered"})]}),!s.ready&&s.why&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:s.why}),s.metered&&Yv.has(n)&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:Vv}),s.secrets.length>0&&t.jsx("ul",{className:"mt-3 space-y-1.5",children:s.secrets.map(j=>{var S;const k=xx(j.name),$=((S=s.picked)==null?void 0:S.includes(j.name))??!1;return t.jsx(Jm,{field:j,required:s.required.includes(j.name),writable:r&&!d,onPaste:$?void 0:()=>void Qm(()=>f({paste:k}),()=>{var N,_;return(_=(N=h.current)==null?void 0:N.querySelector("form"))==null?void 0:_.elements.namedItem(k)}),onRemove:()=>f({remove:k})},j.name)})}),s.picked&&s.picked.length>0&&s.required.every(j=>s.secrets.some(k=>k.name===j&&k.set))&&t.jsx(uW,{v2:e,provider:s,writable:r&&!d,onSave:x}),i&&t.jsx("p",{"data-test":!0,className:`mt-2 text-small ${i.ok?"text-success-text":"text-destructive-text"}`,children:`${i.ok?"Passed":"Failed"} · ${td(i.at)} · ${i.words}`}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:[s.secrets.length?"":"No key. ","Serves: ",a.join(", ")]})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx(B,{size:"sm",onClick:g,disabled:c,children:c?"Testing…":"Test connection"})})]}),r&&v&&t.jsx(fW,{provider:s.name,name:v,set:s.secrets.some(j=>xx(j.name)===v&&j.set),onSave:x,onCancel:()=>f(null)}),r&&y&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",y," saved on this server?"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void b(y),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>f(null),children:"Cancel"})]}),u&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:u})]})}function uW({v2:e,provider:n,writable:s,onSave:r}){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(null),x=n.secrets.map(g=>`${g.name}:${g.set}:${g.changed_at??""}`).join(" ");p.useEffect(()=>{let g=!0;return i(null),d(null),e.computerChoices(n.id).then(h=>{g&&i(h)},h=>{g&&d(Dt(h))}),()=>{g=!1}},[e,n.id,x]);const b=async(g,h)=>{var y;f({key:g.key,value:h}),d(null);const v=await r({[g.key]:h});f(null),v&&d(((y=v.fields)==null?void 0:y.map(j=>j.message).join(" "))||v.message)};return c&&!a?t.jsx("p",{role:"alert",className:"mt-3 font-mono text-small text-destructive-text",children:`The choices could not be read: ${c}`}):a?t.jsxs("div",{className:"mt-3 space-y-3",children:[a.choices.map(g=>{const h=n.secrets.find(y=>xx(y.name)===g.key),v=(h==null?void 0:h.source)==="env";return t.jsxs("div",{"data-choices":g.key,className:"border bg-card p-3",children:[t.jsx("p",{className:"caps mb-2 text-small font-semibold",children:g.key}),"why"in g?t.jsx("p",{"data-why":!0,className:"font-mono text-small text-warning-text",children:g.why}):t.jsxs(t.Fragment,{children:[t.jsx(At,{label:`${n.name} ${g.key}`,value:(u==null?void 0:u.key)===g.key?u.value:g.saved??"",disabled:!s||v||u!==null,options:g.options.map(y=>({value:y.value,label:y.label})),placeholder:"Pick one",onChange:y=>void b(g,y),className:"w-full max-w-md"}),t.jsx("p",{"data-choice-note":!0,className:`mt-2 text-small ${h!=null&&h.set&&g.saved===void 0?"text-warning-text":"text-muted-foreground"}`,children:v?`Set in the environment where AgentRun starts, and that one is used: change ${g.key} there.`:g.saved!==void 0?"Picked and saved on this server.":h!=null&&h.set?`The ${g.key} saved on this server is not one of these any more, and runs still ask for it: pick one.`:g.options.length===1?`The only one, ${g.options[0].label}, is used while none is picked.`:`${g.options.length} to pick from. Pick the one this server's computers use.`})]})]},g.key)}),c&&t.jsx("p",{role:"alert",className:"font-mono text-small text-destructive-text",children:c})]}):t.jsx("p",{role:"status",className:"mt-3 text-small text-muted-foreground",children:"Reading the choices…"})}function fW({provider:e,name:n,set:s,onSave:r,onCancel:a}){const i=p.useRef(null),[c,d]=p.useState(!1),[u,f]=p.useState(!1),[x,b]=p.useState(null),g=()=>{var y,j;return((j=(y=i.current)==null?void 0:y.elements.namedItem(n))==null?void 0:j.value)??""},h=()=>{var y;(y=i.current)==null||y.reset(),d(!1)},v=async y=>{var N;y.preventDefault();const j=g();if(!j)return;f(!0),b(null);const k=await r({[n]:j});if(f(!1),!k){h();return}const $=(N=k.fields)==null?void 0:N.find(_=>_.field===n),S=(k.fields??[]).filter(_=>_.field!==n).map(_=>_.message);b($?{field:$.message,message:S.join(" ")}:{field:null,message:S.join(" ")||k.message})};return t.jsxs("form",{ref:i,autoComplete:"off",onSubmit:y=>void v(y),onInput:()=>d(!!g()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e} ${n}`,children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:n}),s&&t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"A new value replaces the one saved."}),t.jsx(Ie,{type:"password",name:n,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(x==null?void 0:x.field)&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:x.field})]}),(x==null?void 0:x.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:x.message}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Kept sealed on this server. It is never shown again, here or anywhere."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!c||u,children:u?"Saving":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{h(),a()},children:"Cancel"})]})]})}const mW="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.",z0=[{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)"}],hW=e=>({region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),yr="ARCHIL_API_KEY",pW=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function gW({v2:e,writable:n,whyNot:s="sign_in"}){const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState({region:"",s3Url:"",image:""}),[f,x]=p.useState(null),[b,g]=p.useState(null),[h,v]=p.useState(!1),[y,j]=p.useState(null),[k,$]=p.useState(!1),[S,N]=p.useState(!1),[_,E]=p.useState(!1),[O,A]=p.useState(!1),I=p.useRef(null),M=p.useRef(0),R=p.useCallback(F=>{a(F),u(hW(F))},[]),P=p.useCallback(()=>{const F=++M.current;c(null),e.archil().then(G=>{F===M.current&&R(G)},G=>{F===M.current&&c(pW(G))})},[e,R]);if(p.useEffect(P,[P]),!r)return i?t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["Archil's settings could not be read: ",i.code,": ",i.message]}),t.jsx(B,{size:"sm",onClick:P,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Fn,{label:"Loading Archil's settings",rows:2})});const D=()=>{var F,G;return((G=(F=I.current)==null?void 0:F.elements.namedItem(yr))==null?void 0:G.value)??""},W=async F=>{const G={region:d.region,s3Url:d.s3Url,...d.image?{image:d.image}:{},...F!==void 0?{keys:{[yr]:F}}:{}};v(!0),x(null),g(null);try{const U=await e.saveArchil(G);E(!1),A(!1),R(U)}catch(U){if(U instanceof ze&&U.status===422){const z={},Q=[];for(const K of U.fields??[]){const Z=K.field.startsWith("keys.")?K.field.slice(5):K.field;z0.some(de=>de.name===Z)||Z===yr?z[Z]=K.message:Q.push(K.message)}x({fields:z,message:Q.length?Q.join(" "):Object.keys(z).length?null:U.message})}else g(Dt(U))}finally{v(!1)}},Y=F=>{F.preventDefault(),W(_&&D()?D():void 0)},H=async()=>{$(!0);try{const F=await e.testArchil();j(F.ok?{ok:!0,words:F.detail,at:new Date().toISOString()}:{ok:!1,words:F.why,at:new Date().toISOString()})}catch(F){j({ok:!1,words:Dt(F),at:new Date().toISOString()})}finally{$(!1)}},q=async()=>{g(null);try{R(await e.archilOff()),N(!1)}catch(F){g(Dt(F))}};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Workspace"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:mW})]}),!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:Ja[s]}),t.jsxs("section",{"aria-label":"Archil",className:"border p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(lT,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"font-mono text-prose font-semibold",children:"Archil"}),t.jsx("span",{"data-archil-state":!0,children:r.on?t.jsx(je,{tone:"success",children:"On"}):t.jsx(je,{children:"Off"})}),r.on&&t.jsx("span",{"data-disk":!0,className:"font-mono text-small text-muted-foreground",children:r.region??""}),t.jsx("span",{className:"flex-1"}),t.jsx(B,{size:"sm",onClick:()=>void H(),disabled:k,children:k?"Testing…":"Test"}),r.on&&t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Turn off"})]}),y&&t.jsx("p",{"data-test":!0,className:`mt-3 text-small ${y.ok?"text-success-text":"text-destructive-text"}`,children:`${y.ok?"Passed":"Failed"} · ${td(y.at)} · ${y.words}`}),S&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Turn Archil off? Its keys are kept, for turning it on again."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void q(),children:"Turn off"}),t.jsx(B,{size:"sm",onClick:()=>N(!1),children:"Cancel"})]}),b&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:b}),t.jsxs("form",{ref:I,autoComplete:"off",onSubmit:Y,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[z0.map(F=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:F.label}),t.jsx(Ie,{name:F.name,value:d[F.name],placeholder:F.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:G=>{const U=G.currentTarget.value;u(z=>({...z,[F.name]:U}))}}),(f==null?void 0:f.fields[F.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[F.name]})]},F.name)),t.jsx("ul",{children:t.jsx(Jm,{field:r.secret,label:yr,writable:n&&!_&&!O,onPaste:()=>void Qm(()=>E(!0),()=>{var F;return(F=I.current)==null?void 0:F.elements.namedItem(yr)}),onRemove:()=>A(!0)})}),n&&O&&t.jsxs("div",{"data-confirm-key":!0,className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",yr," saved on this server?"]}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:()=>void W(null),children:"Remove"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>A(!1),children:"Cancel"})]}),n&&_&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:yr}),t.jsx(Ie,{type:"password",name:yr,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(f==null?void 0:f.fields[yr])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[yr]})]}),n&&_&&t.jsx(B,{type:"button",size:"sm",onClick:()=>E(!1),children:"Cancel"}),(f==null?void 0:f.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f.message}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:h,children:h?"Saving":r.on?"Save":"Turn on"})]})]})]})})}const TE="tool_approval_requested";function xW(e){var n;return e.status!=="input_required"||e.state!=="waiting"?null:((n=e.pending)==null?void 0:n.kind)==="approval"?e.pending:null}function vW(e){return e==="not metered"?"Not metered":e==="priced by usage"?"Priced by usage: monid estimates the cost when the call runs, and can charge more.":e===0?"Costs nothing per call":typeof e=="number"?`Costs ${Xr(e)} per call`:null}function yW(e){let n;try{n=JSON.parse(e)}catch{return e}return!n||typeof n!="object"||Array.isArray(n)?JSON.stringify(n,null,2):Object.entries(n).map(([s,r])=>`${s}: ${typeof r=="string"?r:JSON.stringify(r)}`).join(`
|
|
690
|
+
`)}const bW={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 RE(e){var n;if(e instanceof ze){const s=((n=e.details)==null?void 0:n.reason)==="already_answered"&&typeof e.details.decision=="string"?bW[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 Dt(e)}const wW=2e3;function AE({pending:e,onAnswer:n,compact:s=!1,heading:r}){const[a,i]=p.useState(""),[c,d]=p.useState(!1),[u,f]=p.useState(null),[x,b]=p.useState(null),[g,h]=p.useState(!1),v=e.destructive===!0,y=p.useRef(!1),j=p.useRef(null),k=p.useRef(!1);p.useEffect(()=>{var N;g||!k.current||(k.current=!1,(N=j.current)==null||N.focus())},[g]);const $=vW(e.price),S=async(N,_)=>{if(y.current)return;y.current=!0,d(!0),f(null),h(!1);const E=a.trim(),O=await(_?n(N,void 0,_):n(N,N==="deny"&&E?E:void 0));y.current=!1,d(!1),O?f(O):b(N)};return t.jsxs("section",{"aria-label":"Approval required",className:ae("min-w-0 border border-warning/50 bg-warning/5",s?"p-4":"p-4 md:p-5"),children:[r,t.jsxs("p",{className:ae("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-2"),children:[t.jsx(jN,{className:"size-3.5","aria-hidden":!0})," Approval required"]}),t.jsxs("p",{className:"mt-2 text-prose leading-snug",children:["The agent wants to run ",t.jsx("span",{className:"break-all font-mono text-lead",children:e.tool}),".",v&&t.jsxs(t.Fragment,{children:[" ",t.jsx(je,{tone:"error",title:"Its server marks this tool destructive: it may delete or overwrite.",children:"Destructive"})]})]}),t.jsx("pre",{"aria-label":`${e.tool} arguments`,title:e.args_preview,className:ae("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:yW(e.args_preview)}),$&&t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:$}),x?t.jsx("p",{className:"mt-3 font-mono text-body text-success-text",role:"status",children:x==="allow"?"Allowed. The run goes on.":"Denied. The agent reads why and goes on."}):t.jsxs("div",{className:"mt-3 space-y-2",children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-small text-muted-foreground",children:"Tell the agent why (optional, sent with Deny)"}),t.jsx(ln,{value:a,onChange:N=>i(N.target.value),maxLength:wW,rows:s?1:2,disabled:c,className:"mt-1 block resize-y py-2 font-sans text-lead"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{ref:j,type:"button",variant:"solid",size:"sm",disabled:c||g,onClick:()=>v?h(!0):void S("allow"),children:"Allow once"}),t.jsx(B,{type:"button",size:"sm",disabled:c,onClick:()=>void S("deny"),children:"Deny"}),c&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]}),g&&t.jsx(jW,{tool:e.tool,onAllow:()=>void S("allow",!0),onBack:()=>{k.current=!0,h(!1)}}),!s&&t.jsx("p",{className:"text-small text-muted-foreground",children:"or type what to do instead; sending it declines this call"}),u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u})]})]})}function jW({tool:e,onAllow:n,onBack:s}){const r=p.useRef(null);return p.useEffect(()=>{var a;(a=r.current)==null||a.focus()},[]),t.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:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Allow a destructive call?"})," Its server marks ",t.jsx("span",{className:"break-all font-mono",children:e})," as one that may delete or overwrite."]}),t.jsx(B,{ref:r,type:"button",size:"sm",variant:"ghost",onClick:s,children:"Back"}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:n,children:"Allow this destructive call"})]})}const kW={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 NW({mode:e,onSend:n,sending:s,sent:r,purpose:a}){const i=a??kW[e],[c,d]=p.useState(""),[u,f]=p.useState(!1),x=s||u,b=async()=>{if(!c.trim()||!n||x)return;f(!0);const g=await n(c.trim());f(!1),g!==!1&&d("")};return t.jsxs("form",{className:"border bg-card focus-within:border-foreground",onSubmit:g=>{g.preventDefault(),b()},children:[t.jsx(ln,{bare:!0,id:"composer",rows:2,value:c,readOnly:x,"aria-busy":x,onChange:g=>d(g.target.value),placeholder:i.placeholder,onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),b())},className:"block w-full resize-none px-4 pt-3"}),t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 pb-3",children:[t.jsxs("span",{className:"min-w-0 text-label text-muted-foreground",children:[t.jsx("label",{htmlFor:"composer",className:"font-semibold text-foreground",children:i.label})," · ",r?"Sent. It appears on the timeline when the run takes it.":i.does]}),t.jsxs(B,{type:"submit",size:"sm",disabled:!c.trim()||!n||x,children:[x?"Sending":"Send"," ",t.jsx(nT,{"aria-hidden":!0})]})]})]})}function Vr(e){if(Number.isInteger(e))return`$${e}`;for(let n=2;n<8;n++)if(Number(e.toFixed(n))===Number(e.toFixed(8)))return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}const OE=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${Vr(e.cap_usd)} `:""}spend cap`;function SW({pending:e}){return t.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Paused at its spend cap",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[t.jsx(_x,{className:"size-3.5","aria-hidden":!0})," ",OE(e)]}),typeof e.said=="string"&&t.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:e.said}),t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:"It waits for its cap to be raised; a message can't go on until then."})]})}const ME=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,PE=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function CW(e){var n,s;return e instanceof ze?e.status===422?((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message:e.status===409?"This run has ended, so its cap can't be raised.":e.status===404?"This run is no longer on the server.":e.message:e instanceof Error?e.message:String(e)}function LE({cap:e,suggested:n,least:s=null,paused:r,onRaise:a}){const[i,c]=p.useState(n===null?"":String(n)),[d,u]=p.useState(!1),[f,x]=p.useState(null),[b,g]=p.useState(null),h=p.useRef(!1),v=Number(i),y=i.trim()!==""&&Number.isFinite(v)&&v>0,j=async k=>{if(k==null||k.preventDefault(),!(!y||h.current)){h.current=!0,u(!0),x(null),g(null);try{const $=await a(v);$.note&&g($.note)}catch($){x(CW($))}finally{h.current=!1,u(!1)}}};return t.jsxs("form",{className:"border border-warning/50 p-4","aria-label":"Raise the cap",onSubmit:k=>void j(k),children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("label",{className:"flex items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"text-muted-foreground",children:"$"}),t.jsx(Ie,{"aria-label":"New cap in dollars",inputMode:"decimal",value:i,onChange:k=>c(k.target.value),disabled:d,placeholder:`more than ${Vr(e)}`,className:"h-9 w-32"})]}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:d||!y,children:d?"Raising":r?"Raise the cap and continue":"Raise the cap"})]}),(s!==null||n!==null)&&t.jsxs("ul",{className:"mt-2 space-y-0.5 font-mono text-small","aria-label":"Cap figures",children:[s!==null&&t.jsxs("li",{"data-cap-figure":"least",children:["Least to continue: ",Vr(s)]}),n!==null&&t.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",Vr(n)]})]}),n!==null&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The suggestion is prefilled; change it before you raise, if you like."}),f&&t.jsx("p",{className:"mt-2 text-body text-destructive-text",role:"alert",children:f}),b&&t.jsx("p",{className:"mt-2 text-body text-muted-foreground",role:"status",children:b})]})}function EW({waiting:e}){if(e){const n=(e.text??e.summary??"").replace(/^Waiting for you:\s*/,"");return t.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"The agent asks",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[t.jsx(Ox,{className:"size-3.5","aria-hidden":!0})," Input required"]}),t.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:n})]})}return t.jsxs("section",{className:"border border-border-strong/60 p-4","aria-label":"Stopped",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(Xi,{className:"size-3.5","aria-hidden":!0})," Stopped"]}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The turn was stopped. The run stays open: send a message to continue it."})]})}let Qi=0;const vx=()=>{var n;const e=(n=history.state)==null?void 0:n.console_at;return typeof e=="number"?e:void 0},D0=e=>{Qi=e,history.replaceState({...history.state??{},console_at:e},"")};function $W(){const e=vx();e===void 0?D0(0):Qi=e;const n=()=>{const s=vx();s===void 0?D0(Qi+1):Qi=s};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)}function _W(){const e=vx();return e===void 0?-1:Qi-e}function TW(e){Qi>0?history.back():location.hash=e}const RW=(e,n)=>{const s=xl(e),r=nd(e)?_2:void 0;return s?r?`${Zj(s,{ended:n})} ${r}`:Zj(s,{ended:n}):e&&e.usd!==null&&MS(e)?r?`A local estimate, not a bill. ${r}`:"A local estimate, not a bill":r};function AW({run:e,agentName:n,actions:s={},costText:r}){var $,S,N;const a=Zn(e),i=a?"your backend":$P(e.place),c=_m(e.status,e.state,e.kind,$m,!0,e.error,e.review,e.computer),d=a?{...c,canStop:!1,canCancel:!1}:c,[u,f]=p.useState(!1),x=!!e.archived_at,b=($=e.cost)==null?void 0:$.cap_usd,g=!!e.pending&&e.pending.kind!=="budget"&&e.pending.kind!=="stopped",h=!a&&!!s.onRaiseCap&&!d.final&&typeof b=="number"&&!g,[v,y]=p.useState(!1),j=((S=e.pending)==null?void 0:S.kind)==="budget"?e.pending:null,k=!!nd(e.cost);return t.jsxs("header",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[t.jsxs("nav",{className:"caps flex min-w-0 items-center gap-2 text-label text-muted-foreground","aria-label":"Breadcrumb",children:[t.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:()=>TW(on(e.agent_id)),className:"-m-1 shrink-0 p-1 hover:text-foreground",children:t.jsx(zn,{className:"size-3.5","aria-hidden":!0})}),t.jsx("a",{href:on(e.agent_id),className:"truncate hover:text-foreground hover:underline",children:n}),t.jsx("span",{"aria-hidden":!0,children:"/"}),t.jsxs("span",{className:"truncate",children:["Run ",ea(e.run_id)]})]}),t.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:[t.jsxs("div",{className:"min-w-0 flex-1 self-stretch max-sm:contents sm:basis-64",children:[t.jsx("h1",{className:"line-clamp-2 break-words text-2xl font-semibold leading-tight max-sm:basis-full max-sm:text-lg",title:Nn(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?n:Nn(e)}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-small text-muted-foreground max-sm:contents",children:[t.jsx(yl,{run:e}),x&&t.jsx(je,{tone:"muted",children:"Archived"}),e.approvals==="never"&&t.jsx(je,{tone:"warning",title:"This run's agent never asks: no call of it waits for you.",children:"Unattended"}),t.jsxs("span",{className:"font-mono",children:[e.kind," · rev ",e.agent_version,i&&` · ${i}`]}),a&&t.jsxs("span",{className:"font-mono",children:[Ko(a.runtime)," · ",((N=e.sdk)==null?void 0:N.model)??"Model not reported"]}),t.jsx("span",{className:"font-mono",children:mt(e.created_at)}),r!==void 0&&!k?t.jsx("span",{className:"font-mono",title:"The run's decisions and model calls, as the providers priced them",children:ek(e.cost,b,{text:r})}):t.jsxs("span",{className:"font-mono",title:RW(e.cost,Ua(e.status)),children:[ek(e.cost,b,{ended:Ua(e.status)}),k&&t.jsxs(t.Fragment,{children:[" · ",t.jsx(Jv,{})]})]}),t.jsx(Gv,{run:e,link:!0}),t.jsx(NE,{run:e})]}),e.status==="completed"&&e.review&&t.jsxs("p",{className:"mt-2 text-body text-warning-text max-sm:mt-0 max-sm:basis-full",children:["Needs review: ",e.review.reason]})]}),(d.canStop||d.canCancel||s.onArchive||h)&&t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[h&&t.jsxs(B,{size:"sm",onClick:()=>y(_=>!_),"aria-expanded":v,title:`Raise its ${Vr(b)} spend cap.`,children:[t.jsx(_x,{"aria-hidden":!0})," Raise the cap"]}),d.canStop&&t.jsxs(B,{size:"sm",onClick:s.onStop,disabled:!s.onStop||!!s.busy,title:e.native?"Stop this native turn. Start a new run for another task.":"End this turn. The run stays open and waits for your next message.",children:[t.jsx(CT,{"aria-hidden":!0})," ",s.busy==="stop"?"Stopping":"Stop"]}),d.canCancel&&!u&&t.jsxs(B,{size:"sm",variant:"destructive",onClick:()=>f(!0),disabled:!s.onCancel||!!s.busy,title:"End the run for good.",children:[t.jsx(pN,{"aria-hidden":!0})," ",s.busy==="cancel"?"Cancelling":"Cancel run"]}),u&&t.jsxs("span",{className:"flex items-center gap-2 border border-destructive/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Cancel this run?",children:[t.jsx("span",{children:"Cancel for good?"}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>{var _;f(!1),(_=s.onCancel)==null||_.call(s)},children:"Yes, cancel"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>f(!1),children:"Keep"})]}),s.onArchive&&t.jsxs(B,{size:"sm",onClick:s.onArchive,disabled:!!s.busy,title:x?"Show it in the runs list again.":"Hide it from the runs list. Its history is kept.",children:[x?t.jsx(hN,{"aria-hidden":!0}):t.jsx(qc,{"aria-hidden":!0})," ",s.busy==="archive"?x?"Unarchiving":"Archiving":x?"Unarchive":"Archive"]})]})]}),h&&v&&t.jsx("div",{className:"mt-3 max-w-xl",children:t.jsx(LE,{cap:b,suggested:ME(j),least:PE(j),paused:!!j,onRaise:s.onRaiseCap},j?`${e.run_id}:${j.at}`:`${e.run_id}:working`)})]})}const OW=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function MW({view:e,onView:n}){return t.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:OW.map(s=>t.jsxs("label",{className:ae("caps -ml-px cursor-pointer border px-3 py-1.5 text-label first:ml-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-1 has-[:focus-visible]:outline-offset-2",e===s.id?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[t.jsx("input",{type:"radio",name:"file-view",value:s.id,checked:e===s.id,onChange:()=>n(s.id),className:"sr-only"}),s.label]},s.id))})}const IE=(e,n)=>n?e:e.filter(s=>!r2(s.path));function PW({files:e,onOpen:n,showHidden:s,onShowHidden:r}){const a=e.filter(d=>r2(d.path)).length,i=IE(e,s),c=i.reduce((d,u)=>d+u.size_bytes,0);return t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center gap-3",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(aT,{className:"size-3.5","aria-hidden":!0})," Files · ",i.length," ",i.length===1?"file":"files"," (",nl(c),")"]}),a>0&&t.jsxs("button",{type:"button",className:"caps ml-auto text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline","aria-pressed":s,onClick:()=>r(!s),children:[s?"Hide":"Show"," ",a," hidden"]})]}),i.length===0?t.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."}):t.jsx("ul",{className:"border",children:i.map(d=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("button",{type:"button",onClick:()=>n(d),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left hover:bg-accent",children:[t.jsx(Ga,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:d.path}),t.jsx("span",{className:"hidden font-mono text-label text-muted-foreground sm:inline",children:mt(d.modified_at)}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:nl(d.size_bytes)})]})},d.path))})]})}function LW({file:e,text:n,onClose:s,files:r=[],onOpen:a}){const[i,c]=p.useState(!1),d=p.useRef(null);p.useEffect(()=>{var k;const y=document.activeElement,j=d.current;return j&&!j.open&&((k=j.showModal)==null||k.call(j)),()=>{var $;j!=null&&j.open&&j.close(),($=y==null?void 0:y.focus)==null||$.call(y)}},[]),p.useEffect(()=>c(!1),[e.path]);const u=p.useRef(!1),f=p.useRef(!1),x=iP(e),[b,g]=p.useState(x==="markdown"?"rendered":"raw");p.useEffect(()=>g(x==="markdown"?"rendered":"raw"),[e.path]);const h=mv(y=>{const j=r.find(k=>k.path===y);j&&(a==null||a(j))}),v=()=>{if(n===null)return;const y=URL.createObjectURL(new Blob([n],{type:e.content_type??"application/octet-stream"}));Object.assign(document.createElement("a"),{href:y,download:e.path.split("/").pop()}).click(),URL.revokeObjectURL(y)};return t.jsx("dialog",{ref:d,"aria-label":e.path,onCancel:y=>{y.preventDefault(),s()},onMouseDown:y=>{u.current=y.target===y.currentTarget},onMouseUp:y=>{f.current=y.target===y.currentTarget},onClick:y=>{u.current&&f.current&&y.target===y.currentTarget&&s(),u.current=f.current=!1},className:"m-0 h-full max-h-none w-full max-w-none border-0 bg-transparent p-0 text-foreground backdrop:bg-overlay/60 md:p-8",children:t.jsxs("div",{className:"mx-auto flex h-full w-full max-w-5xl flex-col border bg-background",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2.5",children:[t.jsx(B,{size:"icon",variant:"ghost",onClick:s,"aria-label":"Close",children:t.jsx(Qo,{"aria-hidden":!0})}),t.jsx(Ga,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:e.path}),x!=="download"&&t.jsx("div",{className:"order-last basis-full sm:order-none sm:basis-auto",children:t.jsx(MW,{view:b,onView:g})}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:async()=>{var y;n!==null&&(await((y=navigator.clipboard)==null?void 0:y.writeText(n)),c(!0))},children:[t.jsx(Ba,{"aria-hidden":!0})," ",i?"Copied":"Copy"]}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:v,children:[t.jsx(rT,{"aria-hidden":!0})," Download"]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 py-8 md:px-16",children:n===null?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading the file..."}):x==="download"?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This file type is not shown here. Download it to open it."}):b==="rendered"?t.jsx("article",{className:"report mx-auto max-w-3xl",onClick:h,dangerouslySetInnerHTML:{__html:eo(n,a&&{paths:r.map(y=>y.path),from:e.path.split("/").slice(0,-1).join("/")})}}):t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-small leading-[1.8]",children:n})}),t.jsxs("footer",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["File · ",n===null?"...":`${n.length.toLocaleString("en-US")} characters`," · ",e.content_type??"unknown type"]})]})})}function IW(e){const n=e.replace(/\r\n?/g,`
|
|
691
|
+
`).trim(),s=c=>{try{const d=JSON.parse(c);return d&&typeof d=="object"&&!Array.isArray(d)?d:null}catch{return null}},r=n.split(`
|
|
692
|
+
`);let a;for(let c=0;c<r.length;c++){const d=/^ {0,3}(`{3,}|~{3,})([^`]*)$/.exec(r[c]);if(!d)continue;const u=d[1],f=new RegExp(`^ {0,3}${u[0]==="`"?"`":"~"}{${u.length},}\\s*$`),x=r.findIndex((g,h)=>h>c&&f.test(g));if(x<0)break;const b=d[2].trim().toLowerCase();a=b==="json"||b===""?{open:c,end:x}:void 0,c=x}if(a&&a.end===r.length-1){const c=s(r.slice(a.open+1,a.end).join(`
|
|
693
|
+
`));return c?{words:r.slice(0,a.open).join(`
|
|
694
|
+
`).trim(),record:c}:null}const i=s(n);if(i)return{words:"",record:i};for(let c=n.lastIndexOf(`
|
|
695
|
+
{`);c>=0;c=n.lastIndexOf(`
|
|
696
|
+
{`,c-1)){const d=s(n.slice(c+1));if(d)return{words:n.slice(0,c).trim(),record:d};if(c===0)break}return null}const zW=e=>e.replace(/[_-]+/g," ").trim()||e,mc=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;function Yf(e,n){let s=mc(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(f=>decodeURIComponent(f).replaceAll("~1","/").replaceAll("~0","~")),{$ref:i,...c}=s,d=mc(a.reduce((f,x)=>{var b;return(b=mc(f))==null?void 0:b[x]},n))??{},u=d.properties||c.properties?{...mc(d.properties),...mc(c.properties)}:void 0;s={...d,...c,...u?{properties:u}:{}}}return s}const DW=(e,n)=>{var s;return((s=Yf(e,n))==null?void 0:s.contentMediaType)==="text/markdown"};function hy({value:e,schema:n,root:s,linked:r}){var a;if(e==null)return t.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"—"});if(Array.isArray(e)){if(!e.length)return t.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"none"});const i=(a=Yf(n,s))==null?void 0:a.items;return t.jsx("ul",{"data-json":"array",className:"list-disc space-y-1 pl-5",children:e.map((c,d)=>t.jsx("li",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:t.jsx(hy,{value:c,schema:i,root:s,linked:r})},d))})}return typeof e=="object"?t.jsx(zE,{record:e,schema:n,root:s,linked:r}):typeof e=="string"&&DW(n,s)?t.jsx("article",{"data-json-markdown":!0,className:"report max-w-none",dangerouslySetInnerHTML:{__html:eo(e,r)}}):t.jsx("span",{"data-json-value":!0,className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:String(e)})}function zE({record:e,schema:n,root:s,linked:r}){var i;const a=(i=Yf(n,s))==null?void 0:i.properties;return t.jsx("dl",{"data-json":"object",className:"min-w-0 space-y-3 border-l pl-4",children:Object.entries(e).map(([c,d])=>{var x;const u=a==null?void 0:a[c],f=(x=Yf(u,s))==null?void 0:x.title;return t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"caps break-words [overflow-wrap:anywhere] text-label text-muted-foreground",children:typeof f=="string"&&f.trim()?f:zW(c)}),t.jsx("dd",{className:"mt-1 min-w-0 text-prose leading-relaxed",children:t.jsx(hy,{value:d,schema:u,root:s,linked:r})})]},c)})})}function F0({record:e,schema:n,linked:s}){const[r,a]=p.useState(!1);return t.jsxs("section",{className:"min-w-0 space-y-3",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(B,{type:"button",size:"xs",onClick:()=>a(i=>!i),children:r?"Show fields":"Show raw JSON"})}),r?t.jsx("pre",{"aria-label":"The answer's JSON",className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(e,null,2)}):t.jsx("div",{"aria-label":"The answer's fields",className:"min-w-0 [&>dl]:border-l-0 [&>dl]:pl-0",children:t.jsx(zE,{record:e,schema:n,root:n,linked:s})})]})}function FW({value:e,schema:n,linked:s}){return t.jsx("div",{"aria-label":"The answer's value",className:"min-w-0 text-prose leading-relaxed",children:t.jsx(hy,{value:e,schema:n,root:n,linked:s})})}function UW({run:e,rows:n,files:s=[],onOpen:r,schema:a}){var b,g,h,v,y;const i=((b=e.result)==null?void 0:b.final_answer)??((g=n.findLast(j=>j.kind==="final_answer"))==null?void 0:g.text)??null,c=r?{paths:s.map(j=>j.path)}:void 0,d=mv(j=>{const k=s.find($=>$.path===j);k&&(r==null||r(k))}),u=(h=e.result)==null?void 0:h.output;if(e.kind==="agentic"&&u!==void 0&&u!==null)return t.jsx("div",{className:"min-w-0",onClick:d,children:typeof u=="object"&&!Array.isArray(u)?t.jsx(F0,{record:u,schema:a,linked:c}):t.jsx(FW,{value:u,schema:a,linked:c})});const f=e.kind==="agentic"?(v=e.result)==null?void 0:v.output_error:void 0,x=f?t.jsx(xt,{tone:"warning",title:"The answer did not match the output schema",children:f}):null;if(i!=null&&i.trim()){const j=IW(i);return j?t.jsxs("div",{className:"min-w-0 space-y-6",children:[x,j.words&&t.jsx("article",{className:"report max-w-none",onClick:d,dangerouslySetInnerHTML:{__html:eo(j.words,c)}}),t.jsx(F0,{record:j.record})]}):t.jsxs("div",{className:"min-w-0 space-y-6",children:[x,t.jsx("article",{className:"report max-w-none",onClick:d,dangerouslySetInnerHTML:{__html:eo(i,c)}})]})}if(x)return x;if(((y=e.result)==null?void 0:y.output)!==void 0&&e.result.output!==null){const j=e.result.output,k=j&&typeof j=="object"&&!Array.isArray(j)?Object.entries(j).filter(S=>typeof S[1]=="string"&&S[1].includes(`
|
|
697
|
+
`)&&S[1].length>80):[],$=k.length?Object.fromEntries(Object.entries(j).filter(([S])=>!k.some(([N])=>N===S))):j;return t.jsxs("div",{className:"space-y-8",children:[k.map(([S,N])=>t.jsxs("section",{children:[t.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:S.replace(/_/g," ")}),t.jsx("article",{className:"report max-w-none border bg-card p-5",onClick:d,dangerouslySetInnerHTML:{__html:eo(N,c)}})]},S)),(!k.length||Object.keys($).length>0)&&t.jsxs("section",{children:[t.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:k.length?"The rest of the output":"Output"}),t.jsx("pre",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify($,null,2)})]})]})}return null}function WW({native:e,agentId:n}){const s=[{label:"Task usage",usage:e.usage.task},...e.usage.reflection.length?e.usage.reflection.map((r,a)=>({label:`Reflection usage · turn ${a+1}`,usage:r})):[{label:"Reflection usage",usage:null}]];return t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Native run details",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Native run"}),t.jsx("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[["Runtime",ld(e.runtime)],["Project",e.project],["Selector",Ev(e.selector)],["Machine",e.machine_id],["Native session",e.session_id??"Not reported"],["Model",e.model??"Unknown"],["Configuration fingerprint",e.fingerprint],["Pinned learning revision",e.learning_revision??"None supplied"]].map(([r,a])=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"text-muted-foreground",children:r}),t.jsx("dd",{className:"break-all font-mono",children:a})]},r))}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Native usage by phase",children:[t.jsx("thead",{children:t.jsx("tr",{children:["Phase","Uncached input","Output tokens","Cache read","Cache write","Cost"].map(r=>t.jsx("th",{className:"whitespace-nowrap border-b px-2 py-2 font-semibold",children:r},r))})}),t.jsx("tbody",{children:s.map(({label:r,usage:a})=>{const i=e.runtime==="codex"?(a==null?void 0:a.input_tokens)==null||a.cache_read_tokens==null||a.cache_write_tokens==null?null:Math.max(0,a.input_tokens-a.cache_read_tokens-a.cache_write_tokens):a==null?void 0:a.input_tokens;return t.jsxs("tr",{children:[t.jsx("th",{className:"whitespace-nowrap px-2 py-2 font-normal",children:r}),[i,a==null?void 0:a.output_tokens,a==null?void 0:a.cache_read_tokens,a==null?void 0:a.cache_write_tokens].map((c,d)=>t.jsx("td",{className:"px-2 py-2 font-mono",children:c==null?"Unknown":c.toLocaleString("en-US")},d)),t.jsx("td",{className:"px-2 py-2 font-mono",children:(a==null?void 0:a.cost_usd)==null?"Unknown":Xr(a.cost_usd)})]},r)})})]})}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Grading usage belongs to the separate learning run.",n&&t.jsxs(t.Fragment,{children:[" ",t.jsx("a",{href:`#/agents/${encodeURIComponent(n)}/learning`,className:"underline underline-offset-2",children:"Open learning evidence"}),"."]})," Unreported native counters and model request totals stay unknown."]})]})}const HW={seeded:"Prepared",reflecting:"Reflecting",proposed:"Under review",merged:"Saved",dropped:"Not saved",pending:"Awaiting approval"},Xu=e=>typeof e=="number"&&Number.isFinite(e)?e.toLocaleString("en-US"):"Not reported";function BW({run:e,read:n,onViewChanges:s}){var y,j,k,$,S,N,_,E,O,A,I;const[r,a]=p.useState({data:void 0,reading:!0}),[i,c]=p.useState(0),d=p.useRef(n);d.current=n;const u=!!n,f=e.run_id,x=(y=e.learning)==null?void 0:y.state,b=(j=e.learning)==null?void 0:j.at;p.useEffect(()=>{let M=!0;if(!u){a({data:void 0,reading:!1});return}return a(R=>({...R,error:void 0,reading:!0})),Promise.resolve().then(()=>d.current()).then(R=>{if(R&&R.run!==f)throw new Error("The learning result belongs to a different run. Refresh to try again.");M&&a({data:R,reading:!1})}).catch(R=>{M&&a(P=>({...P,error:R??new Error("The learning result could not be read."),reading:!1}))}),()=>{M=!1}},[f,x,b,u,i]),p.useEffect(()=>{const M=()=>{document.hidden||c(R=>R+1)};return window.addEventListener("focus",M),document.addEventListener("visibilitychange",M),()=>{window.removeEventListener("focus",M),document.removeEventListener("visibilitychange",M)}},[]);const g=r.data,h=()=>c(M=>M+1),v=(k=g==null?void 0:g.tokens)==null?void 0:k.grade;return t.jsxs("section",{className:"overflow-hidden border bg-card","aria-label":"Learning result",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-4",children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Learning result"}),g&&t.jsx(je,{children:HW[g.state]??g.state}),t.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[t.jsxs("a",{href:`#/agents/${encodeURIComponent(e.agent_id)}/learning`,className:"inline-flex items-center gap-1 text-small text-muted-foreground hover:text-primary-text",children:["Agent learning",t.jsx(cr,{className:"size-3","aria-hidden":!0})]}),u&&t.jsx(B,{size:"icon","aria-label":"Refresh learning result",disabled:r.reading,onClick:h,children:t.jsx(Yo,{"aria-hidden":!0})})]})]}),r.reading&&t.jsx("p",{className:"px-5 py-3 text-body text-muted-foreground",role:"status",children:g===void 0?"Reading learning result…":"Refreshing learning result…"}),r.error!==void 0&&t.jsxs("div",{className:"space-y-2 p-4",children:[g!==void 0&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Showing the last result read."}),t.jsx(Kt,{problem:Ft(r.error,"the learning result"),onRetry:h,className:""})]}),!u&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"Detailed learning results are unavailable in this view."}),u&&g===null&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"No learning result was recorded for this run."}),g&&t.jsxs("div",{className:"space-y-6 p-5",children:[t.jsxs("div",{children:[g.detail&&t.jsx("p",{className:"break-words text-body leading-relaxed",children:g.detail}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-label text-muted-foreground",children:[g.at&&t.jsxs("span",{children:["Updated ",mt(g.at)]}),g.reason&&t.jsxs("span",{children:["Reason: ",g.reason]})]})]}),t.jsxs("section",{"aria-label":"Grader decision",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"Grader decision"}),g.verdict?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-small text-muted-foreground",children:g.verdict.merge?($=g.verdict.items)!=null&&$.some(M=>!M.keep)?"Recommended keeping some changes.":"Recommended keeping these changes.":"Did not recommend keeping these changes."}),t.jsx("p",{className:"mt-2 break-words text-body leading-relaxed",children:g.verdict.reason}),(S=g.verdict.items)!=null&&S.length?t.jsx("ul",{className:"mt-3 divide-y border",children:g.verdict.items.map((M,R)=>t.jsxs("li",{className:"space-y-2 p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("code",{className:"min-w-0 break-all text-small",children:M.file}),t.jsx(je,{tone:M.pending?"warning":M.keep?"success":"muted",children:M.pending?"Needs approval":M.keep?"Keep":"Do not keep"})]}),t.jsx("p",{className:"break-words text-body leading-relaxed text-muted-foreground",children:M.why}),M.question&&t.jsx("p",{className:"text-small",children:M.question}),M.origin&&t.jsx("p",{className:"text-label text-muted-foreground",children:M.origin==="you"?"From your instruction":`Origin: ${M.origin}`})]},`${M.file}-${R}`))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"No item decisions reported."})]}):t.jsx("p",{className:"text-body text-muted-foreground",children:Lm(g)?"No grader decision recorded yet.":"No grader decision was recorded for this run."})]}),!!((N=g.pending)!=null&&N.length)&&t.jsxs("div",{className:"border border-warning/40 px-4 py-3 break-words text-small leading-relaxed",children:[t.jsx("p",{className:"font-semibold",children:"Held for approval in this result"}),t.jsxs("p",{className:"mt-1 text-muted-foreground",children:[g.pending.map(M=>M.name).join(", "),". These changes required approval when recorded. Check their current status in Agent learning."]})]}),t.jsxs("section",{"aria-label":"Learning validation",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"Validation"}),(_=g.problems)!=null&&_.length||(E=g.draft_errors)!=null&&E.length?t.jsxs("ul",{className:"space-y-3",children:[(O=g.problems)==null?void 0:O.map((M,R)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"text-body",children:M.detail}),t.jsx("p",{className:"mt-1 break-all font-mono text-label text-muted-foreground",children:[M.rule,M.path].filter(Boolean).join(" · ")})]},`problem-${R}`)),(A=g.draft_errors)==null?void 0:A.map((M,R)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"mb-1 font-mono text-label text-muted-foreground",children:"Workflow draft"}),t.jsx("p",{className:"break-words text-body",children:M})]},`draft-${R}`))]}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No validation problems reported."})]}),t.jsxs("section",{"aria-label":"Grading usage",children:[t.jsx("h3",{className:"mb-3 text-body font-semibold",children:"Grading usage"}),t.jsx("dl",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[["Grading cost",typeof((I=g.cost_usd)==null?void 0:I.grade)=="number"?Aa(g.cost_usd.grade):"Not reported"],["Input",Xu(v==null?void 0:v.input)],["Output",Xu(v==null?void 0:v.output)],["Cache reads",Xu(v==null?void 0:v.cache_read)],["Cache writes",Xu(v==null?void 0:v.cache_write)]].map(([M,R])=>t.jsxs("div",{className:"border p-3",children:[t.jsx("dt",{className:"mb-1 text-label text-muted-foreground",children:M}),t.jsx("dd",{className:"font-mono text-body",children:R})]},M))}),t.jsx("p",{className:"mt-3 text-label leading-relaxed text-muted-foreground",children:"Input excludes cache reads and writes. Reflection usage is included in the run's totals. These figures cover grading only."})]}),t.jsxs("section",{"aria-label":"Learning provenance",className:"border-t pt-4",children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h3",{className:"text-body font-semibold",children:"Provenance"}),s&&t.jsxs(B,{size:"sm",onClick:s,children:["View changes",t.jsx(cr,{"aria-hidden":!0})]})]}),t.jsxs("dl",{className:"space-y-3 text-small",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"mb-1 text-muted-foreground",children:"Seed commit"}),t.jsx("dd",{className:"break-all font-mono",children:g.seed??"Not reported"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"mb-1 text-muted-foreground",children:"Merge commit"}),t.jsx("dd",{className:"break-all font-mono",children:g.merged??"Not merged"})]})]})]})]})]})}const U0=32,GW=360,qW=.7;function KW(e,n){const s=e.getBoundingClientRect().top;if(!n)return window.innerHeight-(s+window.scrollY)-U0;const r=s-n.getBoundingClientRect().top+n.scrollTop;return n.clientHeight-r-U0}const VW=(e,n)=>Math.round(Math.max(GW,Math.min(e,n*qW)));function YW(e,n,s=3e3,r=Math.min(s,QW),a=!1){const[i,c]=p.useState(null),[d,u]=p.useState(!1),f=p.useRef(e);f.current=e;const x=p.useRef(!1),b=p.useRef(!1),g=p.useRef(0),h=p.useRef(null),v=p.useRef(null);p.useEffect(()=>{a&&(v.current=null)},[a]);const y=!!e;p.useEffect(()=>{if(!y||d)return;if(n||(v.current=null),!n&&x.current&&!b.current){c(E=>E&&W0(E));return}let k=!0,$;const S=E=>{clearTimeout($),$=setTimeout(()=>{h.current=null,_()},E),h.current=()=>S(r)};let N=!1;const _=async()=>{try{const E=await f.current();if(!k)return;x.current=!0,E.state==="live"&&(v.current=E.kind);const O=E.state==="none"&&E.session==="opening"&&E.kind!=="browser"&&E.kind===v.current?{...E,session:"closed"}:E;b.current=O.state==="none"&&O.session==="unopened",N=O.state==="none"&&O.session==="opening"||O.state==="live"&&O.hold==="pending",O.state==="off"?c(null):c(n?A=>XW(A,O)?A:O:W0(O))}catch(E){if(!k)return;if(E instanceof ze&&E.status===401){u(!0),c(O=>O?{state:"signed_out"}:null);return}if(E instanceof ze&&E.status===403){u(!0),c(null);return}}k&&n&&S(N||Date.now()<g.current?r:s)};return _(),()=>{k=!1,clearTimeout($),h.current=null}},[y,n,s,r,d]);const j=p.useCallback(k=>{var $;c(S=>S&&S.state==="live"&&S.hold!==k?{...S,hold:k}:S),g.current=Date.now()+JW,($=h.current)==null||$.call(h)},[]);return{view:i,held:j}}const QW=400,JW=4e3,XW=(e,n)=>{var s,r;return!!e&&e.state!=="signed_out"&&e.state===n.state&&e.kind===n.kind&&e.hold===n.hold&&(e.state!=="live"||n.state==="live"&&e.viewer===n.viewer)&&(e.state!=="none"||n.state==="none"&&e.session===n.session&&((s=e.ended)==null?void 0:s.at)===((r=n.ended)==null?void 0:r.at))},W0=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"},ZW={browser:yN,desktop:qa,phone:kN,sandbox:$T},e9={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},t9={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function n9({runId:e,screen:n,machine:s,opens:r,followUp:a,metered:i,waitsFor:c,keptUntil:d,onTake:u,onHand:f}){const x=p.useRef({viewer:"",n:0});(n==null?void 0:n.state)==="live"&&n.viewer!==x.current.viewer&&(x.current={viewer:n.viewer,n:x.current.n+1});const b=n&&n.state!=="signed_out"?n.kind:(s==null?void 0:s.kind)??"browser",g=(n==null?void 0:n.state)==="live"?i9(n.viewer,e):void 0,h=g&&b!=="browser"?`${g}${g.includes("#")?"&":"#"}hands=page`:g,v=ZW[b],y=(n==null?void 0:n.state)==="live"?n:null,[j,k]=p.useState(!1),[$,S]=p.useState(null),N=async F=>{if(!(!F||j)){k(!0),S(null);try{S(await F())}finally{k(!1)}}},_=y&&h&&b!=="browser"?y:null,[E,O]=p.useState(!1),A=p.useRef(null),I=p.useRef(null),M=p.useRef(null),R=p.useRef(!1),P=!!(y&&h);p.useEffect(()=>{P||O(!1)},[P]);const[D,W]=p.useState(void 0);p.useLayoutEffect(()=>{const F=A.current;if(b!=="phone"||E||!P||!F)return;const G=F.closest("[data-scroll-pane]"),U=()=>W(VW(KW(F,G),window.innerHeight));U();const z=typeof ResizeObserver=="function"&&G?new ResizeObserver(U):void 0;if(G)for(const Q of[G,...G.children])z==null||z.observe(Q);return window.addEventListener("resize",U),()=>{z==null||z.disconnect(),window.removeEventListener("resize",U)}},[b,E,P,$,i,x.current.n]),p.useEffect(()=>{var F,G,U;if(E){R.current=!0,(G=(F=I.current)==null?void 0:F.querySelector("button"))==null||G.focus();return}R.current&&(R.current=!1,(U=M.current)==null||U.focus())},[E]),p.useEffect(()=>{if(!E)return;const F=K=>{if(K.key==="Escape"){O(!1);return}if(K.key!=="Tab"||!I.current)return;const Z=[...I.current.querySelectorAll("button:not([disabled]), iframe")];if(!Z.length)return;const de=Z[0],re=Z[Z.length-1],fe=document.activeElement;I.current.contains(fe)?K.shiftKey&&fe===de?(K.preventDefault(),re.focus()):!K.shiftKey&&fe===re&&(K.preventDefault(),de.focus()):(K.preventDefault(),de.focus())},G=K=>{K.key==="Escape"&&O(!1)};document.addEventListener("keydown",F);const U=A.current;let z=null;const Q=()=>{try{z==null||z.removeEventListener("keydown",G,!0)}catch{}try{z=(U==null?void 0:U.contentWindow)??null,z==null||z.addEventListener("keydown",G,!0)}catch{z=null}};return Q(),U==null||U.addEventListener("load",Q),()=>{document.removeEventListener("keydown",F),U==null||U.removeEventListener("load",Q);try{z==null||z.removeEventListener("keydown",G,!0)}catch{}}},[E,x.current.n]);const Y=y?b==="browser"?"browser · take over in the view below":`${t9[y.hold]} · ${b}`:"",H=_&&(_.hold==="person"?t.jsx(B,{size:"sm",variant:"solid",disabled:j,onClick:()=>void N(f),children:"Hand back"}):t.jsx(B,{size:"sm",variant:"solid",disabled:j||_.hold==="pending",onClick:()=>void N(u),children:_.hold==="pending"?"Taking over":"Take over"})),q=P&&t.jsx(B,{ref:E?void 0:M,size:"sm",variant:"ghost",onClick:()=>O(F=>!F),"aria-label":E?"Exit full window (Esc)":"Fill the window",title:E?"Exit full window (Esc)":"Fill the window","aria-pressed":E,children:E?t.jsx(vT,{className:"size-4","aria-hidden":!0}):t.jsx(pT,{className:"size-4","aria-hidden":!0})});return t.jsxs("section",{"aria-label":"Screen",className:"border",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2.5",children:[t.jsx(v,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:y?"Live":e9[b]}),t.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:Y}),!E&&q,!E&&H]}),i&&b!=="browser"&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:Vv}),!E&&$&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:$}),y&&h?t.jsxs("div",{ref:I,"data-testid":"screen-frame",className:E?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:E?"dialog":void 0,"aria-modal":E?!0:void 0,"aria-label":E?"The run's screen, filling the window":void 0,children:[E&&t.jsxs("div",{className:"flex items-center gap-3 border-b bg-background px-4 py-2 text-foreground",children:[t.jsx("span",{className:"flex-1 font-mono text-small",children:Y}),q,H]}),E&&$&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:$}),t.jsx("iframe",{ref:A,src:h,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:E?"block min-h-0 w-full flex-1 bg-background":b==="phone"?ae("mx-auto block aspect-[9/19] max-w-full bg-background",D===void 0&&"h-[70vh]"):"block aspect-[16/10] w-full bg-background",style:!E&&b==="phone"&&D!==void 0?{height:`${D}px`}:void 0},x.current.n)]}):t.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:a9(b,n,s,r,a,c,d)})]})}const s9={approval:"Waiting for your approval.",question:"Waiting for your answer.",budget:"Waiting for you to raise the spend cap.",browser:"Waiting for you.",computer:"Waiting for you."},r9=/^The (desktop|phone) is kept for (\d+) minutes while you decide\.$/;function o9(e,n){for(let s=e.length-1;s>=0;s-=1){const r=e[s];if(r.kind!=="phase")continue;const a=r.summary??r.text??"";if(a.startsWith(`The ${n} is ready`))return;const i=r9.exec(a);if(!i||i[1]!==n)continue;const c=Date.parse(r.timestamp);return Number.isNaN(c)?void 0:new Date(c+Number(i[2])*6e4).toISOString()}}function a9(e,n,s,r,a,i,c){if((n==null?void 0:n.state)==="live")return"The live view can't be shown here.";if((n==null?void 0:n.state)==="signed_out")return"Signed out: sign in to watch.";if(e==="sandbox")return"A sandbox has no screen. What the agent runs in it is on the timeline.";if((s==null?void 0:s.state)==="failed")return`The ${e} didn't start.${s.why?` ${s.why}`:""}`;if(r&&i&&c&&(n==null?void 0:n.state)==="none"&&n.session==="closed"&&!n.ended)return`${s9[i]} The ${e} is kept until ${H0(c).replace(/^at /,"")}.`;if(r&&(n==null?void 0:n.state)==="none"&&n.ended)return e==="browser"?`${n.ended.why} (${H0(n.ended.at)}). A new browser opens when the run goes on.`:n.ended.why;const d=(n==null?void 0:n.state)==="none"?n.session:void 0;return d==="unopened"?r?e==="browser"?"This run hasn't opened its browser. The agent's page shows here if it opens one.":`This run hasn't opened its ${e}. Its screen shows here if the agent opens one.`:`This run didn't open its ${e}.${a?" A follow-up opens one if the agent needs it.":""}`:r&&d==="closed"?e==="browser"?"The run's browser isn't open now. The agent's page shows here if it opens one again.":`This ${e} has been released.`:r?e==="browser"?"Waiting for the browser. The agent's page shows here once it opens one.":`Waiting for the ${e}. Its screen shows here once it is up.`:`The ${e} closed when the run ended.${a?" A follow-up opens a new one if the agent needs it.":""}`}function H0(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:`at ${n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function i9(e,n){let s;try{s=new URL(e,location.origin).href}catch{return}const r=no(s);if(!r)return;const a=new URL(r);return a.origin===location.origin&&a.pathname.startsWith(`/v2/runs/${encodeURIComponent(n)}/computer/live/`)?r:void 0}const Di=e=>{var n,s;return e.status==="input_required"&&(((n=e.pending)==null?void 0:n.kind)==="browser"||((s=e.pending)==null?void 0:s.kind)==="computer")?e.pending:null},DE=e=>e.kind==="computer"?e.computer:"browser";function yx(e,n){var s;if(e instanceof ze&&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 ze&&e.code==="computer_not_live"?e.message:e instanceof ze&&e.status===404?n==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof ze&&e.status===403?"Sign in with your password to do this from here.":`${n==="hand"?"Not answered":"Not taken"}: ${Dt(e)}`}function FE({ask:e,onAnswer:n,open:s,heading:r,compact:a=!1}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),f=p.useRef(!1),x=async b=>{if(!n||f.current)return;f.current=!0,c(!0),u(null);let g=!1;try{const h=await n(b);g=h===null,u(h)}finally{g||(f.current=!1,c(!1))}};return t.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,t.jsxs("p",{className:ae("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-1"),children:[t.jsx(qa,{className:"size-3.5","aria-hidden":!0})," Waiting for you · ",DE(e)]}),t.jsxs("div",{"data-agent-request":!0,className:ae("border-l-2 border-warning/60 pl-3",a?"mt-1":"mt-2"),children:[t.jsxs("p",{className:a?"text-prose leading-snug":"text-prose leading-relaxed",children:["The agent asks you to: ",e.instruction]}),t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["Done when: ",e.completion_condition]})]}),t.jsx("p",{className:"mt-2 text-small font-semibold",children:"You never need to type your AgentRun password for this."}),t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:["Expires ",mt(e.expires_at)," unanswered"]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s,t.jsx("span",{className:"flex-1"}),n&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"solid",disabled:i,onClick:()=>void x("done"),children:"Done"}),t.jsx(B,{size:"sm",variant:"ghost",disabled:i,onClick:()=>void x("cancelled"),children:"Cancel"})]})]}),d&&t.jsx("p",{className:"mt-2 text-small text-warning-text",role:"alert",children:d})]})}function l9(e,n){const s=!!n&&Fc(e.learning).length>0,[r,a]=p.useState({state:"reading"}),[i,c]=p.useState(0);return p.useEffect(()=>{if(!s)return;let d=!0;return a({state:"reading"}),Promise.resolve().then(()=>n()).then(u=>{d&&a({state:"read",changes:Dz(u,e.learning)})},u=>{d&&a({state:"failed",error:u??new Error("unknown")})}),()=>{d=!1}},[e.run_id,s,i]),s?{got:r,retry:()=>c(d=>d+1)}:null}function c9({got:e,retry:n}){if(e.state==="read"&&!e.changes.length)return null;const s=e.state==="failed"?Ft(e.error,"what it changed"):null;return t.jsxs("section",{className:"border","aria-label":"What it changed",children:[t.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"What it changed"}),e.state==="reading"&&t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:"Reading what it changed…"}),s&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 text-body",role:"alert",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't read what it changed: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)]}),t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})]}),e.state==="read"&&t.jsx("ul",{className:"divide-y",children:e.changes.map(r=>t.jsx("li",{children:t.jsx(d9,{change:r})},r.file))})]})}function d9({change:e}){const[n,s]=p.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 px-4 py-3 text-left hover:bg-accent/40","aria-expanded":n,onClick:()=>s(r=>!r),children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block break-words text-lead","data-said":!0,children:e.said}),t.jsx("span",{className:"mt-0.5 block break-all font-mono text-label text-muted-foreground",children:e.file})]}),t.jsx(Cs,{className:ae("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",n&&"rotate-90"),"aria-hidden":!0})]}),n&&(e.withheld?t.jsx("p",{className:"px-4 pb-3 text-body text-muted-foreground",children:e.withheld}):t.jsxs("div",{className:"grid grid-cols-1 gap-3 px-4 pb-4 md:grid-cols-2",children:[t.jsx(B0,{name:"before",lines:e.before,none:"Not there before."}),t.jsx(B0,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function B0({name:e,lines:n,none:s}){return t.jsxs("div",{className:"min-w-0 border","data-side":e,children:[t.jsx("p",{className:"caps border-b px-3 py-2 text-label text-muted-foreground",children:e==="before"?"Before":"After"}),n===null?t.jsx("p",{className:"px-3 py-2 text-body text-muted-foreground",children:s}):t.jsx("pre",{className:"max-h-80 overflow-auto py-2 font-mono text-small leading-[1.7]",children:n.map((r,a)=>t.jsxs("span",{className:ae("flex min-h-[1.7em] px-3",r.mark==="added"&&"bg-primary/10",r.mark==="removed"&&"bg-destructive/10"),children:[t.jsx("span",{"aria-hidden":!0,className:"w-4 shrink-0 select-none text-muted-foreground",children:r.mark==="added"?"+":r.mark==="removed"?"−":""}),r.mark==="added"&&t.jsx("span",{className:"sr-only",children:"Added line: "}),r.mark==="removed"&&t.jsx("span",{className:"sr-only",children:"Taken out: "}),t.jsx("span",{"data-mark":r.mark,className:ae("min-w-0 whitespace-pre-wrap break-words",r.mark==="gap"&&"text-muted-foreground"),children:r.text})]},a))})]})}const u9=4e3,f9=e=>!!e.learning&&e.learning.reason!=="use",m9="The agent looks back on your words: what was wrong, and what a right answer does.",h9="A look-back needs words. Without them the grade is still kept.",p9='A JSON object of the fields a right answer holds, like {"total": 42}. Replays of a learned workflow are scored against it.',G0='Write it as a JSON object, like {"total": 42}, or leave it empty.';function g9(e){if(!e.trim())return{};try{const n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{value:n}:{error:G0}}catch{return{error:G0}}}function x9(e){const n=Ft(e,"the grade");return e instanceof ze&&e.status<500&&n.said?n.said:`${n.why} ${n.next}`}const v9="The review could not run.";function y9(e,n,s){var r;if(e.feedback&&e.feedback_status==="not_run")return v9;if(e.feedback==="look_back")return n?"The agent is looking back on your words.":"The agent looked back on your words.";if(e.feedback==="revise"){if(n)return"The learned workflow that answered is being revised with your grade.";const a=(s==null?void 0:s.state)==="merged"?(r=s.workflows)==null?void 0:r.find(i=>!e.workflow||i.name===e.workflow):void 0;return a?a.pending?"The learned workflow that answered was revised with your grade. The revision waits for your OK.":"The learned workflow that answered was revised with your grade.":"The agent looked back at your grade; nothing changed."}return"Kept for this agent."}function b9({run:e,graded:n,onGrade:s,onOpenTimeline:r}){const[a,i]=p.useState("auto"),[c,d]=p.useState(""),[u,f]=p.useState(""),[x,b]=p.useState(!1),[g,h]=p.useState(!1),[v,y]=p.useState(null),j=p.useRef(!1),k=Ua(e.status),$=n!=null&&n.feedback?n.feedback_status:null,S=$==="running"||$==="ended"&&Lm(e.learning??void 0);if(!f9(e)||!k&&!n)return null;const N=a==="auto"?n?"closed":"choose":a,_=k&&!S,E=g9(u),O=n?y9(n,S,e.learning):null,A=async I=>{if(j.current||!s)return;const M=I?"":c.trim();if(!I&&E.error){b(!0);return}j.current=!0,h(!0),y(null);try{await s({correct:I,...M?{label:M}:{},...!I&&E.value?{expected:E.value}:{}}),i("auto"),d(""),f(""),b(!1)}catch(R){y(x9(R))}j.current=!1,h(!1)};return t.jsxs("section",{className:"border","aria-label":"Grade",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Grade"}),n&&t.jsxs(je,{tone:n.correct?"success":"error",children:["Graded ",n.correct?"right":"wrong"]}),S&&t.jsx(je,{tone:"active",children:"Reviewing"}),t.jsx("span",{className:"flex-1"}),n&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:mt(n.graded_at)})]}),t.jsxs("div",{className:"space-y-3 px-4 py-3",children:[O&&t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[t.jsx("p",{className:"text-body",role:"status",children:O}),r&&!!(n!=null&&n.feedback)&&t.jsx(B,{type:"button",size:"xs",variant:"ghost",onClick:r,children:"Open the Timeline"})]}),_&&N==="closed"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:!s,onClick:()=>{i("choose"),y(null)},children:"Grade again"}),t.jsx("span",{className:"text-small text-muted-foreground",children:"A new grade replaces this one."})]}),_&&N==="choose"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"Was the answer right? Your grade teaches the agent."}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:g||!s,onClick:()=>void A(!0),children:"Right"}),t.jsx(B,{type:"button",size:"sm",disabled:g||!s,onClick:()=>{i("wrong"),y(null)},children:"Wrong"}),n&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",disabled:g,onClick:()=>i("closed"),children:"Cancel"}),g&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),_&&N==="wrong"&&t.jsxs("form",{className:"space-y-4","aria-label":"Grade wrong",onSubmit:I=>{I.preventDefault(),A(!1)},children:[t.jsx(jt,{label:"What was wrong?",note:m9,warning:c.trim()?void 0:h9,children:t.jsx(ln,{value:c,onChange:I=>d(I.target.value),maxLength:u9,rows:3,disabled:g,className:"resize-y font-sans text-lead"})}),t.jsx(jt,{label:"Correct answer",optional:!0,note:p9,error:x?E.error:void 0,children:t.jsx(ln,{value:u,onChange:I=>{f(I.target.value),b(!1)},rows:2,disabled:g,spellCheck:!1,placeholder:'{"total": 42}',className:"resize-y"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:g,children:"Send grade"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",disabled:g,onClick:()=>{i(n?"closed":"choose"),b(!1)},children:"Cancel"}),g&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),v&&t.jsxs("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:["Your grade wasn't taken: ",v]})]})]})}const w9=(e,n)=>n&&(!e||Date.parse(n.graded_at)>Date.parse(e.graded_at))?n:e;function j9(e,n,s){const r=!!s&&!!e.learning,[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[x,b]=p.useState(0);p.useEffect(()=>{if(!r)return;let j=!0;return Promise.resolve().then(()=>s()).then(k=>{j&&(i(k??null),f(0))},()=>{j&&(i(null),f(k=>k+1))}),()=>{j=!1}},[e.run_id,r,n,e.ended_at,x]);const g=p.useCallback(({expected:j,...k})=>{d({run:k.run_id,grade:{...k,feedback_status:k.feedback?"running":null}})},[]),h=r?a:null,v=w9((h==null?void 0:h.graded)??null,(c==null?void 0:c.run)===e.run_id?c.grade:null),y=r&&(v==null?void 0:v.feedback_status)==="running";return p.useEffect(()=>{if(!y||u===0||u>k9)return;const j=setTimeout(()=>b(k=>k+1),Hg(u-1));return()=>clearTimeout(j)},[y,u]),{read:h,grade:v,graded:g}}const k9=8,N9=e=>e===1?"once":e===2?"twice":`${e} times`;function S9({used:e,agentId:n}){return!e||!e.skills.length&&!e.workflows.length?null:t.jsxs("section",{className:"border","aria-label":"What it used of what it learned",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-4 py-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"What it used of what it learned"}),t.jsx("span",{className:"flex-1"}),t.jsx("a",{href:Im(n),className:"font-mono text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:"Open the Learning tab"})]}),t.jsxs("ul",{className:"divide-y",children:[e.skills.map(s=>t.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[t.jsx(ff,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Skill"}),t.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:s.name}),s.read?t.jsx(je,{tone:"success",children:"Read"}):t.jsx(je,{tone:"muted",children:"Given, not read"})]},`skill:${s.name}`)),e.workflows.map(s=>t.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[t.jsx(Ka,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Workflow"}),t.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:s.name}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Called ",N9(s.calls)]}),s.failed>0&&t.jsxs(je,{tone:"error",children:[s.failed," failed"]})]},`workflow:${s.name}`))]})]})}const Oi=(e,n={})=>({type:"object",properties:{op:{const:e,description:`Action operation. Use "op": "${e}"; never use a "kind" field.`},id:{type:"string",description:'Bracketed ID copied from the latest snapshot, as a string. Use "id"; never use "ref".'},...n},required:["op","id",...Object.keys(n).filter(s=>s!=="delay")],additionalProperties:!1}),_r=(e,n=[])=>({type:"object",additionalProperties:!1,properties:e,...n.length?{required:n}:{}}),C9={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:_r({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},E9=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."}),$9=e=>`Browse and automate websites in the persistent browser. ${E9.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"}]}.`,_9={name:"run",label:"Browser: run",description:$9(),parameters:_r({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},Oi("click"),Oi("hover"),Oi("fill",{value:{type:"string"}}),Oi("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),Oi("press",{key:{type:"string"}}),Oi("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},T9={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:_r({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:{..._r({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"},R9={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:_r({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},A9={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:_r({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},O9={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:_r({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"},M9={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:_r({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"},P9={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:_r({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},L9={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:_r({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"},I9=Object.freeze([C9,_9,T9,R9,A9,O9,M9,P9,L9]),z9=Object.freeze(I9.map(e=>e.name)),D9={"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 F9(e){const n=e.split(".").at(-1)||e;return D9[e]??(n?n[0].toUpperCase()+n.slice(1):e)}const U9=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"]),W9=new Set(["ctrl","alt","super"]);function H9(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=>W9.has(r))||s.every(r=>U9.has(r))?e:void 0}const B9=["press","set","perform","click","type","key","nav","scroll","drag"];function G9(e,n){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=B9.find(u=>u in s)??"step",a=r==="type"?s.into:s[r],i=typeof a=="string"?n(a):void 0,c=r==="key"?H9(s.key):void 0,d=r==="nav"&&typeof s.nav=="string"?s.nav:void 0;return{do:r,...i?{on:i}:{},...c?{keys:c}:{},...d?{nav:d}:{}}}const q9={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"},K9=new Set(["button","link","menuitem","tab","listitem","row","cell","radio","generic","text","heading"]);function V9(e){if(!e)return;const n=q9[e.role]??(e.role==="generic"?"element":e.role);return e.name?K9.has(e.role)?`“${e.name}”`:`the ${n} “${e.name}”`:`the ${n}`}const Y9={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"]},Q9={super:"⌘",shift:"⇧",alt:"⌥",ctrl:"⌃"},xg={enter:"Return",escape:"Esc",tab:"Tab",space:"Space",backspace:"Delete",delete:"Forward Delete",up:"↑",down:"↓",left:"←",right:"→"},mn=(e,n,s="")=>({did:`${e}${s}`,tried:`${n}${s}`});function J9(e){const n=e.endsWith("++")?[...e.slice(0,-2).split("+"),"+"]:e.split("+"),s=n.at(-1)??"",r=n.slice(0,-1).map(c=>c.toLowerCase()),a=n.length===1&&xg[s.toLowerCase()]?xg[s.toLowerCase()]:`${r.map(c=>Q9[c]??`${c}+`).join("")}${xg[s.toLowerCase()]??(s.length===1?s.toUpperCase():s)}`,i=r.length===1&&r[0]==="super"?Y9[s.toLowerCase()]:void 0;return i?mn(i[0],i[1],` (${a})`):mn("Pressed","press",` ${a}`)}const X9={back:["Went","go"," back"],home:["Went","go"," home"],app_switch:["Opened","open"," the recent apps"]};function Z9(e){const n=V9(e.on),s=r=>` ${n??r}`;switch(e.do){case"press":return mn("Pressed","press",s("an element"));case"click":return mn("Clicked","click",n?` ${n}`:" at a point");case"set":return mn("Set","set",s("an element"));case"perform":return mn("Acted on","act on",s("an element"));case"type":return n?mn("Typed into","type into",` ${n}`):mn("Typed text","type text");case"key":return e.keys?J9(e.keys):mn("Pressed a key","press a key");case"nav":{const[r,a,i]=e.nav&&X9[e.nav]||["Navigated","navigate",""];return mn(r,a,i)}case"scroll":return n?mn("Scrolled","scroll",` ${n}`):mn("Scrolled","scroll");case"drag":return mn("Dragged","drag"," across the screen");default:return mn("Acted","act")}}function q0(e){const n=Z9(e);return e.error===void 0?n.did:`Could not ${n.tried}`}const K0=3,bx=e=>e[0].toLowerCase()+e.slice(1);function eH(e){const n=e.slice(0,K0).map(q0),s=e.slice(K0),r=s.findIndex(i=>i.error!==void 0),a=r<0?s.length:s.length-1;return[n[0],...n.slice(1).map(bx),...a>0?[`+${a} more`]:[],...r<0?[]:[bx(q0(s[r]))]].join(", ")}const tH={"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 Cr(e){const n=e.app?F9(e.app):void 0,s=(()=>{var r;switch(e.method){case"apps.launch":return mn("Opened","open",` ${n??"an app"}`);case"apps.terminate":return mn("Quit","quit",` ${n??"an app"}`);case"ui.observe":return mn("Looked at","look at",` ${n??"the window"}`);case"ui.act":return e.ok&&((r=e.steps)!=null&&r.length)?{did:eH(e.steps),tried:""}:e.ok?mn("Waited for","wait for",` ${n??"the window"}${e.expect==="unmet"?" (not seen)":""}`):mn("Acted on","act on",` ${n??"the computer"}`);default:{const[a,i]=tH[e.method]??[e.method,e.method];return mn(a,i)}}})();return e.ok?s.did:`Could not ${s.tried}`}const nH=e=>e.map((n,s)=>s===0?Cr(n):bx(Cr(n))).join(", "),UE='\\s"`<>\\\\',sH=new RegExp(`https?://[^${UE}|]+`,"gi"),rH=new RegExp(`https?://[^${UE}]+`,"gi"),oH=".,;:!?*)]}'",aH={")":"(","]":"[","}":"{"};function iH(e){const n={"(":0,")":0,"[":0,"]":0,"{":0,"}":0};for(const r of e)r in n&&(n[r]+=1);let s=e.length;for(;s>0&&oH.includes(e[s-1]);s--){const r=e[s-1],a=aH[r];if(a&&n[a]>=n[r])break;a&&(n[r]-=1)}return e.slice(0,s)}new RegExp(`\\]\\(|${sH.source}`,"gi");const qo=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,an=e=>typeof e=="string"?e:void 0,Ha=(e,n)=>e.length>n?`${e.slice(0,n-3)}...`:e,WE=e=>e.split(`
|
|
698
|
+
`).map(n=>n.trim()).find(Boolean)??"";function Qf(e){try{return qo(JSON.parse(e))}catch{return}}const lH=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function Bc(e){const n=lH.exec(e.trim());return Ha(n?`${n[1]}${n[2]==="/"?"":n[2]}`:e.split(/[?#]/)[0]??"",80)}const cH="…",dH=/https?:\/\//gi,uH=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i,fH=/(https?:\/\/)[^@/?#\s]*@/gi,mH=/[A-Za-z0-9]/;function py(e){return e.replace(rH,n=>{const s=[0];let[r,a]=[0,!1];for(const i of n.matchAll(dH)){if(i.index===0)continue;for(;r<i.index;r++)a||(a=n[r]==="?"||n[r]==="#");if(a)continue;let c=!1;for(let d=i.index-1;d>s.at(-1)&&!mH.test(n[d]);d--)c||(c=n[d]==="'");c&&s.push(i.index)}return s.map((i,c)=>hH(n.slice(i,s[c+1]??n.length))).join("")})}function hH(e){const n=iH(e).length,s=uH.exec(e.slice(0,n));if(!s)return e;const r=i=>i.replace(fH,"$1"),a=[...new Set((s[4]??"").split("&").map(i=>r(i.split("=")[0])).filter(Boolean))];return`${s[1]}${r(`${s[2]}${s[3]}`)}${a.length?`?${a.map(i=>`${i}=${cH}`).join("&")}`:""}${e.slice(n)}`}const pH=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),gH=new Map,xH=new Map,HE=new Map,vH=new Set;function cn(e,n,s,{name:r,saysFailure:a}={}){gH.set(e,n),s&&xH.set(e,s),r&&HE.set(e,r),a&&vH.add(e)}const yH=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,bH=/^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/,wH=e=>{const n=bH.exec(e)??yH.exec(e);return n&&n[1]!=="hands"?`${n[1]} · ${n[2]}`:void 0},jH=e=>HE.get(e)??wH(e)??e,kH=new Map;function gy(e,n){kH.set(e,n)}const NH=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...NH];const xy=e=>an(e.path)??an(e.file_path),SH=/page\.goto\(\s*["'`]([^"'`]+)/;cn("read",e=>`Read ${xy(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});cn("write",e=>`Wrote ${xy(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});cn("edit",e=>`Edited ${xy(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});cn("bash",e=>`Ran \`${Ha(py(WE(an(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const BE=e=>{const n=e&&qo(Qf(e.text)??Qf(WE(e.text)));if((n==null?void 0:n.ok)!==!1)return;const s=an(n.refused);return s!==void 0?{refused:!0,detail:s.replace(/^refused:\s*/,"")}:{refused:!1,detail:an(n.error)??an(n.message)??"no detail"}},CH=(e,n)=>`${BE(n)?"Tried to fetch":"Fetched"} ${Bc(an(e.url)??"a page")}`,EH={many:e=>`Fetched ${e} pages`,subject:e=>e?Bc(e):void 0},$H=e=>{const n=BE(e);return n&&{failed:!0,text:`${n.refused?"refused":"failed"}: ${n.detail}`}};cn("web_fetch",CH,EH,{name:"Fetch web pages"});gy("web_fetch",$H);cn("web_search",e=>{const n=an(e.query);return n?`Searched the web for "${Ha(py(n),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${Ha(e,40)}"`:void 0},{name:"Search the web"});gy("web_search",e=>{var s;const n=an((s=qo(Qf(e.text)))==null?void 0:s.error);return n!==void 0?{failed:!0,text:`failed: ${n}`}:void 0});cn("browser_read",(e,n)=>{var r;const s=n&&((r=/^title: (.+)$/m.exec(n.text))==null?void 0:r[1]);return s?`Read the page "${Ha(py(s),60)}"`:"Read the page"},{many:e=>`Read ${e} pages`,subject:(e,n)=>{var r;const s=n&&((r=/^url: (\S+)/m.exec(n))==null?void 0:r[1]);return s?Bc(s):void 0}},{name:"Read the browser's page"});cn("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});cn("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});cn("run",(e,n)=>{var i,c;const s=(i=SH.exec(an(e.code)??""))==null?void 0:i[1];if(s)return`Opened ${Bc(s)}`;const r=(c=qo(n==null?void 0:n.details))==null?void 0:c.sent,a=Array.isArray(r)?r.flatMap(d=>{const u=qo(d),[f,x]=[an(u==null?void 0:u.method),an(u==null?void 0:u.url)];return f&&x?`${f} ${Bc(x)}`:[]}):[];return a.length?`Acted on the page (${a.length} request${a.length===1?"":"s"} sent: ${pH(a)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});cn("browser_downloads",(e,n)=>{var a;const s=n&&((a=Qf(n.text))==null?void 0:a.fetched),r=Array.isArray(s)?s.flatMap(i=>{var c;return an((c=qo(i))==null?void 0:c.name)??[]}):[];return r.length===1?`Downloaded ${r[0]}`:r.length?`Downloaded ${r.length} files`:"Downloaded files"},{many:e=>`Downloaded files ${e} times`},{name:"Download files in the browser"});cn("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});cn("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});cn("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});cn("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});cn("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const _H=/^(\d+)\. [a-z_.]+(?: into)?(?: @\S+ ([a-z]+)(?: ("(?:[^"\\]|\\.)*"))?)?(?: \[secure\])?: (.*)$/,TH=e=>{if(e!==void 0)try{return an(JSON.parse(e))}catch{return}};function GE(e){var s;const n=new Map;for(const r of(e??"").split(`
|
|
699
|
+
`)){const a=_H.exec(r);if(!a)continue;const i=TH(a[3]),c=(s=/^refused \([^)]*\): (.*)$/.exec(a[4]))==null?void 0:s[1],d=a[2]===void 0?void 0:{role:a[2],...i?{name:i}:{}};n.set(Number(a[1]),{...d?{on:d}:{},...c!==void 0?{refused:c}:{}})}return n}function RH(e,n){return{...G9(e,()=>n==null?void 0:n.on),...(n==null?void 0:n.refused)!==void 0?{error:"refused"}:{}}}cn("computer_act",(e,n)=>{var d;const s=Array.isArray(e.steps)?e.steps.flatMap(u=>{const f=qo(u);return f?[f]:[]}):[],r={method:"ui.act",started_at:"",ms:0,...an(e.app)?{app:an(e.app)}:{}};if(n!=null&&n.isError)return Cr({...r,ok:!1});const a=n===void 0?void 0:GE(n.text),i=a===void 0?s:s.filter((u,f)=>a.has(f+1));if(s.length>0&&i.length===0)return Cr({...r,ok:!1});const c=n&&((d=/^expect: (met|unmet)$/m.exec(n.text))==null?void 0:d[1]);return Cr({...r,ok:!0,steps:i.map((u,f)=>RH(u,a==null?void 0:a.get(f+1))),...c==="met"||c==="unmet"?{expect:c}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Act on the computer",saysFailure:!0});gy("computer_act",e=>{for(const[n,s]of GE(e.text))if(s.refused!==void 0)return{failed:!0,text:`step ${n} refused: ${s.refused}`}});const V0=/^state \S+ · (\S+)/,AH=/^screen \S+ px · (?:\S+ in front|no app in front)/;cn("computer_observe",(e,n)=>{var r;if(n&&!n.isError&&!V0.test(n.text)){const a=AH.test(n.text),i=(d,u)=>({method:d,started_at:"",ms:0,ok:!0,...u?{app:u}:{}}),c=a?an(e.app):void 0;return nH([...c?[i("apps.launch",c)]:[],i("screen.shot"),...a?[i("apps.list")]:[]])}const s=an(e.app)??(n&&((r=V0.exec(n.text))==null?void 0:r[1]));return Cr({method:"ui.observe",ok:(n==null?void 0:n.isError)!==!0,...s?{app:s}:{}})},{many:e=>`Looked at the screen ${e} times`},{name:"Look at the computer",saysFailure:!0});cn("computer_screenshot",(e,n)=>Cr({method:"screen.shot",ok:(n==null?void 0:n.isError)!==!0}),{many:e=>`Took ${e} screenshots`},{name:"Take screenshots of the computer",saysFailure:!0});const Y0={"input.act":"input.actions","apps.list":"apps.list","apps.open":"apps.launch","shell.run":"exec.run","processes.start":"process.start","files.read":"files.read","files.write":"files.write","files.list":"files.list","files.stat":"files.stat"};cn("computer_op",(e,n)=>{var i;const s=an(e.op),r=s!==void 0&&Object.hasOwn(Y0,s)?Y0[s]:void 0;if(!r)return n!=null&&n.isError?"Could not act on the computer":"Acted on the computer";const a=r==="apps.launch"?an((i=qo(e.args))==null?void 0:i.id):void 0;return Cr({method:r,ok:(n==null?void 0:n.isError)!==!0,...a?{app:a}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Use the computer's apps, shell and files",saysFailure:!0});cn("computer_script",(e,n)=>{var r;const s=(r=an(e.title))==null?void 0:r.replace(/\s+/g," ").trim();return n!=null&&n.isError?s?`Could not run the script “${Ha(s,120)}”`:"Could not run a script on the computer":s?Ha(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 OH=["schedule","webhook","slack","github","composio","email"];new Set(OH);const MH=":feedback",PH=e=>{var n;return e.kind==="user_message"&&((n=e.id)==null?void 0:n.endsWith(MH))===!0},LH={user_message:Ix,thinking:mf,tool_use:hf,tool_result:hf,waiting:Ox,usage:_x,final_answer:Ga,phase:vN,error:Ji,decision:NT,text_block:xT,tool_approval_requested:jN},Q0=e=>{var n;return e.kind==="tool_approval_requested"?(n=/\n\n(Not sent: [\s\S]*)$/.exec(e.text??""))==null?void 0:n[1]:void 0},J0=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),vy=e=>e.origin==="server",qE=e=>e.origin==="trigger",KE=e=>{var i;const n=e.summary??"",s=(i=e.trigger)==null?void 0:i.name,r=s?n.indexOf(` ${s}: `):-1;if(s&&r>0&&!n.slice(0,r).includes(" "))return{who:n.slice(0,r+1+s.length),said:n.slice(r+s.length+3).trimStart()};const a=/^([^:]+):\s*/.exec(n);return a?{who:a[1],said:n.slice(a[0].length)}:{who:null,said:n}};function VE(e){const n=e.split(/(\*\*[^*\n]+?\*\*|`[^`\n]+`)/);return n.length===1?e:n.map((s,r)=>r%2===0?s:s.startsWith("`")?t.jsx("code",{className:"font-mono",children:s.slice(1,-1)},r):t.jsx("strong",{className:"font-semibold",children:VE(s.slice(2,-2))},r))}const IH=e=>{var r;const n=qE(e)?KE(e).said:(e.summary??"").replace(vy(e)?/^AgentRun:\s*/:/^(You|Thinking|Asked you|Waiting for you):\s*/,"");if(e.kind==="user_message"&&n.startsWith("{"))try{return Object.entries(JSON.parse(n)).map(([a,i])=>`${a}: ${typeof i=="string"?i:JSON.stringify(i)}`).join(" · ")}catch{}const s=(e.text??"").split(`
|
|
700
|
+
`).filter(a=>a.trim()).length>1?"…":"";return e.kind==="final_answer"?!n.trim()&&!((r=e.text)!=null&&r.trim())?o2:`${n.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${s}`:e.kind==="user_message"?`${n}${s}`:n},Gc=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,zH=new Set(z9),DH=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 FH(e){const n=DH.get(e.toLowerCase());if(n)return n;const s=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s?s[0].toUpperCase()+s.slice(1):e}const X0=e=>e&&(XL(e)??(zH.has(e)?jH(e):FH(e))),Z0=e=>vy(e)?"AgentRun":qE(e)?KE(e).who??"Trigger":PH(e)?"Your grade":{user_message:"You",thinking:"Thinking",tool_use:X0(e.tool_name)??"Tool",tool_result:X0(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,UH={budget:"Paused at cap"};function WH({step:e,last:n,ended:s,waitingChip:r,files:a,onOpen:i}){var y,j;const c=e.row,[d,u]=p.useState(!1),x=yM(c)?xN:LH[c.kind]??vN,b=e.above?c.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":IH(c),g=e.above?null:e.detail??zS(c),h=g&&g.trim()!==b.trim()?g:null,v=FS(c);return t.jsxs("li",{className:"relative flex gap-3",children:[t.jsxs("div",{className:"flex w-7 shrink-0 flex-col items-center",children:[t.jsx("span",{className:ae("mt-3 flex size-7 items-center justify-center border bg-background",(c.kind==="waiting"||J0(c))&&"border-warning/60 text-warning-text",v&&"border-destructive/60 text-destructive-text"),children:t.jsx(x,{className:"size-3.5","aria-hidden":!0})}),!n&&t.jsx("span",{className:"w-px flex-1 bg-border","aria-hidden":!0})]}),t.jsxs("div",{className:"min-w-0 flex-1 border-b py-3",children:[t.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:()=>u(k=>!k),"aria-expanded":d,disabled:!h,children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-body text-muted-foreground",children:[t.jsx("span",{"data-label":!0,className:"min-w-0 truncate",title:Z0(c),children:Z0(c)}),(c.kind==="tool_use"||c.kind==="tool_result")&&c.usage&&t.jsxs("span",{className:"font-mono text-label",children:["· ",mM(c.usage,{ended:s})]}),c.kind==="waiting"&&t.jsx(je,{tone:"warning",children:r??"Input required"}),J0(c)&&t.jsx(je,{tone:"warning",children:"Approval required"}),v&&t.jsx(je,{tone:"error",children:"Error"}),DS(c)&&t.jsx(je,{tone:"muted",title:"Not run: refused before it ran",children:"Refused"}),c.agent_label&&t.jsx(je,{label:!0,title:c.agent_label,children:c.agent_label}),e.ms!==void 0&&t.jsx("span",{className:"font-mono text-label",children:Gc(e.ms)}),e.times&&t.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${Gc(Math.max(0,Date.parse(e.until)-Date.parse(c.timestamp)))}`:""]})]}),t.jsx("span",{className:ae("mt-0.5 block break-words text-prose leading-snug",vy(c)&&"text-muted-foreground"),children:VE(b)}),e.saved&&t.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),Q0(c)&&t.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:Q0(c)})]}),t.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:td(c.timestamp)}),h&&t.jsx(Cs,{className:ae("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",d&&"rotate-90"),"aria-hidden":!0})]}),d&&h&&c.tool_name&&t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:c.tool_name}),d&&h&&c.kind==="final_answer"&&t.jsx("article",{className:"report mt-3 max-h-80 max-w-none overflow-auto border bg-card p-3",onClick:mv(k=>{const $=a==null?void 0:a.find(S=>S.path===k);$&&(i==null||i($))}),dangerouslySetInnerHTML:{__html:eo(h,i&&a?{paths:a.map(k=>k.path)}:void 0)}}),d&&h&&c.kind!=="final_answer"&&t.jsx("pre",{className:"mt-3 max-h-80 overflow-auto whitespace-pre-wrap break-words border bg-card p-3 font-mono text-small leading-[1.7]",children:h}),(y=c.learned_nodes)!=null&&y.length?t.jsx(GH,{nodes:c.learned_nodes}):null,(j=c.computer_calls)!=null&&j.length?t.jsx(HH,{calls:c.computer_calls,dropped:c.computer_calls_dropped??0}):null]})]})}function HH({calls:e,dropped:n}){const[s,r]=p.useState(!1),a=e.filter(u=>!u.ok).length,i=e.length+n,c=[`${i} computer ${i===1?"call":"calls"}`,...a?[`${a} failed`]:[]].join(" · "),d=Date.parse(e[0].started_at);return t.jsxs("div",{className:"mt-2",children:[t.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>r(u=>!u),"aria-expanded":s,"aria-label":`${s?"Hide":"Show"} the computer calls`,children:[t.jsx(Cs,{className:ae("size-3 transition-transform",s&&"rotate-90"),"aria-hidden":!0}),t.jsx(qa,{className:"size-3","aria-hidden":!0}),c]}),s&&t.jsxs("ol",{"aria-label":"The computer calls",className:"mt-2 divide-y border bg-card",children:[e.map((u,f)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[t.jsxs("span",{className:"w-14 shrink-0 font-mono text-label text-muted-foreground",children:["+",Gc(Math.max(0,Date.parse(u.started_at)-d))]}),t.jsx("span",{className:ae("min-w-0 flex-1 truncate text-body",!u.ok&&"text-destructive-text"),title:Cr(u),children:Cr(u)}),!u.ok&&u.code&&t.jsx("span",{className:"shrink-0 font-mono text-label text-destructive-text",children:u.code}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:Gc(u.ms)})]},f)),n>0&&t.jsxs("li",{className:"px-3 py-1.5 text-body text-muted-foreground",children:[n," more not kept"]})]})]})}const BH={ok:"success",failed:"error",escalated:"warning"};function GH({nodes:e}){const[n,s]=p.useState(!1),r=Object.entries(e.reduce((i,c)=>({...i,[c.status]:(i[c.status]??0)+1}),{})).filter(([i])=>i!=="ok"),a=[`${e.length} ${e.length===1?"node":"nodes"}`,...r.map(([i,c])=>`${c} ${i}`)].join(" · ");return t.jsxs("div",{className:"mt-2",children:[t.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>s(i=>!i),"aria-expanded":n,"aria-label":`${n?"Hide":"Show"} the workflow's ${e.length===1?"node":"nodes"}`,children:[t.jsx(Cs,{className:ae("size-3 transition-transform",n&&"rotate-90"),"aria-hidden":!0}),t.jsx(Ka,{className:"size-3","aria-hidden":!0}),a]}),n&&t.jsx("ol",{"aria-label":"The workflow's nodes",className:"mt-2 divide-y border bg-card",children:e.map((i,c)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[t.jsx("span",{"data-status":i.status,className:"contents",children:t.jsx(je,{tone:BH[i.status]??"muted",className:"w-[5.5rem] justify-center",children:i.status})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body",title:i.label,children:i.label}),t.jsx("span",{"data-kind":!0,className:"font-mono text-label text-muted-foreground",title:O2(i)||void 0,children:Lv(i.kind,i)}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:Gc(i.duration_ms)})]},c))})]})}function qH({rows:e,live:n,fold:s=6,asking:r,waitingOn:a,files:i,onOpen:c,ended:d=!1}){var y;const u=a==="budget"?e.findLastIndex(j=>j.paused===!0):-1,f=u>=0?(y=e.slice(u+1).findLast(j=>j.kind==="waiting"))==null?void 0:y.id:void 0,[x,b]=p.useState(!1),g=bM(e).map(j=>r&&j.row.id===r?{...j,above:!0}:j),h=x?0:Math.max(0,g.length-s),v=g.slice(h);return e.length?t.jsxs("div",{children:[h>0&&t.jsxs("button",{type:"button",className:"caps mb-1 ml-10 flex items-center gap-1 py-2 text-label text-muted-foreground hover:text-foreground",onClick:()=>b(!0),children:[t.jsx(Cs,{className:"size-3","aria-hidden":!0})," ",h," earlier ",h===1?"step":"steps"]}),t.jsx("ol",{children:v.map((j,k)=>t.jsx(WH,{step:j,last:k===v.length-1&&!n,ended:d,waitingChip:j.row.id===f&&a?UH[a]:void 0,files:i,onOpen:c},j.row.id))}),n&&t.jsx(wx,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):t.jsx(wx,{title:n?"The run is starting":"Nothing on the timeline",note:n?"Steps appear here as the agent works.":"This run recorded no steps.",spin:n})}function wx({title:e,note:n,spin:s=!0}){return t.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-center",children:[s&&t.jsx(e5,{className:"size-5"}),t.jsx("p",{className:"caps text-label font-semibold",children:e}),t.jsx("p",{className:"max-w-sm text-body text-muted-foreground",children:n})]})}const KH={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."},VH={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 YH(e,n){var r,a;if(e.status==="input_required"&&((r=e.pending)==null?void 0:r.kind)==="budget"){const{cap_usd:i,spent_usd:c,held_usd:d}=e.pending,u=typeof i=="number"&&Number.isFinite(i),f=typeof d=="number"&&d>0?`, and holds ${Vr(d)} for steps still running`:"";return{title:"Paused at its spend cap",note:`${u&&typeof c=="number"?`It has spent ${Vr(c)} of its ${Vr(i)} cap${f}.`:u?`Its ${Vr(i)} 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${n.canMessage?", or send a message below to decline it":""}.`,spin:!1};const s=Di(e);return s?{title:`Waiting for you at the ${DE(s)}`,note:"The run continues once you answer the ask above, or hand the computer back on the Screen tab.",spin:!1}:e.status==="input_required"&&e.state==="waiting"?{title:"Waiting for your answer",note:n.messageMode==="answer"?"The run continues when you reply below.":"The run continues once the question is answered.",spin:!1}:e.status==="input_required"?{title:"Stopped",note:`Stopped before it wrote an answer.${n.canMessage?" Send a message below to continue it.":""}`,spin:!1}:e.status==="paused"?{title:"Paused",note:"No new step starts until it's resumed. The answer appears here when it finishes.",spin:!1}:{title:"Writing the answer",note:"The answer appears here when the run finishes. Follow it on the timeline.",spin:n.live}}function QH({run:e,agentName:n,messages:s,harnessSteers:r,rows:a,files:i,outputSchema:c,readFile:d,openFile:u=null,actions:f,onMessage:x,onApprove:b,tab:g,graphView:h,costText:v,readLearningDiff:y,readLearning:j,readLearningResult:k,readComputer:$,computerEvery:S,onTakeOver:N,onHandBack:_,readComputers:E,onGrade:O}){var ee,Re,Qe,Ze,at,Xe,pt;const A=e.native,I=Zn(e),M=((ee=e.pending)==null?void 0:ee.kind)==="budget"?e.pending:null,R=Di(e),P=!I&&!A&&R?r&&s.steer?"steer":s.follow_up?"follow_up":null:null,D=_m(e.status,e.state,e.kind,s,r,e.error,e.review,e.computer),W=I||A||M?{...D,canMessage:!1,messageMode:null}:R?{...D,canMessage:P!==null,messageMode:P}:D,Y=h?"graph":W.final&&e.status==="completed"?"report":"timeline",[H,q]=p.useState(g??Y),F=H==="graph"&&!h?Y:H,[G,U]=p.useState(!1),[z,Q]=p.useState(u?{file:u,text:null}:null),K=xW(e),Z=K||R?null:aP(e.status,e.state,a),de=K?a.findLast(et=>et.kind===TE&&et.tool_use_id===K.call_id):void 0,[re,fe]=p.useState(null),ve=async(et,kt,Ct,Tn)=>{const dn=b?await(Tn?b(et,kt,Ct,Tn):b(et,kt,Ct)):"This page can't answer an approval.";return fe(dn?{id:et,text:dn}:null),dn},Ee=p.useRef(Gg()).current,ue=async et=>{const kt=Ee.begin();if(Q({file:et,text:null}),!d)return;const Ct=await d(et);Ee.current(kt)&&Q({file:et,text:Ct})},pe=()=>{Ee.cancel(),Q(null)},me=l9(e,y),{read:ke,grade:$e,graded:J}=j9(e,W.final,j),Le=O&&(async et=>{const kt=await O(et);return J(kt),kt}),qe=W.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",{view:rt,held:vt}=YW($,!W.final,S,void 0,e.status==="queued"),st=e.computer,Se=!!rt||!!st||!!R,Be=p.useRef(!1);p.useEffect(()=>{if(Se){Be.current=!0;return}Be.current&&F==="screen"&&q(Y),Be.current=!1},[Se,F,Y]);const[he,Ve]=p.useState(!1);p.useEffect(()=>{if(!st||!Yv.has(st.kind)||!E)return;let et=!0;return E().then(kt=>{var Ct,Tn;et&&Ve(!!((Tn=(Ct=kt.kinds.find(dn=>dn.kind===st.kind))==null?void 0:Ct.providers.find(dn=>dn.id===st.provider))!=null&&Tn.metered))}).catch(()=>{}),()=>{et=!1}},[st==null?void 0:st.kind,st==null?void 0:st.provider]);const ct=R?`${R.kind}:${R.asked_at}`:null,Me=p.useRef(null);p.useEffect(()=>{!ct||Me.current===ct||!Se||(Me.current=ct,q("screen"))},[ct,Se]);const ot=async()=>{if(!N)return"This page can't take the computer over.";try{return vt((await N()).hold),null}catch(et){return yx(et,"take")}},oe=async et=>{if(!_)return"This page can't hand the computer back.";try{return vt((await _(et)).hold),null}catch(kt){return yx(kt,"hand")}},[xe,Ae]=p.useState(null),De=async et=>{const kt=(R==null?void 0:R.asked_at)??"",Ct=await oe(et);return Ae(Ct?{at:kt,text:Ct}:null),Ct};p.useEffect(()=>{u&&d&&ue(u)},[u]);const ut=[...h?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],...e.learning?[["learning","Learning"]]:[],["files",`Files ${IE(i,G).length}`],...Se?[["screen","Screen"]]:[]];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[t.jsx(AW,{run:e,agentName:n,actions:f,costText:v}),t.jsx(gS,{id:"run-views",label:"Run views",value:F,onChange:et=>q(et),tabs:ut.map(([et,kt])=>({id:et,label:kt}))}),F==="graph"?t.jsx("div",{className:"min-h-0 flex-1 short:min-h-96",children:h}):t.jsx("div",{"data-scroll-pane":!0,className:"min-h-0 flex-1 overflow-auto short:flex-none short:overflow-visible",children:t.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 px-5 py-8 md:px-8",children:[A&&t.jsx(WW,{native:A,agentId:e.agent_id}),e.status==="failed"&&e.error&&t.jsx(na,{error:e.error,title:u2(e.status,e.error)?"The run escalated":void 0}),e.status==="cancelled"&&t.jsxs("section",{className:"border border-border-strong/60 p-4",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Cancelled"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"This run was cancelled. It keeps what it did before; it takes no more messages."})]}),e.status==="completed"&&e.review&&t.jsxs("section",{className:"border border-warning/50 bg-warning/10 p-4","aria-label":"Needs review",children:[t.jsx("p",{className:"caps text-label text-warning-text",children:"Needs review"}),t.jsx("p",{className:"mt-2 text-lead",children:e.review.reason}),t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:[[e.review.node&&`Stopped at ${e.review.node}`,e.review.kind].filter(Boolean).join(" · "),". A person takes it from here."]})]}),re&&re.id!==(K==null?void 0:K.id)&&t.jsxs("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:["Your answer wasn't taken: ",re.text]}),xe&&xe.at!==(R==null?void 0:R.asked_at)&&t.jsxs("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:["Your answer wasn't taken: ",xe.text]}),K?t.jsx(AE,{pending:K,onAnswer:(et,kt,Ct)=>Ct?ve(K.id,et,kt,Ct):ve(K.id,et,kt)},K.id):R?t.jsx(FE,{ask:R,onAnswer:_?De:void 0,open:F!=="screen"?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>q("screen"),children:"Open the screen"}):null},ct):!A&&W.needsYou&&(M?t.jsx(SW,{pending:M}):t.jsx(EW,{waiting:Z})),W.needsYou&&M&&typeof M.cap_usd=="number"&&(f==null?void 0:f.onRaiseCap)&&t.jsx(LE,{cap:M.cap_usd,suggested:ME(M),least:PE(M),paused:!0,onRaise:f.onRaiseCap},`${e.run_id}:${M.at}`),F==="report"&&t.jsx(UW,{run:e,rows:a,files:i,onOpen:ue,schema:c}),F==="report"&&!e.result&&!W.final&&t.jsx(wx,{...YH(e,W)}),F==="report"&&W.final&&!((Qe=(Re=e.result)==null?void 0:Re.final_answer)!=null&&Qe.trim())&&!((Ze=e.result)!=null&&Ze.output)&&!a.some(et=>{var kt;return et.kind==="final_answer"&&((kt=et.text)==null?void 0:kt.trim())})&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:[o2,W.canMessage?" Send a follow-up below to ask for one.":""]}),F==="timeline"&&t.jsx(qH,{rows:Lz(a,e.learning),live:W.live,ended:Ua(e.status),asking:(de==null?void 0:de.id)??(W.needsYou&&!M?Z==null?void 0:Z.id:void 0),waitingOn:e.status==="input_required"?(at=e.pending)==null?void 0:at.kind:void 0,files:i,onOpen:ue}),(F==="report"||F==="timeline")&&t.jsx(b9,{run:e,graded:$e,onGrade:Le,onOpenTimeline:F==="timeline"?void 0:()=>q("timeline")}),(F==="report"||F==="timeline")&&t.jsx(S9,{used:(ke==null?void 0:ke.used)??null,agentId:e.agent_id}),(F==="report"||F==="timeline")&&me&&t.jsx(c9,{got:me.got,retry:me.retry}),F==="learning"&&t.jsx(BW,{run:e,read:k,onViewChanges:me?()=>q("report"):void 0},e.run_id),F==="files"&&t.jsx(PW,{files:i,onOpen:ue,showHidden:G,onShowHidden:U}),F==="screen"&&Se&&t.jsx(n9,{runId:e.run_id,screen:rt,machine:st,opens:qe,followUp:W.canMessage&&W.messageMode==="follow_up",metered:he,waitsFor:e.status==="input_required"&&((Xe=e.pending)==null?void 0:Xe.kind)!=="stopped"?(pt=e.pending)==null?void 0:pt.kind:void 0,keptUntil:e.status==="input_required"&&st?o9(a,st.kind):void 0,onTake:N?ot:void 0,onHand:_?()=>oe():void 0})]})}),A&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:["Native sessions cannot receive steering or follow-up messages. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(e.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," for another task."]}),I&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:[Ko(I.runtime)," runs in your backend. Start, stop and follow up through that application's controls. AgentRun records the result and checked learning."]}),W.canMessage&&t.jsx("div",{className:"border-t px-5 py-4 md:px-8",children:t.jsx("div",{className:"mx-auto max-w-4xl",children:t.jsx(NW,{mode:W.messageMode,onSend:x,purpose:K?KH:R&&P?VH[P]:void 0})})}),z&&t.jsx(LW,{file:z.file,text:z.text,onClose:pe,files:i,onOpen:ue})]})}const YE=new Set(["chain","parallel","route","map","loop","workflow"]),JH={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},XH=e=>e==="review"?"needs review":e.replace("-"," ");function yy({state:e}){const n=$f(e)??"pending";return t.jsx(je,{tone:JH[n]??"plain",className:"whitespace-nowrap",children:XH(n)})}function by({provider:e}){if(!e)return null;const n=e==="parallel"?"--wf-parallel":e==="openrouter"?"--wf-openrouter":"--wf-jev";return t.jsx("span",{className:"caps inline-flex h-5 items-center border px-1.5 text-micro leading-none",style:{color:`hsl(var(${n}))`,borderColor:`hsl(var(${n}) / .6)`,background:`hsl(var(${n}) / .12)`},children:e})}const QE={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},wy=(e,n)=>e&&n?Date.parse(n)-Date.parse(e):void 0;function ZH({data:e,selected:n,onSelect:s,onClose:r,fileUrl:a}){var j,k,$,S,N,_;const i=e.graph.nodes.find(E=>E.path===n.path),[c,d]=p.useState(null);if(!i)return null;const u=e.nodes[i.path],f=bv(e.workflow,i.path,i),x=i.kind==="map"?i.path:(j=e.graph.nodes.find(E=>E.kind==="map"&&i.path.startsWith(`${E.path}/body/`)))==null?void 0:j.path,b=n.item!=null&&x?($=(k=e.nodes[x])==null?void 0:k.items)==null?void 0:$.find(E=>E.index===n.item):void 0,g=e.decisions.filter(E=>E.node===i.path),h=e.effects.filter(E=>E.node===i.path),v=!!x&&i.kind!=="map",y=wy(u==null?void 0:u.startedAt,u==null?void 0:u.endedAt);return t.jsxs("aside",{className:"flex min-h-0 flex-col bg-background","aria-label":"Node details",children:[t.jsxs("header",{className:"border-b px-5 py-4",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"caps flex items-center gap-1.5 text-label text-muted-foreground",children:[f.decision?i.kind:Lv(i.kind,u),f.tool?` · ${ZE(f.tool)}`:i.via?` · ${i.via}`:"",f.tool&&ud(f.tool)&&t.jsx(e$,{}),b&&t.jsxs(t.Fragment,{children:[t.jsx(Cs,{className:"size-3","aria-hidden":!0})," item ",b.index+1]})]}),t.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:b?Lc(e,x,b.index)??`Item ${b.index+1}`:i.label}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t.jsx(yy,{state:b?b.status:u==null?void 0:u.status}),b&&(()=>{const E=wv(e,x,b);return E.outcome?t.jsxs("span",{className:"font-mono text-label",title:E.pNote,children:["outcome ",t.jsx("b",{className:QE[E.tone??""],children:E.outcome}),E.p!==void 0&&t.jsxs("span",{className:"text-muted-foreground",children:[" · ",Bs(E.p)]})]}):null})(),f.decision&&t.jsx(by,{provider:f.provider}),f.decision&&((u==null?void 0:u.model)??f.model)&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:(u==null?void 0:u.model)??f.model}),(u==null?void 0:u.branch)&&t.jsxs("span",{className:"font-mono text-label",children:["took ",t.jsx("b",{children:u.branch})]}),!b&&y!==void 0&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Gi(y)})]})]}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:r,children:t.jsx(Qo,{"aria-hidden":!0})})]}),b&&t.jsxs("button",{type:"button",className:"caps mt-3 text-label text-muted-foreground hover:text-foreground",onClick:()=>s({path:x,item:null}),children:["All ",(N=(S=e.nodes[x])==null?void 0:S.items)==null?void 0:N.length," items of ",(_=e.graph.nodes.find(E=>E.path===x))==null?void 0:_.label]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[b?t.jsx(s7,{data:e,mapPath:x,index:b.index,status:b.status,fileUrl:a,zoom:d}):i.kind==="map"?t.jsx(e7,{data:e,mapPath:i.path,onSelect:s}):v&&(g.length||h.length)?t.jsx(t7,{data:e,path:i.path,mapPath:x,onSelect:s}):t.jsxs(t.Fragment,{children:[i.kind==="parallel"&&t.jsx(n7,{data:e,path:i.path,onSelect:s}),g.map((E,O)=>t.jsx(XE,{d:E,fileUrl:a,zoom:d},E.id??O)),h.map((E,O)=>t.jsx(t$,{e:E,fileUrl:a,zoom:d},O)),!g.length&&!h.length&&i.kind!=="parallel"&&t.jsx(JE,{kind:i.kind,status:u==null?void 0:u.status,meta:f})]}),t.jsx(l7,{workflow:e.workflow,path:i.path,kind:i.kind})]}),c&&t.jsx(c7,{src:c,onClose:()=>d(null)})]})}function JE({kind:e,status:n,meta:s}){const r=s.decision?n==="working"?"Asking now. The verdict shows here when the answer comes back.":"Not asked yet.":e==="code"?"A code node: a pure transform of the run's state. It calls nothing, so it leaves no record of its own.":e==="route"?"Routed by a value already in the state: no model was asked.":YE.has(e)?"Its nodes are drawn inside it. Pick one to see what it did.":"Nothing recorded yet.";return t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:r})}function e7({data:e,mapPath:n,onSelect:s}){var i;const r=((i=e.nodes[n])==null?void 0:i.items)??[],a=n2(r);return t.jsxs("section",{children:[t.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,d])=>t.jsxs("div",{className:"border-r px-3 py-2 last:border-r-0",children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:c}),t.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:d})]},c))}),t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"caps text-left text-micro text-muted-foreground",children:[t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"#"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Item"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"State"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Verdict"}),t.jsx("th",{className:"border-b py-1.5 text-right font-normal",children:"Cost"})]})}),t.jsx("tbody",{children:r.map(c=>{const d=e.decisions.filter(x=>{var b;return x.item===c.index&&!!((b=x.node)!=null&&b.startsWith(`${n}/body`))}),u=wv(e,n,c),f=d.length?d.some(x=>x.cost_usd===null)?null:d.reduce((x,b)=>x+(b.cost_usd??0),0):void 0;return t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>s({path:n,item:c.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:c.index+1}),t.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:Lc(e,n,c.index),children:Lc(e,n,c.index)??"—"}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:t.jsx(yy,{state:c.status})}),t.jsx("td",{className:"max-w-[150px] truncate whitespace-nowrap border-b py-1.5 pr-2",title:[u.pNote,...d.map(x=>rl(x))].filter(Boolean).join(", "),children:u.outcome?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:ae("font-semibold",QE[u.tone??""]),children:u.outcome}),u.p!==void 0&&t.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:Bs(u.p)})]}):d.map(x=>rl(x)).filter(Boolean).join(", ")||t.jsx("span",{className:"text-muted-foreground",children:"—"})}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums",children:f===void 0?t.jsx("span",{className:"text-muted-foreground",children:"—"}):vl(f)})]},c.index)})})]})]})}function t7({data:e,path:n,mapPath:s,onSelect:r}){var x;const a=e.decisions.filter(b=>b.node===n),i=e.effects.filter(b=>b.node===n),c=(((x=e.nodes[s])==null?void 0:x.items)??[]).map(b=>({it:b,d:a.find(g=>g.item===b.index),e:i.find(g=>g.item===b.index)})).filter(b=>b.d||b.e),d=a.filter(b=>b.cost_usd!==null),u=a.filter(b=>b.latency_ms!==null),f=u.length?u.reduce((b,g)=>b+(g.latency_ms??0),0)/u.length:void 0;return t.jsxs("section",{children:[a.length>0&&t.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[a.length," asked · ",vl(d.reduce((b,g)=>b+(g.cost_usd??0),0)),d.length<a.length?` + ${a.length-d.length} unknown`:""," · mean ",Gi(f)]}),t.jsx("table",{className:"w-full border-collapse font-mono text-small",children:t.jsx("tbody",{children:c.map(({it:b,d:g,e:h})=>t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>r({path:s,item:b.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:b.index+1}),t.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:Lc(e,s,b.index)}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:g?rl(g):h?t.jsx(yy,{state:h.status}):null}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:g?Gi(g.latency_ms):h?Gi(wy(h.startedAt,h.endedAt)):""})]},b.index))})})]})}function n7({data:e,path:n,onSelect:s}){var g,h;const r=`${n}/branches/`,a=e.decisions.filter(v=>{var y;return((y=v.node)==null?void 0:y.startsWith(r))&&/^\d+$/.test(v.node.slice(r.length))&&v.item===null}),i=new Set(a.flatMap(v=>Object.keys(v.answers??{}))),[c]=[...i],d=a.map(v=>{var y;return{d:v,a:(y=v.answers)==null?void 0:y[c]}}).filter(v=>{var y;return((y=v.a)==null?void 0:y.type)==="noul"});if(i.size!==1||d.length<2)return t.jsx(JE,{kind:"parallel",meta:{decision:!1}});const u=d.map(v=>v.a.noul),f=u.reduce((v,y)=>v+y,0)/u.length,x=Math.max(...u)-Math.min(...u),b=v=>{var y;return((y=e.graph.nodes.find(j=>j.path===v.node))==null?void 0:y.label)??v.node};return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"border-b px-4 py-2.5",children:[t.jsxs("p",{className:"caps text-micro text-muted-foreground",children:["Jury · ",d.length," models · ",c]}),t.jsx("p",{className:"mt-1 text-body leading-snug",children:((h=(g=a[0].questions)==null?void 0:g[c])==null?void 0:h.instructions)??c})]}),t.jsx("ul",{className:"divide-y",children:d.map(({d:v,a:y})=>t.jsx("li",{children:t.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-2 text-left font-mono text-small hover:bg-accent",onClick:()=>s({path:v.node,item:null}),children:[t.jsx("span",{className:"w-[92px] shrink-0",children:t.jsx(by,{provider:v.provider})}),t.jsx("span",{className:"w-[132px] shrink-0 truncate",title:v.model??"",children:v.model??b(v)}),t.jsx(jx,{p:y.noul,strong:!0,tick:.5,tone:y.noul>=.5?"fg":"muted"}),t.jsx("span",{className:"w-10 text-right tabular-nums",children:Bs(y.noul)})]})},v.id??v.executionPath))}),t.jsxs("dl",{className:"grid grid-cols-3 border-t font-mono text-small",children:[t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Mean P(yes)"}),t.jsx("dd",{className:"font-semibold tabular-nums",children:Bs(f)})]}),t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Spread"}),t.jsx("dd",{className:ae("font-semibold tabular-nums",x>.3&&"text-warning-text"),children:Bs(x)})]}),t.jsxs("div",{className:"px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),t.jsx("dd",{className:"tabular-nums",children:vl(d.some(v=>v.d.cost_usd===null)?null:d.reduce((v,y)=>v+(y.d.cost_usd??0),0))})]})]})]})}function s7({data:e,mapPath:n,index:s,status:r,fileUrl:a,zoom:i}){const d=e.graph.nodes.filter(u=>u.path.startsWith(`${n}/body`)).map(u=>({n:u,ds:e.decisions.filter(f=>f.node===u.path&&f.item===s),es:e.effects.filter(f=>f.node===u.path&&f.item===s)})).filter(u=>!YE.has(u.n.kind)||u.ds.length||u.es.length);return r==="pending"?t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"Not started: this item waits for a free slot in the map."}):t.jsxs("div",{className:"space-y-5",children:[d.map(({n:u,ds:f,es:x})=>f.length||x.length?t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:u.label}),x.map((b,g)=>t.jsx(t$,{e:b,fileUrl:a,zoom:i,compact:!0},g)),f.map((b,g)=>t.jsx(XE,{d:b,fileUrl:a,zoom:i},b.id??g))]},u.path):null),r==="working"&&!d.some(u=>u.ds.length)&&t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"In flight: the verdict shows here when it comes back."})]})}const eN=e=>`${Math.round(e*100)}%`,Bs=e=>e.toFixed(2);function jx({p:e,strong:n,tick:s,tone:r="fg"}){const a={fg:"bg-foreground",success:"bg-success",warning:"bg-warning",muted:"bg-muted-foreground/50"}[r];return t.jsxs("span",{className:"relative block h-2 flex-1 bg-muted",children:[t.jsx("span",{className:ae("absolute inset-y-0 left-0 transition-[width] duration-slow",n?a:"bg-muted-foreground/45"),style:{width:eN(Math.max(0,Math.min(1,e)))}}),s!==void 0&&t.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:eN(s)},title:`threshold ${Bs(s)}`})]})}function r7({id:e,q:n,a:s,rule:r}){const a=d=>{var u;return(r==null?void 0:r.kind)==="pick"&&(n==null?void 0:n.type)==="choice"&&typeof((u=n.criteria)==null?void 0:u[d])=="string"?n.criteria[d]:d},i=(n==null?void 0:n.instructions)??e,c=(r==null?void 0:r.kind)==="route"?r.unsure:null;return t.jsxs("div",{className:"py-2.5",children:[t.jsxs("p",{className:"mb-2 text-body leading-snug",children:[t.jsx("span",{className:"mr-2 font-mono text-label text-muted-foreground",children:e}),i]}),s?s.type==="refusal"?t.jsx("p",{className:"font-mono text-small text-warning-text",children:"Refused to answer."}):s.type==="noul"?t.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[t.jsx("span",{className:ae("w-8 font-semibold",s.noul>=.5?"text-foreground":"text-muted-foreground"),children:s.noul>=.5?"YES":"NO"}),t.jsx(jx,{p:s.noul,strong:!0,tick:.5,tone:s.noul>=.5?"fg":"muted"}),t.jsxs("span",{className:"w-24 text-right tabular-nums text-muted-foreground",children:["P(yes) ",Bs(s.noul)]})]}):s.type==="box"?t.jsxs("p",{className:"font-mono text-small",children:["box ",JSON.stringify(s.box)]}):t.jsxs("div",{className:"space-y-1.5",children:[Object.entries(s.probabilities).sort((d,u)=>u[1]-d[1]).slice(0,(r==null?void 0:r.kind)==="pick"?5:void 0).map(([d,u])=>{const f=(s.type==="choice"?s.choice:String(s.score))===d;return t.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[t.jsx("span",{className:ae("truncate",(r==null?void 0:r.kind)==="pick"?"w-48":"w-28",f?"font-semibold":"text-muted-foreground"),title:a(d),children:s.type==="score"?`${d} ${s.legend[d]??""}`:a(d)}),t.jsx(jx,{p:u,strong:f,tick:f&&c?c.gte:void 0}),t.jsx("span",{className:"w-12 text-right tabular-nums text-muted-foreground",children:Bs(u)})]},d)}),(r==null?void 0:r.kind)==="pick"&&Object.keys(s.probabilities).length>5&&t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[Object.keys(s.probabilities).length-5," more options, each less likely"]})]}):t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No answer."})]})}function o7(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 ${Bs(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) ≥ ${Bs(e.gte)}.`;case"sift":return e.keep?`Keep an item when its ${e.keep.id} ${e.keep.measure} ≥ ${Bs(e.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function a7(e){var s,r,a,i;const n=e.action;if(n==null)return e.status==="cancelled"?"None: the outcome is unknown, so it goes to review and is not asked again.":"None.";if(((s=e.rule)==null?void 0:s.kind)==="route"){const c=((a=(r=e.answers)==null?void 0:r.branch)==null?void 0:a.type)==="choice"?e.answers.branch.confidence:void 0;return n.unsure?`Took "${String(n.taken)}": "${String(n.branch)}" at ${c!==void 0?Bs(c):"?"} is below the threshold.`:`Took "${String(n.taken??n.branch)}".`}if(((i=e.rule)==null?void 0:i.kind)==="pick"&&typeof n.index=="number"){const c=e.rule.options[n.index];return n.none?`None of the options: "${e.rule.none??"none"}".`:`Picked ${c!==void 0?`"${e2(e,Object.keys(e.questions??{})[0]??"pick",c)}"`:`option ${n.index}`}.`}return typeof n=="object"?Object.entries(n).map(([c,d])=>`${c} = ${typeof d=="object"?JSON.stringify(d):String(d)}`).join(" · "):String(n)}function XE({d:e,fileUrl:n,zoom:s}){var i,c,d;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 t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-2 border-b px-4 py-2.5",children:[t.jsx(by,{provider:e.provider}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:e.model??"default model"}),t.jsx(je,{tone:a,children:e.status==="cancelled"?"outcome unknown":e.status})]}),t.jsxs("dl",{className:"grid grid-cols-[minmax(0,1fr)_100px_92px] border-b font-mono text-small",children:[t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:Object.keys(e.answers??{}).length>1&&((i=e.rule)==null?void 0:i.kind)!=="route"?"Least sure answer":"Verdict"}),t.jsx("dd",{className:"break-words font-semibold",children:rl(e)??"—"})]}),t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),t.jsx("dd",{className:"tabular-nums",title:e.cost_basis??void 0,children:vl(e.cost_usd)})]}),t.jsxs("div",{className:"px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Latency"}),t.jsx("dd",{className:"tabular-nums",children:Gi(e.latency_ms)})]})]}),e.error&&t.jsx("p",{className:ae("border-b px-4 py-2.5 font-mono text-small",e.status==="cancelled"?"text-warning-text":"text-destructive-text"),children:e.error}),!!((c=e.images)!=null&&c.length)&&t.jsx("div",{className:"space-y-3 border-b px-4 py-3",children:e.images.map(u=>({img:u,src:u.ref&&n(u.ref)||no(u.url)})).filter(({src:u})=>u).map(({img:u,src:f})=>t.jsxs("figure",{className:"flex gap-3",children:[t.jsx("button",{type:"button",className:"block shrink-0 border bg-white hover:border-foreground",onClick:()=>s(f),"aria-label":`Open ${u.ref}`,children:t.jsx("img",{src:f,alt:`The page the model saw as ${u.token}`,className:"block h-[155px] w-[120px] object-cover object-top",loading:"lazy"})}),t.jsxs("figcaption",{className:"min-w-0 flex-1 space-y-1.5 font-mono text-label",children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:"What the model saw"}),t.jsxs("p",{children:[t.jsx("span",{className:"text-muted-foreground",children:"token "}),u.token]}),t.jsxs("p",{className:"break-all",children:[t.jsx("span",{className:"text-muted-foreground",children:"page "}),u.ref]}),u.sha256&&t.jsxs("p",{className:"break-all",title:u.sha256,children:[t.jsx("span",{className:"text-muted-foreground",children:"sha256 "}),u.sha256.slice(0,16),"…"]}),(u.mime||u.bytes)&&t.jsx("p",{className:"text-muted-foreground",children:[u.mime,u.bytes?`${Math.round(u.bytes/1024)} KB`:null].filter(Boolean).join(" · ")})]})]},u.token))}),t.jsx("div",{className:"divide-y px-4",children:r.map(u=>{var f,x;return t.jsx(r7,{id:u,q:(f=e.questions)==null?void 0:f[u],a:(x=e.answers)==null?void 0:x[u],rule:e.rule},u)})}),t.jsxs("dl",{className:"space-y-2 border-t px-4 py-3 text-body",children:[t.jsxs("div",{className:"flex gap-3",children:[t.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Rule"}),t.jsx("dd",{children:o7(e.rule)})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Action"}),t.jsx("dd",{className:"font-mono text-small",children:a7(e)})]})]}),!!((d=e.evidence)!=null&&d.length)&&t.jsx(i7,{evidence:e.evidence}),e.state!=null&&t.jsxs("details",{className:"group border-t",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Cs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," What the model saw",e.state_truncated?" (cut at 64 KB)":""]}),t.jsx(Jf,{value:e.state})]})]})}function i7({evidence:e}){return t.jsxs("section",{className:"border-t px-4 py-3",children:[t.jsxs("p",{className:"caps mb-2 text-micro text-muted-foreground",children:["Sources · ",e.length]}),t.jsx("ol",{className:"space-y-3",children:e.map((n,s)=>{let r=n.url;try{r=new URL(n.url).host}catch{}const a=no(n.url);return t.jsxs("li",{className:"flex gap-3",children:[t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:s+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[a?t.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:[n.title??r,t.jsx(oT,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}):t.jsx("span",{className:"break-all text-body font-semibold leading-snug",children:n.title??r}),t.jsxs("p",{className:"mt-0.5 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[r,n.scope&&t.jsx("span",{className:"border px-1",children:n.scope})]}),n.excerpts.slice(0,2).map((i,c)=>t.jsx("blockquote",{className:"mt-1.5 line-clamp-3 border-l-2 border-wf-parallel/[.6] pl-2.5 text-body leading-snug text-muted-foreground",children:i},c))]})]},s)})})]})}const ZE=e=>{const n=ud(e);return n?`${n.tool} on ${n.server}`:e},e$=()=>t.jsx(je,{tone:"muted",title:"An MCP server's tool",children:t.jsx("span",{"data-mcp":!0,children:"MCP"})});function t$({e,fileUrl:n,zoom:s,compact:r=!1}){var x;const a=e.output,i=a!=null,c=a&&typeof a=="object"?a:null,d=!e.endedAt&&!["done","ok","failed","stopped"].includes(e.status),u=e.error??(c!=null&&c.error?`${c.error.code?`${c.error.code}: `:""}${c.error.message??""}`:null),f=e.status==="done"||e.status==="ok"?"success":e.status==="failed"?"error":e.status==="stopped"?"muted":"active";return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"flex items-center gap-2 border-b px-4 py-2.5",children:[t.jsx("span",{className:"caps inline-flex h-5 items-center border border-wf-tool/[.6] bg-wf-tool/[.12] px-1.5 text-micro leading-none text-wf-tool",children:"tool"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",title:e.tool,children:ZE(e.tool)}),ud(e.tool)&&t.jsx(e$,{}),t.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?Gi(wy(e.startedAt,e.endedAt)):""}),t.jsx(je,{tone:f,children:e.status})]}),t.jsxs("div",{className:"space-y-3 px-4 py-3",children:[r?t.jsxs("p",{className:"break-all font-mono text-label",children:[t.jsx("span",{className:"caps mr-2 text-micro text-muted-foreground",children:"Input"}),JSON.stringify(e.input)]}):t.jsxs("div",{children:[t.jsx("p",{className:"caps mb-1 text-micro text-muted-foreground",children:"Input"}),t.jsx(Jf,{value:e.input,small:!0})]}),u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",children:u}),!!((x=c==null?void 0:c.pages)!=null&&x.length)&&t.jsx("div",{className:"flex flex-wrap gap-3",children:c.pages.map(b=>t.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>s(n(b.image)),"aria-label":`Open page ${b.page}`,children:t.jsx("img",{src:n(b.image),alt:`Page ${b.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},b.page))}),i&&!u&&t.jsxs("details",{className:"group",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[t.jsx(Cs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),t.jsx(Jf,{value:a,small:!0})]}),!i&&!u&&t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:e.status==="stopped"?"Stopped before it answered.":d?"Running…":"Finished with no output."})]})]})}function l7({workflow:e,path:n,kind:s}){const r=XS(e,n);if(!r)return null;const a=Object.fromEntries(Object.entries(r).map(([i,c])=>[i,(i==="steps"||i==="branches"&&s==="parallel")&&Array.isArray(c)?`… ${Mm(c.length)}`:i==="body"?"… its body":i==="branches"&&s==="route"&&c&&typeof c=="object"?Object.fromEntries(Object.entries(c).map(([d,u])=>[d,(u==null?void 0:u.criteria)??"…"])):c]));return t.jsxs("details",{className:"group border",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Cs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Definition ",t.jsx("span",{className:"normal-case tracking-normal",children:n})]}),t.jsx(Jf,{value:a})]})}function Jf({value:e,small:n}){return t.jsx("pre",{className:ae("overflow-auto whitespace-pre-wrap break-words border-t bg-background px-4 py-3 font-mono leading-[1.6]",n?"max-h-48 border text-label":"max-h-80 text-small"),children:JSON.stringify(e,null,2)})}function c7({src:e,onClose:n}){return t.jsx(wm,{open:!0,onClose:n,title:"Page image",size:"full",children:t.jsx("img",{src:e,alt:"Page",className:"mx-auto max-h-full max-w-full border bg-white"})})}const n$=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function d7(e,{everyMs:n=1e3,key:s="",enabled:r=!0}={}){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[x,b]=p.useState(0),g=p.useRef(e);return g.current=e,p.useEffect(()=>{if(!r)return;const h=new AbortController;let v;const y=async()=>{try{const j=Date.now(),k=await g.current(h.signal);if(h.signal.aborted||(i(k),d(null),f(j),rd(k.run.status)))return}catch(j){if(h.signal.aborted)return;d(j);const k=j;if(k.retryable){v=setTimeout(y,Math.min(n,k.retryAfterMs??500));return}if(n$(j))return}v=setTimeout(y,n)};return y(),()=>{h.abort(),clearTimeout(v)}},[s,n,x,r]),{data:a,error:c,readAt:u,reload:()=>b(h=>h+1)}}function u7({data:e,actions:n={},fileUrl:s,initial:r=null,lastRead:a}){const[i,c]=p.useState(r),d=p.useMemo(()=>nP(e,i),[e,i]),u=rd(e.run.status),[f,x]=p.useState(()=>Date.now()),b=p.useMemo(()=>Date.now(),[e]);return p.useEffect(()=>{if(u||e.run.paused)return;const g=setInterval(()=>x(Date.now()),1e3);return()=>clearInterval(g)},[u,e.run.paused]),t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsx(f7,{data:e,readAt:b,now:f,actions:n,stale:!u&&a&&f-a>5e3?Math.max(1e3,f-a):0}),e.run.paused&&t.jsx("p",{className:"border-b border-warning/40 bg-warning/10 px-5 py-2 font-mono text-small text-warning-text md:px-8",role:"status",children:"Paused. Calls already in flight finish; no new node starts until you resume. The run keeps its place across a restart."}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[t.jsx("div",{className:"min-h-[320px] min-w-0 flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px]",children:t.jsx("div",{className:"px-5 py-6 md:px-8",children:t.jsx(md,{graph:e.graph,marks:d,onSelect:g=>c(h=>h&&h.path===g.path&&(h.item??null)===g.item?null:g),label:"The run's workflow graph"})})}),i&&t.jsx("div",{className:"flex min-h-0 shrink-0 flex-col border-t lg:w-[460px] lg:border-l lg:border-t-0",children:t.jsx(ZH,{data:e,selected:i,onSelect:c,onClose:()=>c(null),fileUrl:s})})]}),t.jsx("div",{className:"border-t px-5 py-2 md:px-8",children:t.jsx(hd,{run:!0})})]})}function f7({data:e,readAt:n,now:s,actions:r,stale:a}){const i=rd(e.run.status),c=e.graph.nodes.find(b=>{var g,h;return b.kind==="map"&&((h=(g=e.nodes[b.path])==null?void 0:g.items)==null?void 0:h.length)}),d=c?n2(e.nodes[c.path].items):null,{usd:u,unknown:f}=s2(e),x=[["Elapsed",ol(oP(e,n,s))],["Cost",t.jsxs(t.Fragment,{children:[vl(u),f>0&&t.jsxs("span",{className:"text-label font-normal text-muted-foreground",children:[" + ",f," unknown"]})]}),"Decisions and model calls, as the providers priced them"],["Decisions",e.totals.decisions],["Tool calls",e.totals.effects],["Agents",h7(e),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return d&&x.push(["Items",t.jsxs(t.Fragment,{children:[t.jsx("span",{children:d.done}),t.jsxs("span",{className:"text-muted-foreground",children:["/",d.total]}),d.failed>0&&t.jsxs("span",{className:"ml-2 text-label text-destructive-text",children:[d.failed," failed"]}),d.review>0&&t.jsxs("span",{className:"ml-2 text-label text-warning-text",children:[d.review," review"]})]})]),t.jsxs("div",{className:"flex flex-wrap items-stretch border-b",children:[e.run.paused&&t.jsx("div",{className:"flex items-center pl-5 md:pl-8",children:t.jsxs(je,{tone:"warning",children:[t.jsx(Xi,{className:"size-3","aria-hidden":!0})," Paused"]})}),x.map(([b,g,h],v)=>t.jsxs("div",{className:ae("px-4 py-2",v?"border-l":"pl-5 md:pl-8"),title:h,children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:b}),t.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:g})]},b)),t.jsxs("div",{className:"flex flex-1 items-center justify-end gap-3 px-5 py-2 md:px-8",children:[a>0&&t.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",ol(a)," ago, reading again"]}),!i&&(e.run.paused?t.jsxs(B,{size:"sm",variant:"solid",onClick:r.onResume,disabled:!r.onResume||!!r.busy,children:[t.jsx(Vo,{"aria-hidden":!0})," ",r.busy==="resume"?"Resuming":"Resume"]}):t.jsxs(B,{size:"sm",onClick:r.onPause,disabled:!r.onPause||!!r.busy,title:"Calls in flight finish; no new node starts.",children:[t.jsx(Xi,{"aria-hidden":!0})," ",r.busy==="pause"?"Pausing":"Pause"]}))]})]})}const m7=new Set(["agent","decide","extract","report","artifact"]),h7=e=>e.graph.nodes.filter(n=>{var s;return m7.has(n.kind)&&!["pending","not_run"].includes(((s=e.nodes[n.path])==null?void 0:s.status)??"pending")}).length;function p7({error:e}){const n=e==null?void 0:e.status;return t.jsx("p",{className:ae("m-8 border p-4 font-mono text-body",n===404?"text-muted-foreground":"text-destructive-text"),role:"status",children:e==null?"Reading the run's graph...":n===404?"This server does not give run graphs: GET /v2/runs/{id}/graph is not there.":`The run's graph could not be read: ${e.message??String(e)}`})}function g7(e,n){return!n||e.state==="loading"?{messages:$m,steers:!1}:e.state==="failed"?{messages:n.features.messages,steers:!1}:{messages:n.features.messages,steers:wP(e.id,n.harnesses)}}async function x7(e,n){try{let s=null;do{const r=await e.listRevisions(n.agent_id,s),a=r.revisions.find(c=>c.revision===n.revision),i=a==null?void 0:a.definition.output_schema;if(a)return{state:"read",id:a.definition.harness,...i?{outputSchema:i}:{}};s=r.next_cursor}while(s)}catch{}return{state:"failed"}}const tN=new Set(["completed","failed","cancelled"]),v7={firstMs:2e3,maxMs:16e3,totalMs:12e4};function y7(e,n,s,r=v7){var x;const a=!!e&&tN.has(e.status)&&Lm(e.learning),i=p.useRef(n);i.current=n;const c=p.useRef(s);c.current=s;const d=(x=e==null?void 0:e.learning)==null?void 0:x.state,u=!!e&&tN.has(e.status),f=p.useRef(d);p.useEffect(()=>{var g;const b=f.current;f.current=d,b!==void 0&&b!==d&&u&&((g=c.current)==null||g.call(c))},[d,u]),p.useEffect(()=>{if(!a)return;let b,g=0,h=r.firstMs,v=!1,y=!1;const j=()=>{y||g+h>r.totalMs||(b=setTimeout(k,h))},k=()=>{if(b=void 0,document.visibilityState==="hidden"){v=!0;return}g+=h,h=Math.min(h*2,r.maxMs),i.current(),j()},$=()=>{v&&document.visibilityState!=="hidden"&&(v=!1,k())};return document.addEventListener("visibilitychange",$),j(),()=>{y=!0,b&&clearTimeout(b),document.removeEventListener("visibilitychange",$)}},[a])}const nN=new Set(["completed","failed","cancelled"]),b7=e=>{const n=s2(e);return`${vl(n.usd)}${n.unknown?` + ${n.unknown} unknown`:""}`},w7=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},Mi=e=>({api:w7(e),title:IM(e),cause:e});function sN({v2:e,runId:n,caps:s,agentName:r}){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[x,b]=p.useState([]),[g,h]=p.useState(null),[v,y]=p.useState(null),[j,k]=p.useState(0),$=p.useRef(""),S=p.useRef(Gg()).current,N=p.useRef(Gg()).current,_=p.useRef(dr()).current,E=p.useRef(0),O=p.useRef(""),[A,I]=p.useState({state:"loading"});p.useEffect(()=>{a&&A.state==="loading"&&x7(e,a).then(I)},[a==null?void 0:a.revision]);const M=g7(A,s);y7(a,()=>R(),()=>k(K=>K+1));const R=async()=>{const K=S.begin();try{const[Z,de]=await Promise.all([e.getRun(n),e.listFiles(n)]);S.current(K)&&(i(Z),b(de.files))}catch(Z){S.current(K)&&h(Mi(Z))}};p.useEffect(()=>{R()},[n]),$E(()=>{R()}),p.useEffect(()=>{const K=new AbortController;return d(null),US(e,n,{signal:K.signal,onRows:Z=>{f(Z);const de=Z.filter(fe=>fe.kind===TE).map(fe=>`${fe.id}\0${fe.summary}`).join("");de!==O.current&&(O.current=de,R());const re=Z.filter(fe=>fe.kind==="tool_result").length;if(re>E.current){E.current=re;const fe=N.begin();e.listFiles(n).then(ve=>{N.current(fe)&&b(ve.files)}).catch(()=>{})}},onPage:Z=>{Z.cost&&d(Z.cost);const de=`${Z.status}/${Z.state}`;(de!==$.current||Z.status==="input_required"&&!Z.unchanged)&&($.current=de,R())}}).catch(Z=>{K.signal.aborted||h(Mi(Z))}),()=>K.abort()},[n,j]);const P=async K=>{y(K);try{await e[K](n),h(null)}catch(Z){h(Mi(Z))}y(null),await R(),k(Z=>Z+1)},D=async()=>{if(a){y("archive");try{const K=await(a.archived_at?e.unarchiveRun(n):e.archiveRun(n));i(Z=>Z?{...Z,archived_at:K.archived_at}:K),h(null)}catch(K){h(Mi(K))}y(null),R()}},W=async K=>{const Z=await K();return await R(),k(de=>de+1),Z},Y=K=>W(()=>e.raiseCap(n,K)),H=K=>W(()=>e.gradeRun(n,K)),q=async K=>{let Z=!0;try{await tC(_,n,K,e.sendMessage),h(null)}catch(de){h(Mi(de)),Z=!1}return await R(),k(de=>de+1),Z},F=async(K,Z,de,re)=>{let fe=null;try{await e.answerApproval(n,K,Z,de,re)}catch(ve){fe=RE(ve)}return await R(),k(ve=>ve+1),fe},G=async K=>{try{return await K()}finally{R(),k(Z=>Z+1)}},U=d7(K=>e.getRunGraph(n,K),{key:n,enabled:(a==null?void 0:a.kind)==="workflow"}),z=!U.data&&n$(U.error);if(!a)return g?g.cause instanceof ze&&g.cause.status===404?t.jsx(BS,{what:"run",id:n,list:{href:"#/runs",label:"Open the runs list"}}):t.jsx(Kt,{problem:Ft(g.cause,"the run"),onRetry:()=>{h(null),R(),k(K=>K+1)}}):t.jsx(AM,{});const Q=c&&!nN.has(a.status)?{...a,cost:c}:a;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[g&&t.jsx("div",{className:"border-b p-3",children:t.jsx(na,{title:g.title,error:g.api})}),t.jsx(QH,{run:Q,agentName:r(a.agent_id),messages:M.messages,harnessSteers:M.steers,graphView:a.kind==="workflow"&&!z?t.jsx(j7,{v2:e,runId:n,graph:U,onMoved:()=>{R()}}):void 0,costText:a.kind==="workflow"&&!nN.has(a.status)&&U.data?b7(U.data):void 0,outputSchema:A.state==="read"?A.outputSchema:void 0,rows:u,files:x,readFile:K=>e.readFile(n,K.path),readLearningDiff:()=>e.runLearningDiff(n),readLearning:()=>e.runLearning(n),readLearningResult:()=>e.runLearningResult(n),readComputer:()=>e.runComputer(n),onTakeOver:()=>G(()=>e.takeOverComputer(n)),onHandBack:K=>G(()=>e.handBackComputer(n,K)),readComputers:()=>e.computers(),onMessage:q,onApprove:F,onGrade:H,actions:{onStop:()=>void P("stop"),onCancel:()=>void P("cancel"),onArchive:()=>void D(),onRaiseCap:Y,busy:v}},a.run_id)]})}function j7({v2:e,runId:n,graph:s,onMoved:r}){const{data:a,error:i,readAt:c,reload:d}=s,[u,f]=p.useState(null),[x,b]=p.useState(null),[g,h]=p.useState(null),v=async j=>{f(j);try{const k=await(j==="pause"?e.pauseRun(n):e.resumeRun(n));h({paused:k.paused,status:k.status,at:Date.now()}),b(null)}catch(k){b(Mi(k))}f(null),d(),r()},y=a&&g&&c<g.at?{...a,run:{...a.run,paused:g.paused,...g.status?{status:g.status}:{}}}:a;return y?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[x&&t.jsx("div",{className:"border-b p-3",children:t.jsx(na,{title:x.title,error:x.api})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(u7,{data:y,lastRead:c,fileUrl:j=>e.fileUrl(n,j),actions:{onPause:()=>void v("pause"),onResume:()=>void v("resume"),busy:u}})})]}):t.jsx(p7,{error:i})}function rN({actions:e,children:n}){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center justify-between gap-2 border-b px-5 py-2 md:px-6",children:[t.jsxs("h1",{className:"flex items-center gap-2.5 font-mono text-small font-semibold",children:[t.jsx(Px,{className:"size-4","aria-hidden":!0}),"Mission Control"]}),e&&t.jsx("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:e})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n})]})}function k7({view:e,error:n,onRetry:s,scope:r,needsYou:a,asking:i,failed:c,live:d,startHere:u,actions:f,observations:x,hasObservedSessions:b=!1}){if(!e)return t.jsx(rN,{actions:f,children:t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-8 px-5 pb-16 pt-8 md:px-8 md:pt-10",children:[n?t.jsx(Kt,{problem:n,onRetry:s}):t.jsx(RM,{}),x]})});const g=y=>{var j;return((j=e.perAgent.find(k=>k.agentId===y))==null?void 0:j.name)??y},h=r!=null&&r.agent?e.perAgent.filter(y=>y.agentId===r.agent):e.perAgent,v=[["Agents",String(e.agents),"#/agents"],["Runs",String(e.runs.total),"#/runs"],["Active",String(e.runs.active),void 0,void 0,[typeof d=="number"&&d!==e.runs.active?`${d} running now`:"",e.runs.statusUnknown?`${e.runs.statusUnknown} unknown`:""].filter(Boolean).join(" · ")||void 0],["Needs input",i===null?"–":String(i??e.runs.needsInput),"#/runs?status=input_required",i??e.runs.needsInput?"text-warning-text":void 0],c===void 0?["Failed",String(e.runs.failed),"#/runs?status=failed",e.runs.failed?"text-destructive-text":void 0,oN(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}`,oN(e.runs.needsReview)??""].filter(Boolean).join(" · ")]];return t.jsx(rN,{actions:f,children:t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-8 px-5 pb-16 pt-8 md:px-8 md:pt-10",children:[n&&t.jsx(Kt,{problem:n,onRetry:s,className:""}),u,a,t.jsxs("section",{className:"space-y-4","aria-label":b?"Registered agents and runs":void 0,children:[b&&t.jsx("h2",{className:"text-lead font-semibold",children:"Registered agents & runs"}),t.jsx("ul",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:v.map(([y,j,k,$,S])=>{const N=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:y}),t.jsx("p",{className:ae("mt-3 font-mono text-display leading-none",$),children:j}),S&&t.jsx("p",{className:"mt-2 text-label text-muted-foreground",children:S})]});return t.jsx("li",{children:k?t.jsx("a",{href:k,className:"block h-full border bg-card p-5 transition-colors hover:border-border-strong hover:bg-accent",children:N}):t.jsx("div",{className:"h-full border bg-card p-5",children:N})},y)})})]}),x,t.jsxs("section",{className:"space-y-4","aria-label":"Analytics",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-6 gap-y-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Activity & usage"}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:N7(e)})]}),r&&t.jsx(YS,{range:r.range,onRange:r.onRange,agent:r.agent,agents:e.perAgent,onAgent:r.onAgent})]}),t.jsx(QS,{a:e.analytics,basis:e.cost.basis,refreshing:r==null?void 0:r.refreshing})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsxs("h2",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:[t.jsx(mf,{className:"size-4","aria-hidden":!0}),"Runs per agent"]}),h.length?t.jsx("ul",{children:h.map(y=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:on(y.agentId,"runs"),className:"flex items-center justify-between gap-3 px-4 py-3 text-lead hover:bg-accent",children:[t.jsx("span",{className:"min-w-0 truncate",children:y.name}),t.jsx("span",{className:"font-mono text-body text-muted-foreground",children:y.runs})]})},y.agentId))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No agents yet."})]}),t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsxs("h2",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:[t.jsx(Kc,{className:"size-4","aria-hidden":!0}),"Recent runs"]}),e.recent.length?t.jsx("ul",{children:e.recent.map(y=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(y.run_id)}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-accent",children:[t.jsx(yl,{run:y}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-lead",children:Nn(y)}),t.jsx(Gv,{run:y,className:"hidden sm:inline-flex"}),cU(y)&&t.jsx("span",{className:"shrink-0 text-small text-muted-foreground",children:"send a message to continue"})]}),t.jsx("span",{className:"hidden shrink-0 text-body text-muted-foreground md:inline",children:g(y.agent_id)}),y.ended_at&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",title:"How long it ran",children:ol(Date.parse(y.ended_at)-Date.parse(y.created_at))}),y.cost&&(y.cost.usd!==null||xl(y.cost))&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:Zr(y.cost,{ended:Ua(y.status)})}),t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:mt(y.created_at)})]})},y.run_id))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs yet."})]})]})]})})}const oN=e=>e?`${e} ${e===1?"needs":"need"} review`:void 0;function N7(e,n=Date.now()){var i;const s=e.analytics.filter,r=s.from?Math.round((Math.floor(n/864e5)*864e5-Date.parse(s.from))/864e5)+1:null,a=s.from?xv.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 ${((i=e.perAgent.find(c=>c.agentId===s.agent))==null?void 0:i.name)??s.agent}`:a}const ms=e=>`#/runs/${encodeURIComponent(e)}`;function S7({asking:e,failed:n,failedAll:s,live:r,learning:a=[],agentName:i,onAnswer:c,onApprove:d,onHandBack:u,onRunAgain:f,onStop:x,problem:b,now:g=Date.now}){const h=rU(n.filter(R=>!Zn(R))),v=n.filter(R=>!R.imported_from&&Zn(R)),[,y]=p.useState(0);p.useEffect(()=>{if(!r.length)return;const R=setInterval(()=>y(P=>P+1),1e3);return()=>clearInterval(R)},[r.length]);const[j,k]=p.useState([]),$=(R,P,D)=>{const W=e.find(H=>H.run_id===R),Y=W?Nn(W):R;k(H=>[...H.filter(q=>q.runId!==R),...D?[{runId:R,what:P,title:Y,text:D}]:[]])},S=d&&(async(R,P,D,W,Y)=>{const H=await(Y?d(R,P,D,W,Y):d(R,P,D,W));return $(R,P,H),H}),N=u&&(async(R,P,D)=>{const W=await u(R,D);return $(R,`ask:${P.asked_at}`,W),W}),_=R=>{var D;const P=Di(R);return((D=R.pending)==null?void 0:D.kind)==="approval"?R.pending.id:P?`ask:${P.asked_at}`:null},E=SE(n),O=a.filter(R=>R.pending>0),A=O.reduce((R,P)=>R+P.pending,0),I=e.length+E+A;if(!I&&!r.length&&!b&&!j.length)return null;const M=g();return t.jsxs("section",{"aria-label":"Needs you",className:"space-y-3",children:[I>0&&t.jsxs("h2",{className:"caps text-small font-semibold",children:["Needs you ",t.jsxs("span",{className:"text-warning-text",children:["· ",I]})]}),b&&t.jsx("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:b}),j.filter(R=>!e.some(P=>P.run_id===R.runId&&_(P)===R.what)).map(R=>t.jsxs("p",{className:"flex items-start gap-3 border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("a",{href:ms(R.runId),className:"underline-offset-4 hover:underline",children:R.title}),": your answer wasn't taken. ",R.text]}),t.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>k(P=>P.filter(D=>D.runId!==R.runId)),children:"Dismiss"})]},R.runId)),e.length>0&&t.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(R=>{var P,D,W;return R.native?t.jsxs("li",{className:"space-y-2 border p-4",children:[t.jsx("a",{href:ms(R.run_id),className:"text-body underline underline-offset-2",children:Nn(R)}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native sessions cannot receive another message. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(R.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," to continue."]})]},R.run_id):((P=R.pending)==null?void 0:P.kind)==="approval"?t.jsx(C7,{run:R,pending:R.pending,agentName:i(R.agent_id),at:M,onApprove:S},`${R.run_id}:${R.pending.id}`):Di(R)?t.jsx(E7,{run:R,ask:Di(R),agentName:i(R.agent_id),at:M,onHandBack:N},`${R.run_id}:${Di(R).asked_at}`):t.jsx($7,{run:R,agentName:i(R.agent_id),at:M,onAnswer:c},`${R.run_id}:${((D=R.pending)==null?void 0:D.kind)==="question"?R.pending.asked_at:((W=R.pending)==null?void 0:W.kind)==="budget"?R.pending.at??"":""}`)})}),(h.length>0||v.length>0)&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps flex items-center justify-between border-b px-4 py-2.5 text-label text-muted-foreground",children:[t.jsxs("span",{children:["Failed in the last 24 h · ",E]}),t.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"} →`})]}),t.jsxs("ul",{children:[h.map(R=>t.jsx(R7,{message:R.message,runs:R.runs,agentName:i,at:M,onRunAgain:f},R.message)),v.map(R=>t.jsx(aN,{run:R,agentName:i(R.agent_id)},R.run_id))]})]}),O.length>0&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Learned, waiting for your OK · ",A]}),t.jsx("ul",{children:O.map(R=>t.jsxs("li",{className:"flex min-w-0 items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:R.name}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:Hv(R.pending)}),t.jsx("a",{href:`#/agents/${encodeURIComponent(R.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},R.agent_id))})]}),r.length>0&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Running now · ",r.length]}),t.jsx("ul",{children:r.map(R=>Zn(R)?t.jsx(aN,{run:R,agentName:i(R.agent_id)},R.run_id):t.jsx(A7,{run:R,agentName:i(R.agent_id),at:M,onStop:x},R.run_id))})]})]})}function C7({run:e,pending:n,agentName:s,at:r,onApprove:a}){return t.jsx("li",{"data-run":e.run_id,className:"min-w-0",children:t.jsx(AE,{compact:!0,pending:n,heading:t.jsx(jy,{run:e,agentName:s,since:`asked ${bd(n.requested_at,r)} ago`}),onAnswer:(i,c,d)=>a?d?a(e.run_id,n.id,i,c,d):a(e.run_id,n.id,i,c):Promise.resolve("Open the run to answer it.")})})}function E7({run:e,ask:n,agentName:s,at:r,onHandBack:a}){return t.jsx("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5",children:t.jsx(FE,{compact:!0,ask:n,heading:t.jsx(jy,{run:e,agentName:s,since:`asked ${bd(n.asked_at,r)} ago`}),open:t.jsx("a",{href:ms(e.run_id),className:"text-body underline underline-offset-2",children:"Open its screen"}),onAnswer:a&&(i=>a(e.run_id,n,i))})})}function $7(e){var n;return((n=e.run.pending)==null?void 0:n.kind)==="budget"?t.jsx(_7,{run:e.run,pending:e.run.pending,agentName:e.agentName}):t.jsx(T7,{...e})}function _7({run:e,pending:n,agentName:s}){return t.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[t.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:s}),t.jsx("a",{href:ms(e.run_id),className:"min-w-0 truncate text-muted-foreground hover:text-foreground",children:Nn(e)})]}),t.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:OE(n)}),typeof n.said=="string"&&t.jsx("p",{className:"mt-1 text-prose leading-snug",children:n.said}),t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:t.jsx("a",{href:ms(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})})]})}function jy({run:e,agentName:n,since:s}){return t.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:n}),t.jsx("a",{href:ms(e.run_id),className:"min-w-0 truncate text-muted-foreground hover:text-foreground",children:Nn(e)}),s&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:s})]})}function T7({run:e,agentName:n,at:s,onAnswer:r}){var j;const a=((j=e.pending)==null?void 0:j.kind)==="question"?e.pending:null,i=(a==null?void 0:a.question)??"",c=sU(i),[d,u]=p.useState(""),[f,x]=p.useState(!1),[b,g]=p.useState(null),[h,v]=p.useState(null),y=async k=>{k.preventDefault();const $=d.trim();if(!$||f)return;x(!0),g(null);const S=await r(e.run_id,$);x(!1),S?g(S):v($)};return t.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[t.jsx(jy,{run:e,agentName:n,since:a!=null&&a.asked_at?`asked ${bd(a.asked_at,s)} ago`:void 0}),t.jsx("p",{className:"mt-2 text-base leading-snug",children:i}),h?t.jsxs("p",{className:"mt-3 font-mono text-body text-success-text",children:["Answered: ",h," · ",t.jsx("a",{href:ms(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})]}):t.jsxs("form",{onSubmit:k=>void y(k),className:"mt-3 flex flex-wrap items-center gap-2",children:[c.map(k=>t.jsx("button",{type:"button",onClick:()=>u(k),className:ae("border px-3 py-1.5 text-body hover:border-border-strong",d===k?"border-warning text-warning-text":"border-border"),children:k},k)),t.jsx(Ie,{value:d,onChange:k=>u(k.target.value),"aria-label":`Answer ${n}`,placeholder:c.length?"Or type an answer…":"Type an answer…",className:"h-9 min-w-[9rem] flex-1 font-sans text-lead"}),t.jsx(B,{type:"submit",variant:"solid",size:"sm",disabled:f||!d.trim(),children:f?"Sending…":"Send"}),b&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:b})]})]})}function R7({message:e,runs:n,agentName:s,at:r,onRunAgain:a}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),[f,x]=p.useState(new Set),b=n.filter(k=>!f.has(k.run_id)),g=n.length-b.length,h=async()=>{c(!0),u(null);const{started:k,problem:$}=await a(b);c(!1),u($),x(S=>new Set([...S,...k]))},v=g>0&&t.jsxs("span",{className:"font-mono text-small text-success-text",children:["Started again: ",g===1?"1 run":`${g} runs`]});if(!b.length)return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-border-strong","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 truncate font-mono text-small text-muted-foreground",children:e}),v]});const y=b[0],j=b.length===1;return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-destructive","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[j?t.jsxs("p",{className:"flex min-w-0 gap-3 text-lead",children:[t.jsx("span",{className:"shrink-0 font-mono text-small leading-5",children:s(y.agent_id)}),t.jsx("a",{href:ms(y.run_id),className:"min-w-0 truncate hover:underline",children:Nn(y)})]}):t.jsxs("p",{className:"text-lead",children:[b.length," runs failed ",t.jsxs("span",{className:"text-muted-foreground",children:["· ",[...new Set(b.map(k=>s(k.agent_id)))].join(", ")]})]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-small text-destructive-text",children:e}),!j&&t.jsxs("details",{className:"mt-1 text-body",children:[t.jsx("summary",{className:"cursor-pointer font-mono text-small text-muted-foreground",children:"The runs"}),t.jsx("ul",{className:"mt-1 space-y-1",children:b.map(k=>t.jsxs("li",{children:[t.jsx("a",{href:ms(k.run_id),className:"hover:underline",children:Nn(k)})," ",t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["· ",s(k.agent_id)]})]},k.run_id))})]}),d&&t.jsx("p",{className:"mt-1 font-mono text-small text-destructive-text",role:"alert",children:d})]}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:[bd(y.ended_at??y.created_at,r)," ago"]}),v,t.jsx(B,{type:"button",size:"sm",disabled:i,onClick:()=>void h(),children:j?"Run again":"Run all again"})]})}function aN({run:e,agentName:n}){var s;return t.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-small text-muted-foreground",children:[n," · ",Ko(Zn(e).runtime)]}),t.jsx("a",{href:ms(e.run_id),className:"text-lead hover:underline",children:Nn(e)}),e.status==="failed"&&t.jsx("p",{className:"mt-1 break-words text-small text-destructive-text",children:((s=e.error)==null?void 0:s.message)||"The run failed."}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Control and retries stay in your backend. ",e.status==="failed"?"Start another task in the original application.":"Stop or cancel this task in the original application."]})]}),t.jsx("a",{href:ms(e.run_id),className:"caps shrink-0 text-small text-muted-foreground hover:text-foreground",children:"Open"})]})}function A7({run:e,agentName:n,at:s,onStop:r}){var x;const[a,i]=p.useState(!1),[c,d]=p.useState(null),u=(x=e.cost)==null?void 0:x.usd,f=nd(e.cost)?`${Zr(e.cost)} so far`:u===0?"nothing spent yet":typeof u=="number"?`${Zr(e.cost)} so far`:xl(e.cost)?Zr(e.cost):"cost not known yet";return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-run-active ring-4 ring-run-active/[0.18]","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:n}),t.jsx("a",{href:ms(e.run_id),className:"min-w-0 flex-1 truncate text-lead hover:underline",children:Nn(e)}),t.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",ol(s-Date.parse(e.created_at))]}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:f}),!e.native&&t.jsx("a",{href:ms(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Steer"}),_m(e.status,e.state,e.kind,$m,!0,e.error,e.review).canStop?t.jsx(B,{type:"button",size:"sm",disabled:a,onClick:async()=>{i(!0),d(await r(e.run_id)),i(!1)},children:"Stop"}):t.jsx("a",{href:ms(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Open to cancel"}),c&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:c})]})}const O7=[{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 s$(e){var r;const n=["pi","claude-agent","codex"],s=e.filter(a=>a.available&&a.default_model);return s.sort((a,i)=>(n.indexOf(a.id)+1||99)-(n.indexOf(i.id)+1||99)),((r=s[0])==null?void 0:r.id)??null}function M7(e,n,s){const r=Tm(n,[...s]).filter(i=>i.available).map(i=>i.name),a=e.tools.find(i=>!r.includes(i));return a?{ok:!1,reason:`${a} can't run on this server yet`}:{ok:!0}}async function P7(e,n,s,r=dr()){const i=(await Gr(f=>e.listAgents({cursor:f}),f=>f.agents)).find(f=>f.definition.name===n.name&&!f.archived_at),c=(i==null?void 0:i.agent_id)??(await e.createAgent({definition:{version:1,name:n.name,description:n.description,instructions:n.instructions,harness:s,tools:n.tools,skills:[]}})).agent_id,d={input:{content:n.input}},{run:u}=await e.startRun(c,d,r.keyFor(n.name,d));return r.done(),u.run_id}const r$="agentrun.console.start-here.dismissed",L7={hello:Ga,web:yN,plan:uT};function I7(){try{return localStorage.getItem(r$)==="true"}catch{return!1}}function z7({harnesses:e,tools:n,onTry:s,imported:r=0,keySettings:a=!1,importAction:i,modelSetup:c}){const[d,u]=p.useState(I7),[f,x]=p.useState(!1),[b,g]=p.useState(!1),[h,v]=p.useState(null),[y,j]=p.useState(null),k=s$(e),$=async S=>{v(S.id),j(null);try{j(await s(S))}finally{v(null)}};return d?null:t.jsxs("section",{"aria-label":"Start here",className:"border bg-card p-5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-base font-semibold",children:"Bring your agents into view"}),t.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:"Connect your Claude Code or Codex setup on this server or another machine. Your coding agent helps choose a live connection or a history import. No model key needed to connect."}),r>0&&t.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:[r," imported ",r===1?"session":"sessions"," · ",t.jsx("a",{href:"#/runs",className:"text-primary-text underline-offset-4 hover:underline",children:"Browse history"})]})]}),t.jsx("button",{type:"button","aria-label":"Dismiss introduction",className:"shrink-0 p-1 text-muted-foreground hover:bg-accent hover:text-foreground",onClick:()=>{u(!0);try{localStorage.setItem(r$,"true")}catch{}},children:t.jsx(Qo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[t.jsx(Fm,{}),i,t.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-body text-muted-foreground hover:text-foreground","aria-expanded":f,onClick:()=>{g(!0),x(S=>!S)},children:["Run an agent here ",t.jsx(Tr,{className:`size-3.5 transition-transform ${f?"rotate-180":""}`,"aria-hidden":!0})]})]}),b&&t.jsxs("div",{hidden:!f,className:"mt-4 border-t pt-4",children:[c,k?t.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:O7.map(S=>{const N=M7(S,k,n),_=L7[S.id]??Ga;return t.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[t.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[t.jsx(_,{className:"size-4 text-primary-text","aria-hidden":!0}),S.name]}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:S.shows}),t.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:S.description}),N.ok?t.jsx(B,{type:"button",variant:S.id==="hello"?"solid":"outline",size:"sm",className:"mt-4 self-start",disabled:h!==null,onClick:()=>void $(S),children:h===S.id?"Starting…":"Try it"}):t.jsx("p",{className:"mt-4 font-mono text-small text-muted-foreground",children:N.reason})]},S.id)})}):!c&&t.jsxs("p",{className:"text-lead text-muted-foreground",children:["Running agents here needs a configured model. ",a?t.jsx("a",{href:"#/settings/keys",className:"text-primary-text underline-offset-4 hover:underline",children:"Set up models in Settings"}):"Configure a model where this server runs, then return here."]}),t.jsxs("p",{className:"mt-3 text-body text-muted-foreground",children:["Or ",t.jsx("a",{href:"#/agents/new",className:"text-primary-text underline-offset-4 hover:underline",children:"Create your own"}),": name it, say what it does, pick its tools."]}),y&&t.jsx("p",{className:"mt-3 font-mono text-body text-destructive-text",role:"alert",children:y})]})]})}const D7=["system","light","dark"],kx="agentrun.theme",F7="(prefers-color-scheme: dark)",Xm=()=>{try{return globalThis.localStorage??null}catch{return null}},o$=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(F7):null;let Nx=null;function U7(e=Xm()){try{const n=e==null?void 0:e.getItem(kx);return n==="light"||n==="dark"?n:"system"}catch{return"system"}}const Sx=(e=Xm())=>Nx??U7(e);function W7(e,n=Xm()){Nx=null;try{e==="system"?n==null||n.removeItem(kx):n==null||n.setItem(kx,e)}catch{Nx=e}}function Cx(e,n=document.documentElement,s=o$()){const r=e==="dark"||e==="system"&&!!(s!=null&&s.matches);n.classList.toggle("dark",r),n.classList.toggle("light",!r)}function H7(e=document.documentElement,n=o$(),s=Xm()){Cx(Sx(s),e,n);const r=()=>{Sx(s)==="system"&&Cx("system",e,n)};return n==null||n.addEventListener("change",r),()=>n==null?void 0:n.removeEventListener("change",r)}const B7={mission:"#/",playground:"#/playground",agents:"#/agents",runs:"#/runs",dojo:"#/dojo",templates:"#/templates",triggers:"#/triggers",settings:"#/settings/keys"},G7={system:["System",qa],light:["Light",ET],dark:["Dark",yT]};function q7(){const[e,n]=p.useState(()=>Sx()),s=r=>{W7(r),Cx(r),n(r)};return t.jsx("div",{role:"group","aria-label":"Theme",className:"flex gap-1 border p-1",children:D7.map(r=>{const[a,i]=G7[r];return t.jsx(B,{variant:"ghost",size:"sm","aria-label":a,title:a,"aria-pressed":e===r,onClick:()=>s(r),className:ae("flex flex-1 items-center justify-center py-1.5 text-muted-foreground hover:bg-accent hover:text-foreground",e===r&&"bg-accent text-foreground"),children:t.jsx(i,{className:"size-4","aria-hidden":!0})},r)})})}function iN(){return t.jsxs("span",{className:"inline-flex items-center whitespace-nowrap text-lg font-semibold font-mono","aria-label":"AgentRun",children:[t.jsx("svg",{viewBox:"0 0 64 64",className:"mr-1 size-4 text-primary-text","aria-hidden":!0,children:t.jsx("path",{d:"M18 12L42 32L18 52",fill:"none",stroke:"currentColor",strokeWidth:"8",strokeLinecap:"square",strokeLinejoin:"miter"})}),"agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})}function K7({active:e,settings:n=!1,triggers:s=!1,banners:r,building:a=!1,onBuild:i,onNavigate:c,onSignOut:d,onSignOutEverywhere:u,children:f}){const[x,b]=p.useState(!1),[g,h]=p.useState(!1),v=p.useRef(null),y=p.useRef(null),j=p.useRef(!1);p.useEffect(()=>{var O,A;g?(O=y.current)==null||O.focus():j.current&&((A=v.current)==null||A.focus())},[g]);const k=()=>{j.current=!0,h(!1)},[$,S]=p.useState(!0),N=e==="agents"||e==="runs"||e==="templates";p.useEffect(()=>{(N||a)&&S(!0)},[e,a]);const _=O=>{c?c(O):location.hash=B7[O],b(!1)},E=()=>{i?i():location.hash="#/agents/new",b(!1)};return t.jsxs("div",{className:"relative flex h-dvh min-h-0 flex-col overflow-hidden bg-background text-foreground roomy:flex-row",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b px-4 roomy:hidden",children:[t.jsx("button",{type:"button",onClick:()=>_("mission"),"aria-label":"AgentRun home",children:t.jsx(iN,{})}),t.jsx(B,{size:"icon","aria-label":"Navigation","aria-expanded":x,onClick:()=>b(O=>!O),children:t.jsx(gT,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("aside",{className:ae("shrink-0 flex-col border-r bg-background roomy:flex roomy:h-dvh roomy:overflow-y-auto roomy:w-sidebar",x?"flex max-h-[60dvh] overflow-y-auto border-b roomy:max-h-none":"hidden"),children:[t.jsx("div",{className:"hidden h-12 shrink-0 items-center border-b px-4 roomy:flex",children:t.jsx("button",{type:"button",onClick:()=>_("mission"),"aria-label":"AgentRun home",children:t.jsx(iN,{})})}),t.jsxs("nav",{"aria-label":"Navigation",className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-3 pt-3",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsxs(xr,{className:"w-full",active:e==="mission",onClick:()=>_("mission"),children:[t.jsx(dT,{className:"size-4 shrink-0","aria-hidden":!0}),"Mission Control"]}),t.jsxs(xr,{className:"w-full",active:e==="playground",onClick:()=>_("playground"),children:[t.jsx(tm,{className:"size-4 shrink-0","aria-hidden":!0}),"API playground"]}),t.jsxs("div",{children:[t.jsxs(xr,{className:ae("w-full",N&&"text-primary-text"),"aria-expanded":$,"aria-controls":"agent-navigation",onClick:()=>S(O=>!O),children:[t.jsx(mf,{className:"size-4 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"flex-1",children:"Agents"}),t.jsx(Tr,{className:ae("size-3.5 transition-transform",!$&&"-rotate-90"),"aria-hidden":!0})]}),t.jsxs("div",{id:"agent-navigation",hidden:!$,className:"space-y-0.5",children:[t.jsxs(xr,{className:"w-full pl-8",active:a,onClick:E,children:[t.jsx(iT,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Build"]}),t.jsxs(xr,{className:"w-full pl-8",active:e==="agents"&&!a,onClick:()=>_("agents"),children:[t.jsx(mf,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Connected agents"]}),t.jsxs(xr,{className:"w-full pl-8",active:e==="templates",onClick:()=>_("templates"),children:[t.jsx(Ax,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Templates"]}),t.jsxs(xr,{className:"w-full pl-8",active:e==="runs",onClick:()=>_("runs"),children:[t.jsx(Kc,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Runs"]})]})]}),s&&t.jsxs(xr,{className:"w-full",active:e==="triggers",onClick:()=>_("triggers"),children:[t.jsx(em,{className:"size-4 shrink-0","aria-hidden":!0}),"Triggers"]}),t.jsxs(xr,{className:"w-full",active:e==="dojo",onClick:()=>_("dojo"),children:[t.jsx(pC,{size:16,className:"shrink-0"}),"Learning Dojo"]})]}),n&&t.jsx("div",{"data-sidebar-account":!0,className:"mt-auto border-t pb-2 pt-3",children:t.jsxs(xr,{className:"w-full",active:e==="settings",onClick:()=>_("settings"),children:[t.jsx(wN,{className:"size-4 shrink-0","aria-hidden":!0}),"Settings"]})})]}),t.jsxs("div",{className:"shrink-0 space-y-2 px-3 pb-4 pt-3",children:[t.jsx(q7,{}),t.jsxs(B,{onClick:d,className:"w-full justify-start",children:[t.jsx(mT,{"aria-hidden":!0}),"Sign out"]}),u&&(g?t.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:O=>{O.key==="Escape"&&k()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[t.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"xs",variant:"destructive",onClick:()=>{h(!1),u()},children:"Sign out everywhere"}),t.jsx(B,{size:"xs",ref:y,onClick:k,children:"Cancel"})]})]}):t.jsx(B,{size:"sm",variant:"ghost",ref:v,onClick:()=>h(!0),className:"mt-1 w-full justify-start text-muted-foreground hover:text-foreground",children:"Sign out everywhere"}))]})]}),t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx(yU,{}),r,t.jsx("main",{className:"relative min-h-0 min-w-0 flex-1 overflow-auto",children:f})]})]})}const vg={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},lN={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 V7({mode:e,code:n=null,codeNeeded:s=!1,onSubmit:r,problem:a=null,offer:i=null}){const[c,d]=p.useState(""),[u,f]=p.useState(!1),[x,b]=p.useState(""),[g,h]=p.useState(n??"");p.useEffect(()=>{n!==null&&h(n)},[n]);const[v,y]=p.useState(a),[j,k]=p.useState(!1),$=e==="setup",S=$&&i!==null&&!("sessions"in i&&i.sessions===0),N=$&&(s||n!==null),_=e!=="token_link"&&c.length>0&&(!$||c===x&&c.length>=12)&&(!N||g.trim()!==""),E=async()=>{if(!_||!r)return;k(!0);const O=await r(c,N&&g.trim()?g.trim():void 0,$&&S&&u);k(!1),y(O)};return t.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:t.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[t.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[t.jsx(Cs,{className:"size-5 text-primary-text","aria-hidden":!0}),t.jsxs("span",{children:["agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl",children:lN[e].title}),t.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:lN[e].body}),e!=="token_link"&&t.jsxs("form",{className:"space-y-5",onSubmit:O=>{O.preventDefault(),E()},children:[N&&t.jsx(jt,{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:t.jsx(Ie,{name:"setup-code",value:g,onChange:O=>h(O.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),t.jsx(jt,{label:vg[e].label,note:$?"12 characters or more.":void 0,children:t.jsxs("span",{className:ae(Pc,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Ma,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Ie,{bare:!0,type:"password",value:c,onChange:O=>d(O.target.value),autoComplete:vg[e].autocomplete,autoFocus:!0,"aria-label":vg[e].label,className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),$&&t.jsx(jt,{label:"Again",note:x&&x!==c?"The two passwords differ.":void 0,children:t.jsxs("span",{className:ae(Pc,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Ma,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Ie,{bare:!0,type:"password",value:x,onChange:O=>b(O.target.value),autoComplete:"new-password","aria-label":"Password again",className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),S&&t.jsxs("label",{className:"flex items-start gap-3 text-lead",children:[t.jsx("input",{type:"checkbox",name:"import",checked:u,onChange:O=>f(O.target.checked),className:"mt-1 size-4 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"block",children:"Import this machine's Claude Code, Codex and pi sessions"}),t.jsx("span",{className:"mt-1 block text-small text-muted-foreground","aria-live":"polite",children:Y7(i)})]})]}),t.jsx(B,{type:"submit",variant:"solid",disabled:!_||j,"aria-busy":j||void 0,className:"w-full text-body",children:j?"Signing in":$?"Set password and continue":"Continue"}),v&&t.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:v}),!$&&t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:["Forgot it? Where the server runs: ",t.jsx("code",{className:"font-mono text-foreground",children:"npx @parcha/agentrun reset-password"})," (add"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data DIR"})," if you started it with one). For a server you started yourself:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"agentrun-serve reset-password --data DIR"})," (in the image:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data /data"}),"). The next visit here sets a new one."]})]})]})})}const cN=(e,n)=>`${e.toLocaleString("en-US")} ${n}${e===1?"":"s"}`,yg="Each project becomes an agent, each session a run you can read.";function Y7(e){return"counting"in e?`Counting sessions… ${yg}`:e.sessions===null||e.projects===null?`The count isn't known. ${yg}`:`${cN(e.sessions,"session")} in ${cN(e.projects,"project")}. ${yg}`}function Q7({problem:e,starting:n=!1,onRetry:s}){return t.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:t.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[t.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[t.jsx(Cs,{className:"size-5 text-primary-text","aria-hidden":!0}),t.jsxs("span",{children:["agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl",children:n?"This server is starting":"Can't read this server's sign-in"}),t.jsx("p",{className:"mb-4 text-prose leading-relaxed text-muted-foreground",children:n?"Its address answers for it until it is up (a first start, a redeploy or a wake can take a minute or two). Trying again…":"The page asked the server whether it has its owner yet, and got no answer it could read, so it can't show setup or sign-in. It asks again on its own."}),t.jsx("p",{className:"mb-6 break-words font-mono text-body text-destructive-text",role:"alert",children:e}),t.jsx(B,{type:"button",variant:"solid",onClick:s,className:"w-full text-body",children:"Retry now"})]})})}const a$=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.accounts)===!1};function J7(e,n){if(a$(e))return n===200?"signed_in":"token_link";const s=e.body??{};return s.signed_in?"signed_in":s.password_set?"sign_in":"setup"}const X7=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.setup_code)===!0};function Z7(e){var n,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=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message}function i$(e){const n=new URLSearchParams(e.startsWith("#")?e.slice(1):e),s=n.get("code");if(s===null)return{code:null,rest:e};n.delete("code");const r=n.toString();return{code:/^[A-Za-z0-9_-]*/.exec(s)[0],rest:r?`#${r}`:""}}const eB=1e4;function dN(e=location.hash){if(e==="#/dojo")return{section:"dojo"};const n=e.match(/^#\/observations\/([^/?]+)$/);if(n)return{section:"agents",observation:decodeURIComponent(n[1])};let s=e.match(/^#\/runs\/([^/?]+)$/);if(s)return{section:"runs",run:decodeURIComponent(s[1])};if(e==="#/agents/connect"||e.startsWith("#/agents/connect?")){const c=new URLSearchParams(e.split("?")[1]??"").get("source");return{section:"agents",nativeConnect:!0,...c==="remote"||c==="observe"?{connectionSource:c}:{}}}if(e==="#/agents/new")return{section:"agents",agent:null};if(s=e.match(/^#\/agents\/([^/?]+)\/learning\?(.*)$/),s)return{section:"agents",agent:decodeURIComponent(s[1]),tab:"learning",notes:new URLSearchParams(s[2]).getAll("note")};if(s=e.match(/^#\/agents\/([^/?]+)\/edit\?(.*)$/),s){const c=new URLSearchParams(s[2]).get("tool");return{section:"agents",agent:decodeURIComponent(s[1]),edit:!0,...c?{tool:c}:{}}}if(s=e.match(/^#\/agents\/([^/?]+)(?:\/([a-z]+))?$/),s)return{section:"agents",agent:decodeURIComponent(s[1]),...s[2]==="edit"?{edit:!0}:s[2]?{tab:s[2]}:{}};if(e.startsWith("#/agents"))return{section:"agents",archived:/[?&]archived=true\b/.test(e)};if(e.startsWith("#/playground")){const c=new URLSearchParams(e.split("?")[1]??""),d=c.get("agent"),u=c.get("operation"),f=c.get("draft");if(u==="apply-template"){const x=c.get("template");return{section:"playground",operation:u,...x?{template:x}:{},...f!==null?{draft:f}:{}}}return{section:"playground",...d?{playgroundAgent:d}:{},...u==="create-agent"||u==="edit-agent"||u==="list-runs"?{operation:u}:{},...f!==null?{draft:f}:{},...u==="list-runs"&&Vf.includes(c.get("status"))?{status:c.get("status")}:{},...u==="list-runs"&&c.get("archived")==="true"?{archived:!0}:{}}}if(s=e.match(/^#\/templates\/install\?(.*)$/),s)return{section:"templates",install:new URLSearchParams(s[1]).get("src")??""};if(s=e.match(/^#\/templates\/([^/?]+)$/),s)return{section:"templates",template:decodeURIComponent(s[1])};if(e.startsWith("#/templates"))return{section:"templates"};if(e==="#/triggers/new")return{section:"triggers",trigger:null,kind:"schedule"};if(e==="#/triggers/new-webhook")return{section:"triggers",trigger:null,kind:"webhook"};if(e==="#/triggers/new-github")return{section:"triggers",trigger:null,kind:"github"};if(e==="#/triggers/new-composio")return{section:"triggers",trigger:null,kind:"composio"};if(s=e.match(/^#\/triggers\/([^/?]+)(\/edit)?$/),s)return{section:"triggers",trigger:decodeURIComponent(s[1]),...s[2]?{edit:!0}:{}};if(e.startsWith("#/triggers"))return{section:"triggers"};if(s=e.match(/^#\/settings\/mcp(?:\?(.*))?$/),s){const c=GL(s[1]);return{section:"settings",settings:"mcp",signIn:JL(s[1]),...c?{add:c}:{}}}if(s=e.match(/^#\/settings\/github(?:\?(.*))?$/),s){const c=SU(s[1]);return{section:"settings",settings:"github",...c?{github:c}:{}}}if(s=e.match(/^#\/settings(?:\/(keys|tools|email|computers|workspace|webhook))?$/),s)return{section:"settings",settings:s[1]??"keys"};if(e===""||e==="#"||e==="#/"||e.startsWith("#/start")||e.startsWith("#/mission"))return{section:"mission"};if(!e.startsWith("#/runs?"))return{section:"runs"};const r=new URLSearchParams(e.slice(7)),a=r.get("agent"),i=r.get("status");return{section:"runs",...a?{runsOf:a}:{},...i&&Vf.includes(i)?{status:i}:{},...r.get("archived")==="true"?{archived:!0}:{}}}function tB({runsOf:e,status:n,archived:s}){const r=new URLSearchParams;return e&&r.set("agent",e),n&&r.set("status",n),s&&r.set("archived","true"),`#/runs${r.size?`?${r}`:""}`}let bg;function nB(){if(!bg){const{code:e,rest:n}=i$(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${n}`),bg={code:e}}return bg.code}const sB=e=>Math.min(1e3*2**e,3e4),l$=1e3,rB=30;function oB(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 aB(){const[e]=p.useState(PM),[n,s]=p.useState(null),[r,a]=p.useState(!1),i=p.useRef(null);i.current=n;const c=p.useRef(!1),d=p.useRef(async()=>{}),u=p.useMemo(()=>jM({fetch:e.fetch,onSignedOut:()=>void d.current()}),[e]),[f,x]=p.useState(nB);p.useEffect(()=>{if(n!=="setup")return;const E=()=>{const{code:O,rest:A}=i$(location.hash);O!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${A}`),x(O))};return window.addEventListener("hashchange",E),E(),()=>window.removeEventListener("hashchange",E)},[n]);const[b,g]=p.useState(!1),h=async()=>{const E=await u.session(),O=a$(E)?await u.listAgents().then(()=>200,A=>A instanceof ze?A.status:0):void 0;return{mode:J7(E,O),codeNeeded:X7(E)}},v=async()=>{const E=await h();return g(E.codeNeeded),E.mode},y=async()=>s(await v());d.current=async()=>{if(!(i.current!=="signed_in"||c.current)){c.current=!0;try{const E=await v();E!=="signed_in"&&i.current==="signed_in"&&(a(!0),s(E))}catch{}finally{c.current=!1}}};const[j,k]=p.useState(null),[$,S]=p.useState(0);p.useEffect(()=>{let E=!0,O;return h().then(A=>{!E||i.current!==null||(g(A.codeNeeded),s(A.mode),k(null))},A=>{if(!E||i.current!==null)return;const I=sB($),M=A instanceof ze?A:null,R=(M==null?void 0:M.code)==="http_error",P=R&&[502,503,504].includes(M.status);k({problem:M===null?Dt(A):P?`Its address answered ${M.status}, not the server.`:`GET /v2/auth/session answered ${M.status}${R?", not as this server answers":`: ${M.message}`}`,starting:P}),O=setTimeout(()=>S(D=>D+1),I)}),()=>{E=!1,clearTimeout(O)}},[u,$]);const[N,_]=p.useState(null);return p.useEffect(()=>{if(n!=="setup")return;let E=!0;return(async()=>{for(let O=!1;E;){const A=await u.setupImport().then(I=>I,()=>{});if(!E)return;if(A===void 0&&O)return void _({projects:null,sessions:null});if(A!==void 0&&(!A||!("counting"in A||"sessions"in A)||(_(A),O=!0,!("counting"in A))))return;await new Promise(I=>setTimeout(I,l$))}})(),()=>{E=!1}},[u,n]),n===null&&j!==null?t.jsx(Q7,{problem:j.problem,starting:j.starting,onRetry:()=>S(E=>E+1)}):n===null?t.jsx($0,{connection:e,children:t.jsx(iB,{})}):n!=="signed_in"?t.jsx(V7,{mode:n,code:f,codeNeeded:b,offer:N,problem:r&&n==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async(E,O,A)=>{try{return await(n==="setup"?u.setup(E,O,A):u.signIn(E)),a(!1),s("signed_in"),null}catch(I){return I instanceof ze&&I.status===403&&n==="setup"&&await y().catch(()=>{}),I instanceof ze?Z7(I):I instanceof Error?I.message:String(I)}}},n):t.jsx($0,{connection:e,children:t.jsx(lB,{v2:u,onSignedOut:()=>{a(!1),s("sign_in")}})})}function iB(){return my().state==="offline"?t.jsx(bU,{}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function lB(e){const n=p.useMemo(gd,[e.v2]);return t.jsx(cB,{...e},n)}function cB({v2:e,onSignedOut:n}){var sa,xs,jd,ss,kd,Nd,Sd,ra,oa,io,aa,Cd,Ed,ei,wl,ti,lo,$d,ni,$t,jl,kl,si,Nl,Sl,Cl,ri,ia,Qs,Js,Xs;const{writable:s,whyNot:r}=FF(e),[a,i]=p.useState(null),[c,d]=p.useState(()=>dN()),[u,f]=p.useState(null),x=((xs=(sa=u==null?void 0:u.features)==null?void 0:sa.triggers)==null?void 0:xs.routes)===!0,[b,g]=p.useState(new Map);p.useEffect(()=>{if(!x)return;let ge=!0;return e.listTriggers().then(Ce=>{ge&&g(new Map(Ce.triggers.map(Pe=>[Pe.id,{name:Pe.name,kind:Pe.source.kind}])))},()=>{}),()=>{ge=!1}},[e,x,c.section,c.trigger]);const[h,v]=p.useState(null),[y,j]=p.useState(null),[k,$]=p.useState(0),[S,N]=p.useState("30d"),_=S==="7d"?7:30,E=hv(e,{active:c.section==="mission"||c.section==="runs"&&!c.run&&!c.runsOf&&!c.archived&&!c.status,days:_}),[O,A]=p.useState(null),[I,M]=p.useState(!1),R=p.useRef(!1),[P,D]=p.useState(null),[W,Y]=p.useState(null),[H,q]=p.useState(null),[F,G]=p.useState(0),U=p.useRef(null),[z,Q]=p.useState(!1),[K,Z]=p.useState(!1),[de,re]=p.useState(!1),[fe,ve]=p.useState(null),[Ee,ue]=p.useState(null),[pe,me]=p.useState(!1),[ke,$e]=p.useState({}),[J,Le]=p.useState(!1),qe=p.useRef(0),[rt,vt]=p.useState([]),st=p.useRef(-1),[Se,Be]=p.useState(null),[he,Ve]=p.useState(0),ct=p.useRef(0),Me=ge=>{Gu(ge)||(location.hash=ge)},[ot,oe]=p.useState(null),[xe,Ae]=p.useState(0);p.useEffect(()=>{let ge=!0;return(async()=>{let Ce=!1;for(let Pe=0;ge&&Pe<rB;){const _t=await e.setupImport().then(wt=>wt,()=>{});if(!ge)return;if(_t===void 0)Pe+=1;else{if(Pe=0,!_t||!("state"in _t))return;if(oe(_t),_t.state!=="running")return void(Ce&&Ae(wt=>wt+1));Ce=!0}await new Promise(wt=>setTimeout(wt,l$))}})(),()=>{ge=!1}},[e]),p.useEffect(()=>{const ge=()=>{const Ce=_W();Gu(location.hash,()=>{Ce&&history.go(-Ce)})?Ce&&history.go(Ce):d(dN())};return window.addEventListener("hashchange",ge),()=>window.removeEventListener("hashchange",ge)},[]),p.useEffect(()=>$W(),[]);const De=p.useRef(0),ut=p.useRef(!1),ee=()=>{const ge=++De.current;return e.capabilities().then(Ce=>(ge===De.current&&f(Ce),!0),()=>!1)};p.useEffect(()=>{ee()},[e]),p.useEffect(()=>{if(qe.current&&c.section!=="runs"&&c.section!=="mission"&&st.current===xe)return;st.current=xe;const ge=++qe.current;Le(!1),Promise.allSettled([!1,!0].map(Ce=>Gr(Pe=>e.listAgents({archived:Ce,cursor:Pe}),Pe=>Pe.agents))).then(Ce=>{if(ge!==qe.current)return;const Pe=Object.fromEntries(Ce.flatMap(wt=>wt.status==="fulfilled"?wt.value:[]).map(wt=>[wt.agent_id,wt.definition.name??wt.agent_id])),_t=Ce.every(wt=>wt.status==="fulfilled");$e(wt=>_t?Pe:{...wt,...Pe}),Le(_t)})},[e,c,xe]);const Re={status:c.status,archived:c.archived};p.useEffect(()=>{if(c.section!=="runs"||c.run)return;const ge=++ct.current;ve(null),Be(null),(c.runsOf?e.listAgentRuns(c.runsOf,50,null,Re):e.listRuns(50,null,Re)).then(Ce=>{ge===ct.current&&(ve(Ce.runs),ue(Ce.next_cursor))}).catch(Ce=>{ge===ct.current&&Be(Ft(Ce,"the runs"))})},[e,c,xe,he]);const Qe=ge=>{var Ce;return ke[ge]??((Ce=Nt==null?void 0:Nt.find(Pe=>Pe.agent_id===ge))==null?void 0:Ce.definition.name)??(J?ge:"")},Ze=u,at={harnesses:(Ze==null?void 0:Ze.harnesses)??[],tools:IP(Ze==null?void 0:Ze.tools),thinking:((jd=Ze==null?void 0:Ze.features)==null?void 0:jd.thinking)??[],...typeof((ss=u==null?void 0:u.limits)==null?void 0:ss.free_model_requests)=="number"?{freeRequests:u.limits.free_model_requests}:{}},Xe=hD(Ze==null?void 0:Ze.tools),pt=gD(Ze==null?void 0:Ze.tools),et=[...(Nd=(kd=u==null?void 0:u.features)==null?void 0:kd.tool_keys)!=null&&Nd.routes?["keys"]:[],...Xe.length||pt.length?["tools"]:[],"mcp","github","email","computers","workspace",...(ra=(Sd=u==null?void 0:u.features)==null?void 0:Sd.webhooks)!=null&&ra.routes?["webhook"]:[]],kt=ge=>Me({runs:"#/runs",agents:"#/agents",playground:"#/playground",dojo:"#/dojo",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${et[0]??"keys"}`}[ge]),Ct=p.useRef(dr()).current,Tn=async ge=>{const Ce=s$(at.harnesses);if(!Ce)return"This server has no model to run it on yet.";try{const Pe=await P7(e,ge,Ce,Ct);return Me(`#/runs/${encodeURIComponent(Pe)}`),null}catch(Pe){return Dt(Pe)}},dn=((h==null?void 0:h.analytics.by_source)??[]).filter(ge=>ge.source!=="live").reduce((ge,Ce)=>ge+Ce.runs,0),[Nt,Rn]=p.useState(null),[hs,Ys]=p.useState([]),[Cn,Un]=p.useState(null),ps=p.useRef(Cn);ps.current=Cn;const[gs,un]=p.useState(null),[Wn,$s]=p.useState(0),Hn=p.useRef(0);p.useEffect(()=>{Rn(null),un(null),Un(null),ps.current=null},[e,c.section,c.operation,c.playgroundAgent]),p.useEffect(()=>{if(c.section!=="playground"||c.operation)return;un(null);const ge=++Hn.current;return Gr(Ce=>e.listAgents({cursor:Ce}),Ce=>Ce.agents).then(Ce=>{var wt;if(ge!==Hn.current)return;const Pe=Ce.filter(rs=>!rs.archived_at),_t=ps.current??c.playgroundAgent;if(_t&&!Pe.some(rs=>rs.agent_id===_t)){Rn(null),Un(null),un("The selected agent is unavailable or archived. Choose another agent from Agents.");return}Rn(Ce),Un(_t??((wt=Pe[0])==null?void 0:wt.agent_id)??null)}).catch(Ce=>{if(ge===Hn.current){const Pe=Ft(Ce,"the agents");un(`${Pe.why} ${Pe.next}${Pe.said?` (${Pe.said})`:""}`)}}),()=>{Hn.current++}},[e,c.section,c.operation,c.playgroundAgent,Wn,xe]),p.useEffect(()=>{if(c.section!=="mission")return;let ge=!0;R.current=!0,j(null),M(!0);const Ce=vv(S);return Promise.all([e.statsOver({...Ce?{from:Ce}:{},...O?{agent:O}:{}}),O?e.listAgentRuns(O,10):e.listRuns(10)]).then(([Pe,_t])=>{ge&&(v(HM(Pe,_t.runs)),O||q(wt=>wt||aU(_t.runs,Pe.analytics.by_source)))}).catch(Pe=>{ge&&j(Ft(Pe,"Mission Control"))}).finally(()=>{ge&&(R.current=!1,M(!1))}),()=>{ge=!1,R.current=!1}},[e,c.section,k,S,O,xe]),$E(()=>$(ge=>ge+1)),p.useEffect(()=>{if(c.section!=="mission")return;const ge=()=>{!document.hidden&&!R.current&&$(Pe=>Pe+1)};window.addEventListener("focus",ge),document.addEventListener("visibilitychange",ge);const Ce=setInterval(ge,15e3);return()=>{window.removeEventListener("focus",ge),document.removeEventListener("visibilitychange",ge),clearInterval(Ce)}},[c.section]),p.useEffect(()=>{if(c.section!=="mission"){U.current=null;return}let ge=!0;const Ce=U,Pe=Bn=>Gr(Gn=>e.listRuns(50,Gn,{status:Bn}),Gn=>Gn.runs,2),_t=()=>Gr(Bn=>e.listAgents({archived:!1,cursor:Bn}),Bn=>Bn.agents).then(Bn=>{ge&&vt(Bn.filter(Gn=>Of(Gn)>0).map(Gn=>({agent_id:Gn.agent_id,name:Gn.definition.name??Gn.agent_id,pending:Of(Gn)})))},()=>{}),rs=lU(()=>Promise.allSettled([Pe("input_required"),Pe("failed"),Pe("working"),_t()]).then(([Bn,Gn,oi])=>{var co,uo,Ar;if(!ge)return;const Rr=[Bn,Gn,oi],Zm=Date.now()-oU;if(Y(k0(null,Rr).problem),((co=Rr[0])==null?void 0:co.status)==="fulfilled"&&Q(!0),((uo=Rr[1])==null?void 0:uo.status)==="fulfilled"){Z(!0);const Or=Rr[1].value.map(fr=>fr.run_id),fo=Ce.current;fo&&Or.some(fr=>!fo.has(fr))&&$(fr=>fr+1),Ce.current=new Set(Or)}((Ar=Rr[2])==null?void 0:Ar.status)==="fulfilled"&&re(!0),D(Or=>{const{needs:fo}=k0(Or,Rr);return{asking:fo.asking.filter(CE),failed:fo.failed.filter(fr=>Date.parse(fr.ended_at??fr.created_at)>Zm),live:fo.live}})}),1e4);return()=>{ge=!1,rs()}},[e,c.section,F]);const _s=p.useRef(Uz()).current,Ts=()=>setTimeout(()=>G(ge=>ge+1),2500),An=async(ge,Ce)=>{try{return await tC(_s(ge),ge,Ce,e.sendMessage),Ts(),null}catch(Pe){return Dt(Pe)}},te=p.useRef(new Map).current,Oe=async ge=>{const Ce=[];try{for(const Pe of ge){const _t=iU(Pe.kind==="workflow"?Pe:await e.getRun(Pe.run_id));if("refusal"in _t)throw new Error(_t.refusal);const wt=te.get(Pe.run_id)??gd();te.set(Pe.run_id,wt),await e.startRun(Pe.agent_id,_t.body,wt),Ce.push(Pe.run_id)}return Ts(),{started:Ce,problem:null}}catch(Pe){return Ce.length&&Ts(),{started:Ce,problem:Dt(Pe)}}},ft=async ge=>{try{return await e.stop(ge),Ts(),null}catch(Ce){return Dt(Ce)}},Ot=async(ge,Ce,Pe,_t,wt)=>{let rs=null;try{await e.answerApproval(ge,Ce,Pe,_t,wt)}catch(Bn){rs=RE(Bn)}return G(Bn=>Bn+1),rs},Vt=async(ge,Ce)=>{let Pe=null;try{await e.handBackComputer(ge,Ce)}catch(_t){Pe=yx(_t,"hand")}return G(_t=>_t+1),Pe},Fe=p.useRef(0);p.useEffect(()=>{const ge=++Fe.current;Ys([]),Cn&&Gr(Ce=>e.listRevisions(Cn,Ce),Ce=>Ce.revisions).then(Ce=>{ge===Fe.current&&Ys(Ce)}).catch(()=>{})},[e,Cn]);const ne=async(ge,Ce,Pe)=>{const _t=performance.now();try{const wt=await e.startRun(ge,Ce,Pe);return{status:wt.status,ms:Math.round(performance.now()-_t),body:wt.run,runId:wt.run.run_id}}catch(wt){return fy(wt,Math.round(performance.now()-_t))}},ye=((oa=u==null?void 0:u.features)==null?void 0:oa.efforts)??[],We=u?((io=u.features)==null?void 0:io.learning)??null:void 0;at.learning=We??void 0;const St=(aa=u==null?void 0:u.models)==null?void 0:aa.ready;p.useEffect(()=>{if(St!==!1)return;const ge=()=>{ut.current||(ut.current=!0,ee().finally(()=>{ut.current=!1}))},Ce=()=>ee(),Pe=setInterval(ge,eB);return window.addEventListener("focus",Ce),()=>{clearInterval(Pe),window.removeEventListener("focus",Ce)}},[e,St]);const[Lt,it]=p.useState(null);p.useEffect(()=>{if(St!==!1)return;let ge=!0;return e.chatGPT().then(Ce=>{ge&&it(Tf(Ce))},()=>{ge&&it(null)}),()=>{ge=!1}},[e,St]);const[yn,En]=p.useState(!1),ur=ge=>{it(ge),(ge.state==="pending"||ge.state==="signed_in")&&En(!0),ge.state==="signed_in"&&ee()},Ut=(Cd=Nt==null?void 0:Nt.find(ge=>ge.agent_id===Cn))==null?void 0:Cd.definition,Za=(Ut==null?void 0:Ut.native)||Zn(Ut),ao=c.operation?c.playgroundAgent:Cn??c.playgroundAgent;return t.jsx(kE.Provider,{value:b,children:t.jsx(K7,{active:c.section,building:c.section==="agents"&&c.agent===null,onBuild:()=>Me("#/agents/new"),settings:et.length>0,triggers:x,onNavigate:kt,onSignOut:()=>{const ge=()=>void e.signOut().then(n,Ce=>i(Ce instanceof ze?Ce.message:"The sign-out did not reach the server. Try again."));Gu(null,ge)||ge()},onSignOutEverywhere:()=>{const ge=()=>void e.signOutEverywhere().then(n,Ce=>i(Ce instanceof ze?Ce.message:"The sign-out did not reach the server. Try again."));Gu(null,ge)||ge()},banners:t.jsxs(t.Fragment,{children:[a&&t.jsxs("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-destructive-text md:px-8",role:"alert",children:["Not signed out: ",a]}),ot&&t.jsxs("p",{className:"flex items-center gap-3 border-b bg-card px-5 py-3 font-mono text-body md:px-8",role:"status",children:[t.jsx("span",{className:"flex-1",children:oB(ot)}),ot.state!=="running"&&t.jsx(B,{size:"xs",type:"button",onClick:()=>oe(null),children:"Dismiss"})]})]}),children:c.section==="settings"?t.jsx(jU,{active:c.settings??"keys",offered:et,children:c.settings==="tools"?t.jsx(NU,{v2:e,choices:Xe,gates:pt,harnesses:at.harnesses,mcp:!!((Ed=u==null?void 0:u.features)!=null&&Ed.mcp_client),onSaved:ee,onOpen:ee}):c.settings==="mcp"?t.jsx(AU,{v2:e,signIn:c.signIn,add:c.add,writable:s,whyNot:r,choices:Xe}):c.settings==="github"?t.jsx(_U,{v2:e,returned:c.github}):c.settings==="email"?t.jsx(ZU,{v2:e,writable:s,whyNot:r}):c.settings==="computers"?t.jsx(oW,{v2:e,writable:s,whyNot:r}):c.settings==="workspace"?t.jsx(gW,{v2:e,writable:s,whyNot:r}):c.settings==="webhook"?t.jsx(tW,{v2:e}):t.jsx(pU,{v2:e,onChange:ee,writable:s,whyNot:r,harnesses:at.harnesses,plan:t.jsx(BF,{v2:e,writable:s,whyNot:r,onChange:()=>void ee()})})}):c.section==="dojo"?t.jsx(ID,{v2:e,server:We},xe):c.section==="mission"?t.jsx("div",{className:"flex h-full flex-col",children:t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(k7,{hasObservedSessions:!!((ei=E.data)!=null&&ei.sessions.length),observations:t.jsx(pv,{read:E,view:"summary",days:_}),view:h,error:y,onRetry:()=>$(ge=>ge+1),actions:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"icon","aria-label":"Refresh Mission Control",disabled:I,onClick:()=>{$(ge=>ge+1),G(ge=>ge+1)},children:t.jsx(Yo,{className:"size-4","aria-hidden":!0})}),t.jsx(tn,{label:"Query",prompt:Em(location.origin,O??void 0),playgroundHref:gv(O??void 0)}),t.jsx(Fm,{variant:"primary"})]}),scope:{range:S,onRange:N,agent:O,onAgent:A,refreshing:I&&h!==null},asking:P&&z?P.asking.length:null,failed:P&&K?SE(P.failed):null,live:P&&de?P.live.length:null,needsYou:P&&t.jsx(S7,{asking:P.asking,failed:P.failed,failedAll:h==null?void 0:h.runs.failed,live:P.live,learning:rt,problem:W,agentName:Qe,onAnswer:An,onApprove:Ot,onHandBack:Vt,onRunAgain:Oe,onStop:ft}),startHere:H===!1&&!((wl=E.data)!=null&&wl.sessions.length)?t.jsx(z7,{harnesses:at.harnesses,tools:at.tools,onTry:Tn,imported:dn,keySettings:((lo=(ti=u==null?void 0:u.features)==null?void 0:ti.tool_keys)==null?void 0:lo.routes)===!0&&u.features.tool_keys.at_rest==="sealed",modelSetup:u&&(u.models.ready===!1||yn)?t.jsx(qU,{v2:e,needs:u.models.needs,model:u.models.default,onSaved:ee,writable:s,whyNot:r,plan:Lt,harnesses:at.harnesses,onPlan:ur,onDone:()=>En(!1)}):void 0}):void 0})})}):c.section==="templates"?t.jsx(x0,{v2:e,name:c.template,install:c.install,go:Me},c.install!==void 0?`install:${c.install}`:c.template??""):c.section==="triggers"?t.jsx(f8,{v2:e,view:{trigger:c.trigger,kind:c.kind,edit:c.edit},go:Me,agentName:Qe,minEvery:(ni=($d=u==null?void 0:u.features)==null?void 0:$d.triggers)==null?void 0:ni.min_every_s,failuresToPause:(jl=($t=u==null?void 0:u.features)==null?void 0:$t.triggers)==null?void 0:jl.failures_to_pause,publicUrl:(si=(kl=u==null?void 0:u.features)==null?void 0:kl.triggers)==null?void 0:si.public_url}):c.section==="playground"?t.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 items-center gap-2 border-b px-5",children:[t.jsx(tm,{className:"size-4","aria-hidden":!0}),t.jsx("h1",{className:"caps text-body font-semibold",children:"API playground"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-6 py-4",children:[t.jsx("label",{className:"sr-only",htmlFor:"api-operation",children:"API operation"}),t.jsx(At,{id:"api-operation",label:"API operation",value:c.operation??"run",onChange:ge=>{const Ce=ao,Pe=new URLSearchParams;ge!=="run"&&Pe.set("operation",ge),ge!=="create-agent"&&ge!=="apply-template"&&Ce&&Pe.set("agent",Ce),Me(`#/playground${Pe.size?`?${Pe}`:""}`)},options:[{value:"create-agent",label:"POST · Create an agent"},{value:"apply-template",label:"POST · Apply a template"},{value:"run",label:"POST · Start a run"},{value:"list-runs",label:"GET · Query runs"},{value:"edit-agent",label:"PUT · Edit agent",disabled:!ao}]}),t.jsx("span",{className:"min-w-0 break-all font-mono text-small text-muted-foreground",children:c.operation==="apply-template"?`/v2/templates/${c.template?encodeURIComponent(c.template):"{template}"}/apply`:c.operation==="list-runs"?c.playgroundAgent?`/v2/agents/${c.playgroundAgent}/runs`:"/v2/runs":c.operation==="create-agent"?"/v2/agents":c.operation==="edit-agent"?`/v2/agents/${c.playgroundAgent??"{agent_id}"}/definition`:"/v2/agents/{agent_id}/runs"}),t.jsx("span",{className:"caps ml-auto text-micro text-muted-foreground",children:"Live API"})]}),c.operation==="apply-template"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(x0,{v2:e,name:c.template,go:Me,playground:!0,draft:c.draft},c.template??"")}):c.operation==="list-runs"?t.jsx(Y8,{v2:e,origin:location.origin,agentId:c.playgroundAgent,filter:{status:c.status,archived:c.archived}},`list:${c.playgroundAgent??""}:${c.status??""}:${c.archived??!1}`):c.operation?t.jsx(Q8,{v2:e,operation:c.operation,origin:location.origin,agentId:c.playgroundAgent,draft:c.draft,harnesses:at.harnesses},`${c.operation}:${c.playgroundAgent??""}:${c.draft??""}`):t.jsxs(t.Fragment,{children:[!Za&&((Nl=u==null?void 0:u.models)==null?void 0:Nl.ready)===!1&&t.jsx(KU,{needs:u.models.needs,source:u.models.source,model:u.models.default,settings:((Cl=(Sl=u.features)==null?void 0:Sl.tool_keys)==null?void 0:Cl.routes)===!0&&u.features.tool_keys.at_rest==="sealed",chatgpt:(Lt==null?void 0:Lt.state)==="signed_out"||(Lt==null?void 0:Lt.state)==="expired"}),gs&&t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"text-lead text-destructive-text",children:["The agents could not be read: ",gs]}),t.jsx(B,{size:"sm",className:"mt-3",type:"button",onClick:()=>$s(ge=>ge+1),children:"Try again"})]}),Nt&&t.jsx(K8,{agents:Nt.filter(ge=>!ge.archived_at),revisions:hs,efforts:ye,origin:location.origin,agentId:Cn??void 0,onAgent:Un,onSend:ne,limits:u==null?void 0:u.limits,removeUpload:e.deleteUpload,onOpenRun:ge=>Me(`#/runs/${encodeURIComponent(ge)}`),live:ge=>t.jsx(sN,{v2:e,runId:ge,caps:u,agentName:Qe},ge)})]})]}):c.section==="agents"?c.observation?t.jsx(NM,{v2:e,sessionId:c.observation,go:Me}):c.nativeConnect?t.jsx(TF,{v2:e,go:Me,initialSource:c.connectionSource}):c.agent===void 0?t.jsx(RF,{v2:e,archived:!!c.archived,go:Me},xe):c.agent===null?t.jsx(I8,{origin:location.origin,v2:e}):c.agent!==null&&!c.edit?t.jsx($D,{v2:e,agentId:c.agent,tab:c.tab,notes:c.notes,learning:We,routePrefix:(ri=Ze==null?void 0:Ze.models)==null?void 0:ri.route_prefix,harnesses:at.harnesses,efforts:ye,limits:u==null?void 0:u.limits,places:gk(u),go:Me},c.agent):t.jsx(AF,{v2:e,choices:Xe,gates:pt,focusTool:c.tool,caps:{...at,routePrefix:(ia=Ze==null?void 0:Ze.models)==null?void 0:ia.route_prefix,decisionProvider:MP(u==null?void 0:u.workflows),places:gk(u),mcp:!!((Qs=u==null?void 0:u.features)!=null&&Qs.mcp_client),mcpHarnesses:(Xs=(Js=u==null?void 0:u.features)==null?void 0:Js.mcp_client)==null?void 0:Xs.harnesses},agentId:c.agent,go:Me},`${c.agent??"new"}:${c.tool??""}`):c.run?t.jsx(sN,{v2:e,runId:c.run,caps:u,agentName:Qe},c.run):t.jsx(F8,{observations:!c.runsOf&&!c.archived&&!c.status?E:void 0,runs:fe,agentName:Qe,agentId:c.runsOf,error:Se,onRetry:()=>Ve(ge=>ge+1),onOpen:ge=>Me(`#/runs/${encodeURIComponent(ge)}`),loadingMore:pe,filter:Re,onFilter:ge=>Me(tB({runsOf:c.runsOf,...ge})),onMore:Ee?()=>{const ge=ct.current;me(!0),(c.runsOf?e.listAgentRuns(c.runsOf,50,Ee,Re):e.listRuns(50,Ee,Re)).then(Ce=>{ge===ct.current&&(ve(Pe=>tx(Pe??[],Ce.runs)),ue(Ce.next_cursor),Be(null))}).catch(Ce=>Be(Ft(Ce,"more runs"))).finally(()=>me(!1))}:void 0})})})}H7();q_.createRoot(document.getElementById("root")).render(t.jsx(p.StrictMode,{children:t.jsx(l5,{children:t.jsx(aB,{})})}));
|