@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.46
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 +148 -5
- package/README.md +385 -305
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +62 -19
- package/dist/composio-preset.js +69 -7
- package/dist/composio-triggers.d.ts +14 -0
- package/dist/composio-triggers.js +79 -15
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-C2MYaUBa.css +1 -0
- package/dist/console/assets/index-CZZeCReB.js +701 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +7 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +9 -1
- package/dist/harness-table.js +20 -3
- package/dist/harness.d.ts +1 -2
- package/dist/harness.js +3 -4
- package/dist/host.js +2 -1
- package/dist/import.d.ts +10 -0
- package/dist/import.js +28 -8
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +23 -89
- package/dist/learn/check.js +57 -335
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +89 -104
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +5 -5
- package/dist/learn/delete.js +8 -10
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +23 -5
- package/dist/learn/promote.js +40 -2
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
- package/dist/learn/{skills.js → workflow-draft.js} +48 -58
- package/dist/learn/workflow-nodes.js +1 -1
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +38 -24
- package/dist/learning-cost.js +41 -24
- package/dist/learning-routes.d.ts +91 -170
- package/dist/learning-routes.js +183 -421
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +21 -10
- package/dist/learning-setting.js +47 -11
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +61 -392
- package/dist/learning.js +101 -651
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +1 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +4 -4
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +4 -0
- package/dist/model.js +26 -9
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +273 -319
- package/dist/paid-calls.d.ts +8 -0
- package/dist/paid-calls.js +20 -0
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +15 -1
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +15 -89
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.js +1 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +8 -6
- package/dist/runner/adapter-loop.js +16 -12
- package/dist/runner/adapter-run-spec.d.ts +16 -4
- package/dist/runner/adapter-run-spec.js +64 -58
- package/dist/runner/adapters/index.js +22 -0
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/audit.js +30 -13
- package/dist/runner/beside.d.ts +6 -2
- package/dist/runner/beside.js +38 -9
- package/dist/runner/claim-secrets.d.ts +18 -2
- package/dist/runner/claim-secrets.js +42 -18
- package/dist/runner/cli-run-spec.js +55 -51
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +35 -13
- package/dist/runner/conformance/subject.d.ts +6 -0
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +2 -2
- package/dist/runner/feedback-round.js +7 -7
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +11 -59
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +2 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -69
- package/dist/runner/learning-end.js +250 -303
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +2 -3
- package/dist/runner/main.d.ts +17 -9
- package/dist/runner/main.js +82 -20
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +10 -5
- package/dist/runner/memory-claim.js +12 -6
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +12 -8
- package/dist/runner/promotion.js +37 -28
- package/dist/runner/reflect-hook.d.ts +64 -95
- package/dist/runner/reflect-hook.js +112 -225
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1230 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +1 -5
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +5 -1
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +7 -2
- package/dist/runs-over-store.d.ts +16 -28
- package/dist/runs-over-store.js +31 -38
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +55 -33
- package/dist/server.js +689 -322
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.js +246 -63
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +193 -36
- package/dist/store/store.js +25 -3
- package/dist/store-reads/learning.d.ts +102 -204
- package/dist/store-reads/learning.js +159 -321
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +29 -1
- package/dist/store-view.js +97 -31
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +8 -4
- package/dist/templates.js +44 -6
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +11 -4
- package/dist/triggers.d.ts +65 -6
- package/dist/triggers.js +125 -19
- package/dist/validate.js +1 -1
- package/dist/webhooks.d.ts +7 -2
- package/dist/webhooks.js +12 -5
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +7 -3
- package/dist/workspace/computer-for-claim.js +119 -22
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +33 -19
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/templates/README.md +8 -8
- package/templates/inbound-lead/agent.md +5 -4
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/kyb/agent.md +2 -1
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BUktRvS-.css +0 -1
- package/dist/console/assets/index-nB9kTfIN.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -35
- package/dist/learning-evals.js +0 -99
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
|
@@ -1,711 +0,0 @@
|
|
|
1
|
-
var ST=Object.defineProperty;var CT=(e,n,s)=>n in e?ST(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var At=(e,n,s)=>CT(e,typeof n!="symbol"?n+"":n,s);function ET(e,n){for(var s=0;s<n.length;s++){const r=n[s];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const i=Object.getOwnPropertyDescriptor(r,o);i&&Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function s(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=s(o);fetch(o.href,i)}})();function MN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Gp={exports:{}},hc={},qp={exports:{}},vt={};/**
|
|
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 ij;function $T(){if(ij)return vt;ij=1;var e=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.iterator;function v(z){return z===null||typeof z!="object"?null:(z=y&&z[y]||z["@@iterator"],typeof z=="function"?z:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,b={};function j(z,V,se){this.props=z,this.context=V,this.refs=b,this.updater=se||h}j.prototype.isReactComponent={},j.prototype.setState=function(z,V){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,V,"setState")},j.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function k(){}k.prototype=j.prototype;function E(z,V,se){this.props=z,this.context=V,this.refs=b,this.updater=se||h}var S=E.prototype=new k;S.constructor=E,x(S,j.prototype),S.isPureReactComponent=!0;var N=Array.isArray,$=Object.prototype.hasOwnProperty,_={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function L(z,V,se){var J,re={},ne=null,me=null;if(V!=null)for(J in V.ref!==void 0&&(me=V.ref),V.key!==void 0&&(ne=""+V.key),V)$.call(V,J)&&!O.hasOwnProperty(J)&&(re[J]=V[J]);var ve=arguments.length-2;if(ve===1)re.children=se;else if(1<ve){for(var je=Array(ve),Ve=0;Ve<ve;Ve++)je[Ve]=arguments[Ve+2];re.children=je}if(z&&z.defaultProps)for(J in ve=z.defaultProps,ve)re[J]===void 0&&(re[J]=ve[J]);return{$$typeof:e,type:z,key:ne,ref:me,props:re,_owner:_.current}}function P(z,V){return{$$typeof:e,type:z.type,key:V,ref:z.ref,props:z.props,_owner:z._owner}}function R(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function A(z){var V={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(se){return V[se]})}var M=/\/+/g;function F(z,V){return typeof z=="object"&&z!==null&&z.key!=null?A(""+z.key):V.toString(36)}function I(z,V,se,J,re){var ne=typeof z;(ne==="undefined"||ne==="boolean")&&(z=null);var me=!1;if(z===null)me=!0;else switch(ne){case"string":case"number":me=!0;break;case"object":switch(z.$$typeof){case e:case n:me=!0}}if(me)return me=z,re=re(me),z=J===""?"."+F(me,0):J,N(re)?(se="",z!=null&&(se=z.replace(M,"$&/")+"/"),I(re,V,se,"",function(Ve){return Ve})):re!=null&&(R(re)&&(re=P(re,se+(!re.key||me&&me.key===re.key?"":(""+re.key).replace(M,"$&/")+"/")+z)),V.push(re)),1;if(me=0,J=J===""?".":J+":",N(z))for(var ve=0;ve<z.length;ve++){ne=z[ve];var je=J+F(ne,ve);me+=I(ne,V,se,je,re)}else if(je=v(z),typeof je=="function")for(z=je.call(z),ve=0;!(ne=z.next()).done;)ne=ne.value,je=J+F(ne,ve++),me+=I(ne,V,se,je,re);else if(ne==="object")throw V=String(z),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.");return me}function q(z,V,se){if(z==null)return z;var J=[],re=0;return I(z,J,"","",function(ne){return V.call(se,ne,re++)}),J}function W(z){if(z._status===-1){var V=z._result;V=V(),V.then(function(se){(z._status===0||z._status===-1)&&(z._status=1,z._result=se)},function(se){(z._status===0||z._status===-1)&&(z._status=2,z._result=se)}),z._status===-1&&(z._status=0,z._result=V)}if(z._status===1)return z._result.default;throw z._result}var K={current:null},U={transition:null},H={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:U,ReactCurrentOwner:_};function G(){throw Error("act(...) is not supported in production builds of React.")}return vt.Children={map:q,forEach:function(z,V,se){q(z,function(){V.apply(this,arguments)},se)},count:function(z){var V=0;return q(z,function(){V++}),V},toArray:function(z){return q(z,function(V){return V})||[]},only:function(z){if(!R(z))throw Error("React.Children.only expected to receive a single React element child.");return z}},vt.Component=j,vt.Fragment=s,vt.Profiler=o,vt.PureComponent=E,vt.StrictMode=r,vt.Suspense=u,vt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H,vt.act=G,vt.cloneElement=function(z,V,se){if(z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+z+".");var J=x({},z.props),re=z.key,ne=z.ref,me=z._owner;if(V!=null){if(V.ref!==void 0&&(ne=V.ref,me=_.current),V.key!==void 0&&(re=""+V.key),z.type&&z.type.defaultProps)var ve=z.type.defaultProps;for(je in V)$.call(V,je)&&!O.hasOwnProperty(je)&&(J[je]=V[je]===void 0&&ve!==void 0?ve[je]:V[je])}var je=arguments.length-2;if(je===1)J.children=se;else if(1<je){ve=Array(je);for(var Ve=0;Ve<je;Ve++)ve[Ve]=arguments[Ve+2];J.children=ve}return{$$typeof:e,type:z.type,key:re,ref:ne,props:J,_owner:me}},vt.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},vt.createElement=L,vt.createFactory=function(z){var V=L.bind(null,z);return V.type=z,V},vt.createRef=function(){return{current:null}},vt.forwardRef=function(z){return{$$typeof:d,render:z}},vt.isValidElement=R,vt.lazy=function(z){return{$$typeof:g,_payload:{_status:-1,_result:z},_init:W}},vt.memo=function(z,V){return{$$typeof:f,type:z,compare:V===void 0?null:V}},vt.startTransition=function(z){var V=U.transition;U.transition={};try{z()}finally{U.transition=V}},vt.unstable_act=G,vt.useCallback=function(z,V){return K.current.useCallback(z,V)},vt.useContext=function(z){return K.current.useContext(z)},vt.useDebugValue=function(){},vt.useDeferredValue=function(z){return K.current.useDeferredValue(z)},vt.useEffect=function(z,V){return K.current.useEffect(z,V)},vt.useId=function(){return K.current.useId()},vt.useImperativeHandle=function(z,V,se){return K.current.useImperativeHandle(z,V,se)},vt.useInsertionEffect=function(z,V){return K.current.useInsertionEffect(z,V)},vt.useLayoutEffect=function(z,V){return K.current.useLayoutEffect(z,V)},vt.useMemo=function(z,V){return K.current.useMemo(z,V)},vt.useReducer=function(z,V,se){return K.current.useReducer(z,V,se)},vt.useRef=function(z){return K.current.useRef(z)},vt.useState=function(z){return K.current.useState(z)},vt.useSyncExternalStore=function(z,V,se){return K.current.useSyncExternalStore(z,V,se)},vt.useTransition=function(){return K.current.useTransition()},vt.version="18.3.1",vt}var lj;function pm(){return lj||(lj=1,qp.exports=$T()),qp.exports}/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.production.min.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var cj;function _T(){if(cj)return hc;cj=1;var e=pm(),n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(d,u,f){var g,y={},v=null,h=null;f!==void 0&&(v=""+f),u.key!==void 0&&(v=""+u.key),u.ref!==void 0&&(h=u.ref);for(g in u)r.call(u,g)&&!i.hasOwnProperty(g)&&(y[g]=u[g]);if(d&&d.defaultProps)for(g in u=d.defaultProps,u)y[g]===void 0&&(y[g]=u[g]);return{$$typeof:n,type:d,key:v,ref:h,props:y,_owner:o.current}}return hc.Fragment=s,hc.jsx=c,hc.jsxs=c,hc}var dj;function TT(){return dj||(dj=1,Gp.exports=_T()),Gp.exports}var t=TT(),p=pm();const Ke=MN(p),Wg=ET({__proto__:null,default:Ke},[p]);var Bu={},Kp={exports:{}},ms={},Vp={exports:{}},Yp={};/**
|
|
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 uj;function RT(){return uj||(uj=1,(function(e){function n(U,H){var G=U.length;U.push(H);e:for(;0<G;){var z=G-1>>>1,V=U[z];if(0<o(V,H))U[z]=H,U[G]=V,G=z;else break e}}function s(U){return U.length===0?null:U[0]}function r(U){if(U.length===0)return null;var H=U[0],G=U.pop();if(G!==H){U[0]=G;e:for(var z=0,V=U.length,se=V>>>1;z<se;){var J=2*(z+1)-1,re=U[J],ne=J+1,me=U[ne];if(0>o(re,G))ne<V&&0>o(me,re)?(U[z]=me,U[ne]=G,z=ne):(U[z]=re,U[J]=G,z=J);else if(ne<V&&0>o(me,G))U[z]=me,U[ne]=G,z=ne;else break e}}return H}function o(U,H){var G=U.sortIndex-H.sortIndex;return G!==0?G:U.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var u=[],f=[],g=1,y=null,v=3,h=!1,x=!1,b=!1,j=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(U){for(var H=s(f);H!==null;){if(H.callback===null)r(f);else if(H.startTime<=U)r(f),H.sortIndex=H.expirationTime,n(u,H);else break;H=s(f)}}function N(U){if(b=!1,S(U),!x)if(s(u)!==null)x=!0,W($);else{var H=s(f);H!==null&&K(N,H.startTime-U)}}function $(U,H){x=!1,b&&(b=!1,k(L),L=-1),h=!0;var G=v;try{for(S(H),y=s(u);y!==null&&(!(y.expirationTime>H)||U&&!A());){var z=y.callback;if(typeof z=="function"){y.callback=null,v=y.priorityLevel;var V=z(y.expirationTime<=H);H=e.unstable_now(),typeof V=="function"?y.callback=V:y===s(u)&&r(u),S(H)}else r(u);y=s(u)}if(y!==null)var se=!0;else{var J=s(f);J!==null&&K(N,J.startTime-H),se=!1}return se}finally{y=null,v=G,h=!1}}var _=!1,O=null,L=-1,P=5,R=-1;function A(){return!(e.unstable_now()-R<P)}function M(){if(O!==null){var U=e.unstable_now();R=U;var H=!0;try{H=O(!0,U)}finally{H?F():(_=!1,O=null)}}else _=!1}var F;if(typeof E=="function")F=function(){E(M)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,q=I.port2;I.port1.onmessage=M,F=function(){q.postMessage(null)}}else F=function(){j(M,0)};function W(U){O=U,_||(_=!0,F())}function K(U,H){L=j(function(){U(e.unstable_now())},H)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(U){U.callback=null},e.unstable_continueExecution=function(){x||h||(x=!0,W($))},e.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<U?Math.floor(1e3/U):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_getFirstCallbackNode=function(){return s(u)},e.unstable_next=function(U){switch(v){case 1:case 2:case 3:var H=3;break;default:H=v}var G=v;v=H;try{return U()}finally{v=G}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(U,H){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var G=v;v=U;try{return H()}finally{v=G}},e.unstable_scheduleCallback=function(U,H,G){var z=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?z+G:z):G=z,U){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=G+V,U={id:g++,callback:H,priorityLevel:U,startTime:G,expirationTime:V,sortIndex:-1},G>z?(U.sortIndex=G,n(f,U),s(u)===null&&U===s(f)&&(b?(k(L),L=-1):b=!0,K(N,G-z))):(U.sortIndex=V,n(u,U),x||h||(x=!0,W($))),U},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(U){var H=v;return function(){var G=v;v=H;try{return U.apply(this,arguments)}finally{v=G}}}})(Yp)),Yp}var fj;function AT(){return fj||(fj=1,Vp.exports=RT()),Vp.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 mj;function OT(){if(mj)return ms;mj=1;var e=pm(),n=AT();function s(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,m=1;m<arguments.length;m++)l+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(a,l){c(a,l),c(a+"Capture",l)}function c(a,l){for(o[a]=l,a=0;a<l.length;a++)r.add(l[a])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,g={},y={};function v(a){return u.call(y,a)?!0:u.call(g,a)?!1:f.test(a)?y[a]=!0:(g[a]=!0,!1)}function h(a,l,m,w){if(m!==null&&m.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return w?!1:m!==null?!m.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function x(a,l,m,w){if(l===null||typeof l>"u"||h(a,l,m,w))return!0;if(w)return!1;if(m!==null)switch(m.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function b(a,l,m,w,C,T,D){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=w,this.attributeNamespace=C,this.mustUseProperty=m,this.propertyName=a,this.type=l,this.sanitizeURL=T,this.removeEmptyString=D}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){j[a]=new b(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];j[l]=new b(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){j[a]=new b(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){j[a]=new b(a,2,!1,a,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){j[a]=new b(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){j[a]=new b(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){j[a]=new b(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){j[a]=new b(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){j[a]=new b(a,5,!1,a.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function E(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var l=a.replace(k,E);j[l]=new b(l,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var l=a.replace(k,E);j[l]=new b(l,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var l=a.replace(k,E);j[l]=new b(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){j[a]=new b(a,1,!1,a.toLowerCase(),null,!1,!1)}),j.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){j[a]=new b(a,1,!1,a.toLowerCase(),null,!0,!0)});function S(a,l,m,w){var C=j.hasOwnProperty(l)?j[l]:null;(C!==null?C.type!==0:w||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(x(l,m,C,w)&&(m=null),w||C===null?v(l)&&(m===null?a.removeAttribute(l):a.setAttribute(l,""+m)):C.mustUseProperty?a[C.propertyName]=m===null?C.type===3?!1:"":m:(l=C.attributeName,w=C.attributeNamespace,m===null?a.removeAttribute(l):(C=C.type,m=C===3||C===4&&m===!0?"":""+m,w?a.setAttributeNS(w,l,m):a.setAttribute(l,m))))}var N=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),_=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),R=Symbol.for("react.provider"),A=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),U=Symbol.iterator;function H(a){return a===null||typeof a!="object"?null:(a=U&&a[U]||a["@@iterator"],typeof a=="function"?a:null)}var G=Object.assign,z;function V(a){if(z===void 0)try{throw Error()}catch(m){var l=m.stack.trim().match(/\n( *(at )?)/);z=l&&l[1]||""}return`
|
|
34
|
-
`+z+a}var se=!1;function J(a,l){if(!a||se)return"";se=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ue){var w=ue}Reflect.construct(a,[],l)}else{try{l.call()}catch(ue){w=ue}a.call(l.prototype)}else{try{throw Error()}catch(ue){w=ue}a()}}catch(ue){if(ue&&w&&typeof ue.stack=="string"){for(var C=ue.stack.split(`
|
|
35
|
-
`),T=w.stack.split(`
|
|
36
|
-
`),D=C.length-1,Y=T.length-1;1<=D&&0<=Y&&C[D]!==T[Y];)Y--;for(;1<=D&&0<=Y;D--,Y--)if(C[D]!==T[Y]){if(D!==1||Y!==1)do if(D--,Y--,0>Y||C[D]!==T[Y]){var Z=`
|
|
37
|
-
`+C[D].replace(" at new "," at ");return a.displayName&&Z.includes("<anonymous>")&&(Z=Z.replace("<anonymous>",a.displayName)),Z}while(1<=D&&0<=Y);break}}}finally{se=!1,Error.prepareStackTrace=m}return(a=a?a.displayName||a.name:"")?V(a):""}function re(a){switch(a.tag){case 5:return V(a.type);case 16:return V("Lazy");case 13:return V("Suspense");case 19:return V("SuspenseList");case 0:case 2:case 15:return a=J(a.type,!1),a;case 11:return a=J(a.type.render,!1),a;case 1:return a=J(a.type,!0),a;default:return""}}function ne(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case O:return"Fragment";case _:return"Portal";case P:return"Profiler";case L:return"StrictMode";case F:return"Suspense";case I:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case A:return(a.displayName||"Context")+".Consumer";case R:return(a._context.displayName||"Context")+".Provider";case M:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case q:return l=a.displayName||null,l!==null?l:ne(a.type)||"Memo";case W:l=a._payload,a=a._init;try{return ne(a(l))}catch{}}return null}function me(a){var l=a.type;switch(a.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=l.render,a=a.displayName||a.name||"",l.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ne(l);case 8:return l===L?"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(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function je(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function Ve(a){var l=je(a)?"checked":"value",m=Object.getOwnPropertyDescriptor(a.constructor.prototype,l),w=""+a[l];if(!a.hasOwnProperty(l)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var C=m.get,T=m.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return C.call(this)},set:function(D){w=""+D,T.call(this,D)}}),Object.defineProperty(a,l,{enumerable:m.enumerable}),{getValue:function(){return w},setValue:function(D){w=""+D},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function de(a){a._valueTracker||(a._valueTracker=Ve(a))}function Oe(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var m=l.getValue(),w="";return a&&(w=je(a)?a.checked?"true":"false":a.value),a=w,a!==m?(l.setValue(a),!0):!1}function ze(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function De(a,l){var m=l.checked;return G({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??a._wrapperState.initialChecked})}function Ne(a,l){var m=l.defaultValue==null?"":l.defaultValue,w=l.checked!=null?l.checked:l.defaultChecked;m=ve(l.value!=null?l.value:m),a._wrapperState={initialChecked:w,initialValue:m,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Q(a,l){l=l.checked,l!=null&&S(a,"checked",l,!1)}function be(a,l){Q(a,l);var m=ve(l.value),w=l.type;if(m!=null)w==="number"?(m===0&&a.value===""||a.value!=m)&&(a.value=""+m):a.value!==""+m&&(a.value=""+m);else if(w==="submit"||w==="reset"){a.removeAttribute("value");return}l.hasOwnProperty("value")?fe(a,l.type,m):l.hasOwnProperty("defaultValue")&&fe(a,l.type,ve(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(a.defaultChecked=!!l.defaultChecked)}function nt(a,l,m){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var w=l.type;if(!(w!=="submit"&&w!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+a._wrapperState.initialValue,m||l===a.value||(a.value=l),a.defaultValue=l}m=a.name,m!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,m!==""&&(a.name=m)}function fe(a,l,m){(l!=="number"||ze(a.ownerDocument)!==a)&&(m==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+m&&(a.defaultValue=""+m))}var Le=Array.isArray;function Ye(a,l,m,w){if(a=a.options,l){l={};for(var C=0;C<m.length;C++)l["$"+m[C]]=!0;for(m=0;m<a.length;m++)C=l.hasOwnProperty("$"+a[m].value),a[m].selected!==C&&(a[m].selected=C),C&&w&&(a[m].defaultSelected=!0)}else{for(m=""+ve(m),l=null,C=0;C<a.length;C++){if(a[C].value===m){a[C].selected=!0,w&&(a[C].defaultSelected=!0);return}l!==null||a[C].disabled||(l=a[C])}l!==null&&(l.selected=!0)}}function ht(a,l){if(l.dangerouslySetInnerHTML!=null)throw Error(s(91));return G({},l,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function ie(a,l){var m=l.value;if(m==null){if(m=l.children,l=l.defaultValue,m!=null){if(l!=null)throw Error(s(92));if(Le(m)){if(1<m.length)throw Error(s(93));m=m[0]}l=m}l==null&&(l=""),m=l}a._wrapperState={initialValue:ve(m)}}function Ce(a,l){var m=ve(l.value),w=ve(l.defaultValue);m!=null&&(m=""+m,m!==a.value&&(a.value=m),l.defaultValue==null&&a.defaultValue!==m&&(a.defaultValue=m)),w!=null&&(a.defaultValue=""+w)}function tt(a){var l=a.textContent;l===a._wrapperState.initialValue&&l!==""&&l!==null&&(a.value=l)}function Ie(a){switch(a){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function at(a,l){return a==null||a==="http://www.w3.org/1999/xhtml"?Ie(l):a==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var St,st=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,m,w,C){MSApp.execUnsafeLocalFunction(function(){return a(l,m,w,C)})}:a})(function(a,l){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=l;else{for(St=St||document.createElement("div"),St.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=St.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}});function ut(a,l){if(l){var m=a.firstChild;if(m&&m===a.lastChild&&m.nodeType===3){m.nodeValue=l;return}}a.textContent=l}var Dt={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},Ft=["Webkit","ms","Moz","O"];Object.keys(Dt).forEach(function(a){Ft.forEach(function(l){l=l+a.charAt(0).toUpperCase()+a.substring(1),Dt[l]=Dt[a]})});function Rt(a,l,m){return l==null||typeof l=="boolean"||l===""?"":m||typeof l!="number"||l===0||Dt.hasOwnProperty(a)&&Dt[a]?(""+l).trim():l+"px"}function pe(a,l){a=a.style;for(var m in l)if(l.hasOwnProperty(m)){var w=m.indexOf("--")===0,C=Rt(m,l[m],w);m==="float"&&(m="cssFloat"),w?a.setProperty(m,C):a[m]=C}}var he=G({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 He(a,l){if(l){if(he[a]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(s(137,a));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(s(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(s(61))}if(l.style!=null&&typeof l.style!="object")throw Error(s(62))}}function Je(a,l){if(a.indexOf("-")===-1)return typeof l.is=="string";switch(a){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var X=null;function ge(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var _e=null,Ae=null,We=null;function gt(a){if(a=Zl(a)){if(typeof _e!="function")throw Error(s(280));var l=a.stateNode;l&&(l=ou(l),_e(a.stateNode,a.type,l))}}function jt(a){Ae?We?We.push(a):We=[a]:Ae=a}function it(){if(Ae){var a=Ae,l=We;if(We=Ae=null,gt(a),l)for(a=0;a<l.length;a++)gt(l[a])}}function Vt(a,l){return a(l)}function xs(){}var Xs=!1;function _n(a,l,m){if(Xs)return a(l,m);Xs=!0;try{return Vt(a,l,m)}finally{Xs=!1,(Ae!==null||We!==null)&&(xs(),it())}}function Bn(a,l){var m=a.stateNode;if(m===null)return null;var w=ou(m);if(w===null)return null;m=w[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(a=a.type,w=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!w;break e;default:a=!1}if(a)return null;if(m&&typeof m!="function")throw Error(s(231,l,typeof m));return m}var vs=!1;if(d)try{var bs={};Object.defineProperty(bs,"passive",{get:function(){vs=!0}}),window.addEventListener("test",bs,bs),window.removeEventListener("test",bs,bs)}catch{vs=!1}function mn(a,l,m,w,C,T,D,Y,Z){var ue=Array.prototype.slice.call(arguments,3);try{l.apply(m,ue)}catch(ke){this.onError(ke)}}var Gn=!1,Rs=null,qn=!1,As=null,Os={onError:function(a){Gn=!0,Rs=a}};function Ln(a,l,m,w,C,T,D,Y,Z){Gn=!1,Rs=null,mn.apply(Os,arguments)}function ee(a,l,m,w,C,T,D,Y,Z){if(Ln.apply(this,arguments),Gn){if(Gn){var ue=Rs;Gn=!1,Rs=null}else throw Error(s(198));qn||(qn=!0,As=ue)}}function Me(a){var l=a,m=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(m=l.return),a=l.return;while(a)}return l.tag===3?m:null}function mt(a){if(a.tag===13){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function Ot(a){if(Me(a)!==a)throw Error(s(188))}function Xt(a){var l=a.alternate;if(!l){if(l=Me(a),l===null)throw Error(s(188));return l!==a?null:a}for(var m=a,w=l;;){var C=m.return;if(C===null)break;var T=C.alternate;if(T===null){if(w=C.return,w!==null){m=w;continue}break}if(C.child===T.child){for(T=C.child;T;){if(T===m)return Ot(C),a;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 D=!1,Y=C.child;Y;){if(Y===m){D=!0,m=C,w=T;break}if(Y===w){D=!0,w=C,m=T;break}Y=Y.sibling}if(!D){for(Y=T.child;Y;){if(Y===m){D=!0,m=T,w=C;break}if(Y===w){D=!0,w=T,m=C;break}Y=Y.sibling}if(!D)throw Error(s(189))}}if(m.alternate!==w)throw Error(s(190))}if(m.tag!==3)throw Error(s(188));return m.stateNode.current===m?a:l}function Be(a){return a=Xt(a),a!==null?te(a):null}function te(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var l=te(a);if(l!==null)return l;a=a.sibling}return null}var ye=n.unstable_scheduleCallback,qe=n.unstable_cancelCallback,Nt=n.unstable_shouldYield,It=n.unstable_requestPaint,lt=n.unstable_now,jn=n.unstable_getCurrentPriorityLevel,Tn=n.unstable_ImmediatePriority,gr=n.unstable_UserBlockingPriority,Bt=n.unstable_NormalPriority,li=n.unstable_LowPriority,co=n.unstable_IdlePriority,ia=null,ys=null;function Fd(a){if(ys&&typeof ys.onCommitFiberRoot=="function")try{ys.onCommitFiberRoot(ia,a,void 0,(a.current.flags&128)===128)}catch{}}var as=Math.clz32?Math.clz32:Hd,Ud=Math.log,Wd=Math.LN2;function Hd(a){return a>>>=0,a===0?32:31-(Ud(a)/Wd|0)|0}var la=64,ca=4194304;function uo(a){switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function da(a,l){var m=a.pendingLanes;if(m===0)return 0;var w=0,C=a.suspendedLanes,T=a.pingedLanes,D=m&268435455;if(D!==0){var Y=D&~C;Y!==0?w=uo(Y):(T&=D,T!==0&&(w=uo(T)))}else D=m&~C,D!==0?w=uo(D):T!==0&&(w=uo(T));if(w===0)return 0;if(l!==0&&l!==w&&(l&C)===0&&(C=w&-w,T=l&-l,C>=T||C===16&&(T&4194240)!==0))return l;if((w&4)!==0&&(w|=m&16),l=a.entangledLanes,l!==0)for(a=a.entanglements,l&=w;0<l;)m=31-as(l),C=1<<m,w|=a[m],l&=~C;return w}function Bd(a,l){switch(a){case 1:case 2:case 4:return l+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gd(a,l){for(var m=a.suspendedLanes,w=a.pingedLanes,C=a.expirationTimes,T=a.pendingLanes;0<T;){var D=31-as(T),Y=1<<D,Z=C[D];Z===-1?((Y&m)===0||(Y&w)!==0)&&(C[D]=Bd(Y,l)):Z<=l&&(a.expiredLanes|=Y),T&=~Y}}function ci(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function Pl(){var a=la;return la<<=1,(la&4194240)===0&&(la=64),a}function di(a){for(var l=[],m=0;31>m;m++)l.push(a);return l}function fo(a,l,m){a.pendingLanes|=l,l!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,l=31-as(l),a[l]=m}function qd(a,l){var m=a.pendingLanes&~l;a.pendingLanes=l,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=l,a.mutableReadLanes&=l,a.entangledLanes&=l,l=a.entanglements;var w=a.eventTimes;for(a=a.expirationTimes;0<m;){var C=31-as(m),T=1<<C;l[C]=0,w[C]=-1,a[C]=-1,m&=~T}}function ui(a,l){var m=a.entangledLanes|=l;for(a=a.entanglements;m;){var w=31-as(m),C=1<<w;C&l|a[w]&l&&(a[w]|=l),m&=~C}}var $t=0;function Il(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var zl,fi,Dl,Fl,Ul,mi=!1,ua=[],Zs=null,er=null,tr=null,xe=new Map,$e=new Map,Fe=[],_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 kt(a,l){switch(a){case"focusin":case"focusout":Zs=null;break;case"dragenter":case"dragleave":er=null;break;case"mouseover":case"mouseout":tr=null;break;case"pointerover":case"pointerout":xe.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":$e.delete(l.pointerId)}}function is(a,l,m,w,C,T){return a===null||a.nativeEvent!==T?(a={blockedOn:l,domEventName:m,eventSystemFlags:w,nativeEvent:T,targetContainers:[C]},l!==null&&(l=Zl(l),l!==null&&fi(l)),a):(a.eventSystemFlags|=w,l=a.targetContainers,C!==null&&l.indexOf(C)===-1&&l.push(C),a)}function Kn(a,l,m,w,C){switch(l){case"focusin":return Zs=is(Zs,a,l,m,w,C),!0;case"dragenter":return er=is(er,a,l,m,w,C),!0;case"mouseover":return tr=is(tr,a,l,m,w,C),!0;case"pointerover":var T=C.pointerId;return xe.set(T,is(xe.get(T)||null,a,l,m,w,C)),!0;case"gotpointercapture":return T=C.pointerId,$e.set(T,is($e.get(T)||null,a,l,m,w,C)),!0}return!1}function Vn(a){var l=fa(a.target);if(l!==null){var m=Me(l);if(m!==null){if(l=m.tag,l===13){if(l=mt(m),l!==null){a.blockedOn=l,Ul(a.priority,function(){Dl(m)});return}}else if(l===3&&m.stateNode.current.memoizedState.isDehydrated){a.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}a.blockedOn=null}function hi(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var m=vh(a.domEventName,a.eventSystemFlags,l[0],a.nativeEvent);if(m===null){m=a.nativeEvent;var w=new m.constructor(m.type,m);X=w,m.target.dispatchEvent(w),X=null}else return l=Zl(m),l!==null&&fi(l),a.blockedOn=m,!1;l.shift()}return!0}function Pr(a,l,m){hi(a)&&m.delete(l)}function gh(){mi=!1,Zs!==null&&hi(Zs)&&(Zs=null),er!==null&&hi(er)&&(er=null),tr!==null&&hi(tr)&&(tr=null),xe.forEach(Pr),$e.forEach(Pr)}function mo(a,l){a.blockedOn===l&&(a.blockedOn=null,mi||(mi=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,gh)))}function ho(a){function l(C){return mo(C,a)}if(0<ua.length){mo(ua[0],a);for(var m=1;m<ua.length;m++){var w=ua[m];w.blockedOn===a&&(w.blockedOn=null)}}for(Zs!==null&&mo(Zs,a),er!==null&&mo(er,a),tr!==null&&mo(tr,a),xe.forEach(l),$e.forEach(l),m=0;m<Fe.length;m++)w=Fe[m],w.blockedOn===a&&(w.blockedOn=null);for(;0<Fe.length&&(m=Fe[0],m.blockedOn===null);)Vn(m),m.blockedOn===null&&Fe.shift()}var Ir=N.ReactCurrentBatchConfig,zr=!0;function po(a,l,m,w){var C=$t,T=Ir.transition;Ir.transition=null;try{$t=1,xh(a,l,m,w)}finally{$t=C,Ir.transition=T}}function xr(a,l,m,w){var C=$t,T=Ir.transition;Ir.transition=null;try{$t=4,xh(a,l,m,w)}finally{$t=C,Ir.transition=T}}function xh(a,l,m,w){if(zr){var C=vh(a,l,m,w);if(C===null)Mh(a,l,w,Kd,m),kt(a,w);else if(Kn(C,a,l,m,w))w.stopPropagation();else if(kt(a,w),l&4&&-1<_t.indexOf(a)){for(;C!==null;){var T=Zl(C);if(T!==null&&zl(T),T=vh(a,l,m,w),T===null&&Mh(a,l,w,Kd,m),T===C)break;C=T}C!==null&&w.stopPropagation()}else Mh(a,l,w,null,m)}}var Kd=null;function vh(a,l,m,w){if(Kd=null,a=ge(w),a=fa(a),a!==null)if(l=Me(a),l===null)a=null;else if(m=l.tag,m===13){if(a=mt(l),a!==null)return a;a=null}else if(m===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null);return Kd=a,null}function Kb(a){switch(a){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(jn()){case Tn:return 1;case gr:return 4;case Bt:case li:return 16;case co:return 536870912;default:return 16}default:return 16}}var go=null,bh=null,Vd=null;function Vb(){if(Vd)return Vd;var a,l=bh,m=l.length,w,C="value"in go?go.value:go.textContent,T=C.length;for(a=0;a<m&&l[a]===C[a];a++);var D=m-a;for(w=1;w<=D&&l[m-w]===C[T-w];w++);return Vd=C.slice(a,1<w?1-w:void 0)}function Yd(a){var l=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&l===13&&(a=13)):a=l,a===10&&(a=13),32<=a||a===13?a:0}function Qd(){return!0}function Yb(){return!1}function ws(a){function l(m,w,C,T,D){this._reactName=m,this._targetInst=C,this.type=w,this.nativeEvent=T,this.target=D,this.currentTarget=null;for(var Y in a)a.hasOwnProperty(Y)&&(m=a[Y],this[Y]=m?m(T):T[Y]);return this.isDefaultPrevented=(T.defaultPrevented!=null?T.defaultPrevented:T.returnValue===!1)?Qd:Yb,this.isPropagationStopped=Yb,this}return G(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=Qd)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=Qd)},persist:function(){},isPersistent:Qd}),l}var pi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},yh=ws(pi),Wl=G({},pi,{view:0,detail:0}),X$=ws(Wl),wh,jh,Hl,Jd=G({},Wl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Nh,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==Hl&&(Hl&&a.type==="mousemove"?(wh=a.screenX-Hl.screenX,jh=a.screenY-Hl.screenY):jh=wh=0,Hl=a),wh)},movementY:function(a){return"movementY"in a?a.movementY:jh}}),Qb=ws(Jd),Z$=G({},Jd,{dataTransfer:0}),e_=ws(Z$),t_=G({},Wl,{relatedTarget:0}),kh=ws(t_),n_=G({},pi,{animationName:0,elapsedTime:0,pseudoElement:0}),s_=ws(n_),r_=G({},pi,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),o_=ws(r_),a_=G({},pi,{data:0}),Jb=ws(a_),i_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},l_={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"},c_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function d_(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=c_[a])?!!l[a]:!1}function Nh(){return d_}var u_=G({},Wl,{key:function(a){if(a.key){var l=i_[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=Yd(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?l_[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Nh,charCode:function(a){return a.type==="keypress"?Yd(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Yd(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),f_=ws(u_),m_=G({},Jd,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Xb=ws(m_),h_=G({},Wl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Nh}),p_=ws(h_),g_=G({},pi,{propertyName:0,elapsedTime:0,pseudoElement:0}),x_=ws(g_),v_=G({},Jd,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),b_=ws(v_),y_=[9,13,27,32],Sh=d&&"CompositionEvent"in window,Bl=null;d&&"documentMode"in document&&(Bl=document.documentMode);var w_=d&&"TextEvent"in window&&!Bl,Zb=d&&(!Sh||Bl&&8<Bl&&11>=Bl),ey=" ",ty=!1;function ny(a,l){switch(a){case"keyup":return y_.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function sy(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var gi=!1;function j_(a,l){switch(a){case"compositionend":return sy(l);case"keypress":return l.which!==32?null:(ty=!0,ey);case"textInput":return a=l.data,a===ey&&ty?null:a;default:return null}}function k_(a,l){if(gi)return a==="compositionend"||!Sh&&ny(a,l)?(a=Vb(),Vd=bh=go=null,gi=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return Zb&&l.locale!=="ko"?null:l.data;default:return null}}var N_={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 ry(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!N_[a.type]:l==="textarea"}function oy(a,l,m,w){jt(w),l=nu(l,"onChange"),0<l.length&&(m=new yh("onChange","change",null,m,w),a.push({event:m,listeners:l}))}var Gl=null,ql=null;function S_(a){ky(a,0)}function Xd(a){var l=wi(a);if(Oe(l))return a}function C_(a,l){if(a==="change")return l}var ay=!1;if(d){var Ch;if(d){var Eh="oninput"in document;if(!Eh){var iy=document.createElement("div");iy.setAttribute("oninput","return;"),Eh=typeof iy.oninput=="function"}Ch=Eh}else Ch=!1;ay=Ch&&(!document.documentMode||9<document.documentMode)}function ly(){Gl&&(Gl.detachEvent("onpropertychange",cy),ql=Gl=null)}function cy(a){if(a.propertyName==="value"&&Xd(ql)){var l=[];oy(l,ql,a,ge(a)),_n(S_,l)}}function E_(a,l,m){a==="focusin"?(ly(),Gl=l,ql=m,Gl.attachEvent("onpropertychange",cy)):a==="focusout"&&ly()}function $_(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Xd(ql)}function __(a,l){if(a==="click")return Xd(l)}function T_(a,l){if(a==="input"||a==="change")return Xd(l)}function R_(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var nr=typeof Object.is=="function"?Object.is:R_;function Kl(a,l){if(nr(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var m=Object.keys(a),w=Object.keys(l);if(m.length!==w.length)return!1;for(w=0;w<m.length;w++){var C=m[w];if(!u.call(l,C)||!nr(a[C],l[C]))return!1}return!0}function dy(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function uy(a,l){var m=dy(a);a=0;for(var w;m;){if(m.nodeType===3){if(w=a+m.textContent.length,a<=l&&w>=l)return{node:m,offset:l-a};a=w}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=dy(m)}}function fy(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?fy(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function my(){for(var a=window,l=ze();l instanceof a.HTMLIFrameElement;){try{var m=typeof l.contentWindow.location.href=="string"}catch{m=!1}if(m)a=l.contentWindow;else break;l=ze(a.document)}return l}function $h(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l&&(l==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||l==="textarea"||a.contentEditable==="true")}function A_(a){var l=my(),m=a.focusedElem,w=a.selectionRange;if(l!==m&&m&&m.ownerDocument&&fy(m.ownerDocument.documentElement,m)){if(w!==null&&$h(m)){if(l=w.start,a=w.end,a===void 0&&(a=l),"selectionStart"in m)m.selectionStart=l,m.selectionEnd=Math.min(a,m.value.length);else if(a=(l=m.ownerDocument||document)&&l.defaultView||window,a.getSelection){a=a.getSelection();var C=m.textContent.length,T=Math.min(w.start,C);w=w.end===void 0?T:Math.min(w.end,C),!a.extend&&T>w&&(C=w,w=T,T=C),C=uy(m,T);var D=uy(m,w);C&&D&&(a.rangeCount!==1||a.anchorNode!==C.node||a.anchorOffset!==C.offset||a.focusNode!==D.node||a.focusOffset!==D.offset)&&(l=l.createRange(),l.setStart(C.node,C.offset),a.removeAllRanges(),T>w?(a.addRange(l),a.extend(D.node,D.offset)):(l.setEnd(D.node,D.offset),a.addRange(l)))}}for(l=[],a=m;a=a.parentNode;)a.nodeType===1&&l.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<l.length;m++)a=l[m],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var O_=d&&"documentMode"in document&&11>=document.documentMode,xi=null,_h=null,Vl=null,Th=!1;function hy(a,l,m){var w=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;Th||xi==null||xi!==ze(w)||(w=xi,"selectionStart"in w&&$h(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}),Vl&&Kl(Vl,w)||(Vl=w,w=nu(_h,"onSelect"),0<w.length&&(l=new yh("onSelect","select",null,l,m),a.push({event:l,listeners:w}),l.target=xi)))}function Zd(a,l){var m={};return m[a.toLowerCase()]=l.toLowerCase(),m["Webkit"+a]="webkit"+l,m["Moz"+a]="moz"+l,m}var vi={animationend:Zd("Animation","AnimationEnd"),animationiteration:Zd("Animation","AnimationIteration"),animationstart:Zd("Animation","AnimationStart"),transitionend:Zd("Transition","TransitionEnd")},Rh={},py={};d&&(py=document.createElement("div").style,"AnimationEvent"in window||(delete vi.animationend.animation,delete vi.animationiteration.animation,delete vi.animationstart.animation),"TransitionEvent"in window||delete vi.transitionend.transition);function eu(a){if(Rh[a])return Rh[a];if(!vi[a])return a;var l=vi[a],m;for(m in l)if(l.hasOwnProperty(m)&&m in py)return Rh[a]=l[m];return a}var gy=eu("animationend"),xy=eu("animationiteration"),vy=eu("animationstart"),by=eu("transitionend"),yy=new Map,wy="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 xo(a,l){yy.set(a,l),i(l,[a])}for(var Ah=0;Ah<wy.length;Ah++){var Oh=wy[Ah],L_=Oh.toLowerCase(),M_=Oh[0].toUpperCase()+Oh.slice(1);xo(L_,"on"+M_)}xo(gy,"onAnimationEnd"),xo(xy,"onAnimationIteration"),xo(vy,"onAnimationStart"),xo("dblclick","onDoubleClick"),xo("focusin","onFocus"),xo("focusout","onBlur"),xo(by,"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 Yl="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(" "),P_=new Set("cancel close invalid load scroll toggle".split(" ").concat(Yl));function jy(a,l,m){var w=a.type||"unknown-event";a.currentTarget=m,ee(w,l,void 0,a),a.currentTarget=null}function ky(a,l){l=(l&4)!==0;for(var m=0;m<a.length;m++){var w=a[m],C=w.event;w=w.listeners;e:{var T=void 0;if(l)for(var D=w.length-1;0<=D;D--){var Y=w[D],Z=Y.instance,ue=Y.currentTarget;if(Y=Y.listener,Z!==T&&C.isPropagationStopped())break e;jy(C,Y,ue),T=Z}else for(D=0;D<w.length;D++){if(Y=w[D],Z=Y.instance,ue=Y.currentTarget,Y=Y.listener,Z!==T&&C.isPropagationStopped())break e;jy(C,Y,ue),T=Z}}}if(qn)throw a=As,qn=!1,As=null,a}function Gt(a,l){var m=l[Uh];m===void 0&&(m=l[Uh]=new Set);var w=a+"__bubble";m.has(w)||(Ny(l,a,2,!1),m.add(w))}function Lh(a,l,m){var w=0;l&&(w|=4),Ny(m,a,w,l)}var tu="_reactListening"+Math.random().toString(36).slice(2);function Ql(a){if(!a[tu]){a[tu]=!0,r.forEach(function(m){m!=="selectionchange"&&(P_.has(m)||Lh(m,!1,a),Lh(m,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[tu]||(l[tu]=!0,Lh("selectionchange",!1,l))}}function Ny(a,l,m,w){switch(Kb(l)){case 1:var C=po;break;case 4:C=xr;break;default:C=xh}m=C.bind(null,l,m,a),C=void 0,!vs||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(C=!0),w?C!==void 0?a.addEventListener(l,m,{capture:!0,passive:C}):a.addEventListener(l,m,!0):C!==void 0?a.addEventListener(l,m,{passive:C}):a.addEventListener(l,m,!1)}function Mh(a,l,m,w,C){var T=w;if((l&1)===0&&(l&2)===0&&w!==null)e:for(;;){if(w===null)return;var D=w.tag;if(D===3||D===4){var Y=w.stateNode.containerInfo;if(Y===C||Y.nodeType===8&&Y.parentNode===C)break;if(D===4)for(D=w.return;D!==null;){var Z=D.tag;if((Z===3||Z===4)&&(Z=D.stateNode.containerInfo,Z===C||Z.nodeType===8&&Z.parentNode===C))return;D=D.return}for(;Y!==null;){if(D=fa(Y),D===null)return;if(Z=D.tag,Z===5||Z===6){w=T=D;continue e}Y=Y.parentNode}}w=w.return}_n(function(){var ue=T,ke=ge(m),Ee=[];e:{var we=yy.get(a);if(we!==void 0){var Ge=yh,Xe=a;switch(a){case"keypress":if(Yd(m)===0)break e;case"keydown":case"keyup":Ge=f_;break;case"focusin":Xe="focus",Ge=kh;break;case"focusout":Xe="blur",Ge=kh;break;case"beforeblur":case"afterblur":Ge=kh;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":Ge=Qb;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ge=e_;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ge=p_;break;case gy:case xy:case vy:Ge=s_;break;case by:Ge=x_;break;case"scroll":Ge=X$;break;case"wheel":Ge=b_;break;case"copy":case"cut":case"paste":Ge=o_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ge=Xb}var Ze=(l&4)!==0,an=!Ze&&a==="scroll",le=Ze?we!==null?we+"Capture":null:we;Ze=[];for(var oe=ue,ce;oe!==null;){ce=oe;var Re=ce.stateNode;if(ce.tag===5&&Re!==null&&(ce=Re,le!==null&&(Re=Bn(oe,le),Re!=null&&Ze.push(Jl(oe,Re,ce)))),an)break;oe=oe.return}0<Ze.length&&(we=new Ge(we,Xe,null,m,ke),Ee.push({event:we,listeners:Ze}))}}if((l&7)===0){e:{if(we=a==="mouseover"||a==="pointerover",Ge=a==="mouseout"||a==="pointerout",we&&m!==X&&(Xe=m.relatedTarget||m.fromElement)&&(fa(Xe)||Xe[Dr]))break e;if((Ge||we)&&(we=ke.window===ke?ke:(we=ke.ownerDocument)?we.defaultView||we.parentWindow:window,Ge?(Xe=m.relatedTarget||m.toElement,Ge=ue,Xe=Xe?fa(Xe):null,Xe!==null&&(an=Me(Xe),Xe!==an||Xe.tag!==5&&Xe.tag!==6)&&(Xe=null)):(Ge=null,Xe=ue),Ge!==Xe)){if(Ze=Qb,Re="onMouseLeave",le="onMouseEnter",oe="mouse",(a==="pointerout"||a==="pointerover")&&(Ze=Xb,Re="onPointerLeave",le="onPointerEnter",oe="pointer"),an=Ge==null?we:wi(Ge),ce=Xe==null?we:wi(Xe),we=new Ze(Re,oe+"leave",Ge,m,ke),we.target=an,we.relatedTarget=ce,Re=null,fa(ke)===ue&&(Ze=new Ze(le,oe+"enter",Xe,m,ke),Ze.target=ce,Ze.relatedTarget=an,Re=Ze),an=Re,Ge&&Xe)t:{for(Ze=Ge,le=Xe,oe=0,ce=Ze;ce;ce=bi(ce))oe++;for(ce=0,Re=le;Re;Re=bi(Re))ce++;for(;0<oe-ce;)Ze=bi(Ze),oe--;for(;0<ce-oe;)le=bi(le),ce--;for(;oe--;){if(Ze===le||le!==null&&Ze===le.alternate)break t;Ze=bi(Ze),le=bi(le)}Ze=null}else Ze=null;Ge!==null&&Sy(Ee,we,Ge,Ze,!1),Xe!==null&&an!==null&&Sy(Ee,an,Xe,Ze,!0)}}e:{if(we=ue?wi(ue):window,Ge=we.nodeName&&we.nodeName.toLowerCase(),Ge==="select"||Ge==="input"&&we.type==="file")var et=C_;else if(ry(we))if(ay)et=T_;else{et=$_;var rt=E_}else(Ge=we.nodeName)&&Ge.toLowerCase()==="input"&&(we.type==="checkbox"||we.type==="radio")&&(et=__);if(et&&(et=et(a,ue))){oy(Ee,et,m,ke);break e}rt&&rt(a,we,ue),a==="focusout"&&(rt=we._wrapperState)&&rt.controlled&&we.type==="number"&&fe(we,"number",we.value)}switch(rt=ue?wi(ue):window,a){case"focusin":(ry(rt)||rt.contentEditable==="true")&&(xi=rt,_h=ue,Vl=null);break;case"focusout":Vl=_h=xi=null;break;case"mousedown":Th=!0;break;case"contextmenu":case"mouseup":case"dragend":Th=!1,hy(Ee,m,ke);break;case"selectionchange":if(O_)break;case"keydown":case"keyup":hy(Ee,m,ke)}var ot;if(Sh)e:{switch(a){case"compositionstart":var ct="onCompositionStart";break e;case"compositionend":ct="onCompositionEnd";break e;case"compositionupdate":ct="onCompositionUpdate";break e}ct=void 0}else gi?ny(a,m)&&(ct="onCompositionEnd"):a==="keydown"&&m.keyCode===229&&(ct="onCompositionStart");ct&&(Zb&&m.locale!=="ko"&&(gi||ct!=="onCompositionStart"?ct==="onCompositionEnd"&&gi&&(ot=Vb()):(go=ke,bh="value"in go?go.value:go.textContent,gi=!0)),rt=nu(ue,ct),0<rt.length&&(ct=new Jb(ct,a,null,m,ke),Ee.push({event:ct,listeners:rt}),ot?ct.data=ot:(ot=sy(m),ot!==null&&(ct.data=ot)))),(ot=w_?j_(a,m):k_(a,m))&&(ue=nu(ue,"onBeforeInput"),0<ue.length&&(ke=new Jb("onBeforeInput","beforeinput",null,m,ke),Ee.push({event:ke,listeners:ue}),ke.data=ot))}ky(Ee,l)})}function Jl(a,l,m){return{instance:a,listener:l,currentTarget:m}}function nu(a,l){for(var m=l+"Capture",w=[];a!==null;){var C=a,T=C.stateNode;C.tag===5&&T!==null&&(C=T,T=Bn(a,m),T!=null&&w.unshift(Jl(a,T,C)),T=Bn(a,l),T!=null&&w.push(Jl(a,T,C))),a=a.return}return w}function bi(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function Sy(a,l,m,w,C){for(var T=l._reactName,D=[];m!==null&&m!==w;){var Y=m,Z=Y.alternate,ue=Y.stateNode;if(Z!==null&&Z===w)break;Y.tag===5&&ue!==null&&(Y=ue,C?(Z=Bn(m,T),Z!=null&&D.unshift(Jl(m,Z,Y))):C||(Z=Bn(m,T),Z!=null&&D.push(Jl(m,Z,Y)))),m=m.return}D.length!==0&&a.push({event:l,listeners:D})}var I_=/\r\n?/g,z_=/\u0000|\uFFFD/g;function Cy(a){return(typeof a=="string"?a:""+a).replace(I_,`
|
|
38
|
-
`).replace(z_,"")}function su(a,l,m){if(l=Cy(l),Cy(a)!==l&&m)throw Error(s(425))}function ru(){}var Ph=null,Ih=null;function zh(a,l){return a==="textarea"||a==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var Dh=typeof setTimeout=="function"?setTimeout:void 0,D_=typeof clearTimeout=="function"?clearTimeout:void 0,Ey=typeof Promise=="function"?Promise:void 0,F_=typeof queueMicrotask=="function"?queueMicrotask:typeof Ey<"u"?function(a){return Ey.resolve(null).then(a).catch(U_)}:Dh;function U_(a){setTimeout(function(){throw a})}function Fh(a,l){var m=l,w=0;do{var C=m.nextSibling;if(a.removeChild(m),C&&C.nodeType===8)if(m=C.data,m==="/$"){if(w===0){a.removeChild(C),ho(l);return}w--}else m!=="$"&&m!=="$?"&&m!=="$!"||w++;m=C}while(m);ho(l)}function vo(a){for(;a!=null;a=a.nextSibling){var l=a.nodeType;if(l===1||l===3)break;if(l===8){if(l=a.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return a}function $y(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var m=a.data;if(m==="$"||m==="$!"||m==="$?"){if(l===0)return a;l--}else m==="/$"&&l++}a=a.previousSibling}return null}var yi=Math.random().toString(36).slice(2),vr="__reactFiber$"+yi,Xl="__reactProps$"+yi,Dr="__reactContainer$"+yi,Uh="__reactEvents$"+yi,W_="__reactListeners$"+yi,H_="__reactHandles$"+yi;function fa(a){var l=a[vr];if(l)return l;for(var m=a.parentNode;m;){if(l=m[Dr]||m[vr]){if(m=l.alternate,l.child!==null||m!==null&&m.child!==null)for(a=$y(a);a!==null;){if(m=a[vr])return m;a=$y(a)}return l}a=m,m=a.parentNode}return null}function Zl(a){return a=a[vr]||a[Dr],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function wi(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(s(33))}function ou(a){return a[Xl]||null}var Wh=[],ji=-1;function bo(a){return{current:a}}function qt(a){0>ji||(a.current=Wh[ji],Wh[ji]=null,ji--)}function Ut(a,l){ji++,Wh[ji]=a.current,a.current=l}var yo={},Mn=bo(yo),ls=bo(!1),ma=yo;function ki(a,l){var m=a.type.contextTypes;if(!m)return yo;var w=a.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===l)return w.__reactInternalMemoizedMaskedChildContext;var C={},T;for(T in m)C[T]=l[T];return w&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=l,a.__reactInternalMemoizedMaskedChildContext=C),C}function cs(a){return a=a.childContextTypes,a!=null}function au(){qt(ls),qt(Mn)}function _y(a,l,m){if(Mn.current!==yo)throw Error(s(168));Ut(Mn,l),Ut(ls,m)}function Ty(a,l,m){var w=a.stateNode;if(l=l.childContextTypes,typeof w.getChildContext!="function")return m;w=w.getChildContext();for(var C in w)if(!(C in l))throw Error(s(108,me(a)||"Unknown",C));return G({},m,w)}function iu(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||yo,ma=Mn.current,Ut(Mn,a),Ut(ls,ls.current),!0}function Ry(a,l,m){var w=a.stateNode;if(!w)throw Error(s(169));m?(a=Ty(a,l,ma),w.__reactInternalMemoizedMergedChildContext=a,qt(ls),qt(Mn),Ut(Mn,a)):qt(ls),Ut(ls,m)}var Fr=null,lu=!1,Hh=!1;function Ay(a){Fr===null?Fr=[a]:Fr.push(a)}function B_(a){lu=!0,Ay(a)}function wo(){if(!Hh&&Fr!==null){Hh=!0;var a=0,l=$t;try{var m=Fr;for($t=1;a<m.length;a++){var w=m[a];do w=w(!0);while(w!==null)}Fr=null,lu=!1}catch(C){throw Fr!==null&&(Fr=Fr.slice(a+1)),ye(Tn,wo),C}finally{$t=l,Hh=!1}}return null}var Ni=[],Si=0,cu=null,du=0,Ls=[],Ms=0,ha=null,Ur=1,Wr="";function pa(a,l){Ni[Si++]=du,Ni[Si++]=cu,cu=a,du=l}function Oy(a,l,m){Ls[Ms++]=Ur,Ls[Ms++]=Wr,Ls[Ms++]=ha,ha=a;var w=Ur;a=Wr;var C=32-as(w)-1;w&=~(1<<C),m+=1;var T=32-as(l)+C;if(30<T){var D=C-C%5;T=(w&(1<<D)-1).toString(32),w>>=D,C-=D,Ur=1<<32-as(l)+C|m<<C|w,Wr=T+a}else Ur=1<<T|m<<C|w,Wr=a}function Bh(a){a.return!==null&&(pa(a,1),Oy(a,1,0))}function Gh(a){for(;a===cu;)cu=Ni[--Si],Ni[Si]=null,du=Ni[--Si],Ni[Si]=null;for(;a===ha;)ha=Ls[--Ms],Ls[Ms]=null,Wr=Ls[--Ms],Ls[Ms]=null,Ur=Ls[--Ms],Ls[Ms]=null}var js=null,ks=null,Yt=!1,sr=null;function Ly(a,l){var m=Ds(5,null,null,0);m.elementType="DELETED",m.stateNode=l,m.return=a,l=a.deletions,l===null?(a.deletions=[m],a.flags|=16):l.push(m)}function My(a,l){switch(a.tag){case 5:var m=a.type;return l=l.nodeType!==1||m.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(a.stateNode=l,js=a,ks=vo(l.firstChild),!0):!1;case 6:return l=a.pendingProps===""||l.nodeType!==3?null:l,l!==null?(a.stateNode=l,js=a,ks=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(m=ha!==null?{id:Ur,overflow:Wr}:null,a.memoizedState={dehydrated:l,treeContext:m,retryLane:1073741824},m=Ds(18,null,null,0),m.stateNode=l,m.return=a,a.child=m,js=a,ks=null,!0):!1;default:return!1}}function qh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Kh(a){if(Yt){var l=ks;if(l){var m=l;if(!My(a,l)){if(qh(a))throw Error(s(418));l=vo(m.nextSibling);var w=js;l&&My(a,l)?Ly(w,m):(a.flags=a.flags&-4097|2,Yt=!1,js=a)}}else{if(qh(a))throw Error(s(418));a.flags=a.flags&-4097|2,Yt=!1,js=a}}}function Py(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;js=a}function uu(a){if(a!==js)return!1;if(!Yt)return Py(a),Yt=!0,!1;var l;if((l=a.tag!==3)&&!(l=a.tag!==5)&&(l=a.type,l=l!=="head"&&l!=="body"&&!zh(a.type,a.memoizedProps)),l&&(l=ks)){if(qh(a))throw Iy(),Error(s(418));for(;l;)Ly(a,l),l=vo(l.nextSibling)}if(Py(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(s(317));e:{for(a=a.nextSibling,l=0;a;){if(a.nodeType===8){var m=a.data;if(m==="/$"){if(l===0){ks=vo(a.nextSibling);break e}l--}else m!=="$"&&m!=="$!"&&m!=="$?"||l++}a=a.nextSibling}ks=null}}else ks=js?vo(a.stateNode.nextSibling):null;return!0}function Iy(){for(var a=ks;a;)a=vo(a.nextSibling)}function Ci(){ks=js=null,Yt=!1}function Vh(a){sr===null?sr=[a]:sr.push(a)}var G_=N.ReactCurrentBatchConfig;function ec(a,l,m){if(a=m.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(s(309));var w=m.stateNode}if(!w)throw Error(s(147,a));var C=w,T=""+a;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===T?l.ref:(l=function(D){var Y=C.refs;D===null?delete Y[T]:Y[T]=D},l._stringRef=T,l)}if(typeof a!="string")throw Error(s(284));if(!m._owner)throw Error(s(290,a))}return a}function fu(a,l){throw a=Object.prototype.toString.call(l),Error(s(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a))}function zy(a){var l=a._init;return l(a._payload)}function Dy(a){function l(le,oe){if(a){var ce=le.deletions;ce===null?(le.deletions=[oe],le.flags|=16):ce.push(oe)}}function m(le,oe){if(!a)return null;for(;oe!==null;)l(le,oe),oe=oe.sibling;return null}function w(le,oe){for(le=new Map;oe!==null;)oe.key!==null?le.set(oe.key,oe):le.set(oe.index,oe),oe=oe.sibling;return le}function C(le,oe){return le=_o(le,oe),le.index=0,le.sibling=null,le}function T(le,oe,ce){return le.index=ce,a?(ce=le.alternate,ce!==null?(ce=ce.index,ce<oe?(le.flags|=2,oe):ce):(le.flags|=2,oe)):(le.flags|=1048576,oe)}function D(le){return a&&le.alternate===null&&(le.flags|=2),le}function Y(le,oe,ce,Re){return oe===null||oe.tag!==6?(oe=Dp(ce,le.mode,Re),oe.return=le,oe):(oe=C(oe,ce),oe.return=le,oe)}function Z(le,oe,ce,Re){var et=ce.type;return et===O?ke(le,oe,ce.props.children,Re,ce.key):oe!==null&&(oe.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===W&&zy(et)===oe.type)?(Re=C(oe,ce.props),Re.ref=ec(le,oe,ce),Re.return=le,Re):(Re=Pu(ce.type,ce.key,ce.props,null,le.mode,Re),Re.ref=ec(le,oe,ce),Re.return=le,Re)}function ue(le,oe,ce,Re){return oe===null||oe.tag!==4||oe.stateNode.containerInfo!==ce.containerInfo||oe.stateNode.implementation!==ce.implementation?(oe=Fp(ce,le.mode,Re),oe.return=le,oe):(oe=C(oe,ce.children||[]),oe.return=le,oe)}function ke(le,oe,ce,Re,et){return oe===null||oe.tag!==7?(oe=ka(ce,le.mode,Re,et),oe.return=le,oe):(oe=C(oe,ce),oe.return=le,oe)}function Ee(le,oe,ce){if(typeof oe=="string"&&oe!==""||typeof oe=="number")return oe=Dp(""+oe,le.mode,ce),oe.return=le,oe;if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case $:return ce=Pu(oe.type,oe.key,oe.props,null,le.mode,ce),ce.ref=ec(le,null,oe),ce.return=le,ce;case _:return oe=Fp(oe,le.mode,ce),oe.return=le,oe;case W:var Re=oe._init;return Ee(le,Re(oe._payload),ce)}if(Le(oe)||H(oe))return oe=ka(oe,le.mode,ce,null),oe.return=le,oe;fu(le,oe)}return null}function we(le,oe,ce,Re){var et=oe!==null?oe.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return et!==null?null:Y(le,oe,""+ce,Re);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:return ce.key===et?Z(le,oe,ce,Re):null;case _:return ce.key===et?ue(le,oe,ce,Re):null;case W:return et=ce._init,we(le,oe,et(ce._payload),Re)}if(Le(ce)||H(ce))return et!==null?null:ke(le,oe,ce,Re,null);fu(le,ce)}return null}function Ge(le,oe,ce,Re,et){if(typeof Re=="string"&&Re!==""||typeof Re=="number")return le=le.get(ce)||null,Y(oe,le,""+Re,et);if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case $:return le=le.get(Re.key===null?ce:Re.key)||null,Z(oe,le,Re,et);case _:return le=le.get(Re.key===null?ce:Re.key)||null,ue(oe,le,Re,et);case W:var rt=Re._init;return Ge(le,oe,ce,rt(Re._payload),et)}if(Le(Re)||H(Re))return le=le.get(ce)||null,ke(oe,le,Re,et,null);fu(oe,Re)}return null}function Xe(le,oe,ce,Re){for(var et=null,rt=null,ot=oe,ct=oe=0,Sn=null;ot!==null&&ct<ce.length;ct++){ot.index>ct?(Sn=ot,ot=null):Sn=ot.sibling;var Tt=we(le,ot,ce[ct],Re);if(Tt===null){ot===null&&(ot=Sn);break}a&&ot&&Tt.alternate===null&&l(le,ot),oe=T(Tt,oe,ct),rt===null?et=Tt:rt.sibling=Tt,rt=Tt,ot=Sn}if(ct===ce.length)return m(le,ot),Yt&&pa(le,ct),et;if(ot===null){for(;ct<ce.length;ct++)ot=Ee(le,ce[ct],Re),ot!==null&&(oe=T(ot,oe,ct),rt===null?et=ot:rt.sibling=ot,rt=ot);return Yt&&pa(le,ct),et}for(ot=w(le,ot);ct<ce.length;ct++)Sn=Ge(ot,le,ct,ce[ct],Re),Sn!==null&&(a&&Sn.alternate!==null&&ot.delete(Sn.key===null?ct:Sn.key),oe=T(Sn,oe,ct),rt===null?et=Sn:rt.sibling=Sn,rt=Sn);return a&&ot.forEach(function(To){return l(le,To)}),Yt&&pa(le,ct),et}function Ze(le,oe,ce,Re){var et=H(ce);if(typeof et!="function")throw Error(s(150));if(ce=et.call(ce),ce==null)throw Error(s(151));for(var rt=et=null,ot=oe,ct=oe=0,Sn=null,Tt=ce.next();ot!==null&&!Tt.done;ct++,Tt=ce.next()){ot.index>ct?(Sn=ot,ot=null):Sn=ot.sibling;var To=we(le,ot,Tt.value,Re);if(To===null){ot===null&&(ot=Sn);break}a&&ot&&To.alternate===null&&l(le,ot),oe=T(To,oe,ct),rt===null?et=To:rt.sibling=To,rt=To,ot=Sn}if(Tt.done)return m(le,ot),Yt&&pa(le,ct),et;if(ot===null){for(;!Tt.done;ct++,Tt=ce.next())Tt=Ee(le,Tt.value,Re),Tt!==null&&(oe=T(Tt,oe,ct),rt===null?et=Tt:rt.sibling=Tt,rt=Tt);return Yt&&pa(le,ct),et}for(ot=w(le,ot);!Tt.done;ct++,Tt=ce.next())Tt=Ge(ot,le,ct,Tt.value,Re),Tt!==null&&(a&&Tt.alternate!==null&&ot.delete(Tt.key===null?ct:Tt.key),oe=T(Tt,oe,ct),rt===null?et=Tt:rt.sibling=Tt,rt=Tt);return a&&ot.forEach(function(NT){return l(le,NT)}),Yt&&pa(le,ct),et}function an(le,oe,ce,Re){if(typeof ce=="object"&&ce!==null&&ce.type===O&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:e:{for(var et=ce.key,rt=oe;rt!==null;){if(rt.key===et){if(et=ce.type,et===O){if(rt.tag===7){m(le,rt.sibling),oe=C(rt,ce.props.children),oe.return=le,le=oe;break e}}else if(rt.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===W&&zy(et)===rt.type){m(le,rt.sibling),oe=C(rt,ce.props),oe.ref=ec(le,rt,ce),oe.return=le,le=oe;break e}m(le,rt);break}else l(le,rt);rt=rt.sibling}ce.type===O?(oe=ka(ce.props.children,le.mode,Re,ce.key),oe.return=le,le=oe):(Re=Pu(ce.type,ce.key,ce.props,null,le.mode,Re),Re.ref=ec(le,oe,ce),Re.return=le,le=Re)}return D(le);case _:e:{for(rt=ce.key;oe!==null;){if(oe.key===rt)if(oe.tag===4&&oe.stateNode.containerInfo===ce.containerInfo&&oe.stateNode.implementation===ce.implementation){m(le,oe.sibling),oe=C(oe,ce.children||[]),oe.return=le,le=oe;break e}else{m(le,oe);break}else l(le,oe);oe=oe.sibling}oe=Fp(ce,le.mode,Re),oe.return=le,le=oe}return D(le);case W:return rt=ce._init,an(le,oe,rt(ce._payload),Re)}if(Le(ce))return Xe(le,oe,ce,Re);if(H(ce))return Ze(le,oe,ce,Re);fu(le,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,oe!==null&&oe.tag===6?(m(le,oe.sibling),oe=C(oe,ce),oe.return=le,le=oe):(m(le,oe),oe=Dp(ce,le.mode,Re),oe.return=le,le=oe),D(le)):m(le,oe)}return an}var Ei=Dy(!0),Fy=Dy(!1),mu=bo(null),hu=null,$i=null,Yh=null;function Qh(){Yh=$i=hu=null}function Jh(a){var l=mu.current;qt(mu),a._currentValue=l}function Xh(a,l,m){for(;a!==null;){var w=a.alternate;if((a.childLanes&l)!==l?(a.childLanes|=l,w!==null&&(w.childLanes|=l)):w!==null&&(w.childLanes&l)!==l&&(w.childLanes|=l),a===m)break;a=a.return}}function _i(a,l){hu=a,Yh=$i=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&l)!==0&&(ds=!0),a.firstContext=null)}function Ps(a){var l=a._currentValue;if(Yh!==a)if(a={context:a,memoizedValue:l,next:null},$i===null){if(hu===null)throw Error(s(308));$i=a,hu.dependencies={lanes:0,firstContext:a}}else $i=$i.next=a;return l}var ga=null;function Zh(a){ga===null?ga=[a]:ga.push(a)}function Uy(a,l,m,w){var C=l.interleaved;return C===null?(m.next=m,Zh(l)):(m.next=C.next,C.next=m),l.interleaved=m,Hr(a,w)}function Hr(a,l){a.lanes|=l;var m=a.alternate;for(m!==null&&(m.lanes|=l),m=a,a=a.return;a!==null;)a.childLanes|=l,m=a.alternate,m!==null&&(m.childLanes|=l),m=a,a=a.return;return m.tag===3?m.stateNode:null}var jo=!1;function ep(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Wy(a,l){a=a.updateQueue,l.updateQueue===a&&(l.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function Br(a,l){return{eventTime:a,lane:l,tag:0,payload:null,callback:null,next:null}}function ko(a,l,m){var w=a.updateQueue;if(w===null)return null;if(w=w.shared,(Ct&2)!==0){var C=w.pending;return C===null?l.next=l:(l.next=C.next,C.next=l),w.pending=l,Hr(a,m)}return C=w.interleaved,C===null?(l.next=l,Zh(w)):(l.next=C.next,C.next=l),w.interleaved=l,Hr(a,m)}function pu(a,l,m){if(l=l.updateQueue,l!==null&&(l=l.shared,(m&4194240)!==0)){var w=l.lanes;w&=a.pendingLanes,m|=w,l.lanes=m,ui(a,m)}}function Hy(a,l){var m=a.updateQueue,w=a.alternate;if(w!==null&&(w=w.updateQueue,m===w)){var C=null,T=null;if(m=m.firstBaseUpdate,m!==null){do{var D={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};T===null?C=T=D:T=T.next=D,m=m.next}while(m!==null);T===null?C=T=l:T=T.next=l}else C=T=l;m={baseState:w.baseState,firstBaseUpdate:C,lastBaseUpdate:T,shared:w.shared,effects:w.effects},a.updateQueue=m;return}a=m.lastBaseUpdate,a===null?m.firstBaseUpdate=l:a.next=l,m.lastBaseUpdate=l}function gu(a,l,m,w){var C=a.updateQueue;jo=!1;var T=C.firstBaseUpdate,D=C.lastBaseUpdate,Y=C.shared.pending;if(Y!==null){C.shared.pending=null;var Z=Y,ue=Z.next;Z.next=null,D===null?T=ue:D.next=ue,D=Z;var ke=a.alternate;ke!==null&&(ke=ke.updateQueue,Y=ke.lastBaseUpdate,Y!==D&&(Y===null?ke.firstBaseUpdate=ue:Y.next=ue,ke.lastBaseUpdate=Z))}if(T!==null){var Ee=C.baseState;D=0,ke=ue=Z=null,Y=T;do{var we=Y.lane,Ge=Y.eventTime;if((w&we)===we){ke!==null&&(ke=ke.next={eventTime:Ge,lane:0,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null});e:{var Xe=a,Ze=Y;switch(we=l,Ge=m,Ze.tag){case 1:if(Xe=Ze.payload,typeof Xe=="function"){Ee=Xe.call(Ge,Ee,we);break e}Ee=Xe;break e;case 3:Xe.flags=Xe.flags&-65537|128;case 0:if(Xe=Ze.payload,we=typeof Xe=="function"?Xe.call(Ge,Ee,we):Xe,we==null)break e;Ee=G({},Ee,we);break e;case 2:jo=!0}}Y.callback!==null&&Y.lane!==0&&(a.flags|=64,we=C.effects,we===null?C.effects=[Y]:we.push(Y))}else Ge={eventTime:Ge,lane:we,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null},ke===null?(ue=ke=Ge,Z=Ee):ke=ke.next=Ge,D|=we;if(Y=Y.next,Y===null){if(Y=C.shared.pending,Y===null)break;we=Y,Y=we.next,we.next=null,C.lastBaseUpdate=we,C.shared.pending=null}}while(!0);if(ke===null&&(Z=Ee),C.baseState=Z,C.firstBaseUpdate=ue,C.lastBaseUpdate=ke,l=C.shared.interleaved,l!==null){C=l;do D|=C.lane,C=C.next;while(C!==l)}else T===null&&(C.shared.lanes=0);ba|=D,a.lanes=D,a.memoizedState=Ee}}function By(a,l,m){if(a=l.effects,l.effects=null,a!==null)for(l=0;l<a.length;l++){var w=a[l],C=w.callback;if(C!==null){if(w.callback=null,w=m,typeof C!="function")throw Error(s(191,C));C.call(w)}}}var tc={},br=bo(tc),nc=bo(tc),sc=bo(tc);function xa(a){if(a===tc)throw Error(s(174));return a}function tp(a,l){switch(Ut(sc,l),Ut(nc,a),Ut(br,tc),a=l.nodeType,a){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:at(null,"");break;default:a=a===8?l.parentNode:l,l=a.namespaceURI||null,a=a.tagName,l=at(l,a)}qt(br),Ut(br,l)}function Ti(){qt(br),qt(nc),qt(sc)}function Gy(a){xa(sc.current);var l=xa(br.current),m=at(l,a.type);l!==m&&(Ut(nc,a),Ut(br,m))}function np(a){nc.current===a&&(qt(br),qt(nc))}var Zt=bo(0);function xu(a){for(var l=a;l!==null;){if(l.tag===13){var m=l.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var sp=[];function rp(){for(var a=0;a<sp.length;a++)sp[a]._workInProgressVersionPrimary=null;sp.length=0}var vu=N.ReactCurrentDispatcher,op=N.ReactCurrentBatchConfig,va=0,en=null,bn=null,kn=null,bu=!1,rc=!1,oc=0,q_=0;function Pn(){throw Error(s(321))}function ap(a,l){if(l===null)return!1;for(var m=0;m<l.length&&m<a.length;m++)if(!nr(a[m],l[m]))return!1;return!0}function ip(a,l,m,w,C,T){if(va=T,en=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,vu.current=a===null||a.memoizedState===null?Q_:J_,a=m(w,C),rc){T=0;do{if(rc=!1,oc=0,25<=T)throw Error(s(301));T+=1,kn=bn=null,l.updateQueue=null,vu.current=X_,a=m(w,C)}while(rc)}if(vu.current=ju,l=bn!==null&&bn.next!==null,va=0,kn=bn=en=null,bu=!1,l)throw Error(s(300));return a}function lp(){var a=oc!==0;return oc=0,a}function yr(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return kn===null?en.memoizedState=kn=a:kn=kn.next=a,kn}function Is(){if(bn===null){var a=en.alternate;a=a!==null?a.memoizedState:null}else a=bn.next;var l=kn===null?en.memoizedState:kn.next;if(l!==null)kn=l,bn=a;else{if(a===null)throw Error(s(310));bn=a,a={memoizedState:bn.memoizedState,baseState:bn.baseState,baseQueue:bn.baseQueue,queue:bn.queue,next:null},kn===null?en.memoizedState=kn=a:kn=kn.next=a}return kn}function ac(a,l){return typeof l=="function"?l(a):l}function cp(a){var l=Is(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=a;var w=bn,C=w.baseQueue,T=m.pending;if(T!==null){if(C!==null){var D=C.next;C.next=T.next,T.next=D}w.baseQueue=C=T,m.pending=null}if(C!==null){T=C.next,w=w.baseState;var Y=D=null,Z=null,ue=T;do{var ke=ue.lane;if((va&ke)===ke)Z!==null&&(Z=Z.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),w=ue.hasEagerState?ue.eagerState:a(w,ue.action);else{var Ee={lane:ke,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};Z===null?(Y=Z=Ee,D=w):Z=Z.next=Ee,en.lanes|=ke,ba|=ke}ue=ue.next}while(ue!==null&&ue!==T);Z===null?D=w:Z.next=Y,nr(w,l.memoizedState)||(ds=!0),l.memoizedState=w,l.baseState=D,l.baseQueue=Z,m.lastRenderedState=w}if(a=m.interleaved,a!==null){C=a;do T=C.lane,en.lanes|=T,ba|=T,C=C.next;while(C!==a)}else C===null&&(m.lanes=0);return[l.memoizedState,m.dispatch]}function dp(a){var l=Is(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=a;var w=m.dispatch,C=m.pending,T=l.memoizedState;if(C!==null){m.pending=null;var D=C=C.next;do T=a(T,D.action),D=D.next;while(D!==C);nr(T,l.memoizedState)||(ds=!0),l.memoizedState=T,l.baseQueue===null&&(l.baseState=T),m.lastRenderedState=T}return[T,w]}function qy(){}function Ky(a,l){var m=en,w=Is(),C=l(),T=!nr(w.memoizedState,C);if(T&&(w.memoizedState=C,ds=!0),w=w.queue,up(Qy.bind(null,m,w,a),[a]),w.getSnapshot!==l||T||kn!==null&&kn.memoizedState.tag&1){if(m.flags|=2048,ic(9,Yy.bind(null,m,w,C,l),void 0,null),Nn===null)throw Error(s(349));(va&30)!==0||Vy(m,l,C)}return C}function Vy(a,l,m){a.flags|=16384,a={getSnapshot:l,value:m},l=en.updateQueue,l===null?(l={lastEffect:null,stores:null},en.updateQueue=l,l.stores=[a]):(m=l.stores,m===null?l.stores=[a]:m.push(a))}function Yy(a,l,m,w){l.value=m,l.getSnapshot=w,Jy(l)&&Xy(a)}function Qy(a,l,m){return m(function(){Jy(l)&&Xy(a)})}function Jy(a){var l=a.getSnapshot;a=a.value;try{var m=l();return!nr(a,m)}catch{return!0}}function Xy(a){var l=Hr(a,1);l!==null&&ir(l,a,1,-1)}function Zy(a){var l=yr();return typeof a=="function"&&(a=a()),l.memoizedState=l.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ac,lastRenderedState:a},l.queue=a,a=a.dispatch=Y_.bind(null,en,a),[l.memoizedState,a]}function ic(a,l,m,w){return a={tag:a,create:l,destroy:m,deps:w,next:null},l=en.updateQueue,l===null?(l={lastEffect:null,stores:null},en.updateQueue=l,l.lastEffect=a.next=a):(m=l.lastEffect,m===null?l.lastEffect=a.next=a:(w=m.next,m.next=a,a.next=w,l.lastEffect=a)),a}function ew(){return Is().memoizedState}function yu(a,l,m,w){var C=yr();en.flags|=a,C.memoizedState=ic(1|l,m,void 0,w===void 0?null:w)}function wu(a,l,m,w){var C=Is();w=w===void 0?null:w;var T=void 0;if(bn!==null){var D=bn.memoizedState;if(T=D.destroy,w!==null&&ap(w,D.deps)){C.memoizedState=ic(l,m,T,w);return}}en.flags|=a,C.memoizedState=ic(1|l,m,T,w)}function tw(a,l){return yu(8390656,8,a,l)}function up(a,l){return wu(2048,8,a,l)}function nw(a,l){return wu(4,2,a,l)}function sw(a,l){return wu(4,4,a,l)}function rw(a,l){if(typeof l=="function")return a=a(),l(a),function(){l(null)};if(l!=null)return a=a(),l.current=a,function(){l.current=null}}function ow(a,l,m){return m=m!=null?m.concat([a]):null,wu(4,4,rw.bind(null,l,a),m)}function fp(){}function aw(a,l){var m=Is();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&ap(l,w[1])?w[0]:(m.memoizedState=[a,l],a)}function iw(a,l){var m=Is();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&ap(l,w[1])?w[0]:(a=a(),m.memoizedState=[a,l],a)}function lw(a,l,m){return(va&21)===0?(a.baseState&&(a.baseState=!1,ds=!0),a.memoizedState=m):(nr(m,l)||(m=Pl(),en.lanes|=m,ba|=m,a.baseState=!0),l)}function K_(a,l){var m=$t;$t=m!==0&&4>m?m:4,a(!0);var w=op.transition;op.transition={};try{a(!1),l()}finally{$t=m,op.transition=w}}function cw(){return Is().memoizedState}function V_(a,l,m){var w=Eo(a);if(m={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null},dw(a))uw(l,m);else if(m=Uy(a,l,m,w),m!==null){var C=Qn();ir(m,a,w,C),fw(m,l,w)}}function Y_(a,l,m){var w=Eo(a),C={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null};if(dw(a))uw(l,C);else{var T=a.alternate;if(a.lanes===0&&(T===null||T.lanes===0)&&(T=l.lastRenderedReducer,T!==null))try{var D=l.lastRenderedState,Y=T(D,m);if(C.hasEagerState=!0,C.eagerState=Y,nr(Y,D)){var Z=l.interleaved;Z===null?(C.next=C,Zh(l)):(C.next=Z.next,Z.next=C),l.interleaved=C;return}}catch{}finally{}m=Uy(a,l,C,w),m!==null&&(C=Qn(),ir(m,a,w,C),fw(m,l,w))}}function dw(a){var l=a.alternate;return a===en||l!==null&&l===en}function uw(a,l){rc=bu=!0;var m=a.pending;m===null?l.next=l:(l.next=m.next,m.next=l),a.pending=l}function fw(a,l,m){if((m&4194240)!==0){var w=l.lanes;w&=a.pendingLanes,m|=w,l.lanes=m,ui(a,m)}}var ju={readContext:Ps,useCallback:Pn,useContext:Pn,useEffect:Pn,useImperativeHandle:Pn,useInsertionEffect:Pn,useLayoutEffect:Pn,useMemo:Pn,useReducer:Pn,useRef:Pn,useState:Pn,useDebugValue:Pn,useDeferredValue:Pn,useTransition:Pn,useMutableSource:Pn,useSyncExternalStore:Pn,useId:Pn,unstable_isNewReconciler:!1},Q_={readContext:Ps,useCallback:function(a,l){return yr().memoizedState=[a,l===void 0?null:l],a},useContext:Ps,useEffect:tw,useImperativeHandle:function(a,l,m){return m=m!=null?m.concat([a]):null,yu(4194308,4,rw.bind(null,l,a),m)},useLayoutEffect:function(a,l){return yu(4194308,4,a,l)},useInsertionEffect:function(a,l){return yu(4,2,a,l)},useMemo:function(a,l){var m=yr();return l=l===void 0?null:l,a=a(),m.memoizedState=[a,l],a},useReducer:function(a,l,m){var w=yr();return l=m!==void 0?m(l):l,w.memoizedState=w.baseState=l,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:l},w.queue=a,a=a.dispatch=V_.bind(null,en,a),[w.memoizedState,a]},useRef:function(a){var l=yr();return a={current:a},l.memoizedState=a},useState:Zy,useDebugValue:fp,useDeferredValue:function(a){return yr().memoizedState=a},useTransition:function(){var a=Zy(!1),l=a[0];return a=K_.bind(null,a[1]),yr().memoizedState=a,[l,a]},useMutableSource:function(){},useSyncExternalStore:function(a,l,m){var w=en,C=yr();if(Yt){if(m===void 0)throw Error(s(407));m=m()}else{if(m=l(),Nn===null)throw Error(s(349));(va&30)!==0||Vy(w,l,m)}C.memoizedState=m;var T={value:m,getSnapshot:l};return C.queue=T,tw(Qy.bind(null,w,T,a),[a]),w.flags|=2048,ic(9,Yy.bind(null,w,T,m,l),void 0,null),m},useId:function(){var a=yr(),l=Nn.identifierPrefix;if(Yt){var m=Wr,w=Ur;m=(w&~(1<<32-as(w)-1)).toString(32)+m,l=":"+l+"R"+m,m=oc++,0<m&&(l+="H"+m.toString(32)),l+=":"}else m=q_++,l=":"+l+"r"+m.toString(32)+":";return a.memoizedState=l},unstable_isNewReconciler:!1},J_={readContext:Ps,useCallback:aw,useContext:Ps,useEffect:up,useImperativeHandle:ow,useInsertionEffect:nw,useLayoutEffect:sw,useMemo:iw,useReducer:cp,useRef:ew,useState:function(){return cp(ac)},useDebugValue:fp,useDeferredValue:function(a){var l=Is();return lw(l,bn.memoizedState,a)},useTransition:function(){var a=cp(ac)[0],l=Is().memoizedState;return[a,l]},useMutableSource:qy,useSyncExternalStore:Ky,useId:cw,unstable_isNewReconciler:!1},X_={readContext:Ps,useCallback:aw,useContext:Ps,useEffect:up,useImperativeHandle:ow,useInsertionEffect:nw,useLayoutEffect:sw,useMemo:iw,useReducer:dp,useRef:ew,useState:function(){return dp(ac)},useDebugValue:fp,useDeferredValue:function(a){var l=Is();return bn===null?l.memoizedState=a:lw(l,bn.memoizedState,a)},useTransition:function(){var a=dp(ac)[0],l=Is().memoizedState;return[a,l]},useMutableSource:qy,useSyncExternalStore:Ky,useId:cw,unstable_isNewReconciler:!1};function rr(a,l){if(a&&a.defaultProps){l=G({},l),a=a.defaultProps;for(var m in a)l[m]===void 0&&(l[m]=a[m]);return l}return l}function mp(a,l,m,w){l=a.memoizedState,m=m(w,l),m=m==null?l:G({},l,m),a.memoizedState=m,a.lanes===0&&(a.updateQueue.baseState=m)}var ku={isMounted:function(a){return(a=a._reactInternals)?Me(a)===a:!1},enqueueSetState:function(a,l,m){a=a._reactInternals;var w=Qn(),C=Eo(a),T=Br(w,C);T.payload=l,m!=null&&(T.callback=m),l=ko(a,T,C),l!==null&&(ir(l,a,C,w),pu(l,a,C))},enqueueReplaceState:function(a,l,m){a=a._reactInternals;var w=Qn(),C=Eo(a),T=Br(w,C);T.tag=1,T.payload=l,m!=null&&(T.callback=m),l=ko(a,T,C),l!==null&&(ir(l,a,C,w),pu(l,a,C))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var m=Qn(),w=Eo(a),C=Br(m,w);C.tag=2,l!=null&&(C.callback=l),l=ko(a,C,w),l!==null&&(ir(l,a,w,m),pu(l,a,w))}};function mw(a,l,m,w,C,T,D){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(w,T,D):l.prototype&&l.prototype.isPureReactComponent?!Kl(m,w)||!Kl(C,T):!0}function hw(a,l,m){var w=!1,C=yo,T=l.contextType;return typeof T=="object"&&T!==null?T=Ps(T):(C=cs(l)?ma:Mn.current,w=l.contextTypes,T=(w=w!=null)?ki(a,C):yo),l=new l(m,T),a.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=ku,a.stateNode=l,l._reactInternals=a,w&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=C,a.__reactInternalMemoizedMaskedChildContext=T),l}function pw(a,l,m,w){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(m,w),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(m,w),l.state!==a&&ku.enqueueReplaceState(l,l.state,null)}function hp(a,l,m,w){var C=a.stateNode;C.props=m,C.state=a.memoizedState,C.refs={},ep(a);var T=l.contextType;typeof T=="object"&&T!==null?C.context=Ps(T):(T=cs(l)?ma:Mn.current,C.context=ki(a,T)),C.state=a.memoizedState,T=l.getDerivedStateFromProps,typeof T=="function"&&(mp(a,l,T,m),C.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(l=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),l!==C.state&&ku.enqueueReplaceState(C,C.state,null),gu(a,m,C,w),C.state=a.memoizedState),typeof C.componentDidMount=="function"&&(a.flags|=4194308)}function Ri(a,l){try{var m="",w=l;do m+=re(w),w=w.return;while(w);var C=m}catch(T){C=`
|
|
39
|
-
Error generating stack: `+T.message+`
|
|
40
|
-
`+T.stack}return{value:a,source:l,stack:C,digest:null}}function pp(a,l,m){return{value:a,source:null,stack:m??null,digest:l??null}}function gp(a,l){try{console.error(l.value)}catch(m){setTimeout(function(){throw m})}}var Z_=typeof WeakMap=="function"?WeakMap:Map;function gw(a,l,m){m=Br(-1,m),m.tag=3,m.payload={element:null};var w=l.value;return m.callback=function(){Tu||(Tu=!0,Rp=w),gp(a,l)},m}function xw(a,l,m){m=Br(-1,m),m.tag=3;var w=a.type.getDerivedStateFromError;if(typeof w=="function"){var C=l.value;m.payload=function(){return w(C)},m.callback=function(){gp(a,l)}}var T=a.stateNode;return T!==null&&typeof T.componentDidCatch=="function"&&(m.callback=function(){gp(a,l),typeof w!="function"&&(So===null?So=new Set([this]):So.add(this));var D=l.stack;this.componentDidCatch(l.value,{componentStack:D!==null?D:""})}),m}function vw(a,l,m){var w=a.pingCache;if(w===null){w=a.pingCache=new Z_;var C=new Set;w.set(l,C)}else C=w.get(l),C===void 0&&(C=new Set,w.set(l,C));C.has(m)||(C.add(m),a=mT.bind(null,a,l,m),l.then(a,a))}function bw(a){do{var l;if((l=a.tag===13)&&(l=a.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return a;a=a.return}while(a!==null);return null}function yw(a,l,m,w,C){return(a.mode&1)===0?(a===l?a.flags|=65536:(a.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(l=Br(-1,1),l.tag=2,ko(m,l,1))),m.lanes|=1),a):(a.flags|=65536,a.lanes=C,a)}var eT=N.ReactCurrentOwner,ds=!1;function Yn(a,l,m,w){l.child=a===null?Fy(l,null,m,w):Ei(l,a.child,m,w)}function ww(a,l,m,w,C){m=m.render;var T=l.ref;return _i(l,C),w=ip(a,l,m,w,T,C),m=lp(),a!==null&&!ds?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~C,Gr(a,l,C)):(Yt&&m&&Bh(l),l.flags|=1,Yn(a,l,w,C),l.child)}function jw(a,l,m,w,C){if(a===null){var T=m.type;return typeof T=="function"&&!zp(T)&&T.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(l.tag=15,l.type=T,kw(a,l,T,w,C)):(a=Pu(m.type,null,w,l,l.mode,C),a.ref=l.ref,a.return=l,l.child=a)}if(T=a.child,(a.lanes&C)===0){var D=T.memoizedProps;if(m=m.compare,m=m!==null?m:Kl,m(D,w)&&a.ref===l.ref)return Gr(a,l,C)}return l.flags|=1,a=_o(T,w),a.ref=l.ref,a.return=l,l.child=a}function kw(a,l,m,w,C){if(a!==null){var T=a.memoizedProps;if(Kl(T,w)&&a.ref===l.ref)if(ds=!1,l.pendingProps=w=T,(a.lanes&C)!==0)(a.flags&131072)!==0&&(ds=!0);else return l.lanes=a.lanes,Gr(a,l,C)}return xp(a,l,m,w,C)}function Nw(a,l,m){var w=l.pendingProps,C=w.children,T=a!==null?a.memoizedState:null;if(w.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ut(Oi,Ns),Ns|=m;else{if((m&1073741824)===0)return a=T!==null?T.baseLanes|m:m,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:a,cachePool:null,transitions:null},l.updateQueue=null,Ut(Oi,Ns),Ns|=a,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=T!==null?T.baseLanes:m,Ut(Oi,Ns),Ns|=w}else T!==null?(w=T.baseLanes|m,l.memoizedState=null):w=m,Ut(Oi,Ns),Ns|=w;return Yn(a,l,C,m),l.child}function Sw(a,l){var m=l.ref;(a===null&&m!==null||a!==null&&a.ref!==m)&&(l.flags|=512,l.flags|=2097152)}function xp(a,l,m,w,C){var T=cs(m)?ma:Mn.current;return T=ki(l,T),_i(l,C),m=ip(a,l,m,w,T,C),w=lp(),a!==null&&!ds?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~C,Gr(a,l,C)):(Yt&&w&&Bh(l),l.flags|=1,Yn(a,l,m,C),l.child)}function Cw(a,l,m,w,C){if(cs(m)){var T=!0;iu(l)}else T=!1;if(_i(l,C),l.stateNode===null)Su(a,l),hw(l,m,w),hp(l,m,w,C),w=!0;else if(a===null){var D=l.stateNode,Y=l.memoizedProps;D.props=Y;var Z=D.context,ue=m.contextType;typeof ue=="object"&&ue!==null?ue=Ps(ue):(ue=cs(m)?ma:Mn.current,ue=ki(l,ue));var ke=m.getDerivedStateFromProps,Ee=typeof ke=="function"||typeof D.getSnapshotBeforeUpdate=="function";Ee||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(Y!==w||Z!==ue)&&pw(l,D,w,ue),jo=!1;var we=l.memoizedState;D.state=we,gu(l,w,D,C),Z=l.memoizedState,Y!==w||we!==Z||ls.current||jo?(typeof ke=="function"&&(mp(l,m,ke,w),Z=l.memoizedState),(Y=jo||mw(l,m,Y,w,we,Z,ue))?(Ee||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount()),typeof D.componentDidMount=="function"&&(l.flags|=4194308)):(typeof D.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=w,l.memoizedState=Z),D.props=w,D.state=Z,D.context=ue,w=Y):(typeof D.componentDidMount=="function"&&(l.flags|=4194308),w=!1)}else{D=l.stateNode,Wy(a,l),Y=l.memoizedProps,ue=l.type===l.elementType?Y:rr(l.type,Y),D.props=ue,Ee=l.pendingProps,we=D.context,Z=m.contextType,typeof Z=="object"&&Z!==null?Z=Ps(Z):(Z=cs(m)?ma:Mn.current,Z=ki(l,Z));var Ge=m.getDerivedStateFromProps;(ke=typeof Ge=="function"||typeof D.getSnapshotBeforeUpdate=="function")||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(Y!==Ee||we!==Z)&&pw(l,D,w,Z),jo=!1,we=l.memoizedState,D.state=we,gu(l,w,D,C);var Xe=l.memoizedState;Y!==Ee||we!==Xe||ls.current||jo?(typeof Ge=="function"&&(mp(l,m,Ge,w),Xe=l.memoizedState),(ue=jo||mw(l,m,ue,w,we,Xe,Z)||!1)?(ke||typeof D.UNSAFE_componentWillUpdate!="function"&&typeof D.componentWillUpdate!="function"||(typeof D.componentWillUpdate=="function"&&D.componentWillUpdate(w,Xe,Z),typeof D.UNSAFE_componentWillUpdate=="function"&&D.UNSAFE_componentWillUpdate(w,Xe,Z)),typeof D.componentDidUpdate=="function"&&(l.flags|=4),typeof D.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof D.componentDidUpdate!="function"||Y===a.memoizedProps&&we===a.memoizedState||(l.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||Y===a.memoizedProps&&we===a.memoizedState||(l.flags|=1024),l.memoizedProps=w,l.memoizedState=Xe),D.props=w,D.state=Xe,D.context=Z,w=ue):(typeof D.componentDidUpdate!="function"||Y===a.memoizedProps&&we===a.memoizedState||(l.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||Y===a.memoizedProps&&we===a.memoizedState||(l.flags|=1024),w=!1)}return vp(a,l,m,w,T,C)}function vp(a,l,m,w,C,T){Sw(a,l);var D=(l.flags&128)!==0;if(!w&&!D)return C&&Ry(l,m,!1),Gr(a,l,T);w=l.stateNode,eT.current=l;var Y=D&&typeof m.getDerivedStateFromError!="function"?null:w.render();return l.flags|=1,a!==null&&D?(l.child=Ei(l,a.child,null,T),l.child=Ei(l,null,Y,T)):Yn(a,l,Y,T),l.memoizedState=w.state,C&&Ry(l,m,!0),l.child}function Ew(a){var l=a.stateNode;l.pendingContext?_y(a,l.pendingContext,l.pendingContext!==l.context):l.context&&_y(a,l.context,!1),tp(a,l.containerInfo)}function $w(a,l,m,w,C){return Ci(),Vh(C),l.flags|=256,Yn(a,l,m,w),l.child}var bp={dehydrated:null,treeContext:null,retryLane:0};function yp(a){return{baseLanes:a,cachePool:null,transitions:null}}function _w(a,l,m){var w=l.pendingProps,C=Zt.current,T=!1,D=(l.flags&128)!==0,Y;if((Y=D)||(Y=a!==null&&a.memoizedState===null?!1:(C&2)!==0),Y?(T=!0,l.flags&=-129):(a===null||a.memoizedState!==null)&&(C|=1),Ut(Zt,C&1),a===null)return Kh(l),a=l.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((l.mode&1)===0?l.lanes=1:a.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(D=w.children,a=w.fallback,T?(w=l.mode,T=l.child,D={mode:"hidden",children:D},(w&1)===0&&T!==null?(T.childLanes=0,T.pendingProps=D):T=Iu(D,w,0,null),a=ka(a,w,m,null),T.return=l,a.return=l,T.sibling=a,l.child=T,l.child.memoizedState=yp(m),l.memoizedState=bp,a):wp(l,D));if(C=a.memoizedState,C!==null&&(Y=C.dehydrated,Y!==null))return tT(a,l,D,w,Y,C,m);if(T){T=w.fallback,D=l.mode,C=a.child,Y=C.sibling;var Z={mode:"hidden",children:w.children};return(D&1)===0&&l.child!==C?(w=l.child,w.childLanes=0,w.pendingProps=Z,l.deletions=null):(w=_o(C,Z),w.subtreeFlags=C.subtreeFlags&14680064),Y!==null?T=_o(Y,T):(T=ka(T,D,m,null),T.flags|=2),T.return=l,w.return=l,w.sibling=T,l.child=w,w=T,T=l.child,D=a.child.memoizedState,D=D===null?yp(m):{baseLanes:D.baseLanes|m,cachePool:null,transitions:D.transitions},T.memoizedState=D,T.childLanes=a.childLanes&~m,l.memoizedState=bp,w}return T=a.child,a=T.sibling,w=_o(T,{mode:"visible",children:w.children}),(l.mode&1)===0&&(w.lanes=m),w.return=l,w.sibling=null,a!==null&&(m=l.deletions,m===null?(l.deletions=[a],l.flags|=16):m.push(a)),l.child=w,l.memoizedState=null,w}function wp(a,l){return l=Iu({mode:"visible",children:l},a.mode,0,null),l.return=a,a.child=l}function Nu(a,l,m,w){return w!==null&&Vh(w),Ei(l,a.child,null,m),a=wp(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function tT(a,l,m,w,C,T,D){if(m)return l.flags&256?(l.flags&=-257,w=pp(Error(s(422))),Nu(a,l,D,w)):l.memoizedState!==null?(l.child=a.child,l.flags|=128,null):(T=w.fallback,C=l.mode,w=Iu({mode:"visible",children:w.children},C,0,null),T=ka(T,C,D,null),T.flags|=2,w.return=l,T.return=l,w.sibling=T,l.child=w,(l.mode&1)!==0&&Ei(l,a.child,null,D),l.child.memoizedState=yp(D),l.memoizedState=bp,T);if((l.mode&1)===0)return Nu(a,l,D,null);if(C.data==="$!"){if(w=C.nextSibling&&C.nextSibling.dataset,w)var Y=w.dgst;return w=Y,T=Error(s(419)),w=pp(T,w,void 0),Nu(a,l,D,w)}if(Y=(D&a.childLanes)!==0,ds||Y){if(w=Nn,w!==null){switch(D&-D){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|D))!==0?0:C,C!==0&&C!==T.retryLane&&(T.retryLane=C,Hr(a,C),ir(w,a,C,-1))}return Ip(),w=pp(Error(s(421))),Nu(a,l,D,w)}return C.data==="$?"?(l.flags|=128,l.child=a.child,l=hT.bind(null,a),C._reactRetry=l,null):(a=T.treeContext,ks=vo(C.nextSibling),js=l,Yt=!0,sr=null,a!==null&&(Ls[Ms++]=Ur,Ls[Ms++]=Wr,Ls[Ms++]=ha,Ur=a.id,Wr=a.overflow,ha=l),l=wp(l,w.children),l.flags|=4096,l)}function Tw(a,l,m){a.lanes|=l;var w=a.alternate;w!==null&&(w.lanes|=l),Xh(a.return,l,m)}function jp(a,l,m,w,C){var T=a.memoizedState;T===null?a.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:w,tail:m,tailMode:C}:(T.isBackwards=l,T.rendering=null,T.renderingStartTime=0,T.last=w,T.tail=m,T.tailMode=C)}function Rw(a,l,m){var w=l.pendingProps,C=w.revealOrder,T=w.tail;if(Yn(a,l,w.children,m),w=Zt.current,(w&2)!==0)w=w&1|2,l.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=l.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&Tw(a,m,l);else if(a.tag===19)Tw(a,m,l);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===l)break e;for(;a.sibling===null;){if(a.return===null||a.return===l)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}w&=1}if(Ut(Zt,w),(l.mode&1)===0)l.memoizedState=null;else switch(C){case"forwards":for(m=l.child,C=null;m!==null;)a=m.alternate,a!==null&&xu(a)===null&&(C=m),m=m.sibling;m=C,m===null?(C=l.child,l.child=null):(C=m.sibling,m.sibling=null),jp(l,!1,C,m,T);break;case"backwards":for(m=null,C=l.child,l.child=null;C!==null;){if(a=C.alternate,a!==null&&xu(a)===null){l.child=C;break}a=C.sibling,C.sibling=m,m=C,C=a}jp(l,!0,m,null,T);break;case"together":jp(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function Su(a,l){(l.mode&1)===0&&a!==null&&(a.alternate=null,l.alternate=null,l.flags|=2)}function Gr(a,l,m){if(a!==null&&(l.dependencies=a.dependencies),ba|=l.lanes,(m&l.childLanes)===0)return null;if(a!==null&&l.child!==a.child)throw Error(s(153));if(l.child!==null){for(a=l.child,m=_o(a,a.pendingProps),l.child=m,m.return=l;a.sibling!==null;)a=a.sibling,m=m.sibling=_o(a,a.pendingProps),m.return=l;m.sibling=null}return l.child}function nT(a,l,m){switch(l.tag){case 3:Ew(l),Ci();break;case 5:Gy(l);break;case 1:cs(l.type)&&iu(l);break;case 4:tp(l,l.stateNode.containerInfo);break;case 10:var w=l.type._context,C=l.memoizedProps.value;Ut(mu,w._currentValue),w._currentValue=C;break;case 13:if(w=l.memoizedState,w!==null)return w.dehydrated!==null?(Ut(Zt,Zt.current&1),l.flags|=128,null):(m&l.child.childLanes)!==0?_w(a,l,m):(Ut(Zt,Zt.current&1),a=Gr(a,l,m),a!==null?a.sibling:null);Ut(Zt,Zt.current&1);break;case 19:if(w=(m&l.childLanes)!==0,(a.flags&128)!==0){if(w)return Rw(a,l,m);l.flags|=128}if(C=l.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),Ut(Zt,Zt.current),w)break;return null;case 22:case 23:return l.lanes=0,Nw(a,l,m)}return Gr(a,l,m)}var Aw,kp,Ow,Lw;Aw=function(a,l){for(var m=l.child;m!==null;){if(m.tag===5||m.tag===6)a.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===l)break;for(;m.sibling===null;){if(m.return===null||m.return===l)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},kp=function(){},Ow=function(a,l,m,w){var C=a.memoizedProps;if(C!==w){a=l.stateNode,xa(br.current);var T=null;switch(m){case"input":C=De(a,C),w=De(a,w),T=[];break;case"select":C=G({},C,{value:void 0}),w=G({},w,{value:void 0}),T=[];break;case"textarea":C=ht(a,C),w=ht(a,w),T=[];break;default:typeof C.onClick!="function"&&typeof w.onClick=="function"&&(a.onclick=ru)}He(m,w);var D;m=null;for(ue in C)if(!w.hasOwnProperty(ue)&&C.hasOwnProperty(ue)&&C[ue]!=null)if(ue==="style"){var Y=C[ue];for(D in Y)Y.hasOwnProperty(D)&&(m||(m={}),m[D]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(o.hasOwnProperty(ue)?T||(T=[]):(T=T||[]).push(ue,null));for(ue in w){var Z=w[ue];if(Y=C!=null?C[ue]:void 0,w.hasOwnProperty(ue)&&Z!==Y&&(Z!=null||Y!=null))if(ue==="style")if(Y){for(D in Y)!Y.hasOwnProperty(D)||Z&&Z.hasOwnProperty(D)||(m||(m={}),m[D]="");for(D in Z)Z.hasOwnProperty(D)&&Y[D]!==Z[D]&&(m||(m={}),m[D]=Z[D])}else m||(T||(T=[]),T.push(ue,m)),m=Z;else ue==="dangerouslySetInnerHTML"?(Z=Z?Z.__html:void 0,Y=Y?Y.__html:void 0,Z!=null&&Y!==Z&&(T=T||[]).push(ue,Z)):ue==="children"?typeof Z!="string"&&typeof Z!="number"||(T=T||[]).push(ue,""+Z):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(o.hasOwnProperty(ue)?(Z!=null&&ue==="onScroll"&&Gt("scroll",a),T||Y===Z||(T=[])):(T=T||[]).push(ue,Z))}m&&(T=T||[]).push("style",m);var ue=T;(l.updateQueue=ue)&&(l.flags|=4)}},Lw=function(a,l,m,w){m!==w&&(l.flags|=4)};function lc(a,l){if(!Yt)switch(a.tailMode){case"hidden":l=a.tail;for(var m=null;l!==null;)l.alternate!==null&&(m=l),l=l.sibling;m===null?a.tail=null:m.sibling=null;break;case"collapsed":m=a.tail;for(var w=null;m!==null;)m.alternate!==null&&(w=m),m=m.sibling;w===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:w.sibling=null}}function In(a){var l=a.alternate!==null&&a.alternate.child===a.child,m=0,w=0;if(l)for(var C=a.child;C!==null;)m|=C.lanes|C.childLanes,w|=C.subtreeFlags&14680064,w|=C.flags&14680064,C.return=a,C=C.sibling;else for(C=a.child;C!==null;)m|=C.lanes|C.childLanes,w|=C.subtreeFlags,w|=C.flags,C.return=a,C=C.sibling;return a.subtreeFlags|=w,a.childLanes=m,l}function sT(a,l,m){var w=l.pendingProps;switch(Gh(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return In(l),null;case 1:return cs(l.type)&&au(),In(l),null;case 3:return w=l.stateNode,Ti(),qt(ls),qt(Mn),rp(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(a===null||a.child===null)&&(uu(l)?l.flags|=4:a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,sr!==null&&(Lp(sr),sr=null))),kp(a,l),In(l),null;case 5:np(l);var C=xa(sc.current);if(m=l.type,a!==null&&l.stateNode!=null)Ow(a,l,m,w,C),a.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!w){if(l.stateNode===null)throw Error(s(166));return In(l),null}if(a=xa(br.current),uu(l)){w=l.stateNode,m=l.type;var T=l.memoizedProps;switch(w[vr]=l,w[Xl]=T,a=(l.mode&1)!==0,m){case"dialog":Gt("cancel",w),Gt("close",w);break;case"iframe":case"object":case"embed":Gt("load",w);break;case"video":case"audio":for(C=0;C<Yl.length;C++)Gt(Yl[C],w);break;case"source":Gt("error",w);break;case"img":case"image":case"link":Gt("error",w),Gt("load",w);break;case"details":Gt("toggle",w);break;case"input":Ne(w,T),Gt("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!T.multiple},Gt("invalid",w);break;case"textarea":ie(w,T),Gt("invalid",w)}He(m,T),C=null;for(var D in T)if(T.hasOwnProperty(D)){var Y=T[D];D==="children"?typeof Y=="string"?w.textContent!==Y&&(T.suppressHydrationWarning!==!0&&su(w.textContent,Y,a),C=["children",Y]):typeof Y=="number"&&w.textContent!==""+Y&&(T.suppressHydrationWarning!==!0&&su(w.textContent,Y,a),C=["children",""+Y]):o.hasOwnProperty(D)&&Y!=null&&D==="onScroll"&&Gt("scroll",w)}switch(m){case"input":de(w),nt(w,T,!0);break;case"textarea":de(w),tt(w);break;case"select":case"option":break;default:typeof T.onClick=="function"&&(w.onclick=ru)}w=C,l.updateQueue=w,w!==null&&(l.flags|=4)}else{D=C.nodeType===9?C:C.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=Ie(m)),a==="http://www.w3.org/1999/xhtml"?m==="script"?(a=D.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof w.is=="string"?a=D.createElement(m,{is:w.is}):(a=D.createElement(m),m==="select"&&(D=a,w.multiple?D.multiple=!0:w.size&&(D.size=w.size))):a=D.createElementNS(a,m),a[vr]=l,a[Xl]=w,Aw(a,l,!1,!1),l.stateNode=a;e:{switch(D=Je(m,w),m){case"dialog":Gt("cancel",a),Gt("close",a),C=w;break;case"iframe":case"object":case"embed":Gt("load",a),C=w;break;case"video":case"audio":for(C=0;C<Yl.length;C++)Gt(Yl[C],a);C=w;break;case"source":Gt("error",a),C=w;break;case"img":case"image":case"link":Gt("error",a),Gt("load",a),C=w;break;case"details":Gt("toggle",a),C=w;break;case"input":Ne(a,w),C=De(a,w),Gt("invalid",a);break;case"option":C=w;break;case"select":a._wrapperState={wasMultiple:!!w.multiple},C=G({},w,{value:void 0}),Gt("invalid",a);break;case"textarea":ie(a,w),C=ht(a,w),Gt("invalid",a);break;default:C=w}He(m,C),Y=C;for(T in Y)if(Y.hasOwnProperty(T)){var Z=Y[T];T==="style"?pe(a,Z):T==="dangerouslySetInnerHTML"?(Z=Z?Z.__html:void 0,Z!=null&&st(a,Z)):T==="children"?typeof Z=="string"?(m!=="textarea"||Z!=="")&&ut(a,Z):typeof Z=="number"&&ut(a,""+Z):T!=="suppressContentEditableWarning"&&T!=="suppressHydrationWarning"&&T!=="autoFocus"&&(o.hasOwnProperty(T)?Z!=null&&T==="onScroll"&&Gt("scroll",a):Z!=null&&S(a,T,Z,D))}switch(m){case"input":de(a),nt(a,w,!1);break;case"textarea":de(a),tt(a);break;case"option":w.value!=null&&a.setAttribute("value",""+ve(w.value));break;case"select":a.multiple=!!w.multiple,T=w.value,T!=null?Ye(a,!!w.multiple,T,!1):w.defaultValue!=null&&Ye(a,!!w.multiple,w.defaultValue,!0);break;default:typeof C.onClick=="function"&&(a.onclick=ru)}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 In(l),null;case 6:if(a&&l.stateNode!=null)Lw(a,l,a.memoizedProps,w);else{if(typeof w!="string"&&l.stateNode===null)throw Error(s(166));if(m=xa(sc.current),xa(br.current),uu(l)){if(w=l.stateNode,m=l.memoizedProps,w[vr]=l,(T=w.nodeValue!==m)&&(a=js,a!==null))switch(a.tag){case 3:su(w.nodeValue,m,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&su(w.nodeValue,m,(a.mode&1)!==0)}T&&(l.flags|=4)}else w=(m.nodeType===9?m:m.ownerDocument).createTextNode(w),w[vr]=l,l.stateNode=w}return In(l),null;case 13:if(qt(Zt),w=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(Yt&&ks!==null&&(l.mode&1)!==0&&(l.flags&128)===0)Iy(),Ci(),l.flags|=98560,T=!1;else if(T=uu(l),w!==null&&w.dehydrated!==null){if(a===null){if(!T)throw Error(s(318));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(s(317));T[vr]=l}else Ci(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;In(l),T=!1}else sr!==null&&(Lp(sr),sr=null),T=!0;if(!T)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=m,l):(w=w!==null,w!==(a!==null&&a.memoizedState!==null)&&w&&(l.child.flags|=8192,(l.mode&1)!==0&&(a===null||(Zt.current&1)!==0?yn===0&&(yn=3):Ip())),l.updateQueue!==null&&(l.flags|=4),In(l),null);case 4:return Ti(),kp(a,l),a===null&&Ql(l.stateNode.containerInfo),In(l),null;case 10:return Jh(l.type._context),In(l),null;case 17:return cs(l.type)&&au(),In(l),null;case 19:if(qt(Zt),T=l.memoizedState,T===null)return In(l),null;if(w=(l.flags&128)!==0,D=T.rendering,D===null)if(w)lc(T,!1);else{if(yn!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(D=xu(a),D!==null){for(l.flags|=128,lc(T,!1),w=D.updateQueue,w!==null&&(l.updateQueue=w,l.flags|=4),l.subtreeFlags=0,w=m,m=l.child;m!==null;)T=m,a=w,T.flags&=14680066,D=T.alternate,D===null?(T.childLanes=0,T.lanes=a,T.child=null,T.subtreeFlags=0,T.memoizedProps=null,T.memoizedState=null,T.updateQueue=null,T.dependencies=null,T.stateNode=null):(T.childLanes=D.childLanes,T.lanes=D.lanes,T.child=D.child,T.subtreeFlags=0,T.deletions=null,T.memoizedProps=D.memoizedProps,T.memoizedState=D.memoizedState,T.updateQueue=D.updateQueue,T.type=D.type,a=D.dependencies,T.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),m=m.sibling;return Ut(Zt,Zt.current&1|2),l.child}a=a.sibling}T.tail!==null&<()>Li&&(l.flags|=128,w=!0,lc(T,!1),l.lanes=4194304)}else{if(!w)if(a=xu(D),a!==null){if(l.flags|=128,w=!0,m=a.updateQueue,m!==null&&(l.updateQueue=m,l.flags|=4),lc(T,!0),T.tail===null&&T.tailMode==="hidden"&&!D.alternate&&!Yt)return In(l),null}else 2*lt()-T.renderingStartTime>Li&&m!==1073741824&&(l.flags|=128,w=!0,lc(T,!1),l.lanes=4194304);T.isBackwards?(D.sibling=l.child,l.child=D):(m=T.last,m!==null?m.sibling=D:l.child=D,T.last=D)}return T.tail!==null?(l=T.tail,T.rendering=l,T.tail=l.sibling,T.renderingStartTime=lt(),l.sibling=null,m=Zt.current,Ut(Zt,w?m&1|2:m&1),l):(In(l),null);case 22:case 23:return Pp(),w=l.memoizedState!==null,a!==null&&a.memoizedState!==null!==w&&(l.flags|=8192),w&&(l.mode&1)!==0?(Ns&1073741824)!==0&&(In(l),l.subtreeFlags&6&&(l.flags|=8192)):In(l),null;case 24:return null;case 25:return null}throw Error(s(156,l.tag))}function rT(a,l){switch(Gh(l),l.tag){case 1:return cs(l.type)&&au(),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return Ti(),qt(ls),qt(Mn),rp(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 5:return np(l),null;case 13:if(qt(Zt),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(s(340));Ci()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return qt(Zt),null;case 4:return Ti(),null;case 10:return Jh(l.type._context),null;case 22:case 23:return Pp(),null;case 24:return null;default:return null}}var Cu=!1,zn=!1,oT=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function Ai(a,l){var m=a.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(w){rn(a,l,w)}else m.current=null}function Np(a,l,m){try{m()}catch(w){rn(a,l,w)}}var Mw=!1;function aT(a,l){if(Ph=zr,a=my(),$h(a)){if("selectionStart"in a)var m={start:a.selectionStart,end:a.selectionEnd};else e:{m=(m=a.ownerDocument)&&m.defaultView||window;var w=m.getSelection&&m.getSelection();if(w&&w.rangeCount!==0){m=w.anchorNode;var C=w.anchorOffset,T=w.focusNode;w=w.focusOffset;try{m.nodeType,T.nodeType}catch{m=null;break e}var D=0,Y=-1,Z=-1,ue=0,ke=0,Ee=a,we=null;t:for(;;){for(var Ge;Ee!==m||C!==0&&Ee.nodeType!==3||(Y=D+C),Ee!==T||w!==0&&Ee.nodeType!==3||(Z=D+w),Ee.nodeType===3&&(D+=Ee.nodeValue.length),(Ge=Ee.firstChild)!==null;)we=Ee,Ee=Ge;for(;;){if(Ee===a)break t;if(we===m&&++ue===C&&(Y=D),we===T&&++ke===w&&(Z=D),(Ge=Ee.nextSibling)!==null)break;Ee=we,we=Ee.parentNode}Ee=Ge}m=Y===-1||Z===-1?null:{start:Y,end:Z}}else m=null}m=m||{start:0,end:0}}else m=null;for(Ih={focusedElem:a,selectionRange:m},zr=!1,Qe=l;Qe!==null;)if(l=Qe,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,Qe=a;else for(;Qe!==null;){l=Qe;try{var Xe=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Xe!==null){var Ze=Xe.memoizedProps,an=Xe.memoizedState,le=l.stateNode,oe=le.getSnapshotBeforeUpdate(l.elementType===l.type?Ze:rr(l.type,Ze),an);le.__reactInternalSnapshotBeforeUpdate=oe}break;case 3:var ce=l.stateNode.containerInfo;ce.nodeType===1?ce.textContent="":ce.nodeType===9&&ce.documentElement&&ce.removeChild(ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(Re){rn(l,l.return,Re)}if(a=l.sibling,a!==null){a.return=l.return,Qe=a;break}Qe=l.return}return Xe=Mw,Mw=!1,Xe}function cc(a,l,m){var w=l.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var C=w=w.next;do{if((C.tag&a)===a){var T=C.destroy;C.destroy=void 0,T!==void 0&&Np(l,m,T)}C=C.next}while(C!==w)}}function Eu(a,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var m=l=l.next;do{if((m.tag&a)===a){var w=m.create;m.destroy=w()}m=m.next}while(m!==l)}}function Sp(a){var l=a.ref;if(l!==null){var m=a.stateNode;switch(a.tag){case 5:a=m;break;default:a=m}typeof l=="function"?l(a):l.current=a}}function Pw(a){var l=a.alternate;l!==null&&(a.alternate=null,Pw(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&(delete l[vr],delete l[Xl],delete l[Uh],delete l[W_],delete l[H_])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function Iw(a){return a.tag===5||a.tag===3||a.tag===4}function zw(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||Iw(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Cp(a,l,m){var w=a.tag;if(w===5||w===6)a=a.stateNode,l?m.nodeType===8?m.parentNode.insertBefore(a,l):m.insertBefore(a,l):(m.nodeType===8?(l=m.parentNode,l.insertBefore(a,m)):(l=m,l.appendChild(a)),m=m._reactRootContainer,m!=null||l.onclick!==null||(l.onclick=ru));else if(w!==4&&(a=a.child,a!==null))for(Cp(a,l,m),a=a.sibling;a!==null;)Cp(a,l,m),a=a.sibling}function Ep(a,l,m){var w=a.tag;if(w===5||w===6)a=a.stateNode,l?m.insertBefore(a,l):m.appendChild(a);else if(w!==4&&(a=a.child,a!==null))for(Ep(a,l,m),a=a.sibling;a!==null;)Ep(a,l,m),a=a.sibling}var Rn=null,or=!1;function No(a,l,m){for(m=m.child;m!==null;)Dw(a,l,m),m=m.sibling}function Dw(a,l,m){if(ys&&typeof ys.onCommitFiberUnmount=="function")try{ys.onCommitFiberUnmount(ia,m)}catch{}switch(m.tag){case 5:zn||Ai(m,l);case 6:var w=Rn,C=or;Rn=null,No(a,l,m),Rn=w,or=C,Rn!==null&&(or?(a=Rn,m=m.stateNode,a.nodeType===8?a.parentNode.removeChild(m):a.removeChild(m)):Rn.removeChild(m.stateNode));break;case 18:Rn!==null&&(or?(a=Rn,m=m.stateNode,a.nodeType===8?Fh(a.parentNode,m):a.nodeType===1&&Fh(a,m),ho(a)):Fh(Rn,m.stateNode));break;case 4:w=Rn,C=or,Rn=m.stateNode.containerInfo,or=!0,No(a,l,m),Rn=w,or=C;break;case 0:case 11:case 14:case 15:if(!zn&&(w=m.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){C=w=w.next;do{var T=C,D=T.destroy;T=T.tag,D!==void 0&&((T&2)!==0||(T&4)!==0)&&Np(m,l,D),C=C.next}while(C!==w)}No(a,l,m);break;case 1:if(!zn&&(Ai(m,l),w=m.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=m.memoizedProps,w.state=m.memoizedState,w.componentWillUnmount()}catch(Y){rn(m,l,Y)}No(a,l,m);break;case 21:No(a,l,m);break;case 22:m.mode&1?(zn=(w=zn)||m.memoizedState!==null,No(a,l,m),zn=w):No(a,l,m);break;default:No(a,l,m)}}function Fw(a){var l=a.updateQueue;if(l!==null){a.updateQueue=null;var m=a.stateNode;m===null&&(m=a.stateNode=new oT),l.forEach(function(w){var C=pT.bind(null,a,w);m.has(w)||(m.add(w),w.then(C,C))})}}function ar(a,l){var m=l.deletions;if(m!==null)for(var w=0;w<m.length;w++){var C=m[w];try{var T=a,D=l,Y=D;e:for(;Y!==null;){switch(Y.tag){case 5:Rn=Y.stateNode,or=!1;break e;case 3:Rn=Y.stateNode.containerInfo,or=!0;break e;case 4:Rn=Y.stateNode.containerInfo,or=!0;break e}Y=Y.return}if(Rn===null)throw Error(s(160));Dw(T,D,C),Rn=null,or=!1;var Z=C.alternate;Z!==null&&(Z.return=null),C.return=null}catch(ue){rn(C,l,ue)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)Uw(l,a),l=l.sibling}function Uw(a,l){var m=a.alternate,w=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(ar(l,a),wr(a),w&4){try{cc(3,a,a.return),Eu(3,a)}catch(Ze){rn(a,a.return,Ze)}try{cc(5,a,a.return)}catch(Ze){rn(a,a.return,Ze)}}break;case 1:ar(l,a),wr(a),w&512&&m!==null&&Ai(m,m.return);break;case 5:if(ar(l,a),wr(a),w&512&&m!==null&&Ai(m,m.return),a.flags&32){var C=a.stateNode;try{ut(C,"")}catch(Ze){rn(a,a.return,Ze)}}if(w&4&&(C=a.stateNode,C!=null)){var T=a.memoizedProps,D=m!==null?m.memoizedProps:T,Y=a.type,Z=a.updateQueue;if(a.updateQueue=null,Z!==null)try{Y==="input"&&T.type==="radio"&&T.name!=null&&Q(C,T),Je(Y,D);var ue=Je(Y,T);for(D=0;D<Z.length;D+=2){var ke=Z[D],Ee=Z[D+1];ke==="style"?pe(C,Ee):ke==="dangerouslySetInnerHTML"?st(C,Ee):ke==="children"?ut(C,Ee):S(C,ke,Ee,ue)}switch(Y){case"input":be(C,T);break;case"textarea":Ce(C,T);break;case"select":var we=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!T.multiple;var Ge=T.value;Ge!=null?Ye(C,!!T.multiple,Ge,!1):we!==!!T.multiple&&(T.defaultValue!=null?Ye(C,!!T.multiple,T.defaultValue,!0):Ye(C,!!T.multiple,T.multiple?[]:"",!1))}C[Xl]=T}catch(Ze){rn(a,a.return,Ze)}}break;case 6:if(ar(l,a),wr(a),w&4){if(a.stateNode===null)throw Error(s(162));C=a.stateNode,T=a.memoizedProps;try{C.nodeValue=T}catch(Ze){rn(a,a.return,Ze)}}break;case 3:if(ar(l,a),wr(a),w&4&&m!==null&&m.memoizedState.isDehydrated)try{ho(l.containerInfo)}catch(Ze){rn(a,a.return,Ze)}break;case 4:ar(l,a),wr(a);break;case 13:ar(l,a),wr(a),C=a.child,C.flags&8192&&(T=C.memoizedState!==null,C.stateNode.isHidden=T,!T||C.alternate!==null&&C.alternate.memoizedState!==null||(Tp=lt())),w&4&&Fw(a);break;case 22:if(ke=m!==null&&m.memoizedState!==null,a.mode&1?(zn=(ue=zn)||ke,ar(l,a),zn=ue):ar(l,a),wr(a),w&8192){if(ue=a.memoizedState!==null,(a.stateNode.isHidden=ue)&&!ke&&(a.mode&1)!==0)for(Qe=a,ke=a.child;ke!==null;){for(Ee=Qe=ke;Qe!==null;){switch(we=Qe,Ge=we.child,we.tag){case 0:case 11:case 14:case 15:cc(4,we,we.return);break;case 1:Ai(we,we.return);var Xe=we.stateNode;if(typeof Xe.componentWillUnmount=="function"){w=we,m=we.return;try{l=w,Xe.props=l.memoizedProps,Xe.state=l.memoizedState,Xe.componentWillUnmount()}catch(Ze){rn(w,m,Ze)}}break;case 5:Ai(we,we.return);break;case 22:if(we.memoizedState!==null){Bw(Ee);continue}}Ge!==null?(Ge.return=we,Qe=Ge):Bw(Ee)}ke=ke.sibling}e:for(ke=null,Ee=a;;){if(Ee.tag===5){if(ke===null){ke=Ee;try{C=Ee.stateNode,ue?(T=C.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none"):(Y=Ee.stateNode,Z=Ee.memoizedProps.style,D=Z!=null&&Z.hasOwnProperty("display")?Z.display:null,Y.style.display=Rt("display",D))}catch(Ze){rn(a,a.return,Ze)}}}else if(Ee.tag===6){if(ke===null)try{Ee.stateNode.nodeValue=ue?"":Ee.memoizedProps}catch(Ze){rn(a,a.return,Ze)}}else if((Ee.tag!==22&&Ee.tag!==23||Ee.memoizedState===null||Ee===a)&&Ee.child!==null){Ee.child.return=Ee,Ee=Ee.child;continue}if(Ee===a)break e;for(;Ee.sibling===null;){if(Ee.return===null||Ee.return===a)break e;ke===Ee&&(ke=null),Ee=Ee.return}ke===Ee&&(ke=null),Ee.sibling.return=Ee.return,Ee=Ee.sibling}}break;case 19:ar(l,a),wr(a),w&4&&Fw(a);break;case 21:break;default:ar(l,a),wr(a)}}function wr(a){var l=a.flags;if(l&2){try{e:{for(var m=a.return;m!==null;){if(Iw(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&&(ut(C,""),w.flags&=-33);var T=zw(a);Ep(a,T,C);break;case 3:case 4:var D=w.stateNode.containerInfo,Y=zw(a);Cp(a,Y,D);break;default:throw Error(s(161))}}catch(Z){rn(a,a.return,Z)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function iT(a,l,m){Qe=a,Ww(a)}function Ww(a,l,m){for(var w=(a.mode&1)!==0;Qe!==null;){var C=Qe,T=C.child;if(C.tag===22&&w){var D=C.memoizedState!==null||Cu;if(!D){var Y=C.alternate,Z=Y!==null&&Y.memoizedState!==null||zn;Y=Cu;var ue=zn;if(Cu=D,(zn=Z)&&!ue)for(Qe=C;Qe!==null;)D=Qe,Z=D.child,D.tag===22&&D.memoizedState!==null?Gw(C):Z!==null?(Z.return=D,Qe=Z):Gw(C);for(;T!==null;)Qe=T,Ww(T),T=T.sibling;Qe=C,Cu=Y,zn=ue}Hw(a)}else(C.subtreeFlags&8772)!==0&&T!==null?(T.return=C,Qe=T):Hw(a)}}function Hw(a){for(;Qe!==null;){var l=Qe;if((l.flags&8772)!==0){var m=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:zn||Eu(5,l);break;case 1:var w=l.stateNode;if(l.flags&4&&!zn)if(m===null)w.componentDidMount();else{var C=l.elementType===l.type?m.memoizedProps:rr(l.type,m.memoizedProps);w.componentDidUpdate(C,m.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var T=l.updateQueue;T!==null&&By(l,T,w);break;case 3:var D=l.updateQueue;if(D!==null){if(m=null,l.child!==null)switch(l.child.tag){case 5:m=l.child.stateNode;break;case 1:m=l.child.stateNode}By(l,D,m)}break;case 5:var Y=l.stateNode;if(m===null&&l.flags&4){m=Y;var Z=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":Z.autoFocus&&m.focus();break;case"img":Z.src&&(m.src=Z.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ue=l.alternate;if(ue!==null){var ke=ue.memoizedState;if(ke!==null){var Ee=ke.dehydrated;Ee!==null&&ho(Ee)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}zn||l.flags&512&&Sp(l)}catch(we){rn(l,l.return,we)}}if(l===a){Qe=null;break}if(m=l.sibling,m!==null){m.return=l.return,Qe=m;break}Qe=l.return}}function Bw(a){for(;Qe!==null;){var l=Qe;if(l===a){Qe=null;break}var m=l.sibling;if(m!==null){m.return=l.return,Qe=m;break}Qe=l.return}}function Gw(a){for(;Qe!==null;){var l=Qe;try{switch(l.tag){case 0:case 11:case 15:var m=l.return;try{Eu(4,l)}catch(Z){rn(l,m,Z)}break;case 1:var w=l.stateNode;if(typeof w.componentDidMount=="function"){var C=l.return;try{w.componentDidMount()}catch(Z){rn(l,C,Z)}}var T=l.return;try{Sp(l)}catch(Z){rn(l,T,Z)}break;case 5:var D=l.return;try{Sp(l)}catch(Z){rn(l,D,Z)}}}catch(Z){rn(l,l.return,Z)}if(l===a){Qe=null;break}var Y=l.sibling;if(Y!==null){Y.return=l.return,Qe=Y;break}Qe=l.return}}var lT=Math.ceil,$u=N.ReactCurrentDispatcher,$p=N.ReactCurrentOwner,zs=N.ReactCurrentBatchConfig,Ct=0,Nn=null,hn=null,An=0,Ns=0,Oi=bo(0),yn=0,dc=null,ba=0,_u=0,_p=0,uc=null,us=null,Tp=0,Li=1/0,qr=null,Tu=!1,Rp=null,So=null,Ru=!1,Co=null,Au=0,fc=0,Ap=null,Ou=-1,Lu=0;function Qn(){return(Ct&6)!==0?lt():Ou!==-1?Ou:Ou=lt()}function Eo(a){return(a.mode&1)===0?1:(Ct&2)!==0&&An!==0?An&-An:G_.transition!==null?(Lu===0&&(Lu=Pl()),Lu):(a=$t,a!==0||(a=window.event,a=a===void 0?16:Kb(a.type)),a)}function ir(a,l,m,w){if(50<fc)throw fc=0,Ap=null,Error(s(185));fo(a,m,w),((Ct&2)===0||a!==Nn)&&(a===Nn&&((Ct&2)===0&&(_u|=m),yn===4&&$o(a,An)),fs(a,w),m===1&&Ct===0&&(l.mode&1)===0&&(Li=lt()+500,lu&&wo()))}function fs(a,l){var m=a.callbackNode;Gd(a,l);var w=da(a,a===Nn?An:0);if(w===0)m!==null&&qe(m),a.callbackNode=null,a.callbackPriority=0;else if(l=w&-w,a.callbackPriority!==l){if(m!=null&&qe(m),l===1)a.tag===0?B_(Kw.bind(null,a)):Ay(Kw.bind(null,a)),F_(function(){(Ct&6)===0&&wo()}),m=null;else{switch(Il(w)){case 1:m=Tn;break;case 4:m=gr;break;case 16:m=Bt;break;case 536870912:m=co;break;default:m=Bt}m=tj(m,qw.bind(null,a))}a.callbackPriority=l,a.callbackNode=m}}function qw(a,l){if(Ou=-1,Lu=0,(Ct&6)!==0)throw Error(s(327));var m=a.callbackNode;if(Mi()&&a.callbackNode!==m)return null;var w=da(a,a===Nn?An:0);if(w===0)return null;if((w&30)!==0||(w&a.expiredLanes)!==0||l)l=Mu(a,w);else{l=w;var C=Ct;Ct|=2;var T=Yw();(Nn!==a||An!==l)&&(qr=null,Li=lt()+500,wa(a,l));do try{uT();break}catch(Y){Vw(a,Y)}while(!0);Qh(),$u.current=T,Ct=C,hn!==null?l=0:(Nn=null,An=0,l=yn)}if(l!==0){if(l===2&&(C=ci(a),C!==0&&(w=C,l=Op(a,C))),l===1)throw m=dc,wa(a,0),$o(a,w),fs(a,lt()),m;if(l===6)$o(a,w);else{if(C=a.current.alternate,(w&30)===0&&!cT(C)&&(l=Mu(a,w),l===2&&(T=ci(a),T!==0&&(w=T,l=Op(a,T))),l===1))throw m=dc,wa(a,0),$o(a,w),fs(a,lt()),m;switch(a.finishedWork=C,a.finishedLanes=w,l){case 0:case 1:throw Error(s(345));case 2:ja(a,us,qr);break;case 3:if($o(a,w),(w&130023424)===w&&(l=Tp+500-lt(),10<l)){if(da(a,0)!==0)break;if(C=a.suspendedLanes,(C&w)!==w){Qn(),a.pingedLanes|=a.suspendedLanes&C;break}a.timeoutHandle=Dh(ja.bind(null,a,us,qr),l);break}ja(a,us,qr);break;case 4:if($o(a,w),(w&4194240)===w)break;for(l=a.eventTimes,C=-1;0<w;){var D=31-as(w);T=1<<D,D=l[D],D>C&&(C=D),w&=~T}if(w=C,w=lt()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*lT(w/1960))-w,10<w){a.timeoutHandle=Dh(ja.bind(null,a,us,qr),w);break}ja(a,us,qr);break;case 5:ja(a,us,qr);break;default:throw Error(s(329))}}}return fs(a,lt()),a.callbackNode===m?qw.bind(null,a):null}function Op(a,l){var m=uc;return a.current.memoizedState.isDehydrated&&(wa(a,l).flags|=256),a=Mu(a,l),a!==2&&(l=us,us=m,l!==null&&Lp(l)),a}function Lp(a){us===null?us=a:us.push.apply(us,a)}function cT(a){for(var l=a;;){if(l.flags&16384){var m=l.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var w=0;w<m.length;w++){var C=m[w],T=C.getSnapshot;C=C.value;try{if(!nr(T(),C))return!1}catch{return!1}}}if(m=l.child,l.subtreeFlags&16384&&m!==null)m.return=l,l=m;else{if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function $o(a,l){for(l&=~_p,l&=~_u,a.suspendedLanes|=l,a.pingedLanes&=~l,a=a.expirationTimes;0<l;){var m=31-as(l),w=1<<m;a[m]=-1,l&=~w}}function Kw(a){if((Ct&6)!==0)throw Error(s(327));Mi();var l=da(a,0);if((l&1)===0)return fs(a,lt()),null;var m=Mu(a,l);if(a.tag!==0&&m===2){var w=ci(a);w!==0&&(l=w,m=Op(a,w))}if(m===1)throw m=dc,wa(a,0),$o(a,l),fs(a,lt()),m;if(m===6)throw Error(s(345));return a.finishedWork=a.current.alternate,a.finishedLanes=l,ja(a,us,qr),fs(a,lt()),null}function Mp(a,l){var m=Ct;Ct|=1;try{return a(l)}finally{Ct=m,Ct===0&&(Li=lt()+500,lu&&wo())}}function ya(a){Co!==null&&Co.tag===0&&(Ct&6)===0&&Mi();var l=Ct;Ct|=1;var m=zs.transition,w=$t;try{if(zs.transition=null,$t=1,a)return a()}finally{$t=w,zs.transition=m,Ct=l,(Ct&6)===0&&wo()}}function Pp(){Ns=Oi.current,qt(Oi)}function wa(a,l){a.finishedWork=null,a.finishedLanes=0;var m=a.timeoutHandle;if(m!==-1&&(a.timeoutHandle=-1,D_(m)),hn!==null)for(m=hn.return;m!==null;){var w=m;switch(Gh(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&au();break;case 3:Ti(),qt(ls),qt(Mn),rp();break;case 5:np(w);break;case 4:Ti();break;case 13:qt(Zt);break;case 19:qt(Zt);break;case 10:Jh(w.type._context);break;case 22:case 23:Pp()}m=m.return}if(Nn=a,hn=a=_o(a.current,null),An=Ns=l,yn=0,dc=null,_p=_u=ba=0,us=uc=null,ga!==null){for(l=0;l<ga.length;l++)if(m=ga[l],w=m.interleaved,w!==null){m.interleaved=null;var C=w.next,T=m.pending;if(T!==null){var D=T.next;T.next=C,w.next=D}m.pending=w}ga=null}return a}function Vw(a,l){do{var m=hn;try{if(Qh(),vu.current=ju,bu){for(var w=en.memoizedState;w!==null;){var C=w.queue;C!==null&&(C.pending=null),w=w.next}bu=!1}if(va=0,kn=bn=en=null,rc=!1,oc=0,$p.current=null,m===null||m.return===null){yn=1,dc=l,hn=null;break}e:{var T=a,D=m.return,Y=m,Z=l;if(l=An,Y.flags|=32768,Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var ue=Z,ke=Y,Ee=ke.tag;if((ke.mode&1)===0&&(Ee===0||Ee===11||Ee===15)){var we=ke.alternate;we?(ke.updateQueue=we.updateQueue,ke.memoizedState=we.memoizedState,ke.lanes=we.lanes):(ke.updateQueue=null,ke.memoizedState=null)}var Ge=bw(D);if(Ge!==null){Ge.flags&=-257,yw(Ge,D,Y,T,l),Ge.mode&1&&vw(T,ue,l),l=Ge,Z=ue;var Xe=l.updateQueue;if(Xe===null){var Ze=new Set;Ze.add(Z),l.updateQueue=Ze}else Xe.add(Z);break e}else{if((l&1)===0){vw(T,ue,l),Ip();break e}Z=Error(s(426))}}else if(Yt&&Y.mode&1){var an=bw(D);if(an!==null){(an.flags&65536)===0&&(an.flags|=256),yw(an,D,Y,T,l),Vh(Ri(Z,Y));break e}}T=Z=Ri(Z,Y),yn!==4&&(yn=2),uc===null?uc=[T]:uc.push(T),T=D;do{switch(T.tag){case 3:T.flags|=65536,l&=-l,T.lanes|=l;var le=gw(T,Z,l);Hy(T,le);break e;case 1:Y=Z;var oe=T.type,ce=T.stateNode;if((T.flags&128)===0&&(typeof oe.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(So===null||!So.has(ce)))){T.flags|=65536,l&=-l,T.lanes|=l;var Re=xw(T,Y,l);Hy(T,Re);break e}}T=T.return}while(T!==null)}Jw(m)}catch(et){l=et,hn===m&&m!==null&&(hn=m=m.return);continue}break}while(!0)}function Yw(){var a=$u.current;return $u.current=ju,a===null?ju:a}function Ip(){(yn===0||yn===3||yn===2)&&(yn=4),Nn===null||(ba&268435455)===0&&(_u&268435455)===0||$o(Nn,An)}function Mu(a,l){var m=Ct;Ct|=2;var w=Yw();(Nn!==a||An!==l)&&(qr=null,wa(a,l));do try{dT();break}catch(C){Vw(a,C)}while(!0);if(Qh(),Ct=m,$u.current=w,hn!==null)throw Error(s(261));return Nn=null,An=0,yn}function dT(){for(;hn!==null;)Qw(hn)}function uT(){for(;hn!==null&&!Nt();)Qw(hn)}function Qw(a){var l=ej(a.alternate,a,Ns);a.memoizedProps=a.pendingProps,l===null?Jw(a):hn=l,$p.current=null}function Jw(a){var l=a;do{var m=l.alternate;if(a=l.return,(l.flags&32768)===0){if(m=sT(m,l,Ns),m!==null){hn=m;return}}else{if(m=rT(m,l),m!==null){m.flags&=32767,hn=m;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{yn=6,hn=null;return}}if(l=l.sibling,l!==null){hn=l;return}hn=l=a}while(l!==null);yn===0&&(yn=5)}function ja(a,l,m){var w=$t,C=zs.transition;try{zs.transition=null,$t=1,fT(a,l,m,w)}finally{zs.transition=C,$t=w}return null}function fT(a,l,m,w){do Mi();while(Co!==null);if((Ct&6)!==0)throw Error(s(327));m=a.finishedWork;var C=a.finishedLanes;if(m===null)return null;if(a.finishedWork=null,a.finishedLanes=0,m===a.current)throw Error(s(177));a.callbackNode=null,a.callbackPriority=0;var T=m.lanes|m.childLanes;if(qd(a,T),a===Nn&&(hn=Nn=null,An=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||Ru||(Ru=!0,tj(Bt,function(){return Mi(),null})),T=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||T){T=zs.transition,zs.transition=null;var D=$t;$t=1;var Y=Ct;Ct|=4,$p.current=null,aT(a,m),Uw(m,a),A_(Ih),zr=!!Ph,Ih=Ph=null,a.current=m,iT(m),It(),Ct=Y,$t=D,zs.transition=T}else a.current=m;if(Ru&&(Ru=!1,Co=a,Au=C),T=a.pendingLanes,T===0&&(So=null),Fd(m.stateNode),fs(a,lt()),l!==null)for(w=a.onRecoverableError,m=0;m<l.length;m++)C=l[m],w(C.value,{componentStack:C.stack,digest:C.digest});if(Tu)throw Tu=!1,a=Rp,Rp=null,a;return(Au&1)!==0&&a.tag!==0&&Mi(),T=a.pendingLanes,(T&1)!==0?a===Ap?fc++:(fc=0,Ap=a):fc=0,wo(),null}function Mi(){if(Co!==null){var a=Il(Au),l=zs.transition,m=$t;try{if(zs.transition=null,$t=16>a?16:a,Co===null)var w=!1;else{if(a=Co,Co=null,Au=0,(Ct&6)!==0)throw Error(s(331));var C=Ct;for(Ct|=4,Qe=a.current;Qe!==null;){var T=Qe,D=T.child;if((Qe.flags&16)!==0){var Y=T.deletions;if(Y!==null){for(var Z=0;Z<Y.length;Z++){var ue=Y[Z];for(Qe=ue;Qe!==null;){var ke=Qe;switch(ke.tag){case 0:case 11:case 15:cc(8,ke,T)}var Ee=ke.child;if(Ee!==null)Ee.return=ke,Qe=Ee;else for(;Qe!==null;){ke=Qe;var we=ke.sibling,Ge=ke.return;if(Pw(ke),ke===ue){Qe=null;break}if(we!==null){we.return=Ge,Qe=we;break}Qe=Ge}}}var Xe=T.alternate;if(Xe!==null){var Ze=Xe.child;if(Ze!==null){Xe.child=null;do{var an=Ze.sibling;Ze.sibling=null,Ze=an}while(Ze!==null)}}Qe=T}}if((T.subtreeFlags&2064)!==0&&D!==null)D.return=T,Qe=D;else e:for(;Qe!==null;){if(T=Qe,(T.flags&2048)!==0)switch(T.tag){case 0:case 11:case 15:cc(9,T,T.return)}var le=T.sibling;if(le!==null){le.return=T.return,Qe=le;break e}Qe=T.return}}var oe=a.current;for(Qe=oe;Qe!==null;){D=Qe;var ce=D.child;if((D.subtreeFlags&2064)!==0&&ce!==null)ce.return=D,Qe=ce;else e:for(D=oe;Qe!==null;){if(Y=Qe,(Y.flags&2048)!==0)try{switch(Y.tag){case 0:case 11:case 15:Eu(9,Y)}}catch(et){rn(Y,Y.return,et)}if(Y===D){Qe=null;break e}var Re=Y.sibling;if(Re!==null){Re.return=Y.return,Qe=Re;break e}Qe=Y.return}}if(Ct=C,wo(),ys&&typeof ys.onPostCommitFiberRoot=="function")try{ys.onPostCommitFiberRoot(ia,a)}catch{}w=!0}return w}finally{$t=m,zs.transition=l}}return!1}function Xw(a,l,m){l=Ri(m,l),l=gw(a,l,1),a=ko(a,l,1),l=Qn(),a!==null&&(fo(a,1,l),fs(a,l))}function rn(a,l,m){if(a.tag===3)Xw(a,a,m);else for(;l!==null;){if(l.tag===3){Xw(l,a,m);break}else if(l.tag===1){var w=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(So===null||!So.has(w))){a=Ri(m,a),a=xw(l,a,1),l=ko(l,a,1),a=Qn(),l!==null&&(fo(l,1,a),fs(l,a));break}}l=l.return}}function mT(a,l,m){var w=a.pingCache;w!==null&&w.delete(l),l=Qn(),a.pingedLanes|=a.suspendedLanes&m,Nn===a&&(An&m)===m&&(yn===4||yn===3&&(An&130023424)===An&&500>lt()-Tp?wa(a,0):_p|=m),fs(a,l)}function Zw(a,l){l===0&&((a.mode&1)===0?l=1:(l=ca,ca<<=1,(ca&130023424)===0&&(ca=4194304)));var m=Qn();a=Hr(a,l),a!==null&&(fo(a,l,m),fs(a,m))}function hT(a){var l=a.memoizedState,m=0;l!==null&&(m=l.retryLane),Zw(a,m)}function pT(a,l){var m=0;switch(a.tag){case 13:var w=a.stateNode,C=a.memoizedState;C!==null&&(m=C.retryLane);break;case 19:w=a.stateNode;break;default:throw Error(s(314))}w!==null&&w.delete(l),Zw(a,m)}var ej;ej=function(a,l,m){if(a!==null)if(a.memoizedProps!==l.pendingProps||ls.current)ds=!0;else{if((a.lanes&m)===0&&(l.flags&128)===0)return ds=!1,nT(a,l,m);ds=(a.flags&131072)!==0}else ds=!1,Yt&&(l.flags&1048576)!==0&&Oy(l,du,l.index);switch(l.lanes=0,l.tag){case 2:var w=l.type;Su(a,l),a=l.pendingProps;var C=ki(l,Mn.current);_i(l,m),C=ip(null,l,w,a,C,m);var T=lp();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,cs(w)?(T=!0,iu(l)):T=!1,l.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,ep(l),C.updater=ku,l.stateNode=C,C._reactInternals=l,hp(l,w,a,m),l=vp(null,l,w,!0,T,m)):(l.tag=0,Yt&&T&&Bh(l),Yn(null,l,C,m),l=l.child),l;case 16:w=l.elementType;e:{switch(Su(a,l),a=l.pendingProps,C=w._init,w=C(w._payload),l.type=w,C=l.tag=xT(w),a=rr(w,a),C){case 0:l=xp(null,l,w,a,m);break e;case 1:l=Cw(null,l,w,a,m);break e;case 11:l=ww(null,l,w,a,m);break e;case 14:l=jw(null,l,w,rr(w.type,a),m);break e}throw Error(s(306,w,""))}return l;case 0:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:rr(w,C),xp(a,l,w,C,m);case 1:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:rr(w,C),Cw(a,l,w,C,m);case 3:e:{if(Ew(l),a===null)throw Error(s(387));w=l.pendingProps,T=l.memoizedState,C=T.element,Wy(a,l),gu(l,w,null,m);var D=l.memoizedState;if(w=D.element,T.isDehydrated)if(T={element:w,isDehydrated:!1,cache:D.cache,pendingSuspenseBoundaries:D.pendingSuspenseBoundaries,transitions:D.transitions},l.updateQueue.baseState=T,l.memoizedState=T,l.flags&256){C=Ri(Error(s(423)),l),l=$w(a,l,w,m,C);break e}else if(w!==C){C=Ri(Error(s(424)),l),l=$w(a,l,w,m,C);break e}else for(ks=vo(l.stateNode.containerInfo.firstChild),js=l,Yt=!0,sr=null,m=Fy(l,null,w,m),l.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(Ci(),w===C){l=Gr(a,l,m);break e}Yn(a,l,w,m)}l=l.child}return l;case 5:return Gy(l),a===null&&Kh(l),w=l.type,C=l.pendingProps,T=a!==null?a.memoizedProps:null,D=C.children,zh(w,C)?D=null:T!==null&&zh(w,T)&&(l.flags|=32),Sw(a,l),Yn(a,l,D,m),l.child;case 6:return a===null&&Kh(l),null;case 13:return _w(a,l,m);case 4:return tp(l,l.stateNode.containerInfo),w=l.pendingProps,a===null?l.child=Ei(l,null,w,m):Yn(a,l,w,m),l.child;case 11:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:rr(w,C),ww(a,l,w,C,m);case 7:return Yn(a,l,l.pendingProps,m),l.child;case 8:return Yn(a,l,l.pendingProps.children,m),l.child;case 12:return Yn(a,l,l.pendingProps.children,m),l.child;case 10:e:{if(w=l.type._context,C=l.pendingProps,T=l.memoizedProps,D=C.value,Ut(mu,w._currentValue),w._currentValue=D,T!==null)if(nr(T.value,D)){if(T.children===C.children&&!ls.current){l=Gr(a,l,m);break e}}else for(T=l.child,T!==null&&(T.return=l);T!==null;){var Y=T.dependencies;if(Y!==null){D=T.child;for(var Z=Y.firstContext;Z!==null;){if(Z.context===w){if(T.tag===1){Z=Br(-1,m&-m),Z.tag=2;var ue=T.updateQueue;if(ue!==null){ue=ue.shared;var ke=ue.pending;ke===null?Z.next=Z:(Z.next=ke.next,ke.next=Z),ue.pending=Z}}T.lanes|=m,Z=T.alternate,Z!==null&&(Z.lanes|=m),Xh(T.return,m,l),Y.lanes|=m;break}Z=Z.next}}else if(T.tag===10)D=T.type===l.type?null:T.child;else if(T.tag===18){if(D=T.return,D===null)throw Error(s(341));D.lanes|=m,Y=D.alternate,Y!==null&&(Y.lanes|=m),Xh(D,m,l),D=T.sibling}else D=T.child;if(D!==null)D.return=T;else for(D=T;D!==null;){if(D===l){D=null;break}if(T=D.sibling,T!==null){T.return=D.return,D=T;break}D=D.return}T=D}Yn(a,l,C.children,m),l=l.child}return l;case 9:return C=l.type,w=l.pendingProps.children,_i(l,m),C=Ps(C),w=w(C),l.flags|=1,Yn(a,l,w,m),l.child;case 14:return w=l.type,C=rr(w,l.pendingProps),C=rr(w.type,C),jw(a,l,w,C,m);case 15:return kw(a,l,l.type,l.pendingProps,m);case 17:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:rr(w,C),Su(a,l),l.tag=1,cs(w)?(a=!0,iu(l)):a=!1,_i(l,m),hw(l,w,C),hp(l,w,C,m),vp(null,l,w,!0,a,m);case 19:return Rw(a,l,m);case 22:return Nw(a,l,m)}throw Error(s(156,l.tag))};function tj(a,l){return ye(a,l)}function gT(a,l,m,w){this.tag=a,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ds(a,l,m,w){return new gT(a,l,m,w)}function zp(a){return a=a.prototype,!(!a||!a.isReactComponent)}function xT(a){if(typeof a=="function")return zp(a)?1:0;if(a!=null){if(a=a.$$typeof,a===M)return 11;if(a===q)return 14}return 2}function _o(a,l){var m=a.alternate;return m===null?(m=Ds(a.tag,l,a.key,a.mode),m.elementType=a.elementType,m.type=a.type,m.stateNode=a.stateNode,m.alternate=a,a.alternate=m):(m.pendingProps=l,m.type=a.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=a.flags&14680064,m.childLanes=a.childLanes,m.lanes=a.lanes,m.child=a.child,m.memoizedProps=a.memoizedProps,m.memoizedState=a.memoizedState,m.updateQueue=a.updateQueue,l=a.dependencies,m.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},m.sibling=a.sibling,m.index=a.index,m.ref=a.ref,m}function Pu(a,l,m,w,C,T){var D=2;if(w=a,typeof a=="function")zp(a)&&(D=1);else if(typeof a=="string")D=5;else e:switch(a){case O:return ka(m.children,C,T,l);case L:D=8,C|=8;break;case P:return a=Ds(12,m,l,C|2),a.elementType=P,a.lanes=T,a;case F:return a=Ds(13,m,l,C),a.elementType=F,a.lanes=T,a;case I:return a=Ds(19,m,l,C),a.elementType=I,a.lanes=T,a;case K:return Iu(m,C,T,l);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case R:D=10;break e;case A:D=9;break e;case M:D=11;break e;case q:D=14;break e;case W:D=16,w=null;break e}throw Error(s(130,a==null?a:typeof a,""))}return l=Ds(D,m,l,C),l.elementType=a,l.type=w,l.lanes=T,l}function ka(a,l,m,w){return a=Ds(7,a,w,l),a.lanes=m,a}function Iu(a,l,m,w){return a=Ds(22,a,w,l),a.elementType=K,a.lanes=m,a.stateNode={isHidden:!1},a}function Dp(a,l,m){return a=Ds(6,a,null,l),a.lanes=m,a}function Fp(a,l,m){return l=Ds(4,a.children!==null?a.children:[],a.key,l),l.lanes=m,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}function vT(a,l,m,w,C){this.tag=l,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=di(0),this.expirationTimes=di(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=di(0),this.identifierPrefix=w,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function Up(a,l,m,w,C,T,D,Y,Z){return a=new vT(a,l,m,Y,Z),l===1?(l=1,T===!0&&(l|=8)):l=0,T=Ds(3,null,null,l),a.current=T,T.stateNode=a,T.memoizedState={element:w,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},ep(T),a}function bT(a,l,m){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_,key:w==null?null:""+w,children:a,containerInfo:l,implementation:m}}function nj(a){if(!a)return yo;a=a._reactInternals;e:{if(Me(a)!==a||a.tag!==1)throw Error(s(170));var l=a;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(cs(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(s(171))}if(a.tag===1){var m=a.type;if(cs(m))return Ty(a,m,l)}return l}function sj(a,l,m,w,C,T,D,Y,Z){return a=Up(m,w,!0,a,C,T,D,Y,Z),a.context=nj(null),m=a.current,w=Qn(),C=Eo(m),T=Br(w,C),T.callback=l??null,ko(m,T,C),a.current.lanes=C,fo(a,C,w),fs(a,w),a}function zu(a,l,m,w){var C=l.current,T=Qn(),D=Eo(C);return m=nj(m),l.context===null?l.context=m:l.pendingContext=m,l=Br(T,D),l.payload={element:a},w=w===void 0?null:w,w!==null&&(l.callback=w),a=ko(C,l,D),a!==null&&(ir(a,C,D,T),pu(a,C,D)),D}function Du(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function rj(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var m=a.retryLane;a.retryLane=m!==0&&m<l?m:l}}function Wp(a,l){rj(a,l),(a=a.alternate)&&rj(a,l)}function yT(){return null}var oj=typeof reportError=="function"?reportError:function(a){console.error(a)};function Hp(a){this._internalRoot=a}Fu.prototype.render=Hp.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(s(409));zu(a,l,null,null)},Fu.prototype.unmount=Hp.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;ya(function(){zu(null,a,null,null)}),l[Dr]=null}};function Fu(a){this._internalRoot=a}Fu.prototype.unstable_scheduleHydration=function(a){if(a){var l=Fl();a={blockedOn:null,target:a,priority:l};for(var m=0;m<Fe.length&&l!==0&&l<Fe[m].priority;m++);Fe.splice(m,0,a),m===0&&Vn(a)}};function Bp(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Uu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function aj(){}function wT(a,l,m,w,C){if(C){if(typeof w=="function"){var T=w;w=function(){var ue=Du(D);T.call(ue)}}var D=sj(l,w,a,0,null,!1,!1,"",aj);return a._reactRootContainer=D,a[Dr]=D.current,Ql(a.nodeType===8?a.parentNode:a),ya(),D}for(;C=a.lastChild;)a.removeChild(C);if(typeof w=="function"){var Y=w;w=function(){var ue=Du(Z);Y.call(ue)}}var Z=Up(a,0,!1,null,null,!1,!1,"",aj);return a._reactRootContainer=Z,a[Dr]=Z.current,Ql(a.nodeType===8?a.parentNode:a),ya(function(){zu(l,Z,m,w)}),Z}function Wu(a,l,m,w,C){var T=m._reactRootContainer;if(T){var D=T;if(typeof C=="function"){var Y=C;C=function(){var Z=Du(D);Y.call(Z)}}zu(l,D,a,C)}else D=wT(m,l,a,C,w);return Du(D)}zl=function(a){switch(a.tag){case 3:var l=a.stateNode;if(l.current.memoizedState.isDehydrated){var m=uo(l.pendingLanes);m!==0&&(ui(l,m|1),fs(l,lt()),(Ct&6)===0&&(Li=lt()+500,wo()))}break;case 13:ya(function(){var w=Hr(a,1);if(w!==null){var C=Qn();ir(w,a,1,C)}}),Wp(a,1)}},fi=function(a){if(a.tag===13){var l=Hr(a,134217728);if(l!==null){var m=Qn();ir(l,a,134217728,m)}Wp(a,134217728)}},Dl=function(a){if(a.tag===13){var l=Eo(a),m=Hr(a,l);if(m!==null){var w=Qn();ir(m,a,l,w)}Wp(a,l)}},Fl=function(){return $t},Ul=function(a,l){var m=$t;try{return $t=a,l()}finally{$t=m}},_e=function(a,l,m){switch(l){case"input":if(be(a,m),l=m.name,m.type==="radio"&&l!=null){for(m=a;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<m.length;l++){var w=m[l];if(w!==a&&w.form===a.form){var C=ou(w);if(!C)throw Error(s(90));Oe(w),be(w,C)}}}break;case"textarea":Ce(a,m);break;case"select":l=m.value,l!=null&&Ye(a,!!m.multiple,l,!1)}},Vt=Mp,xs=ya;var jT={usingClientEntryPoint:!1,Events:[Zl,wi,ou,jt,it,Mp]},mc={findFiberByHostInstance:fa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},kT={bundleType:mc.bundleType,version:mc.version,rendererPackageName:mc.rendererPackageName,rendererConfig:mc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:N.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=Be(a),a===null?null:a.stateNode},findFiberByHostInstance:mc.findFiberByHostInstance||yT,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 Hu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hu.isDisabled&&Hu.supportsFiber)try{ia=Hu.inject(kT),ys=Hu}catch{}}return ms.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=jT,ms.createPortal=function(a,l){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Bp(l))throw Error(s(200));return bT(a,l,null,m)},ms.createRoot=function(a,l){if(!Bp(a))throw Error(s(299));var m=!1,w="",C=oj;return l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(w=l.identifierPrefix),l.onRecoverableError!==void 0&&(C=l.onRecoverableError)),l=Up(a,1,!1,null,null,m,!1,w,C),a[Dr]=l.current,Ql(a.nodeType===8?a.parentNode:a),new Hp(l)},ms.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var l=a._reactInternals;if(l===void 0)throw typeof a.render=="function"?Error(s(188)):(a=Object.keys(a).join(","),Error(s(268,a)));return a=Be(l),a=a===null?null:a.stateNode,a},ms.flushSync=function(a){return ya(a)},ms.hydrate=function(a,l,m){if(!Uu(l))throw Error(s(200));return Wu(null,a,l,!0,m)},ms.hydrateRoot=function(a,l,m){if(!Bp(a))throw Error(s(405));var w=m!=null&&m.hydratedSources||null,C=!1,T="",D=oj;if(m!=null&&(m.unstable_strictMode===!0&&(C=!0),m.identifierPrefix!==void 0&&(T=m.identifierPrefix),m.onRecoverableError!==void 0&&(D=m.onRecoverableError)),l=sj(l,null,a,1,m??null,C,!1,T,D),a[Dr]=l.current,Ql(a),w)for(a=0;a<w.length;a++)m=w[a],C=m._getVersion,C=C(m._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[m,C]:l.mutableSourceEagerHydrationData.push(m,C);return new Fu(l)},ms.render=function(a,l,m){if(!Uu(l))throw Error(s(200));return Wu(null,a,l,!1,m)},ms.unmountComponentAtNode=function(a){if(!Uu(a))throw Error(s(40));return a._reactRootContainer?(ya(function(){Wu(null,null,a,!1,function(){a._reactRootContainer=null,a[Dr]=null})}),!0):!1},ms.unstable_batchedUpdates=Mp,ms.unstable_renderSubtreeIntoContainer=function(a,l,m,w){if(!Uu(m))throw Error(s(200));if(a==null||a._reactInternals===void 0)throw Error(s(38));return Wu(a,l,m,!1,w)},ms.version="18.3.1-next-f1338f8080-20240426",ms}var hj;function PN(){if(hj)return Kp.exports;hj=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(),Kp.exports=OT(),Kp.exports}var pj;function LT(){if(pj)return Bu;pj=1;var e=PN();return Bu.createRoot=e.createRoot,Bu.hydrateRoot=e.hydrateRoot,Bu}var MT=LT();function ns(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 Qo=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 PT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),IN=(...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 IT={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 zT=p.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:c,...d},u)=>p.createElement("svg",{ref:u,...IT,width:n,height:n,stroke:e,strokeWidth:r?Number(s)*24/Number(n):s,className:IN("lucide",o),...d},[...c.map(([f,g])=>p.createElement(f,g)),...Array.isArray(i)?i:[i]]));/**
|
|
56
|
-
* @license lucide-react v0.468.0 - ISC
|
|
57
|
-
*
|
|
58
|
-
* This source code is licensed under the ISC license.
|
|
59
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
60
|
-
*/const Te=(e,n)=>{const s=p.forwardRef(({className:r,...o},i)=>p.createElement(zT,{ref:i,iconNode:n,className:IN(`lucide-${PT(e)}`,r),...o}));return s.displayName=`${e}`,s};/**
|
|
61
|
-
* @license lucide-react v0.468.0 - ISC
|
|
62
|
-
*
|
|
63
|
-
* This source code is licensed under the ISC license.
|
|
64
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
65
|
-
*/const DT=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 zN=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 ld=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 On=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 Jx=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 hr=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 DN=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 gm=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 Rf=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 FN=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 Hc=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 cd=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 wl=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 Mr=Te("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
131
|
-
* @license lucide-react v0.468.0 - ISC
|
|
132
|
-
*
|
|
133
|
-
* This source code is licensed under the ISC license.
|
|
134
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
135
|
-
*/const FT=Te("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
|
136
|
-
* @license lucide-react v0.468.0 - ISC
|
|
137
|
-
*
|
|
138
|
-
* This source code is licensed under the ISC license.
|
|
139
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
140
|
-
*/const _s=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 al=Te("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
|
146
|
-
* @license lucide-react v0.468.0 - ISC
|
|
147
|
-
*
|
|
148
|
-
* This source code is licensed under the ISC license.
|
|
149
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
150
|
-
*/const UT=Te("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/**
|
|
151
|
-
* @license lucide-react v0.468.0 - ISC
|
|
152
|
-
*
|
|
153
|
-
* This source code is licensed under the ISC license.
|
|
154
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
155
|
-
*/const UN=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 Xx=Te("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/**
|
|
161
|
-
* @license lucide-react v0.468.0 - ISC
|
|
162
|
-
*
|
|
163
|
-
* This source code is licensed under the ISC license.
|
|
164
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
165
|
-
*/const WT=Te("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
|
|
166
|
-
* @license lucide-react v0.468.0 - ISC
|
|
167
|
-
*
|
|
168
|
-
* This source code is licensed under the ISC license.
|
|
169
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
170
|
-
*/const WN=Te("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
|
|
171
|
-
* @license lucide-react v0.468.0 - ISC
|
|
172
|
-
*
|
|
173
|
-
* This source code is licensed under the ISC license.
|
|
174
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
175
|
-
*/const HT=Te("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/**
|
|
176
|
-
* @license lucide-react v0.468.0 - ISC
|
|
177
|
-
*
|
|
178
|
-
* This source code is licensed under the ISC license.
|
|
179
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
180
|
-
*/const BT=Te("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
|
181
|
-
* @license lucide-react v0.468.0 - ISC
|
|
182
|
-
*
|
|
183
|
-
* This source code is licensed under the ISC license.
|
|
184
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
185
|
-
*/const xm=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 Xa=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 GT=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 qT=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 HN=Te("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
206
|
-
* @license lucide-react v0.468.0 - ISC
|
|
207
|
-
*
|
|
208
|
-
* This source code is licensed under the ISC license.
|
|
209
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
210
|
-
*/const KT=Te("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
|
|
211
|
-
* @license lucide-react v0.468.0 - ISC
|
|
212
|
-
*
|
|
213
|
-
* This source code is licensed under the ISC license.
|
|
214
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
215
|
-
*/const VT=Te("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
|
216
|
-
* @license lucide-react v0.468.0 - ISC
|
|
217
|
-
*
|
|
218
|
-
* This source code is licensed under the ISC license.
|
|
219
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
220
|
-
*/const vm=Te("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
221
|
-
* @license lucide-react v0.468.0 - ISC
|
|
222
|
-
*
|
|
223
|
-
* This source code is licensed under the ISC license.
|
|
224
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
225
|
-
*/const Za=Te("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
|
226
|
-
* @license lucide-react v0.468.0 - ISC
|
|
227
|
-
*
|
|
228
|
-
* This source code is licensed under the ISC license.
|
|
229
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
230
|
-
*/const BN=Te("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
|
|
231
|
-
* @license lucide-react v0.468.0 - ISC
|
|
232
|
-
*
|
|
233
|
-
* This source code is licensed under the ISC license.
|
|
234
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
235
|
-
*/const YT=Te("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
|
|
236
|
-
* @license lucide-react v0.468.0 - ISC
|
|
237
|
-
*
|
|
238
|
-
* This source code is licensed under the ISC license.
|
|
239
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
240
|
-
*/const bm=Te("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/**
|
|
241
|
-
* @license lucide-react v0.468.0 - ISC
|
|
242
|
-
*
|
|
243
|
-
* This source code is licensed under the ISC license.
|
|
244
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
245
|
-
*/const gj=Te("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/**
|
|
246
|
-
* @license lucide-react v0.468.0 - ISC
|
|
247
|
-
*
|
|
248
|
-
* This source code is licensed under the ISC license.
|
|
249
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
250
|
-
*/const GN=Te("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
|
|
251
|
-
* @license lucide-react v0.468.0 - ISC
|
|
252
|
-
*
|
|
253
|
-
* This source code is licensed under the ISC license.
|
|
254
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
255
|
-
*/const QT=Te("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/**
|
|
256
|
-
* @license lucide-react v0.468.0 - ISC
|
|
257
|
-
*
|
|
258
|
-
* This source code is licensed under the ISC license.
|
|
259
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
260
|
-
*/const JT=Te("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
|
|
261
|
-
* @license lucide-react v0.468.0 - ISC
|
|
262
|
-
*
|
|
263
|
-
* This source code is licensed under the ISC license.
|
|
264
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
265
|
-
*/const dd=Te("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
|
|
266
|
-
* @license lucide-react v0.468.0 - ISC
|
|
267
|
-
*
|
|
268
|
-
* This source code is licensed under the ISC license.
|
|
269
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
270
|
-
*/const Zx=Te("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/**
|
|
271
|
-
* @license lucide-react v0.468.0 - ISC
|
|
272
|
-
*
|
|
273
|
-
* This source code is licensed under the ISC license.
|
|
274
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
275
|
-
*/const Hg=Te("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
|
|
276
|
-
* @license lucide-react v0.468.0 - ISC
|
|
277
|
-
*
|
|
278
|
-
* This source code is licensed under the ISC license.
|
|
279
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
280
|
-
*/const Da=Te("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
|
|
281
|
-
* @license lucide-react v0.468.0 - ISC
|
|
282
|
-
*
|
|
283
|
-
* This source code is licensed under the ISC license.
|
|
284
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
285
|
-
*/const XT=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"}]]);/**
|
|
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 qN=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"}]]);/**
|
|
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 ym=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"}]]);/**
|
|
296
|
-
* @license lucide-react v0.468.0 - ISC
|
|
297
|
-
*
|
|
298
|
-
* This source code is licensed under the ISC license.
|
|
299
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
300
|
-
*/const ZT=Te("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"}]]);/**
|
|
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 eR=Te("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
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 Qp=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"}]]);/**
|
|
311
|
-
* @license lucide-react v0.468.0 - ISC
|
|
312
|
-
*
|
|
313
|
-
* This source code is licensed under the ISC license.
|
|
314
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
315
|
-
*/const tR=Te("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"}]]);/**
|
|
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 nR=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"}]]);/**
|
|
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 sR=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"}]]);/**
|
|
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 rR=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"}]]);/**
|
|
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 ev=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"}]]);/**
|
|
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 oR=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"}]]);/**
|
|
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 aR=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"}]]);/**
|
|
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 ei=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"}]]);/**
|
|
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 iR=Te("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
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 lR=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"}]]);/**
|
|
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 cR=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"}]]);/**
|
|
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 il=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"}]]);/**
|
|
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 tv=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"}]]);/**
|
|
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 Jo=Te("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
|
|
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 dR=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"}]]);/**
|
|
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 jl=Te("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
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 uR=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"}]]);/**
|
|
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 KN=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"}]]);/**
|
|
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 Xo=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"}]]);/**
|
|
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 VN=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"}]]);/**
|
|
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 nv=Te("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/**
|
|
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 fR=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"}]]);/**
|
|
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 wm=Te("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
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 YN=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"}]]);/**
|
|
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 mR=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"}]]);/**
|
|
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 QN=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"}]]);/**
|
|
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 JN=Te("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
|
|
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 sv=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"}]]);/**
|
|
451
|
-
* @license lucide-react v0.468.0 - ISC
|
|
452
|
-
*
|
|
453
|
-
* This source code is licensed under the ISC license.
|
|
454
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
455
|
-
*/const hR=Te("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
456
|
-
* @license lucide-react v0.468.0 - ISC
|
|
457
|
-
*
|
|
458
|
-
* This source code is licensed under the ISC license.
|
|
459
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
460
|
-
*/const pR=Te("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"}]]);/**
|
|
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 gR=Te("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
|
|
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 XN=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"}]]);/**
|
|
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 Ks=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"}]]);/**
|
|
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 rv=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"}]]);/**
|
|
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 ll=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"}]]);/**
|
|
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 ZN=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"}]]);/**
|
|
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 ti=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"}]]);/**
|
|
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 Af=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"}]]);/**
|
|
501
|
-
* @license lucide-react v0.468.0 - ISC
|
|
502
|
-
*
|
|
503
|
-
* This source code is licensed under the ISC license.
|
|
504
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
505
|
-
*/const Zo=Te("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
|
|
506
|
-
* @license lucide-react v0.468.0 - ISC
|
|
507
|
-
*
|
|
508
|
-
* This source code is licensed under the ISC license.
|
|
509
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
510
|
-
*/const xR=Te("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 e1(e){var n,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(n=0;n<o;n++)e[n]&&(s=e1(e[n]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function t1(){for(var e,n,s=0,r="",o=arguments.length;s<o;s++)(e=arguments[s])&&(n=e1(e))&&(r&&(r+=" "),r+=n);return r}const ov="-",vR=e=>{const n=yR(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const d=c.split(ov);return d[0]===""&&d.length!==1&&d.shift(),n1(d,n)||bR(c)},getConflictingClassGroupIds:(c,d)=>{const u=s[c]||[];return d&&r[c]?[...u,...r[c]]:u}}},n1=(e,n)=>{var c;if(e.length===0)return n.classGroupId;const s=e[0],r=n.nextPart.get(s),o=r?n1(e.slice(1),r):void 0;if(o)return o;if(n.validators.length===0)return;const i=e.join(ov);return(c=n.validators.find(({validator:d})=>d(i)))==null?void 0:c.classGroupId},xj=/^\[(.+)\]$/,bR=e=>{if(xj.test(e)){const n=xj.exec(e)[1],s=n==null?void 0:n.substring(0,n.indexOf(":"));if(s)return"arbitrary.."+s}},yR=e=>{const{theme:n,prefix:s}=e,r={nextPart:new Map,validators:[]};return jR(Object.entries(e.classGroups),s).forEach(([i,c])=>{Bg(c,r,i,n)}),r},Bg=(e,n,s,r)=>{e.forEach(o=>{if(typeof o=="string"){const i=o===""?n:vj(n,o);i.classGroupId=s;return}if(typeof o=="function"){if(wR(o)){Bg(o(r),n,s,r);return}n.validators.push({validator:o,classGroupId:s});return}Object.entries(o).forEach(([i,c])=>{Bg(c,vj(n,i),s,r)})})},vj=(e,n)=>{let s=e;return n.split(ov).forEach(r=>{s.nextPart.has(r)||s.nextPart.set(r,{nextPart:new Map,validators:[]}),s=s.nextPart.get(r)}),s},wR=e=>e.isThemeGetter,jR=(e,n)=>n?e.map(([s,r])=>{const o=r.map(i=>typeof i=="string"?n+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([c,d])=>[n+c,d])):i);return[s,o]}):e,kR=e=>{if(e<1)return{get:()=>{},set:()=>{}};let n=0,s=new Map,r=new Map;const o=(i,c)=>{s.set(i,c),n++,n>e&&(n=0,r=s,s=new Map)};return{get(i){let c=s.get(i);if(c!==void 0)return c;if((c=r.get(i))!==void 0)return o(i,c),c},set(i,c){s.has(i)?s.set(i,c):o(i,c)}}},s1="!",NR=e=>{const{separator:n,experimentalParseClassName:s}=e,r=n.length===1,o=n[0],i=n.length,c=d=>{const u=[];let f=0,g=0,y;for(let j=0;j<d.length;j++){let k=d[j];if(f===0){if(k===o&&(r||d.slice(j,j+i)===n)){u.push(d.slice(g,j)),g=j+i;continue}if(k==="/"){y=j;continue}}k==="["?f++:k==="]"&&f--}const v=u.length===0?d:d.substring(g),h=v.startsWith(s1),x=h?v.substring(1):v,b=y&&y>g?y-g:void 0;return{modifiers:u,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:b}};return s?d=>s({className:d,parseClassName:c}):c},SR=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},CR=e=>({cache:kR(e.cacheSize),parseClassName:NR(e),...vR(e)}),ER=/\s+/,$R=(e,n)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:o}=n,i=[],c=e.trim().split(ER);let d="";for(let u=c.length-1;u>=0;u-=1){const f=c[u],{modifiers:g,hasImportantModifier:y,baseClassName:v,maybePostfixModifierPosition:h}=s(f);let x=!!h,b=r(x?v.substring(0,h):v);if(!b){if(!x){d=f+(d.length>0?" "+d:d);continue}if(b=r(v),!b){d=f+(d.length>0?" "+d:d);continue}x=!1}const j=SR(g).join(":"),k=y?j+s1:j,E=k+b;if(i.includes(E))continue;i.push(E);const S=o(b,x);for(let N=0;N<S.length;++N){const $=S[N];i.push(k+$)}d=f+(d.length>0?" "+d:d)}return d};function _R(){let e=0,n,s,r="";for(;e<arguments.length;)(n=arguments[e++])&&(s=r1(n))&&(r&&(r+=" "),r+=s);return r}const r1=e=>{if(typeof e=="string")return e;let n,s="";for(let r=0;r<e.length;r++)e[r]&&(n=r1(e[r]))&&(s&&(s+=" "),s+=n);return s};function bj(e,...n){let s,r,o,i=c;function c(u){const f=n.reduce((g,y)=>y(g),e());return s=CR(f),r=s.cache.get,o=s.cache.set,i=d,d(u)}function d(u){const f=r(u);if(f)return f;const g=$R(u,s);return o(u,g),g}return function(){return i(_R.apply(null,arguments))}}const Kt=e=>{const n=s=>s[e]||[];return n.isThemeGetter=!0,n},o1=/^\[(?:([a-z-]+):)?(.+)\]$/i,TR=/^\d+\/\d+$/,RR=new Set(["px","full","screen"]),AR=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,OR=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,LR=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,MR=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,PR=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Kr=e=>Yi(e)||RR.has(e)||TR.test(e),Ro=e=>kl(e,"length",BR),Yi=e=>!!e&&!Number.isNaN(Number(e)),Jp=e=>kl(e,"number",Yi),pc=e=>!!e&&Number.isInteger(Number(e)),IR=e=>e.endsWith("%")&&Yi(e.slice(0,-1)),pt=e=>o1.test(e),Ao=e=>AR.test(e),zR=new Set(["length","size","percentage"]),DR=e=>kl(e,zR,a1),FR=e=>kl(e,"position",a1),UR=new Set(["image","url"]),WR=e=>kl(e,UR,qR),HR=e=>kl(e,"",GR),gc=()=>!0,kl=(e,n,s)=>{const r=o1.exec(e);return r?r[1]?typeof n=="string"?r[1]===n:n.has(r[1]):s(r[2]):!1},BR=e=>OR.test(e)&&!LR.test(e),a1=()=>!1,GR=e=>MR.test(e),qR=e=>PR.test(e),yj=()=>{const e=Kt("colors"),n=Kt("spacing"),s=Kt("blur"),r=Kt("brightness"),o=Kt("borderColor"),i=Kt("borderRadius"),c=Kt("borderSpacing"),d=Kt("borderWidth"),u=Kt("contrast"),f=Kt("grayscale"),g=Kt("hueRotate"),y=Kt("invert"),v=Kt("gap"),h=Kt("gradientColorStops"),x=Kt("gradientColorStopPositions"),b=Kt("inset"),j=Kt("margin"),k=Kt("opacity"),E=Kt("padding"),S=Kt("saturate"),N=Kt("scale"),$=Kt("sepia"),_=Kt("skew"),O=Kt("space"),L=Kt("translate"),P=()=>["auto","contain","none"],R=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto",pt,n],M=()=>[pt,n],F=()=>["",Kr,Ro],I=()=>["auto",Yi,pt],q=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],W=()=>["solid","dashed","dotted","double","none"],K=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>["start","end","center","between","around","evenly","stretch"],H=()=>["","0",pt],G=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[Yi,pt];return{cacheSize:500,separator:":",theme:{colors:[gc],spacing:[Kr,Ro],blur:["none","",Ao,pt],brightness:z(),borderColor:[e],borderRadius:["none","","full",Ao,pt],borderSpacing:M(),borderWidth:F(),contrast:z(),grayscale:H(),hueRotate:z(),invert:H(),gap:M(),gradientColorStops:[e],gradientColorStopPositions:[IR,Ro],inset:A(),margin:A(),opacity:z(),padding:M(),saturate:z(),scale:z(),sepia:H(),skew:z(),space:M(),translate:M()},classGroups:{aspect:[{aspect:["auto","square","video",pt]}],container:["container"],columns:[{columns:[Ao]}],"break-after":[{"break-after":G()}],"break-before":[{"break-before":G()}],"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:[...q(),pt]}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[b]}],"inset-x":[{"inset-x":[b]}],"inset-y":[{"inset-y":[b]}],start:[{start:[b]}],end:[{end:[b]}],top:[{top:[b]}],right:[{right:[b]}],bottom:[{bottom:[b]}],left:[{left:[b]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",pc,pt]}],basis:[{basis:A()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",pt]}],grow:[{grow:H()}],shrink:[{shrink:H()}],order:[{order:["first","last","none",pc,pt]}],"grid-cols":[{"grid-cols":[gc]}],"col-start-end":[{col:["auto",{span:["full",pc,pt]},pt]}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":[gc]}],"row-start-end":[{row:["auto",{span:[pc,pt]},pt]}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",pt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",pt]}],gap:[{gap:[v]}],"gap-x":[{"gap-x":[v]}],"gap-y":[{"gap-y":[v]}],"justify-content":[{justify:["normal",...U()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...U(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...U(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[E]}],px:[{px:[E]}],py:[{py:[E]}],ps:[{ps:[E]}],pe:[{pe:[E]}],pt:[{pt:[E]}],pr:[{pr:[E]}],pb:[{pb:[E]}],pl:[{pl:[E]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[O]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[O]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",pt,n]}],"min-w":[{"min-w":[pt,n,"min","max","fit"]}],"max-w":[{"max-w":[pt,n,"none","full","min","max","fit","prose",{screen:[Ao]},Ao]}],h:[{h:[pt,n,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[pt,n,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[pt,n,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[pt,n,"auto","min","max","fit"]}],"font-size":[{text:["base",Ao,Ro]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Jp]}],"font-family":[{font:[gc]}],"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",pt]}],"line-clamp":[{"line-clamp":["none",Yi,Jp]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Kr,pt]}],"list-image":[{"list-image":["none",pt]}],"list-style-type":[{list:["none","disc","decimal",pt]}],"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:[...W(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Kr,Ro]}],"underline-offset":[{"underline-offset":["auto",Kr,pt]}],"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:M()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pt]}],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",pt]}],"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:[...q(),FR]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",DR]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},WR]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[d]}],"border-w-x":[{"border-x":[d]}],"border-w-y":[{"border-y":[d]}],"border-w-s":[{"border-s":[d]}],"border-w-e":[{"border-e":[d]}],"border-w-t":[{"border-t":[d]}],"border-w-r":[{"border-r":[d]}],"border-w-b":[{"border-b":[d]}],"border-w-l":[{"border-l":[d]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...W(),"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:W()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...W()]}],"outline-offset":[{"outline-offset":[Kr,pt]}],"outline-w":[{outline:[Kr,Ro]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Kr,Ro]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Ao,HR]}],"shadow-color":[{shadow:[gc]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...K(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":K()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Ao,pt]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[g]}],invert:[{invert:[y]}],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":[g]}],"backdrop-invert":[{"backdrop-invert":[y]}],"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",pt]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",pt]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",pt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[N]}],"scale-x":[{"scale-x":[N]}],"scale-y":[{"scale-y":[N]}],rotate:[{rotate:[pc,pt]}],"translate-x":[{"translate-x":[L]}],"translate-y":[{"translate-y":[L]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",pt]}],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",pt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"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",pt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Kr,Ro,Jp]}],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"]}}},KR=(e,{cacheSize:n,prefix:s,separator:r,experimentalParseClassName:o,extend:i={},override:c={}})=>{_c(e,"cacheSize",n),_c(e,"prefix",s),_c(e,"separator",r),_c(e,"experimentalParseClassName",o);for(const d in c)VR(e[d],c[d]);for(const d in i)YR(e[d],i[d]);return e},_c=(e,n,s)=>{s!==void 0&&(e[n]=s)},VR=(e,n)=>{if(n)for(const s in n)_c(e,s,n[s])},YR=(e,n)=>{if(n)for(const s in n){const r=n[s];r!==void 0&&(e[s]=(e[s]||[]).concat(r))}},QR=(e,...n)=>typeof e=="function"?bj(yj,e,...n):bj(()=>KR(yj(),e),...n),JR=QR({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)=>JR(t1(e)),XR={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:Hg},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:Hg},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:UN},warning:{box:"border-warning/50 bg-warning/5",text:"text-warning-text",Icon:Ks},error:{box:"border-destructive/50 bg-destructive/5",text:"text-destructive-text",Icon:al}};function bt({tone:e="neutral",title:n,actions:s,bar:r,icon:o,role:i,className:c,children:d,...u}){const f=XR[e],g=o===!1?null:o??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:[g&&t.jsx(g,{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 wj=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,jj=t1,ZR=(e,n)=>s=>{var r;if((n==null?void 0:n.variants)==null)return jj(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:o,defaultVariants:i}=n,c=Object.keys(o).map(f=>{const g=s==null?void 0:s[f],y=i==null?void 0:i[f];if(g===null)return null;const v=wj(g)||wj(y);return o[f][v]}),d=s&&Object.entries(s).reduce((f,g)=>{let[y,v]=g;return v===void 0||(f[y]=v),f},{}),u=n==null||(r=n.compoundVariants)===null||r===void 0?void 0:r.reduce((f,g)=>{let{class:y,className:v,...h}=g;return Object.entries(h).every(x=>{let[b,j]=x;return Array.isArray(j)?j.includes({...i,...d}[b]):{...i,...d}[b]===j})?[...f,y,v]:f},[]);return jj(e,c,u,s==null?void 0:s.class,s==null?void 0:s.className)},cl=ZR("caps inline-flex items-center justify-center gap-2 whitespace-nowrap !rounded-action border text-small transition-colors disabled:cursor-not-allowed disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0",{variants:{variant:{outline:"border-border bg-background hover:border-border-strong hover:bg-accent",primary:"border-transparent bg-primary/10 text-primary-action-text hover:bg-primary/20 focus-visible:bg-primary/20",solid:"border-transparent bg-primary/10 text-primary-action-text hover:bg-primary/20 focus-visible:bg-primary/20",destructive:"border-destructive/60 text-destructive-text hover:bg-destructive/10",ghost:"border-transparent hover:bg-accent"},size:{xs:"h-7 gap-1.5 px-2 text-label",sm:"h-control-sm px-3",md:"h-control-md px-4",lg:"h-control-lg px-5",icon:"size-control-sm"}},defaultVariants:{variant:"outline",size:"md"}}),B=p.forwardRef(({className:e,variant:n,size:s,...r},o)=>t.jsx("button",{ref:o,className:ae(cl({variant:n,size:s}),e),...r}));B.displayName="Button";const kj={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 Se({tone:e="plain",className:n,title:s,label:r,children:o}){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",kj[e],n),children:t.jsx("span",{className:"min-w-0 truncate",children:o})}):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",kj[e],n),children:o})}const Vs=e=>eA(e)?e.document:tA(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),jm=e=>{let n=Vs(e);return(n==null?void 0:n.defaultView)??(typeof window<"u"?window:void 0)};function i1(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function eA(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function tA(e){return i1(e)&&e.nodeType===9}function nA(e){return i1(e)&&e.nodeType===11&&"host"in e}let sA=!1;function av(){return sA}function Oa(e,n){var r;if(!av())return n&&e?e.contains(n):!1;if(!e||!n)return!1;let s=n;for(;s!=null;){if(s===e)return!0;typeof s.assignedElements!="function"&&((r=s.assignedSlot)!=null&&r.parentNode)?s=s.assignedSlot.parentNode:nA(s)?s=s.host:s=s.parentNode}return!1}const Ho=(e=document)=>{var s;if(!av())return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&((s=n.shadowRoot)!=null&&s.activeElement);)n=n.shadowRoot.activeElement;return n};function Zn(e){if(av()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}function rA(e){e.focus({preventScroll:!0})}const oA=typeof document<"u"?Ke.useLayoutEffect:()=>{};function l1(e){let n=e;return n.nativeEvent=e,n.isDefaultPrevented=()=>n.defaultPrevented,n.isPropagationStopped=()=>n.cancelBubble,n.persist=()=>{},n}function aA(e,n){Object.defineProperty(e,"target",{value:n}),Object.defineProperty(e,"currentTarget",{value:n})}function c1(e){let n=p.useRef({isFocused:!1,observer:null});return oA(()=>{const s=n.current;return()=>{s.observer&&(s.observer.disconnect(),s.observer=null)}},[]),p.useCallback(s=>{let r=Zn(s);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){n.current.isFocused=!0;let o=r,i=c=>{if(n.current.isFocused=!1,o.disabled){let d=l1(c);e==null||e(d)}n.current.observer&&(n.current.observer.disconnect(),n.current.observer=null)};o.addEventListener("focusout",i,{once:!0}),n.current.observer=new MutationObserver(()=>{var c;if(n.current.isFocused&&o.disabled){(c=n.current.observer)==null||c.disconnect();let d=o===Ho()?null:Ho();o.dispatchEvent(new FocusEvent("blur",{relatedTarget:d})),o.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:d}))}}),n.current.observer.observe(o,{attributes:!0,attributeFilter:["disabled"]})}},[e])}function iv(e){var s;if(typeof window>"u"||window.navigator==null)return!1;let n=(s=window.navigator.userAgentData)==null?void 0:s.brands;return Array.isArray(n)&&n.some(r=>e.test(r.brand))||e.test(window.navigator.userAgent)}function lv(e){var n;return typeof window<"u"&&window.navigator!=null?e.test(((n=window.navigator.userAgentData)==null?void 0:n.platform)||window.navigator.platform):!1}function ni(e){let n=null;return()=>(n==null&&(n=e()),n)}const cv=ni(function(){return lv(/^Mac/i)}),iA=ni(function(){return lv(/^iPhone/i)}),d1=ni(function(){return lv(/^iPad/i)||cv()&&navigator.maxTouchPoints>1}),lA=ni(function(){return iA()||d1()}),cA=ni(function(){return iv(/AppleWebKit/i)&&(lA()||!dA())}),dA=ni(function(){return iv(/Chrome|CriOS|CrMo/i)}),uA=ni(function(){return iv(/Android/i)});function fA(e){return e.pointerType===""&&e.isTrusted?!0:uA()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Bc(e,n,s=!0){let{metaKey:r,ctrlKey:o,altKey:i,shiftKey:c}=n,d=cA()&&cv()&&!d1()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:o,altKey:i,shiftKey:c}):new MouseEvent("click",{metaKey:r,ctrlKey:o,altKey:i,shiftKey:c,detail:1,bubbles:!0,cancelable:!0});Bc.isOpening=s,rA(e),e.dispatchEvent(d),Bc.isOpening=!1}Bc.isOpening=!1;let Nl=null;const Gg=new Set;let Mc=new Map,Fa=!1,bf=!1;const mA={Tab:!0,Escape:!0};function km(e,n){for(let s of Gg)s(e,n)}function hA(e){return!(e.metaKey||!cv()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Of(e){Fa=!0,!Bc.isOpening&&hA(e)&&(Nl="keyboard",km("keyboard",e))}function Qi(e){Nl="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(Fa=!0,km("pointer",e))}function u1(e){!Bc.isOpening&&fA(e)&&(Fa=!0,Nl="virtual")}function f1(e){let n=Zn(e),s=jm(n),r=Vs(n);if(n===s){bf=!0;return}n===r||!e.isTrusted||(!Fa&&!bf&&(Nl="virtual",km("virtual",e)),Fa=!1,bf=!1)}function m1(){Fa=!1,bf=!0}function h1(e){let n=Ho(Vs(Zn(e)));queueMicrotask(()=>{Ho(Vs(Zn(e)))!==n&&gA("keyboard")})}function qg(e){if(typeof window>"u"||typeof document>"u")return;const n=jm(e),s=Vs(e);if(Mc.get(n))return;let r=n.HTMLElement.prototype.focus;Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){Fa=!0,r.apply(this,arguments)}}),s.addEventListener("keydown",Of,!0),s.addEventListener("keyup",Of,!0),s.addEventListener("click",u1,!0),s.addEventListener("invalid",h1,!0),n.addEventListener("focus",f1,!0),n.addEventListener("blur",m1,!1),typeof PointerEvent<"u"&&(s.addEventListener("pointerdown",Qi,!0),s.addEventListener("pointermove",Qi,!0),s.addEventListener("pointerup",Qi,!0)),n.addEventListener("beforeunload",()=>{p1(e)},{once:!0}),Mc.set(n,{focus:r})}const p1=(e,n)=>{const s=jm(e),r=Vs(e);n&&r.removeEventListener("DOMContentLoaded",n),Mc.has(s)&&(Reflect.defineProperty(s.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:Mc.get(s).focus}),r.removeEventListener("keydown",Of,!0),r.removeEventListener("keyup",Of,!0),r.removeEventListener("click",u1,!0),r.removeEventListener("invalid",h1,!0),s.removeEventListener("focus",f1,!0),s.removeEventListener("blur",m1,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",Qi,!0),r.removeEventListener("pointermove",Qi,!0),r.removeEventListener("pointerup",Qi,!0)),Mc.delete(s))};function pA(e){const n=Vs(e);let s;return n.readyState!=="loading"?qg(e):(s=()=>{qg(e)},n.addEventListener("DOMContentLoaded",s)),()=>p1(e,s)}typeof document<"u"&&pA();function Kg(){return Nl!=="pointer"}function gA(e){Nl=e,km(e,null)}const xA=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function vA(e,n,s){let r=s?Zn(s):void 0,o=Vs(r),i=jm(r);const c=typeof i<"u"?i.HTMLInputElement:HTMLInputElement,d=typeof i<"u"?i.HTMLTextAreaElement:HTMLTextAreaElement,u=typeof i<"u"?i.HTMLElement:HTMLElement,f=typeof i<"u"?i.KeyboardEvent:KeyboardEvent;let g=Ho(o);return e=e||g instanceof c&&!xA.has(g.type)||g instanceof d||g instanceof u&&g.isContentEditable,!(e&&n==="keyboard"&&s instanceof f&&!mA[s.key])}function bA(e,n,s){qg(),p.useEffect(()=>{if((s==null?void 0:s.enabled)===!1)return;let r=(o,i)=>{vA(!!(s!=null&&s.isTextInput),o,i)&&e(Kg())};return Gg.add(r),()=>{Gg.delete(r)}},n)}function yA(e){let{isDisabled:n,onFocus:s,onBlur:r,onFocusChange:o}=e;const i=p.useCallback(u=>{if(Zn(u)===u.currentTarget)return r&&r(u),o&&o(!1),!0},[r,o]),c=c1(i),d=p.useCallback(u=>{let f=Zn(u);const g=Vs(f),y=g?Ho(g):Ho();f===u.currentTarget&&f===y&&(s&&s(u),o&&o(!0),c(u))},[o,s,c]);return{focusProps:{onFocus:!n&&(s||o||r)?d:void 0,onBlur:!n&&(r||o)?i:void 0}}}function g1(){let e=p.useRef(new Map),n=p.useCallback((o,i,c,d)=>{let u=d!=null&&d.once?(...f)=>{e.current.delete(c),c(...f)}:c;e.current.set(c,{type:i,eventTarget:o,fn:u,options:d}),o.addEventListener(i,u,d)},[]),s=p.useCallback((o,i,c,d)=>{var f;let u=((f=e.current.get(c))==null?void 0:f.fn)||c;o.removeEventListener(i,u,d),e.current.delete(c)},[]),r=p.useCallback(()=>{e.current.forEach((o,i)=>{s(o.eventTarget,o.type,i,o.options)})},[s]);return p.useEffect(()=>r,[r]),{addGlobalListener:n,removeGlobalListener:s,removeAllGlobalListeners:r}}function wA(e){let{isDisabled:n,onBlurWithin:s,onFocusWithin:r,onFocusWithinChange:o}=e,i=p.useRef({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:d}=g1(),u=p.useCallback(y=>{Oa(y.currentTarget,Zn(y))&&i.current.isFocusWithin&&!Oa(y.currentTarget,y.relatedTarget)&&(i.current.isFocusWithin=!1,d(),s&&s(y),o&&o(!1))},[s,o,i,d]),f=c1(u),g=p.useCallback(y=>{if(!Oa(y.currentTarget,Zn(y)))return;let v=Zn(y);const h=Vs(v),x=Ho(h);if(!i.current.isFocusWithin&&x===v){r&&r(y),o&&o(!0),i.current.isFocusWithin=!0,f(y);let b=y.currentTarget;c(h,"focus",j=>{let k=Zn(j);if(i.current.isFocusWithin&&!Oa(b,k)){let E=new h.defaultView.FocusEvent("blur",{relatedTarget:k});aA(E,b);let S=l1(E);u(S)}},{capture:!0})}},[r,o,f,c,u]);return n?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:g,onBlur:u}}}function jA(e={}){let{autoFocus:n=!1,isTextInput:s,within:r}=e,o=p.useRef({isFocused:!1,isFocusVisible:n||Kg()}),[i,c]=p.useState(!1),[d,u]=p.useState(()=>o.current.isFocused&&o.current.isFocusVisible),f=p.useCallback(()=>u(o.current.isFocused&&o.current.isFocusVisible),[]),g=p.useCallback(h=>{o.current.isFocused=h,o.current.isFocusVisible=Kg(),c(h),f()},[f]);bA(h=>{o.current.isFocusVisible=h,f()},[s,i],{enabled:i,isTextInput:s});let{focusProps:y}=yA({isDisabled:r,onFocusChange:g}),{focusWithinProps:v}=wA({isDisabled:!r,onFocusWithinChange:g});return{isFocused:i,isFocusVisible:d,focusProps:r?v:y}}var Cs=PN();let Vg=!1,Gu=0;function kA(){Vg=!0,setTimeout(()=>{Vg=!1},500)}function Nj(e){e.pointerType==="touch"&&kA()}function NA(){let e=Vs(null);if(!(typeof e>"u"))return Gu===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",Nj),Gu++,()=>{Gu--,!(Gu>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",Nj)}}function SA(e){let{onHoverStart:n,onHoverChange:s,onHoverEnd:r,isDisabled:o}=e,[i,c]=p.useState(!1),d=p.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;p.useEffect(NA,[]);let{addGlobalListener:u,removeAllGlobalListeners:f}=g1(),{hoverProps:g,triggerHoverEnd:y}=p.useMemo(()=>{let v=(b,j)=>{if(d.pointerType=j,o||j==="touch"||d.isHovered||!Oa(b.currentTarget,Zn(b)))return;d.isHovered=!0;let k=b.currentTarget;d.target=k,u(Vs(Zn(b)),"pointerover",E=>{d.isHovered&&d.target&&!Oa(d.target,Zn(E))&&h(E,E.pointerType)},{capture:!0}),n&&n({type:"hoverstart",target:k,pointerType:j}),s&&s(!0),c(!0)},h=(b,j)=>{let k=d.target;d.pointerType="",d.target=null,!(j==="touch"||!d.isHovered||!k)&&(d.isHovered=!1,f(),r&&r({type:"hoverend",target:k,pointerType:j}),s&&s(!1),c(!1))},x={};return typeof PointerEvent<"u"&&(x.onPointerEnter=b=>{Vg&&b.pointerType==="mouse"||v(b,b.pointerType)},x.onPointerLeave=b=>{!o&&Oa(b.currentTarget,Zn(b))&&h(b,b.pointerType)}),{hoverProps:x,triggerHoverEnd:h}},[n,s,r,o,d,u,f]);return p.useEffect(()=>{o&&y({currentTarget:d.target},d.pointerType)},[o]),{hoverProps:g,isHovered:i}}var CA=Object.defineProperty,EA=(e,n,s)=>n in e?CA(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Xp=(e,n,s)=>(EA(e,typeof n!="symbol"?n+"":n,s),s);let $A=class{constructor(){Xp(this,"current",this.detect()),Xp(this,"handoffState","pending"),Xp(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"}},$r=new $A;function Sl(e){var n;return $r.isServer?null:e==null?document:(n=e==null?void 0:e.ownerDocument)!=null?n:document}function Lf(e){var n,s;return $r.isServer?null:e==null?document:(s=(n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))!=null?s:document}function x1(e){var n,s;return(s=(n=Lf(e))==null?void 0:n.activeElement)!=null?s:null}function v1(e){return x1(e)===e}function Nm(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(n=>setTimeout(()=>{throw n}))}function Ts(){let e=[],n={addEventListener(s,r,o,i){return s.addEventListener(r,o,i),n.add(()=>s.removeEventListener(r,o,i))},requestAnimationFrame(...s){let r=requestAnimationFrame(...s);return n.add(()=>cancelAnimationFrame(r))},nextFrame(...s){return n.requestAnimationFrame(()=>n.requestAnimationFrame(...s))},setTimeout(...s){let r=setTimeout(...s);return n.add(()=>clearTimeout(r))},microTask(...s){let r={current:!0};return Nm(()=>{r.current&&s[0]()}),n.add(()=>{r.current=!1})},style(s,r,o){let i=s.style.getPropertyValue(r);return Object.assign(s.style,{[r]:o}),this.add(()=>{Object.assign(s.style,{[r]:i})})},group(s){let r=Ts();return s(r),this.add(()=>r.dispose())},add(s){return e.includes(s)||e.push(s),()=>{let r=e.indexOf(s);if(r>=0)for(let o of e.splice(r,1))o()}},dispose(){for(let s of e.splice(0))s()}};return n}function ea(){let[e]=p.useState(Ts);return p.useEffect(()=>()=>e.dispose(),[e]),e}let tn=(e,n)=>{$r.isServer?p.useEffect(e,n):p.useLayoutEffect(e,n)};function ta(e){let n=p.useRef(e);return tn(()=>{n.current=e},[e]),n}let dt=function(e){let n=ta(e);return Ke.useCallback((...s)=>n.current(...s),[n])};function _A(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 TA(e,n){return!(!e||!n||e.right<n.left||e.left>n.right||e.bottom<n.top||e.top>n.bottom)}function RA({disabled:e=!1}={}){let n=p.useRef(null),[s,r]=p.useState(!1),o=ea(),i=dt(()=>{n.current=null,r(!1),o.dispose()}),c=dt(d=>{if(o.dispose(),n.current===null){n.current=d.currentTarget,r(!0);{let u=Sl(d.currentTarget);o.addEventListener(u,"pointerup",i,!1),o.addEventListener(u,"pointermove",f=>{if(n.current){let g=_A(f);r(TA(g,n.current.getBoundingClientRect()))}},!1),o.addEventListener(u,"pointercancel",i,!1)}}});return{pressed:s,pressProps:e?{}:{onPointerDown:c,onPointerUp:i,onClick:i}}}function Ys(e){return p.useMemo(()=>e,Object.values(e))}let AA=p.createContext(void 0);function dv(){return p.useContext(AA)}function Yg(...e){return Array.from(new Set(e.flatMap(n=>typeof n=="string"?n.split(" "):[]))).filter(Boolean).join(" ")}function ss(e,n,...s){if(e in n){let o=n[e];return typeof o=="function"?o(...s):o}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(n).map(o=>`"${o}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,ss),r}var dl=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(dl||{}),zo=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(zo||{});function $n(){let e=LA();return p.useCallback(n=>OA({mergeRefs:e,...n}),[e])}function OA({ourProps:e,theirProps:n,slot:s,defaultTag:r,features:o,visible:i=!0,name:c,mergeRefs:d}){d=d??MA;let u=b1(n,e);if(i)return qu(u,s,r,c,d);let f=o??0;if(f&2){let{static:g=!1,...y}=u;if(g)return qu(y,s,r,c,d)}if(f&1){let{unmount:g=!0,...y}=u;return ss(g?0:1,{0(){return null},1(){return qu({...y,hidden:!0,style:{display:"none"}},s,r,c,d)}})}return qu(u,s,r,c,d)}function qu(e,n={},s,r,o){let{as:i=s,children:c,refName:d="ref",...u}=Zp(e,["unmount","static"]),f=e.ref!==void 0?{[d]:e.ref}:{},g=typeof c=="function"?c(n):c;g=w1(g),"className"in u&&u.className&&typeof u.className=="function"&&(u.className=u.className(n)),u["aria-labelledby"]&&u["aria-labelledby"]===u.id&&(u["aria-labelledby"]=void 0);let y={};if(n){let v=!1,h=[];for(let[x,b]of Object.entries(n))typeof b=="boolean"&&(v=!0),b===!0&&h.push(x.replace(/([A-Z])/g,j=>`-${j.toLowerCase()}`));if(v){y["data-headlessui-state"]=h.join(" ");for(let x of h)y[`data-${x}`]=""}}if(Pc(i)&&(Object.keys(Po(u)).length>0||Object.keys(Po(y)).length>0))if(!p.isValidElement(g)||Array.isArray(g)&&g.length>1||IA(g)){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(y))).map(v=>` - ${v}`).join(`
|
|
511
|
-
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(v=>` - ${v}`).join(`
|
|
512
|
-
`)].join(`
|
|
513
|
-
`))}else{let v=g.props,h=v==null?void 0:v.className,x=typeof h=="function"?(...k)=>Yg(h(...k),u.className):Yg(h,u.className),b=x?{className:x}:{},j=b1(g.props,Po(Zp(u,["ref"])));for(let k in y)k in j&&delete y[k];return p.cloneElement(g,Object.assign({},j,y,f,{ref:o(PA(g),f.ref)},b))}return p.createElement(i,Object.assign({},Zp(u,["ref"]),!Pc(i)&&f,!Pc(i)&&y),g)}function LA(){let e=p.useRef([]),n=p.useCallback(s=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(s):r.current=s)},[]);return(...s)=>{if(!s.every(r=>r==null))return e.current=s,n}}function MA(...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 b1(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},s={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(s[o]!=null||(s[o]=[]),s[o].push(r[o])):n[o]=r[o];if(n.disabled||n["aria-disabled"])for(let r in s)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(s[r]=[o=>{var i;return(i=o==null?void 0:o.preventDefault)==null?void 0:i.call(o)}]);for(let r in s)Object.assign(n,{[r](o,...i){let c=s[r];for(let d of c){if((o instanceof Event||(o==null?void 0:o.nativeEvent)instanceof Event)&&o.defaultPrevented)return;d(o,...i)}}});return n}function y1(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},s={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(s[o]!=null||(s[o]=[]),s[o].push(r[o])):n[o]=r[o];for(let r in s)Object.assign(n,{[r](...o){let i=s[r];for(let c of i)c==null||c(...o)}});return n}function vn(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 Zp(e,n=[]){let s=Object.assign({},e);for(let r of n)r in s&&delete s[r];return s}function PA(e){return Ke.version.split(".")[0]>="19"?e.props.ref:e.ref}function w1(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let n=e._payload;if(n!=null&&n.status==="fulfilled")return w1(n.value)}return e}function Pc(e){return e===p.Fragment||e===Symbol.for("react.fragment")}function IA(e){return Pc(e.type)}function zA(e,n,s){let[r,o]=p.useState(s),i=e!==void 0,c=p.useRef(i),d=p.useRef(!1),u=p.useRef(!1);return i&&!c.current&&!d.current?(d.current=!0,c.current=i,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!i&&c.current&&!u.current&&(u.current=!0,c.current=i,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[i?e:r,dt(f=>(i||Cs.flushSync(()=>o(f)),n==null?void 0:n(f)))]}function DA(e){let[n]=p.useState(e);return n}function j1(e={},n=null,s=[]){for(let[r,o]of Object.entries(e))N1(s,k1(n,r),o);return s}function k1(e,n){return e?e+"["+n+"]":n}function N1(e,n,s){if(Array.isArray(s))for(let[r,o]of s.entries())N1(e,k1(n,r.toString()),o);else s instanceof Date?e.push([n,s.toISOString()]):typeof s=="boolean"?e.push([n,s?"1":"0"]):typeof s=="string"?e.push([n,s]):typeof s=="number"?e.push([n,`${s}`]):s==null?e.push([n,""]):UA(s)&&!p.isValidElement(s)&&j1(s,n,e)}function FA(e){var n,s;let r=(n=e==null?void 0:e.form)!=null?n:e.closest("form");if(r){for(let o of r.elements)if(o!==e&&(o.tagName==="INPUT"&&o.type==="submit"||o.tagName==="BUTTON"&&o.type==="submit"||o.nodeName==="INPUT"&&o.type==="image")){o.click();return}(s=r.requestSubmit)==null||s.call(r)}}function UA(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}let WA="span";var ul=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(ul||{});function HA(e,n){var s;let{features:r=1,...o}=e,i={ref:n,"aria-hidden":(r&2)===2?!0:(s=o["aria-hidden"])!=null?s:void 0,hidden:(r&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(r&4)===4&&(r&2)!==2&&{display:"none"}}};return $n()({ourProps:i,theirProps:o,slot:{},defaultTag:WA,name:"Hidden"})}let Gc=vn(HA),BA=p.createContext(null);function GA({children:e}){let n=p.useContext(BA);if(!n)return Ke.createElement(Ke.Fragment,null,e);let{target:s}=n;return s?Cs.createPortal(Ke.createElement(Ke.Fragment,null,e),s):null}function qA({data:e,form:n,disabled:s,onReset:r,overrides:o}){let[i,c]=p.useState(null),d=ea();return p.useEffect(()=>{if(r&&i)return d.addEventListener(i,"reset",r)},[i,n,r]),Ke.createElement(GA,null,Ke.createElement(KA,{setForm:c,formId:n}),j1(e).map(([u,f])=>Ke.createElement(Gc,{features:ul.Hidden,...Po({key:u,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:n,disabled:s,name:u,value:f,...o})})))}function KA({setForm:e,formId:n}){return p.useEffect(()=>{if(n){let s=document.getElementById(n);s&&e(s)}},[e,n]),n?null:Ke.createElement(Gc,{features:ul.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let r=s.closest("form");r&&e(r)}})}let VA=p.createContext(void 0);function S1(){return p.useContext(VA)}function C1(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function eo(e){return C1(e)&&"tagName"in e}function Es(e){return eo(e)&&"accessKey"in e}function Jr(e){return eo(e)&&"tabIndex"in e}function YA(e){return eo(e)&&"style"in e}function QA(e){return Es(e)&&e.nodeName==="IFRAME"}function E1(e){return Es(e)&&e.nodeName==="INPUT"}function Sj(e){return Es(e)&&e.nodeName==="LABEL"}function JA(e){return Es(e)&&e.nodeName==="FIELDSET"}function $1(e){return Es(e)&&e.nodeName==="LEGEND"}function XA(e){return eo(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function Cj(e){let n=e.parentElement,s=null;for(;n&&!JA(n);)$1(n)&&(s=n),n=n.parentElement;let r=(n==null?void 0:n.getAttribute("disabled"))==="";return r&&ZA(s)?!1:r}function ZA(e){if(!e)return!1;let n=e.previousElementSibling;for(;n!==null;){if($1(n))return!1;n=n.previousElementSibling}return!0}let _1=Symbol();function e3(e,n=!0){return Object.assign(e,{[_1]:n})}function Wn(...e){let n=p.useRef(e);p.useEffect(()=>{n.current=e},[e]);let s=dt(r=>{for(let o of n.current)o!=null&&(typeof o=="function"?o(r):o.current=r)});return e.every(r=>r==null||(r==null?void 0:r[_1]))?void 0:s}let Sm=p.createContext(null);Sm.displayName="DescriptionContext";function T1(){let e=p.useContext(Sm);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,T1),n}return e}function t3(){var e,n;return(n=(e=p.useContext(Sm))==null?void 0:e.value)!=null?n:void 0}function n3(){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}))),o=p.useMemo(()=>({register:r,slot:s.slot,name:s.name,props:s.props,value:s.value}),[r,s.slot,s.name,s.props,s.value]);return Ke.createElement(Sm.Provider,{value:o},s.children)},[n])]}let s3="p";function r3(e,n){let s=p.useId(),r=dv(),{id:o=`headlessui-description-${s}`,...i}=e,c=T1(),d=Wn(n);tn(()=>c.register(o),[o,c.register]);let u=Ys({...c.slot,disabled:r||!1}),f={ref:d,...c.props,id:o};return $n()({ourProps:f,theirProps:i,slot:u,defaultTag:s3,name:c.name||"Description"})}let o3=vn(r3),R1=Object.assign(o3,{});var wn=(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))(wn||{});let Cm=p.createContext(null);Cm.displayName="LabelContext";function A1(){let e=p.useContext(Cm);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,A1),n}return e}function O1(e){var n,s,r;let o=(s=(n=p.useContext(Cm))==null?void 0:n.value)!=null?s:void 0;return((r=e==null?void 0:e.length)!=null?r:0)>0?[o,...e].filter(Boolean).join(" "):o}function a3({inherit:e=!1}={}){let n=O1(),[s,r]=p.useState([]),o=e?[n,...s].filter(Boolean):s;return[o.length>0?o.join(" "):void 0,p.useMemo(()=>function(i){let c=dt(u=>(r(f=>[...f,u]),()=>r(f=>{let g=f.slice(),y=g.indexOf(u);return y!==-1&&g.splice(y,1),g}))),d=p.useMemo(()=>({register:c,slot:i.slot,name:i.name,props:i.props,value:i.value}),[c,i.slot,i.name,i.props,i.value]);return Ke.createElement(Cm.Provider,{value:d},i.children)},[r])]}let i3="label";function l3(e,n){var s;let r=p.useId(),o=A1(),i=S1(),c=dv(),{id:d=`headlessui-label-${r}`,htmlFor:u=i??((s=o.props)==null?void 0:s.htmlFor),passive:f=!1,...g}=e,y=Wn(n);tn(()=>o.register(d),[d,o.register]);let v=dt(b=>{let j=b.currentTarget;if(!(b.target!==b.currentTarget&&XA(b.target))&&(Sj(j)&&b.preventDefault(),o.props&&"onClick"in o.props&&typeof o.props.onClick=="function"&&o.props.onClick(b),Sj(j))){let k=document.getElementById(j.htmlFor);if(k){let E=k.getAttribute("disabled");if(E==="true"||E==="")return;let S=k.getAttribute("aria-disabled");if(S==="true"||S==="")return;(E1(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=Ys({...o.slot,disabled:c||!1}),x={ref:y,...o.props,id:d,htmlFor:u,onClick:v};return f&&("onClick"in x&&(delete x.htmlFor,delete x.onClick),"onClick"in g&&delete g.onClick),$n()({ourProps:x,theirProps:g,slot:h,defaultTag:u?i3:"div",name:o.name||"Label"})}let c3=vn(l3),d3=Object.assign(c3,{}),u3=p.createContext(()=>{});function f3({value:e,children:n}){return Ke.createElement(u3.Provider,{value:e},n)}function m3(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 h3(e=m3){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 Ej(e){if(e===null)return{width:0,height:0};let{width:n,height:s}=e.getBoundingClientRect();return{width:n,height:s}}function p3(e,n,s=!1){let[r,o]=p.useState(()=>Ej(n));return tn(()=>{if(!n||!e)return;let i=Ts();return i.requestAnimationFrame(function c(){i.requestAnimationFrame(c),o(d=>{let u=Ej(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 L1=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(L1||{});function g3(e){let n=p.useRef(null),s=dt(o=>{n.current=o.pointerType,!Cj(o.currentTarget)&&o.pointerType==="mouse"&&o.button===L1.Left&&(o.preventDefault(),e(o))}),r=dt(o=>{n.current!=="mouse"&&(Cj(o.currentTarget)||e(o))});return{onPointerDown:s,onClick:r}}let M1=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 x3=Object.defineProperty,v3=(e,n,s)=>n in e?x3(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,b3=(e,n,s)=>(v3(e,n+"",s),s),P1=(e,n,s)=>{if(!n.has(e))throw TypeError("Cannot "+s)},Fs=(e,n,s)=>(P1(e,n,"read from private field"),s?s.call(e):n.get(e)),eg=(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)},$j=(e,n,s,r)=>(P1(e,n,"write to private field"),n.set(e,s),s),Nr,Tc,Rc;let I1=class{constructor(n){eg(this,Nr,{}),eg(this,Tc,new M1(()=>new Set)),eg(this,Rc,new Set),b3(this,"disposables",Ts()),$j(this,Nr,n),$r.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return Fs(this,Nr)}subscribe(n,s){if($r.isServer)return()=>{};let r={selector:n,callback:s,current:n(Fs(this,Nr))};return Fs(this,Rc).add(r),this.disposables.add(()=>{Fs(this,Rc).delete(r)})}on(n,s){return $r.isServer?()=>{}:(Fs(this,Tc).get(n).add(s),this.disposables.add(()=>{Fs(this,Tc).get(n).delete(s)}))}send(n){let s=this.reduce(Fs(this,Nr),n);if(s!==Fs(this,Nr)){$j(this,Nr,s);for(let r of Fs(this,Rc)){let o=r.selector(Fs(this,Nr));z1(r.current,o)||(r.current=o,r.callback(o))}for(let r of Fs(this,Tc).get(n.type))r(Fs(this,Nr),n)}}};Nr=new WeakMap,Tc=new WeakMap,Rc=new WeakMap;function z1(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:tg(e[Symbol.iterator](),n[Symbol.iterator]()):e instanceof Map&&n instanceof Map||e instanceof Set&&n instanceof Set?e.size!==n.size?!1:tg(e.entries(),n.entries()):_j(e)&&_j(n)?tg(Object.entries(e)[Symbol.iterator](),Object.entries(n)[Symbol.iterator]()):!1}function tg(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 _j(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}function ng(e){let[n,s]=e(),r=Ts();return(...o)=>{n(...o),r.dispose(),r.microTask(s)}}var y3=Object.defineProperty,w3=(e,n,s)=>n in e?y3(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Tj=(e,n,s)=>(w3(e,typeof n!="symbol"?n+"":n,s),s),D1=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(D1||{});let j3={0(e,n){let s=n.id,r=e.stack,o=e.stack.indexOf(s);if(o!==-1){let i=e.stack.slice();return i.splice(o,1),i.push(s),r=i,{...e,stack:r}}return{...e,stack:[...e.stack,s]}},1(e,n){let s=n.id,r=e.stack.indexOf(s);if(r===-1)return e;let o=e.stack.slice();return o.splice(r,1),{...e,stack:o}}},k3=class F1 extends I1{constructor(){super(...arguments),Tj(this,"actions",{push:n=>this.send({type:0,id:n}),pop:n=>this.send({type:1,id:n})}),Tj(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 ss(s.type,j3,n,s)}};const Em=new M1(()=>k3.new());var sg={exports:{}},rg={};/**
|
|
514
|
-
* @license React
|
|
515
|
-
* use-sync-external-store-with-selector.production.js
|
|
516
|
-
*
|
|
517
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
518
|
-
*
|
|
519
|
-
* This source code is licensed under the MIT license found in the
|
|
520
|
-
* LICENSE file in the root directory of this source tree.
|
|
521
|
-
*/var Rj;function N3(){if(Rj)return rg;Rj=1;var e=pm();function n(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var s=typeof Object.is=="function"?Object.is:n,r=e.useSyncExternalStore,o=e.useRef,i=e.useEffect,c=e.useMemo,d=e.useDebugValue;return rg.useSyncExternalStoreWithSelector=function(u,f,g,y,v){var h=o(null);if(h.current===null){var x={hasValue:!1,value:null};h.current=x}else x=h.current;h=c(function(){function j($){if(!k){if(k=!0,E=$,$=y($),v!==void 0&&x.hasValue){var _=x.value;if(v(_,$))return S=_}return S=$}if(_=S,s(E,$))return _;var O=y($);return v!==void 0&&v(_,O)?(E=$,_):(E=$,S=O)}var k=!1,E,S,N=g===void 0?null:g;return[function(){return j(f())},N===null?void 0:function(){return j(N())}]},[f,g,y,v]);var b=r(u,h[0],h[1]);return i(function(){x.hasValue=!0,x.value=b},[b]),d(b),b},rg}var Aj;function S3(){return Aj||(Aj=1,sg.exports=N3()),sg.exports}var C3=S3();function Xn(e,n,s=z1){return C3.useSyncExternalStoreWithSelector(dt(r=>e.subscribe(E3,r)),dt(()=>e.state),dt(()=>e.state),dt(n),s)}function E3(e){return e}function ud(e,n){let s=p.useId(),r=Em.get(n),[o,i]=Xn(r,p.useCallback(c=>[r.selectors.isTop(c,s),r.selectors.inStack(c,s)],[r,s]));return tn(()=>{if(e)return r.actions.push(s),()=>r.actions.pop(s)},[r,e,s]),e?i?o:!0:!1}let Qg=new Map,Ic=new Map;function Oj(e){var n;let s=(n=Ic.get(e))!=null?n:0;return Ic.set(e,s+1),s!==0?()=>Lj(e):(Qg.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Lj(e))}function Lj(e){var n;let s=(n=Ic.get(e))!=null?n:1;if(s===1?Ic.delete(e):Ic.set(e,s-1),s!==1)return;let r=Qg.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,Qg.delete(e))}function U1(e,{allowed:n,disallowed:s}={}){let r=ud(e,"inert-others");tn(()=>{var o,i;if(!r)return;let c=Ts();for(let u of(o=s==null?void 0:s())!=null?o:[])u&&c.add(Oj(u));let d=(i=n==null?void 0:n())!=null?i:[];for(let u of d){if(!u)continue;let f=Sl(u);if(!f)continue;let g=u.parentElement;for(;g&&g!==f.body;){for(let y of g.children)d.some(v=>y.contains(v))||c.add(Oj(y));g=g.parentElement}}return c.dispose},[r,n,s])}function W1(e,n,s){let r=ta(o=>{let i=o.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&s()});p.useEffect(()=>{if(!e)return;let o=n===null?null:Es(n)?n:n.current;if(!o)return;let i=Ts();if(typeof ResizeObserver<"u"){let c=new ResizeObserver(()=>r.current(o));c.observe(o),i.add(()=>c.disconnect())}if(typeof IntersectionObserver<"u"){let c=new IntersectionObserver(()=>r.current(o));c.observe(o),i.add(()=>c.disconnect())}return()=>i.dispose()},[n,r,e])}let Mf=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","details>summary","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),$3=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var dr=(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))(dr||{}),Jg=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(Jg||{}),_3=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(_3||{});function H1(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(Mf)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}function T3(e=document.body){return e==null?[]:Array.from(e.querySelectorAll($3)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}var uv=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(uv||{});function B1(e,n=0){var s;return e===((s=Sl(e))==null?void 0:s.body)?!1:ss(n,{0(){return e.matches(Mf)},1(){let r=e;for(;r!==null;){if(r.matches(Mf))return!0;r=r.parentElement}return!1}})}var R3=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(R3||{});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 to(e){e==null||e.focus({preventScroll:!0})}let A3=["textarea","input"].join(",");function O3(e){var n,s;return(s=(n=e==null?void 0:e.matches)==null?void 0:n.call(e,A3))!=null?s:!1}function G1(e,n=s=>s){return e.slice().sort((s,r)=>{let o=n(s),i=n(r);if(o===null||i===null)return 0;let c=o.compareDocumentPosition(i);return c&Node.DOCUMENT_POSITION_FOLLOWING?-1:c&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function L3(e,n,s=e===null?document.body:Lf(e)){return Ji(H1(s),n,{relativeTo:e})}function Ji(e,n,{sorted:s=!0,relativeTo:r=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?Lf(e[0]):document:Lf(e),c=Array.isArray(e)?s?G1(e):e:n&64?T3(e):H1(e);o.length>0&&c.length>1&&(c=c.filter(h=>!o.some(x=>x!=null&&"current"in x?(x==null?void 0:x.current)===h:x===h))),r=r??(i==null?void 0:i.activeElement);let d=(()=>{if(n&5)return 1;if(n&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),u=(()=>{if(n&1)return 0;if(n&2)return Math.max(0,c.indexOf(r))-1;if(n&4)return Math.max(0,c.indexOf(r))+1;if(n&8)return c.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),f=n&32?{preventScroll:!0}:{},g=0,y=c.length,v;do{if(g>=y||g+y<=0)return 0;let h=u+g;if(n&16)h=(h+y)%y;else{if(h<0)return 3;if(h>=y)return 1}v=c[h],v==null||v.focus(f),g+=d}while(v!==x1(v));return n&6&&O3(v)&&v.select(),2}function q1(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function M3(){return/Android/gi.test(window.navigator.userAgent)}function Mj(){return q1()||M3()}function Bi(e,n,s,r){let o=ta(s);p.useEffect(()=>{if(!e)return;function i(c){o.current(c)}return document.addEventListener(n,i,r),()=>document.removeEventListener(n,i,r)},[e,n,r])}function K1(e,n,s,r){let o=ta(s);p.useEffect(()=>{if(!e)return;function i(c){o.current(c)}return window.addEventListener(n,i,r),()=>window.removeEventListener(n,i,r)},[e,n,r])}const Pj=30;function V1(e,n,s){let r=ta(s),o=p.useCallback(function(d,u){if(d.defaultPrevented)return;let f=u(d);if(f===null||!f.getRootNode().contains(f)||!f.isConnected)return;let g=(function y(v){return typeof v=="function"?y(v()):Array.isArray(v)||v instanceof Set?v:[v]})(n);for(let y of g)if(y!==null&&(y.contains(f)||d.composed&&d.composedPath().includes(y)))return;return!B1(f,uv.Loose)&&f.tabIndex!==-1&&d.preventDefault(),r.current(d,f)},[r,n]),i=p.useRef(null);Bi(e,"pointerdown",d=>{var u,f;Mj()||(i.current=((f=(u=d.composedPath)==null?void 0:u.call(d))==null?void 0:f[0])||d.target)},!0),Bi(e,"pointerup",d=>{if(Mj()||!i.current)return;let u=i.current;return i.current=null,o(d,()=>u)},!0);let c=p.useRef({x:0,y:0});Bi(e,"touchstart",d=>{c.current.x=d.touches[0].clientX,c.current.y=d.touches[0].clientY},!0),Bi(e,"touchend",d=>{let u={x:d.changedTouches[0].clientX,y:d.changedTouches[0].clientY};if(!(Math.abs(u.x-c.current.x)>=Pj||Math.abs(u.y-c.current.y)>=Pj))return o(d,()=>Jr(d.target)?d.target:null)},!0),K1(e,"blur",d=>o(d,()=>QA(window.document.activeElement)?window.document.activeElement:null),!0)}function qc(...e){return p.useMemo(()=>Sl(...e),[...e])}var P3=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(P3||{});const Ku={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},I3=200,Ij=5;function z3(e,{trigger:n,action:s,close:r,select:o}){let i=p.useRef(null),c=p.useRef(null),d=p.useRef(null);Bi(e&&n!==null,"pointerdown",u=>{C1(u==null?void 0:u.target)&&n!=null&&n.contains(u.target)&&(c.current=u.x,d.current=u.y,i.current=u.timeStamp)}),Bi(e&&n!==null,"pointerup",u=>{var f,g;let y=i.current;if(y===null||(i.current=null,!Jr(u.target))||Math.abs(u.x-((f=c.current)!=null?f:u.x))<Ij&&Math.abs(u.y-((g=d.current)!=null?g:u.y))<Ij)return;let v=s(u);switch(v.kind){case 0:return;case 1:{u.timeStamp-y>I3&&(o(v.target),r());break}case 2:{r();break}}},{capture:!0})}function Y1(e,n,s,r){let o=ta(s);p.useEffect(()=>{e=e??window;function i(c){o.current(c)}return e.addEventListener(n,i,r),()=>e.removeEventListener(n,i,r)},[e,n,r])}function D3(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 F3(e){return p.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function U3(e,n){let s=e(),r=new Set;return{getSnapshot(){return s},subscribe(o){return r.add(o),()=>r.delete(o)},dispatch(o,...i){let c=n[o].call(s,...i);c&&(s=c,r.forEach(d=>d()))}}}function W3(){let e;return{before({doc:n}){var s;let r=n.documentElement,o=(s=n.defaultView)!=null?s:window;e=Math.max(0,o.innerWidth-r.clientWidth)},after({doc:n,d:s}){let r=n.documentElement,o=Math.max(0,r.clientWidth-r.offsetWidth),i=Math.max(0,e-o);s.style(r,"paddingRight",`${i}px`)}}}function H3(){return q1()?{before({doc:e,d:n,meta:s}){function r(o){for(let i of s().containers)for(let c of i())if(c.contains(o))return!0;return!1}n.microTask(()=>{var o;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let d=Ts();d.style(e.documentElement,"scrollBehavior","auto"),n.add(()=>n.microTask(()=>d.dispose()))}let i=(o=window.scrollY)!=null?o:window.pageYOffset,c=null;n.addEventListener(e,"click",d=>{if(Jr(d.target))try{let u=d.target.closest("a");if(!u)return;let{hash:f}=new URL(u.href),g=e.querySelector(f);Jr(g)&&!r(g)&&(c=g)}catch{}},!0),n.group(d=>{n.addEventListener(e,"touchstart",u=>{if(d.dispose(),Jr(u.target)&&YA(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(Jr(d.target)){if(E1(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 B3(){return{before({doc:e,d:n}){n.style(e.documentElement,"overflow","hidden")}}}function zj(e){let n={};for(let s of e)Object.assign(n,s(n));return n}let La=U3(()=>new Map,{PUSH(e,n){var s;let r=(s=this.get(e))!=null?s:{doc:e,count:0,d:Ts(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(n),r.computedMeta=zj(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=zj(s.meta)),this},SCROLL_PREVENT(e){let n={doc:e.doc,d:e.d,meta(){return e.computedMeta}},s=[H3(),W3(),B3()];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)}});La.subscribe(()=>{let e=La.getSnapshot(),n=new Map;for(let[s]of e)n.set(s,s.documentElement.style.overflow);for(let s of e.values()){let r=n.get(s.doc)==="hidden",o=s.count!==0;(o&&!r||!o&&r)&&La.dispatch(s.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",s),s.count===0&&La.dispatch("TEARDOWN",s)}});function G3(e,n,s=()=>({containers:[]})){let r=F3(La),o=n?r.get(n):void 0,i=o?o.count>0:!1;return tn(()=>{if(!(!n||!e))return La.dispatch("PUSH",n,s),()=>La.dispatch("POP",n,s)},[e,n]),i}function Q1(e,n,s=()=>[document.body]){let r=ud(e,"scroll-lock");G3(r,n,o=>{var i;return{containers:[...(i=o.containers)!=null?i:[],s]}})}function Dj(e){return[e.screenX,e.screenY]}function q3(){let e=p.useRef([-1,-1]);return{wasMoved(n){let s=Dj(n);return e.current[0]===s[0]&&e.current[1]===s[1]?!1:(e.current=s,!0)},update(n){e.current=Dj(n)}}}function K3(e=0){let[n,s]=p.useState(e),r=p.useCallback(u=>s(u),[]),o=p.useCallback(u=>s(f=>f|u),[]),i=p.useCallback(u=>(n&u)===u,[n]),c=p.useCallback(u=>s(f=>f&~u),[]),d=p.useCallback(u=>s(f=>f^u),[]);return{flags:n,setFlag:r,addFlag:o,hasFlag:i,removeFlag:c,toggleFlag:d}}var V3={},Fj,Uj;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Fj=process==null?void 0:V3)==null?void 0:Fj.NODE_ENV)==="test"&&typeof((Uj=Element==null?void 0:Element.prototype)==null?void 0:Uj.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(`
|
|
522
|
-
`)),[]});var Y3=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(Y3||{});function J1(e){let n={};for(let s in e)e[s]===!0&&(n[`data-${s}`]="");return n}function X1(e,n,s,r){let[o,i]=p.useState(s),{hasFlag:c,addFlag:d,removeFlag:u}=K3(e&&o?3:0),f=p.useRef(!1),g=p.useRef(!1),y=ea();return tn(()=>{var v;if(e){if(s&&i(!0),!n){s&&d(3);return}return(v=r==null?void 0:r.start)==null||v.call(r,s),Q3(n,{inFlight:f,prepare(){g.current?g.current=!1:g.current=f.current,f.current=!0,!g.current&&(s?(d(3),u(4)):(d(4),u(2)))},run(){g.current?s?(u(3),d(4)):(u(4),d(3)):s?u(1):d(1)},done(){var h;g.current&&Z3(n)||(f.current=!1,u(7),s||i(!1),(h=r==null?void 0:r.end)==null||h.call(r,s))}})}},[e,s,n,y]),e?[o,{closed:c(1),enter:c(2),leave:c(4),transition:c(2)||c(4)}]:[s,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function Q3(e,{prepare:n,run:s,done:r,inFlight:o}){let i=Ts();return X3(e,{prepare:n,inFlight:o}),i.nextFrame(()=>{s(),i.requestAnimationFrame(()=>{i.add(J3(e,r))})}),i.dispose}function J3(e,n){var s,r;let o=Ts();if(!e)return o.dispose;let i=!1;o.add(()=>{i=!0});let c=(r=(s=e.getAnimations)==null?void 0:s.call(e).filter(d=>d instanceof CSSTransition))!=null?r:[];return c.length===0?(n(),o.dispose):(Promise.allSettled(c.map(d=>d.finished)).then(()=>{i||n()}),o.dispose)}function X3(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 Z3(e){var n,s;return((s=(n=e.getAnimations)==null?void 0:n.call(e))!=null?s:[]).some(r=>r instanceof CSSTransition&&r.playState!=="finished")}function fv(e,n){let s=p.useRef([]),r=dt(e);p.useEffect(()=>{let o=[...s.current];for(let[i,c]of n.entries())if(s.current[i]!==c){let d=r(n,o);return s.current=n,d}},[r,...n])}function $m(){return typeof window<"u"}function Cl(e){return Z1(e)?(e.nodeName||"").toLowerCase():"#document"}function ps(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function lo(e){var n;return(n=(Z1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function Z1(e){return $m()?e instanceof Node||e instanceof ps(e).Node:!1}function hs(e){return $m()?e instanceof Element||e instanceof ps(e).Element:!1}function na(e){return $m()?e instanceof HTMLElement||e instanceof ps(e).HTMLElement:!1}function Wj(e){return!$m()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ps(e).ShadowRoot}function _m(e){const{overflow:n,overflowX:s,overflowY:r,display:o}=Rr(e);return/auto|scroll|overlay|hidden|clip/.test(n+r+s)&&o!=="inline"&&o!=="contents"}function e4(e){return/^(table|td|th)$/.test(Cl(e))}function Tm(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const t4=/transform|translate|scale|rotate|perspective|filter/,n4=/paint|layout|strict|content/,Na=e=>!!e&&e!=="none";let og;function mv(e){const n=hs(e)?Rr(e):e;return Na(n.transform)||Na(n.translate)||Na(n.scale)||Na(n.rotate)||Na(n.perspective)||!hv()&&(Na(n.backdropFilter)||Na(n.filter))||t4.test(n.willChange||"")||n4.test(n.contain||"")}function s4(e){let n=Ua(e);for(;na(n)&&!Kc(n);){if(mv(n))return n;if(Tm(n))return null;n=Ua(n)}return null}function hv(){return og==null&&(og=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),og}function Kc(e){return/^(html|body|#document)$/.test(Cl(e))}function Rr(e){return ps(e).getComputedStyle(e)}function Rm(e){return hs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ua(e){if(Cl(e)==="html")return e;const n=e.assignedSlot||e.parentNode||Wj(e)&&e.host||lo(e);return Wj(n)?n.host:n}function eS(e){const n=Ua(e);return Kc(n)?(e.ownerDocument||e).body:na(n)&&_m(n)?n:eS(n)}function Vc(e,n,s){var r;n===void 0&&(n=[]),s===void 0&&(s=!0);const o=eS(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),c=ps(o);if(i){const d=Xg(c);return n.concat(c,c.visualViewport||[],_m(o)?o:[],d&&s?Vc(d):[])}else return n.concat(o,Vc(o,[],s))}function Xg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function r4(){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 Wa=Math.min,Gs=Math.max,Yc=Math.round,Vu=Math.floor,no=e=>({x:e,y:e}),o4={left:"right",right:"left",bottom:"top",top:"bottom"};function a4(e,n,s){return Gs(e,Wa(n,s))}function El(e,n){return typeof e=="function"?e(n):e}function Ha(e){return e.split("-")[0]}function fd(e){return e.split("-")[1]}function tS(e){return e==="x"?"y":"x"}function nS(e){return e==="y"?"height":"width"}function Xr(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function sS(e){return tS(Xr(e))}function i4(e,n,s){s===void 0&&(s=!1);const r=fd(e),o=sS(e),i=nS(o);let c=o==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[i]>n.floating[i]&&(c=Pf(c)),[c,Pf(c)]}function l4(e){const n=Pf(e);return[Zg(e),n,Zg(n)]}function Zg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Hj=["left","right"],Bj=["right","left"],c4=["top","bottom"],d4=["bottom","top"];function u4(e,n,s){switch(e){case"top":case"bottom":return s?n?Bj:Hj:n?Hj:Bj;case"left":case"right":return n?c4:d4;default:return[]}}function f4(e,n,s,r){const o=fd(e);let i=u4(Ha(e),s==="start",r);return o&&(i=i.map(c=>c+"-"+o),n&&(i=i.concat(i.map(Zg)))),i}function Pf(e){const n=Ha(e);return o4[n]+e.slice(n.length)}function m4(e){var n,s,r,o;return{top:(n=e.top)!=null?n:0,right:(s=e.right)!=null?s:0,bottom:(r=e.bottom)!=null?r:0,left:(o=e.left)!=null?o:0}}function h4(e){return typeof e!="number"?m4(e):{top:e,right:e,bottom:e,left:e}}function If(e){const{x:n,y:s,width:r,height:o}=e;return{width:r,height:o,top:s,left:n,right:n+r,bottom:s+o,x:n,y:s}}function Gj(e,n,s){let{reference:r,floating:o}=e;const i=Xr(n),c=sS(n),d=nS(c),u=Ha(n),f=i==="y",g=r.x+r.width/2-o.width/2,y=r.y+r.height/2-o.height/2,v=r[d]/2-o[d]/2;let h;switch(u){case"top":h={x:g,y:r.y-o.height};break;case"bottom":h={x:g,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y};break;case"left":h={x:r.x-o.width,y};break;default:h={x:r.x,y:r.y}}const x=fd(n);return x&&(h[c]+=v*(x==="end"?1:-1)*(s&&f?-1:1)),h}async function rS(e,n){var s;n===void 0&&(n={});const{x:r,y:o,platform:i,rects:c,elements:d,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:v=!1,padding:h=0}=El(n,e),x=h4(h),j=d[v?y==="floating"?"reference":"floating":y],k=If(await i.getClippingRect({element:(s=await(i.isElement==null?void 0:i.isElement(j)))==null||s?j:j.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(d.floating)),boundary:f,rootBoundary:g,strategy:u})),E=y==="floating"?{x:r,y:o,width:c.floating.width,height:c.floating.height}:c.reference,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},$=If(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:E,offsetParent:S,strategy:u}):E);return{top:(k.top-$.top+x.top)/N.y,bottom:($.bottom-k.bottom+x.bottom)/N.y,left:(k.left-$.left+x.left)/N.x,right:($.right-k.right+x.right)/N.x}}const p4=50,g4=async(e,n,s)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:c}=s,d=c.detectOverflow?c:{...c,detectOverflow:rS},u=await(c.isRTL==null?void 0:c.isRTL(n));let f=await c.getElementRects({reference:e,floating:n,strategy:o}),{x:g,y}=Gj(f,r,u),v=r,h=0;const x={};for(let b=0;b<i.length;b++){const j=i[b];if(!j)continue;const{name:k,fn:E}=j,{x:S,y:N,data:$,reset:_}=await E({x:g,y,initialPlacement:r,placement:v,strategy:o,middlewareData:x,rects:f,platform:d,elements:{reference:e,floating:n}});g=S??g,y=N??y,x[k]={...x[k],...$},_&&h<p4&&(h++,typeof _=="object"&&(_.placement&&(v=_.placement),_.rects&&(f=_.rects===!0?await c.getElementRects({reference:e,floating:n,strategy:o}):_.rects),{x:g,y}=Gj(f,v,u)),b=-1)}return{x:g,y,placement:v,strategy:o,middlewareData:x}},x4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,r;const{placement:o,middlewareData:i,rects:c,initialPlacement:d,platform:u,elements:f}=n,{mainAxis:g=!0,crossAxis:y=!0,fallbackPlacements:v,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:b=!0,...j}=El(e,n);if((s=i.arrow)!=null&&s.alignmentOffset)return{};const k=Ha(o),E=Xr(d),S=Ha(d)===d,N=await(u.isRTL==null?void 0:u.isRTL(f.floating)),$=v||(S||!b?[Pf(d)]:l4(d)),_=x!=="none";!v&&_&&$.push(...f4(d,b,x,N));const O=[d,...$],L=await u.detectOverflow(n,j),P=[];let R=((r=i.flip)==null?void 0:r.overflows)||[];if(g&&P.push(L[k]),y){const I=i4(o,c,N);P.push(L[I[0]],L[I[1]])}if(R=[...R,{placement:o,overflows:P}],!P.every(I=>I<=0)){var A,M;const I=(((A=i.flip)==null?void 0:A.index)||0)+1,q=O[I];if(q&&(!(y==="alignment"?E!==Xr(q):!1)||R.every(U=>Xr(U.placement)===E?U.overflows[0]>0:!0)))return{data:{index:I,overflows:R},reset:{placement:q}};let W=(M=R.filter(K=>K.overflows[0]<=0).sort((K,U)=>K.overflows[1]-U.overflows[1])[0])==null?void 0:M.placement;if(!W)switch(h){case"bestFit":{var F;const K=(F=R.filter(U=>{if(_){const H=Xr(U.placement);return H===E||H==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(H=>H>0).reduce((H,G)=>H+G,0)]).sort((U,H)=>U[1]-H[1])[0])==null?void 0:F[0];K&&(W=K);break}case"initialPlacement":W=d;break}if(o!==W)return{reset:{placement:W}}}return{}}}},v4=new Set(["left","top"]);async function b4(e,n){const{placement:s,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),c=Ha(s),d=fd(s),u=Xr(s)==="y",f=v4.has(c)?-1:1,g=i&&u?-1:1,y=El(n,e);let{mainAxis:v,crossAxis:h,alignmentAxis:x}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return d&&typeof x=="number"&&(h=d==="end"?x*-1:x),u?{x:h*g,y:v*f}:{x:v*f,y:h*g}}const y4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var s,r;const{x:o,y:i,placement:c,middlewareData:d}=n,u=await b4(n,e);return c===((s=d.offset)==null?void 0:s.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:c}}}}},w4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:s,y:r,placement:o,platform:i}=n,{mainAxis:c=!0,crossAxis:d=!1,limiter:u={fn:E=>{let{x:S,y:N}=E;return{x:S,y:N}}},...f}=El(e,n),g={x:s,y:r},y=await i.detectOverflow(n,f),v=Xr(o),h=tS(v);let x=g[h],b=g[v];const j=(E,S)=>a4(S+y[E==="y"?"top":"left"],S,S-y[E==="y"?"bottom":"right"]);c&&(x=j(h,x)),d&&(b=j(v,b));const k=u.fn({...n,[h]:x,[v]:b});return{...k,data:{x:k.x-s,y:k.y-r,enabled:{[h]:c,[v]:d}}}}}},j4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){const{placement:s,rects:r,platform:o,elements:i}=n,{apply:c=()=>{},...d}=El(e,n),u=await o.detectOverflow(n,d),f=Ha(s),g=fd(s),y=Xr(s)==="y",{width:v,height:h}=r.floating;let x,b;f==="top"||f==="bottom"?(x=f,b=g===(await(o.isRTL==null?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(b=f,x=g==="end"?"top":"bottom");const j=h-u.top-u.bottom,k=v-u.left-u.right,E=Wa(h-u[x],j),S=Wa(v-u[b],k),N=n.middlewareData.shift,$=!N;let _=E,O=S;N!=null&&N.enabled.x&&(O=k),N!=null&&N.enabled.y&&(_=j),$&&!g&&(y?O=v-2*Gs(u.left,u.right):_=h-2*Gs(u.top,u.bottom)),await c({...n,availableWidth:O,availableHeight:_});const L=await o.getDimensions(i.floating);return v!==L.width||h!==L.height?{reset:{rects:!0}}:{}}}};function oS(e){const n=Rr(e);let s=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const o=na(e),i=o?e.offsetWidth:s,c=o?e.offsetHeight:r,d=Yc(s)!==i||Yc(r)!==c;return d&&(s=i,r=c),{width:s,height:r,$:d}}function pv(e){return hs(e)?e:e.contextElement}function Xi(e){const n=pv(e);if(!na(n))return no(1);const s=n.getBoundingClientRect(),{width:r,height:o,$:i}=oS(n);let c=(i?Yc(s.width):s.width)/r,d=(i?Yc(s.height):s.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const k4=no(0);function aS(e){const n=ps(e);return!hv()||!n.visualViewport?k4:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function N4(e,n,s){return n===void 0&&(n=!1),!!s&&n&&s===ps(e)}function Ba(e,n,s,r){n===void 0&&(n=!1),s===void 0&&(s=!1);const o=e.getBoundingClientRect(),i=pv(e);let c=no(1);n&&(r?hs(r)&&(c=Xi(r)):c=Xi(e));const d=N4(i,s,r)?aS(i):no(0);let u=(o.left+d.x)/c.x,f=(o.top+d.y)/c.y,g=o.width/c.x,y=o.height/c.y;if(i&&r){const v=ps(i),h=hs(r)?ps(r):r;let x=v,b=Xg(x);for(;b&&h!==x;){const j=Xi(b),k=b.getBoundingClientRect(),E=Rr(b),S=k.left+(b.clientLeft+parseFloat(E.paddingLeft))*j.x,N=k.top+(b.clientTop+parseFloat(E.paddingTop))*j.y;u*=j.x,f*=j.y,g*=j.x,y*=j.y,u+=S,f+=N,x=ps(b),b=Xg(x)}}return If({width:g,height:y,x:u,y:f})}function Am(e,n){const s=Rm(e).scrollLeft;return n?n.left+s:Ba(lo(e)).left+s}function iS(e,n){const s=e.getBoundingClientRect(),r=s.left+n.scrollLeft-Am(e,s),o=s.top+n.scrollTop;return{x:r,y:o}}function S4(e){let{elements:n,rect:s,offsetParent:r,strategy:o}=e;const i=o==="fixed",c=lo(r),d=n?Tm(n.floating):!1;if(r===c||d&&i)return s;let u={scrollLeft:0,scrollTop:0},f=no(1);const g=no(0),y=na(r);if((y||!i)&&((Cl(r)!=="body"||_m(c))&&(u=Rm(r)),y)){const h=Ba(r);f=Xi(r),g.x=h.x+r.clientLeft,g.y=h.y+r.clientTop}const v=c&&!y&&!i?iS(c,u):no(0);return{width:s.width*f.x,height:s.height*f.y,x:s.x*f.x-u.scrollLeft*f.x+g.x+v.x,y:s.y*f.y-u.scrollTop*f.y+g.y+v.y}}function C4(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function E4(e){const n=Rm(e),s=e.ownerDocument.body,r=Gs(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),o=Gs(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+Am(e);const c=-n.scrollTop;return Rr(s).direction==="rtl"&&(i+=Gs(e.clientWidth,s.clientWidth)-r),{width:r,height:o,x:i,y:c}}const $4=25;function _4(e,n,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",o=ps(e),i=lo(e),c=o.visualViewport;let d=i.clientWidth,u=i.clientHeight,f=0,g=0;if(c){const v=!hv()||n==="fixed";r?v||(f=-c.offsetLeft,g=-c.offsetTop):(d=c.width,u=c.height,v&&(f=c.offsetLeft,g=c.offsetTop))}if(Am(i)<=0){const v=i.ownerDocument,h=v.body,x=getComputedStyle(h),b=v.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,j=Math.abs(i.clientWidth-h.clientWidth-b),k=getComputedStyle(i).scrollbarGutter==="stable both-edges"?j/2:j;k<=$4&&(d-=k)}return{width:d,height:u,x:f,y:g}}function T4(e,n){const s=Ba(e,!0,n==="fixed"),r=s.top+e.clientTop,o=s.left+e.clientLeft,i=Xi(e),c=e.clientWidth*i.x,d=e.clientHeight*i.y,u=o*i.x,f=r*i.y;return{width:c,height:d,x:u,y:f}}function qj(e,n,s){let r;if(n==="viewport"||n==="layoutViewport")r=_4(e,s,n);else if(n==="document")r=E4(lo(e));else if(hs(n))r=T4(n,s);else{const o=aS(e);r={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return If(r)}function R4(e,n){const s=n.get(e);if(s)return s;let r=Vc(e,[],!1).filter(d=>hs(d)&&Cl(d)!=="body"),o=null;const i=Rr(e).position==="fixed";let c=i?Ua(e):e;for(;hs(c)&&!Kc(c);){const d=Rr(c),u=mv(c),f=o?o.position:i?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&d.position==="static")?r=r.filter(y=>y!==c):o=d,c=Ua(c)}return n.set(e,r),r}function A4(e){let{element:n,boundary:s,rootBoundary:r,strategy:o}=e;const c=[...s==="clippingAncestors"?Tm(n)?[]:R4(n,this._c):[].concat(s),r],d=qj(n,c[0],o);let u=d.top,f=d.right,g=d.bottom,y=d.left;for(let v=1;v<c.length;v++){const h=qj(n,c[v],o);u=Gs(h.top,u),f=Wa(h.right,f),g=Wa(h.bottom,g),y=Gs(h.left,y)}return{width:f-y,height:g-u,x:y,y:u}}function O4(e){const{width:n,height:s}=oS(e);return{width:n,height:s}}function L4(e,n,s){const r=na(n),o=lo(n),i=s==="fixed",c=Ba(e,!0,i,n);let d={scrollLeft:0,scrollTop:0};const u=no(0);if((r||!i)&&((Cl(n)!=="body"||_m(o))&&(d=Rm(n)),r)){const v=Ba(n,!0,i,n);u.x=v.x+n.clientLeft,u.y=v.y+n.clientTop}!r&&o&&(u.x=Am(o));const f=o&&!r&&!i?iS(o,d):no(0),g=c.left+d.scrollLeft-u.x-f.x,y=c.top+d.scrollTop-u.y-f.y;return{x:g,y,width:c.width,height:c.height}}function ag(e){return Rr(e).position==="static"}function Kj(e,n){if(!na(e)||Rr(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return lo(e)===s&&(s=s.ownerDocument.body),s}function lS(e,n){const s=ps(e);if(Tm(e))return s;if(!na(e)){let o=Ua(e);for(;o&&!Kc(o);){if(hs(o)&&!ag(o))return o;o=Ua(o)}return s}let r=Kj(e,n);for(;r&&e4(r)&&ag(r);)r=Kj(r,n);return r&&Kc(r)&&ag(r)&&!mv(r)?s:r||s4(e)||s}const M4=async function(e){const n=this.getOffsetParent||lS,s=this.getDimensions,r=await s(e.floating);return{reference:L4(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function P4(e){return Rr(e).direction==="rtl"}const I4={convertOffsetParentRelativeRectToViewportRelativeRect:S4,getDocumentElement:lo,getClippingRect:A4,getOffsetParent:lS,getElementRects:M4,getClientRects:C4,getDimensions:O4,getScale:Xi,isElement:hs,isRTL:P4};function cS(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function z4(e,n,s){let r=null,o;const i=lo(e);function c(){var g;clearTimeout(o),(g=r)==null||g.disconnect(),r=null}function d(g,y){g===void 0&&(g=!1),y===void 0&&(y=1),c();const v=e.getBoundingClientRect(),{left:h,top:x,width:b,height:j}=v;if(g||n(),!b||!j)return;const k=Vu(x),E=Vu(i.clientWidth-(h+b)),S=Vu(i.clientHeight-(x+j)),N=Vu(h),_={rootMargin:-k+"px "+-E+"px "+-S+"px "+-N+"px",threshold:Gs(0,Wa(1,y))||1};let O=!0;function L(P){const R=P[0].intersectionRatio;if(!cS(v,e.getBoundingClientRect()))return d();if(R!==y){if(!O)return d();R?d(!1,R):o=setTimeout(()=>{d(!1,1e-7)},1e3)}O=!1}try{r=new IntersectionObserver(L,{..._,root:i.ownerDocument})}catch{r=new IntersectionObserver(L,_)}r.observe(e)}const u=ps(e),f=()=>d(s);return u.addEventListener("resize",f),d(!0),()=>{u.removeEventListener("resize",f),c()}}function D4(e,n,s,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=pv(e),g=o||i?[...f?Vc(f):[],...n?Vc(n):[]]:[];g.forEach(k=>{o&&k.addEventListener("scroll",s),i&&k.addEventListener("resize",s)});const y=f&&d?z4(f,s,i):null;let v=-1,h=null;c&&(h=new ResizeObserver(k=>{let[E]=k;E&&E.target===f&&h&&n&&(h.unobserve(n),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var S;(S=h)==null||S.observe(n)})),s()}),f&&!u&&h.observe(f),n&&h.observe(n));let x,b=u?Ba(e):null;u&&j();function j(){const k=Ba(e);b&&!cS(b,k)&&s(),b=k,x=requestAnimationFrame(j)}return s(),()=>{var k;g.forEach(E=>{o&&E.removeEventListener("scroll",s),i&&E.removeEventListener("resize",s)}),y==null||y(),(k=h)==null||k.disconnect(),h=null,u&&cancelAnimationFrame(x)}}const ig=rS,F4=y4,U4=w4,W4=x4,H4=j4,B4=(e,n,s)=>{const r=new Map,o=s??{},i={...I4,...o.platform,_c:r};return g4(e,n,{...o,platform:i})};var G4=typeof document<"u",q4=function(){},yf=G4?p.useLayoutEffect:q4;function zf(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let s,r,o;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==n.length)return!1;for(r=s;r--!==0;)if(!zf(e[r],n[r]))return!1;return!0}if(o=Object.keys(e),s=o.length,s!==Object.keys(n).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(n,o[r]))return!1;for(r=s;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!zf(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}function dS(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Vj(e,n){const s=dS(e);return Math.round(n*s)/s}function lg(e){const n=p.useRef(e);return yf(()=>{n.current=e}),n}function K4(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:c}={},transform:d=!0,whileElementsMounted:u,open:f}=e,[g,y]=p.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[v,h]=p.useState(r);zf(v,r)||h(r);const[x,b]=p.useState(null),[j,k]=p.useState(null),E=p.useCallback(U=>{U!==_.current&&(_.current=U,b(U))},[]),S=p.useCallback(U=>{U!==O.current&&(O.current=U,k(U))},[]),N=i||x,$=c||j,_=p.useRef(null),O=p.useRef(null),L=p.useRef(g),P=u!=null,R=lg(u),A=lg(o),M=lg(f),F=p.useCallback(()=>{if(!_.current||!O.current)return;const U={placement:n,strategy:s,middleware:v};A.current&&(U.platform=A.current),B4(_.current,O.current,U).then(H=>{const G={...H,isPositioned:M.current!==!1};I.current&&!zf(L.current,G)&&(L.current=G,Cs.flushSync(()=>{y(G)}))})},[v,n,s,A,M]);yf(()=>{f===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,y(U=>({...U,isPositioned:!1})))},[f]);const I=p.useRef(!1);yf(()=>(I.current=!0,()=>{I.current=!1}),[]),yf(()=>{if(N&&(_.current=N),$&&(O.current=$),N&&$){if(R.current)return R.current(N,$,F);F()}},[N,$,F,R,P]);const q=p.useMemo(()=>({reference:_,floating:O,setReference:E,setFloating:S}),[E,S]),W=p.useMemo(()=>({reference:N,floating:$}),[N,$]),K=p.useMemo(()=>{const U={position:s,left:0,top:0};if(!W.floating)return U;const H=Vj(W.floating,g.x),G=Vj(W.floating,g.y);return d?{...U,transform:"translate("+H+"px, "+G+"px)",...dS(W.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:H,top:G}},[s,d,W.floating,g.x,g.y]);return p.useMemo(()=>({...g,update:F,refs:q,elements:W,floatingStyles:K}),[g,F,q,W,K])}const uS=(e,n)=>{const s=F4(e);return{name:s.name,fn:s.fn,options:[e,n]}},V4=(e,n)=>{const s=U4(e);return{name:s.name,fn:s.fn,options:[e,n]}},Y4=(e,n)=>{const s=W4(e);return{name:s.name,fn:s.fn,options:[e,n]}},Q4=(e,n)=>{const s=H4(e);return{name:s.name,fn:s.fn,options:[e,n]}},fS={...Wg},J4=fS.useInsertionEffect,X4=J4||(e=>e());function mS(e){const n=p.useRef(()=>{});return X4(()=>{n.current=e}),p.useCallback(function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return n.current==null?void 0:n.current(...r)},[])}var ex=typeof document<"u"?p.useLayoutEffect:p.useEffect;let Yj=!1,Z4=0;const Qj=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+Z4++;function eO(){const[e,n]=p.useState(()=>Yj?Qj():void 0);return ex(()=>{e==null&&n(Qj())},[]),p.useEffect(()=>{Yj=!0},[]),e}const tO=fS.useId,nO=tO||eO;function sO(){const e=new Map;return{emit(n,s){var r;(r=e.get(n))==null||r.forEach(o=>o(s))},on(n,s){e.set(n,[...e.get(n)||[],s])},off(n,s){var r;e.set(n,((r=e.get(n))==null?void 0:r.filter(o=>o!==s))||[])}}}const rO=p.createContext(null),oO=p.createContext(null),aO=()=>{var e;return((e=p.useContext(rO))==null?void 0:e.id)||null},iO=()=>p.useContext(oO),lO="data-floating-ui-focusable";function cO(e){const{open:n=!1,onOpenChange:s,elements:r}=e,o=nO(),i=p.useRef({}),[c]=p.useState(()=>sO()),d=aO()!=null,[u,f]=p.useState(r.reference),g=mS((h,x,b)=>{i.current.openEvent=h?x:void 0,c.emit("openchange",{open:h,event:x,reason:b,nested:d}),s==null||s(h,x,b)}),y=p.useMemo(()=>({setPositionReference:f}),[]),v=p.useMemo(()=>({reference:u||r.reference||null,floating:r.floating||null,domReference:r.reference}),[u,r.reference,r.floating]);return p.useMemo(()=>({dataRef:i,open:n,onOpenChange:g,elements:v,events:c,floatingId:o,refs:y}),[n,g,v,c,o,y])}function dO(e){e===void 0&&(e={});const{nodeId:n}=e,s=cO({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||s,o=r.elements,[i,c]=p.useState(null),[d,u]=p.useState(null),g=(o==null?void 0:o.domReference)||i,y=p.useRef(null),v=iO();ex(()=>{g&&(y.current=g)},[g]);const h=K4({...e,elements:{...o,...d&&{reference:d}}}),x=p.useCallback(S=>{const N=hs(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),contextElement:S}:S;u(N),h.refs.setReference(N)},[h.refs]),b=p.useCallback(S=>{(hs(S)||S===null)&&(y.current=S,c(S)),(hs(h.refs.reference.current)||h.refs.reference.current===null||S!==null&&!hs(S))&&h.refs.setReference(S)},[h.refs]),j=p.useMemo(()=>({...h.refs,setReference:b,setPositionReference:x,domReference:y}),[h.refs,b,x]),k=p.useMemo(()=>({...h.elements,domReference:g}),[h.elements,g]),E=p.useMemo(()=>({...h,...r,refs:j,elements:k,nodeId:n}),[h,j,k,n,r]);return ex(()=>{r.dataRef.current.floatingContext=E;const S=v==null?void 0:v.nodesRef.current.find(N=>N.id===n);S&&(S.context=E)}),p.useMemo(()=>({...h,context:E,refs:j,elements:k}),[h,j,k,E])}const Jj="active",Xj="selected";function cg(e,n,s){const r=new Map,o=s==="item";let i=e;if(o&&e){const{[Jj]:c,[Xj]:d,...u}=e;i=u}return{...s==="floating"&&{tabIndex:-1,[lO]:""},...i,...n.map(c=>{const d=c?c[s]:null;return typeof d=="function"?e?d(e):null:d}).concat(e).reduce((c,d)=>(d&&Object.entries(d).forEach(u=>{let[f,g]=u;if(!(o&&[Jj,Xj].includes(f)))if(f.indexOf("on")===0){if(r.has(f)||r.set(f,[]),typeof g=="function"){var y;(y=r.get(f))==null||y.push(g),c[f]=function(){for(var v,h=arguments.length,x=new Array(h),b=0;b<h;b++)x[b]=arguments[b];return(v=r.get(f))==null?void 0:v.map(j=>j(...x)).find(j=>j!==void 0)}}}else c[f]=g}),c),{})}}function uO(e){e===void 0&&(e=[]);const n=e.map(d=>d==null?void 0:d.reference),s=e.map(d=>d==null?void 0:d.floating),r=e.map(d=>d==null?void 0:d.item),o=p.useCallback(d=>cg(d,e,"reference"),n),i=p.useCallback(d=>cg(d,e,"floating"),s),c=p.useCallback(d=>cg(d,e,"item"),r);return p.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:c}),[o,i,c])}function Zj(e,n){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:n}}}}const fO=e=>({name:"inner",options:e,async fn(n){const{listRef:s,overflowRef:r,onFallbackChange:o,offset:i=0,index:c=0,minItemsVisible:d=4,referenceOverflowThreshold:u=0,scrollRef:f,...g}=El(e,n),{rects:y,elements:{floating:v}}=n,h=s.current[c],x=(f==null?void 0:f.current)||v,b=v.clientTop||x.clientTop,j=v.clientTop!==0,k=x.clientTop!==0,E=v===x;if(!h)return{};const S={...n,...await uS(-h.offsetTop-v.clientTop-y.reference.height/2-h.offsetHeight/2-i).fn(n)},N=await ig(Zj(S,x.scrollHeight+b+v.clientTop),g),$=await ig(S,{...g,elementContext:"reference"}),_=Gs(0,N.top),O=S.y+_,R=(x.scrollHeight>x.clientHeight?A=>A:Yc)(Gs(0,x.scrollHeight+(j&&E||k?b*2:0)-_-Gs(0,N.bottom)));if(x.style.maxHeight=R+"px",x.scrollTop=_,o){const A=x.offsetHeight<h.offsetHeight*Wa(d,s.current.length)-1||$.top>=-u||$.bottom>=-u;Cs.flushSync(()=>o(A))}return r&&(r.current=await ig(Zj({...S,y:O},x.offsetHeight+b+v.clientTop),g)),{y:O}}});function mO(e,n){const{open:s,elements:r}=e,{enabled:o=!0,overflowRef:i,scrollRef:c,onChange:d}=n,u=mS(d),f=p.useRef(!1),g=p.useRef(null),y=p.useRef(null);p.useEffect(()=>{if(!o)return;function h(b){if(b.ctrlKey||!x||i.current==null)return;const j=b.deltaY,k=i.current.top>=-.5,E=i.current.bottom>=-.5,S=x.scrollHeight-x.clientHeight,N=j<0?-1:1,$=j<0?"max":"min";x.scrollHeight<=x.clientHeight||(!k&&j>0||!E&&j<0?(b.preventDefault(),Cs.flushSync(()=>{u(_=>_+Math[$](j,S*N))})):/firefox/i.test(r4())&&(x.scrollTop+=j))}const x=(c==null?void 0:c.current)||r.floating;if(s&&x)return x.addEventListener("wheel",h),requestAnimationFrame(()=>{g.current=x.scrollTop,i.current!=null&&(y.current={...i.current})}),()=>{g.current=null,y.current=null,x.removeEventListener("wheel",h)}},[o,s,r.floating,i,c,u]);const v=p.useMemo(()=>({onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const h=(c==null?void 0:c.current)||r.floating;if(!(!i.current||!h||!f.current)){if(g.current!==null){const x=h.scrollTop-g.current;(i.current.bottom<-.5&&x<-1||i.current.top<-.5&&x>1)&&Cs.flushSync(()=>u(b=>b+x))}requestAnimationFrame(()=>{g.current=h.scrollTop})}}}),[r.floating,u,i,c]);return p.useMemo(()=>o?{floating:v}:{},[o,v])}let $l=p.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});$l.displayName="FloatingContext";let gv=p.createContext(null);gv.displayName="PlacementContext";function hO(e){return p.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function pO(){return p.useContext($l).setReference}function gO(){return p.useContext($l).getReferenceProps}function xO(){let{getFloatingProps:e,slot:n}=p.useContext($l);return p.useCallback((...s)=>Object.assign({},e(...s),{"data-anchor":n.anchor}),[e,n])}function vO(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let n=p.useContext(gv),s=p.useMemo(()=>e,[JSON.stringify(e,(o,i)=>{var c;return(c=i==null?void 0:i.outerHTML)!=null?c:i})]);tn(()=>{n==null||n(s??null)},[n,s]);let r=p.useContext($l);return p.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let ek=4;function bO({children:e,enabled:n=!0}){let[s,r]=p.useState(null),[o,i]=p.useState(0),c=p.useRef(null),[d,u]=p.useState(null);yO(d);let f=n&&s!==null&&d!==null,{to:g="bottom",gap:y=0,offset:v=0,padding:h=0,inner:x}=wO(s,d),[b,j="center"]=g.split(" ");tn(()=>{f&&i(0)},[f]);let{refs:k,floatingStyles:E,context:S}=dO({open:f,placement:b==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${b}`:`${b}-${j}`,strategy:"absolute",transform:!1,middleware:[uS({mainAxis:b==="selection"?0:y,crossAxis:v}),V4({padding:h}),b!=="selection"&&Y4({padding:h}),b==="selection"&&x?fO({...x,padding:h,overflowRef:c,offset:o,minItemsVisible:ek,referenceOverflowThreshold:h,onFallbackChange(A){var M,F;if(!A)return;let I=S.elements.floating;if(!I)return;let q=parseFloat(getComputedStyle(I).scrollPaddingBottom)||0,W=Math.min(ek,I.childElementCount),K=0,U=0;for(let H of(F=(M=S.elements.floating)==null?void 0:M.childNodes)!=null?F:[])if(Es(H)){let G=H.offsetTop,z=G+H.clientHeight+q,V=I.scrollTop,se=V+I.clientHeight;if(G>=V&&z<=se)W--;else{U=Math.max(0,Math.min(z,se)-Math.max(G,V)),K=H.clientHeight;break}}W>=1&&i(H=>{let G=K*W-U+q;return H>=G?H:G})}}):null,Q4({padding:h,apply({availableWidth:A,availableHeight:M,elements:F}){Object.assign(F.floating.style,{overflow:"auto",maxWidth:`${A}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${M}px)`})}})].filter(Boolean),whileElementsMounted:D4}),[N=b,$=j]=S.placement.split("-");b==="selection"&&(N="selection");let _=p.useMemo(()=>({anchor:[N,$].filter(Boolean).join(" ")}),[N,$]),O=mO(S,{overflowRef:c,onChange:i}),{getReferenceProps:L,getFloatingProps:P}=uO([O]),R=dt(A=>{u(A),k.setFloating(A)});return p.createElement(gv.Provider,{value:r},p.createElement($l.Provider,{value:{setFloating:R,setReference:k.setReference,styles:E,getReferenceProps:L,getFloatingProps:P,slot:_}},e))}function yO(e){tn(()=>{if(!e)return;let n=new MutationObserver(()=>{let s=window.getComputedStyle(e).maxHeight,r=parseFloat(s);if(isNaN(r))return;let o=parseInt(s);isNaN(o)||r!==o&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return n.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{n.disconnect()}},[e])}function wO(e,n){var s,r,o;let i=dg((s=e==null?void 0:e.gap)!=null?s:"var(--anchor-gap, 0)",n),c=dg((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",n),d=dg((o=e==null?void 0:e.padding)!=null?o:"var(--anchor-padding, 0)",n);return{...e,gap:i,offset:c,padding:d}}function dg(e,n,s=void 0){let r=ea(),o=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 g=tk(u,f);return[g,y=>{let v=hS(u);{let h=v.map(x=>window.getComputedStyle(f).getPropertyValue(x));r.requestAnimationFrame(function x(){r.nextFrame(x);let b=!1;for(let[k,E]of v.entries()){let S=window.getComputedStyle(f).getPropertyValue(E);if(h[k]!==S){h[k]=S,b=!0;break}}if(!b)return;let j=tk(u,f);g!==j&&(y(j),g=j)})}return r.dispose}]}return[s,null]}),i=p.useMemo(()=>o(e,n)[0],[e,n]),[c=i,d]=p.useState();return tn(()=>{let[u,f]=o(e,n);if(d(u),!!f)return f(d)},[e,n]),c}function hS(e){let n=/var\((.*)\)/.exec(e);if(n){let s=n[1].indexOf(",");if(s===-1)return[n[1]];let r=n[1].slice(0,s).trim(),o=n[1].slice(s+1).trim();return o?[r,...hS(o)]:[r]}return[]}function tk(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 jO({children:e,freeze:n},s){let r=pS(n,e);return p.isValidElement(r)?p.cloneElement(r,{ref:s}):Ke.createElement(Ke.Fragment,null,r)}Ke.forwardRef(jO);function pS(e,n){let[s,r]=p.useState(n);return!e&&s!==n&&r(n),e?s:n}let Om=p.createContext(null);Om.displayName="OpenClosedContext";var es=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(es||{});function md(){return p.useContext(Om)}function gS({value:e,children:n}){return Ke.createElement(Om.Provider,{value:e},n)}function kO({children:e}){return Ke.createElement(Om.Provider,{value:null},e)}function NO(e){function n(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",n))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",n),n())}let Io=[];NO(()=>{function e(n){if(!Jr(n.target)||n.target===document.body||Io[0]===n.target)return;let s=n.target;s=s.closest(Mf),Io.unshift(s??n.target),Io=Io.filter(r=>r!=null&&r.isConnected),Io.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 SO(e){throw new Error("Unexpected object: "+e)}var on=(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))(on||{});function Yu(e,n){let s=n.resolveItems();if(s.length<=0)return null;let r=n.resolveActiveIndex(),o=r??-1;switch(e.focus){case 0:{for(let i=0;i<s.length;++i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 1:{o===-1&&(o=s.length);for(let i=o-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 2:{for(let i=o+1;i<s.length;++i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 3:{for(let i=s.length-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 4:{for(let i=0;i<s.length;++i)if(n.resolveId(s[i],i,s)===e.id)return i;return r}case 5:return null;default:SO(e)}}function xv(e){let n=dt(e),s=p.useRef(!1);p.useEffect(()=>(s.current=!1,()=>{s.current=!0,Nm(()=>{s.current&&n()})}),[n])}function CO(){let e=typeof document>"u";return"useSyncExternalStore"in Wg?(n=>n.useSyncExternalStore)(Wg)(()=>()=>{},()=>!1,()=>!e):!1}function hd(){let e=CO(),[n,s]=p.useState($r.isHandoffComplete);return n&&$r.isHandoffComplete===!1&&s(!1),p.useEffect(()=>{n!==!0&&s(!0)},[n]),p.useEffect(()=>$r.handoff(),[]),e?!1:n}let xS=p.createContext(!1);function EO(){return p.useContext(xS)}function nk(e){return Ke.createElement(xS.Provider,{value:e.force},e.children)}function $O(e){let n=EO(),s=p.useContext(bS),[r,o]=p.useState(()=>{var i;if(!n&&s!==null)return(i=s.current)!=null?i:null;if($r.isServer)return null;let c=e==null?void 0:e.getElementById("headlessui-portal-root");if(c)return c;if(e===null)return null;let d=e.createElement("div");return d.setAttribute("id","headlessui-portal-root"),e.body.appendChild(d)});return p.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),p.useEffect(()=>{n||s!==null&&o(s.current)},[s,o,n]),r}let vS=p.Fragment,_O=vn(function(e,n){let{ownerDocument:s=null,...r}=e,o=p.useRef(null),i=Wn(e3(h=>{o.current=h}),n),c=qc(o.current),d=s??c,u=$O(d),f=p.useContext(tx),g=ea(),y=hd(),v=$n();return xv(()=>{var h;u&&u.childNodes.length<=0&&((h=u.parentElement)==null||h.removeChild(u))}),!u||!y?null:Cs.createPortal(Ke.createElement("div",{"data-headlessui-portal":"",ref:h=>{g.dispose(),f&&h&&g.add(f.register(h))}},v({ourProps:{ref:i},theirProps:r,slot:{},defaultTag:vS,name:"Portal"})),u)});function TO(e,n){let s=Wn(n),{enabled:r=!0,ownerDocument:o,...i}=e,c=$n();return r?Ke.createElement(_O,{...i,ownerDocument:o,ref:s}):c({ourProps:{ref:s},theirProps:i,slot:{},defaultTag:vS,name:"Portal"})}let RO=p.Fragment,bS=p.createContext(null);function AO(e,n){let{target:s,...r}=e,o={ref:Wn(n)},i=$n();return Ke.createElement(bS.Provider,{value:s},i({ourProps:o,theirProps:r,defaultTag:RO,name:"Popover.Group"}))}let tx=p.createContext(null);function OO(){let e=p.useContext(tx),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)}),o=p.useMemo(()=>({register:s,unregister:r,portals:n}),[s,r,n]);return[n,p.useMemo(()=>function({children:i}){return Ke.createElement(tx.Provider,{value:o},i)},[o])]}let LO=vn(TO),yS=vn(AO),wS=Object.assign(LO,{Group:yS});const wf={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function jS(e){let n=e.getBoundingClientRect();return`${n.x},${n.y}`}function MO(e,n,s){let r=Ts();if(n.kind==="Tracked"){let o=function(){i!==jS(e)&&(r.dispose(),s())},{position:i}=n,c=new ResizeObserver(o);c.observe(e),r.add(()=>c.disconnect()),r.addEventListener(window,"scroll",o,{passive:!0}),r.addEventListener(window,"resize",o)}return()=>r.dispose()}function PO(e,n=typeof document<"u"?document.defaultView:null,s){let r=ud(e,"escape");Y1(n,"keydown",o=>{r&&(o.defaultPrevented||o.key===wn.Escape&&s(o))})}function IO(){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 tn(()=>{if(!n)return;function o(i){r(i.matches)}return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[n]),s}function zO({defaultContainers:e=[],portals:n,mainTreeNode:s}={}){let r=dt(()=>{var o,i;let c=Sl(s),d=[];for(let u of e)u!==null&&(eo(u)?d.push(u):"current"in u&&eo(u.current)&&d.push(u.current));if(n!=null&&n.current)for(let u of n.current)d.push(u);for(let u of(o=c==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?o:[])u!==document.body&&u!==document.head&&eo(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(o=>r().some(i=>i.contains(o)))}}let kS=p.createContext(null);function sk({children:e,node:n}){let[s,r]=p.useState(null),o=NS(n??s);return Ke.createElement(kS.Provider,{value:o},e,o===null&&Ke.createElement(Gc,{features:ul.Hidden,ref:i=>{var c,d;if(i){for(let u of(d=(c=Sl(i))==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?d:[])if(u!==document.body&&u!==document.head&&eo(u)&&u!=null&&u.contains(i)){r(u);break}}}}))}function NS(e=null){var n;return(n=p.useContext(kS))!=null?n:e}function vv(){let e=p.useRef(!1);return tn(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Ac=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(Ac||{});function DO(){let e=p.useRef(0);return K1(!0,"keydown",n=>{n.key==="Tab"&&(e.current=n.shiftKey?1:0)},!0),e}function SS(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let n=new Set;for(let s of e.current)eo(s.current)&&n.add(s.current);return n}let FO="div";var $a=(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))($a||{});function UO(e,n){let s=p.useRef(null),r=Wn(s,n),{initialFocus:o,initialFocusFallback:i,containers:c,features:d=15,...u}=e;hd()||(d=0);let f=qc(s.current);GO(d,{ownerDocument:f});let g=qO(d,{ownerDocument:f,container:s,initialFocus:o,initialFocusFallback:i});KO(d,{ownerDocument:f,container:s,containers:c,previousActiveElement:g});let y=DO(),v=dt(E=>{if(!Es(s.current))return;let S=s.current;(N=>N())(()=>{ss(y.current,{[Ac.Forwards]:()=>{Ji(S,dr.First,{skipElements:[E.relatedTarget,i]})},[Ac.Backwards]:()=>{Ji(S,dr.Last,{skipElements:[E.relatedTarget,i]})}})})}),h=ud(!!(d&2),"focus-trap#tab-lock"),x=ea(),b=p.useRef(!1),j={ref:r,onKeyDown(E){E.key=="Tab"&&(b.current=!0,x.requestAnimationFrame(()=>{b.current=!1}))},onBlur(E){if(!(d&4))return;let S=SS(c);Es(s.current)&&S.add(s.current);let N=E.relatedTarget;Jr(N)&&N.dataset.headlessuiFocusGuard!=="true"&&(CS(S,N)||(b.current?Ji(s.current,ss(y.current,{[Ac.Forwards]:()=>dr.Next,[Ac.Backwards]:()=>dr.Previous})|dr.WrapAround,{relativeTo:E.target}):Jr(E.target)&&to(E.target)))}},k=$n();return Ke.createElement(Ke.Fragment,null,h&&Ke.createElement(Gc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:v,features:ul.Focusable}),k({ourProps:j,theirProps:u,defaultTag:FO,name:"FocusTrap"}),h&&Ke.createElement(Gc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:v,features:ul.Focusable}))}let WO=vn(UO),HO=Object.assign(WO,{features:$a});function BO(e=!0){let n=p.useRef(Io.slice());return fv(([s],[r])=>{r===!0&&s===!1&&Nm(()=>{n.current.splice(0)}),r===!1&&s===!0&&(n.current=Io.slice())},[e,Io,n]),dt(()=>{var s;return(s=n.current.find(r=>r!=null&&r.isConnected))!=null?s:null})}function GO(e,{ownerDocument:n}){let s=!!(e&8),r=BO(s);fv(()=>{s||v1(n==null?void 0:n.body)&&to(r())},[s]),xv(()=>{s&&to(r())})}function qO(e,{ownerDocument:n,container:s,initialFocus:r,initialFocusFallback:o}){let i=p.useRef(null),c=ud(!!(e&1),"focus-trap#initial-focus"),d=vv();return fv(()=>{if(e===0)return;if(!c){o!=null&&o.current&&to(o.current);return}let u=s.current;u&&Nm(()=>{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)to(r.current);else{if(e&16){if(Ji(u,dr.First|dr.AutoFocus)!==Jg.Error)return}else if(Ji(u,dr.First)!==Jg.Error)return;if(o!=null&&o.current&&(to(o.current),(n==null?void 0:n.activeElement)===o.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}i.current=n==null?void 0:n.activeElement})},[o,c,e]),i}function KO(e,{ownerDocument:n,container:s,containers:r,previousActiveElement:o}){let i=vv(),c=!!(e&4);Y1(n==null?void 0:n.defaultView,"focus",d=>{if(!c||!i.current)return;let u=SS(r);Es(s.current)&&u.add(s.current);let f=o.current;if(!f)return;let g=d.target;Es(g)?CS(u,g)?(o.current=g,to(g)):(d.preventDefault(),d.stopPropagation(),to(f)):to(o.current)},!0)}function CS(e,n){for(let s of e)if(s.contains(n))return!0;return!1}function ES(e){var n;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!Pc((n=e.as)!=null?n:_S)||Ke.Children.count(e.children)===1}let Lm=p.createContext(null);Lm.displayName="TransitionContext";var VO=(e=>(e.Visible="visible",e.Hidden="hidden",e))(VO||{});function YO(){let e=p.useContext(Lm);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function QO(){let e=p.useContext(Mm);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let Mm=p.createContext(null);Mm.displayName="NestingContext";function Pm(e){return"children"in e?Pm(e.children):e.current.filter(({el:n})=>n.current!==null).filter(({state:n})=>n==="visible").length>0}function $S(e,n){let s=ta(e),r=p.useRef([]),o=vv(),i=ea(),c=dt((h,x=zo.Hidden)=>{let b=r.current.findIndex(({el:j})=>j===h);b!==-1&&(ss(x,{[zo.Unmount](){r.current.splice(b,1)},[zo.Hidden](){r.current[b].state="hidden"}}),i.microTask(()=>{var j;!Pm(r)&&o.current&&((j=s.current)==null||j.call(s))}))}),d=dt(h=>{let x=r.current.find(({el:b})=>b===h);return x?x.state!=="visible"&&(x.state="visible"):r.current.push({el:h,state:"visible"}),()=>c(h,zo.Unmount)}),u=p.useRef([]),f=p.useRef(Promise.resolve()),g=p.useRef({enter:[],leave:[]}),y=dt((h,x,b)=>{u.current.splice(0),n&&(n.chains.current[x]=n.chains.current[x].filter(([j])=>j!==h)),n==null||n.chains.current[x].push([h,new Promise(j=>{u.current.push(j)})]),n==null||n.chains.current[x].push([h,new Promise(j=>{Promise.all(g.current[x].map(([k,E])=>E)).then(()=>j())})]),x==="enter"?f.current=f.current.then(()=>n==null?void 0:n.wait.current).then(()=>b(x)):b(x)}),v=dt((h,x,b)=>{Promise.all(g.current[x].splice(0).map(([j,k])=>k)).then(()=>{var j;(j=u.current.shift())==null||j()}).then(()=>b(x))});return p.useMemo(()=>({children:r,register:d,unregister:c,onStart:y,onStop:v,wait:f,chains:g}),[d,c,r,y,v,g,f])}let _S=p.Fragment,TS=dl.RenderStrategy;function JO(e,n){var s,r;let{transition:o=!0,beforeEnter:i,afterEnter:c,beforeLeave:d,afterLeave:u,enter:f,enterFrom:g,enterTo:y,entered:v,leave:h,leaveFrom:x,leaveTo:b,...j}=e,[k,E]=p.useState(null),S=p.useRef(null),N=ES(e),$=Wn(...N?[S,n,E]:n===null?[]:[n]),_=(s=j.unmount)==null||s?zo.Unmount:zo.Hidden,{show:O,appear:L,initial:P}=YO(),[R,A]=p.useState(O?"visible":"hidden"),M=QO(),{register:F,unregister:I}=M;tn(()=>F(S),[F,S]),tn(()=>{if(_===zo.Hidden&&S.current){if(O&&R!=="visible"){A("visible");return}return ss(R,{hidden:()=>I(S),visible:()=>F(S)})}},[R,S,F,I,O,_]);let q=hd();tn(()=>{if(N&&q&&R==="visible"&&S.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[S,R,q,N]);let W=P&&!L,K=L&&O&&P,U=p.useRef(!1),H=$S(()=>{U.current||(A("hidden"),I(S))},M),G=dt(me=>{U.current=!0;let ve=me?"enter":"leave";H.onStart(S,ve,je=>{je==="enter"?i==null||i():je==="leave"&&(d==null||d())})}),z=dt(me=>{let ve=me?"enter":"leave";U.current=!1,H.onStop(S,ve,je=>{je==="enter"?c==null||c():je==="leave"&&(u==null||u())}),ve==="leave"&&!Pm(H)&&(A("hidden"),I(S))});p.useEffect(()=>{N&&o||(G(O),z(O))},[O,N,o]);let V=!(!o||!N||!q||W),[,se]=X1(V,k,O,{start:G,end:z}),J=Po({ref:$,className:((r=Yg(j.className,K&&f,K&&g,se.enter&&f,se.enter&&se.closed&&g,se.enter&&!se.closed&&y,se.leave&&h,se.leave&&!se.closed&&x,se.leave&&se.closed&&b,!se.transition&&O&&v))==null?void 0:r.trim())||void 0,...J1(se)}),re=0;R==="visible"&&(re|=es.Open),R==="hidden"&&(re|=es.Closed),O&&R==="hidden"&&(re|=es.Opening),!O&&R==="visible"&&(re|=es.Closing);let ne=$n();return Ke.createElement(Mm.Provider,{value:H},Ke.createElement(gS,{value:re},ne({ourProps:J,theirProps:j,defaultTag:_S,features:TS,visible:R==="visible",name:"Transition.Child"})))}function XO(e,n){let{show:s,appear:r=!1,unmount:o=!0,...i}=e,c=p.useRef(null),d=ES(e),u=Wn(...d?[c,n]:n===null?[]:[n]);hd();let f=md();if(s===void 0&&f!==null&&(s=(f&es.Open)===es.Open),s===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[g,y]=p.useState(s?"visible":"hidden"),v=$S(()=>{s||y("hidden")}),[h,x]=p.useState(!0),b=p.useRef([s]);tn(()=>{h!==!1&&b.current[b.current.length-1]!==s&&(b.current.push(s),x(!1))},[b,s]);let j=p.useMemo(()=>({show:s,appear:r,initial:h}),[s,r,h]);tn(()=>{s?y("visible"):!Pm(v)&&c.current!==null&&y("hidden")},[s,v]);let k={unmount:o},E=dt(()=>{var $;h&&x(!1),($=e.beforeEnter)==null||$.call(e)}),S=dt(()=>{var $;h&&x(!1),($=e.beforeLeave)==null||$.call(e)}),N=$n();return Ke.createElement(Mm.Provider,{value:v},Ke.createElement(Lm.Provider,{value:j},N({ourProps:{...k,as:p.Fragment,children:Ke.createElement(RS,{ref:u,...k,...i,beforeEnter:E,beforeLeave:S})},theirProps:{},defaultTag:p.Fragment,features:TS,visible:g==="visible",name:"Transition"})))}function ZO(e,n){let s=p.useContext(Lm)!==null,r=md()!==null;return Ke.createElement(Ke.Fragment,null,!s&&r?Ke.createElement(nx,{ref:n,...e}):Ke.createElement(RS,{ref:n,...e}))}let nx=vn(XO),RS=vn(JO),bv=vn(ZO),e5=Object.assign(nx,{Child:bv,Root:nx});var t5=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(t5||{}),n5=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(n5||{});let s5={0(e,n){return e.titleId===n.id?e:{...e,titleId:n.id}}},yv=p.createContext(null);yv.displayName="DialogContext";function Im(e){let n=p.useContext(yv);if(n===null){let s=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Im),s}return n}function r5(e,n){return ss(n.type,s5,e,n)}let rk=vn(function(e,n){let s=p.useId(),{id:r=`headlessui-dialog-${s}`,open:o,onClose:i,initialFocus:c,role:d="dialog",autoFocus:u=!0,__demoMode:f=!1,unmount:g=!1,...y}=e,v=p.useRef(!1);d=(function(){return d==="dialog"||d==="alertdialog"?d:(v.current||(v.current=!0,console.warn(`Invalid role [${d}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let h=md();o===void 0&&h!==null&&(o=(h&es.Open)===es.Open);let x=p.useRef(null),b=Wn(x,n),j=qc(x.current),k=o?0:1,[E,S]=p.useReducer(r5,{titleId:null,descriptionId:null,panelRef:p.createRef()}),N=dt(()=>i(!1)),$=dt(se=>S({type:0,id:se})),_=hd()?k===0:!1,[O,L]=OO(),P={get current(){var se;return(se=E.panelRef.current)!=null?se:x.current}},R=NS(),{resolveContainers:A}=zO({mainTreeNode:R,portals:O,defaultContainers:[P]}),M=h!==null?(h&es.Closing)===es.Closing:!1;U1(f||M?!1:_,{allowed:dt(()=>{var se,J;return[(J=(se=x.current)==null?void 0:se.closest("[data-headlessui-portal]"))!=null?J:null]}),disallowed:dt(()=>{var se;return[(se=R==null?void 0:R.closest("body > *:not(#headlessui-portal-root)"))!=null?se:null]})});let F=Em.get(null);tn(()=>{if(_)return F.actions.push(r),()=>F.actions.pop(r)},[F,r,_]);let I=Xn(F,p.useCallback(se=>F.selectors.isTop(se,r),[F,r]));V1(I,A,se=>{se.preventDefault(),N()}),PO(I,j==null?void 0:j.defaultView,se=>{se.preventDefault(),se.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),N()}),Q1(f||M?!1:_,j,A),W1(_,x,N);let[q,W]=n3(),K=p.useMemo(()=>[{dialogState:k,close:N,setTitleId:$,unmount:g},E],[k,N,$,g,E]),U=Ys({open:k===0}),H={ref:b,id:r,role:d,tabIndex:-1,"aria-modal":f?void 0:k===0?!0:void 0,"aria-labelledby":E.titleId,"aria-describedby":q,unmount:g},G=!IO(),z=$a.None;_&&!f&&(z|=$a.RestoreFocus,z|=$a.TabLock,u&&(z|=$a.AutoFocus),G&&(z|=$a.InitialFocus));let V=$n();return Ke.createElement(kO,null,Ke.createElement(nk,{force:!0},Ke.createElement(wS,null,Ke.createElement(yv.Provider,{value:K},Ke.createElement(yS,{target:x},Ke.createElement(nk,{force:!1},Ke.createElement(W,{slot:U},Ke.createElement(L,null,Ke.createElement(HO,{initialFocus:c,initialFocusFallback:x,containers:A,features:z},Ke.createElement(f3,{value:N},V({ourProps:H,theirProps:y,slot:U,defaultTag:o5,features:a5,visible:k===0,name:"Dialog"})))))))))))}),o5="div",a5=dl.RenderStrategy|dl.Static;function i5(e,n){let{transition:s=!1,open:r,...o}=e,i=md(),c=e.hasOwnProperty("open")||i!==null,d=e.hasOwnProperty("onClose");if(!c&&!d)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!c)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!d)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!i&&typeof e.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(r!==void 0||s)&&!o.static?Ke.createElement(sk,null,Ke.createElement(e5,{show:r,transition:s,unmount:o.unmount},Ke.createElement(rk,{ref:n,...o}))):Ke.createElement(sk,null,Ke.createElement(rk,{ref:n,open:r,...o}))}let l5="div";function c5(e,n){let s=p.useId(),{id:r=`headlessui-dialog-panel-${s}`,transition:o=!1,...i}=e,[{dialogState:c,unmount:d},u]=Im("Dialog.Panel"),f=Wn(n,u.panelRef),g=Ys({open:c===0}),y=dt(j=>{j.stopPropagation()}),v={ref:f,id:r,onClick:y},h=o?bv:p.Fragment,x=o?{unmount:d}:{},b=$n();return Ke.createElement(h,{...x},b({ourProps:v,theirProps:i,slot:g,defaultTag:l5,name:"Dialog.Panel"}))}let d5="div";function u5(e,n){let{transition:s=!1,...r}=e,[{dialogState:o,unmount:i}]=Im("Dialog.Backdrop"),c=Ys({open:o===0}),d={ref:n,"aria-hidden":!0},u=s?bv:p.Fragment,f=s?{unmount:i}:{},g=$n();return Ke.createElement(u,{...f},g({ourProps:d,theirProps:r,slot:c,defaultTag:d5,name:"Dialog.Backdrop"}))}let f5="h2";function m5(e,n){let s=p.useId(),{id:r=`headlessui-dialog-title-${s}`,...o}=e,[{dialogState:i,setTitleId:c}]=Im("Dialog.Title"),d=Wn(n);p.useEffect(()=>(c(r),()=>c(null)),[r,c]);let u=Ys({open:i===0}),f={ref:d,id:r};return $n()({ourProps:f,theirProps:o,slot:u,defaultTag:f5,name:"Dialog.Title"})}let h5=vn(i5),AS=vn(c5),p5=vn(u5),OS=vn(m5),g5=Object.assign(h5,{Panel:AS,Title:OS,Description:R1}),ok=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function ak(e){var n,s;let r=(n=e.innerText)!=null?n:"",o=e.cloneNode(!0);if(!Es(o))return r;let i=!1;for(let d of o.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))d.remove(),i=!0;let c=i?(s=o.innerText)!=null?s:"":r;return ok.test(c)&&(c=c.replace(ok,"")),c}function x5(e){let n=e.getAttribute("aria-label");if(typeof n=="string")return n.trim();let s=e.getAttribute("aria-labelledby");if(s){let r=s.split(" ").map(o=>{let i=document.getElementById(o);if(i){let c=i.getAttribute("aria-label");return typeof c=="string"?c.trim():ak(i).trim()}return null}).filter(Boolean);if(r.length>0)return r.join(", ")}return ak(e).trim()}function v5(e){let n=p.useRef(""),s=p.useRef("");return dt(()=>{let r=e.current;if(!r)return"";let o=r.innerText;if(n.current===o)return s.current;let i=x5(r).trim().toLowerCase();return n.current=o,s.current=i,i})}var b5=Object.defineProperty,y5=(e,n,s)=>n in e?b5(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,ik=(e,n,s)=>(y5(e,typeof n!="symbol"?n+"":n,s),s),Fn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Fn||{}),Do=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Do||{}),jf=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(jf||{}),LS=(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))(LS||{});function lk(e,n=s=>s){let s=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=G1(n(e.options.slice()),i=>i.dataRef.current.domRef.current),o=s?r.indexOf(s):null;return o===-1&&(o=null),{options:r,activeOptionIndex:o}}let w5={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=e.buttonElement?wf.Tracked(jS(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:on.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:n}},0(e,n){if(e.dataRef.current.disabled||e.listboxState===0)return e;let s=e.activeOptionIndex,{isSelected:r}=e.dataRef.current,o=e.options.findIndex(i=>r(i.dataRef.current.value));return o!==-1&&(s=o),{...e,frozenValue:!1,pendingFocus:n.focus,listboxState:0,activeOptionIndex:s,__demoMode:!1,buttonPositionState:wf.Idle}},2(e,n){var s,r,o,i,c;if(e.dataRef.current.disabled||e.listboxState===1)return e;let d={...e,searchQuery:"",activationTrigger:(s=n.trigger)!=null?s:1,__demoMode:!1};if(n.focus===on.Nothing)return{...d,activeOptionIndex:null};if(n.focus===on.Specific)return{...d,activeOptionIndex:e.options.findIndex(g=>g.id===n.id)};if(n.focus===on.Previous){let g=e.activeOptionIndex;if(g!==null){let y=e.options[g].dataRef.current.domRef,v=Yu(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(v!==null){let h=e.options[v].dataRef.current.domRef;if(((r=y.current)==null?void 0:r.previousElementSibling)===h.current||((o=h.current)==null?void 0:o.previousElementSibling)===null)return{...d,activeOptionIndex:v}}}}else if(n.focus===on.Next){let g=e.activeOptionIndex;if(g!==null){let y=e.options[g].dataRef.current.domRef,v=Yu(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(v!==null){let h=e.options[v].dataRef.current.domRef;if(((i=y.current)==null?void 0:i.nextElementSibling)===h.current||((c=h.current)==null?void 0:c.nextElementSibling)===null)return{...d,activeOptionIndex:v}}}}let u=lk(e),f=Yu(n,{resolveItems:()=>u.options,resolveActiveIndex:()=>u.activeOptionIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});return{...d,...u,activeOptionIndex:f}},3:(e,n)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let s=e.searchQuery!==""?0:1,r=e.searchQuery+n.value.toLowerCase(),o=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+s).concat(e.options.slice(0,e.activeOptionIndex+s)):e.options).find(c=>{var d;return!c.dataRef.current.disabled&&((d=c.dataRef.current.textValue)==null?void 0:d.startsWith(r))}),i=o?e.options.indexOf(o):-1;return i===-1||i===e.activeOptionIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeOptionIndex:i,activationTrigger:1}},4(e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},5(e){return e.dataRef.current.mode===0?{...e,frozenValue:!0}:{...e}},6:(e,n)=>{let s=e.options.concat(n.options),r=e.activeOptionIndex;if(e.pendingFocus.focus!==on.Nothing&&(r=Yu(e.pendingFocus,{resolveItems:()=>s,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:o=>o.id,resolveDisabled:o=>o.dataRef.current.disabled})),e.activeOptionIndex===null){let{isSelected:o}=e.dataRef.current;if(o){let i=s.findIndex(c=>o==null?void 0:o(c.dataRef.current.value));i!==-1&&(r=i)}}return{...e,options:s,activeOptionIndex:r,pendingFocus:{focus:on.Nothing},pendingShouldSort:!0}},7:(e,n)=>{let s=e.options,r=[],o=new Set(n.options);for(let[i,c]of s.entries())if(o.has(c.id)&&(r.push(i),o.delete(c.id),o.size===0))break;if(r.length>0){s=s.slice();for(let i of r.reverse())s.splice(i,1)}return{...e,options:s,activationTrigger:1}},8:(e,n)=>e.buttonElement===n.element?e:{...e,buttonElement:n.element},9:(e,n)=>e.optionsElement===n.element?e:{...e,optionsElement:n.element},10:e=>e.pendingShouldSort?{...e,...lk(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:wf.Moved}}};class wv extends I1{constructor(n){super(n),ik(this,"actions",{onChange:s=>{let{onChange:r,compare:o,mode:i,value:c}=this.state.dataRef.current;return ss(i,{0:()=>r==null?void 0:r(s),1:()=>{let d=c.slice(),u=d.findIndex(f=>o(f,s));return u===-1?d.push(s):d.splice(u,1),r==null?void 0:r(d)}})},registerOption:ng(()=>{let s=[],r=new Set;return[(o,i)=>{r.has(i)||(r.add(i),s.push({id:o,dataRef:i}))},()=>(r.clear(),this.send({type:6,options:s.splice(0)}))]}),unregisterOption:ng(()=>{let s=[];return[r=>s.push(r),()=>{this.send({type:7,options:s.splice(0)})}]}),goToOption:ng(()=>{let s=null;return[(r,o)=>{s={type:2,...r,trigger:o}},()=>s&&this.send(s)]}),closeListbox:()=>{this.send({type:1})},openListbox:s=>{this.send({type:0,focus:s})},selectActiveOption:()=>{var s;if(this.state.activeOptionIndex!==null){let{dataRef:r}=this.state.options[this.state.activeOptionIndex];this.actions.selectOption(r.current.value)}else this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(s=this.state.buttonElement)==null||s.focus({preventScroll:!0}))},selectOption:s=>{this.send({type:5,value:s})},search:s=>{this.send({type:3,value:s})},clearSearch:()=>{this.send({type:4})},setButtonElement:s=>{this.send({type:8,element:s})},setOptionsElement:s=>{this.send({type:9,element:s})}}),ik(this,"selectors",{activeDescendantId(s){var r;let o=s.activeOptionIndex,i=s.options;return o===null||(r=i[o])==null?void 0:r.id},isActive(s,r){var o;let i=s.activeOptionIndex,c=s.options;return i!==null?((o=c[i])==null?void 0:o.id)===r:!1},hasFrozenValue(s){return s.frozenValue},shouldScrollIntoView(s,r){return s.__demoMode||s.listboxState!==0||s.activationTrigger===0?!1:this.isActive(s,r)},didButtonMove(s){return s.buttonPositionState.kind==="Moved"}}),this.on(6,()=>{requestAnimationFrame(()=>{this.send({type:10})})});{let s=this.state.id,r=Em.get(null);this.disposables.add(r.on(D1.Push,o=>{!r.selectors.isTop(o,s)&&this.state.listboxState===0&&this.actions.closeListbox()})),this.on(0,()=>r.actions.push(s)),this.on(1,()=>r.actions.pop(s))}this.disposables.group(s=>{this.on(1,r=>{r.buttonElement&&(s.dispose(),s.add(MO(r.buttonElement,r.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(s,r)=>{var o;this.actions.onChange(r.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(o=this.state.buttonElement)==null||o.focus({preventScroll:!0}))})}static new({id:n,__demoMode:s=!1}){return new wv({id:n,dataRef:{current:{}},listboxState:s?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:on.Nothing},frozenValue:!1,__demoMode:s,buttonPositionState:wf.Idle})}reduce(n,s){return ss(s.type,w5,n,s)}}const MS=p.createContext(null);function jv(e){let n=p.useContext(MS);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,PS),s}return n}function PS({id:e,__demoMode:n=!1}){let s=p.useMemo(()=>wv.new({id:e,__demoMode:n}),[]);return xv(()=>s.dispose()),s}let zm=p.createContext(null);zm.displayName="ListboxDataContext";function pd(e){let n=p.useContext(zm);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,pd),s}return n}let j5=p.Fragment;function k5(e,n){let s=p.useId(),r=dv(),{value:o,defaultValue:i,form:c,name:d,onChange:u,by:f,invalid:g=!1,disabled:y=r||!1,horizontal:v=!1,multiple:h=!1,__demoMode:x=!1,...b}=e;const j=v?"horizontal":"vertical";let k=Wn(n),E=DA(i),[S=h?[]:void 0,N]=zA(o,u,E),$=PS({id:s,__demoMode:x}),_=p.useRef({static:!1,hold:!1}),O=p.useRef(new Map),L=h3(f),P=p.useCallback(V=>ss(R.mode,{[Do.Multi]:()=>S.some(se=>L(se,V)),[Do.Single]:()=>L(S,V)}),[S]),R=Ys({value:S,disabled:y,invalid:g,mode:h?Do.Multi:Do.Single,orientation:j,onChange:N,compare:L,isSelected:P,optionsPropsRef:_,listRef:O});tn(()=>{$.state.dataRef.current=R},[R]);let A=Xn($,V=>V.listboxState),M=Em.get(null),F=Xn(M,p.useCallback(V=>M.selectors.isTop(V,s),[M,s])),[I,q]=Xn($,V=>[V.buttonElement,V.optionsElement]);V1(F,[I,q],(V,se)=>{$.send({type:LS.CloseListbox}),B1(se,uv.Loose)||(V.preventDefault(),I==null||I.focus())});let W=Ys({open:A===Fn.Open,disabled:y,invalid:g,value:S}),[K,U]=a3({inherit:!0}),H={ref:k},G=p.useCallback(()=>{if(E!==void 0)return N==null?void 0:N(E)},[N,E]),z=$n();return Ke.createElement(U,{value:K,props:{htmlFor:I==null?void 0:I.id},slot:{open:A===Fn.Open,disabled:y}},Ke.createElement(bO,null,Ke.createElement(MS.Provider,{value:$},Ke.createElement(zm.Provider,{value:R},Ke.createElement(gS,{value:ss(A,{[Fn.Open]:es.Open,[Fn.Closed]:es.Closed})},d!=null&&S!=null&&Ke.createElement(qA,{disabled:y,data:{[d]:S},form:c,onReset:G}),z({ourProps:H,theirProps:b,slot:W,defaultTag:j5,name:"Listbox"}))))))}let N5="button";function S5(e,n){let s=p.useId(),r=S1(),o=pd("Listbox.Button"),i=jv("Listbox.Button"),{id:c=r||`headlessui-listbox-button-${s}`,disabled:d=o.disabled||!1,autoFocus:u=!1,...f}=e,g=Wn(n,pO(),i.actions.setButtonElement),y=gO(),[v,h,x]=Xn(i,q=>[q.listboxState,q.buttonElement,q.optionsElement]),b=v===Fn.Open;z3(b,{trigger:h,action:p.useCallback(q=>{if(h!=null&&h.contains(q.target))return Ku.Ignore;let W=q.target.closest('[role="option"]:not([data-disabled])');return Es(W)?Ku.Select(W):x!=null&&x.contains(q.target)?Ku.Ignore:Ku.Close},[h,x]),close:i.actions.closeListbox,select:i.actions.selectActiveOption});let j=dt(q=>{switch(q.key){case wn.Enter:FA(q.currentTarget);break;case wn.Space:case wn.ArrowDown:q.preventDefault(),i.actions.openListbox({focus:o.value?on.Nothing:on.First});break;case wn.ArrowUp:q.preventDefault(),i.actions.openListbox({focus:o.value?on.Nothing:on.Last});break}}),k=dt(q=>{switch(q.key){case wn.Space:q.preventDefault();break}}),E=g3(q=>{var W;i.state.listboxState===Fn.Open?(Cs.flushSync(()=>i.actions.closeListbox()),(W=i.state.buttonElement)==null||W.focus({preventScroll:!0})):(q.preventDefault(),i.actions.openListbox({focus:on.Nothing}))}),S=dt(q=>q.preventDefault()),N=O1([c]),$=t3(),{isFocusVisible:_,focusProps:O}=jA({autoFocus:u}),{isHovered:L,hoverProps:P}=SA({isDisabled:d}),{pressed:R,pressProps:A}=RA({disabled:d}),M=Ys({open:v===Fn.Open,active:R||v===Fn.Open,disabled:d,invalid:o.invalid,value:o.value,hover:L,focus:_,autofocus:u}),F=Xn(i,q=>q.listboxState===Fn.Open),I=y1(y(),{ref:g,id:c,type:D3(e,h),"aria-haspopup":"listbox","aria-controls":x==null?void 0:x.id,"aria-expanded":F,"aria-labelledby":N,"aria-describedby":$,disabled:d||void 0,autoFocus:u,onKeyDown:j,onKeyUp:k,onKeyPress:S},E,O,P,A);return $n()({ourProps:I,theirProps:f,slot:M,defaultTag:N5,name:"Listbox.Button"})}let IS=p.createContext(!1),C5="div",E5=dl.RenderStrategy|dl.Static;function $5(e,n){let s=p.useId(),{id:r=`headlessui-listbox-options-${s}`,anchor:o,portal:i=!1,modal:c=!0,transition:d=!1,...u}=e,f=hO(o),[g,y]=p.useState(null);f&&(i=!0);let v=pd("Listbox.Options"),h=jv("Listbox.Options"),[x,b,j,k]=Xn(h,ne=>[ne.listboxState,ne.buttonElement,ne.optionsElement,ne.__demoMode]),E=qc(b),S=qc(j),N=md(),[$,_]=X1(d,g,N!==null?(N&es.Open)===es.Open:x===Fn.Open);W1($,b,h.actions.closeListbox);let O=k?!1:c&&x===Fn.Open;Q1(O,S);let L=k?!1:c&&x===Fn.Open;U1(L,{allowed:p.useCallback(()=>[b,j],[b,j])});let P=Xn(h,h.selectors.didButtonMove)?!1:$,R=Xn(h,h.selectors.hasFrozenValue)&&!e.static,A=pS(R,v.value),M=p.useCallback(ne=>v.compare(A,ne),[v.compare,A]),F=Xn(h,ne=>{var me;if(f==null||!((me=f==null?void 0:f.to)!=null&&me.includes("selection")))return null;let ve=ne.options.findIndex(je=>M(je.dataRef.current.value));return ve===-1&&(ve=0),ve}),I=(()=>{if(f==null)return;if(F===null)return{...f,inner:void 0};let ne=Array.from(v.listRef.current.values());return{...f,inner:{listRef:{current:ne},index:F}}})(),[q,W]=vO(I),K=xO(),U=Wn(n,f?q:null,h.actions.setOptionsElement,y),H=ea();p.useEffect(()=>{let ne=j;ne&&x===Fn.Open&&(v1(ne)||ne==null||ne.focus({preventScroll:!0}))},[x,j]);let G=dt(ne=>{var me;switch(H.dispose(),ne.key){case wn.Space:if(h.state.searchQuery!=="")return ne.preventDefault(),ne.stopPropagation(),h.actions.search(ne.key);case wn.Enter:ne.preventDefault(),ne.stopPropagation(),h.actions.selectActiveOption();break;case ss(v.orientation,{vertical:wn.ArrowDown,horizontal:wn.ArrowRight}):return ne.preventDefault(),ne.stopPropagation(),h.actions.goToOption({focus:on.Next});case ss(v.orientation,{vertical:wn.ArrowUp,horizontal:wn.ArrowLeft}):return ne.preventDefault(),ne.stopPropagation(),h.actions.goToOption({focus:on.Previous});case wn.Home:case wn.PageUp:return ne.preventDefault(),ne.stopPropagation(),h.actions.goToOption({focus:on.First});case wn.End:case wn.PageDown:return ne.preventDefault(),ne.stopPropagation(),h.actions.goToOption({focus:on.Last});case wn.Escape:ne.preventDefault(),ne.stopPropagation(),Cs.flushSync(()=>h.actions.closeListbox()),(me=h.state.buttonElement)==null||me.focus({preventScroll:!0});return;case wn.Tab:ne.preventDefault(),ne.stopPropagation(),Cs.flushSync(()=>h.actions.closeListbox()),L3(h.state.buttonElement,ne.shiftKey?dr.Previous:dr.Next);break;default:ne.key.length===1&&(h.actions.search(ne.key),H.setTimeout(()=>h.actions.clearSearch(),350));break}}),z=Xn(h,ne=>{var me;return(me=ne.buttonElement)==null?void 0:me.id}),V=Ys({open:x===Fn.Open}),se=y1(f?K():{},{id:r,ref:U,"aria-activedescendant":Xn(h,h.selectors.activeDescendantId),"aria-multiselectable":v.mode===Do.Multi?!0:void 0,"aria-labelledby":z,"aria-orientation":v.orientation,onKeyDown:G,role:"listbox",tabIndex:x===Fn.Open?0:void 0,style:{...u.style,...W,"--button-width":p3($,b,!0).width},...J1(_)}),J=$n(),re=p.useMemo(()=>v.mode===Do.Multi?v:{...v,isSelected:M},[v,M]);return Ke.createElement(wS,{enabled:i?e.static||$:!1,ownerDocument:E},Ke.createElement(zm.Provider,{value:re},J({ourProps:se,theirProps:u,slot:V,defaultTag:C5,features:E5,visible:P,name:"Listbox.Options"})))}let _5="div";function T5(e,n){let s=p.useId(),{id:r=`headlessui-listbox-option-${s}`,disabled:o=!1,value:i,...c}=e,d=p.useContext(IS)===!0,u=pd("Listbox.Option"),f=jv("Listbox.Option"),g=Xn(f,R=>f.selectors.isActive(R,r)),y=u.isSelected(i),v=p.useRef(null),h=v5(v),x=ta({disabled:o,value:i,domRef:v,get textValue(){return h()}}),b=Wn(n,v,R=>{R?u.listRef.current.set(r,R):u.listRef.current.delete(r)}),j=Xn(f,R=>f.selectors.shouldScrollIntoView(R,r));tn(()=>{if(j)return Ts().requestAnimationFrame(()=>{var R,A;(A=(R=v.current)==null?void 0:R.scrollIntoView)==null||A.call(R,{block:"nearest"})})},[j,v]),tn(()=>{if(!d)return f.actions.registerOption(r,x),()=>f.actions.unregisterOption(r)},[x,r,d]);let k=dt(R=>{if(o)return R.preventDefault();f.actions.selectOption(i)}),E=dt(()=>{if(o)return f.actions.goToOption({focus:on.Nothing});f.actions.goToOption({focus:on.Specific,id:r})}),S=q3(),N=dt(R=>S.update(R)),$=dt(R=>{S.wasMoved(R)&&(o||g&&f.state.activationTrigger===jf.Pointer||f.actions.goToOption({focus:on.Specific,id:r},jf.Pointer))}),_=dt(R=>{S.wasMoved(R)&&(o||g&&f.state.activationTrigger===jf.Pointer&&f.actions.goToOption({focus:on.Nothing}))}),O=Ys({active:g,focus:g,selected:y,disabled:o,selectedOption:y&&d}),L=d?{}:{id:r,ref:b,role:"option",tabIndex:o===!0?void 0:-1,"aria-disabled":o===!0?!0:void 0,"aria-selected":y,disabled:void 0,onClick:k,onFocus:E,onPointerEnter:N,onMouseEnter:N,onPointerMove:$,onMouseMove:$,onPointerLeave:_,onMouseLeave:_},P=$n();return!y&&d?null:P({ourProps:L,theirProps:c,slot:O,defaultTag:_5,name:"Listbox.Option"})}let R5=p.Fragment;function A5(e,n){let{options:s,placeholder:r,...o}=e,i={ref:Wn(n)},c=pd("ListboxSelectedOption"),d=Ys({}),u=c.value===void 0||c.value===null||c.mode===Do.Multi&&Array.isArray(c.value)&&c.value.length===0,f=$n();return Ke.createElement(IS.Provider,{value:!0},f({ourProps:i,theirProps:{...o,children:Ke.createElement(Ke.Fragment,null,r&&u?r:s)},slot:d,defaultTag:R5,name:"ListboxSelectedOption"}))}let O5=vn(k5),zS=vn(S5),L5=d3,DS=vn($5),FS=vn(T5),M5=vn(A5),P5=Object.assign(O5,{Button:zS,Label:L5,Options:DS,Option:FS,SelectedOption:M5});const I5={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function Dm({open:e,onClose:n,title:s,description:r,footer:o,size:i="md",initialFocus:c,hideClose:d,className:u,children:f}){return t.jsxs(g5,{open:e,onClose:n,initialFocus:c,className:"relative z-dialog",children:[t.jsx(p5,{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(AS,{className:ae("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",I5[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(R1,{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(Zo,{"aria-hidden":!0})})]}),f&&t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4 text-body",children:f}),o&&t.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t px-5 py-3",children:o})]})})]})}function kv({open:e,title:n,confirm:s,cancel:r="Cancel",tone:o="destructive",busy:i,onConfirm:c,onCancel:d,children:u}){const f=p.useRef(null);return t.jsx(Dm,{open:e,onClose:i?()=>{}:d,title:n,size:"sm",hideClose:!0,initialFocus:f,footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{ref:f,size:"sm",onClick:d,disabled:i,children:r}),t.jsx(B,{size:"sm",variant:o,onClick:c,disabled:i,"aria-busy":i||void 0,children:s})]}),children:u})}const Nv=p.createContext(null),z5=()=>p.useContext(Nv);function Sv(e){const n=p.useContext(Nv);return{id:e.id??(n==null?void 0:n.id),"aria-describedby":e["aria-describedby"]??(n==null?void 0:n.describedBy),"aria-invalid":e["aria-invalid"]??((n==null?void 0:n.invalid)||void 0),"aria-required":e["aria-required"]??((n==null?void 0:n.required)&&!e.required||void 0)}}function xt({label:e,id:n,required:s,optional:r,note:o,hint:i,error:c,warning:d,aside:u,group:f,className:g,children:y}){const v=p.useId(),h=n??`${v}-control`,[x,b,j,k,E]=[`${v}-label`,`${v}-note`,`${v}-hint`,`${v}-error`,`${v}-warning`],S=[o&&b,i&&j,c&&k,d&&E].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:g,...f===!0?{role:"group","aria-labelledby":x,"aria-describedby":S}:{},children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[f?t.jsx("span",{id:x,className:"caps text-small font-semibold",children:N}):t.jsx("label",{id:x,htmlFor:h,className:"caps text-small font-semibold",children:N}),u]}),o&&t.jsx("p",{id:b,className:"-mt-1 mb-2 text-small text-muted-foreground",children:o}),t.jsx(Nv.Provider,{value:f?null:{id:h,describedBy:S,invalid:!!c,required:!!s},children:y}),i&&t.jsx("p",{id:j,className:"mt-1.5 text-small text-muted-foreground",children:i}),c&&t.jsx("p",{id:k,className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{id:E,className:"mt-2 font-mono text-small text-warning-text",children:d})]})}const US="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",WS="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",gd="xl:columns-2 xl:gap-x-10 2xl:columns-3 [&>*]:mb-5 [&>*]:mt-0 [&>*]:break-inside-avoid",fl="border border-input bg-background hover:border-foreground/60 focus-within:outline focus-within:outline-focus focus-within:outline-ring",Pe=p.forwardRef(({className:e,fieldSize:n="md",bare:s,...r},o)=>t.jsx("input",{ref:o,...r,...Sv(r),className:ae(s?WS:ae(US,n==="sm"?"h-control-sm":"h-control-md"),e)}));Pe.displayName="Input";const nn=p.forwardRef(({className:e,bare:n,...s},r)=>t.jsx("textarea",{ref:r,...s,...Sv(s),className:ae(n?WS:ae(US,"py-2.5"),e)}));nn.displayName="Textarea";const HS=e=>{const n=p.forwardRef(({label:s,note:r,className:o,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",o),children:[t.jsx("input",{ref:d,type:e,disabled:i,...c,...Sv(c),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block",children:s}),r&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:r})]})]}));return n.displayName=e==="checkbox"?"Checkbox":"Radio",n},BS=HS("checkbox");HS("radio");function jr({icon:e,active:n,className:s,children:r,...o}){return t.jsxs("button",{type:"button","aria-current":n?"page":void 0,...o,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 Et({value:e,onChange:n,options:s,label:r,id:o,className:i,disabled:c=!1,name:d,small:u=!1,placeholder:f,autoFocus:g,steady:y=!1}){const v=s.find(x=>x.value===e),h=z5();return t.jsxs(P5,{value:e,onChange:n,disabled:c,name:d,children:[t.jsxs(zS,{id:o??(h==null?void 0:h.id),autoFocus:g,"aria-label":r,"aria-describedby":h==null?void 0:h.describedBy,"aria-invalid":(h==null?void 0:h.invalid)||void 0,"data-value":e,className: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:[y?t.jsxs("span",{className:"grid min-w-0",children:[s.map(x=>t.jsx("span",{"data-picker-sizer":"","aria-hidden":!0,className:"invisible col-start-1 row-start-1 h-0 min-w-0 truncate",children:x.label},x.value)),t.jsx("span",{className:ae("col-start-1 row-start-1 min-w-0 truncate",!v&&"text-muted-foreground"),children:(v==null?void 0:v.label)??f??""})]}):t.jsx("span",{className:ae("min-w-0 truncate",!v&&"text-muted-foreground"),children:(v==null?void 0:v.label)??f??""}),t.jsx(Mr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsx(DS,{anchor:"bottom start","data-picker-list":"",className:ae("z-popover max-h-72 overflow-auto border border-border-strong bg-background py-1 font-mono text-body shadow-float outline-none [--anchor-gap:2px] [--anchor-padding:8px]",y?"w-max min-w-[max(12rem,var(--button-width))] max-w-[calc(100vw-1rem)]":"w-[var(--button-width)] min-w-[12rem]"),children:s.map(x=>t.jsxs(FS,{value:x.value,disabled:x.disabled,title:x.title,"data-value":x.value,className:"group flex min-h-10 cursor-pointer items-center gap-2 px-3 py-2 data-[disabled]:cursor-not-allowed data-[focus]:bg-accent data-[disabled]:opacity-50 data-[selected]:text-foreground",children:[t.jsx(wl,{className:"invisible size-3.5 shrink-0 text-primary-text group-data-[selected]:visible","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 break-words",children:x.label}),x.tag&&t.jsx(Se,{tone:"success",className:"ml-auto",children:x.tag})]},x.value))})]})}function xd({value:e,onChange:n,options:s,label:r,name:o,size:i="md",className:c}){return t.jsx("div",{role:"radiogroup","aria-label":r,className: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:o,value:d.value,checked:e===d.value,disabled:d.disabled,onChange:()=>n(d.value),className:"sr-only"}),d.label]},d.value))})}const D5=["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 F5({value:e,onChange:n,min:s,max:r,label:o,valueText:i,className:c,disabled:d=!1}){return t.jsx("input",{type:"range",min:s,max:r,step:1,value:e,disabled:d,"aria-label":o,"aria-valuetext":i,onChange:u=>n(Number(u.target.value)),className:ae(D5,"h-control-sm cursor-pointer disabled:cursor-not-allowed disabled:opacity-45",c)})}function GS({label:e,className:n}){return t.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[t.jsx(eR,{className:ae("size-4 animate-spin text-run-active",n),"aria-hidden":!0}),e&&t.jsx("span",{className:"sr-only",children:e})]})}function vd({checked:e,onChange:n,disabled:s,label:r,labelledBy:o,busy:i,className:c}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":r,"aria-labelledby":o,"aria-busy":i||void 0,disabled:s||i,onClick:()=>n(!e),className: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")})})}const qS="flex shrink-0 gap-x-4 overflow-x-auto border-b px-5 md:px-8",KS=e=>ae("caps whitespace-nowrap border-b-2 px-1 py-3 text-small -outline-offset-2 first:-ml-1 max-sm:py-2.5",e?"border-primary text-primary-text":"border-transparent text-muted-foreground hover:text-foreground");function VS({tabs:e,value:n,onChange:s,label:r,id:o,className:i}){var f;const c=e.some(g=>g.id===n)?n:(f=e[0])==null?void 0:f.id,d=p.useRef(null),u=g=>{var h,x;const y=e.findIndex(b=>b.id===n),v=g.key==="ArrowRight"?(y+1)%e.length:g.key==="ArrowLeft"?(y-1+e.length)%e.length:g.key==="Home"?0:g.key==="End"?e.length-1:-1;v<0||v===y||(g.preventDefault(),s(e[v].id),(x=(h=d.current)==null?void 0:h.querySelectorAll('[role="tab"]')[v])==null||x.focus())};return t.jsx("div",{ref:d,role:"tablist","aria-label":r,onKeyDown:u,className:ae(qS,i),children:e.map(g=>t.jsx("button",{type:"button",role:"tab",id:o&&`${o}-tab-${g.id}`,"aria-controls":o&&`${o}-panel-${g.id}`,"aria-selected":n===g.id,tabIndex:c===g.id?0:-1,onClick:()=>s(g.id),className:KS(n===g.id),children:g.label},g.id))})}const U5=(e,n)=>({role:"tabpanel",id:`${e}-panel-${n}`,"aria-labelledby":`${e}-tab-${n}`});function W5({tip:e,children:n,className:s,align:r="start"}){const o=p.useId();return t.jsxs("span",{className:ae("group/tip relative inline-flex",s),children:[p.cloneElement(n,{"aria-describedby":o}),t.jsx("span",{role:"tooltip",id:o,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 pr="flex min-h-12 shrink-0 items-center border-b py-1.5",Bo="caps flex items-center gap-2 text-body font-semibold",YS=p.createContext(null),H5={neutral:[Hg,"text-muted-foreground"],success:[UN,"text-success-text"],warning:[Ks,"text-warning-text"],error:[al,"text-destructive-text"]},B5=5e3;function G5(){return p.useContext(YS)??q5}const q5=()=>{};function K5({toast:e,done:n}){const s=p.useCallback(()=>n(e.id),[n,e.id]),r=e.tone??"neutral",o=e.duration??(r==="error"?0:B5),[i,c]=p.useState(!1),[d,u]=p.useState(!1),f=i||d;p.useEffect(()=>{if(!o||f)return;const v=setTimeout(s,o);return()=>clearTimeout(v)},[o,f,s]);const[g,y]=H5[r];return t.jsxs("div",{role:r==="error"?"alert":"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>u(!0),onBlur:()=>u(!1),className:"pointer-events-auto flex w-full items-start gap-3 border border-border-strong bg-card p-3 text-body text-card-foreground shadow-float motion-safe:animate-toast-in",children:[t.jsx(g,{className:ae("mt-0.5 size-4 shrink-0",y),"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"font-semibold",children:e.title}),e.description&&t.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:e.description})]}),t.jsx("button",{type:"button",onClick:s,"aria-label":"Dismiss",className:"-m-1 shrink-0 p-1 text-muted-foreground hover:text-foreground",children:t.jsx(Zo,{className:"size-3.5","aria-hidden":!0})})]})}function V5({children:e}){const[n,s]=p.useState([]),r=p.useRef(0),o=p.useCallback(c=>s(d=>[...d,{...c,id:r.current++}].slice(-3)),[]),i=p.useCallback(c=>s(d=>d.filter(u=>u.id!==c)),[]);return t.jsxs(YS.Provider,{value:o,children:[e,t.jsx("div",{role:"region","aria-label":"Notifications","aria-live":"polite",className:"pointer-events-none fixed inset-x-4 bottom-4 z-toast flex flex-col gap-2 sm:left-auto sm:w-[22rem]",children:n.map(c=>t.jsx(K5,{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:QS,setPrototypeOf:ck,isFrozen:Y5,getPrototypeOf:Q5,getOwnPropertyDescriptor:J5}=Object;let{freeze:rs,seal:Qs,create:JS}=Object,{apply:sx,construct:rx}=typeof Reflect<"u"&&Reflect;rs||(rs=function(n){return n});Qs||(Qs=function(n){return n});sx||(sx=function(n,s,r){return n.apply(s,r)});rx||(rx=function(n,s){return new n(...s)});const Qu=$s(Array.prototype.forEach),dk=$s(Array.prototype.pop),xc=$s(Array.prototype.push),kf=$s(String.prototype.toLowerCase),ug=$s(String.prototype.toString),uk=$s(String.prototype.match),vc=$s(String.prototype.replace),X5=$s(String.prototype.indexOf),Z5=$s(String.prototype.trim),lr=$s(Object.prototype.hasOwnProperty),Jn=$s(RegExp.prototype.test),bc=eL(TypeError);function $s(e){return function(n){for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];return sx(e,n,r)}}function eL(e){return function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return rx(e,s)}}function yt(e,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kf;ck&&ck(e,null);let r=n.length;for(;r--;){let o=n[r];if(typeof o=="string"){const i=s(o);i!==o&&(Y5(n)||(n[r]=i),o=i)}e[o]=!0}return e}function tL(e){for(let n=0;n<e.length;n++)lr(e,n)||(e[n]=null);return e}function Ea(e){const n=JS(null);for(const[s,r]of QS(e))lr(e,s)&&(Array.isArray(r)?n[s]=tL(r):r&&typeof r=="object"&&r.constructor===Object?n[s]=Ea(r):n[s]=r);return n}function yc(e,n){for(;e!==null;){const r=J5(e,n);if(r){if(r.get)return $s(r.get);if(typeof r.value=="function")return $s(r.value)}e=Q5(e)}function s(){return null}return s}const fk=rs(["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"]),fg=rs(["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"]),mg=rs(["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"]),nL=rs(["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"]),hg=rs(["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"]),sL=rs(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),mk=rs(["#text"]),hk=rs(["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"]),pg=rs(["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"]),pk=rs(["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"]),Ju=rs(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),rL=Qs(/\{\{[\w\W]*|[\w\W]*\}\}/gm),oL=Qs(/<%[\w\W]*|[\w\W]*%>/gm),aL=Qs(/\$\{[\w\W]*}/gm),iL=Qs(/^data-[\-\w.\u00B7-\uFFFF]+$/),lL=Qs(/^aria-[\-\w]+$/),XS=Qs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),cL=Qs(/^(?:\w+script|data):/i),dL=Qs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ZS=Qs(/^html$/i),uL=Qs(/^[a-z][.\w]*(-[.\w]+)+$/i);var gk=Object.freeze({__proto__:null,ARIA_ATTR:lL,ATTR_WHITESPACE:dL,CUSTOM_ELEMENT:uL,DATA_ATTR:iL,DOCTYPE_NAME:ZS,ERB_EXPR:oL,IS_ALLOWED_URI:XS,IS_SCRIPT_OR_DATA:cL,MUSTACHE_EXPR:rL,TMPLIT_EXPR:aL});const wc={element:1,text:3,progressingInstruction:7,comment:8,document:9},fL=function(){return typeof window>"u"?null:window},mL=function(n,s){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";s&&s.hasAttribute(o)&&(r=s.getAttribute(o));const i="dompurify"+(r?"#"+r:"");try{return n.createPolicy(i,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},xk=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function e2(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:fL();const n=Be=>e2(Be);if(n.version="3.2.3",n.removed=[],!e||!e.document||e.document.nodeType!==wc.document)return n.isSupported=!1,n;let{document:s}=e;const r=s,o=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:c,Node:d,Element:u,NodeFilter:f,NamedNodeMap:g=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:y,DOMParser:v,trustedTypes:h}=e,x=u.prototype,b=yc(x,"cloneNode"),j=yc(x,"remove"),k=yc(x,"nextSibling"),E=yc(x,"childNodes"),S=yc(x,"parentNode");if(typeof c=="function"){const Be=s.createElement("template");Be.content&&Be.content.ownerDocument&&(s=Be.content.ownerDocument)}let N,$="";const{implementation:_,createNodeIterator:O,createDocumentFragment:L,getElementsByTagName:P}=s,{importNode:R}=r;let A=xk();n.isSupported=typeof QS=="function"&&typeof S=="function"&&_&&_.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:M,ERB_EXPR:F,TMPLIT_EXPR:I,DATA_ATTR:q,ARIA_ATTR:W,IS_SCRIPT_OR_DATA:K,ATTR_WHITESPACE:U,CUSTOM_ELEMENT:H}=gk;let{IS_ALLOWED_URI:G}=gk,z=null;const V=yt({},[...fk,...fg,...mg,...hg,...mk]);let se=null;const J=yt({},[...hk,...pg,...pk,...Ju]);let re=Object.seal(JS(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}})),ne=null,me=null,ve=!0,je=!0,Ve=!1,de=!0,Oe=!1,ze=!0,De=!1,Ne=!1,Q=!1,be=!1,nt=!1,fe=!1,Le=!0,Ye=!1;const ht="user-content-";let ie=!0,Ce=!1,tt={},Ie=null;const at=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 St=null;const st=yt({},["audio","video","img","source","image","track"]);let ut=null;const Dt=yt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ft="http://www.w3.org/1998/Math/MathML",Rt="http://www.w3.org/2000/svg",pe="http://www.w3.org/1999/xhtml";let he=pe,He=!1,Je=null;const X=yt({},[Ft,Rt,pe],ug);let ge=yt({},["mi","mo","mn","ms","mtext"]),_e=yt({},["annotation-xml"]);const Ae=yt({},["title","style","font","a","script"]);let We=null;const gt=["application/xhtml+xml","text/html"],jt="text/html";let it=null,Vt=null;const xs=s.createElement("form"),Xs=function(te){return te instanceof RegExp||te instanceof Function},_n=function(){let te=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Vt&&Vt===te)){if((!te||typeof te!="object")&&(te={}),te=Ea(te),We=gt.indexOf(te.PARSER_MEDIA_TYPE)===-1?jt:te.PARSER_MEDIA_TYPE,it=We==="application/xhtml+xml"?ug:kf,z=lr(te,"ALLOWED_TAGS")?yt({},te.ALLOWED_TAGS,it):V,se=lr(te,"ALLOWED_ATTR")?yt({},te.ALLOWED_ATTR,it):J,Je=lr(te,"ALLOWED_NAMESPACES")?yt({},te.ALLOWED_NAMESPACES,ug):X,ut=lr(te,"ADD_URI_SAFE_ATTR")?yt(Ea(Dt),te.ADD_URI_SAFE_ATTR,it):Dt,St=lr(te,"ADD_DATA_URI_TAGS")?yt(Ea(st),te.ADD_DATA_URI_TAGS,it):st,Ie=lr(te,"FORBID_CONTENTS")?yt({},te.FORBID_CONTENTS,it):at,ne=lr(te,"FORBID_TAGS")?yt({},te.FORBID_TAGS,it):{},me=lr(te,"FORBID_ATTR")?yt({},te.FORBID_ATTR,it):{},tt=lr(te,"USE_PROFILES")?te.USE_PROFILES:!1,ve=te.ALLOW_ARIA_ATTR!==!1,je=te.ALLOW_DATA_ATTR!==!1,Ve=te.ALLOW_UNKNOWN_PROTOCOLS||!1,de=te.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Oe=te.SAFE_FOR_TEMPLATES||!1,ze=te.SAFE_FOR_XML!==!1,De=te.WHOLE_DOCUMENT||!1,be=te.RETURN_DOM||!1,nt=te.RETURN_DOM_FRAGMENT||!1,fe=te.RETURN_TRUSTED_TYPE||!1,Q=te.FORCE_BODY||!1,Le=te.SANITIZE_DOM!==!1,Ye=te.SANITIZE_NAMED_PROPS||!1,ie=te.KEEP_CONTENT!==!1,Ce=te.IN_PLACE||!1,G=te.ALLOWED_URI_REGEXP||XS,he=te.NAMESPACE||pe,ge=te.MATHML_TEXT_INTEGRATION_POINTS||ge,_e=te.HTML_INTEGRATION_POINTS||_e,re=te.CUSTOM_ELEMENT_HANDLING||{},te.CUSTOM_ELEMENT_HANDLING&&Xs(te.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(re.tagNameCheck=te.CUSTOM_ELEMENT_HANDLING.tagNameCheck),te.CUSTOM_ELEMENT_HANDLING&&Xs(te.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(re.attributeNameCheck=te.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),te.CUSTOM_ELEMENT_HANDLING&&typeof te.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(re.allowCustomizedBuiltInElements=te.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Oe&&(je=!1),nt&&(be=!0),tt&&(z=yt({},mk),se=[],tt.html===!0&&(yt(z,fk),yt(se,hk)),tt.svg===!0&&(yt(z,fg),yt(se,pg),yt(se,Ju)),tt.svgFilters===!0&&(yt(z,mg),yt(se,pg),yt(se,Ju)),tt.mathMl===!0&&(yt(z,hg),yt(se,pk),yt(se,Ju))),te.ADD_TAGS&&(z===V&&(z=Ea(z)),yt(z,te.ADD_TAGS,it)),te.ADD_ATTR&&(se===J&&(se=Ea(se)),yt(se,te.ADD_ATTR,it)),te.ADD_URI_SAFE_ATTR&&yt(ut,te.ADD_URI_SAFE_ATTR,it),te.FORBID_CONTENTS&&(Ie===at&&(Ie=Ea(Ie)),yt(Ie,te.FORBID_CONTENTS,it)),ie&&(z["#text"]=!0),De&&yt(z,["html","head","body"]),z.table&&(yt(z,["tbody"]),delete ne.tbody),te.TRUSTED_TYPES_POLICY){if(typeof te.TRUSTED_TYPES_POLICY.createHTML!="function")throw bc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof te.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw bc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=te.TRUSTED_TYPES_POLICY,$=N.createHTML("")}else N===void 0&&(N=mL(h,o)),N!==null&&typeof $=="string"&&($=N.createHTML(""));rs&&rs(te),Vt=te}},Bn=yt({},[...fg,...mg,...nL]),vs=yt({},[...hg,...sL]),bs=function(te){let ye=S(te);(!ye||!ye.tagName)&&(ye={namespaceURI:he,tagName:"template"});const qe=kf(te.tagName),Nt=kf(ye.tagName);return Je[te.namespaceURI]?te.namespaceURI===Rt?ye.namespaceURI===pe?qe==="svg":ye.namespaceURI===Ft?qe==="svg"&&(Nt==="annotation-xml"||ge[Nt]):!!Bn[qe]:te.namespaceURI===Ft?ye.namespaceURI===pe?qe==="math":ye.namespaceURI===Rt?qe==="math"&&_e[Nt]:!!vs[qe]:te.namespaceURI===pe?ye.namespaceURI===Rt&&!_e[Nt]||ye.namespaceURI===Ft&&!ge[Nt]?!1:!vs[qe]&&(Ae[qe]||!Bn[qe]):!!(We==="application/xhtml+xml"&&Je[te.namespaceURI]):!1},mn=function(te){xc(n.removed,{element:te});try{S(te).removeChild(te)}catch{j(te)}},Gn=function(te,ye){try{xc(n.removed,{attribute:ye.getAttributeNode(te),from:ye})}catch{xc(n.removed,{attribute:null,from:ye})}if(ye.removeAttribute(te),te==="is")if(be||nt)try{mn(ye)}catch{}else try{ye.setAttribute(te,"")}catch{}},Rs=function(te){let ye=null,qe=null;if(Q)te="<remove></remove>"+te;else{const lt=uk(te,/^[\r\n\t ]+/);qe=lt&<[0]}We==="application/xhtml+xml"&&he===pe&&(te='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+te+"</body></html>");const Nt=N?N.createHTML(te):te;if(he===pe)try{ye=new v().parseFromString(Nt,We)}catch{}if(!ye||!ye.documentElement){ye=_.createDocument(he,"template",null);try{ye.documentElement.innerHTML=He?$:Nt}catch{}}const It=ye.body||ye.documentElement;return te&&qe&&It.insertBefore(s.createTextNode(qe),It.childNodes[0]||null),he===pe?P.call(ye,De?"html":"body")[0]:De?ye.documentElement:It},qn=function(te){return O.call(te.ownerDocument||te,te,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},As=function(te){return te instanceof y&&(typeof te.nodeName!="string"||typeof te.textContent!="string"||typeof te.removeChild!="function"||!(te.attributes instanceof g)||typeof te.removeAttribute!="function"||typeof te.setAttribute!="function"||typeof te.namespaceURI!="string"||typeof te.insertBefore!="function"||typeof te.hasChildNodes!="function")},Os=function(te){return typeof d=="function"&&te instanceof d};function Ln(Be,te,ye){Qu(Be,qe=>{qe.call(n,te,ye,Vt)})}const ee=function(te){let ye=null;if(Ln(A.beforeSanitizeElements,te,null),As(te))return mn(te),!0;const qe=it(te.nodeName);if(Ln(A.uponSanitizeElement,te,{tagName:qe,allowedTags:z}),te.hasChildNodes()&&!Os(te.firstElementChild)&&Jn(/<[/\w]/g,te.innerHTML)&&Jn(/<[/\w]/g,te.textContent)||te.nodeType===wc.progressingInstruction||ze&&te.nodeType===wc.comment&&Jn(/<[/\w]/g,te.data))return mn(te),!0;if(!z[qe]||ne[qe]){if(!ne[qe]&&mt(qe)&&(re.tagNameCheck instanceof RegExp&&Jn(re.tagNameCheck,qe)||re.tagNameCheck instanceof Function&&re.tagNameCheck(qe)))return!1;if(ie&&!Ie[qe]){const Nt=S(te)||te.parentNode,It=E(te)||te.childNodes;if(It&&Nt){const lt=It.length;for(let jn=lt-1;jn>=0;--jn){const Tn=b(It[jn],!0);Tn.__removalCount=(te.__removalCount||0)+1,Nt.insertBefore(Tn,k(te))}}}return mn(te),!0}return te instanceof u&&!bs(te)||(qe==="noscript"||qe==="noembed"||qe==="noframes")&&Jn(/<\/no(script|embed|frames)/i,te.innerHTML)?(mn(te),!0):(Oe&&te.nodeType===wc.text&&(ye=te.textContent,Qu([M,F,I],Nt=>{ye=vc(ye,Nt," ")}),te.textContent!==ye&&(xc(n.removed,{element:te.cloneNode()}),te.textContent=ye)),Ln(A.afterSanitizeElements,te,null),!1)},Me=function(te,ye,qe){if(Le&&(ye==="id"||ye==="name")&&(qe in s||qe in xs))return!1;if(!(je&&!me[ye]&&Jn(q,ye))){if(!(ve&&Jn(W,ye))){if(!se[ye]||me[ye]){if(!(mt(te)&&(re.tagNameCheck instanceof RegExp&&Jn(re.tagNameCheck,te)||re.tagNameCheck instanceof Function&&re.tagNameCheck(te))&&(re.attributeNameCheck instanceof RegExp&&Jn(re.attributeNameCheck,ye)||re.attributeNameCheck instanceof Function&&re.attributeNameCheck(ye))||ye==="is"&&re.allowCustomizedBuiltInElements&&(re.tagNameCheck instanceof RegExp&&Jn(re.tagNameCheck,qe)||re.tagNameCheck instanceof Function&&re.tagNameCheck(qe))))return!1}else if(!ut[ye]){if(!Jn(G,vc(qe,U,""))){if(!((ye==="src"||ye==="xlink:href"||ye==="href")&&te!=="script"&&X5(qe,"data:")===0&&St[te])){if(!(Ve&&!Jn(K,vc(qe,U,"")))){if(qe)return!1}}}}}}return!0},mt=function(te){return te!=="annotation-xml"&&uk(te,H)},Ot=function(te){Ln(A.beforeSanitizeAttributes,te,null);const{attributes:ye}=te;if(!ye||As(te))return;const qe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:se,forceKeepAttr:void 0};let Nt=ye.length;for(;Nt--;){const It=ye[Nt],{name:lt,namespaceURI:jn,value:Tn}=It,gr=it(lt);let Bt=lt==="value"?Tn:Z5(Tn);if(qe.attrName=gr,qe.attrValue=Bt,qe.keepAttr=!0,qe.forceKeepAttr=void 0,Ln(A.uponSanitizeAttribute,te,qe),Bt=qe.attrValue,Ye&&(gr==="id"||gr==="name")&&(Gn(lt,te),Bt=ht+Bt),ze&&Jn(/((--!?|])>)|<\/(style|title)/i,Bt)){Gn(lt,te);continue}if(qe.forceKeepAttr||(Gn(lt,te),!qe.keepAttr))continue;if(!de&&Jn(/\/>/i,Bt)){Gn(lt,te);continue}Oe&&Qu([M,F,I],co=>{Bt=vc(Bt,co," ")});const li=it(te.nodeName);if(Me(li,gr,Bt)){if(N&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!jn)switch(h.getAttributeType(li,gr)){case"TrustedHTML":{Bt=N.createHTML(Bt);break}case"TrustedScriptURL":{Bt=N.createScriptURL(Bt);break}}try{jn?te.setAttributeNS(jn,lt,Bt):te.setAttribute(lt,Bt),As(te)?mn(te):dk(n.removed)}catch{}}}Ln(A.afterSanitizeAttributes,te,null)},Xt=function Be(te){let ye=null;const qe=qn(te);for(Ln(A.beforeSanitizeShadowDOM,te,null);ye=qe.nextNode();)Ln(A.uponSanitizeShadowNode,ye,null),ee(ye),Ot(ye),ye.content instanceof i&&Be(ye.content);Ln(A.afterSanitizeShadowDOM,te,null)};return n.sanitize=function(Be){let te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ye=null,qe=null,Nt=null,It=null;if(He=!Be,He&&(Be="<!-->"),typeof Be!="string"&&!Os(Be))if(typeof Be.toString=="function"){if(Be=Be.toString(),typeof Be!="string")throw bc("dirty is not a string, aborting")}else throw bc("toString is not a function");if(!n.isSupported)return Be;if(Ne||_n(te),n.removed=[],typeof Be=="string"&&(Ce=!1),Ce){if(Be.nodeName){const Tn=it(Be.nodeName);if(!z[Tn]||ne[Tn])throw bc("root node is forbidden and cannot be sanitized in-place")}}else if(Be instanceof d)ye=Rs("<!---->"),qe=ye.ownerDocument.importNode(Be,!0),qe.nodeType===wc.element&&qe.nodeName==="BODY"||qe.nodeName==="HTML"?ye=qe:ye.appendChild(qe);else{if(!be&&!Oe&&!De&&Be.indexOf("<")===-1)return N&&fe?N.createHTML(Be):Be;if(ye=Rs(Be),!ye)return be?null:fe?$:""}ye&&Q&&mn(ye.firstChild);const lt=qn(Ce?Be:ye);for(;Nt=lt.nextNode();)ee(Nt),Ot(Nt),Nt.content instanceof i&&Xt(Nt.content);if(Ce)return Be;if(be){if(nt)for(It=L.call(ye.ownerDocument);ye.firstChild;)It.appendChild(ye.firstChild);else It=ye;return(se.shadowroot||se.shadowrootmode)&&(It=R.call(r,It,!0)),It}let jn=De?ye.outerHTML:ye.innerHTML;return De&&z["!doctype"]&&ye.ownerDocument&&ye.ownerDocument.doctype&&ye.ownerDocument.doctype.name&&Jn(ZS,ye.ownerDocument.doctype.name)&&(jn="<!DOCTYPE "+ye.ownerDocument.doctype.name+`>
|
|
523
|
-
`+jn),Oe&&Qu([M,F,I],Tn=>{jn=vc(jn,Tn," ")}),N&&fe?N.createHTML(jn):jn},n.setConfig=function(){let Be=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_n(Be),Ne=!0},n.clearConfig=function(){Vt=null,Ne=!1},n.isValidAttribute=function(Be,te,ye){Vt||_n({});const qe=it(Be),Nt=it(te);return Me(qe,Nt,ye)},n.addHook=function(Be,te){typeof te=="function"&&xc(A[Be],te)},n.removeHook=function(Be){return dk(A[Be])},n.removeHooks=function(Be){A[Be]=[]},n.removeAllHooks=function(){A=xk()},n}var Nf=e2();function Cv(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let si=Cv();function t2(e){si=e}const zc={exec:()=>null};function zt(e,n=""){let s=typeof e=="string"?e:e.source;const r={replace:(o,i)=>{let c=typeof i=="string"?i:i.source;return c=c.replace(ts.caret,"$1"),s=s.replace(o,c),r},getRegex:()=>new RegExp(s,n)};return r}const ts={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")},hL=/^(?:[ \t]*(?:\n|$))+/,pL=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,gL=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bd=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,xL=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,n2=/(?:[*+-]|\d{1,9}[.)])/,s2=zt(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,n2).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(),Ev=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,vL=/^[^\n]+/,$v=/(?!\s*\])(?:\\.|[^\[\]\\])+/,bL=zt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",$v).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),yL=zt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,n2).getRegex(),Fm="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",_v=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,wL=zt("^ {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",_v).replace("tag",Fm).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),r2=zt(Ev).replace("hr",bd).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",Fm).getRegex(),jL=zt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",r2).getRegex(),Tv={blockquote:jL,code:pL,def:bL,fences:gL,heading:xL,hr:bd,html:wL,lheading:s2,list:yL,newline:hL,paragraph:r2,table:zc,text:vL},vk=zt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bd).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",Fm).getRegex(),kL={...Tv,table:vk,paragraph:zt(Ev).replace("hr",bd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",vk).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",Fm).getRegex()},NL={...Tv,html:zt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",_v).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:zc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:zt(Ev).replace("hr",bd).replace("heading",` *#{1,6} *[^
|
|
524
|
-
]`).replace("lheading",s2).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},SL=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,CL=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,o2=/^( {2,}|\\)\n(?!\s*$)/,EL=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Um=/[\p{P}\p{S}]/u,Rv=/[\s\p{P}\p{S}]/u,a2=/[^\s\p{P}\p{S}]/u,$L=zt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Rv).getRegex(),i2=/(?!~)[\p{P}\p{S}]/u,_L=/(?!~)[\s\p{P}\p{S}]/u,TL=/(?:[^\s\p{P}\p{S}]|~)/u,RL=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,l2=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,AL=zt(l2,"u").replace(/punct/g,Um).getRegex(),OL=zt(l2,"u").replace(/punct/g,i2).getRegex(),c2="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",LL=zt(c2,"gu").replace(/notPunctSpace/g,a2).replace(/punctSpace/g,Rv).replace(/punct/g,Um).getRegex(),ML=zt(c2,"gu").replace(/notPunctSpace/g,TL).replace(/punctSpace/g,_L).replace(/punct/g,i2).getRegex(),PL=zt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,a2).replace(/punctSpace/g,Rv).replace(/punct/g,Um).getRegex(),IL=zt(/\\(punct)/,"gu").replace(/punct/g,Um).getRegex(),zL=zt(/^<(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(),DL=zt(_v).replace("(?:-->|$)","-->").getRegex(),FL=zt("^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",DL).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Df=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,UL=zt(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Df).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),d2=zt(/^!?\[(label)\]\[(ref)\]/).replace("label",Df).replace("ref",$v).getRegex(),u2=zt(/^!?\[(ref)\](?:\[\])?/).replace("ref",$v).getRegex(),WL=zt("reflink|nolink(?!\\()","g").replace("reflink",d2).replace("nolink",u2).getRegex(),Av={_backpedal:zc,anyPunctuation:IL,autolink:zL,blockSkip:RL,br:o2,code:CL,del:zc,emStrongLDelim:AL,emStrongRDelimAst:LL,emStrongRDelimUnd:PL,escape:SL,link:UL,nolink:u2,punctuation:$L,reflink:d2,reflinkSearch:WL,tag:FL,text:EL,url:zc},HL={...Av,link:zt(/^!?\[(label)\]\((.*?)\)/).replace("label",Df).getRegex(),reflink:zt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Df).getRegex()},ox={...Av,emStrongRDelimAst:ML,emStrongLDelim:OL,url:zt(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},BL={...ox,br:zt(o2).replace("{2,}","*").getRegex(),text:zt(ox.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Xu={normal:Tv,gfm:kL,pedantic:NL},jc={normal:Av,gfm:ox,breaks:BL,pedantic:HL},GL={"&":"&","<":"<",">":">",'"':""","'":"'"},bk=e=>GL[e];function Sr(e,n){if(n){if(ts.escapeTest.test(e))return e.replace(ts.escapeReplace,bk)}else if(ts.escapeTestNoEncode.test(e))return e.replace(ts.escapeReplaceNoEncode,bk);return e}function yk(e){try{e=encodeURI(e).replace(ts.percentDecode,"%")}catch{return null}return e}function wk(e,n){var i;const s=e.replace(ts.findPipe,(c,d,u)=>{let f=!1,g=d;for(;--g>=0&&u[g]==="\\";)f=!f;return f?"|":" |"}),r=s.split(ts.splitPipe);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.trim())&&r.pop(),n)if(r.length>n)r.splice(n);else for(;r.length<n;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(ts.slashPipe,"|");return r}function kc(e,n,s){const r=e.length;if(r===0)return"";let o=0;for(;o<r&&e.charAt(r-o-1)===n;)o++;return e.slice(0,r-o)}function qL(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 jk(e,n,s,r,o){const i=n.href,c=n.title||null,d=e[1].replace(o.other.outputLinkReplace,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const u={type:"link",raw:s,href:i,title:c,text:d,tokens:r.inlineTokens(d)};return r.state.inLink=!1,u}return{type:"image",raw:s,href:i,title:c,text:d}}function KL(e,n,s){const r=e.match(s.other.indentCodeCompensation);if(r===null)return n;const o=r[1];return n.split(`
|
|
525
|
-
`).map(i=>{const c=i.match(s.other.beginningSpace);if(c===null)return i;const[d]=c;return d.length>=o.length?i.slice(o.length):i}).join(`
|
|
526
|
-
`)}class Ff{constructor(n){At(this,"options");At(this,"rules");At(this,"lexer");this.options=n||si}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:kc(r,`
|
|
527
|
-
`)}}}fences(n){const s=this.rules.block.fences.exec(n);if(s){const r=s[0],o=KL(r,s[3]||"",this.rules);return{type:"code",raw:r,lang:s[2]?s[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):s[2],text:o}}}heading(n){const s=this.rules.block.heading.exec(n);if(s){let r=s[2].trim();if(this.rules.other.endingHash.test(r)){const o=kc(r,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceChar.test(o))&&(r=o.trim())}return{type:"heading",raw:s[0],depth:s[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(n){const s=this.rules.block.hr.exec(n);if(s)return{type:"hr",raw:kc(s[0],`
|
|
528
|
-
`)}}blockquote(n){const s=this.rules.block.blockquote.exec(n);if(s){let r=kc(s[0],`
|
|
529
|
-
`).split(`
|
|
530
|
-
`),o="",i="";const c=[];for(;r.length>0;){let d=!1;const u=[];let f;for(f=0;f<r.length;f++)if(this.rules.other.blockquoteStart.test(r[f]))u.push(r[f]),d=!0;else if(!d)u.push(r[f]);else break;r=r.slice(f);const g=u.join(`
|
|
531
|
-
`),y=g.replace(this.rules.other.blockquoteSetextReplace,`
|
|
532
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
|
|
533
|
-
${g}`:g,i=i?`${i}
|
|
534
|
-
${y}`:y;const v=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(y,c,!0),this.lexer.state.top=v,r.length===0)break;const h=c.at(-1);if((h==null?void 0:h.type)==="code")break;if((h==null?void 0:h.type)==="blockquote"){const x=h,b=x.raw+`
|
|
535
|
-
`+r.join(`
|
|
536
|
-
`),j=this.blockquote(b);c[c.length-1]=j,o=o.substring(0,o.length-x.raw.length)+j.raw,i=i.substring(0,i.length-x.text.length)+j.text;break}else if((h==null?void 0:h.type)==="list"){const x=h,b=x.raw+`
|
|
537
|
-
`+r.join(`
|
|
538
|
-
`),j=this.list(b);c[c.length-1]=j,o=o.substring(0,o.length-h.raw.length)+j.raw,i=i.substring(0,i.length-x.raw.length)+j.raw,r=b.substring(c.at(-1).raw.length).split(`
|
|
539
|
-
`);continue}}return{type:"blockquote",raw:o,tokens:c,text:i}}}list(n){let s=this.rules.block.list.exec(n);if(s){let r=s[1].trim();const o=r.length>1,i={type:"list",raw:"",ordered:o,start:o?+r.slice(0,-1):"",loose:!1,items:[]};r=o?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=o?r:"[*+-]");const c=this.rules.other.listItemRegex(r);let d=!1;for(;n;){let f=!1,g="",y="";if(!(s=c.exec(n))||this.rules.block.hr.test(n))break;g=s[0],n=n.substring(g.length);let v=s[2].split(`
|
|
540
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,E=>" ".repeat(3*E.length)),h=n.split(`
|
|
541
|
-
`,1)[0],x=!v.trim(),b=0;if(this.options.pedantic?(b=2,y=v.trimStart()):x?b=s[1].length+1:(b=s[2].search(this.rules.other.nonSpaceChar),b=b>4?1:b,y=v.slice(b),b+=s[1].length),x&&this.rules.other.blankLine.test(h)&&(g+=h+`
|
|
542
|
-
`,n=n.substring(h.length+1),f=!0),!f){const E=this.rules.other.nextBulletRegex(b),S=this.rules.other.hrRegex(b),N=this.rules.other.fencesBeginRegex(b),$=this.rules.other.headingBeginRegex(b),_=this.rules.other.htmlBeginRegex(b);for(;n;){const O=n.split(`
|
|
543
|
-
`,1)[0];let L;if(h=O,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),L=h):L=h.replace(this.rules.other.tabCharGlobal," "),N.test(h)||$.test(h)||_.test(h)||E.test(h)||S.test(h))break;if(L.search(this.rules.other.nonSpaceChar)>=b||!h.trim())y+=`
|
|
544
|
-
`+L.slice(b);else{if(x||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(v)||$.test(v)||S.test(v))break;y+=`
|
|
545
|
-
`+h}!x&&!h.trim()&&(x=!0),g+=O+`
|
|
546
|
-
`,n=n.substring(O.length+1),v=L.slice(b)}}i.loose||(d?i.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(d=!0));let j=null,k;this.options.gfm&&(j=this.rules.other.listIsTask.exec(y),j&&(k=j[0]!=="[ ] ",y=y.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:g,task:!!j,checked:k,loose:!1,text:y,tokens:[]}),i.raw+=g}const u=i.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let f=0;f<i.items.length;f++)if(this.lexer.state.top=!1,i.items[f].tokens=this.lexer.blockTokens(i.items[f].text,[]),!i.loose){const g=i.items[f].tokens.filter(v=>v.type==="space"),y=g.length>0&&g.some(v=>this.rules.other.anyLine.test(v.raw));i.loose=y}if(i.loose)for(let f=0;f<i.items.length;f++)i.items[f].loose=!0;return i}}html(n){const s=this.rules.block.html.exec(n);if(s)return{type:"html",block:!0,raw:s[0],pre:s[1]==="pre"||s[1]==="script"||s[1]==="style",text:s[0]}}def(n){const s=this.rules.block.def.exec(n);if(s){const r=s[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),o=s[2]?s[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=s[3]?s[3].substring(1,s[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):s[3];return{type:"def",tag:r,raw:s[0],href:o,title:i}}}table(n){var d;const s=this.rules.block.table.exec(n);if(!s||!this.rules.other.tableDelimiter.test(s[2]))return;const r=wk(s[1]),o=s[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(d=s[3])!=null&&d.trim()?s[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
547
|
-
`):[],c={type:"table",raw:s[0],header:[],align:[],rows:[]};if(r.length===o.length){for(const u of o)this.rules.other.tableAlignRight.test(u)?c.align.push("right"):this.rules.other.tableAlignCenter.test(u)?c.align.push("center"):this.rules.other.tableAlignLeft.test(u)?c.align.push("left"):c.align.push(null);for(let u=0;u<r.length;u++)c.header.push({text:r[u],tokens:this.lexer.inline(r[u]),header:!0,align:c.align[u]});for(const u of i)c.rows.push(wk(u,c.header.length).map((f,g)=>({text:f,tokens:this.lexer.inline(f),header:!1,align:c.align[g]})));return c}}lheading(n){const s=this.rules.block.lheading.exec(n);if(s)return{type:"heading",raw:s[0],depth:s[2].charAt(0)==="="?1:2,text:s[1],tokens:this.lexer.inline(s[1])}}paragraph(n){const s=this.rules.block.paragraph.exec(n);if(s){const r=s[1].charAt(s[1].length-1)===`
|
|
548
|
-
`?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=kc(r.slice(0,-1),"\\");if((r.length-c.length)%2===0)return}else{const c=qL(s[2],"()");if(c>-1){const u=(s[0].indexOf("!")===0?5:4)+s[1].length+c;s[2]=s[2].substring(0,c),s[0]=s[0].substring(0,u).trim(),s[3]=""}}let o=s[2],i="";if(this.options.pedantic){const c=this.rules.other.pedanticHrefTitle.exec(o);c&&(o=c[1],i=c[3])}else i=s[3]?s[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?o=o.slice(1):o=o.slice(1,-1)),jk(s,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},s[0],this.lexer,this.rules)}}reflink(n,s){let r;if((r=this.rules.inline.reflink.exec(n))||(r=this.rules.inline.nolink.exec(n))){const o=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=s[o.toLowerCase()];if(!i){const c=r[0].charAt(0);return{type:"text",raw:c,text:c}}return jk(r,i,r[0],this.lexer,this.rules)}}emStrong(n,s,r=""){let o=this.rules.inline.emStrongLDelim.exec(n);if(!o||o[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(o[1]||o[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const c=[...o[0]].length-1;let d,u,f=c,g=0;const y=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(y.lastIndex=0,s=s.slice(-1*n.length+c);(o=y.exec(s))!=null;){if(d=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!d)continue;if(u=[...d].length,o[3]||o[4]){f+=u;continue}else if((o[5]||o[6])&&c%3&&!((c+u)%3)){g+=u;continue}if(f-=u,f>0)continue;u=Math.min(u,u+f+g);const v=[...o[0]][0].length,h=n.slice(0,c+o.index+v+u);if(Math.min(c,u)%2){const b=h.slice(1,-1);return{type:"em",raw:h,text:b,tokens:this.lexer.inlineTokens(b)}}const x=h.slice(2,-2);return{type:"strong",raw:h,text:x,tokens:this.lexer.inlineTokens(x)}}}}codespan(n){const s=this.rules.inline.code.exec(n);if(s){let r=s[2].replace(this.rules.other.newLineCharGlobal," ");const o=this.rules.other.nonSpaceChar.test(r),i=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return o&&i&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:s[0],text:r}}}br(n){const s=this.rules.inline.br.exec(n);if(s)return{type:"br",raw:s[0]}}del(n){const s=this.rules.inline.del.exec(n);if(s)return{type:"del",raw:s[0],text:s[2],tokens:this.lexer.inlineTokens(s[2])}}autolink(n){const s=this.rules.inline.autolink.exec(n);if(s){let r,o;return s[2]==="@"?(r=s[1],o="mailto:"+r):(r=s[1],o=r),{type:"link",raw:s[0],text:r,href:o,tokens:[{type:"text",raw:r,text:r}]}}}url(n){var r;let s;if(s=this.rules.inline.url.exec(n)){let o,i;if(s[2]==="@")o=s[0],i="mailto:"+o;else{let c;do c=s[0],s[0]=((r=this.rules.inline._backpedal.exec(s[0]))==null?void 0:r[0])??"";while(c!==s[0]);o=s[0],s[1]==="www."?i="http://"+s[0]:i=s[0]}return{type:"link",raw:s[0],text:o,href:i,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(n){const s=this.rules.inline.text.exec(n);if(s){const r=this.lexer.state.inRawBlock;return{type:"text",raw:s[0],text:s[0],escaped:r}}}}class Ws{constructor(n){At(this,"tokens");At(this,"options");At(this,"state");At(this,"tokenizer");At(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||si,this.options.tokenizer=this.options.tokenizer||new Ff,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:ts,block:Xu.normal,inline:jc.normal};this.options.pedantic?(s.block=Xu.pedantic,s.inline=jc.pedantic):this.options.gfm&&(s.block=Xu.gfm,this.options.breaks?s.inline=jc.breaks:s.inline=jc.gfm),this.tokenizer.rules=s}static get rules(){return{block:Xu,inline:jc}}static lex(n,s){return new Ws(s).lex(n)}static lexInline(n,s){return new Ws(s).inlineTokens(n)}lex(n){n=n.replace(ts.carriageReturn,`
|
|
549
|
-
`),this.blockTokens(n,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){const r=this.inlineQueue[s];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(n,s=[],r=!1){var o,i,c;for(this.options.pedantic&&(n=n.replace(ts.tabCharGlobal," ").replace(ts.spaceLine,""));n;){let d;if((i=(o=this.options.extensions)==null?void 0:o.block)!=null&&i.some(f=>(d=f.call({lexer:this},n,s))?(n=n.substring(d.raw.length),s.push(d),!0):!1))continue;if(d=this.tokenizer.space(n)){n=n.substring(d.raw.length);const f=s.at(-1);d.raw.length===1&&f!==void 0?f.raw+=`
|
|
550
|
-
`: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+=`
|
|
551
|
-
`+d.raw,f.text+=`
|
|
552
|
-
`+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+=`
|
|
553
|
-
`+d.raw,f.text+=`
|
|
554
|
-
`+d.raw,this.inlineQueue.at(-1).src=f.text):this.tokens.links[d.tag]||(this.tokens.links[d.tag]={href:d.href,title:d.title});continue}if(d=this.tokenizer.table(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.lheading(n)){n=n.substring(d.raw.length),s.push(d);continue}let u=n;if((c=this.options.extensions)!=null&&c.startBlock){let f=1/0;const g=n.slice(1);let y;this.options.extensions.startBlock.forEach(v=>{y=v.call({lexer:this},g),typeof y=="number"&&y>=0&&(f=Math.min(f,y))}),f<1/0&&f>=0&&(u=n.substring(0,f+1))}if(this.state.top&&(d=this.tokenizer.paragraph(u))){const f=s.at(-1);r&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=`
|
|
555
|
-
`+d.raw,f.text+=`
|
|
556
|
-
`+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+=`
|
|
557
|
-
`+d.raw,f.text+=`
|
|
558
|
-
`+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):s.push(d);continue}if(n){const f="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(f);break}else throw new Error(f)}}return this.state.top=!0,s}inline(n,s=[]){return this.inlineQueue.push({src:n,tokens:s}),s}inlineTokens(n,s=[]){var d,u,f;let r=n,o=null;if(this.tokens.links){const g=Object.keys(this.tokens.links);if(g.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)g.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,o.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i=!1,c="";for(;n;){i||(c=""),i=!1;let g;if((u=(d=this.options.extensions)==null?void 0:d.inline)!=null&&u.some(v=>(g=v.call({lexer:this},n,s))?(n=n.substring(g.raw.length),s.push(g),!0):!1))continue;if(g=this.tokenizer.escape(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.tag(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.link(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.reflink(n,this.tokens.links)){n=n.substring(g.raw.length);const v=s.at(-1);g.type==="text"&&(v==null?void 0:v.type)==="text"?(v.raw+=g.raw,v.text+=g.text):s.push(g);continue}if(g=this.tokenizer.emStrong(n,r,c)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.codespan(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.br(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.del(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.autolink(n)){n=n.substring(g.raw.length),s.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(n))){n=n.substring(g.raw.length),s.push(g);continue}let y=n;if((f=this.options.extensions)!=null&&f.startInline){let v=1/0;const h=n.slice(1);let x;this.options.extensions.startInline.forEach(b=>{x=b.call({lexer:this},h),typeof x=="number"&&x>=0&&(v=Math.min(v,x))}),v<1/0&&v>=0&&(y=n.substring(0,v+1))}if(g=this.tokenizer.inlineText(y)){n=n.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(c=g.raw.slice(-1)),i=!0;const v=s.at(-1);(v==null?void 0:v.type)==="text"?(v.raw+=g.raw,v.text+=g.text):s.push(g);continue}if(n){const v="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(v);break}else throw new Error(v)}}return s}}class Uf{constructor(n){At(this,"options");At(this,"parser");this.options=n||si}space(n){return""}code({text:n,lang:s,escaped:r}){var c;const o=(c=(s||"").match(ts.notSpaceStart))==null?void 0:c[0],i=n.replace(ts.endingNewline,"")+`
|
|
559
|
-
`;return o?'<pre><code class="language-'+Sr(o)+'">'+(r?i:Sr(i,!0))+`</code></pre>
|
|
560
|
-
`:"<pre><code>"+(r?i:Sr(i,!0))+`</code></pre>
|
|
561
|
-
`}blockquote({tokens:n}){return`<blockquote>
|
|
562
|
-
${this.parser.parse(n)}</blockquote>
|
|
563
|
-
`}html({text:n}){return n}heading({tokens:n,depth:s}){return`<h${s}>${this.parser.parseInline(n)}</h${s}>
|
|
564
|
-
`}hr(n){return`<hr>
|
|
565
|
-
`}list(n){const s=n.ordered,r=n.start;let o="";for(let d=0;d<n.items.length;d++){const u=n.items[d];o+=this.listitem(u)}const i=s?"ol":"ul",c=s&&r!==1?' start="'+r+'"':"";return"<"+i+c+`>
|
|
566
|
-
`+o+"</"+i+`>
|
|
567
|
-
`}listitem(n){var r;let s="";if(n.task){const o=this.checkbox({checked:!!n.checked});n.loose?((r=n.tokens[0])==null?void 0:r.type)==="paragraph"?(n.tokens[0].text=o+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=o+" "+Sr(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:o+" ",text:o+" ",escaped:!0}):s+=o+" "}return s+=this.parser.parse(n.tokens,!!n.loose),`<li>${s}</li>
|
|
568
|
-
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
569
|
-
`}table(n){let s="",r="";for(let i=0;i<n.header.length;i++)r+=this.tablecell(n.header[i]);s+=this.tablerow({text:r});let o="";for(let i=0;i<n.rows.length;i++){const c=n.rows[i];r="";for(let d=0;d<c.length;d++)r+=this.tablecell(c[d]);o+=this.tablerow({text:r})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
|
|
570
|
-
<thead>
|
|
571
|
-
`+s+`</thead>
|
|
572
|
-
`+o+`</table>
|
|
573
|
-
`}tablerow({text:n}){return`<tr>
|
|
574
|
-
${n}</tr>
|
|
575
|
-
`}tablecell(n){const s=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+s+`</${r}>
|
|
576
|
-
`}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>${Sr(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:s,tokens:r}){const o=this.parser.parseInline(r),i=yk(n);if(i===null)return o;n=i;let c='<a href="'+n+'"';return s&&(c+=' title="'+Sr(s)+'"'),c+=">"+o+"</a>",c}image({href:n,title:s,text:r}){const o=yk(n);if(o===null)return Sr(r);n=o;let i=`<img src="${n}" alt="${r}"`;return s&&(i+=` title="${Sr(s)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:Sr(n.text)}}class Ov{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 Hs{constructor(n){At(this,"options");At(this,"renderer");At(this,"textRenderer");this.options=n||si,this.options.renderer=this.options.renderer||new Uf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ov}static parse(n,s){return new Hs(s).parse(n)}static parseInline(n,s){return new Hs(s).parseInline(n)}parse(n,s=!0){var o,i;let r="";for(let c=0;c<n.length;c++){const d=n[c];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[d.type]){const f=d,g=this.options.extensions.renderers[f.type].call({parser:this},f);if(g!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type)){r+=g||"";continue}}const u=d;switch(u.type){case"space":{r+=this.renderer.space(u);continue}case"hr":{r+=this.renderer.hr(u);continue}case"heading":{r+=this.renderer.heading(u);continue}case"code":{r+=this.renderer.code(u);continue}case"table":{r+=this.renderer.table(u);continue}case"blockquote":{r+=this.renderer.blockquote(u);continue}case"list":{r+=this.renderer.list(u);continue}case"html":{r+=this.renderer.html(u);continue}case"paragraph":{r+=this.renderer.paragraph(u);continue}case"text":{let f=u,g=this.renderer.text(f);for(;c+1<n.length&&n[c+1].type==="text";)f=n[++c],g+=`
|
|
577
|
-
`+this.renderer.text(f);s?r+=this.renderer.paragraph({type:"paragraph",raw:g,text:g,tokens:[{type:"text",raw:g,text:g,escaped:!0}]}):r+=g;continue}default:{const f='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}parseInline(n,s=this.renderer){var o,i;let r="";for(let c=0;c<n.length;c++){const d=n[c];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[d.type]){const f=this.options.extensions.renderers[d.type].call({parser:this},d);if(f!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(d.type)){r+=f||"";continue}}const u=d;switch(u.type){case"escape":{r+=s.text(u);break}case"html":{r+=s.html(u);break}case"link":{r+=s.link(u);break}case"image":{r+=s.image(u);break}case"strong":{r+=s.strong(u);break}case"em":{r+=s.em(u);break}case"codespan":{r+=s.codespan(u);break}case"br":{r+=s.br(u);break}case"del":{r+=s.del(u);break}case"text":{r+=s.text(u);break}default:{const f='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}}class Dc{constructor(n){At(this,"options");At(this,"block");this.options=n||si}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Ws.lex:Ws.lexInline}provideParser(){return this.block?Hs.parse:Hs.parseInline}}At(Dc,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class VL{constructor(...n){At(this,"defaults",Cv());At(this,"options",this.setOptions);At(this,"parse",this.parseMarkdown(!0));At(this,"parseInline",this.parseMarkdown(!1));At(this,"Parser",Hs);At(this,"Renderer",Uf);At(this,"TextRenderer",Ov);At(this,"Lexer",Ws);At(this,"Tokenizer",Ff);At(this,"Hooks",Dc);this.use(...n)}walkTokens(n,s){var o,i;let r=[];for(const c of n)switch(r=r.concat(s.call(this,c)),c.type){case"table":{const d=c;for(const u of d.header)r=r.concat(this.walkTokens(u.tokens,s));for(const u of d.rows)for(const f of u)r=r.concat(this.walkTokens(f.tokens,s));break}case"list":{const d=c;r=r.concat(this.walkTokens(d.items,s));break}default:{const d=c;(i=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&i[d.type]?this.defaults.extensions.childTokens[d.type].forEach(u=>{const f=d[u].flat(1/0);r=r.concat(this.walkTokens(f,s))}):d.tokens&&(r=r.concat(this.walkTokens(d.tokens,s)))}}return r}use(...n){const s=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(r=>{const o={...r};if(o.async=this.defaults.async||o.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const c=s.renderers[i.name];c?s.renderers[i.name]=function(...d){let u=i.renderer.apply(this,d);return u===!1&&(u=c.apply(this,d)),u}:s.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const c=s[i.level];c?c.unshift(i.tokenizer):s[i.level]=[i.tokenizer],i.start&&(i.level==="block"?s.startBlock?s.startBlock.push(i.start):s.startBlock=[i.start]:i.level==="inline"&&(s.startInline?s.startInline.push(i.start):s.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(s.childTokens[i.name]=i.childTokens)}),o.extensions=s),r.renderer){const i=this.defaults.renderer||new Uf(this.defaults);for(const c in r.renderer){if(!(c in i))throw new Error(`renderer '${c}' does not exist`);if(["options","parser"].includes(c))continue;const d=c,u=r.renderer[d],f=i[d];i[d]=(...g)=>{let y=u.apply(i,g);return y===!1&&(y=f.apply(i,g)),y||""}}o.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new Ff(this.defaults);for(const c in r.tokenizer){if(!(c in i))throw new Error(`tokenizer '${c}' does not exist`);if(["options","rules","lexer"].includes(c))continue;const d=c,u=r.tokenizer[d],f=i[d];i[d]=(...g)=>{let y=u.apply(i,g);return y===!1&&(y=f.apply(i,g)),y}}o.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new Dc;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];Dc.passThroughHooks.has(c)?i[d]=g=>{if(this.defaults.async)return Promise.resolve(u.call(i,g)).then(v=>f.call(i,v));const y=u.call(i,g);return f.call(i,y)}:i[d]=(...g)=>{let y=u.apply(i,g);return y===!1&&(y=f.apply(i,g)),y}}o.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,c=r.walkTokens;o.walkTokens=function(d){let u=[];return u.push(c.call(this,d)),i&&(u=u.concat(i.call(this,d))),u}}this.defaults={...this.defaults,...o}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,s){return Ws.lex(n,s??this.defaults)}parser(n,s){return Hs.parse(n,s??this.defaults)}parseMarkdown(n){return(r,o)=>{const i={...o},c={...this.defaults,...i},d=this.onError(!!c.silent,!!c.async);if(this.defaults.async===!0&&i.async===!1)return d(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return d(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return d(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));c.hooks&&(c.hooks.options=c,c.hooks.block=n);const u=c.hooks?c.hooks.provideLexer():n?Ws.lex:Ws.lexInline,f=c.hooks?c.hooks.provideParser():n?Hs.parse:Hs.parseInline;if(c.async)return Promise.resolve(c.hooks?c.hooks.preprocess(r):r).then(g=>u(g,c)).then(g=>c.hooks?c.hooks.processAllTokens(g):g).then(g=>c.walkTokens?Promise.all(this.walkTokens(g,c.walkTokens)).then(()=>g):g).then(g=>f(g,c)).then(g=>c.hooks?c.hooks.postprocess(g):g).catch(d);try{c.hooks&&(r=c.hooks.preprocess(r));let g=u(r,c);c.hooks&&(g=c.hooks.processAllTokens(g)),c.walkTokens&&this.walkTokens(g,c.walkTokens);let y=f(g,c);return c.hooks&&(y=c.hooks.postprocess(y)),y}catch(g){return d(g)}}}onError(n,s){return r=>{if(r.message+=`
|
|
578
|
-
Please report this to https://github.com/markedjs/marked.`,n){const o="<p>An error occurred:</p><pre>"+Sr(r.message+"",!0)+"</pre>";return s?Promise.resolve(o):o}if(s)return Promise.reject(r);throw r}}}const Ga=new VL;function Pt(e,n){return Ga.parse(e,n)}Pt.options=Pt.setOptions=function(e){return Ga.setOptions(e),Pt.defaults=Ga.defaults,t2(Pt.defaults),Pt};Pt.getDefaults=Cv;Pt.defaults=si;Pt.use=function(...e){return Ga.use(...e),Pt.defaults=Ga.defaults,t2(Pt.defaults),Pt};Pt.walkTokens=function(e,n){return Ga.walkTokens(e,n)};Pt.parseInline=Ga.parseInline;Pt.Parser=Hs;Pt.parser=Hs.parse;Pt.Renderer=Uf;Pt.TextRenderer=Ov;Pt.Lexer=Ws;Pt.lexer=Ws.lex;Pt.Tokenizer=Ff;Pt.Hooks=Dc;Pt.parse=Pt;Pt.options;Pt.setOptions;Pt.use;Pt.walkTokens;Pt.parseInline;Hs.parse;Ws.lex;let Nc;const YL=e=>(Nc||(Nf.addHook("uponSanitizeElement",(n,s)=>{Nc??(Nc=s.allowedTags)}),Nf.sanitize("<b></b>"),Nf.removeHook("uponSanitizeElement")),(Nc==null?void 0:Nc[e.toLowerCase()])===!0),QL=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,(o,i)=>YL(i)?(s++,o):QL(o));return n&&!s&&r!==e?`<p>${r.trim().replace(/\n/g,`<br>
|
|
579
|
-
`)}</p>
|
|
580
|
-
`:r}}});const sa=e=>e.slice(-8),qa=e=>new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),ft=e=>new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function Ka(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const f2=e=>e.basis==="estimate",so=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Wf=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")}`},_l=e=>e&&e.usd===null&&typeof e.so_far_usd=="number"&&typeof e.unpriced=="number"?e:void 0,kk=(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.`,JL=new Set(["completed","failed","cancelled"]),Va=e=>typeof e=="string"&&JL.has(e),XL="$0 · free model",m2=e=>e.usd===0&&e.free===!0,h2=e=>e.upper_bound===!0?"at most ":"",ZL=(e,{ended:n=!1}={})=>e.usd!==null?`${h2(e)}${so(e.usd)}`:typeof e.so_far_usd=="number"?n?`${Wf(e.so_far_usd)} known, ${e.unpriced??0} not priced`:`so far ${Wf(e.so_far_usd)}, ${e.unpriced??0} not priced`:"not priced";function ro(e,{ended:n=!1}={}){const s=yd(e);if(s&&(e==null?void 0:e.usd)===0)return`${p2(s.tokens)} tokens · Using ChatGPT plan`;const r=eM(e,n);return s?`${r} + ChatGPT plan`:r}function eM(e,n){const s=_l(e),r=o=>f2(o)?" est.":"";return s?n?`${Wf(s.so_far_usd)}${r(s)} known · ${s.unpriced} not priced`:`so far ${Wf(s.so_far_usd)}${r(s)} · ${s.unpriced} not priced`:!e||e.usd===null?"Unknown":m2(e)?XL:`${h2(e)}${so(e.usd)}${r(e)}`}const yd=e=>e!=null&&e.plan&&e.plan.requests>0?e.plan:void 0;function p2(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 Nk(e,n,{ended:s=!1,text:r}={}){const o=r??ro(e,{ended:s});return typeof n!="number"?o:(r!==void 0?tM.test(r):!_l(e)&&!yd(e)&&!!e&&e.usd!==null&&!m2(e))?`${o} of ${Sk(n)}`:`${o} · cap ${Sk(n)}`}const tM=/^<?\$[\d.,]+( est\.)?$/;function Sk(e){for(let n=2;n<8;n++)if(Number(e.toFixed(n))===e)return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}function nM(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 oo(e,n){const s=Nf.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 o=r.getAttribute("href").trim();if(/^(https?|ftps?):/i.test(o)){r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer");continue}if(/^[a-z][a-z\d+.-]*:/i.test(o))continue;const i=n&&nM(o,n);if(i){const c=r.ownerDocument.createElement("button");c.type="button",c.title=`Open ${i}`,c.dataset.runFile=i,c.append(...r.childNodes),r.replaceWith(c)}else r.replaceWith(...r.childNodes)}return s.innerHTML}const Lv=e=>n=>{var r,o,i;const s=(i=(o=(r=n.target).closest)==null?void 0:o.call(r,"[data-run-file]"))==null?void 0:i.getAttribute("data-run-file");s&&(n.preventDefault(),e(s))},sM=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 En(e){const{title:n}=e;if(!e.trigger)return n;let s=n.search(/<trigger-payload\b/);if(s<0){const o=/<([a-z-]*)…$/.exec(n);if(!o||!"trigger-payload".startsWith(o[1]))return n;s=o.index}return n.slice(0,s).trim()||sM(n.slice(s))}function rM(e,n){if(n.unchanged&&!n.reset&&!n.drop.length&&!n.rows.length)return e;const s=new Map;if(!n.reset)for(const r of e)s.set(r.id,r);for(const r of n.drop)s.delete(r);for(const r of n.rows)s.set(r.id,r);return[...s.values()].sort((r,o)=>r.seq-o.seq)}const g2=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,x2=e=>e.refused===!0,v2=e=>e.tool_status==="failed"&&!x2(e)||e.kind==="error",oM=e=>e.paused===!0;function aM(e){const n=new Map(e.filter(f=>f.kind==="tool_result"&&f.tool_use_id).map(f=>[f.tool_use_id,f])),s=new Set(e.filter(f=>f.kind==="tool_use"&&f.tool_use_id).map(f=>f.tool_use_id)),r=new Set(e.filter(f=>f.kind==="waiting"&&f.id.endsWith(":waiting")).map(f=>f.id.slice(0,-8))),o=f=>{var g;return r.has(f.id)||(f.tool_use_id?r.has(((g=n.get(f.tool_use_id))==null?void 0:g.id)??""):!1)},i=e.findLast(f=>f.kind==="usage"),c=[],d=new Map;let u;for(const f of e){if(f.kind==="usage")continue;if(f.tool_name==="ask_person"&&(f.kind==="tool_use"||f.kind==="tool_result")&&o(f)){u=void 0;continue}if(f.kind==="tool_result"&&f.tool_use_id&&s.has(f.tool_use_id)){u=d.get(f.tool_use_id);continue}if(f.kind==="phase"&&f.path&&u&&(u.row.kind==="tool_result"||u.row.kind==="tool_use")&&!u.saved){u.saved=f.path;continue}const g=c.at(-1);if(f.kind==="error"&&(g==null?void 0:g.row.kind)==="error"&&g.row.summary===f.summary&&g.row.text===f.text&&(g.row.agent_label??null)===(f.agent_label??null)){g.times=(g.times??1)+1,g.until=f.timestamp,u=g;continue}let y;const v=f.kind==="tool_use"&&f.tool_use_id?n.get(f.tool_use_id):void 0;if(v){const h=v.tool_status!=="failed",x=[f.tool_input_preview,v.tool_result_preview].filter(Boolean),b=v.tool_status!==null;y={row:{...v,id:f.id,seq:f.seq,timestamp:f.timestamp,summary:h?(v.summary??"").replace(/:\s*ok$/i,""):v.summary,...f.usage?{usage:f.usage}:{}},...b?{ms:Math.max(0,Date.parse(v.timestamp)-Date.parse(f.timestamp))}:{},detail:x.length===2?`${x[0]}
|
|
581
|
-
|
|
582
|
-
→ ${x[1]}`:x[0]??null}}else y={row:f};c.push(y),f.kind==="tool_use"&&f.tool_use_id&&d.set(f.tool_use_id,y),u=y}return i&&c.push({row:i}),c}class Ue extends Error{constructor(s,r,o,i=!1,c){super(o);At(this,"fields");At(this,"retryAfterMs");At(this,"details");At(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 Wt=e=>e instanceof Ue?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),Ck=(e,n,{status:s,archived:r}={})=>{const o=new URLSearchParams({limit:String(e)});return n&&o.set("cursor",n),s&&o.set("status",s),r&&o.set("archived","true"),`?${o}`},iM=new Set(["/auth/sign-in","/setup"]);function lM({fetch:e=globalThis.fetch.bind(globalThis),base:n="/v2",onSignedOut:s}={}){async function r(x,b,j={}){return(await o(x,b,j)).body}async function o(x,b,{body:j,headers:k={},signal:E,text:S=!1}={}){var O;const N=j!==void 0||x!=="GET"&&x!=="HEAD",$=await e(`${n}${b}`,{method:x,signal:E,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&&!iM.has(b)&&(s==null||s());const L=(O=await $.json().catch(()=>null))==null?void 0:O.error,P=new Ue($.status,(L==null?void 0:L.code)??"http_error",(L==null?void 0:L.message)??`${x} ${b}: ${$.status}`,(L==null?void 0:L.retryable)??!1,L==null?void 0:L.request_id);throw L!=null&&L.fields&&(P.fields=L.fields),typeof(L==null?void 0:L.retry_after_ms)=="number"&&(P.retryAfterMs=L.retry_after_ms),L!=null&&L.details&&typeof L.details=="object"&&!Array.isArray(L.details)&&(P.details=L.details),Array.isArray(L==null?void 0:L.problems)&&(P.problems=L.problems),P}return{body:!S&&($.headers.get("content-type")??"").includes("json")?await $.json():await $.text(),etag:$.headers.get("etag"),status:$.status}}const i=x=>`/agents/${encodeURIComponent(x)}`,c=x=>`/runs/${encodeURIComponent(x)}`,d=(x,b,j)=>`${i(x)}/learning/workflows/${encodeURIComponent(b)}/revisions/${encodeURIComponent(j)}/replays`,u=x=>`/settings/mcp-servers/${encodeURIComponent(x)}`,f=x=>`/triggers/${encodeURIComponent(x)}`,g=new Map,y=(x,b)=>`${i(x)}/learning/files/${encodeURIComponent(b)}`,v=x=>({note:x.body,etag:x.etag}),h={accept:"text/markdown, application/json"};return{capabilities:()=>r("GET","/capabilities"),session:()=>o("GET","/auth/session").then(x=>({status:x.status,body:x.body})),signIn:x=>r("POST","/auth/sign-in",{body:{password:x}}),setup:(x,b,j=[])=>r("POST","/setup",{body:{password:x,...b?{code:b}:{},...j.length?{import:[...j]}:{}}}),setupImport:()=>r("GET","/setup/import").then(x=>(x==null?void 0:x.offer)===!1?null:x,x=>{if(x instanceof Ue&&(x.status===404||x.status===403))return null;throw x}),signOut:()=>r("POST","/auth/sign-out",{body:{}}),setupCode:()=>r("POST","/setup/code",{body:{}}),signOutEverywhere:()=>r("POST","/auth/sign-out-everywhere",{body:{}}),stats:()=>r("GET","/stats"),listRuns:(x=50,b,j)=>r("GET",`/runs${Ck(x,b,j)}`),listAgentRuns:(x,b=50,j,k={})=>r("GET",`${i(x)}/runs${Ck(b,j,typeof k=="boolean"?{archived:k}:k)}`),discoverNative:(x,b)=>r("POST","/native/discover",{body:{project:x,...b?{runtime:b}:{}}}),connectNative:x=>r("POST","/native/connect",{body:x}),getNative:x=>r("GET",`${i(x)}/native`),verifyNative:x=>r("POST",`${i(x)}/native/verify`,{body:{}}),disconnectNative:x=>r("POST",`${i(x)}/native/disconnect`,{body:{}}),observations:({days:x=30,sessionId:b}={},j)=>{const k=new URLSearchParams({days:String(x)});return b&&k.set("session_id",b),r("GET",`/observations?${k}`,{signal:j})},listConnectors:()=>r("GET","/connectors"),enrollConnector:(x,b)=>r("POST","/connectors/enrollment",{body:{...x!=null&&x.trim()?{label:x.trim()}:{},...b?{capabilities:b}:{}}}),revokeConnector:x=>r("DELETE",`/connectors/${encodeURIComponent(x)}`),listAgents:({archived:x=!1,cursor:b}={})=>{const j=new URLSearchParams;return x&&j.set("archived","true"),b&&j.set("cursor",b),r("GET",`/agents${j.size?`?${j}`:""}`)},getAgent:async x=>{const b=await o("GET",i(x)),j=g.get(x);return{agent:j&&j.revision===b.body.revision&&!b.body.warnings?{...b.body,warnings:j.warnings}:b.body,etag:b.etag}},createAgent:async x=>{var j;const b=await r("POST","/agents",{body:x});return(j=b.warnings)!=null&&j.length&&g.set(b.agent_id,{revision:b.revision,warnings:b.warnings}),b},updateDefinition:async(x,b,j)=>{const k=await o("PUT",`${i(x)}/definition`,{body:b,headers:j?{"if-match":j}:{}});return g.delete(x),{agent:k.body,etag:k.etag}},listRevisions:(x,b)=>r("GET",`${i(x)}/revisions${b?`?cursor=${encodeURIComponent(b)}`:""}`),setCurrent:async(x,b)=>{const j=await r("POST",`${i(x)}/current`,{body:{revision:b}});return g.delete(x),j},archiveAgent:x=>r("POST",`${i(x)}/archive`,{body:{}}),unarchiveAgent:x=>r("POST",`${i(x)}/unarchive`,{body:{}}),agentLearning:x=>r("GET",`${i(x)}/learning`),learningCost:(x,b)=>r("GET",`${i(x)}/learning/cost${b?`?limit=${b}`:""}`),learningBatches:x=>r("GET",`${i(x)}/learning/batches`),learningBatch:(x,b)=>r("GET",`${i(x)}/learning/batches/${encodeURIComponent(b)}`),startLearningBatch:(x,b)=>r("POST",`${i(x)}/learning/batches`,{body:b}),cancelLearningBatch:(x,b)=>r("POST",`${i(x)}/learning/batches/${encodeURIComponent(b)}/cancel`,{body:{}}),learningEvals:x=>r("GET",`${i(x)}/learning/evals`),learningPromotions:x=>r("GET",`${i(x)}/learning/promotions`),learningLoop:x=>r("GET",`${i(x)}/learning/loop`),learningAudits:x=>r("GET",`${i(x)}/learning/audits`),learnedWorkflowRevisions:(x,b,j)=>r("GET",`${i(x)}/learning/workflows/${encodeURIComponent(b)}/revisions${j?`?limit=${j}`:""}`),startLearnedWorkflowReplay:(x,b,j)=>r("POST",`${d(x,b,j)}`,{body:{}}),learnedWorkflowReplay:(x,b,j,k)=>r("GET",`${d(x,b,j)}/${encodeURIComponent(k)}`),learningNotes:(x,b)=>r("GET",`${i(x)}/learning/notes?cursor=${encodeURIComponent(b)}`),learningLog:(x,b)=>r("GET",`${i(x)}/learning/log?cursor=${encodeURIComponent(b)}`),readNote:async(x,b)=>v(await o("GET",y(x,b),{headers:h,text:!0})),writeNote:async(x,b,j,k)=>v(await o("PUT",y(x,b),{body:{text:j},headers:{...h,..."etag"in k?{"if-match":k.etag}:{"if-none-match":"*"}},text:!0})),retireNote:async(x,b,j)=>v(await o("POST",`${y(x,b)}/retire`,{body:{},headers:{...h,"if-match":j},text:!0})),approveNote:async(x,b,j)=>v(await o("POST",`${y(x,b)}/approve`,{body:{},headers:{...h,"if-match":j},text:!0})),restoreNote:async(x,b,j)=>v(await o("POST",`${y(x,b)}/restore`,{body:{},headers:{...h,"if-match":j},text:!0})),forgetSignIn:(x,b)=>r("DELETE",`${i(x)}/sign-ins/${encodeURIComponent(b)}`),promoteWorkflow:async(x,b,j)=>{var E;const k=await r("POST",`${i(x)}/learning/workflows/${encodeURIComponent(b)}/promote`,{body:{},headers:{"idempotency-key":j}});return(E=k.warnings)!=null&&E.length&&g.set(k.agent_id,{revision:k.revision,warnings:k.warnings}),k},getRun:x=>r("GET",c(x)),runLearningResult:x=>r("GET",`${c(x)}/learning`),runLearningDiff:x=>r("GET",`${c(x)}/learning/diff`),runLearning:x=>r("GET",`${c(x)}/learning`),runComputer:x=>r("GET",`${c(x)}/computer`),takeOverComputer:x=>r("POST",`${c(x)}/computer/take-over`,{body:{}}),handBackComputer:(x,b)=>r("POST",`${c(x)}/computer/hand-back`,{body:b?{outcome:b}:{}}),archiveRun:x=>r("POST",`${c(x)}/archive`,{body:{}}),unarchiveRun:x=>r("POST",`${c(x)}/unarchive`,{body:{}}),raiseCap:(x,b)=>r("PATCH",c(x),{body:{max_cost_usd:b}}),gradeRun:(x,b)=>r("PUT",`${c(x)}/grade`,{body:b}),startRun:async(x,b,j)=>{const k=await o("POST",`${i(x)}/runs`,{body:b,headers:{"idempotency-key":j}});return{run:k.body,status:k.status}},getTimeline:(x,{after:b,waitMs:j,signal:k}={})=>{const E=new URLSearchParams;return b!==void 0&&E.set("after",String(b)),j!==void 0&&E.set("wait_ms",String(j)),r("GET",`${c(x)}/timeline${E.size?`?${E}`:""}`,{signal:k})},listFiles:x=>r("GET",`${c(x)}/files`),deleteUpload:x=>r("DELETE",`/files/${encodeURIComponent(x)}`),readFile:(x,b)=>r("GET",`${c(x)}/files/${b.split("/").map(encodeURIComponent).join("/")}`,{text:!0}),sendMessage:(x,b,j)=>r("POST",`${c(x)}/messages`,{body:{content:b},headers:{"idempotency-key":j}}),getRunGraph:(x,b)=>r("GET",`${c(x)}/graph`,{signal:b}),pauseRun:x=>r("POST",`${c(x)}/pause`,{body:{}}),resumeRun:x=>r("POST",`${c(x)}/resume`,{body:{}}),validateWorkflow:(x,b)=>r("POST","/workflows/validate",{body:x,signal:b}),statsOver:({from:x,agent:b})=>{const j=new URLSearchParams;return x&&j.set("from",x),b&&j.set("agent",b),r("GET",`/stats${j.size?`?${j}`:""}`)},fileUrl:(x,b)=>`${n}${c(x)}/files/${b.split("/").map(encodeURIComponent).join("/")}`,listToolKeys:()=>r("GET","/settings/tool-keys"),saveToolKey:(x,b)=>r("PUT",`/settings/tool-keys/${encodeURIComponent(x)}`,{body:{values:b}}),removeToolKey:x=>r("DELETE",`/settings/tool-keys/${encodeURIComponent(x)}`),chatGPT:()=>r("GET","/settings/chatgpt"),startChatGPT:()=>r("POST","/settings/chatgpt/sign-in"),finishChatGPT:x=>r("POST","/settings/chatgpt/sign-in/finish",{body:{redirect_url:x}}),signOutChatGPT:()=>r("DELETE","/settings/chatgpt"),computers:()=>r("GET","/computers"),saveComputerKeys:(x,b)=>r("PUT",`/computers/${encodeURIComponent(x)}/keys`,{body:b}),testComputer:x=>r("POST",`/computers/${encodeURIComponent(x)}/test`),computerChoices:x=>r("GET",`/computers/${encodeURIComponent(x)}/choices`),createPairing:()=>r("POST","/computers/pairings"),removeComputer:x=>r("DELETE",`/computers/${encodeURIComponent(x)}`),archil:()=>r("GET","/workspace/archil"),saveArchil:x=>r("PUT","/workspace/archil",{body:x}),archilOff:()=>r("DELETE","/workspace/archil"),testArchil:()=>r("POST","/workspace/archil/test"),webhook:()=>r("GET","/settings/webhook"),saveWebhook:x=>r("PUT","/settings/webhook",{body:{url:x}}),removeWebhook:()=>r("DELETE","/settings/webhook"),testWebhook:()=>r("POST","/settings/webhook/test",{body:{}}),emailAccount:()=>r("GET","/settings/email"),saveEmailAccount:x=>r("PUT","/settings/email",{body:x}),removeEmailAccount:()=>r("DELETE","/settings/email"),testEmailAccount:(x={})=>r("POST","/settings/email/test",{body:x}),listTriggers:()=>r("GET","/triggers"),getTrigger:x=>r("GET",f(x)),createTrigger:(x,b)=>r("POST","/triggers",{body:x,headers:{"idempotency-key":b}}),rotateTriggerSecret:x=>r("POST",`${f(x)}/secret`),updateTrigger:(x,b)=>r("PATCH",f(x),{body:b}),deleteTrigger:x=>r("DELETE",f(x)),fireTrigger:(x,b)=>r("POST",`${f(x)}/fire`,{body:{},headers:{"idempotency-key":b}}),triggerFirings:x=>r("GET",`${f(x)}/firings`),webhookDeliveries:()=>r("GET","/settings/webhook/deliveries"),redeliverWebhook:x=>r("POST",`/settings/webhook/deliveries/${encodeURIComponent(x)}/redeliver`,{body:{}}),listTemplates:()=>r("GET","/templates"),applyTemplate:(x,b,j)=>r("POST",`/templates/${encodeURIComponent(x)}/apply`,{body:b,headers:{"idempotency-key":j}}),importTemplate:(x,b={})=>r("POST","/templates/import",{body:{source:x,...b.dryRun?{dry_run:!0}:{},...b.trustPublisher?{trust_publisher:!0}:{}}}),deleteTemplate:x=>r("DELETE",`/templates/${encodeURIComponent(x)}`),listMcpServers:()=>r("GET","/settings/mcp-servers"),previewMcpServer:(x,b,j)=>r("POST","/settings/mcp-servers/preview",{body:{url:x,auth:b,...j?{name:j}:{}}}),saveMcpServer:(x,b,j,k={})=>r("PUT",u(x),{body:{url:b,auth:j,...k}}),composioTools:(x,b)=>r("POST","/settings/mcp-servers/composio/tools",{body:{api_key:x,toolkit:b}}),saveComposioServer:(x,b,j,k)=>r("PUT",`${u(x)}/composio`,{body:{api_key:b,toolkit:j,tools:k}}),refreshMcpServer:x=>r("POST",`${u(x)}/refresh`,{body:{}}),deleteMcpServer:x=>r("DELETE",u(x)),composioEvents:x=>r("GET",`${u(x)}/composio/events`),composioTriggers:x=>r("GET",`${u(x)}/composio/triggers`),rotateComposioSecret:x=>r("POST",`${u(x)}/composio/rotate-secret`,{body:{}}),deleteComposioSubscription:x=>r("DELETE",`${u(x)}/composio/subscription`),startMcpSignIn:(x,b)=>r("POST",`${u(x)}/oauth/start`,{body:b}),mcpPrivateHosts:()=>r("GET","/settings/mcp-servers/oauth/private-hosts"),saveMcpPrivateHosts:x=>r("PUT","/settings/mcp-servers/oauth/private-hosts",{body:{hosts:x}}),githubConnection:()=>r("GET","/integrations/github"),connectGitHub:x=>r("POST","/integrations/github/connect",{body:x?{org:x}:{}}),disconnectGitHub:()=>r("DELETE","/integrations/github"),toolSettings:()=>r("GET","/settings/tools"),saveToolSettings:x=>r("PUT","/settings/tools",{body:x}),stop:x=>r("POST",`${c(x)}/stop`,{body:{}}),answerApproval:(x,b,j,k,E)=>r("POST",`${c(x)}/approvals/${encodeURIComponent(b)}`,{body:{decision:j,...k?{note:k}:{},...E?{confirm_destructive:!0}:{}}}),cancel:x=>r("POST",`${c(x)}/cancel`,{body:{}})}}async function Qr(e,n,s=100){const r=[];let o=null;for(let i=0;i<s;i++){const c=await e(o);if(r.push(...n(c)),!c.next_cursor)break;o=c.next_cursor}return r}async function b2(e,n,{onRows:s,onPage:r,signal:o,waitMs:i=25e3,minDelayMs:c=250}){let d=[],u,f;for(;!(o!=null&&o.aborted);){const g=await e.getTimeline(n,u===void 0?{signal:o}:{after:u,waitMs:i,signal:o}).catch(v=>{if(o!=null&&o.aborted)return null;throw v});if(!g||o!=null&&o.aborted||(f=g,s&&(d=rM(d,g)),r==null||r(g),s==null||s(d),g.final&&!g.has_more))break;u=g.next_after;const y=Math.max(c,g.unchanged?g.poll_after_ms??0:0);y&&await new Promise(v=>setTimeout(v,y))}return f}const Ek=e=>`#/observations/${encodeURIComponent(e)}`,Hf=e=>e==="claude"?"Claude Code":e==="codex"?"Codex":e;function _a(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 ax=e=>{const n=_a(e);return n==="Running"?"success":["Needs input","Disconnected","Failed"].includes(n)?"warning":"muted"},Ta=e=>e==null?"—":e.toLocaleString("en-US");function Mv(e,{active:n=!0,days:s=30,sessionId:r}={}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,y]=p.useState(!1);return p.useEffect(()=>{i(null),d(null)},[e,n,s,r]),p.useEffect(()=>{let v=!0;if(!n||typeof e.observations!="function"){y(!1);return}let h=null,x,b;const j=async()=>{if(!v||h)return;clearTimeout(x);const E=h=new AbortController,S=()=>v&&h===E;y(!0);const N=()=>{clearTimeout($),S()&&(h=null,b=void 0,y(!1),clearTimeout(x),x=setTimeout(k,15e3))},$=b=setTimeout(()=>{S()&&(d("The observation read timed out. Try refreshing again."),E.abort(),N())},3e4);try{const _=await e.observations({days:s,sessionId:r},E.signal);S()&&(i(_),d(null))}catch(_){S()&&(_ instanceof Ue&&_.status===404?(i(null),d(null)):d(Wt(_)))}finally{N()}},k=()=>{!v||h||(document.hidden?(clearTimeout(x),x=setTimeout(k,15e3)):j())};return j(),window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{v=!1,clearTimeout(x),clearTimeout(b),h==null||h.abort(),h=null,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[e,n,s,r,u]),{data:o,error:c,loading:g,refresh:()=>f(v=>v+1)}}function Pv({read:e,view:n="table",query:s="",days:r=30}){const{data:o,error:i,refresh:c}=e,d=o==null?void 0:o.connectors.some(f=>f.storage_full);if(!(o!=null&&o.sessions.length)&&!i&&!d)return null;const u=((o==null?void 0:o.sessions)??[]).filter(f=>`${f.display_name} ${f.harness} ${f.models.join(" ")}`.toLowerCase().includes(s.toLowerCase()));return t.jsxs("section",{className:"space-y-4","aria-label":"Observed sessions",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("div",{className:"mr-auto",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-lead font-semibold",children:[t.jsx(KN,{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(Xo,{className:"size-4","aria-hidden":!0})})]}),d&&t.jsx(bt,{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(bt,{tone:"error",children:["Could not refresh observed sessions: ",i]}),n==="summary"&&o&&t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsx("dl",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[["Retained sessions",u.length],["Running",u.filter(f=>_a(f)==="Running").length],["Needs input",u.filter(f=>_a(f)==="Needs input").length],["Disconnected",u.filter(f=>_a(f)==="Disconnected").length]].map(([f,g])=>t.jsxs("div",{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:f}),t.jsx("dd",{className:"mt-2 font-mono text-figure",children:g})]},f))}),t.jsxs("h3",{className:"text-body font-semibold",children:["Observed token usage · last ",r," days"]}),o.usage.status==="unavailable"?t.jsx("p",{className:"text-small text-muted-foreground",children:o.usage.overflow?"Combined token totals are too large to display reliably. Open individual sessions for exact counters.":"Token usage has not been reported."}):t.jsxs(t.Fragment,{children:[t.jsx(y2,{usage:o.usage}),t.jsx(cM,{models:o.usage.models}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Reported tokens only. Input includes cache reads and writes; cache hit rate is cache reads divided by input. Idle does not mean a task completed."})]})]}),n==="summary"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Session totals cover retained reports, independently of the aggregate range."}),u.length?n==="cards"?t.jsx("ul",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 2xl:grid-cols-3",children:u.map(f=>t.jsx("li",{className:"border p-5 transition-colors hover:border-border-strong",children:t.jsxs("a",{href:Ek(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(hr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Se,{children:Hf(f.harness)}),t.jsx(Se,{tone:ax(f),children:_a(f)}),t.jsx(Se,{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 ",ft(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(Se,{tone:ax(f),children:_a(f)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("a",{href:Ek(f.id),className:"inline-flex items-center gap-1 underline underline-offset-2",children:[f.display_name,t.jsx(hr,{className:"size-3 shrink-0","aria-hidden":!0})]})}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:Hf(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"?"—":Ta(f.usage.total_tokens)}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:ft(f.received_at)})]},f.id))})]})}):t.jsx("p",{className:"text-body text-muted-foreground",children:"No observed session matches."})]})}function y2({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",Ta(e.input_tokens)],["Output",Ta(e.output_tokens)],["Cache writes",Ta(e.cache_write_tokens)],["Cache reads",Ta(e.cache_read_tokens)],["Total tokens",Ta(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 cM({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:Ta(s)},r))]},n.model))})]})}):null}function dM({v2:e,sessionId:n,go:s}){var i;const r=Mv(e,{sessionId:n}),o=(i=r.data)==null?void 0:i.sessions.find(c=>c.id===n);return t.jsxs("section",{className:"flex min-h-full flex-col","aria-label":"Observed session detail",children:[t.jsxs("header",{className:ae(pr,"flex-wrap gap-2 px-5"),children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>s("#/agents"),children:t.jsx(On,{"aria-hidden":!0})}),t.jsx(KN,{className:"size-4","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 flex-1 truncate text-body",children:(o==null?void 0:o.display_name)??"Observed session"}),t.jsx(B,{size:"icon","aria-label":"Refresh session",disabled:r.loading,onClick:r.refresh,children:t.jsx(Xo,{"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(bt,{tone:"error",children:["Could not read this session: ",r.error]}),o?t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold",children:o.display_name}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[t.jsx(Se,{tone:"muted",children:"Observed"}),t.jsx(Se,{tone:ax(o),children:_a(o)}),t.jsx(Se,{children:Hf(o.harness)})]})]}),t.jsx(bt,{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",Hf(o.harness)],["Model",o.models.join(", ")||"Not reported"],["Connection",o.connection_state],["Last reported activity",o.reported_activity],["First seen",ft(o.created_at)],["Last received",ft(o.received_at)],["Session",o.id],["Connector",o.connector_id]].map(([c,d])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:c}),t.jsx("dd",{className:"mt-1 break-all text-body",children:d})]},c))}),t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Session token usage",children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Reported token usage · retained session"}),t.jsx(y2,{usage:o.usage}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Session totals cover retained reports. Input includes cache reads and writes. Missing cache counters are shown as a dash. Activity signals do not establish a completed task or its outcome."})]})]}):t.jsx("p",{className:"text-body text-muted-foreground",children:r.loading?"Loading observed session…":r.data?"This session was not found.":"Observed sessions are unavailable on this server."})]})]})}function Iv(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 uM=800,fM=16;function gg(){const e=p.useRef(null);return p.useEffect(()=>{const n=e.current;if(!n)return;let s;const r=()=>{n.setAttribute("data-scrolling",""),clearTimeout(s),s=setTimeout(()=>n.removeAttribute("data-scrolling"),uM)},o=c=>n.toggleAttribute("data-scroll-lane",c.clientX>=n.getBoundingClientRect().right-fM),i=()=>n.removeAttribute("data-scroll-lane");return n.addEventListener("scroll",r,{passive:!0}),n.addEventListener("pointermove",o,{passive:!0}),n.addEventListener("pointerleave",i),()=>{n.removeEventListener("scroll",r),n.removeEventListener("pointermove",o),n.removeEventListener("pointerleave",i),clearTimeout(s),n.removeAttribute("data-scrolling"),n.removeAttribute("data-scroll-lane")}},[]),e}const Qt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),mM=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),ix=128,hM=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},lx=(e,n=0)=>n>ix?'"…"':Array.isArray(e)?`[${e.map(s=>lx(s,n+1)).join(",")}]`:Qt(e)?`{${Object.keys(e).filter(s=>e[s]!==void 0).sort().map(s=>`${JSON.stringify(s)}:${lx(e[s],n+1)}`).join(",")}}`:hM(e),pM=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")},Sc=(e,n)=>Object.fromEntries(Object.entries(e).filter(([s])=>s!==n)),gM=e=>{switch(e.node){case"chain":return Sc(e,"steps");case"parallel":return Sc(e,"branches");case"map":case"loop":return Sc(e,"body");case"route":return Qt(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([n,s])=>[n,Qt(s)?Sc(s,"body"):s]))}:e;case"workflow":return Qt(e.workflow)?{...e,workflow:Sc(e.workflow,"root")}:e;default:return e}};function ml(e){const n=[],s=[],r=(o,i,c,d)=>{if(!Qt(o)||typeof o.node!="string"||c>ix)return;n.push({path:i,kind:o.node,label:typeof o.label=="string"?o.label:o.node,...o.node==="call"&&typeof o.via=="string"?{via:o.via}:{},changeCheck:pM(lx(gM(o))),...vM(o,d)});const u=(f,g,y,v=i,h=d)=>{!Qt(f)||typeof f.node!="string"||c+1>ix||(s.push({from:v,to:g,kind:y}),r(f,g,c+1,h))};switch(o.node){case"chain":Array.isArray(o.steps)&&o.steps.forEach((f,g)=>u(f,`${i}/steps/${g}`,"next",g===0?i:`${i}/steps/${g-1}`));break;case"parallel":Array.isArray(o.branches)&&o.branches.forEach((f,g)=>u(f,`${i}/branches/${g}`,"branch"));break;case"map":u(o.body,`${i}/body`,"item");break;case"loop":u(o.body,`${i}/body`,"next");break;case"route":if(Qt(o.branches))for(const[f,g]of Object.entries(o.branches))Qt(g)&&u(g.body,`${i}/branches/${mM(f)}/body`,"route");break;case"workflow":Qt(o.workflow)&&u(o.workflow.root,`${i}/workflow/root`,"child",i,Qt(o.workflow.schemas)?o.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 xM=(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},o=r(s);return!Qt(o)||!Qt(o.properties)?[]:Object.entries(o.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(g=>g!=="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}})},vM=(e,n)=>{let s=e,r;const o=i=>typeof i=="string"?i:"";switch(e.node){case"judge":case"sift":r=xM(e.out,n);break;case"pick":r=[{id:"pick",type:"choice",instructions:o(e.instructions)}];break;case"route":if(e.valuePath!==void 0)return{};r=[{id:"branch",type:"choice",instructions:o(e.instructions),options: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:o(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 w2(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},[o,i]=[r(e),r(n)],c=S=>o.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)},g=new Map(e.nodes.filter(c).map(S=>[s(S),S.path]));for(const S of n.nodes){const N=c(S)?g.get(s(S)):void 0;N!==void 0&&f(N,S.path)}const y=new Map(e.nodes.map(S=>[S.path,S])),v=[];for(const S of n.nodes){const N=y.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)&&v.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:y.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 x=({path:S,kind:N,label:$})=>({path:S,kind:N,label:$}),b=(S,N,$)=>JSON.stringify([S,N,$]),j=new Set(e.edges.map(S=>b(S.from,S.to,S.kind))),k=new Set(n.edges.map(S=>b(S.from,S.to,S.kind))),E=(S,N,$)=>{const[_,O]=[N.get(S.from),N.get(S.to)];return _!==void 0&&O!==void 0&&$.has(b(_,O,S.kind))};return{added:n.nodes.filter(S=>!d.has(S.path)).map(x),removed:e.nodes.filter(S=>!u.has(S.path)).map(x),changed:v,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=>!E(S,d,j)).map(({from:S,to:N,kind:$})=>({from:S,to:N,kind:$})),removed:e.edges.filter(S=>!E(S,u,k)).map(({from:S,to:N,kind:$})=>({from:S,to:N,kind:$}))}}}function xn({className:e}){return t.jsx("span",{"aria-hidden":!0,className:ae("block bg-muted motion-safe:animate-pulse",e)})}function Wm({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 bM(){return t.jsxs(Wm,{label:"Loading Mission Control",className:"space-y-8 p-5 md:p-8",children:[t.jsx(xn,{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(xn,{className:"h-3 w-16"}),t.jsx(xn,{className:"mt-3 h-6 w-12"})]},n))}),t.jsx(xn,{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(Bf,{n:4}),t.jsx(Bf,{n:6})]})]})}function Bf({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(xn,{className:"h-4 w-20"}),t.jsx(xn,{className:"h-4 flex-1"}),t.jsx(xn,{className:"hidden h-4 w-24 sm:block"})]},s))})}function Hn({label:e,rows:n=8}){return t.jsx(Wm,{label:e,children:t.jsx(Bf,{n})})}function yM(){return t.jsxs(Wm,{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(xn,{className:"h-4 w-24"}),t.jsx(xn,{className:"h-7 w-2/3"}),t.jsx(xn,{className:"h-3 w-1/3"})]}),t.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,n)=>t.jsx(xn,{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(xn,{className:"size-4 shrink-0"}),t.jsx(xn,{className:ae("h-4",n%2?"w-1/2":"w-3/4")})]},n))})]})}function wM(){return t.jsxs(Wm,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(xn,{className:"h-7 w-64"}),t.jsx(xn,{className:"h-3 w-80 max-w-full"})]}),t.jsx(xn,{className:"h-12 w-full"}),t.jsx(Bf,{n:5})]})}function Jt({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(Ks,{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 j2({what:e,id:n,list:s}){return t.jsx(Jt,{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 cx extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const dx=e=>Math.min(1e4,1e3*2**e),$k=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),jM=e=>(e==null?void 0:e.name)==="AbortError",_k=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function kM({fetch:e=(o,i)=>globalThis.fetch(o,i),probe:n="/v2/health",resumedMs:s=5e3,probeMs:r=5e3}={}){let o={state:"online"};const i=new Set,c=new Set;let d=[],u,f=null,g=null;const y=N=>{o=N;for(const $ of[...i])$()},v=N=>{const $=dx(N);clearTimeout(u),y({state:"offline",attempt:N,retryAt:Date.now()+$}),u=setTimeout(()=>void j(),$)},h=()=>{o.state!=="offline"&&v(0)},x=()=>{if(o.state!=="offline")return;clearTimeout(u),y({state:"resumed"});const N=d;d=[];for(const $ of N)$();for(const $ of[...c])$();u=setTimeout(()=>{o.state==="resumed"&&y({state:"online"})},s)};async function b(N){const $=setTimeout(()=>N.abort(),r);try{return!$k(await e(n,{method:"GET",cache:"no-store",credentials:"same-origin",signal:N.signal}))}catch{return!1}finally{clearTimeout($)}}async function j(){if(o.state!=="offline")return;clearTimeout(u),f==null||f.abort();const N=f=new AbortController,$=await b(N);f===N&&(f=null,o.state==="offline"&&($?x():v(o.attempt+1)))}const k=()=>g??(g=b(new AbortController).finally(()=>{g=null})),E=N=>new Promise(($,_)=>{if(N!=null&&N.aborted)return _(_k(N));const O=()=>{d=d.filter(P=>P!==L),_(_k(N))},L=()=>{N==null||N.removeEventListener("abort",O),$()};d.push(L),N==null||N.addEventListener("abort",O,{once:!0})});return{fetch:async(N,$)=>{var L;const _=(($==null?void 0:$.method)??"GET").toUpperCase(),O=_==="GET"||_==="HEAD";for(let P=0;;P++){let R,A;try{R=await e(N,$)}catch(M){if((L=$==null?void 0:$.signal)!=null&&L.aborted||jM(M))throw M;A=M}if(R&&!$k(R))return x(),R;if(o.state!=="offline"&&await k()){if(R)return R;if(!O)throw new cx;if(P>=2)throw A;await new Promise(M=>setTimeout(M,dx(P)));continue}if(h(),!O)throw new cx;await E($==null?void 0:$.signal)}},link:()=>o,subscribe:N=>(i.add(N),()=>{i.delete(N)}),onResume:N=>(c.add(N),()=>{c.delete(N)}),retryNow:()=>void j()}}const NM=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),k2=e=>e instanceof cx||e instanceof TypeError&&/fetch|network/i.test(e.message);function Ht(e,n){const s=`${NM(n)} could not be read.`;if(k2(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof Ue))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=e.message,o=[e.code,e.requestId].filter(Boolean).join(" · "),i=(c,d)=>({title:s,why:c,next:d,said:r,code:o});return e.status===401?i("This browser is signed out.","Reload the page to sign in again."):e.status===403?i("The server doesn't allow this here.","Sign in as the server's owner, or open the console from the address the server printed."):e.status===404?i("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===429?i("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?i("The server is busy.","Try again in a moment."):e.status>=500?i("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):i("The server turned the request down.","Its words say why: change what they name, then try again.")}function SM(e){return k2(e)?"Can't reach agentrun-serve":e instanceof Ue?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}function CM({agent:e,v2:n}){const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,y]=p.useState(null),v=p.useRef(0),h=p.useRef(!1),x=async b=>{if(h.current)return;h.current=!0;const j=++v.current;f(!0);try{const k=await n.listRevisions(e.agent_id,b);if(j!==v.current)return;r(E=>{const S=new Map((b?E??[]:[]).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===v.current&&d(Ht(k,b?"more versions":"the versions"))}finally{j===v.current&&(h.current=!1,f(!1))}};return p.useEffect(()=>(h.current=!1,r(null),i(null),d(null),y(null),x(null),()=>{v.current++,h.current=!1}),[n,e.agent_id,e.revision,e.revisions]),c&&!s?t.jsx(Jt,{problem:c,onRetry:()=>void x(null),className:""}):s?t.jsxs("section",{className:"overflow-hidden border","aria-label":"Agent versions",children:[t.jsxs("div",{className:"border-b px-4 py-3 text-body text-muted-foreground",children:[e.revisions," ",e.revisions===1?"version":"versions"," · Current version ",e.definition.version]}),s.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Versions",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Version","Created","Note","Configuration"].map(b=>t.jsx("th",{className:"px-4 py-3 font-semibold",children:b},b))})}),t.jsx("tbody",{children:s.map(b=>t.jsxs(p.Fragment,{children:[t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsxs("td",{className:"whitespace-nowrap px-4 py-3",children:[t.jsxs("span",{className:"font-semibold",children:["v",b.version]}),b.revision===e.revision&&t.jsx("span",{className:"ml-2 bg-primary/10 px-2 py-1 text-micro text-primary-text",children:"Current"})]}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:ft(b.created_at)}),t.jsx("td",{className:"min-w-40 px-4 py-3 text-muted-foreground",children:b.note||"—"}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(B,{size:"sm","aria-expanded":g===b.revision,"aria-label":`View configuration for version ${b.version}`,onClick:()=>y(j=>j===b.revision?null:b.revision),children:g===b.revision?"Hide":"View"})})]}),g===b.revision&&t.jsx("tr",{className:"border-b bg-card",children:t.jsxs("td",{colSpan:4,className:"p-4",children:[t.jsx("p",{className:"mb-3 break-all font-mono text-label text-muted-foreground",children:b.revision}),t.jsx("pre",{"aria-label":`Version ${b.version} configuration`,className:"max-h-[520px] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:JSON.stringify(b.definition,null,2)})]})})]},b.revision))})]})}):t.jsx("p",{className:"p-10 text-center text-body text-muted-foreground",children:"No versions were returned for this agent."}),c&&t.jsx(Jt,{problem:c,className:"m-4"}),o&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",disabled:u,onClick:()=>void x(o),children:u?"Loading":"Load more versions"})})]}):t.jsx(Hn,{label:"Loading versions",rows:4})}const N2=(e,n)=>e.name.localeCompare(n.name,void 0,{sensitivity:"base",numeric:!0})||(e.id<n.id?-1:e.id>n.id?1:0),Tl=e=>[...e].sort((n,s)=>N2({name:n.definition.name||n.agent_id,id:n.agent_id},{name:s.definition.name||s.agent_id,id:s.agent_id}));function EM(e){return e.usd===null?{total:"Unknown"}:{total:ro({usd:e.usd,basis:"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}const zv=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],Zi=864e5,ux=e=>Math.floor(e/Zi)*Zi;function Dv(e,n=Date.now()){var r;const s=(r=zv.find(o=>o.id===e))==null?void 0:r.days;return s?new Date(ux(n)-(s-1)*Zi).toISOString():void 0}const S2=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function $M(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 _M(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 C2=(e,n)=>EM({usd:e.cost_usd,unknownRuns:e.unknown_cost_runs}),Fv=e=>e.runs_with_metrics<e.runs?`tokens from ${e.runs_with_metrics} of ${e.runs} runs`:void 0;function Ya(e){return e===null?"Unknown":p2(e)}const Gf=e=>e===null?"—":`${Math.round(e*100)}%`;function Tk(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function TM(e,n,s=Date.now()){if(!e.length)return[];const r=ux(s),o=Math.max(r-29*Zi,n?ux(Date.parse(n)):r-29*Zi),i=new Map(e.map(d=>[d.day,d])),c=[];for(let d=o;d<=r;d+=Zi){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 RM(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)=>N2({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 E2({range:e,onRange:n,agent:s,agents:r,onAgent:o}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(xd,{label:"Range",name:"mission-range",value:e,onChange:n,size:"sm",options:zv.map(i=>({value:i.id,label:i.label}))}),o&&r.length>0&&t.jsx(Et,{label:"Agent",value:s??"",onChange:i=>o(i||null),className:"h-control-sm w-56",options:[{value:"",label:"All agents"},...r.map(i=>({value:i.agentId,label:i.name}))]})]})}const Sf=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function $2({a:e,basis:n,now:s=Date.now(),refreshing:r=!1}){const o=e.totals,i=_M(o),c=S2(o),d=C2(o),u=[{label:"Tokens",value:Ya(o.tokens),notes:[`${i===null?"":`${Gf(i)} of input cached · `}${Ya(o.output)} output`,Fv(o),o.requests===null||o.unmetered===null?"Model request counts unavailable":o.unmetered?`${Sf(o.unmetered,"request")} with no token count`:void 0]},{label:"Run time",value:Tk(e.time.wall_ms),notes:[`wall time of ${Sf(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${Tk(e.time.active_ms)} active, over ${Sf(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:Gf(c),notes:[o.completed+o.failed?$M(o):"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(g=>t.jsx("p",{className:"mt-2 text-small leading-relaxed text-muted-foreground",children:g},g))]},f.label))}),t.jsx(MM,{days:TM(e.by_day,e.filter.from,s)}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[t.jsx(AM,{rows:e.by_harness_effort,basis:n}),t.jsx(OM,{tools:e.tools})]}),t.jsx(LM,{groups:e.by_source})]})}function Gi({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 _2="px-4 py-2 text-left font-normal",Cr="px-4 py-2.5 align-top";function AM({rows:e,basis:n}){return t.jsx(Gi,{title:"Success by harness and effort",children:e.length?t.jsx("div",{className:"overflow-x-auto",role:"region","aria-label":"Success by harness and effort, table",tabIndex:0,children:t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Harness","Effort","Runs","Success","Tokens","Cost"].map(s=>t.jsx("th",{className:_2,children:s},s))})}),t.jsx("tbody",{children:e.map(s=>{const r=C2(s),o=Fv(s);return t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:Cr,children:s.harness}),t.jsx("td",{className:ae(Cr,!s.effort&&"text-muted-foreground"),children:s.effort??"unset"}),t.jsx("td",{className:Cr,children:s.runs}),t.jsx("td",{className:Cr,children:Gf(S2(s))}),t.jsxs("td",{className:Cr,children:[t.jsx("span",{className:"whitespace-nowrap",children:Ya(s.tokens)}),o&&t.jsx("span",{className:"block text-label text-muted-foreground",children:o})]}),t.jsxs("td",{className:Cr,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 OM({tools:e}){return t.jsx(Gi,{title:"Top tools",children:e.length?t.jsx("div",{className:"overflow-x-auto",role:"region","aria-label":"Top tools, table",tabIndex:0,children:t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Tool","Calls","Errors","Error rate"].map(n=>t.jsx("th",{className:_2,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:Cr,title:n.tool,children:n.label}),t.jsx("td",{className:Cr,children:Ya(n.calls)}),t.jsx("td",{className:ae(Cr,n.errors>0&&"text-destructive-text"),children:Ya(n.errors)}),t.jsx("td",{className:Cr,children:Gf(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 LM({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}`}: ${Sf(n.runs,"run")}`).join(" · ")}):null}const xg=e=>Math.max(0,e.runs-e.completed-e.failed);function Rk(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 vg=e=>e.slice(5);function MM({days:e}){const n=e.some(d=>d.runs>0),s=t.jsxs(t.Fragment,{children:[t.jsx(DT,{className:"size-4","aria-hidden":!0}),"Run activity"]}),r=t.jsxs(t.Fragment,{children:[t.jsx(qT,{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(Gi,{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(Gi,{title:r,children:t.jsx("p",{className:"flex min-h-[220px] items-center justify-center px-5 py-6 text-center text-body text-muted-foreground",children:"No token usage in this range."})})]});const o=Rk(Math.max(...e.map(d=>d.runs))),i=Rk(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:xg}];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(Gi,{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(Ak,{days:e,top:o,label:"Runs per day",stack:d=>c.map(u=>({className:u.className,value:u.of(d)})),readout:d=>[`${d.runs} ${d.runs===1?"run":"runs"}`,`${d.completed} completed · ${d.failed} failed · ${xg(d)} other`]})]})}),t.jsx(Gi,{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(Ak,{days:e,top:i,label:"Tokens per day",format:Ya,stack:d=>[{className:"bg-primary",value:d.tokens}],readout:d=>[`${Ya(d.tokens)} tokens`,Fv(d)??`${d.runs} ${d.runs===1?"run":"runs"}`]})]})})]}),t.jsxs("details",{className:"border bg-card px-5 py-3",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),t.jsx("div",{className:"overflow-x-auto",role:"region","aria-label":"Per day, table",tabIndex:0,children:t.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Day","Runs","Completed","Failed","Other","Tokens"].map(d=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:d},d))})}),t.jsx("tbody",{children:e.map(d=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:d.day}),t.jsx("td",{className:"pr-4",children:d.runs}),t.jsx("td",{className:"pr-4",children:d.completed}),t.jsx("td",{className:"pr-4",children:d.failed}),t.jsx("td",{className:"pr-4",children:xg(d)}),t.jsx("td",{className:"pr-4",children:d.tokens===null?"Unknown":d.tokens.toLocaleString("en-US")})]},d.day))})]})})]})]})}function Ak({days:e,top:n,label:s,stack:r,readout:o,format:i=c=>c.toLocaleString("en-US")}){const[d,u]=p.useState(e.length-1),f=Math.min(d,e.length-1),g=j=>{var E;const k=j.key==="ArrowRight"?Math.min(f+1,e.length-1):j.key==="ArrowLeft"?Math.max(f-1,0):j.key==="Home"?0:j.key==="End"?e.length-1:-1;k<0||(j.preventDefault(),u(k),(E=j.currentTarget.querySelectorAll('[role="listitem"]')[k])==null||E.focus())},[y,v]=p.useState(null),[h,x]=p.useState(null),b=e.find(j=>j.day===(y??h));return t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"flex w-10 shrink-0 flex-col justify-between text-right font-mono text-micro text-muted-foreground",style:{height:140},"aria-hidden":!0,children:[t.jsx("span",{children:i(n)}),t.jsx("span",{children:i(n/2)}),t.jsx("span",{children:"0"})]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"relative flex items-end gap-px border-b border-border-strong",style:{height:140},role:"list","aria-label":s,onMouseLeave:()=>v(null),onKeyDown:g,children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-border","aria-hidden":!0}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-border","aria-hidden":!0}),e.map((j,k)=>{const E=r(j),S=E.some($=>$.value===null),N=E.filter($=>$.value!==null&&$.value>0);return t.jsxs("div",{role:"listitem",tabIndex:k===f?0:-1,"aria-label":`${j.day}: ${o(j).join(", ")}`,onMouseEnter:()=>v(j.day),onFocus:()=>{x(j.day),u(k)},onBlur:()=>x(null),className:"group relative flex h-full min-w-0 flex-1 flex-col items-center justify-end focus-visible:outline-focus focus-visible:outline-ring hover:bg-accent/60 focus-visible:bg-accent/60",children:[S&&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:N.map(($,_)=>t.jsx("div",{className:$.className,style:{height:Math.max(1,Math.round($.value/n*(140-2*(N.length-1))))}},_))})]},j.day)})]}),t.jsxs("div",{className:"mt-1 flex justify-between font-mono text-micro text-muted-foreground","aria-hidden":!0,children:[t.jsx("span",{children:vg(e[0].day)}),e.length>2&&t.jsx("span",{children:vg(e[Math.floor(e.length/2)].day)}),t.jsx("span",{children:vg(e.at(-1).day)})]}),t.jsx("div",{"aria-label":`${s} readout`,className:"mt-2 min-h-16 break-words font-mono text-label text-muted-foreground",children:b?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block font-semibold text-foreground",children:o(b)[0]}),o(b).slice(1).map(j=>t.jsx("span",{className:"block",children:j},j)),t.jsx("span",{className:"block",children:b.day})]}):"Hover or focus a day for its figures."})]})]})}const ln=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Cf=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function PM(e){const n=new Map;let s=0;const r=d=>{throw Object.assign(new Error(d),{offset:s})},o=()=>{for(;s<e.length&&`
|
|
583
|
-
\r`.includes(e[s]);)s++},i=()=>{const d=s;for(s++;s<e.length&&e[s]!=='"';)e[s]==="\\"?s++:e.charCodeAt(s)<32&&r("a string cannot hold a raw line break or control character"),s++;s>=e.length&&(s=d,r("this string is not closed")),s++;try{return JSON.parse(e.slice(d,s))}catch{return s=d,r("this string has a bad escape")}},c=d=>{o();const u=s;let f;const g=e[s];if(g==="{"){s++;const y={};if(o(),e[s]==="}")s++;else for(;;){o(),e[s]!=='"'&&r(e[s]==="}"?"a trailing comma before }":"expected a key in double quotes");const v=i();if(o(),e[s]!==":"&&r("expected : after the key"),s++,y[v]=c(`${d}/${Cf(v)}`),o(),e[s]===","){s++;continue}if(e[s]==="}"){s++;break}r("expected , or } after the value")}f=y}else if(g==="["){s++;const y=[];if(o(),e[s]==="]")s++;else for(;;){if(y.push(c(`${d}/${y.length}`)),o(),e[s]===","){s++,o(),e[s]==="]"&&r("a trailing comma before ]");continue}if(e[s]==="]"){s++;break}r("expected , or ] after the value")}f=y}else if(g==='"')f=i();else{const y=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(e.slice(s,s+400));y||r(s>=e.length?"the text ends before the value":"expected a value"),s+=y[0].length,f=JSON.parse(y[0])}return n.set(d,{start:u,end:s}),f};try{const d=c("");return o(),s<e.length&&r("text after the end of the JSON"),{ok:!0,value:d,spans:n}}catch(d){return{ok:!1,error:{message:d.message,offset:d.offset??0}}}}function IM(e,n){let s=1,r=-1;for(let o=0;o<Math.min(n,e.length);o++)e[o]===`
|
|
584
|
-
`&&(s++,r=o);return{line:s,col:n-r}}function T2(e,n){let s=e;for(const r of n.split("/").slice(1)){const o=r.replace(/~1/g,"/").replace(/~0/g,"~");if(Array.isArray(s))s=s[Number(o)];else if(ln(s))s=Object.prototype.hasOwnProperty.call(s,o)?s[o]:void 0;else return}return s}const R2=new Set(["judge","pick","sift","route"]),Ok=["jev","parallel","openrouter"];function zM(e){return!ln(e)||!ln(e.properties)?[]:Object.entries(e.properties).flatMap(([n,s])=>{if(!ln(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 Uv(e,n,s){const r=T2(e,n);if(!ln(r))return{decision:!1};const o=r.node,i=s??{},c=o==="route"&&typeof r.valuePath=="string",d=typeof o=="string"&&R2.has(o)&&!c||Array.isArray(i.questions);if(!d)return{decision:!1,...o==="call"&&typeof r.tool=="string"?{tool:r.tool}:{}};const u=typeof i.provider=="string"?i.provider:typeof r.provider=="string"?r.provider:"jev",f=typeof i.model=="string"?i.model:typeof r.model=="string"?r.model:void 0,g=ln(e)&&ln(e.schemas)?e.schemas:{};let y=[];Array.isArray(i.questions)?y=i.questions.map(x=>({id:x.id,type:x.type==="choice"||x.type==="score"?x.type:"noul",text:x.instructions||x.id,...x.options?{options:x.options}:{}})):o==="judge"||o==="sift"?y=typeof r.out=="string"?zM(g[r.out]):[]:o==="pick"?y=[{id:"pick",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Pick one"}]:o==="route"&&(y=[{id:"branch",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Which branch?",options:ln(r.branches)?Object.keys(r.branches):[]}]);const v=Array.isArray(i.images)?i.images.map(String):ln(r.images)?Object.keys(r.images):[],h=ln(r.unsure)&&typeof r.unsure.branch=="string"&&typeof r.unsure.gte=="number"?{branch:r.unsure.branch,gte:r.unsure.gte}:void 0;return{decision:d,provider:u,model:f,questions:y,...v.length?{images:v}:{},web:u==="parallel",...h?{unsure:h}:{}}}const DM=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function FM(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(!ln(e))return s("","the workflow is a JSON object"),n;e.v!==2&&s("/v",'the workflow format is "v": 2'),(typeof e.name!="string"||!e.name)&&s("/name","the workflow needs a name");const o=ln(e.schemas)?e.schemas:{};ln(e.input)&&typeof e.input.schemaId=="string"&&!o[e.input.schemaId]&&s("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),ln(e.output)?typeof e.output.schemaId=="string"&&!o[e.output.schemaId]&&s("/output/schemaId",`no schema "${e.output.schemaId}" in schemas`):s("",'the workflow needs an output: { "schemaId": ..., "path": ... }');const i=new Map,c=(d,u)=>{if(!ln(d)){s(u,'expected a node (an object with a "node" kind)');return}const f=d.node;if(typeof f!="string"||!DM.has(f)){s(`${u}/node`,typeof f=="string"?`"${f}" is not a node kind`:'a node names its kind in "node"');return}f!=="chain"&&(typeof d.label!="string"||!d.label?s(u,`a ${f} node needs a label`):i.has(d.label)?r(`${u}/label`,`the label "${d.label}" is also used at ${i.get(d.label)}; receipts name nodes by label`):i.set(d.label,u));const g=(v,h)=>{d[v]===void 0&&s(u,`a ${f} node needs ${v} (${h})`)},y=v=>{typeof d[v]=="string"&&!o[d[v]]&&s(`${u}/${v}`,`no schema "${d[v]}" in schemas`)};switch(f){case"chain":!Array.isArray(d.steps)||!d.steps.length?s(u,"a chain needs steps"):d.steps.forEach((v,h)=>c(v,`${u}/steps/${h}`));break;case"parallel":!Array.isArray(d.branches)||!d.branches.length?s(u,"a parallel node needs branches"):d.branches.forEach((v,h)=>c(v,`${u}/branches/${h}`));break;case"map":g("itemsPath","where the items are"),g("as","where the results go"),c(d.body,`${u}/body`);break;case"loop":g("until","when it stops"),g("maxIters","a bound"),c(d.body,`${u}/body`);break;case"workflow":ln(d.workflow)?c(d.workflow.root,`${u}/workflow/root`):s(u,"a workflow node embeds its workflow");break;case"call":g("via","tool, executor or shell"),d.via==="tool"&&g("tool","the tool's name");break;case"code":typeof d.code!="string"&&s(u,"a code node needs code");break;case"escalate":g("when","the predicate that fires it"),g("kind","the review it asks for");break;case"judge":case"sift":g("out","the questions' schema"),y("out"),g("as","where the answers go");break;case"pick":g("itemsPath","the options' list"),g("as","where the pick goes");break;case"agent":case"decide":case"extract":y("out");break}if(f==="route"){if(!ln(d.branches)||!Object.keys(d.branches).length)s(u,"a route needs branches");else for(const[v,h]of Object.entries(d.branches))ln(h)?c(h.body,`${u}/branches/${Cf(v)}/body`):s(`${u}/branches/${Cf(v)}`,`branch "${v}" is an object with a body`);typeof d.valuePath!="string"&&d.instructions===void 0&&s(u,"a route asks by instructions (and state), or reads a valuePath"),ln(d.unsure)&&ln(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(R2.has(f)&&!(f==="route"&&typeof d.valuePath=="string")&&(d.provider!==void 0&&!Ok.includes(d.provider)&&r(`${u}/provider`,`provider "${String(d.provider)}" is not one of ${Ok.join(", ")}`),d.provider==="openrouter"&&typeof d.model!="string"&&s(u,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),ln(d.images))){const v=JSON.stringify(d.state??{})+JSON.stringify(d.instructions??"")+(typeof d.out=="string"?JSON.stringify(o[d.out]??{}):"");for(const h of Object.keys(d.images))v.includes(h)||s(`${u}/images/${Cf(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 Lk(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 UM(e,n,s){let r=null,o=1/0;for(const i of n){const c=e.get(i);c&&c.start<=s&&s<=c.end&&c.end-c.start<o&&(r=i,o=c.end-c.start)}return r}function WM(e){const n=ml(e),r=n.nodes.map(i=>Uv(e,i.path,i)).filter(i=>i.decision),o=[...new Set(r.map(i=>i.provider??"jev"))];return`${n.nodes.length} nodes · ${r.length} ${r.length===1?"decision":"decisions"}${o.length?` · ${o.join(", ")}`:""}`}const qf=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,Mk=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),wd=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function jd(e,n){return Object.fromEntries(n.nodes.map(s=>[s.path,Uv(e,s.path,s)]))}const Zu=e=>e>=.995?"1.00":e.toFixed(2);function hl(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?` ${Zu(f)}`:""}`}const r=Object.keys(n);if(!r.length)return;const o=u=>{const f=n[u];return f.type==="choice"?`${A2(e,u,f.choice)} ${Zu(f.probabilities[f.choice]??f.confidence)}`:f.type==="noul"?`${f.noul>=.5?"yes":"no"} ${Zu(f.noul>=.5?f.noul:1-f.noul)}`:f.type==="score"?`${f.score} ${Zu(f.confidence)}`:f.type==="refusal"?"refused":"box"};if(r.length===1)return o(r[0]);const i=u=>{const f=n[u];return f.type==="noul"?Math.abs(f.noul-.5)*2:"confidence"in f&&typeof f.confidence=="number"?f.confidence:1},c=r.reduce((u,f)=>i(f)<i(u)?f:u,r[0]);return`${c} ${o(c)}`}function A2(e,n,s){var i,c;const r=(i=e.questions)==null?void 0:i[n],o=e.kind==="pick"&&(r==null?void 0:r.type)==="choice"?(c=r.criteria)==null?void 0:c[s]:null;return typeof o=="string"&&o?o:s}const O2=(e,n)=>e.nodes.filter(s=>s.path.startsWith(`${n}/body`)).map(s=>s.path);function HM(e,n,s){var y,v;const r=(v=(y=e.nodes[n])==null?void 0:y.items)==null?void 0:v.find(h=>h.index===s),o={};if(!r)return o;const i=new Set(["chain","parallel","route","map","loop","workflow"]),c=new Map(e.graph.nodes.map(h=>[h.path,h.kind])),d=O2(e.graph,n).filter(h=>!i.has(c.get(h)??""));let u=-1;d.forEach((h,x)=>{const b=e.decisions.filter(k=>k.node===h&&k.item===s),j=e.effects.filter(k=>k.node===h&&k.item===s);!b.length&&!j.length||(u=x,b.some(k=>k.status==="failed")||j.some(k=>k.status==="failed")?o[h]="failed":b.some(k=>k.status==="cancelled")?o[h]="review":j.some(k=>!k.endedAt)?o[h]=j.some(k=>k.status==="stopped")?"stopped":"working":o[h]="done")});const f=qf(r.status)??"pending";let g=!Object.values(o).includes("working");return d.forEach((h,x)=>{o[h]||(x<u||f==="done"?o[h]="done":f==="working"?(o[h]=g?"working":"pending",g=!1):f==="pending"?o[h]="pending":o[h]="not-run")}),o}function BM(e,n){var g,y,v;const s={},r=[],o={};let i=null;const c=new Map(e.graph.nodes.map(h=>[h.path,h.kind]));for(const[h,x]of Object.entries(e.nodes)){const b=qf(x.status);b&&(s[h]=b),x.branch&&r.push(`${h}/branches/${Mk(x.branch)}/body`),x.items&&(o[h]=x.items.map(j=>({index:j.index,status:qf(j.status)??"pending",label:Qc(e,h,j.index),...Wv(e,h,j)}))),x.status==="escalated"&&c.get(h)==="escalate"&&(i=h)}const d={},u=h=>/\/body(\/|$)/.test(h)&&e.graph.nodes.some(x=>x.kind==="map"&&h.startsWith(`${x.path}/body`));for(const h of e.decisions){if(!h.node||h.item!==null||u(h.node))continue;const x=hl(h);x&&(d[h.node]=x)}if(n&&n.item!=null&&c.get(n.path)==="map"){Object.assign(s,HM(e,n.path,n.item));const h=((v=(y=(g=e.nodes[n.path])==null?void 0:g.items)==null?void 0:y.find(x=>x.index===n.item))==null?void 0:v.branches)??{};for(const[x,b]of Object.entries(h)){const j=`${x}/branches/`,k=`${j}${Mk(b)}/body`;for(let E=r.length-1;E>=0;E--)r[E].startsWith(j)&&r.splice(E,1);r.push(k);for(const E of e.graph.nodes)E.path.startsWith(j)&&!(E.path===k||E.path.startsWith(`${k}/`))&&(s[E.path]="not-run")}for(const x of e.decisions)if(x.node&&x.item===n.item&&x.node.startsWith(`${n.path}/body`)){const b=hl(x);b&&(d[x.node]=b)}}if(e.run.paused){for(const[h,x]of Object.entries(s))x==="working"&&(s[h]="held");for(const h of Object.values(o))for(const x of h)x.status==="working"&&(x.status="held")}const f={};for(const[h,x]of Object.entries(e.nodes))x.model&&(f[h]={model:x.model,...x.tier?{tier:x.tier}:{}});return{status:s,taken:r,items:o,fired:i,verdict:d,meta:jd(e.workflow,e.graph),selected:n,...Object.keys(f).length?{ran:f}:{}}}const bg={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"},GM=e=>{if(!e)return;const n=e.toLowerCase();return bg[n]??bg[n.split(/[_\s-]/)[0]]??bg[n.split(/[_\s-]/).at(-1)??""]};function qM(e){if(e.status!=="answered"||!e.answers)return;const n=e.action,s=e.answers.branch;if(n&&typeof n=="object"&&n.taken&&(s==null?void 0:s.type)==="choice")return{p:s.confidence,note:`${e.kind} confidence`};let r;for(const[o,i]of Object.entries(e.answers)){const c=i.type==="noul"?{p:Math.max(i.noul,1-i.noul),note:`${o}: ${i.noul>=.5?"yes":"no"}, P(yes) ${i.noul.toFixed(2)}`,sure:Math.abs(i.noul-.5)}:i.type==="choice"||i.type==="score"?{p:i.confidence,note:`${o} confidence`,sure:i.confidence-.5}:void 0;c&&(!r||c.sure<r.sure)&&(r=c)}return r&&{p:r.p,note:`least sure: ${r.note}`}}function Wv(e,n,s){const r=O2(e.graph,n),o=v=>v?r.indexOf(v):-1,i=e.decisions.filter(v=>{var h;return v.item===s.index&&!!((h=v.node)!=null&&h.startsWith(`${n}/body`))}).sort((v,h)=>o(v.node)-o(h.node));let c,d;const u=Object.entries(s.branches??{}).sort(([v],[h])=>o(v)-o(h));if(u.length)[d,c]=u[u.length-1];else{const v=i.filter(h=>{var x;return h.status==="answered"&&((x=h.action)==null?void 0:x.taken)}).at(-1);v&&(c=v.action.taken,d=v.node??void 0)}const f=d&&i.filter(v=>v.node===d).at(-1)||i.filter(v=>v.status==="answered").at(-1),g=f?qM(f):void 0,y=s.status==="failed"?"bad":s.status==="needs_review"||s.status==="escalated"?"warn":GM(c);return{...c?{outcome:c}:{},...g?{p:g.p,pNote:g.note}:{},...y?{tone:y}:{}}}function Qc(e,n,s){var d,u;const r=(u=(d=e.nodes[n])==null?void 0:d.items)==null?void 0:u.find(f=>f.index===s);if(r!=null&&r.label)return r.label;const o=e.effects.find(f=>{var g;return f.item===s&&!!((g=f.node)!=null&&g.startsWith(`${n}/body`))}),i=o==null?void 0:o.input,c=(i==null?void 0:i.path)??(i==null?void 0:i.url);return typeof c=="string"?c:void 0}function L2(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 M2(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 Rl=e=>e==null?"Unknown":e>0&&e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,el=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function pl(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 KM=(e,n,s)=>{const r=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||n)-Date.parse(e.run.startedAt);return wd(e.run.status)||e.run.paused?r:r+Math.max(0,s-n)};function VM(e,n,s){return e!=="input_required"||n!=="waiting"?null:s.findLast(r=>r.kind==="waiting")??null}function YM(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 P2(e){return e.split("/").slice(0,-1).some(n=>n.startsWith(".")||n==="__pycache__"||n==="node_modules")}const I2="The agent finished without writing an answer.",Pk=[0,250,1e3],QM=e=>new Promise(n=>setTimeout(n,e));function z2(){let e=0;return{begin:()=>++e,current:n=>n===e,cancel:()=>{e++}}}const D2="30d",Ik=10,JM=["queued","working","input_required","paused"];function XM({agent:e,v2:n,now:s=Date.now,stats:r}){const[o,i]=p.useState(D2),[c,d]=p.useState(r??null),[u,f]=p.useState(null),[g,y]=p.useState(!0),[v,h]=p.useState(0),x=p.useRef(0),b=p.useRef(!0);p.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]);const j=p.useRef(null),k=p.useRef(null);p.useEffect(()=>{const S=`${o}/${v}`;if(k.current===S)return;const N=++x.current;if(j.current===S){k.current=null,f(null),y(!1);return}k.current=S,y(!0),f(null),(async()=>{for(const[$,_]of Pk.entries()){if(_&&await QM(_),N!==x.current||!b.current)return;try{const O=await n.statsOver({from:Dv(o,s()),agent:e.agent_id});if(N!==x.current||!b.current)return;const L=!(O.runs.status_unknown>0);if(d(O),j.current=L||$===Pk.length-1?S:null,L)break}catch(O){N===x.current&&f(Wt(O));break}}N===x.current&&(k.current=null,y(!1))})()},[n,e.agent_id,o,v]),p.useEffect(()=>{const S=new AbortController,N=$=>({status:$,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(JM.map($=>n.listAgentRuns(e.agent_id,Ik,null,N($)))).then($=>{if(S.signal.aborted)return;const _=$.flatMap(O=>O.status==="fulfilled"?O.value.runs:[]).filter(O=>!wd(O.status));for(const O of _.slice(0,Ik)){let L=`${O.status}/${O.state}`;b2(n,O.run_id,{signal:S.signal,onPage:P=>{const R=`${P.status}/${P.state}`;R!==L&&(L=R,h(A=>A+1))}}).catch(()=>{})}}),()=>S.abort()},[n,e.agent_id]);const E=c==null?void 0:c.analytics;return t.jsxs("div",{className:"space-y-6",children:[t.jsx(E2,{range:o,onRange:i,agent:null,agents:[]}),u?t.jsxs("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:["The analytics could not be read: ",u]}):!c||!E?t.jsx("p",{className:"py-12 text-center font-mono text-body text-muted-foreground",children:"Loading analytics..."}):E.totals.runs?t.jsx($2,{a:E,basis:c.cost.basis,now:s(),refreshing:g}):t.jsx("div",{className:"border px-4 py-12 text-center",children:t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent in this range."})})]})}const Hv=["codex","codex-cli","claude","claude-cli","cursor","other"],F2="agentrun.coding-agent.v1",yg="agentrun:coding-agent",wg={codex:"Codex app","codex-cli":"Codex CLI",claude:"Claude Code app","claude-cli":"Claude Code CLI",cursor:"Cursor",other:"Other / terminal"};function zk(){try{const e=localStorage.getItem(F2);return Hv.includes(e)?e:""}catch{return""}}function ZM(e){try{localStorage.setItem(F2,e)}catch{}}function eP(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 tP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGgAAABoCAYAAAAdHLWhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAJnFJREFUeAHtfQuYFdWV7tpVdc7pprvpppvuhm4ejQ9AQQFFUEEUfAUVH4k448TRuT4y0UnumGiSm0y8YuZO8jlXRx0fMXGi5rtqfIyj8YWiKCoEQcGAgAEabZAG+km/+/Q5VXvfvXftvWtV9ek3oM7X6/uqq07Vrl1V699rrX+vvasaYFiGZViGZViGZViGZViG5VAKUUs3YYyRPs77byNftYfRoDCxLFu2zHrr/ZEV444Zd9KMU046c0Qia+LY8lETxx41ojDZBJ07d1Y3Upr4/NNNm/+8v7ltbePW97atWnV3faQuCl9j+aoAJO7D4osnfpz3rbumXvY3139/2nEjLystJmNLcgEcruYEL+F2AaRdBhYhEIurE7IAmjoB2rvA27ItvW3NB5UPH9j8zBNPPnlHS7Tur5t8FQCywW/l7Lqb18775lWz758xxZmVx23IdoEdqALYvYeR2gYG7a0WpDhAHi9NuMpj/MxEgkFBPsDYMYSOmwRQOBqsZAKgsh68lSv3/8d/PXH/P61f+asGfB34GsmXCZC4tlCae8bSXxbfdNOtLy08NXZqIQdlbyXQjzeBVX2AkXQXAeLwgrykxUGx+ULUXTOuasoXz/MXsTsvh8JRFRadOQsguwSsXdyGXnix5ue3/f2Yf1HXdcQ14WsiXxZAxu384M5d/+Paq496dOoogM82QXrteog1cqU6XI2xGC8kgFFRSQDUmwjT8LjqXdevfGI50HlnALVKwHlrE1Q98/DT855+9Mp9/BB3jpCCr4F8GQCZ4P2715IvXLIocaldw9x3VhLrizqwBDBxR1mKAgTj0hdIWlzuzFIpv/wJxzF39unE2doG8MhDm77xwC9mvgEBGZH39J3v/MbZsSNuFxfvps89t0xYGM1w3wBH2EUeaYAMOL9/vfOTy8/Mmr5nM3StWQOJLq6OrIQCBhQQiGhrt0aEeqyeb1y4PcPd+Jpy19fFgSouYvSsMxltyrOct95q/vG67ZtXxtrot06dN/f0xIiuieXl+QWeBTE3Ce7Bxtb21nZSR7vaN77x9qdv19R9sGbV0z+tij4DHAE5kgAZt/bY8uTmK+YnTvhkDU19vNWKC1AS8QAUguKMpf702Cnqh1BhTWkek3gDmH8apBLlEE/yfUWcXMSEmrm90JQPprwct2DC76eL/05zF9vCj23fBbtXvL3ryVUv/eb+D1f93wNwhNjhkQRIBufHXup69aLT4xdUrmepTZ+SuKDKwqVJYBA4Iu5oUIiV4a77unMGIWckyIQAQDSCslJgI/MYaWujUF9PoK3TgjQH0GMcLcpJCb94zGGQm8OguBjY+AkWKynjlWRz4pIEWPF2w0sv/9cL/7D8yRv2wmFmh0cKIAnOLb+quunGqyc+2LKddX24iSQcTgLi4vEsZT2W/7TYakCBFZKIi8v0EBIfCt0ih4hNbsq3KnFMs0KmynjMP09QeUE20imfeMTiDCaMJXTmSUDzy8HZx4F6+vnq+2777rib8TPCIZYjAZAMxouW/rr8V7/87t6RB5n7p3VE9Dsh4fjAEAWQpa1InGX5QGnrIeZP95smfbVdJg3DCDV/gm0DqKLuehHHXG55KbF0+aCNHc3YqacRr3ASOKt3wv7f3vf06S8+fmUVHAZ2eCQAEkbhPfhs8uNFUxIzN38ItKkdrDiPBw5RwChwLOXVQ8CQ8M3KRREFvS8TPma/dnWiPA3KYp8kPZsqZ4CivjkIS2NqcZVVCdJB+frYo5l7ymng1CcIPPJY1eJ7fjrpdX4K9wuQhkMkNhx+YVf/4wfzLzp34s+a9kCq+gA4mhAIQGxMCpSL6waOsizQ5dECkd897Tf1QBDdtVUy1VCwlQqxCOLhEGzY6uT9tcTa8xmhEwuod/L8UVfbBVdVr3vn/o/AB+mQsLzDDZB4FHbTj3/7WolFSj7byWzGtSX6OpoQaAsyv8VZBCkLKVxrlpEBsroMQMl9LAAL75M/iaLs4F9P7tO/1XHB9tragVRVEas0y0vPPXP0pU7h3+1Yv+q+TeDHpCGD1M9u36CFnrXk/qnjism01jpwk2nOkGzlcTJoWGYCSKQl9xBfGAmWgQh2mWBFfkPflomPi9ad4K66i7u799fYsebtnnvFNyue+v5tn80A30MOWb+HEyD56PPOueIH0ApQU8dblI4vynXI3l4GNyI6FpShHRS1XmZ2BQsJL70JgzADZxA+B19WW7KFf2Pw1D7RTRB9pnUbeGKqmneI501af9rSf8uGQ0C9DzVA2L2zs5Ytc46ZXXJFzAPalgTjnhQ5khtC8WLbgAKBAl2qACR+c2QsCNgQWTManCesMLQo+uyqtQbWA+SDtGvDKsVMD1l0pjYg8oYdnYT8mTu3wjSLX/p333td1erAEORQASTuWVi81P38G5+cdPudW+/+5dLbG04Z4RbU1knSY4IuZlIe/q2UKNmUUoTuk2hQqYoNjIWtgZkC4UUCxyKMLoMZafaGGw/eDtO+0MpsxzgUDU3E2r0X0pPt2IKrvrf2LPDb1gAdcVixQxXRQqSeL7/pD6dffvk37zttdnx28QiAxn3APvgTeNX7wRFEwFFJUMzc8LYMvPrGIkTB6uHmtZJ6amm9tUCjfGy5qIFIa9NWRIPGIhbR4tLU3y+2U2I/J9fJtH/No44G2poHe29cSiaC6mrAIGQoAGmrcc++8t7Sb191/R8XL8yZG+8Ctms787ZsIXZdHS9j+3k2R4/nENQpRWkdTRrMGgUDTL6iN0AyHejrrrH1KMGdV9NZReB4yhJFukj/Fi6YKaBEtiHt+esu7s6LisDNmwjOO2s3nP/k/bNXwCBlsP5Rxxr35n/def0NNxzzSCG/+S1rIb1hA3Oa24gjAqfITgurETGE6nhj+du2orQWUpDk5BDEJUmD9U4IGBfBKRzwj1u9gaTLM+hVMCC6XjkgqMHRFqP2gdqWHV1A1scbY0MjOLFsYEcdM+0XfO8KMF3lgclg+kG64dKHl6dfvGLJ6B+1VrH0H1/kAXIbOB7v6GRlgZwvIEZBtZUwlWvTWQCGagv5chZqyKFtHXsyhBozupppwXFKlu+hnEcj+wABQYN90oLAtyZPWZWH3Z8ai7IZZXllsfFN+8c9XF39chsMQgZqQQacR17p+mTeTGf6ptUste4jiIsbHZHlW4wAIEp5baUgz/Ldl2UFuS4LMTtLAagtCli42Rm3FtkXzVISBn3n6JTQaLumAZCgXZ1ae14QmzQYGjQZozSB4TfV0sGfsp7n7o4/aSmsgwdgEDIQgLRb8379ctcnJ58Qn/7eCpba+hcSF1lpEWcECrjzaNYQ9De0nQs3xZR/E4oIAaNcEmXhi2Mv1WM8UmIA7qdT0QxOn0zRWtN4bTlyG8ciBZoXAUlYURMfOaqYMu0iftqgABqIi5Ns7b6X3FdnTI7NW/ceTW3bYcUdMZ4TA5O2wWuCBuCiGmRK21Ip2tpYN/Yb0GQWuDHszgDvQy1fB/RMrs+UjcQVPWZEEUnQCscWI8FAAOnj2uXpY65PGlh8lDOyvGDbPdu2beunTYeV3h+RbO3v7znw/SlH2xds2ci6/rLTSog4o12ajCtoLYkBBMAwpXFqmeISFILIgqa98pTIo2ACgUWfA/h4xCdGz2HoHBwAdSMwdSMioMmAzGqra7g0AMZFgHuYXHhAsl0oSjrnjAJ4rh4GKP0BSMacBZfcPf68+aX/XruTup98aiWsmJ8s7AaMIgCMoN9ihx3EGKrK2Mhfa8XgNIsQ4+7ULpapDWZQtoVAk6kitW2yRypG4eoYDZ9jLDgSZ7D1GZAQ9dakQU0JY9yK7OamxvG8isMCkIw7F1/7w5dTzQy2/MWyhB9OKLcGaNHDBCGgQMUeBIy2Brmtjok6CWrtGgyKUizyZljoZzjDrBSswdR1EI1MJB4ZWhw531gSdnUQAUi7PxoAxSLuUnV25eVTQMfAIKQvgMRjeX9969qzikfDjN2fQpoPtsXi8SDOaGA0INQKhq+1t7FU8JeuzPLB6OKjk8mkn1kYkeMnHImyJj0MoN0TbuXYDTK8HTIFgG59HoMCQLRDGq487OrMgB0EwAALuzHt/ozVsCD35z8SJRb5Ls+t/BMMVPoDEJs8deqDHdw499XwdJPjuzbNwIiuwQqvmTpb68NSZiMAbGykMP3oNEybnOBAUfjTxhQ0tSSgYCQxCuvJUkJpGVUOb0eJBrYaeQs0g5tElocZnFwpQEyHFAGiCYWH4w5D9FsDzVswZS8Naii8L4DokiufmjZ2QsHx9bvBTbnEEazNTPIgwUIQQFJBFvL5VgBSQ6MHf7WYwtwZCZkisfiJ8+bE4dFnu+DzvVkwMhdMh1BIFBizqV0QBFZGIzGIRqwK95UspTxcl1xpdBFQxnrUOcaqEDghi/JP05ZHhJaznOqDMAjpM5tddsKiWzp41Y1N4BCV7NQuDOywe2MoHjHl+ig61toJMGsa4+DEoHI/g921ALt4P6GuhcDV34zzh0pBl4o7Wk9myACCzDeNLJ5SrNnH/EkBHvodpedpFsw5oGrbYxEmpvo9Hg2GQzQYHqBtdA6DgFTIcwgw0U/MyinaC4OQ3gCStjH+mNIL+bAuTfEnsPmFqANmbpQGysJkAdWqx360VSV5JbOOA+gUxs4ZgUgFiRR9U7uYi2bBxWdzmnPQp1waFNP3UXWkMwFC/AyFBjGUqlHKdzMco0rRLlI+ReXlosHDMUb9dlE9uHEwCECTc8ttaKvbWVMLhxggNueyB47lwbsklVQ+3g6y0QT1d5i2JkSt9eCcdm9+n4j4gyORq4q4tqcOYM6JMRhdkJJDyNpSPOVCzTYoBUBYKab1gg+W7ofhctE8nhc5X1uFdpdRq9OAGwsh4eviOoWowUbS2NqxZcOGZR0wCOnVxZWWzZjbwt1bV5qHCkfdiErnmDEczeRIAAhELEdvJ3JsWPcJ5f6YhSI1UQrpcglcfr4FdU18CNY2D2gemqmMg942o7MKRKEwl6AWrM9RblO7y1BL13WrJWRtyLXKuiFcRxRw8xt10hnXW2drcrt61BgcSoAst3yu5vgmhaNBwP0fpQgztxpZjoxFahZPNk+mbtxhwef70jCmkMiUiLkWB2QfZ4rHTYrD5IlpaE+qB1RWaZRIEFCRRUMuf1uBgilmllj5BIGggNSNC1sDy7DQyLZuDDptJe+R7xyZzbxZJxVe81c3r14MvoceUIK6V4AmHD/h2I7WgIEByq3Je1FAaJdGrUB5DMJA6VZVkO/AM28xyE2w0MU1yM3cESw9z4KWVtdYiAZGKyUEHFIoJWHFAbIyF7d87YohDDYmIxCtF1ssoN+RBsMQsxXeprkd7FSd61582bzXln5n9QQY4Gyf3i0I3BKPBQrUw9AW0ipB5Y1SQIGGWrVWWoJb0ec1DmzY4cK40TKZaESQhtomgPLiOJwy3ZNgGctAgGjr0BbKotuqrIesDyA4V5fHLR9n4BkJztXnS5dIgsZIILiOnqeH85CSPHFbSXYR+GSrY9XtADp/8bzNAMv6DY6qsmfhw9QjpGJYAIhptcjtmMmEuvUASm5CuEWLcwoLbXh+FeVWyeTkeYZviD9UfQvAtxbZkBZvDJOwYjTo2orNxSIMEidpCYqbpvHo+wYEqg2Bi0KWHyI9JADatFYrONfEZbUWzLctCda2rZwAd7D8f7z7J4+BX3W/RhJ6R5NYVD+UZEZKk0bhSvBcNeyONCBq00ybEqytoT0OqzamoXy0P9/Z3BAv2MjHHvNzHFg0m/BtJh/eMEELuRk70mDwNgmUSiFsZRoM3G/TDYFaEBoeMW7cDq5h4rAiMjjl1W3Ny4jOfT3vR362naQqKrKuvvja5VMA+jeJpFeAGPPabN1MWWStthmEf2sxlNQK/LsJ4vzg6AICr34g3hqgPB5BqNcvAKxuBLjwdIdbWNrPFqj7kElV3WoBWYZWaITmayVBJIYyHD+RJWgvII/b6DgJyjE7DIK0Hju4DkPXFORHWLAgStU1EG/4nLHjTj3/cfWofVpRrwDZYO22lOVIZbDACvQ+SiGUXIzmupjxg4Er0WAlaQxeWpOCskLwJ84pEISSOrvEa/a887qAQW0jDVwJsk5ALgdPyQWsZG0d6HwDHAQA4v4cTgBjxQOaU25ikR1egwLEAKOOCVcnOvuN9cQrSJBTT1n49jTohxX1CtC+zz7e4WSDn4b3gk4aBgkUSDo/ZfJaFIEEYRB17kwkR9/eaEEDZ2yFed0Jwxecdi84IQal+a58P0c2ag0KBMrGcYNhayJhy5KKRGNYeCF2AKp2Z7ivZ1lhayR2ZFvVbWtg1DQzDZIEjIPU1AJObTXvlJ9z4u3qUQkMFqDG5sb1IhUja1CdAhoFSQGBE4c0cjxkRQxC4y3xRByeWelBUV7Y8oRiXJlesWDpIgIHW6iJPVqZWAgiBdhSQswLkQPAAOgFWQ9u/ditEQ2yAsBSyjc5StukdwKgHP+3mBsoXpZuawavoKRoyYkn/m0ORKLEgACq3bF6XU4ej4sO90Cq223GPcS2+k3VWupcWZNMxXsQegEqBJgCK5ePkmyotGHL7hSUFoRjkXio6gaA6ZNiUCKsCMBkBoBEQEBWQ1BcwWxPg2eOayvAMcgJAwNI0QQdt/S2gwCMAhP5TdQgZyoNJNkKWaUnXDwP+pDeACIb3v/l/pZGWsn9JxEzKOUYu+gLKxCkxWAg3AAQ3XfAw8HYFRpQxblcC9t2URiRiFgR+BZpczo+MseV1wpZYERMpgEChTMdxC20D1DMsgLL0C8u430hpueErUgDJdwadm16keWVdem1iEVpD6wW3vAKSucugSEAJJ9z9859f8jLkS8+U0+BRFWyysxk0UBhkNwABJppUeVF4CyIp+CSBXGobYDQDFEBcC6nqO1JBl/UJuS3eQYqBMKxCMcjs88OCAFB4BilEghPV8ZWprP72OUh4KSFOYEl2eq6Hbz7UFQy5vS+7t/q6/kqN/zx/uwcoIkYE5MffGtQn1thePH8aUauOm4sy0WWQgPANHE4UE/hynP9ptzmQeiFKlHPGM7wXlnL3RvXIKE93GQPS6gMge5v2OkFUAxT4OGUkLYczPB07DFgOAEY2vXplwOsqKuUTJa3+K5YGSx91h4SQOtXfq/hQEPXyyNGyPbC3DSyHGRRFA2iMC+wLJfqYB+U028EtLYDTB6TgjnHxaGaDzc46G5E+ZJ8kfrx4PUPCBTkEDNpMBTLFDHBmeVoRzrUjckEFCIL+riNAj/DrlCD5UDYPVp+eccKGJ8ua1vB6/7G/fEbzM6DghObd2fBEACSpGnrh+/dNLqcu5sY9SgHSIDkaoDwkg62pVWlg7W2Km1hAqSDB124fokDbZ1BXwa0cnnZAs5xHl+e5vm7WACsjmkAoVFWPegWGvVkwRhPKPcWWXS/qqdXH80YGKjF6oEoKOuzrWBeOmirQhYHxFBwO4e0J2AIAMkybz563r7Pd9Y/UlRKHIePuXmcTjH16RRXKV66Pa18D7m5TIDxcrU8U7BgBk+Yljqw/6B/86ZV8PNECmjz5ynYuN2B3GwIJhHSIMYBcp9Aw/TdiO5QM8g8oR6BpIchzILHvlBsCQFFwsdkPFPuzYrsxzNuBTPmwDodMdHTHBpA4r6tB3704Hfjo0hLQYFncaXQtLIYoXRhVbKFp4P45LrBtgFKrcU+2pWEv70gBjVN4H8bR+uTayvGf2TFKfzuRQqjChz/OjRC25VVGFdnxq7D2Y2eGF+/RNF5GulPmYwCQIgN4o9xMBSfQLlOQMf5fos3ds/yrF5n+wxg8GgZ/eiNhbMXXLJgR6rddQ82O5aLTV3CiG5c3Zh2GR5qUfsOULjuEp4QHWFLgMSkClFU6FmAV1EG8OrqFOytj0NZsQ+scT8QDvhMtWiT4VYxL+XqnUydi2iD2GfySpChK+8jw9O0EHOInDehwTJg20F/zkx4VPciZsPqGbVyjp96dvNpGmLikhuXMwRhyACJqmPP/+bMnQXl1d+eMrXsybYNqVRHMh63dD+DRFoTRQpVYIlWmOTKLslNwsVnZUFVrZ8Y1QoWD1TAO67t7R488RpA8SjLd4mW0aWxeV2vRQNwhDQ0M8jP9WDaeNFaPePCCMFIIIBQnaIAIb7JieOizgMNNuyuZVA4yjFv/ZmUFVK6mb1Kgt8yUUzBvNWu45SMa478tExrdifpOBQACRFd1Njv/nf5U3998/uTR5fOv731CxAfSCYGDEOVUALT8uGVGIlh7WoX7rzF5rk1S7Z029Yq811iSQnAvz/ZxVlctnRbMocatRh1HR30ia9baKijcP4pKbjqG3HeOnWEHqowWLc9Db992ZPjWJCJ6uvnRiDpacy6D4bfuRVr2xZK8WpWrVrm9nb1gT6B/AbNnt3xN3JHwe08nhCqrcWCHj/4INaiXCdvK3OOd2H29ARU7vdjjxYRX8pGAezdn4Ll7zswroxItohdpragUJ9GtX5R97QKF665IIu7Rv7bhW4fqRiwqNTE3ClxaG5LwdPvWlA4koQOyzXL5CZ9wczU3DK/5+xcniSubfoA+pD+kIRuUl5e+jftB/0WIqk1WlxNFNIBUfDUB/Oa6l04f76wHgLY92uXIdjaXb/zIC8v7neE02FWaDrBbkDV5X5+vKkpDUvmUTlM0eH6iUnbGuKiMgT7GxnMmxaDhO2aqcC6DyZB6MbZA4kQSvmsvGGynFzezfhi43LoQwblAwpKJs49uJdBKkV8lmSFLcYMlkX2uSkKsbgIGv7sIz1RXoAxaQzAex91wsfb4zBxvA82VeTDxCBVj2FFJHAhjKOXzeuW04kH1ewyCPMvl+YNyuJuImbxmMbHsPQ0LylUxRtM3SkiEypGaqQEoUgkgMVHAjvwxYvv9nULg3kUEndoeVsL54gp1fmMUmtNvdMB9RbWEONDC+/+icg3GTzeGZHfGuDLqByhaAp3/YbHoCJb1ivPS6n0EeoAUzeg9h6qG0gC1m91YGS2/8E+80Iw7WNhPe8THVzxJcYSnmXfy1NSjc3x4N1XTOtZOLOBBzYxSJpQZGUzy23ten/9ygcb+sJgwBZUUVGRSKcgN5303+Q2bwFYiLHpbWRFopWP5EmNP66wYM7MTjjnjGz5fRuRGrH5E//8ziS0tWfDiBE+MGbihRqoMwNo6hokco18ft5zrwLMnpqCqZPicnoxMQ4GR3AtmTpHPrUOihD57m1nisFDz3qcHToq+66smQW1mldUEDi6f6bBEY2GJ0Xc0eXEWbNi1R3qKploB7qjAcrixU+MrDjj27Xb1kJCfjlEuR3MUgAF9Eypk/01LixemIQz5mZDB4/mz73iwp79I6BkDJEP0i3lYqmqSLhOnEcTLk+0+ObmNFx2rgfTj83i1t392X06Hu4HmTUJ/xT9swMNLrz4LgOXW6iIkQY+hDfOXpgPA6LMB6OB9Y8eDTR7FKv6xdXW0eppegVowBa0p7OSTuCuWLRsmQez/BsKWYwXVrKZkqWUOabYgXfW5sIrKxn37XEoKkxAEXcjbjJidRoMADPNyYCFjoltTx3Lz4/B82868NSrIshbBlgdJ/GXhYXoeBWySNXjF/dtc5RGceaW7QSzjwh67m6ZWe3iIpYjAMrNglTJOIi/98pb16rSfeY4BgxQ194n0ha5LcmYlSU/Z2whZQJkTjhqhSrgRJDlNwt52cQoOpUOl7eQO9OdPNP/wUolgQXprHP+CL6RgxoFIFKBrT1q4XYAQAAY8TPmqaAuxb4DGo9AwiPL+lObwnIsQmlBIYm3uGzDy4+d9y5A/77fM2CAKisrU5dmWa3ciPIJH9SQL0LJJh60dN0SjVLBZy/d+jRaqRG3KFNDNChrYatEoFCkcC/aKNBC7SBumEyHumdpCPo+XWSZJAywaWQAob4NqOfQ4AihGCR/6IWVFFFaXuFYzz/6r2erMyj0QwZDs1lTfe3WRFbJ+M6WYKd2Zbprb1q9Whv/ThBYBEKukaG1cUNUVWmhcyFsOdSKKFRv6zKeX6cpC2DyZgI8CX6G+qOUHpDrDh4cjAURndpRRMFT8zaK8ll6/DQnvnJ91cK3nvtfzdBP6xEyqH5QfbLlvbyckm90NvkvMVkRhTBkNYBA0w+EJ3iEXAx03xcth11d1CKx1egpgdK6oscxG1RJXkD1GJA1mCSwGvOMAOHPeipXJkRTdeEFivK89ISpdnx3VetP/vO2SatggF8FHsQoP88kTJzbVT7xxBvqvpCdfEmIQql93dvW9673A4TeAZW7dFAFRFFVP0SWV8cJC7ZBuY5MkyfNe6deuF+ir9dtSpgK6H4y0F/rsScdQ/A9dZu8SSPxhvqWI9xl8SiaOup4O753X/Ndd9+YvwwG8fHzwVgQOUArN80qglaekc2Rg3fmSACEaeUQtF6G9ml3YlqnF5QxbxqgeCAburJGzBa1GxKCXZ1HMlgWclGYWYbIAw0sxDA9Amaut7bakFXJm/VXgq3x7gcdW+rSo0504rt2N//srpsKfgXBhw8HJIOxIFK3bZU384xbpnY1J2Z2tMq+HTE9bEW59acrAbVqhmgpnogftTZjYbgs66U1s8h5kV49Zd3LmnPUq/Q6I6B/a+vAr0Li9ynNwKFPAvzsCQcnP4+5EyuYXTHdJmveqVz88I/LHwffrWk7HZAMysUJyc2dsnPKSTNvqqniGRePty0ULLXCbe2mINjXzd1pd4jOC631fhV8Q+VpUGcUMEBlAYFlAEZrXJ++lh4D76lByASuSnMJq8vNAW9cuQuTpvPeV8zduOIPz0z/z4fO2gJD/BI9gcGJ5Fe33ul9vHk1mdFYR4h+iThasYmj2q1A2JURdIJxR3pXhNZiBkUyBW5E30NUG8LuLkTrI64LUGZCMjh0v9H74TlFNnIUsKLRQMom8PZjw/51qz647sl7T1uuahYGMKCYE5XBAiTl0us/OHlCxdyPNrzBUp0pEscftzAPz9BvQErSvwmEXxuEMKghhaPtEFAQvi5B9QFSahS0vthiiCkSNWytrD8n20uOn2xnjZ8EtKbRXbfxvRd+8drjV7yuHst8aBeGKEMBSDKSW+/qfPPzj+Pn7Nll+f+eh3SvnWTah35iZTG1HRrmRnVggM1k+Ch40N3CoLdMRw+AGdDRuXJSCycB5ZM4JbHa7n1z7e9vr1z+P3WPUFiMdqyHRAYdg8C/ESueij07e8nCHzd85pGOdp7QIGG9SNExQW2bz7uQyCEUw2Q5Chm/DxclD91iFgSxKXR9isqjOBii3hD8NufpaV3Ujz1ZfDxnwnGEvvTrHy2qXH9HBwRw9is7MBAZCkBCSFXVqvTI4qtWzjx19A31Va7b1WXZuCWHCos/UaVBGAS5mwTb3cDSCibQrZ8VAomiY3o/Kg8IFGCQkeHhKcq4P5afzwiNty5f8dxl/w9UtggOkwxmwA6LeLzYK48eu7a5s+nmWYucWG62m9IT6KO3jek2bt3dOo6IMSFCFbxApnYQ88WJoB79tSk9oT/09gXa1p+/1Ptkx1dNsNRzyimazyenMIuPlvORh7FHE9i5/eX/g3Rw2GQoMQiLpJI3/XPNXdms5JaP33HTjS08T0/Q8DMO5r3dEMl8hz3FsWiM0tcxb9qhMt2YIoGMbNCco+OiIjtiNbqEsYknkl13/5AcC/0YzxmqDNWCtMgvaDx0W+mtSWi8/bSLnFhpsec6ohF64ZgRmvyO3JyWbh1J1DfBqR7TCVU/9YeQ9NsT2sIsL3BjgHJk5n0lL5iAYl4684K0jbYuUYbT6lTFdEL+sn7/tfp24TDLobIgLZLZfftnXyyeOnHca9tWM9hTxdzWdsvRNJWQPu6G9HxTPZ1LulHC4CfebfozBIJPbUauF2V1QgQKYsRi/CTPGjuTfXj3P8TmwBH6l9NDJQlRkTHpk/fv2R5Ljfn19LNPWVJWTkrcNs9zUxZLp3mD1sE76n60YPaEpFdwIsQjREYAwp+UQYyOKPIh+16oPEWkQ35SjFtQ4ai0d9K5jvXmCw8eX125PAVHwHqEHGoL0mLGO664cfU1J8+Zd++BKiio+hRoSx2Dlg5ipfWbCTjGIGXjyYBE1WihPklGyWR9fcQwvSb4fNUh1eNb+XzIYM5iO1a1a8vCJ+49YRUMYDxnqHK4ANJ1q4FugAuv2f2dU+aO+4mXso5qrAZoPADQ2sTEP0USU5sY9/VEtm7fFcqvFIp3VrNyeSPnYDbUg9vWwd0K6U4IensKEt2IkIBu+wB1aAQ4uen0zDNjMc9pvfWen4y8Gw7xf3nsSw4nQPga5pkXXHTfseMrzvtWUdnES4vys6ekk5BP03wkwFU9X/BjlQAIsiHZlUxv9cDrSjZmnb5ljZtqbXPilPQwObGPGKaLQAamiPdTNcBYyC1n1gI71mG1/MsDP83/ORyhuBO5tSN+LeO7p01bGi+ecEbJiPyC8lQ6OY55bjaxbEosp97OGr37i4/fqN669SH5X0Ou+2ntP5eUFP/8zyuYW1tHLFdMCOoP6YA+yqDjmjk6FtCSkjSbtTBmt3W1c8vJFZZzxMGR9wZfnuDw3lc5oZz0dT88cPbYo0vfqlxPYe8uSLd1WDFRgWX3DYKpLML0hGj6L3bnZUNqwmQanzbfoutWrz/3hf+Y+zYcYbeG5csEaKAilXTa0n8rPO/cH7yZrIGTdm6itLbGYu0dYIuevhWZS9CbmHEg8CN+Tja4xWOZddwpnMDE2MZ333hq4brlV7XAlwiOkK8TQELU+9FAl9667cLpk4/7bfN+KNu/E6C+htHWNkKSKU42aNC97yknKGbEikns+XlA84uYJTqgiVGsZuum1dc8//CCN3Qx+BLcWvRev24SUtyV39+0pHzCsXfk5GTPauHssKGGQWsjYZ1JIGIypP6Yhuwo22ICv/xHVCyvAEh+KUBBGTCbuB99uP79O179/aJX1TUO+bDBYOXrCJCWEDucNe/OsqOOn3Hh6DFzLiguGXUSTUGhzSCLCmWLORM+rB4vnWRxVt/U3PnnlprNr1ZVvvPi+8t/VqfqxBN6vxLydQZISzd2KOTkk5eMyCu7ckSnW5/lxDpzWJq4+bkVLU1717atXXtPEpXXZKW/pGVYhij9bXT/HRrnsAzLsAzLsAzLsAzLsHwl5f8DGzhXq3EeY8wAAAAASUVORK5CYII=",nP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQoAAAEKCAYAAADqyxvJAAAoPUlEQVR4Ae2dW4xd5Xn3n3fv7TkYO8zE8BEUUcbfp2CjL1XGSJXakipjpF7ARWIiFYwvyiE3PdBCK8Wh3DD0ghJXSohCW/UigdwYJ1XDkAtyUSkMKrRSL5ipmsqHtPWmNAUKxJvEhxnPzF5d/zX7Hfbs2Ye13vO71vOTJh47gz17z1r/9Tz/5/AKYkrH+ceOzqzValPJ+vqMwK9EMyJJbu783zP4n6Tza/efDaEpPxGdz9P/voXPEyE+TNoi/XyjWavVWo2JleX98wstYkqFICZKzs8fmVpfmZjdaIvZmmjf3LnxZ9OPqc6HZ5JlQQKCsdxOam/Wa8kyi0i8sFBEQBYhEM1RknymIwhzFIQYKIFIZDn9dTlJklfbtdryrU+fahITNCwUAfKTx47OIVIQov05ilsU8oIoYzFJaq8i8vjU06cWiQkKFooAOPf4sdn2ejKXphBfSD5KH6pMFnWkKctLtYZYvOWpk8vEeIWFwgPSX0hDbwjDA8TCMIqmyCKO5KUDJ763QIxzWCgcAXFYW5k4kvoM93PUoM2CEOKlXRMrC2yOuoGFwiJdkcMTLA7WyETjlqdPPU+MNVgoLAAzktMK58DXgGh8h81Q87BQGCKLHi6PPZIIcaQTPTD+aKaC8eRG6mtw6dUMLBSacPQQNukF/jzV69/gyokeLBSKdAQC3sMcMcGDqgmlaQl7GWqwUBQA6cXq5ckHhGg/QqPnI5gwydISFoxisFDkQPoPbSEeJU4vygILRgFYKIbAAlEJWDBywEIxgHNfufeR1H+YJxaIqsCCMQQWih5gUraT5DliD6KqsGD0gYWiA1cxmG5QJdkQ4kHuw9ik8kKRzWBcGYdAPEoM0wP6MFLBeLLqglFpoWAfgslJ5dORSgrF6ceOztRTH4LTDKYgzbQCdriK0UWNKsZPjt/zRC1JzrNIMArM4NrBNUQVozIRxbkvH5tNautpNUPwwBZjgkpFF5WIKPAESGobSywSjEEqFV2UOqJgL4JxROmji9JGFKhopIq/xCLBOADRxdK5x44+QCWldBEF90UwPklvqGd2Ta4+WbZdnqUSCqQaqbK/Qtx+zfildKlIaVKPfzt+z/0I/4hFgvFP6VKRUggFnOcNIZ4n7rBkwmEqSY30slRFok494EdcvTKOSc8jxDDhsjA2ufpgzL5FtELBfgQTGVH7FlGmHuiyZJFgIiN7sOEBRxESnVCcPX7PkaS2wSLBxEhmcuIapsiISijQREVCvEhsWjLxMoVr+Mzxe6Pq84lGKLJ5DaJniGFKgBD09ZgqIlGYmXhDUyNoniKiNrGbxj7xS7T3tl/PPl99+y1av/ABrbfe3/pgmDQVmf/Uie89SYETvFDEKBLX/tpv0tThL2QCMYyr7/wntVcu0wcvn8o+Z6pJDGIRtFDEKBJ7Zm+n67/4pUL/DcTiZz98gX6x9Dox1SR0sahToMQoEo2p6+iGY39AorGr0H+Hr999622Zaq80z1Ks7D54iP7PPb9DyfpaGiG9RUx+EiHmHrn9/9M3X//XVylAghSKGEUCfPL35qm+51pSZWL/wcy7iO0mg0Bef/dDNH3Hkez1X5OK3t5Dt2eREgtGfkIWi+BSj1hFYjr1JOBL6AKheOtrxykWRvkxeD3vnnyWPZgChJiGBBVRxCoSCLmv+/xvkwlww62cPxt8VWQzzXqY9v7K4aGpFl7P7k99mi6m/gtSEmY0IUYWwfRRoJkqRpHADbPvrvvIJNOHP0+hc+NDx2li5mCur8V7NG0g2qoSuBdCasoKQiiytuxIm6mu/+JD2Y1gEngVeW9CH6CyU/Q1fyxNUXYfvI2Y/KApK5R2b+9CkQ3JCPEcRQhuGFs39O5bD1Go7L3tdlLBhqiWnvTeOPf4Me/b470KRdeoeJSzG41pexc9qgajGrZ8gBtdVRzxelAdYQoxlWxsvOh76tSbUGDpTOyj4mjJtgVuKoTroaFb2Rm78ZeIKUz2QMU9Q57wJhSdzVQzFDHt1UtkE5QeQ4sqJvcfIB1WuUyqykznnvGCF6HoTM1Fv77u6tt2m4my0mJAXoWKidmL7fes5BzxNXHqXCiwmTjGMmg/0OuA7kOb7J1VMw5toGpidsNTs3rg3jn7J/fcT45xKhQwZJIk+TqViEunl8gmIZVK6wYqFusXWCi0aYtnXJubzoSiy7ws1XYqdFHaJpQGrF0mhKJlzwCuEFOuzU1nQoFj/qiEey4vn3mDbIOownf/gSlTlWc+jDHTuaec4EQo4EuU9SxQeBRrDvJu36VSE0LFImEW3FOu2rytC0UZfYleLlv2KYDvBiwT//baBU47TCMEPeHCr7AuFGX0JXpxIRS+G7AaRvwJNjItMFVPEuv9FVaFolPznaGSs9I842SNnc8GrMb0PtKFUw87pCnI3NnHjs6TRRpkCYRD7SSZp4qAnZfX3HrI6o0sG7AuetitaeJ1rXtOPfAaMO4+KjK7fPoNeveFZykqkuSJc48fW7jlqZPLZAFrEUUn5agMMDUvvPIS2cZXA1bsEQVSpxsfPJ4rfcP+0hhH4pONdWspiBWhqErK0cvP//HvaOX8GbKJrwasumZEASG13cU6CLxf2GdaZCANI/EhTu8OR8zaSkGMC0WWcpSkRVuF9178NtnGRwOW7k3jaxgMvg62cRX9/qMdiU9TEBtVEONCUbWUoxc4+7ZTEB9RhW7VY8NDxQN+xMfvVF9TGGsKYqMKYlQo0FhFfMp4loLYLgXuPfTr5BLtiMLx1Cj6TkxsRY8xBUEVxHQjljGh6DRWRXPoqk2Qi7/3fbspCJ52ri7gRmTDYBCJ6+4udlrbIGJNQdCIZXIWxJhQ1BOqpIE5CPRWoMxmC5cNWEZKo46GwXAwtCmRkESagkyZnAUxIhRZNEHJA8Rs44MfnrLq9LtqwKoZqHi4KI1CJGBc2iDSFOTR9N6cIwMYEQoXLaQxAp/iw9SvsAUu3D2H7PdV6KYeLioeWZ+EQnUjL6FtG8tL3ZAdoC0UncnQOWL6YtvYvNZB+lGbnCQdbK+/sy0SEhe7R0yDe9NEVKEtFGxgDgdh9wcvnyJb6KzPz4vuDWgz7ZAiYXtfx5XUc4p1qK1mIOLXEgouh+YDy21sdmzabsAKdaEuBMyFSIAYo4kuZnTLpVpCwdFEfi688gOyhe0GrF2acx62IgrMbrja/BW5UGiXS5WFIvRoQobk+IAb7nuVHMqlNo3NUA82tiUS++68z9lhQkg58POLnKmrKxPKUYXymHnI0cSovBU/eHxgh4TLke3WKy9Z21SFqAIVEBuvR2f79tW3zQtFnlFxk9ge9HNGkjySRhXP7J9faFFBlCKKkKOJPHmrjDauv/tL9MnfnXcWbcDYtBtV6Lcs90Nn+/bqO2b9CbzGKUuvcxCXHGwwc4RyVKEkFCFHE0XzVoSvEBZXQ1aIKmy553jdLvoqimDSyNx98JBzkQArzbj9iW1sRhWFvYrCQhFyNIEIQSVvlanKtKOL0OYciOnXoF3xMORR4Pu4/otmW7PzgLKorz0alphavTz+ABWksFCEGk3gBtF9muJpdcN9D1tPRWCM2cp7TUcVOu8FRMLETSbTSdct1Ij83v++/f0irkkrII9QQQoJRajRBFprTYWkGAByUZu3ueAGohnCXIKp9fyY3vRRtfrg5RfKujl8pmi3ZrGIIkmcH47qA1yUN/3xCavOus05EHz/pr73sRtvIlVMlBQhehBv12D50OUzpTExd1B0BiS3UJz78m/NhjrTYavzD7V6fNh6OsPYtJX/mpos1fk7dH8uvszLi0uvZT+bMlN0BiR/RFGrF85rXGEzPMSTGYtZbYS+Njd3m9pXoRNR6BiZeL/33aW+xk4VXEtYD1AFRJIcyfu1uYQihn0TNs//lFURG6VHTJfaaEoCJqIK1e3buOFUoyWXMxzd4Pt9+9snylblGIgguj9vqTSXUNQjGCO3vRglK8+l5VcbJVRbTzATUYVqV6bOjkwsxPViXv6wtOblIHI3YOUSihiGv1ydQoWc2fQwks1yqW5UodqVqSrcEOK9HprGkAL6OIHNO0mS68k3Uih+sml4zFDgXHW45RlzFQiNMWxmClvlUp2oQs/ILC4UvsxLNFWV3bwcwmweU3OkUCQJRVESdX1cHSIKmJymUhGb54GoRhU6Qni14IyHT/OyjE1VRchjao4WCsrvjPoEQmFz4GoQeAKaKqHC2LRhpKlGFaor8PAaiuT6vsxLAPOyYr7EDvKYmkOFotOJaexsANvgRHEfI8GmSqg2p0tVogrV11N0mS6iMjYvvTK1sjIxO+wLhgpFktPoCAnk+j5++DIV0S2h2lrGqxJVqEZJRfwi17slJBDkn3uIQENlVKfmQKE4/2gWikSRdnSDm+zdk896EYvNU6X0SqhZE9aPwvAqVJut8kZ1GO33YV7i2kD0yXxEkpqaw9KPgUKxNjERnUhI4Ff89C/nsw1WPsDFr7MQ5+Ly61ZSqKJRhXqz1ehS9ebYuPuj+iAS8CWYHUytrQy+5wcKRYxpRzd4Mr//4rfove9/y0t0IRfiqKYitpbxIqrIK2B1iz0UvszLCxYXB0XPkKHPYR5FtBFFN3g64wniI7rQ6ea01YSFqCLvIl6VZqsrOSZG93nqvKxsU1VOhqUffYXi7PF7SiESkqxWnkYXcLl99PEjFcHYetGbw1YT1p5Dnx35vagamRsjTi3fM3u7F/Oy4k1VeRlY/egrFELUok47BgGXG95FLFURmzsrRkUVqs1Ww5bpclNV+AxqvuorFAklc1RScNG89bXjXpqzZFWkSIOWrZ0VeaIKFQaVRn2tswO+qmAxguarfn++QyiwoIYqcEwgymO+jM4iDVo2m7CGRRUNw0amr6Yq+BKu2/sjZ+rc48d2pB87hKItGnNUEaTR6aObU67by2N02mrtHhZVqLRvD1qmi0qLD1/i8uk32JdQoL2+Mdf7ZzuEoibapfQnBpHV1Z87YW0gaxQwOkctj908Ed1Og9CgqEIlRei3TBevy1dTVVU2VZmmJmjHD2yHUKBEQhUETx5fRiee7KPG1m01YQ2KKlSEojfEZ18iTvppwDah6OyeiGYIzDS40H32XIwaW7fVhNUvqmgonGDeu4Pi4x77JdiX0GKqd0fFNqHYaItKRhPdhNBzMWiDlq0mLKzD733q15Uiio8qHvAlfGyqYl/CDKKdbNOCbUIhRPtzxGTIngsf0YXcoLX74M7zLGxEFRAJ3W1d3TsoIBCIJlzDvoRBxPY9ub0exRwxW8jowkcZFRHFDcce3pGKIKqwIV44ba2bonMeeH/wPUMkrrvb/RmhAGe6si9hBkH0uZ7fb4KV/LUkOU9MX6R77yOclhOP8iZABIDSqkmTUDaiSfb/aVydjPAlOOUwS1uI/bc+faqJz7ciilq7XXl/Yhi+o4vuVMTGwUH4N0wuC3YJz3HYofuYji2hSISYI2YkvqZRe1MRG1vHZfrho1KhCs9x2KOdfGRoNuQnqWJ8JiEmDzK6QAVi+g63rclIf7B5qp/RqcvkzAFqEXnpe1CFfQmrzMhPtoSiqo1WOmRNUM2zzr0LGyIBUG2BSMQiFEi/TJyYzvSn29DMzEzsx7w6Pn6BGGWwZ8F1dGED9CFsrFzxYtoWAZu+/zstXzN2GZtcnd4/v9DKIor1iYlZnPTDqOMrujANmq9i4H9OPkuMfTqLbBYzM5M7Ms3gszJSJS4uvRbl+4toE2ljTFGn7NBsdH43Q4wxyhJdhMjm0Yt2Zl5MITtdYTpDFMbTX/H7bu8HYofXEbzgiU1DMxMKrniYx2dlpMx8aOmAJBVw48v+E4hCP0EYBKZ28QEz9sKPfhCyKTuD/5FVj8pOjNoG0cXlM0tZdHGth+UtZQIC4et0r0wMOoKwa3pf9rkJ8cchSDc+dHBzTuXlU+m18gaFRFrt+Ax+zYSCS6N2QSclVu9dPr2UHXrD0YUaLpYLyQgBY/YyQnDRsSoPRHrzqbCEgjpBhODSqFt8zozEDHJ608cX4GeBJ3rRtMEmmLcJzbfAzEeDS6NuYe9CDV0Ds9tgnNx/IBOIEBvLJtLv7eJSWEJRr9WmGu12e4qEIMYtXBnJj4qBCVHATYdIAaIQiyCvXxh9bqtrkiSZaSRUnxHUJsY9HF2MJo+BGWIKoQJea4jVD5EkUw1RS6aIMw+vcHQxmN5oIpYUQoULgY7Kp/KQRhSpWnDi4R+OLvqDkjKEACXJmFIIFVbOn6UQEZTc3EhF4mZigoGji+1AGFROg4+N0NvSa4KbrYLD9yZwxj2/WPoHChcx0yAmWGDiZU1adz+U7Ypgysda+lDAzzj0vRri7FeOnk/tihkKDOSmMKw2rlzZXAWflo1kaIZf8WdVetri7E6E4GUx7qoK9mjAi8AqQ7RrR3INN4OLKGQrK4yrPEjB6BYRKS7ZR/p5GQRGRhdYsstGZzxIYcg+0qgh1odbUBEFoogpR0/NXoGRv5cH7SKC2RKbng/f4D2qgsEXI9gInkULqagPOt09QpqpUNwbRBcFxOHmx+PYWtRPOKTgdAtN95+bvmjQS4Ct3Bxd+AM/zyvZMY+bqUSJhGEHwaQeMZ0pobOAFsIhU6C1TtQi/RcZ4eS52OSByjgIiLGPFAX8rDJhSN//Km0xC0YoapOTVAUQAeSJAuTTSQpKJjAdYZHA7GXMg/cY3kIWJaQf8BaqvtowGKHYDN/+M7344zytyjSxntoVGywK+QhGKPADe/eFZ+mTvzfPJUDGGmudwauV/zjHolCAoMqjch0YyqMMY4KylCd9E1wfxcXl17Lcm/dLMkWRaYQUhjJXIVwTZAs3TqbGOZjsVzDD6C5PSmFg7JAKhWiG1sIt/YqP33V081wENvYYYn/BI+G1cEtwEchj4+SyEqw2A9iQnP3aKTN29zXs4gak0sD+QjhEMT2KCyR7khSYsJPi0S0iUlik0Oz4vEtkWHzc05tGsDCEQ0NQ0kw6pwGVCVtzGf2Ep9//J+kWoq2v6Wku69eAJf+srtEFGhuyFRrI18xi4R8hRLipR6j0m+9wQb8Iafrw50u1p2LQoFt323tv63vvz4J9Czs0EiHe5HM9wqdfhHTpzE2VWGiTt+1dl24x6jdN3D1pnHcmpwy0k+RDjigi5ppbDxFjDhUxGrYPpXdVQcTl2yz1aBITFUg90JCWd7kPYw+ZCuYRGWxYx7GIsaVHqUfRwhbuJice8eByuQ9jFqSJWAuAhsJQz/DoR9JOWo2k3W7xkYLhg+iBT0IvBxD6PYduz/aJxBBdiHqt2RBJWh5loQgWCMT0HZ/nNKNkQPBjiS5SM7PV2KjXWzWuegQHUouP33kfHwJUchBdNKb2Zd5FqExMrCxnocTZr9x7gfggoCCQRuXHOkfpVQWE4ei8lYcN704rOuORHjasAg57GnUYsy8OfPW7olMeFa3UsmCh8Mye2dtp3133VdKo3HfnUXr7uRNbrfrypqmKcKDZDJu7A/QslvE/MqJ4Mf3lCDFeYB9iE6xChFgMa2Qqs3Dkef2uSUuji7c8fepwFlGkDsWbbGe6p+hhR2UH+0ewCnFYNaA34pBTxfiAcMRcFcLrR2SBNCQUUiPzn/HrZuqR1Jok2sS4AU9BXBAfs7jFCzfahR/9ILq1grjRcRpa3tIhuh3x0S0cY5/YbG1H5BHbLhNcE6iCBBNVJJsNmZsRRS1ZFlz4sI4ro/LD9KZB2S3Wp2tRsehGCsfF5de3/q7eqCNkbE09q5LUROZRZEIxsbKyfHV8nBh7uGiYQo77wQ9PZaE5hAgnicWKjlh0IydPcSAwkEuQ4HEg4pgMLO1bDWweBKVR/LplTXCJ1A6ujEqEq62uxp0b7ns4vRluo9jBTW67gxE/m+6Iw6dBimjwZ+F4FK20NDqNT7qnRxeJKx/GwBMRzTS2G6awFer9728fNIL/UQaRAKYii2FsbU97ZfP33akKIg5XwoGf5cWl1ykU0orHsvx8Syi48mEGVz4E8lhEEb1NOhCJqZKddO5CLLoZZpBOpuJhOn2EQLRS47nIqkcXyIoH2BKKWqoeCbdya+FqsrNfFAF2HzxUOpGQuBaLbmwZpKEKhETUaovy8y2h2EhTjxoxKiDHRWeh7XNIBkURYLMn40ukAm68d08+m5mtIZ95itco+yx8LoHRNUhDFwhJGlFspR7bsg02NIuBi2PfXUedNEwNiiKAfNqqhsRvfe149vfu/9NwB5N6ef/Fb9EvAsrne+nXQRqLQHTYMjJB7yq8RWJDcyQuGqYkiCLQqTfI5ML3oiMS+LshErF1h15395ey1xzqiHZvBym+15g2W6UmxKvdv98mFElSe1WINgvFAFxPdl4+/UY2fjysAQej6KoicXHpta0LeXeE+zelHxPDtqjotoMnWdCwxXah4A7NgWCyc/qOLzjbBv1emmaMClGnNcqvWYv3Kz/Y+v1k5xS22JDmcUjzEWVAdmRKdlRE2afYjuvJTtl+PaqNF/4IjD1V5P4HILctxQwW1+K8Wj4wyAjb/Amwo9AhOvPnDHYk3Jfl/y5EQnYgoitv1MWOG1unPRuhene0UiRKctEpqQJ6HCCcvFNUn+5GK8kOoWgntXjWA1siK8P97rwTsxIgivjpX87ndsN1ZkYwD9Lqyenhzudl9e23su8TqZEpZNlXV3x0qz/MJu12skMDdghFLVlfpAoDsxJPJts9EaBIFCGBL6Ea4WT9Ei88u+PPi0YUIHP1z5sp8+G1Q7yydEjz72Sx0KfWqC/u+LPeP7jlz/8GYUeLKoa8wFBFcFHRKBpFAN3Oy0FP7fECEUW3oI2qyOQF7z2it0w4nzuRvTe6fx/EnhcCKdG85amTo1MPkBY+vkMVQkYRLi4shP4QiCJRBMDFj32aquDmG9aLkZduocHnuje1ZPrwRxUlvDe6JU/ZX+IqfSwLQmwvi0r6C4UQC1QB5MXkIoqQefhP/2peqf0YY+Oq4TRu6GGjy0Xattc7h/ZK0IdhwtjE+3/93R9t40IqgrZy3YgFhvR0SedfbJCI/h5lX6HAIhsqefqBMB4lQVft14giWopPSVzoOp4Jcv9BFJ3t6L1xMwH8kRn/G5WL7ggAsxR433SFCOkai0U+DvzZC32DhL5Csf+ZhVZZy6R4cuEpc8OxP3ASRaAR6B2NciIavXR8CdmiPYjG9D4qQr8nPKYqTRmb3SkIMFWOxXvYHbEwO0kth4GKP3hgVIjS+RSIHuBFuMhbZRShc6gLbhh0g6rS3aI9iKIRxaAbtrvLU4feFET+m3gvdYfA9hz6bJbC8QHP/RlmOQwUil0rK/iPSpF+yCjCRdnMRBQh0fl+e1u0B1Gkh2LY60H1xpSx2ZuCALyvmBjVNTmx+evGB4+zWPRhYmKluFCUJf2QpbJYogjJPo1hLwAjMI9Q1QvcMKOMxTyt53npTUG6/w3duQ55fgj3WnwE0o798wsDA4Ohu2o2hHiSIsZV8w1ujndPftNIFAHkhKoqeOrmrawUST02RoiArOyYoF8KIvl5pwdF573mxqztjKp0DhWK2KsfU4ftT3tiFByLXy6fWSITyKW8qmTLUXLerLgZi4TgGzluTNzE6BUxQb8URAIh1DU5WSy2aN369Knnh33BUKFA+hFz89Wugo5+EaQbb3JiUfZ1qObP+J7eLzCDUdTIXOvpoRgEzhYxxfQQsZc/A52KC4tF1mQ1sm9q5JrMqjRfFUGl/ToPCLV1Ltj3BqzKG0RtcpKKkFcQ8b4g0jLBsBQEmGj7lj5WyPtCbbJBoyucI4UiDUkWYzU164afEipDXHnRPYujd3Q8D0WbzdYv5BchRBWm3qNhKYhEt+1bRnO7D5bjPJQCNHGPj/qiXIu306giytHzXQaFwlYUAXSHvfqNjuehyDAYaK9cyf21m+VZc5fNdA6/SbciIo9htH1oU0i0cxYscgnF2MrKM1TBiVJgM4oAusNeg0bH86Dbvj0KGJumOjZHpSDd/6ZuRQSLeyvU8r2Y54tyCUWMpiYuLF33PRvishRFSHSNNNWFL2MKZ2yq/DsYRTdFnhQEmKiIVGE+JDUxn0/Tjmaer8195k9spiaefjC5VEw1OQpusoGoH7pNVRAJ1bMqGwoVIZX3wkcKIv/d7KAgjYdF6cWiVv9G3i+t5/3Cv3jtx80//Oyn59JPZygSkvU1uvTjf8ourPEc05dr6cWF0PW9v/lr2rj4IdlEHj+oCm6E/1FMOcDeXzlMEzf9v9xfv955b1RYaZ6la1Ifpr73WtJFNHbR+Cdu2jrebxgQNvz863uuzfXz7weiGGygxmsoE0KIxVv+7IWv5v36BhUAnZq1JJmjyMCMAC70PalJJY+Dw14FfCBMxQXlclkswn7swFAli5a+rbc1u6iRuab5/iAF0dka3o1MQfIIl5wRwc9XNTrYbNzbZzSN8s1GQSuh8AHmZ79y73mKKKoIDRMNPu+lF/5FzUnKmx9/tpBHcen0UhrBfJN0gDhea2jmBgJQ1LSEQKOqofre5zmQKRKaB7763f1F/oPC5xInSS13XsPsRGdTFRi20i4vKkZmsnqJdGkZ2LQtyVsF6UaanKrNYGWZPG0rzHAVForxq1eep4qWSnXR3VSFm6xlwBgc+0SxtAPkbd8eBp7EJtf8562CdCPLyaoGawkmT5uj5jr6UVgoUCpNnRCOKgqia15KX8JE2KsiVqYiAZN7K0DeKkgvrU7pW+V1xTwf0lacCC8sFKDKDVgq6E6EggsGw/aiRiZoXzGXl/tOQSQ6qQh+phGu1lOKJoCSUHBUkR/59NHJa/OstCuCykLhIu3bo/8u/ymIRCcVcXFIlEnaGvtllIQCcFSRj313HtUKUXEhmxzbVp2QNF0+DiUFkaikIhD/iCZOlaMJoCwUWVt3QlFvwLKN7kQoMOVLSFSMTGCjzySUFEQiU5Ei8ykT+w9QDLQ1t9UpCwU4eOK7iCqaxOxAdyIUmPQlJAjTi2KrbyCkFEQi91vkTUVU/B4PaEUTQEsoQKpUDxKzDd2JUABfovWK+el+lQvbZteqySU3QDcFkchDk0e99l+88Q8UOm0Du2+1haKz2GaRmAy5AEXXlzB1TkYvKjn1huVORJPdjiZSEAlEbFgqorIsyDWY6dCNJoC2UIDYt3WbxMQTLe+q/aKoHp/YvmKu4tH37w8wBZEMSkVMNb/ZZoPISMSfe3p0GJgsffizn55OI4tfpQoDkbj2N+4iHXBBYuLRBrtvPUS7P/XLVJQr//bj7MMma++/nUUDRSZah4G/59K//JOxSAXTo2idXzl/llb/69/pwt/9bfAzH9g3cfDp7xrZI2MkogDjq6vzVOFyKUJ6E+alzaeUainP1Q0RWhWkF3xvODjZ1AnulmlukLlI35hQVLlcilQDU4k62BYJoOrQu7opNg9SUt+x0QtSkD0V2n/ZDQzMvNur8mBMKADKpVU0Nq//4kPam6pc5LvKzVYGBsLygl4G3SMDu5mMpM/BME0TBmY3RoUCbFSsXApfQtUkBDih24VI6HyPrnNxk0t5xfg1VDXSaOIwGca4UGThTkWqILrDXhAJbF9ywZhGY5AP085UyTSShihjmE45JMaFAhx4+tR8GU5CHwX6JVTB0tefGQyxR6Ezk+DDuMO/aaJkGvuSmYIg5ZgnC1gRiox2vdQpiE6/BEQCtXmXT2rVJ6vPEiAqDLqDY0UPYo4ZGymHxJpQ3PLnJ5fLnILojjW7vAF1phx9lwFNlEyrIBS2Ug6JvYiCtlKQRSohKhefPGvC9c2nk3ZseG4qMlEyVZ2YjQhrKYfEqlCAThWkVI1YKimHL5EAOkbmRgCNRbol09pkqSOKls2UQ2JdKBAOla0Rq6hQ+BQJoLMzYc1hD8UwTJZMy0QqEn9kM+WQWBcKgEashKiSq/Nk6Owz1x/XSD1CmmdQKZnifcd8RhnBPWW6sWoQToQCdGZBmlQCipwslp1/+Y7eYck6IPrRGnm/EM5Mg0rJFL0qEcxlqNAcn8zuKSc4EwrMgnRyqej9Ctz4b33teHrRfmvoRYgTvXyKBBjTbDgyuVTXBHlLpmudw5FNLiUOiOxe2j+/4OxeKnykoC6nHzv6QC1JnqMSsWf2dpq+Y7OvAtEGnmKXTy8FsdRE9xg/LJz1LXb9QCUH7zf8F4ihTK9Ceu9tga1yrlIOiXOhAKlYzKdi8QSVCFy0uHhxgYaU16N7VGfO482nHi7DWZulodMvMU+OcZZ6dNN5oQtUIuSugtBuKh2RACwSQbHgQySAF6EAY6ur6K9oEmMNXZEoqQkYK82xyVVvYxHehKLL3GwSYwVdI3ONhSIUmq7Ny168CQVAo4ho1+8mPnHMCrqH09heqsvkInugumiqGoZXoQDZ8FiS8NkgFrj69lukQ7J6iRjPpPeGb5EA3oUCHDjxvYUkoT8ixii6PQShtG9XFdwTuDcoAIIQCoA27zafD2IUVCx05iO44uEP3AudIzuDIBihACj9sFiYRefEsZDat6uEr16JYQQlFIDFwixoAFONKq6+o+dxMMUJUSRAcEIBWCzMcunMEhUF+x+4j8ItoYoEMHKkoA3+4rUfL/7+b/yyEERzxGix+l//kf06uT9fAxaGqT78+5eJcUfIIgGCFQrAYmEOnJ2JcunETf934Bo/mJetVCBiOHy3TIQuEsDLUFhRyjhE5ovs+MP7HqaxGz9aZnMl9TEwcYlDeLnS4ZYYRAJEIRSAxcIs8uAi9FqwOPghFpEA0QgFOHP83kfTPOTrxDCRg2aqkPokRhGVUICzx+85QkJg8c0UMUx8tNCWHUrHZV6iEwqQpiEzaRrySvrpDDFMPGRDkNl8U2REKRSAxYKJjGYIU6CqBNlwlQe84WOrq4eoZJuymFKyMDa5eihWkQDRRhTdcEWECZWYKhvDKIVQgM52b1RE2ORkQqDVOcXreSoBpREKwL4FEwhR+xH9iNaj6If0Lap6fCHjH1x7sfsR/ShVRNENpyKMY1o4jDumJqoilFYoAKcijAuEEIsbREHstrRFqYVCwlURxhZlqWqMohJCATi6YMySLIt248EYuyxVqIxQSDi6YHSpShTRTeWEAnB0wahQBS9iEJUUCkmnMoLoYoYYZjClrmjkodJCAbLogmiekuR+Ypge0BcxPrk67/PczxCovFBIIBh1oueSJJkjpvJ00gx4EYvEsFD0wulI5UH79YMsENthoRgAC0blqLwPMQwWihGwYJQeTHl+Y2Ji5Zmq+xDDYKHICQtG6WCBKAALRUFYMKKnmSS1b4zvvvI8C0R+WCgUgWCkVZL7uUoSB1zF0IOFQpNzXz42m9Tbj3IfRpC0EqLvJEIssEDowUJhCPRhpL/McVoSBMup//AS+w/mYKGwQCoaczWiB9IoA+f28eIcN3D0YBEWCstsmp8iFYz2EWJM00q9h2V4D2n0sMzRgz1YKBxxfv7I1MrKxBEWDW2kOHwnFYcFFgc3sFB4IjtDtVY7kqYnnyP2NEaxlVZw5OAHFooAQOWkLZK5Wi35QlpunSX2NbKood0WL6UR2GJVtkiFDAtFgMAMFW0xKwSl0UZ7jsovHGmEUFtMEno1qSXLbEaGBwtFBGQ7M9rt2TT0nqsJ8ZnIo45NUaD2m+nrQaSwWMWNUbHBQhEpHXN0FpEHifYMBCT1O6bSXH6W/NMiIVqUiGUIAiW1JiIF9hfihYWihEgRSaOQVDjqM6KWCkgqIoJqNwuRZJFI0m2gJsnM0L9QiObWp0Ty82bn73mznX6e/lstkTSaG/V2iyOE8vG/NDMyyjmzsTYAAAAASUVORK5CYII=",sP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%3e%3crect%20x='1'%20y='1'%20width='22'%20height='22'%20rx='5'%20fill='%23F4F4F5'/%3e%3cpath%20d='m6%207%205%205-5%205M13%2017h5'%20stroke='%2318181B'%20stroke-width='2.25'%20stroke-linecap='square'%20stroke-linejoin='miter'/%3e%3c/svg%3e",rP="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 Dk({agent:e}){const n=e==="codex"?tP:e==="claude"?nP:e==="codex-cli"?sP:e==="claude-cli"?rP: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(lR,{className:"size-4 shrink-0","aria-hidden":!0}):t.jsx(Xa,{className:"size-4 shrink-0","aria-hidden":!0})}function oP(){const[e,n]=p.useState(zk);return p.useEffect(()=>{const r=o=>{const i=o instanceof CustomEvent?o.detail:void 0;n(Hv.includes(i)?i:zk())};return window.addEventListener(yg,r),window.addEventListener("storage",r),()=>{window.removeEventListener(yg,r),window.removeEventListener("storage",r)}},[]),{agent:e,choose:r=>{ZM(r),n(r),window.dispatchEvent(new CustomEvent(yg,{detail:r}))}}}function sn({label:e,prompt:n,playgroundHref:s,playgroundLabel:r="API playground",disabled:o,compact:i=!1,compactIcon:c,variant:d="outline",size:u="sm"}){const{agent:f,choose:g}=oP(),[y,v]=p.useState(!1),[h,x]=p.useState(!1),[b,j]=p.useState(!1),[k,E]=p.useState(null),S=p.useRef(null),N=p.useRef(null),$=p.useRef(null),_=p.useRef(null),O=p.useRef(null),L=p.useRef(0),P=p.useId(),R=eP(f,n),A=f?R?`Open in ${wg[f]}`:`Copy prompt for ${wg[f]}`:"Choose your coding agent",M=()=>{var z;v(!1),(z=S.current)==null||z.focus()},F=async()=>{const z=++L.current;v(!1);try{if(await navigator.clipboard.writeText(n),z!==L.current)return;x(!0),j(!1)}catch{z===L.current&&j(!0)}};p.useEffect(()=>(x(!1),j(!1),()=>{L.current++}),[f,n]),p.useEffect(()=>{if(!h)return;const z=setTimeout(()=>x(!1),2e3);return()=>clearTimeout(z)},[h]),p.useEffect(()=>{o&&v(!1)},[o]),p.useEffect(()=>{if(!y){E(null);return}const z=()=>{var de;const se=N.current.getBoundingClientRect(),J=Math.min(240,window.innerWidth-16),re=se.left+J<=window.innerWidth-8?se.left:se.right-J,ne=Math.min(((de=$.current)==null?void 0:de.scrollHeight)||340,window.innerHeight-16),me=window.innerHeight-se.bottom-12,ve=se.top-12,je=me>=ne||me>=ve,Ve=Math.max(80,je?me:ve);E({width:J,left:Math.max(8,Math.min(re,window.innerWidth-J-8)),top:je?se.bottom+4:Math.max(8,se.top-Math.min(ne,Ve)-4),maxHeight:Ve})};z();const V=se=>{var J,re;!((J=N.current)!=null&&J.contains(se.target))&&!((re=$.current)!=null&&re.contains(se.target))&&v(!1)};return document.addEventListener("pointerdown",V),window.addEventListener("resize",z),window.addEventListener("scroll",z,!0),()=>{document.removeEventListener("pointerdown",V),window.removeEventListener("resize",z),window.removeEventListener("scroll",z,!0)}},[y]);const I=k!==null;p.useEffect(()=>{var z,V,se;y&&I&&((se=((z=$.current)==null?void 0:z.querySelector('[aria-checked="true"]'))??((V=$.current)==null?void 0:V.querySelector('[role="menuitemradio"]')))==null||se.focus())},[y,I]),p.useEffect(()=>{var z,V;b&&((z=_.current)==null||z.focus(),(V=_.current)==null||V.select())},[b]);const q=z=>{var re;if(z.key==="Escape"){z.preventDefault(),M();return}if(z.key==="Tab"){M();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(z.key))return;z.preventDefault();const V=[...$.current.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')],se=V.indexOf(document.activeElement),J=z.key==="Home"?0:z.key==="End"?V.length-1:(se+(z.key==="ArrowDown"?1:-1)+V.length)%V.length;(re=V[J])==null||re.focus()},W="flex w-full items-center gap-2 px-3 py-2 text-left text-body hover:bg-accent focus:bg-accent focus:outline-none",K=t.jsxs(t.Fragment,{children:[i&&c?c:t.jsx(Dk,{agent:f}),i?t.jsx("span",{className:"sr-only",children:h?"Copied":e}):h?"Copied":e]}),U=i?`${e} · ${A}`:A,H=`h-full !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none ${i?"px-2":u==="lg"?"pl-5 pr-1.5":u==="md"?"pl-4 pr-1":"pl-3 pr-1"}`,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:N,role:"group","aria-label":`${e} options`,"data-state":y?"open":"closed","data-size":u,className:ae(cl({variant:d,size:u}),"shrink-0 items-stretch gap-0 overflow-hidden px-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring",G),children:[R&&!o?t.jsx("a",{href:R,title:U,"aria-label":i?e:void 0,className:ae(cl({variant:"ghost",size:"sm"}),H),children:K}):t.jsx(B,{variant:"ghost",size:"sm",className:H,disabled:o,title:U,"aria-label":i?e:void 0,onClick:()=>f?void F():v(!0),children:K}),t.jsx(B,{ref:S,variant:"ghost",size:"icon",className:ae("h-full !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none",u==="lg"?"w-9":u==="md"?"w-8":"w-7"),disabled:o,"aria-label":`Choose coding agent for ${e}`,"aria-haspopup":"menu","aria-expanded":y,"aria-controls":y?P:void 0,onClick:()=>v(z=>!z),onKeyDown:z=>{(z.key==="ArrowDown"||z.key==="ArrowUp")&&(z.preventDefault(),v(!0))},children:t.jsx(Mr,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:h?"Prompt copied":""}),y&&Cs.createPortal(t.jsxs("div",{ref:$,id:P,role:"menu","aria-label":"Coding agent",onKeyDown:q,className:`fixed z-popover overflow-y-auto border bg-card p-1 shadow-float${I?"":" invisible"}`,style:k??{width:240},children:[Hv.map(z=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":f===z,tabIndex:-1,className:W,onClick:()=>{g(z),M()},children:[t.jsx(Dk,{agent:z}),wg[z],f===z&&t.jsx(wl,{className:"ml-auto size-3.5","aria-hidden":!0})]},z)),t.jsx("div",{role:"separator",className:"my-1 border-t"}),s&&t.jsxs("a",{role:"menuitem",tabIndex:-1,href:s,className:W,onClick:()=>v(!1),children:[t.jsx(xm,{className:"size-4","aria-hidden":!0}),r]}),t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,className:W,onClick:()=>{var z;(z=S.current)==null||z.focus(),F()},children:[t.jsx(Xa,{className:"size-4","aria-hidden":!0}),"Copy prompt"]})]}),document.body),b&&Cs.createPortal(t.jsx("div",{className:"fixed inset-0 z-popover grid place-items-center bg-overlay/70 p-4",onClick:z=>{var V;z.target===z.currentTarget&&(j(!1),(V=S.current)==null||V.focus())},children:t.jsxs("div",{ref:O,role:"dialog","aria-modal":"true","aria-label":"Copy prompt",className:"w-full max-w-xl border bg-background p-5 shadow-float",onKeyDown:z=>{var V,se,J;if(z.key==="Escape"&&(z.preventDefault(),j(!1),(V=S.current)==null||V.focus()),z.key==="Tab"){const re=[...O.current.querySelectorAll("button, textarea")];z.shiftKey&&document.activeElement===re[0]?(z.preventDefault(),(se=re.at(-1))==null||se.focus()):!z.shiftKey&&document.activeElement===re.at(-1)&&(z.preventDefault(),(J=re[0])==null||J.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 z;j(!1),(z=S.current)==null||z.focus()},children:t.jsx(Zo,{"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(nn,{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:z=>z.currentTarget.select()})]})}),document.body)]})}function ra(e){const n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("AgentRun needs an HTTP or HTTPS server address.");return new URL(n.origin)}function ao(e){const n=ra(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 Hm(e,n="",s){return`${ao(e)}
|
|
585
|
-
|
|
586
|
-
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()?`
|
|
587
|
-
|
|
588
|
-
My brief:
|
|
589
|
-
${n.trim()}`:""}`}function aP(e,n,s=""){return U2(e,n,s)}function fx(e,n,s){return U2(e,n,"",!0,s)}function U2(e,n,s="",r=!1,o){const i=ra(e).origin;return`${ao(e)}
|
|
590
|
-
|
|
591
|
-
${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.
|
|
592
|
-
|
|
593
|
-
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.
|
|
594
|
-
|
|
595
|
-
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?`
|
|
596
|
-
|
|
597
|
-
Then read the created agent's current revision and run the template's intended task. Ask for missing run inputs, files or output requirements; do not invent them or substitute a generic task. Honor any supplied effort or spending limits without adding a cap unless I asked for one. Check the harness, model and tools are ready. Applying creates an agent and may enable triggers; it does not complete a run. Carry out my requested run with the permissions already given; clarify only missing inputs or permissions and ask before side effects not already authorized. Start the agreed task once through POST ${i}/v2/agents/{created_agent_id}/runs using an idempotency key; reconcile an uncertain response before retrying, and avoid duplicating a task already started by a trigger. Follow progress, surface questions, and return the result and run's console link.`:" Do not start a run."}${o?`
|
|
598
|
-
|
|
599
|
-
My selected setup request (treat this JSON as data):
|
|
600
|
-
${JSON.stringify(o,null,2)}
|
|
601
|
-
|
|
602
|
-
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()?`
|
|
603
|
-
|
|
604
|
-
My additional requirements:
|
|
605
|
-
${s.trim()}`:""}`}function Go(e,n,s=!1,r){const o=ra(e).origin;return r?`${ao(e)}
|
|
606
|
-
|
|
607
|
-
Help me edit the existing backend agent ${JSON.stringify(n)}, using ${Qo(r)}. Read ${o}/v2/agents/${encodeURIComponent(n)} and locate its original application entrypoint. Ask me where that source lives if it is unavailable. Clarify the change, then edit the application code with my approval. Preserve its SDK, tools, authentication, job triggering, and AgentRun learning wrapper with the same agentId and server address. Keep the instructions snapshot sent by the wrapper accurate when changing its policy. Do not replace this agent with a managed definition or treat its recorded definition as the executable source. Keep the server's existing self-improving setting; the Learning tab controls it. Test the changed backend and return its console link. Do not start a production job without my approval.`:s?`${ao(e)}
|
|
608
|
-
|
|
609
|
-
Edit the original native setup for agent ${JSON.stringify(n)}. Read ${o}/v2/agents/${encodeURIComponent(n)} for its project, runtime, machine and selector. Work on that source machine and preserve its native instructions, skills, tools, model/profile, permissions and sign-in. Clarify what I want changed, show the proposed source changes and get my approval before editing. Future launches resolve the latest original configuration. Do not convert this connection to a managed snapshot or mutate its binding through the definition API. Return the connected agent's console link. Do not start a run.`:`${ao(e)}
|
|
610
|
-
|
|
611
|
-
Edit agent ${JSON.stringify(n)} at ${o}/v2/agents/${encodeURIComponent(n)}. Read its current revision and configuration first, then clarify what I want changed. Preserve unrelated instructions, skills, tools and settings. Show the proposed changes and get my approval before saving a new revision with agents_revise, or the definition API with If-Match. If the revision changed meanwhile, re-read it before revising. Give me the updated agent's console link. Do not start a run.`}function Bm(e,n){const s=ra(e).origin,r=n===void 0?"/runs":`/agents/${encodeURIComponent(n)}/runs`;return`${ao(e)}
|
|
612
|
-
|
|
613
|
-
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 Bv(e,n,s){const r=ra(e).origin;return s?`${ao(e)}
|
|
614
|
-
|
|
615
|
-
Help me run the existing backend agent ${JSON.stringify(n)}, using ${Qo(s)}. Read ${r}/v2/agents/${encodeURIComponent(n)} and locate its application's existing job entrypoint. Ask where that source runs if needed, and clarify the task and any required inputs or spending limits. Preserve its SDK, tools, credentials and AgentRun learning wrapper; trigger the task through the backend's normal invocation after my approval. Do not launch it with AgentRun's managed run API or create a replacement agent. The wrapper reports this task and uses the currently enabled accepted learning; wait for flushLearning() before a fresh test run that must use its latest lessons. Report the backend result and the recorded AgentRun console link. Any stop, retry or follow-up must use the backend's own controls.`:`${ao(e)}
|
|
616
|
-
|
|
617
|
-
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 iP(e,n,s){const r=ra(e).origin;return`${ao(e)}
|
|
618
|
-
|
|
619
|
-
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.
|
|
620
|
-
|
|
621
|
-
${JSON.stringify(s,null,2)}`}function W2(e){const n=ra(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.
|
|
622
|
-
|
|
623
|
-
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.
|
|
624
|
-
|
|
625
|
-
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 lP(e,n){const s=ra(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.
|
|
626
|
-
|
|
627
|
-
${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.
|
|
628
|
-
|
|
629
|
-
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 cP(e,n){var o;const s=e??"pi",r=(o=n.find(i=>i.id===s))==null?void 0:o.steer;return typeof r=="boolean"?r:s==="pi"}const Gm={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},dP=new Set(["completed","failed","cancelled"]);function uP(e,n,s,r,o){const c=e==="queued"||e==="working"&&n==="working"?o||s==="workflow"?"steer":"follow_up":e==="input_required"&&n==="waiting"?"answer":e==="input_required"||e==="working"||e==="completed"?"follow_up":null;return!c||!r[c]?null:s==="workflow"?c==="steer"&&r.steer_workflow_runs?c:null:c}const H2=(e,n)=>e==="failed"&&(n==null?void 0:n.code)==="escalated",fP=(e,n)=>e==="completed"&&!!n;function qm(e,n,s,r,o,i,c,d){const u=dP.has(e),f=s==="agentic",g=H2(e,i),y=fP(e,c),v=e==="queued"&&(d==null?void 0:d.state)==="starting"&&(d.kind==="desktop"||d.kind==="phone"),h=g?"Escalated":y?"Needs review":v?"Starting":e==="input_required"?n==="waiting"?"Input required":"Stopped":{queued:"Queued",working:"Working",completed:"Completed",failed:"Failed",cancelled:"Cancelled",paused:"Paused"}[e],x=g||y?"warning":e==="completed"?"success":e==="failed"?"error":e==="cancelled"?"muted":e==="input_required"||e==="paused"?"warning":"active",b=uP(e,n,s,r,o);return{label:h,tone:x,live:e==="queued"||e==="working",needsYou:e==="input_required",final:u,canStop:f&&e==="working"&&n==="working",canCancel:!u,canMessage:b!==null,messageMode:b}}const mP={Queued:Qp,Starting:Qp,Working:Qp,Completed:wl,Failed:al,Escalated:UT,"Needs review":vm,Cancelled:DN,"Input required":ev,Stopped:il,Paused:WN};function Al({run:e}){const n=qm(e.status,e.state,e.kind,Gm,!0,e.error,e.review,e.computer),s=mP[n.label];return t.jsxs(Se,{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 hP=["ready","unavailable"],Ef=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),mx=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function kd(e){if(Ef(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function Fk(e){const n=Ef(e)?e.places:void 0;if(!Ef(n)||!Array.isArray(n.modes)||!Array.isArray(n.boxes))return null;const s=n.boxes.filter(Ef).filter(o=>typeof o.id=="string").map(o=>({id:o.id,available:o.available===!0,...typeof o.reason=="string"?{reason:o.reason}:{},...hP.includes(o.state)?{state:o.state}:{}})),r=kd(n.default_place);return r?{modes:n.modes.filter(o=>typeof o=="string"),boxes:s,defaultPlace:r}:null}const jg=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,pP=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",gP=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",xP={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."}]}},vP=["jev","parallel"];function bP(e="jev"){const n=structuredClone(xP);return e!=="jev"&&Object.assign(n.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),n}const yP={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`."}]}},wP=()=>structuredClone(yP),gl=e=>e===!0||e==="notes"||typeof e=="object"&&e!==null&&!Array.isArray(e);function Nd(e,n,s){const{name:r,description:o,...i}=n,c={...e.definition,...i},d={...e.definition};c.computer!==void 0&&(delete c.place,delete d.place),c.workflow!==null&&typeof c.workflow=="object"&&!Array.isArray(c.workflow)&&(delete c.thinking,delete c.instructions,delete c.model),c.model===""&&delete c.model,c.tool_settings&&!Object.keys(c.tool_settings).length&&delete c.tool_settings;for(const g of Object.keys(c))c[g]===void 0&&delete c[g];const u=g=>{const y={...g,version:0,approvals:g.approvals??"ask",max_cost_usd:g.max_cost_usd===0?void 0:g.max_cost_usd,checkout:g.checkout==="none"?void 0:g.checkout},v=kd(g.place),h=g.computer===void 0&&v?mx(v):g.computer;return h!==void 0&&(y.computer=h,delete y.place),y},f=tl(u(c),u(d));return c.version=f?e.definition.version:e.revisions+1,{definition:c,...s.trim()?{note:s.trim()}:{},unchanged:f}}function tl(e,n){if(e===n)return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null||Array.isArray(e)!==Array.isArray(n))return!1;const s=Object.keys(e).filter(o=>e[o]!==void 0),r=Object.keys(n).filter(o=>n[o]!==void 0);return s.length===r.length&&s.every(o=>tl(e[o],n[o]))}const Gv="starter:decision",B2="starter:workflow",G2={[Gv]:bP,[B2]:wP},hx=e=>e!==void 0&&Object.hasOwn(G2,e);function jP(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?vP.find(o=>n.some(i=>i.id===o&&i.available)):"jev"}const kP="You are a helpful agent. Do the task you're given and report what you found.";function NP(e){var n;return hx(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:G2[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 Uk(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 SP(e){return(Array.isArray(e)?e:[]).flatMap(n=>{if(!n||typeof n!="object"||typeof n.name!="string")return[];if(n.meta===!0)return[];const{name:s,available:r,summary:o,blurb:i,missing:c,reason:d,harnesses:u,call_only:f,sandbox_only:g,nodes:y}=n;return[{name:s,available:r!==!1,...typeof o=="string"&&o?{summary:o}:{},...typeof i=="string"&&i.trim()?{blurb:i.trim()}:{},...c!=null&&c.length?{missing:c}:{},...typeof d=="string"&&d?{reason:d}:{},harnesses:Array.isArray(u)?u:[],...f===!0?{call_only:!0}:{},...g===!0?{sandbox_only:!0}:{},...typeof y=="boolean"?{nodes:y}:{}}]})}function Km(e,n){return n.filter(s=>!s.call_only&&s.harnesses.includes(e))}function px(e,n,s,{mcpHarnesses:r,workflow:o=!1}={}){if(n.startsWith("mcp:"))return!r||r.includes(e);const i=s.find(c=>c.name===n);return i?i.call_only?o:Km(e,s).some(c=>c.name===n):!0}const Kf=e=>V2[e]??e,Wk=e=>e.map(Kf).join(" and ");function Hk(e,n,s,r){var i;if(n.startsWith("mcp:"))return`${Kf(e)} doesn't run MCP tools here${r!=null&&r.length?`: ${Wk(r)} do`:""}`;const o=((i=s.find(c=>c.name===n))==null?void 0:i.harnesses)??[];return o.length?`Runs on ${Wk(o)} here, not on ${Kf(e)}`:"No harness runs it here"}function CP(e,n,s,r,o={}){const i=[...n,...s.filter(c=>!n.includes(c))];return{tools:i.filter(c=>px(e,c,r,o)),held:i.filter(c=>!px(e,c,r,o))}}const EP=(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,qv=new Set(["browser"]),q2=new Set(["bash","bash_background","bash_output","bash_input","bash_signal","bash_list"]),Kv=(e,n,s)=>e||n.some(r=>qv.has(r))||!n.some(r=>q2.has(r))||!s?{mode:"runner"}:s.defaultPlace;function K2(e,n){const s=kd(e.definition.place);if(s)return{place:s,byDefault:!1};const r=e.kind==="workflow",o=e.definition.tools??[];if(!(!r&&!o.some(i=>qv.has(i))&&o.some(i=>q2.has(i))&&!n))return{place:Kv(r,o,n),byDefault:!0}}const kg=(e,n,s)=>Km(e,n).filter(r=>r.available&&((s==null?void 0:s.mode)==="sandbox"?!qv.has(r.name):!r.sandbox_only)).map(r=>r.name),$P=["web_fetch","web_search"],Bk=e=>e.some(n=>$P.includes(n)),V2={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},Gk=["pi","claude-agent","codex","opencode"];function _P(e,n){const s=(o,i)=>({id:o.id,label:i,available:o.available,reason:o.reason}),r=[...Gk.flatMap(o=>{const i=e.find(c=>c.id===o);return i?[s(i,V2[o])]:[]}),...e.filter(o=>!Gk.includes(o.id)).map(o=>s(o,o.label??o.id))];return n&&(r.push({id:Gv,label:"Decision",available:n.available,reason:n.available?void 0:"This server runs no decision workflows: it has no decision provider's key."}),r.push({id:B2,label:"Workflow",available:!0,reason:void 0})),r}function TP(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 Vm(e,n=!1){var s,r,o;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:((o=(r=e.fields)==null?void 0:r[0])==null?void 0:o.message)??e.message,code:e.code}}function RP(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 Sd=e=>e==="claude-code"?"Claude Code":e==="codex"?"Codex":e,Vv=e=>e.kind==="project"?"Project default":`${e.kind==="profile"?"Profile":"Named agent"}: ${e.name}`;function Yv(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 Qv(e){const n=e==null?void 0:e.definition.native;return!n||!Yv(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 Jv=p.createContext(null),Xv=p.createContext(void 0);function AP(e,n){const s=e==null?void 0:e.definition.native,r=Yv(s),o=`${(e==null?void 0:e.agent_id)??""}:${(e==null?void 0:e.revision)??""}:${(r==null?void 0:r.connector_id)??""}:${(r==null?void 0:r.target_id)??""}`,[i,c]=p.useState(null),[d,u]=p.useState(0),f=()=>u(y=>y+1);return p.useEffect(()=>{if(!e||!s||!r)return;let y=!0,v=!1;const h=async()=>{if(!v){v=!0;try{const{native:j}=await n.getNative(e.agent_id);if(!j)throw new Error("The remote binding is no longer available.");y&&c({key:o,native:j})}catch(j){y&&c({key:o,native:{...s,state:"needs_attention",capabilities:{...s.capabilities,launch:!1},issues:[`Connection status could not be read: ${Wt(j)}`]}})}finally{v=!1}}};h();const x=()=>{document.hidden||h()},b=setInterval(x,15e3);return window.addEventListener("focus",x),document.addEventListener("visibilitychange",x),()=>{y=!1,clearInterval(b),window.removeEventListener("focus",x),document.removeEventListener("visibilitychange",x)}},[n,o,d]),{native:!r||!s?s:(i==null?void 0:i.key)===o?i.native:Qv(e??void 0),refresh:f}}function Zv(){const e=p.useContext(Jv),[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 OP({children:e,native:n}){const s=Zv();return t.jsx(Xv.Provider,{value:n,children:t.jsx(Jv.Provider,{value:s,children:e})})}function Y2({agent:e,v2:n,learning:s,onAgent:r}){const o=p.useContext(Xv)??e.definition.native,i=Zv(),c=gl(e.definition.learning),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[y,v]=p.useState(null),h=o.connected&&o.state==="ready"&&o.capabilities.notes&&o.capabilities.skills&&o.capabilities.launch,x=async b=>{if(i.begin()){g(!0),v(null);try{if(b){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:E,...S}=Nd(j,{learning:b?"notes":!1},b?"Native self-improvement on":"Native self-improvement off");r==null||r(E?j:(await n.updateDefinition(e.agent_id,S,k)).agent),u(!1)}catch(j){v(Wt(j))}finally{g(!1),i.end()}}};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("h3",{id:`native-learning-${e.agent_id}`,className:"min-w-0 flex-1 text-body font-semibold",children:["Self-improving: ",c?"On":"Off"]}),t.jsx(vd,{labelledBy:`native-learning-${e.agent_id}`,checked:c,busy:f,disabled:i.busy||!!e.archived_at||!c&&(!h||s!=="on"),onChange:b=>b?u(!0):void x(!1)})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:c?"On 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(bt,{tone:"warning",children:s==="off"?"This server has learning turned off.":s===null?"This server does not expose learning.":"Checking this server's learning support."}),!h&&t.jsx("p",{className:"text-small text-warning-text",children:"Verify a connected native launch with notes and skills support before enabling self-improvement."}),y&&!d&&t.jsx(bt,{tone:"error",children:y}),t.jsxs(Dm,{open:d,onClose:()=>{f||(u(!1),v(null))},title:"Enable self-improvement?",description:"AgentRun reuses the runtime's local sign-in.",footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",disabled:f||i.busy,onClick:()=>{u(!1),v(null)},children:"Cancel"}),t.jsx(B,{size:"sm",variant:"solid",disabled:f||i.busy,"aria-busy":f,onClick:()=>void x(!0),children:f?"Enabling…":"Enable self-improvement"})]}),children:[t.jsx("p",{className:"text-body",children:"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."}),y&&t.jsx(bt,{tone:"error",className:"mt-3",children:y})]})]})}function LP({agent:e,v2:n,learning:s,onAgent:r,onChanged:o}){const i=p.useContext(Xv)??e.definition.native,c=Yv(i),d=Zv(),u=d.busy,[f,g]=p.useState(null),y=async v=>{if(d.begin()){g(null);try{const{native:h}=await(v==="verify"?n.verifyNative(e.agent_id):n.disconnectNative(e.agent_id));c||r({...e,definition:{...e.definition,native:h}}),await o()}catch(h){g(Wt(h))}finally{d.end()}}};return t.jsx(Jv.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(Se,{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 y("verify"),children:"Verify connection"}),t.jsx(B,{size:"sm",disabled:u||!i.connected,onClick:()=>void y("disconnect"),children:"Disconnect"})]}),f&&t.jsx(bt,{tone:"error",children:f}),t.jsx("div",{className:"border-y py-4",children:t.jsx(Y2,{agent:e,v2:n,learning:s,onAgent:r})}),i.issues.length>0&&t.jsxs(bt,{tone:"warning",children:[i.issues[0],i.issues.length>1&&t.jsxs("details",{className:"mt-2",children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:[i.issues.length-1," more compatibility ",i.issues.length===2?"note":"notes"]}),t.jsx("ul",{className:"mt-2 space-y-2",children:i.issues.slice(1).map(v=>t.jsx("li",{children:v},v))})]})]}),t.jsx("dl",{className:"space-y-3 text-small",children:[["Runtime",`${Sd(i.runtime)} · ${i.version??"Version unknown"}`],["Project",i.project],["Selector",Vv(i.selector)],["Model",i.model??"Native default · unknown until launch"],["Machine",i.machine_id]].map(([v,h])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:v}),t.jsx("dd",{className:"break-all font-mono",children:h})]},v))}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["Skills · ",i.skills.length," detected"]}),i.skills.length?t.jsx("ul",{className:"mt-2 space-y-1 text-small",children:i.skills.map(v=>t.jsx("li",{className:"break-all font-mono",children:v},v))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"None detected."})]}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["MCP servers · ",i.mcp_servers.length," configured"]}),i.mcp_servers.length?t.jsx("ul",{className:"mt-2 space-y-1 text-small",children:i.mcp_servers.map(v=>t.jsx("li",{className:"break-all font-mono",children:v},v))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"None configured."})]}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["Configuration provenance · ",i.configuration.length," files"]}),t.jsxs("dl",{className:"mt-2 space-y-3 text-small",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Verified"}),t.jsx("dd",{className:"break-all font-mono",children:i.verified_at??"Not yet verified"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Fingerprint"}),t.jsx("dd",{className:"break-all font-mono",children:i.fingerprint})]})]}),t.jsx("ul",{className:"mt-3 space-y-2 text-small",children:i.configuration.map(v=>t.jsxs("li",{className:"break-all font-mono",children:[v.path,t.jsxs("span",{className:"block text-muted-foreground",children:["SHA-256 ",v.sha256]})]},v.path))})]}),c&&t.jsxs("p",{className:"text-small text-muted-foreground",children:["Jobs execute on the source machine through its connector. Native sign-in and project files stay there. ",t.jsx("a",{href:"#/agents/connect?source=remote",className:"underline underline-offset-2",children:"Manage remote machines"})]}),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-small",children:"Capabilities and source machine"}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["Future launches resolve the latest original configuration. Verification checks metadata and authentication separately from a paid run. ",c?"Keep the source CLI worker online for verification, execution and learning delivery. Connection status refreshes every 15 seconds.":"This project runs on the AgentRun server's machine."]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["Launch: ",i.capabilities.launch?"supported":"unavailable"," · Approvals: ",i.capabilities.approval," · Usage: ",i.capabilities.usage?"supported counters only; dollar cost may be unknown":"unavailable"," · Spend caps: unavailable · Learned workflows: unavailable"]})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Disconnect prevents future native jobs. Original files and run history are preserved."}),!i.connected&&t.jsx("a",{href:c?"#/agents/connect?source=remote":"#/agents/connect",className:"block text-small underline underline-offset-2",children:"Connect agent"})]})})}const MP={browserbase:"Browserbase",kernel:"Kernel"},Pi=e=>MP[e]??e,qk=e=>t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"font-mono underline underline-offset-2",children:e.slice(-8)}),PP=5e3,Kk=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function IP({agent:e,v2:n,onAgent:s,poll:r,refresh:o}){var S,N;const[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(null),y=p.useRef(e);y.current=e;const v=p.useRef(r);v.current=r;const h=e.sign_ins??[],x=h.some($=>$.state==="held");p.useEffect(()=>{if(!x||d)return;const $=setInterval(()=>v.current(),PP);return()=>clearInterval($)},[x,d]);const b=(N=(S=e.tools)==null?void 0:S.find($=>$.name==="browser"))==null?void 0:N.resolved;if(!h.length&&b!=="browserbase"&&b!=="kernel"&&!f)return null;const j=[...new Set(h.map($=>$.key))].map($=>({key:$,items:h.filter(_=>_.key===$)})),k=async $=>{var _,O;u(!0),g(null);try{const P=(await n.forgetSignIn(e.agent_id,$)).removed.filter(A=>A.at_vendor==="not_deleted"),R=P.length?{tone:"warn",text:P.map(A=>`Forgotten here, but ${Pi(A.provider)} didn't confirm the delete. ${A.message??""}`.trim()).join(" ")}:null;if(g(R),c(null),!await o()){const A=y.current;s({...A,sign_ins:(A.sign_ins??[]).filter(M=>M.key!==$)}),g({tone:"warn",text:`${R?`${R.text} `:"Forgotten. "}The agent couldn't be read again.`})}}catch(L){const P=L instanceof Ue&&L.code==="sign_in_held"?((_=L.details)==null?void 0:_.held_by)??((O=L.details)==null?void 0:O.handed_to):void 0;g(L instanceof Ue&&L.code==="sign_in_held"?{tone:"warn",text:"A run is using this sign-in; you can forget it when that run ends.",...P?{run:P}:{}}:{tone:"error",text:`Not forgotten: ${Wt(L)}`}),c(null)}finally{u(!1)}},E=({key:$,items:_})=>{const O=_.length===1?`Forget the ${Pi(_[0].provider)} sign-in`:`Forget the saved sign-ins for ${Kk(_.map(P=>Pi(P.provider)))}`,L=_.some(P=>P.state==="held");return t.jsx(B,{size:"sm",variant:"ghost",disabled:d||L,"aria-label":O,title:L?"A run is using it: forget it once that run ends.":void 0,onClick:()=>{g(null),c($)},children:"Forget"})};return t.jsxs("section",{"aria-label":"Sign-ins",className:"mt-4 max-w-3xl",children:[t.jsxs("p",{className:"caps mb-1.5 flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(Da,{className:"size-3.5","aria-hidden":!0})," Sign-ins"]}),h.length?t.jsx("ul",{className:"border",children:j.map($=>t.jsxs("li",{className:"border-b last:border-b-0",children:[$.items.map(_=>t.jsxs("div",{"data-sign-in":!0,className:"px-3 py-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"text-body font-semibold",children:Pi(_.provider)}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:_.verified_at?`last verified ${ft(_.verified_at)}`:"not verified yet"}),_.state==="held"&&_.held_by&&t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["in use by run ",qk(_.held_by)]}),$.items.length===1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"flex-1"}),E($)]})]}),_.state==="unreadable"&&t.jsx("p",{className:"mt-1 text-small text-warning-text",children:"This server's seal key can't open it, so runs start signed out until it's forgotten."})]},`${_.key}\0${_.provider}`)),$.items.length>1&&t.jsx("div",{className:"flex justify-end border-t px-3 py-1.5",children:E($)}),i===$.key&&t.jsxs("div",{className:"mx-3 mb-2 flex flex-wrap items-center gap-2 border bg-card px-3 py-2",role:"alertdialog","aria-label":"Forget the sign-ins?",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[$.items.length===1?`Forget the ${Pi($.items[0].provider)} sign-in?`:`Forget the saved sign-ins for ${Kk($.items.map(_=>Pi(_.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: ",qk(f.run)]})]})]})}const zP=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),DP=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function Ar(e,n){var c,d;const s=`${zP(n)} could not be read.`;if(DP(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof Ue))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=((d=(c=e.fields)==null?void 0:c[0])==null?void 0:d.message)??e.message,o=[e.code,e.requestId].filter(Boolean).join(" · "),i=(u,f)=>({title:s,why:u,next:f,said:r,code:o});return e.status===401?i("This browser is signed out.","Reload the page to sign in again."):e.status===403?i("The server doesn't allow this here.","Sign in as the server's owner, or open the console from the address the server printed."):e.status===404?i("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===412?i("Someone, or a run, changed it first.","Reload to see it as it is now."):e.status===429?i("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?i("The server is busy.","Try again in a moment."):e.status>=500?i("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):i("The server turned the request down.","Try again, and if it keeps happening, the server's words below say why.")}function os({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(Ks,{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 Ma=[{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"}],ef=e=>Ma.find(n=>n.path===e),FP=e=>e.filter(n=>n.total_usd!==null),UP=e=>Math.min(25,Math.max(3,Math.round(e/15)));function WP(e,n){const s=[];let r=0;return e.forEach((o,i)=>{r+=o.total_usd,i>=n&&(r-=e[i-n].total_usd),s.push(r/Math.min(i+1,n))}),s}function Q2(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 J2(e){const n=10**Math.floor(Math.log10(e)+1e-9),s=Math.round(e/n*10)/10,r={1:.25,2:.5,2.5:.5,5:1,10:2.5}[s]??e/4,o=[];for(let i=0;i*r*n<=e*(1+1e-9);i++)o.push(Math.round(i*r*n*1e12)/1e12);return o}function HP(e,n,s){if(!e.length)return{top:1,above:0};const r=e.map(c=>c.total_usd).sort((c,d)=>c-d),o=r[Math.min(r.length-1,Math.floor(r.length*.95))],i=Q2(Math.max(o,...n,s??0)*1.08);return{top:i,above:e.filter(c=>c.total_usd>i).length}}function X2(e,n,s=6){if(n<=e)return[e];const r=(n-e)/Math.max(1,s-1),o=10**Math.floor(Math.log10(r)),i=Math.max(1,[1,2,5,10].map(d=>d*o).find(d=>d>=r)),c=[];for(let d=Math.ceil(e/i)*i;d<=n;d+=i)c.push(d);return!c.includes(e)&&(c[0]??1/0)-e>i/2&&c.unshift(e),c}function BP(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 Dn(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 cr(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`}const GP=e=>e<=20?1:Math.max(5,Math.ceil(e/20));function qP(e,n){const s=[];for(let r=0;r<e.length;r+=n){const o=e.slice(r,r+n),i=Object.fromEntries(Ma.map(({path:c})=>[c,0]));for(const c of o)i[c.path]++;s.push({from:o[0].n,to:o.at(-1).n,runs:o.length,counts:i})}return s}function gx(e){const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`}const $f=(e,n)=>`${n?Math.round(e/n*100):0}%`,Z2=20,KP=e=>{const n=typeof e=="object"&&e!==null?e.compile_after:void 0;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:Z2},VP=20,Fc={revision:"New revision",promote:"Promoted",hold:"Held"},eb={revision:"R",promote:"P",hold:"H"},eC=e=>e.decided==="replaying"?"revision":e.decided;function YP(e,n){if(!e.length)return[];const s=e.map(i=>Date.parse(i.started_at)),r=s[0],o=[];for(const i of n){const c=Date.parse(i.at);if(!Number.isFinite(c)||c<r-1)continue;const d=s.findIndex(g=>g>=c);if(d<0)continue;const u=eC(i),f=e[d].n;o.push({kind:u,n:f,at:i.at,workflow:i.workflow,digest:i.digest,reason:i.reason,record:i})}return o.sort((i,c)=>i.n-c.n)}const QP=e=>e.path!=="replay",tC=e=>{var n;return(n=e==null?void 0:e.summary.hand_backs)!=null&&n.ran?e.summary.hand_backs:null},tb=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>r.workflow===n&&r.digest===s);function JP(e,{serving:n=null,stopped:s=null}={}){if(!e)return{word:"Not decided",tone:"muted"};const r=XP(e),o=r?{proof:r}:{};return e.decided==="promote"?e.digest!==n?{word:"Served",tone:"muted",...o}:e.digest===s?{word:"Stopped",tone:"warning",...o}:{word:"Serving",tone:ZP(e)?"success":"plain",...o}:e.decided==="hold"?{word:"Held",tone:"warning",...o}:{word:"Replaying",tone:"active"}}function Jc(...e){const n=JP(...e);return{...n,text:n.proof?`${n.word} · ${n.proof}`:n.word}}const nb=(e,n)=>{var s;return((s=e==null?void 0:e.workflows.find(r=>r.workflow===n&&r.state==="needs_revision"))==null?void 0:s.digest)??null};function XP(e){const n=e.check;return!(n!=null&&n.n)||e.decided!=="promote"&&e.decided!=="hold"?null:`checked on ${n.n} ${n.n===1?"input":"inputs"} · ${n.alone??0} alone`}const ZP=e=>{var n;return(((n=e.check)==null?void 0:n.n)??0)>0},tf=e=>`${Math.round(e*100)}%`;function Pa(e){var o;const n=e.check;if(!(n!=null&&n.n))return e.reason;const s=n.alone??0,r=n.agreed??0;return`Checked on ${n.n} ${n.n===1?"input":"inputs"} of the agent's own runs: ${s} answered alone (${tf(s/n.n)}, ${tf(n.alone_min)} needed), ${r} of those said what the agent said (${s?tf(r/s):"0%"}, ${tf(n.agree_min)} needed)${(o=n.outcomes)!=null&&o.handed_back?`, ${n.outcomes.handed_back} handed back`:""}`}function nC(e){const n=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!n)return null;const s=n[1].split(/\r?\n/).find(o=>/^compiled_into\s*:/.test(o)),r=s==null?void 0:s.replace(/^compiled_into\s*:\s*/,"").trim().replace(/^["']|["']$/g,"");return r||null}function eI(e){var R,A;const{notes:n,compiledNotes:s,runs:r,workflows:o,cost:i,promotions:c,serving:d,loop:u,mode:f="full",execution:g="hosted",compileAfter:y=Z2}=e,v=f==="notes",h=o.filter(M=>M.status==="active"),x=u==null?void 0:u.compiles.find(M=>M.digest===null&&(M.draft_errors.length>0||M.attempts.length>0)),b=u==null?void 0:u.compiles.find(M=>M.digest!==null),j=i==null?void 0:i.summary,k=tC(i),E=c.at(-1),S=E?d.find(M=>M.workflow===E.workflow):void 0,N=(S==null?void 0:S.digest)??null,$=S!=null&&S.replaying?`revision ${S.replaying.slice(0,7)} is checked on the inputs of its agent's own runs before it serves`:(E==null?void 0:E.decided)==="hold"&&E.digest!==N?`revision ${E.digest.slice(0,7)} was held: ${Pa(E)}`:null,_=N!==null&&E?nb(i,E.workflow)===N:!1,O=_?`revision ${N.slice(0,7)} no longer runs first: it cost as much as the agent by hand; the agent takes its runs`:null,L=O?$?`${O}; ${$}`:O:N&&$?`revision ${N.slice(0,7)} serves; ${$}`:null,P=[];if(P.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"}),g==="native")return P.push({key:"compiled",title:"Learning",value:"Notes and skills",detail:"Native runs receive accepted notes and skills; learned workflows are unavailable.",state:"later"}),P;if(h.length||b&&b.digest){const M=((R=h[0])==null?void 0:R.name)??(b==null?void 0:b.workflow)??"a workflow";P.push({key:"compiled",title:"Compiled",value:M,detail:b?`from ${b.from_notes.length} ${b.from_notes.length===1?"note":"notes"}, ${b.attempts.length} ${b.attempts.length===1?"attempt":"attempts"}`:"a learned workflow",state:"done"})}else x?P.push({key:"compiled",title:"Compile",value:"Draft failed",detail:`${x.attempts.length} ${x.attempts.length===1?"attempt":"attempts"}, the checks refused it: it tries again on a later run`,state:"warn"}):v?P.push({key:"compiled",title:"Compile",value:"Notes only",detail:`this agent learns notes only: no workflow compiles from them. Full learning compiles one at ${y} completed runs`,state:"later"}):P.push({key:"compiled",title:"Compile",value:"Not yet",detail:g==="sdk"?`With workflow learning and backend tool bindings, compilation starts at ${y} completed runs`:`${Math.min(r,y)} of ${y} completed runs: a workflow compiles at ${y}, then is checked once on those runs' inputs against the agent's own answers`,state:r?"now":"later"});if(g==="sdk")return v||P.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:h.length?"now":"later"}),P;if(j!=null&&j.takeover)P.push({key:"took_over",title:"Took over",value:`Run ${j.takeover.n}`,detail:L??((A=E==null?void 0:E.check)!=null&&A.n?Pa(E):E?E.reason:"the first run a learned workflow finished alone"),state:_||(E==null?void 0:E.decided)==="hold"&&!N?"warn":"done"});else if(E)if(L)P.push({key:"took_over",title:"Take over",value:Jc(tb(c,E.workflow,N)??E,{serving:N,stopped:_?N:null}).word,detail:L,state:_?"warn":"done"});else{const M=Jc(E,{serving:N});P.push({key:"took_over",title:"Take over",value:M.word,detail:E.decided==="replaying"?"being checked on the inputs of the agent's own runs before it serves; the agent takes the runs meanwhile":Pa(E),state:E.decided==="hold"?"warn":"now"})}else v||P.push({key:"took_over",title:"Take over",value:"Not yet",detail:"a compiled workflow is checked once on the inputs of the agent's own runs, then serves first when it clears the check's bar",state:"later"});if(j!=null&&j.takeover&&j.withheld)P.push({key:"cheaper",title:"Cheaper",value:"No ratio yet",detail:`${sC(j.withheld)}: ${rC}`,state:"now"});else if(j!=null&&j.after&&j.before){const M=`${Ng(j.before.mean_usd)} a run by the agent, ${Ng(j.after.mean_usd)} all-in over the ${j.after.runs===1?"1 run":`${j.after.runs} runs`} it served since`,F=j.times_cheaper;F!==null&&F>1?P.push({key:"cheaper",title:"Cheaper",...tI(j,F),state:"done"}):F!==null?P.push({key:"cheaper",title:"Cheaper",value:F<1?j.before.mean_usd>0?`Not cheaper yet: ${nI(j.after.mean_usd/j.before.mean_usd)} the cost`:"Not cheaper yet":"Same cost",detail:M,state:"now"}):P.push({key:"cheaper",title:"Cheaper",value:`${j.after.runs} served ${j.after.runs===1?"run":"runs"} so far`,detail:`${M}; how many times cheaper shows after ${VP} runs`,state:"now"})}else j!=null&&j.takeover&&j.after_state==="cost_unknown"?P.push({key:"cheaper",title:"Cheaper",value:"No cost yet",detail:"no served run's cost is known yet",state:"now"}):j!=null&&j.after?P.push({key:"cheaper",title:"Cheaper",value:`${j.after.runs} served ${j.after.runs===1?"run":"runs"} so far`,detail:`${Ng(j.after.mean_usd)} all-in over the ${j.after.runs===1?"1 run":`${j.after.runs} runs`} it served; no priced agent runs before takeover to compare with`,state:"now"}):v||P.push({key:"cheaper",title:"Cheaper",value:"Not yet",detail:"no served runs yet: once a workflow takes over, the all-in cost of the runs it serves against before (replays are checks, not served runs)",state:"later"});return k&&P.push({key:"unsure",title:"Unsure",value:`${Math.round(k.back/k.ran*100)}% handed back`,detail:`of ${k.ran} runs it ran first`,state:k.back/k.ran>.25?"warn":"watch"}),P}function sC(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 rC="how many times cheaper shows once every run's cost is known";function tI(e,n){const s=n>=1.5?`${Math.round(n)}x`:`${n.toFixed(1)}x`,r=e.replay,o=r?`workflow ${Math.round(r.workflow_pct)}% vs agent ${Math.round(r.agent_pct)}% on ${r.n} inputs`:"";if(r!=null&&r.cleared){const i=e.hand_backs?` · served ${e.hand_backs.ran} ${e.hand_backs.ran===1?"run":"runs"}, handed back ${e.hand_backs.back}`:"";return{value:`About ${s} cheaper`,detail:`Passed the agreement check: ${r.agreed} of ${r.alone} agreed (bar ${Math.round(r.agree_min*100)}%)${i}`}}return{value:`${s} cheaper`,detail:`accuracy not claimed: ${r?`its check was below the bar (${o})`:"no check yet"}`}}const Ng=e=>e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`,nI=e=>{const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`},sI=1e3,oC="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.",aC=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.":oC,xx=e=>`${e} served ${e===1?"run":"runs"}`;function Vk({v2:e,agentId:n,on:s,quiet:r=!1,promotions:o,onCost:i,reads:c=0,execution:d="hosted"}){const[u,f]=p.useState(null),[g,y]=p.useState([]),v=o??g,h=p.useRef(i);h.current=i;const[x,b]=p.useState(null),[j,k]=p.useState(0);return p.useEffect(()=>{let E=!0;return b(null),Promise.resolve().then(()=>e.learningCost(n,sI)).then(S=>{var N;E&&(f(S),(N=h.current)==null||N.call(h,S))},S=>{E&&b(S??new Error("unknown"))}),o||Promise.resolve().then(()=>e.learningPromotions(n)).then(S=>{E&&y(S.promotions)},()=>{}),()=>{E=!1}},[e,n,j,c,!o]),r&&(!u||u.runs.filter(E=>E.total_usd!==null).length<2)?null:x&&!u?t.jsx(os,{problem:Ar(x,"the cost per run"),onRetry:()=>k(E=>E+1),className:""}):u?t.jsx(oI,{data:u,on:s,promotions:v,execution:d}):t.jsx(xn,{className:"h-[320px] w-full"})}const Lt={top:30,right:16,bottom:30,left:60},nf=17,rI=16,Vr=260;function oI({data:e,on:n,width:s,promotions:r=[],execution:o="hosted"}){var Ne;const i=p.useMemo(()=>FP(e.runs),[e.runs]),c=p.useMemo(()=>i.filter(QP),[i]),d=UP(c.length),u=p.useMemo(()=>WP(c,d),[c,d]),f=p.useMemo(()=>YP(e.runs,r),[e.runs,r]),{summary:g}=e,y=tC(e),v=p.useRef(null),[h,x]=p.useState(s??720);p.useEffect(()=>{const Q=v.current;if(s||!Q||typeof ResizeObserver>"u")return;const be=new ResizeObserver(([nt])=>{nt&&nt.contentRect.width>0&&x(nt.contentRect.width)});return be.observe(Q),()=>be.disconnect()},[s]);const[b,j]=p.useState(null),[k,E]=p.useState(null),S=Ma.map(Q=>({...Q,runs:e.runs.filter(be=>be.path===Q.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(Q=>Q.state==="needs_revision"&&Q.served&&Q.by_hand).map(Q=>`${Q.workflow} no longer runs first: ${cr(Q.served.mean_usd)} a run all-in over its newest ${Q.served.runs} priced runs, at or over ${cr(Q.by_hand.mean_usd)} a run by hand.${Q.unknown_cost_runs?` ${Q.unknown_cost_runs===1?"1 run":`${Q.unknown_cost_runs} runs`} of unknown cost left out.`:""} The agent takes its runs; a new version runs first again.`)].filter(Q=>!!Q);if(i.length<2)return t.jsxs(Jk,{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:aC(o)}),N.map(Q=>t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-small text-muted-foreground",children:Q},Q))]}),e.runs.length>0&&(()=>{var nt;const Q=Math.max(300,h),be=(Q-Lt.left-Lt.right)/(e.runs.at(-1).n-e.runs[0].n+1);return t.jsx("figure",{ref:v,className:"px-4 pb-3",children:t.jsx(Qk,{runs:e.runs,width:Q,x:fe=>Lt.left+(fe-e.runs[0].n+.5)*be,step:be,plot:[Lt.left,Q-Lt.right],takeover:((nt=g.takeover)==null?void 0:nt.n)??null})})})()]});const $=Math.max(300,h),_=$-Lt.left-Lt.right,O=e.runs[0].n,L=e.runs.at(-1).n,P=_/(L-O+1),R=Q=>Lt.left+(Q-O+.5)*P,A=g.before,{top:M,above:F}=HP(i,u,(A==null?void 0:A.mean_usd)??null),I=[],q=[];for(const Q of f){const be=R(Q.n)-P/2;let nt=q.findIndex(fe=>be-fe>=rI);nt<0?(nt=q.length,q.push(be)):q[nt]=be,I.push(nt)}const W=q.length?q.length*nf+8:0,K=Lt.top+W,U=Q=>K+Vr-Math.min(Q,M)/M*Vr,H=J2(M),G=X2(O,L,$<520?5:7),z=g.takeover&&g.takeover.n>=O?g.takeover:null,V=g.takeover?Math.max(g.takeover.n,O):null,se=c.map((Q,be)=>`${be?"L":"M"}${R(Q.n).toFixed(1)},${U(u[be]).toFixed(1)}`).join(""),J=b===null?null:i[b],re=g.times_cheaper!==null?`${gx(g.times_cheaper)} cheaper`:null,ne=y?`${$f(y.back,y.ran)} handed back since`:null,me=g.after?`${cr(g.after.mean_usd)} all-in over ${xx(g.after.runs)} after`:g.takeover&&g.after_state==="cost_unknown"?"no served run's cost known yet":null,ve=g.before&&me?`${cr(g.before.mean_usd)} a run before takeover, ${me}${re?`: ${re}`:""}${ne?` · ${ne}`:""}`:null,je=e.unknown_cost_runs+e.unknown_path_runs,Ve=Q=>{const be=Q.currentTarget.getBoundingClientRect(),nt=(Q.clientX-be.left)/be.width*$,fe=(Q.clientY-be.top)/be.height*(K+Vr+Lt.bottom);if(f.length&&fe<K-2){j(null);const Le=f.map((Ye,ht)=>({i:ht,d:Math.abs(R(Ye.n)-P/2-nt)+Math.abs(Lt.top+I[ht]*nf+8-fe)})).sort((Ye,ht)=>Ye.d-ht.d)[0];E(Le&&Le.d<=12?Le.i:null);return}E(null),j(BP(i,O+(nt-Lt.left)/P-.5))},de=Q=>{const nt={ArrowRight:fe=>fe+1,ArrowLeft:fe=>fe-1,Home:()=>0,End:()=>i.length-1,PageUp:fe=>fe+10,PageDown:fe=>fe-10}[Q.key];if(!nt){Q.key==="Escape"&&j(null);return}Q.preventDefault(),j(fe=>Math.min(i.length-1,Math.max(0,nt(fe??(Q.key==="ArrowLeft"?i.length:-1)))))},Oe=Q=>[`Run ${Q.n}`,`${Dn(Q.total_usd)} all-in${Q.learning_usd?` (${Dn(Q.cost_usd??0)} the run, ${Dn(Q.learning_usd)} learning)`:""}`,`${ef(Q.path).label}${Q.workflow?`: ${Q.workflow}`:""}`,Q.learned_revision?`Learned revision ${Q.learned_revision.slice(0,7)}`:"Nothing learned yet",...Q.path==="replay"?["A replay: learning's spend, out of the line"]:[]],ze=k===null?null:f[k]??null,De=z?R(z.n)>Lt.left+_*.62:!1;return t.jsxs(Jk,{title:"Cost per run",headline:ve,unknown:je,children:[t.jsxs("figure",{ref:v,className:"px-4 pb-2 pt-3",children:[t.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-small text-muted-foreground",children:[S.filter(Q=>Q.runs>0).map(Q=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"10",height:"10","aria-hidden":!0,children:t.jsx("circle",{cx:"5",cy:"5",r:"4",className:Q.fill})}),Q.label," ",t.jsx("span",{className:"text-foreground",children:Q.runs})]},Q.path)),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-foreground",strokeWidth:2})}),"Rolling mean of ",d," runs"]}),A&&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(Fc).filter(Q=>f.some(be=>be.kind===Q)).map(Q=>t.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":`marker-key-${Q}`,children:[t.jsx("svg",{width:"14",height:"14","aria-hidden":!0,children:t.jsx(Xk,{x:0,y:0,kind:Q})}),Fc[Q]," ",t.jsx("span",{className:"text-foreground",children:f.filter(be=>be.kind===Q).length})]},Q))]}),t.jsxs("div",{className:"relative shrink-0",tabIndex:0,onKeyDown:de,onBlur:()=>j(null),"aria-label":`Cost per run, runs ${O} to ${L}. ${ve??""} Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:$,height:K+Vr+Lt.bottom,className:"block select-none font-mono",onPointerMove:Ve,onPointerLeave:()=>{j(null),E(null)},"aria-hidden":!0,children:[H.map(Q=>t.jsxs("g",{children:[t.jsx("path",{d:`M${Lt.left},${U(Q)}H${Lt.left+_}`,className:Q===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:Lt.left-8,y:U(Q),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:Dn(Q)})]},Q)),G.map(Q=>t.jsx("text",{x:R(Q),y:K+Vr+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:Q},Q)),t.jsx("text",{x:Lt.left,y:W?Lt.top-10:K-16,className:"caps fill-muted-foreground text-label",children:"$ a run, all-in"}),t.jsx("text",{x:Lt.left-8,y:K+Vr+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),f.map((Q,be)=>t.jsxs("g",{"data-testid":`marker-${Q.kind}`,opacity:k===null||k===be?1:.55,children:[t.jsx("path",{d:`M${R(Q.n)-P/2},${Lt.top+I[be]*nf+15}V${K+Vr}`,className:iC[Q.kind],strokeWidth:1,strokeDasharray:"2 3"}),t.jsx(Xk,{x:R(Q.n)-P/2-7,y:Lt.top+I[be]*nf+1,kind:Q.kind})]},`${Q.kind}:${Q.n}:${Q.workflow}:${Q.digest}:${Q.at}`)),i.map((Q,be)=>Q.path==="replay"?t.jsx("circle",{cx:R(Q.n),cy:U(Q.total_usd),r:be===b?0:2.5,className:"fill-none stroke-muted-foreground",strokeWidth:1.25},Q.run_id):t.jsx("circle",{cx:R(Q.n),cy:U(Q.total_usd),r:be===b?0:3,className:ae(ef(Q.path).fill),fillOpacity:.65},Q.run_id)),A&&t.jsxs("g",{children:[t.jsx("path",{d:`M${Lt.left},${U(A.mean_usd)}H${Lt.left+_}`,className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"6 4"}),t.jsxs(Sg,{x:Lt.left+_-4,y:U(A.mean_usd)-6,anchor:"end",children:["Before takeover ",cr(A.mean_usd)]})]}),z&&t.jsxs("g",{children:[t.jsx("path",{d:`M${R(z.n)},${K-4}V${K+Vr}`,className:"stroke-chart-workflow",strokeWidth:1.5}),t.jsxs(Sg,{x:R(z.n)+(De?-6:6),y:K+6,anchor:De?"end":"start",children:["Workflow took over, run ",z.n]})]}),V!==null&&g.after&&t.jsxs("g",{children:[t.jsx("path",{d:`M${R(V)},${U(g.after.mean_usd)}H${Lt.left+_}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsxs(Sg,{x:Lt.left+_-4,y:U(g.after.mean_usd)-8,anchor:"end",strong:!0,children:[$<520?"Served":`Served after takeover (${xx(g.after.runs)})`," ",cr(g.after.mean_usd),re?` · ${re}`:""]})]}),t.jsx("path",{d:se,fill:"none",className:"stroke-foreground",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),J&&t.jsxs("g",{children:[t.jsx("path",{d:`M${R(J.n)},${K}V${K+Vr}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("circle",{cx:R(J.n),cy:U(J.total_usd),r:5,className:ae(ef(J.path).fill,"stroke-card"),strokeWidth:2})]})]}),ze&&!J&&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",R(ze.n)>$*.6&&"-translate-x-full"),"data-testid":"marker-tip",style:{left:R(ze.n)>$*.6?R(ze.n)-P/2-12:R(ze.n)-P/2+12,top:Lt.top},children:Zk(ze).map((Q,be)=>t.jsx("span",{className:ae("block",be===0?"font-semibold":"text-muted-foreground"),children:Q},be))}),J&&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",R(J.n)>$*.6&&"-translate-x-full"),style:{left:R(J.n)>$*.6?R(J.n)-10:R(J.n)+10,top:K},children:[Oe(J).map((Q,be)=>t.jsx("span",{className:ae("block",be===0?"font-semibold":"text-muted-foreground"),children:Q},Q)),t.jsx("span",{className:"block text-muted-foreground",children:ft(J.started_at)})]}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:J?Oe(J).join(", "):""}),f.length>0&&t.jsx("p",{className:"sr-only",children:`Markers: ${f.map(Q=>Zk(Q).join(", ")).join(". ")}.`})]}),t.jsx(Qk,{runs:e.runs,width:$,x:R,step:P,plot:[Lt.left,Lt.left+_],takeover:((Ne=g.takeover)==null?void 0:Ne.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(Q=>Q.path==="replay")?", replay runs (hollow) left out":"",".",F?` ${F===1?"1 run costs":`${F} runs cost`} more than ${Dn(M)} and ${F===1?"is":"are"} drawn at the top.`:"",g.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,...lI(e,n,o)].map(Q=>t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:Q},Q))]}),t.jsxs("details",{className:"border-t px-4 py-2",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),t.jsx("div",{className:"max-h-96 overflow-auto",children:t.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[t.jsx("thead",{className:"sticky top-0 z-sticky bg-card",children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Started","Path","Revision","Run $","Learning $","All-in $"].map(Q=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:Q},Q))})}),t.jsx("tbody",{children:e.runs.map(Q=>{var be;return t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:Q.n}),t.jsx("td",{className:"pr-4",children:ft(Q.started_at)}),t.jsxs("td",{className:"pr-4",children:[ef(Q.path).label,Q.workflow?`: ${Q.workflow}`:""]}),t.jsx("td",{className:"pr-4",children:((be=Q.learned_revision)==null?void 0:be.slice(0,7))??"-"}),t.jsx("td",{className:"pr-4",children:Q.cost_usd===null?"unknown":Dn(Q.cost_usd)}),t.jsx("td",{className:"pr-4",children:Q.learning_usd===null?"unknown":Dn(Q.learning_usd)}),t.jsx("td",{className:"pr-4",children:Q.total_usd===null?"unknown":Dn(Q.total_usd)})]},Q.run_id)})})]})}),f.length>0&&t.jsxs("table",{className:"mt-3 w-full border-collapse font-mono text-small","data-testid":"marker-table",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Marker","Workflow","Revision","Numbers"].map(Q=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:Q},Q))})}),t.jsx("tbody",{children:f.map(Q=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:Q.n}),t.jsxs("td",{className:"pr-4",children:[eb[Q.kind]," ",Fc[Q.kind]]}),t.jsx("td",{className:"pr-4",children:Q.workflow}),t.jsx("td",{className:"pr-4",children:Q.digest.slice(0,7)}),t.jsx("td",{className:"pr-4 font-sans",children:Pa(Q.record)})]},`${Q.kind}:${Q.n}:${Q.workflow}:${Q.digest}:${Q.at}`))})]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["As CSV: ",t.jsxs("code",{className:"font-mono",children:["agentrun learning cost ",e.agent," --format csv"]})]})]})]})}const aI=64,Oo={top:4,bottom:6},iI=[...Ma].reverse(),Yk=e=>e.from===e.to?`Run ${e.from}`:`Runs ${e.from} to ${e.to}`;function Qk({runs:e,width:n,x:s,step:r,plot:o,takeover:i}){const c=aI,d=GP(e.length),u=p.useMemo(()=>qP(e,d),[e,d]),[f,g]=p.useState(null);if(!u.length)return null;const[y,v]=o,h=L=>Math.min(v,Math.max(y,L)),x=L=>({from:h(s(L.from)-r/2),to:h(s(L.to)+r/2)}),b=L=>Oo.top+c*(1-L),j=u.at(-1),k=L=>{const{from:P,to:R}=x(L),A=R-P>4?1:0;return{x0:P+A,w:Math.max(1,R-P-2*A)}},E=L=>`${Yk(L)}: ${Ma.filter(P=>L.counts[P.path]).map(P=>`${P.label.toLowerCase()} ${L.counts[P.path]}`).join(", ")}`,S=u.some(L=>L.counts.workflow)?`${$f(j.counts.workflow,j.runs)} by the learned workflow`:Ma.filter(L=>j.counts[L.path]).map(L=>`${$f(j.counts[L.path],j.runs)} ${L.label.toLowerCase()}`).join(", "),N=`Last ${j.runs===1?"run":`${j.runs} runs`}: ${S}`,$=f===null?null:u[f],_=$?k($).x0>n/2:!1,O=i!==null&&s(i)>=y&&s(i)<=v;return t.jsxs("div",{className:"relative min-w-0",style:{width:n},"data-testid":"execution-mix",children:[t.jsxs("div",{className:"font-mono text-label",style:{paddingLeft:y},children:[t.jsxs("span",{className:"caps block text-muted-foreground",children:["Who finished each run",d>1?`, by ${d}`:""]}),t.jsx("span",{className:"block text-foreground",children:N})]}),t.jsxs("svg",{width:n,height:Oo.top+c+Oo.bottom,className:"mt-2 block select-none font-mono","aria-hidden":!0,onPointerLeave:()=>g(null),children:[[0,.5,1].map(L=>t.jsxs("text",{x:y-6,y:b(L),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:[L*100,"%"]},L)),u.map((L,P)=>{const{x0:R,w:A}=k(L);let M=Oo.top+c;return t.jsxs("g",{onPointerEnter:()=>g(P),opacity:f===null||f===P?1:.55,children:[t.jsx("rect",{x:x(L).from,y:Oo.top,width:Math.max(1,x(L).to-x(L).from),height:c,className:"fill-card",fillOpacity:0}),iI.map(F=>{const I=L.counts[F.path]/L.runs*c;if(!I)return null;M-=I;const q=M>Oo.top+.5?Math.min(2,I):0;return t.jsx("rect",{x:R,y:M+q,width:A,height:I-q,className:F.fill,fillOpacity:.8},F.path)})]},L.from)}),O&&t.jsx("g",{"data-testid":"mix-takeover",children:t.jsx("path",{d:`M${s(i)-r/2},${Oo.top}V${Oo.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",_&&"-translate-x-full"),style:{left:_?k($).x0-6:k($).x0+k($).w+6,top:40},children:[t.jsx("span",{className:"block font-semibold",children:Yk($)}),Ma.filter(L=>$.counts[L.path]).map(L=>t.jsxs("span",{className:"block text-muted-foreground",children:[L.label," ",$.counts[L.path]," (",$f($.counts[L.path],$.runs),")"]},L.path))]}),t.jsx("p",{className:"sr-only",children:`Execution mix in blocks of ${d} runs. ${u.map(E).join(". ")}. ${N}.`})]})}function lI(e,n,s){const r=e.summary;return!r.takeover&&s!=="hosted"?[aC(s)]:r.takeover?r.withheld?[`${sC(r.withheld)}: ${rC}.`]:r.after_state==="cost_unknown"?["No run the workflow served has a known cost yet: a replay is a check, never a served run."]:r.times_cheaper===null&&r.after?[`${xx(r.after.runs)} since the workflow took over: how many times cheaper it is shows after 20.`]:[]:[n?"No learned workflow has finished a run alone yet. Keep running the same job: once one does, a marker shows where, and the level after it.":oC]}function Jk({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(Se,{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 iC={promote:"stroke-chart-workflow",hold:"stroke-warning",revision:"stroke-muted-foreground"},cI={promote:"fill-foreground",hold:"fill-warning-text",revision:"fill-muted-foreground"};function Xk({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",iC[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",cI[s]),children:eb[s]})]})}const Zk=e=>[`${Fc[e.kind]} · run ${e.n}`,`${e.workflow} ${e.digest.slice(0,7)}`,Pa(e.record),ft(e.at)];function Sg({x:e,y:n,anchor:s="start",strong:r=!1,children:o}){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:o})}const Cg=e=>`${e} ${e===1?"run":"runs"}`,sf=e=>e>=1?`$${e.toFixed(2)}`:Dn(e);function dI(e){const n=e.points.at(-1),s=e.withheld?` · ${Cg(e.withheld)} of unknown cost on neither line`:"";if(!n)return{headline:`No run with a known cost yet${s}`,marker:null};if(!e.promoted)return{headline:`No learned workflow serves yet: the bill is the agent's own, ${sf(e.booked_usd)} over ${Cg(e.points.length)}${s}`,marker:null};if(e.break_even){const o=n.agent_usd===null?"":`, ${sf(n.agent_usd)} had the agent done all of it`;return{headline:`Break-even at run ${e.break_even.n}: ${sf(e.booked_usd)} booked over ${Cg(e.points.length)}${o}${s}`,marker:e.break_even.n}}return{headline:`Not yet${e.gap_usd===null?"":`: ${sf(e.gap_usd)} over the agent for all of it at run ${n.n}`}${s}`,marker:null}}function uI(e,n){return e.map(s=>{const r=typeof n=="string"?null:n.filter(o=>o.workflow===s.workflow&&o.agreed!==null);return{workflow:s.workflow,recent:s.audit?{rows:s.audit.rows,agreed:s.audit.rows-s.audit.disagreed,window:s.audit.window,disagree:s.audit.disagree}:null,all:r===null?null:{rows:r.length,agreed:r.filter(o=>o.agreed).length},off:s.audits_off}})}const fI=e=>e==="fast"?"fast":e==="agent"?"agent model":"-",mI=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function vx(e){return mI(e)?e.predicate==="not"?`not ${vx(e.of)}`:(e.predicate==="and"||e.predicate==="or")&&Array.isArray(e.of)?e.of.map(vx).join(` ${e.predicate} `):e.predicate==="field_equals"&&typeof e.path=="string"?`${e.path} = ${JSON.stringify(e.value)}`:[e.predicate,e.path].filter(n=>typeof n=="string").join(" ")||"?":"?"}const hI=e=>`${e.on} ${vx(e.predicate)}`,e0=e=>`${Math.round(e*100)}%`;function pI(e){return e!=null&&e.n?`Checked on ${e.n} ${e.n===1?"input":"inputs"}: ${e.alone??0} answered alone (bar ${e0(e.alone_min)}), ${e.agreed??0} of them agreed (bar ${e0(e.agree_min)}) · inputs from the newest ${e.compile_after} runs · ${e.attempt===1?"first check":"the recompile's check"}`:"Promoted with no check behind it"}function t0({v2:e,agentId:n,cost:s,serving:r,width:o}){const i=s==null?void 0:s.bill,c=!!(i!=null&&i.points.length),[d,u]=p.useState("loading"),f=r.find(g=>g.digest!==null&&g.champion)??null;return p.useEffect(()=>{if(!c)return;let g=!0;return Promise.resolve().then(()=>e.learningAudits(n)).then(y=>{g&&u(y.audits)},()=>{g&&u("failed")}),()=>{g=!1}},[e,n,c,s]),!i||!c?null:t.jsxs(t.Fragment,{children:[t.jsx(gI,{bill:i,width:o}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[t.jsx(xI,{serving:r,audits:d,bill:i}),(f==null?void 0:f.champion)&&t.jsx(vI,{workflow:f.workflow,champion:f.champion})]})]})}const pn={top:16,right:16,bottom:30,left:60},Sa=220;function gI({bill:e,width:n}){var M,F;const s=p.useRef(null),[r,o]=p.useState(n??720);p.useEffect(()=>{const I=s.current;if(n||!I||typeof ResizeObserver>"u")return;const q=new ResizeObserver(([W])=>{W&&W.contentRect.width>0&&o(W.contentRect.width)});return q.observe(I),()=>q.disconnect()},[n]);const[i,c]=p.useState(null),d=e.points,{headline:u,marker:f}=dI(e),g=d.some(I=>I.agent_usd!==null),y=Math.max(300,r),v=y-pn.left-pn.right,h=((M=d[0])==null?void 0:M.n)??1,x=((F=d.at(-1))==null?void 0:F.n)??1,b=I=>pn.left+(x===h?v/2:(I-h)/(x-h)*v),j=p.useMemo(()=>Q2(d.reduce((I,q)=>Math.max(I,q.actual_usd,q.agent_usd??0),-1/0)),[d]),k=I=>pn.top+Sa-I/j*Sa,E=I=>I.map(([q,W],K)=>`${K?"L":"M"}${b(q).toFixed(1)},${k(W).toFixed(1)}`).join(""),S=E(d.map(I=>[I.n,I.actual_usd])),N=g?E(d.filter(I=>I.agent_usd!==null).map(I=>[I.n,I.agent_usd])):null,$=d.at(-1),_=y<520,O=i===null?null:d[i]??null,L=e.unattributed_usd??0,P=I=>{const q=I.currentTarget.getBoundingClientRect(),W=(I.clientX-q.left)/q.width*y;let K=0;d.forEach((U,H)=>{Math.abs(b(U.n)-W)<Math.abs(b(d[K].n)-W)&&(K=H)}),c(d.length?K:null)},R=I=>{const W={ArrowRight:K=>K+1,ArrowLeft:K=>K-1,Home:()=>0,End:()=>d.length-1}[I.key];if(!W){I.key==="Escape"&&c(null);return}I.preventDefault(),c(K=>Math.min(d.length-1,Math.max(0,W(K??(I.key==="ArrowLeft"?d.length:-1)))))},A=I=>[`Run ${I.n}`,`Your bill ${Dn(I.actual_usd)}`,...I.agent_usd===null?[]:[`The agent for all of it ${Dn(I.agent_usd)}`]];return t.jsxs(sb,{title:"The bill",headline:u,testid:"learning-bill",children:[t.jsxs("figure",{ref:s,className:"px-4 pb-2 pt-3",children:[g&&t.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-small text-muted-foreground","data-testid":"bill-legend",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-chart-workflow",strokeWidth:2})}),"Your bill, booked"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-chart-agent",strokeWidth:2,strokeDasharray:"5 3"})}),"The agent for all of it"]})]}),t.jsxs("div",{className:"relative",tabIndex:0,onKeyDown:R,onBlur:()=>c(null),"aria-label":`The bill, runs ${h} to ${x}. ${u}. Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:y,height:pn.top+Sa+pn.bottom,className:"block select-none font-mono",onPointerMove:P,onPointerLeave:()=>c(null),"aria-hidden":!0,children:[t.jsx("g",{"data-testid":"bill-y-axis",children:J2(j).map(I=>t.jsxs("g",{children:[t.jsx("path",{d:`M${pn.left},${k(I)}H${pn.left+v}`,className:I===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:pn.left-8,y:k(I),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:Dn(I)})]},I))}),X2(h,x,_?5:7).map(I=>t.jsx("text",{x:b(I),y:pn.top+Sa+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:I},I)),t.jsx("text",{x:pn.left-8,y:pn.top+Sa+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),f!==null&&t.jsxs("g",{"data-testid":"bill-break-even",children:[t.jsx("path",{d:`M${b(f)},${pn.top}V${pn.top+Sa}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsxs(Eg,{x:b(f)+(b(f)>pn.left+v*.7?-6:6),y:pn.top+10,anchor:b(f)>pn.left+v*.7?"end":"start",strong:!0,children:["Break-even, run ",f]})]}),N&&t.jsx("path",{d:N,"data-testid":"bill-agent",fill:"none",className:"stroke-chart-agent",strokeWidth:2,strokeDasharray:"5 3",strokeLinejoin:"round"}),t.jsx("path",{d:S,"data-testid":"bill-actual",fill:"none",className:"stroke-chart-workflow",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),$&&!_&&t.jsxs("g",{children:[t.jsxs(Eg,{x:b($.n)-4,y:k($.actual_usd)+($.agent_usd!==null&&$.agent_usd>$.actual_usd?16:-8),anchor:"end",children:["Your bill ",Dn($.actual_usd)]}),$.agent_usd!==null&&t.jsxs(Eg,{x:b($.n)-4,y:k($.agent_usd)+($.agent_usd>$.actual_usd?-8:16),anchor:"end",children:["Agent for all of it ",Dn($.agent_usd)]})]}),O&&t.jsxs("g",{children:[t.jsx("path",{d:`M${b(O.n)},${pn.top}V${pn.top+Sa}`,className:"stroke-border-strong",strokeWidth:1}),O.agent_usd!==null&&t.jsx("circle",{cx:b(O.n),cy:k(O.agent_usd),r:4,className:"fill-chart-agent stroke-card",strokeWidth:2}),t.jsx("circle",{cx:b(O.n),cy:k(O.actual_usd),r:4,className:"fill-chart-workflow stroke-card",strokeWidth:2})]})]}),O&&t.jsx("div",{className:ae("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",b(O.n)>y*.6&&"-translate-x-full"),style:{left:b(O.n)>y*.6?b(O.n)-10:b(O.n)+10,top:pn.top},children:A(O).map((I,q)=>t.jsx("span",{className:ae("block",q===0?"font-semibold":"text-muted-foreground"),children:I},I))}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:O?A(O).join(", "):""})]}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Each point adds a run that did a job, all in: its own cost, its look-back and grade, and its audit's shadow run, with each replay run on the run before it.",g?" The dashed line is the mean of the agent's own runs before its first served run, times the runs.":"",L>0?` ${Dn(L)} of learning spend is on no run yet: a revision's compile and check its next served runs carry, or one that stopped or never drafted.`:""]})]}),t.jsxs("details",{className:"border-t px-4 py-2",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),t.jsx("div",{className:"max-h-96 overflow-auto",children:t.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[t.jsx("thead",{className:"sticky top-0 z-sticky bg-card",children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Run id","Your bill $","The agent for all of it $"].map(I=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:I},I))})}),t.jsx("tbody",{children:d.map(I=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:I.n}),t.jsx("td",{className:"pr-4",children:I.run_id}),t.jsx("td",{className:"pr-4",children:n0(I.actual_usd)}),t.jsx("td",{className:"pr-4",children:I.agent_usd===null?"-":n0(I.agent_usd)})]},I.run_id))})]})})]})]})}const n0=e=>e>=1?`$${e.toFixed(2)}`:Dn(e);function xI({serving:e,audits:n,bill:s}){var c;const r=uI(e,n),o=s.holds;if(!r.length&&!o.length)return null;const i=(c=s.points.at(-1))==null?void 0:c.n;return t.jsxs(sb,{title:"Audits",headline:null,testid:"learning-audits",children:[t.jsx("ul",{className:"space-y-2 px-4 py-3 text-body",children:r.map(d=>t.jsxs("li",{className:"space-y-0.5",children:[t.jsx("span",{className:"block font-mono font-semibold",children:d.workflow}),d.recent&&t.jsxs("span",{className:"block",children:["Last ",d.recent.rows," ",d.recent.rows===1?"audit":"audits",": ",d.recent.agreed," agreed ",t.jsxs("span",{className:"text-muted-foreground",children:["· hold at ",d.recent.disagree," disagreeing of the newest ",d.recent.window]})]}),d.all&&t.jsxs("span",{className:"block",children:["All time: ",d.all.agreed," of ",d.all.rows," agreed"]}),d.off&&t.jsx("span",{className:"block text-muted-foreground",children:d.off})]},d.workflow))}),n==="failed"&&t.jsx("p",{className:"border-t px-4 py-2 text-small text-warning-text",role:"status",children:"The audits couldn't be read, so there is no all-time figure. Reload to try again."}),o.length>0&&t.jsx("ul",{className:"space-y-0.5 border-t px-4 py-3 font-mono text-small","data-testid":"audit-holds",children:o.map(d=>t.jsxs("li",{children:[d.n!==null?`Held at run ${d.n}`:`Held after run ${i??0}`," ",t.jsxs("span",{className:"text-muted-foreground",children:["· ",d.workflow," · ",d.by==="audit"?"by its audits":d.by==="check"?"by its check":"refused by this release's DSL"," · ",ft(d.at)]})]},`${d.workflow}:${d.at}`))})]})}function vI({workflow:e,champion:n}){const s=n.nodes;return t.jsxs(sb,{title:"Serving workflow",headline:e,testid:"serving-workflow",children:[s!=null&&s.length?t.jsx("div",{className:"overflow-auto px-4 py-2",children:t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Node","Kind","Tier","Code checks"].map(r=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:r},r))})}),t.jsx("tbody",{children:s.map(r=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:r.label}),t.jsx("td",{className:"pr-4 text-muted-foreground",children:r.kind}),t.jsx("td",{className:"whitespace-nowrap pr-4",children:fI(r.tier)}),t.jsx("td",{className:"pr-4",children:r.checks.map(hI).join("; ")||"-"})]},r.path))})]})}):t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:s===null?"Its workflow.json couldn't be read.":"Its workflow.json has no nodes."}),t.jsx("p",{className:"border-t px-4 py-2 text-small text-muted-foreground",children:pI(n.check)})]})}function sb({title:e,headline:n,testid:s,children:r}){return t.jsxs("section",{className:"min-w-0 border bg-card","aria-label":e,"data-testid":s,children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[t.jsx("h3",{className:"caps text-small font-semibold",children:e}),n&&t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:n})]}),r]})}function Eg({x:e,y:n,anchor:s="start",strong:r=!1,children:o}){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:o})}function bI(e){const n=[];let s=[],r="",o=!1;const i=e.replace(/^/,"");for(let c=0;c<i.length;c++){const d=i[c];o?d==='"'?i[c+1]==='"'?(r+='"',c++):o=!1:r+=d:d==='"'&&r===""?o=!0:d===","?(s.push(r),r=""):d===`
|
|
630
|
-
`||d==="\r"?(d==="\r"&&i[c+1]===`
|
|
631
|
-
`&&c++,s.push(r),r="",s.some(u=>u.trim()!=="")&&n.push(s),s=[]):r+=d}return o?null:(s.push(r),s.some(c=>c.trim()!=="")&&n.push(s),n)}function yI(e){var i;const n=bI(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 o=n.findIndex(c=>c.length!==s.length);return o>=0?{error:`Row ${o+1} has ${n[o].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 s0=500,wI=5,bx=e=>e.status==="running";function jI(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 kI={agent:"by hand",handed_back:"handed back",workflow:"workflow"},NI=2e3;function SI({v2:e,agentId:n,onFinished:s,pollMs:r=NI}){const[o,i]=p.useState(void 0),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,y]=p.useState(0),v=p.useRef(!1),h=p.useRef(s);if(h.current=s,p.useEffect(()=>{let b=!0,j;const k=async E=>{var S,N;try{const $=E??((S=(await e.learningBatches(n)).batches[0])==null?void 0:S.id),_=$?await e.learningBatch(n,$):null;if(!b)return;i(_),d(null),_&&bx(_)?(v.current=!0,j=setTimeout(()=>void k(_.id),r)):_&&v.current&&(v.current=!1,(N=h.current)==null||N.call(h))}catch($){if(!b)return;d($??new Error("unknown")),j=setTimeout(()=>void k(E),r*2)}};return k(),()=>{b=!1,clearTimeout(j)}},[e,n,r,g]),o===void 0&&!c)return t.jsx(xn,{className:"h-24 w-full"});if(o===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),y(b=>b+1)},children:"Read again"})]});const x=o&&bx(o);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"}),!x&&!u&&t.jsx(B,{size:"sm",onClick:()=>f(!0),children:o?"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&&!x&&t.jsx(CI,{v2:e,agentId:n,onStarted:b=>{v.current=!0,i(b),f(!1),y(j=>j+1)},onCancel:()=>f(!1)}),o&&!u&&t.jsx(_I,{v2:e,agentId:n,batch:o,onBatch:i}),!o&&!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 CI({v2:e,agentId:n,onStarted:s,onCancel:r}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[g,y]=p.useState(""),[v,h]=p.useState(String(wI)),[x,b]=p.useState(!1),[j,k]=p.useState(null),E=async _=>{var R;const O=(R=_.target.files)==null?void 0:R[0];if(!O)return;k(null);const L=yI(await O.text());if("error"in L){i(null),d(L.error);return}d(L.rows.length>s0?`A batch takes at most ${s0} rows: this file has ${L.rows.length}.`:null),i({name:O.name,columns:L.columns,rows:L.rows});const P=L.columns.at(-1);y(P),f(L.columns.filter(A=>A!==P))},S=Number(v),N=!!o&&!c&&u.length>0&&!!g&&!u.includes(g)&&Number.isFinite(S)&&S>0,$=async()=>{var _,O;if(!(!o||!N)){b(!0),k(null);try{s(await e.startLearningBatch(n,{inputs:u,answer:g,rows:o.rows,max_cost_usd:S}))}catch(L){k(L instanceof Ue?((O=(_=L.fields)==null?void 0:_[0])==null?void 0:O.message)??L.message:L instanceof Error?L.message:String(L)),b(!1)}}};return t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsx(xt,{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:_=>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}),o&&!("error"in o)&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[o.name,": ",o.rows.length," rows, ",o.columns.length," columns"]}),t.jsx(xt,{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:o.columns.map(_=>t.jsx(BS,{label:_,checked:u.includes(_),disabled:_===g,onChange:O=>f(L=>O.target.checked?o.columns.filter(P=>L.includes(P)||P===_):L.filter(P=>P!==_))},_))})}),t.jsx(xt,{label:"The answer column",note:"What the agent is told after each answer: the reference it should have given.",children:t.jsx(Et,{label:"The answer column",value:g,onChange:_=>{y(_),f(O=>O.filter(L=>L!==_))},options:o.columns.map(_=>({value:_,label:_}))})}),t.jsx(xt,{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 ${so(S)} for ${o.rows.length} rows.`:void 0,children:t.jsx(Pe,{inputMode:"decimal",value:v,onChange:_=>h(_.target.value),className:"max-w-40","aria-label":"Cap, in dollars"})}),t.jsx(EI,{columns:[...u,g].filter(Boolean),rows:o.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||x,onClick:()=>void $(),children:x?"Starting":"Learn"}),t.jsx(B,{variant:"ghost",onClick:r,disabled:x,children:"Cancel"})]})]})}function EI({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(o=>t.jsx("td",{className:"max-w-64 truncate border-b px-2 py-1",children:s[o]},o))},r))})]})})}const $I={running:"active",completed:"success",cancelled:"muted",stopped:"warning"};function _I({v2:e,agentId:n,batch:s,onBatch:r}){const[o,i]=p.useState(!1),[c,d]=p.useState(null),u=async()=>{i(!0),d(null);try{r(await e.cancelLearningBatch(n,s.id))}catch(y){d(y instanceof Error?y.message:String(y))}i(!1)},f=jI(s),g=s.cost_usd===null?"unknown":so(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(Se,{tone:$I[s.status],children:s.status}),t.jsxs("span",{className:"font-mono text-body",children:[s.finished," of ",s.total," rows"]})]}),bx(s)&&t.jsx(B,{size:"sm",variant:"destructive",disabled:o,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(bt,{tone:"warning",children:f}),s.status==="completed"&&t.jsx(bt,{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(Lo,{label:"Right",value:`${s.right}`}),t.jsx(Lo,{label:"Wrong",value:`${s.wrong}`}),t.jsx(Lo,{label:"Failed",value:`${s.failed}`}),t.jsx(Lo,{label:"Cost so far",value:`${g} of ${so(s.max_cost_usd)}`}),t.jsx(Lo,{label:"Notes learned",value:`${s.lessons.notes.length}`}),t.jsx(Lo,{label:"Skills learned",value:`${s.lessons.skills.length}`}),t.jsx(Lo,{label:"Workflow revisions",value:`${s.revisions.length}`}),t.jsx(Lo,{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(y=>`${y} (skill)`),...s.lessons.workflows.map(y=>`${y} (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(y=>t.jsx("th",{className:"caps sticky top-0 border-b bg-card px-2 py-1 text-left font-semibold",children:y},y))})}),t.jsx("tbody",{children:s.rows.map(y=>t.jsxs("tr",{"aria-current":s.current===y.n?"step":void 0,children:[t.jsx("td",{className:"border-b px-2 py-1",children:y.n}),t.jsx("td",{className:"border-b px-2 py-1",children:y.state==="done"?t.jsx(Se,{tone:y.right?"success":"error",children:y.right?"right":"wrong"}):y.state==="failed"?t.jsx(Se,{tone:"error",title:y.error,children:"failed"}):t.jsx(Se,{tone:y.state==="running"?"active":"muted",children:y.state==="running"?"running":"waiting"})}),t.jsx("td",{className:"border-b px-2 py-1",children:y.path?kI[y.path]:""}),t.jsx("td",{className:"border-b px-2 py-1",children:y.total_usd==null?"":so(y.total_usd)}),t.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:y.answer??void 0,children:y.answer??""}),t.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:y.reference,children:y.reference})]},y.n))})]})})]})}const Lo=({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})]}),TI="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).",$g=e=>`${Math.round(e*1e3)/10}%`;function RI(e){const{cost_per_task_usd:n,baseline_cost_per_task_usd:s}=e,r=n!==null&&s!==null,o=r&&n>0?s/n:null,[i,c]=e.ci;return{accuracy:$g(e.accuracy),accuracyVs:`95% interval ${$g(i)} to ${$g(c)}, n=${e.n.toLocaleString("en-US")}`,cost:r?o===null||s===0?cr(n):o>=1?`${gx(o)} cheaper`:`${gx(n/s)} the cost`:n!==null?cr(n):"Not counted",costVs:r?`${cr(n)} a task vs ${cr(s)} by hand`:n!==null?`${cr(n)} a task; by hand not counted`:"The test did not count the cost a task."}}function r0({v2:e,agentId:n,quiet:s=!1}){const[r,o]=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(g=>{f&&o(g)},g=>{f&&c(g??new Error("unknown"))}),()=>{f=!1}},[e,n,d]),s&&!(r!=null&&r.latest)?null:i&&!r?t.jsx(os,{problem:Ar(i,"the held-out test"),onRetry:()=>u(f=>f+1),className:""}):r?t.jsx(AI,{result:r.latest}):t.jsx(xn,{className:"h-[116px] w-full"})}function AI({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("h2",{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," · ",ft(e.recorded_at),e.learned_revision?` · revision ${e.learned_revision.slice(0,7)}`:""]})]}),e?t.jsx(OI,{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:TI})]})]})}function OI({result:e}){const n=RI(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,o)=>t.jsxs("div",{className:o?"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 Vf="https://api.githubcopilot.com/mcp/",Ed={composio:"Composio",github:"GitHub",url:"URL"},o0=/^[a-z][a-z0-9-]{0,31}$/,rb=[{id:"parallel",label:"Parallel Search",name:"parallel",url:"https://mcp.parallel.ai/mcp",auth:"none",note:"Web search, free for light use: no key, no account."},{id:"firecrawl",label:"Firecrawl",name:"firecrawl",url:"https://mcp.firecrawl.dev/v2/mcp",auth:"none",note:"Search, scrape and parse, free without a key and rate limited: add your Firecrawl key later as a bearer token for more."},{id:"github-token",label:"GitHub (token)",name:"github",url:Vf,readOnly:`${Vf}readonly`,auth:"bearer",note:"A fine-grained personal access token for the repositories it may use, with Contents, Issues and Pull requests (read-only, or read and write)."},{id:"linear",label:"Linear",name:"linear",url:"https://mcp.linear.app/mcp",auth:"oauth",note:"Sign in with your Linear account: this server keeps the tokens."},{id:"notion",label:"Notion",name:"notion",url:"https://mcp.notion.com/mcp",auth:"oauth",note:"Sign in with your Notion workspace: this server keeps the tokens."}],lC=e=>rb.find(n=>n.id===e);function LI(e){const n=new URLSearchParams(e??""),s=n.get("add");if(!s||!o0.test(s))return;const r=n.get("toolkit")??"",o=n.get("preset")??void 0;if(o==="composio"&&o0.test(r)){const c=(n.get("tools")??"").split(",").filter(d=>/^[A-Za-z0-9_-]{1,128}$/.test(d)).slice(0,64);return{name:s,preset:"composio",toolkit:r,...c.length?{tools:c}:{}}}const i=lC(o);return i?{name:s,preset:i.id}:{name:s,...n.get("auth")==="github_app"?{auth:"github_app"}:{}}}const MI="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.",cC=(e,n)=>`mcp:${e}/${n}`;function qo(e){const n=/^mcp:([^/]+)\/(.+)$/.exec(e);return n?{server:n[1],tool:n[2]}:null}function PI(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 II(e,n){return e.flatMap(s=>{const r=qo(s);if(!r)return[];const o=n.find(i=>i.name===r.server);return o?o.tools.some(i=>i.name===r.tool)?[]:[{grant:s,why:`${r.server} no longer lists ${r.tool}: refresh it, or untick this.`}]:[{grant:s,why:`The MCP server ${r.server} is not saved here any more, so a run can't call it.`}]})}const a0=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 io(e){var i,c,d,u,f,g,y,v;if(!(e instanceof Ue))return{text:`The request didn't reach this server: ${e instanceof Error?e.message:String(e)}`};const n=(i=e.fields)==null?void 0:i.find(h=>h.field==="url"&&h.reason==="redirect"),s=(c=e.fields)==null?void 0:c.find(h=>h.field==="client_id"&&h.reason==="registration_unavailable"),r=(d=e.details)==null?void 0:d.oauth,o=typeof(r==null?void 0:r.callback)=="string"?r.callback:"";return s?{text:s.message,detail:a0(o),signIn:!0,needsClient:!0}:e.code==="auth_required"&&((u=e.details)==null?void 0:u.auth)==="oauth"&&(r==null?void 0:r.registration)===!1?{text:"This server signs in with OAuth, and its sign-in lets no app register itself.",detail:a0(o),signIn:!0,needsClient:!0}:e.code==="auth_required"?((f=e.details)==null?void 0:f.auth)==="oauth"?{text:"This server signs in with OAuth.",detail:"Sign in to it: its tools are saved once you approve.",signIn:!0}:{text:"This server asks for a token.",detail:e.message}:e.code==="github_not_connected"?{text:"GitHub is not connected on this server.",detail:`${e.message} A GitHub App server runs on this server's GitHub App: connect GitHub, or add a repository to its installation, in Settings → GitHub, then try again.`}:e.code==="not_mcp"?{text:"This address doesn't speak MCP.",detail:e.message}:n?{text:"This address redirects; use the final address.",detail:n.message}:e.status===424?{text:`The server failed: ${e.message}`}:e.code==="wrong_origin"?{text:"Sign in from this server's own address: the sign-in comes back there.",...typeof((g=e.details)==null?void 0:g.open)=="string"?{detail:`Open ${e.details.open} and sign in from it.`}:{}}:(y=e.fields)!=null&&y.length?{text:e.fields.map(h=>h.message).join(" "),...typeof((v=e.details)==null?void 0:v.composio)=="string"?{detail:e.details.composio}:{}}:{text:`${e.code}: ${e.message}`}}const i0={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"},zI="the sign-in didn't finish: try again",DI=e=>e&&Object.hasOwn(i0,e)?i0[e]:zI;function FI(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 $d=qo;function UI(e){const n=qo(e);return n?`${n.server} · ${n.tool}`:null}const WI="https://chatgpt.com/#settings",yx="chatgpt",Xc=e=>!!e&&e.startsWith(`${yx}/`)&&e.length>yx.length+1,dC="Codex and pi agents run on your ChatGPT plan. Claude Agent, OpenCode, Jev decisions and paid tools need their own keys.",HI="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.",BI="This sign-in is yours: don't let other people run agents on this server with it.",GI="Signed out. If ChatGPT still lists AgentRun under connected apps, disconnect it there.",qI="Signed out here. OpenAI didn't confirm the revocation: remove AgentRun in your ChatGPT settings.",KI="Your ChatGPT sign-in expired. Sign in again.",uC="Requests on your ChatGPT plan cost no dollars here; your plan's own limits apply.",VI=`Counts dollars. ${uC}`,YI=new Set(["signed_out","pending","signed_in","expired"]),Yf=e=>e&&typeof e=="object"&&YI.has(String(e.state))?e:null,QI=e=>e.charAt(0).toUpperCase()+e.slice(1),JI=e=>`Signed in as ${e.email??"your ChatGPT account"}${e.plan?` (${QI(e.plan)})`:""}`;function xl(e,n){return Xc(e)?{text:`${e.slice(yx.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 fC(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 XI(e,n,s,r){return!e||typeof r!="number"||Xc(e)?null:fC(n,s).has(e)?`free model: up to ${r} requests`:null}function ZI(e){return e>=1e6?`${Math.round(e/1e6*10)/10}M`.replace(/\.0M$/,"M"):`${Math.round(e/1e3)}K`}function ez(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.models)??[]}function mC(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 tz="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",nz="none yet: add a model key in Settings → Model keys",hC=e=>xl(e,null).text,ob=(e,n)=>[e,n!=null&&n.model?n.tier:void 0,n!=null&&n.model?hC(n.model):void 0].filter(Boolean).join(" · "),pC=e=>e!=null&&e.model?`ran on ${hC(e.model)}${e.tier?` (the ${e.tier} tier)`:""}`:"",sz="http://www.w3.org/2000/svg",Ii=16,cn=240,rz=40,oz=58,_g=16,Tg=26,rf=18,zi=14,l0=16,az=26,iz=14,lz=22,Us=14,c0=16,of=16,cz=4,dz=10,uz=18,fz=30,mz=5,Oc=124,wx=34,hz=4,Rg=10*.6,pz=12.5*.6,Zc=10.5*.6,d0=11*.6,ab=9*.66,u0=10.5*.6,gz={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"},ib=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),Qf={review:"needs review","not-run":"",pending:""};function wt(e,n,...s){const r=document.createElementNS(sz,e);if(n)for(const[o,i]of Object.entries(n))r.setAttribute(o,String(i));for(const o of s)Ss(r,o);return r}function Ss(e,n){if(n!=null){if(Array.isArray(n)){for(const s of n)Ss(e,s);return}e.appendChild(typeof n=="string"?document.createTextNode(n):n)}}const _r=(e,n)=>e.length>n?`${e.slice(0,n-1)}…`:e,xz=(e,n)=>{const s=/^(.*) (\d\.\d\d)$/.exec(e);return!s||e.length<=n?_r(e,n):`${_r(s[1],Math.max(2,n-s[2].length-1))} ${s[2]}`},Fo=(e,n)=>Math.max(2,Math.floor(e/n)),Ko=(e,n)=>Math.ceil(e.length*n),Bs=(e,n,s,r,o)=>wt("line",{x1:e,y1:n,x2:s,y2:r,class:o?`wire ${o}`:"wire"});function gC(e){const n={},s={};for(const o of e)n[o.path]=o;const r=o=>{var i;return((i=n[o])==null?void 0:i.kind)??""};for(const o of e){let i;const c={node:o,order:0,name:null};let d=null;(i=/^(.*)\/steps\/(\d+)$/.exec(o.path))&&r(i[1])==="chain"?(d=i[1],c.order=Number(i[2])):(i=/^(.*)\/branches\/([^/]*)\/body$/.exec(o.path))&&r(i[1])==="route"?(d=i[1],c.name=i[2].replace(/~1/g,"/").replace(/~0/g,"~")):(i=/^(.*)\/branches\/(\d+)$/.exec(o.path))&&r(i[1])==="parallel"?(d=i[1],c.order=Number(i[2])):((i=/^(.*)\/body$/.exec(o.path))&&(r(i[1])==="map"||r(i[1])==="loop")||(i=/^(.*)\/workflow\/root$/.exec(o.path))&&r(i[1])==="workflow")&&(d=i[1]),d!==null&&(s[d]??(s[d]=[])).push(c)}for(const o of Object.values(s))o.sort((i,c)=>i.order-c.order);return{byPath:n,kids:s}}function lb(e,n){var u,f,g,y;const{diff:s={},status:r={},fired:o}=e.marks,i=n===o?"escalated":r[n],c=i&&ib.has(i)?i:"",d=(u=s.added)!=null&&u.includes(n)?"NEW":(f=s.edited)!=null&&f.includes(n)?"EDITED":(g=s.moved)!=null&&g.includes(n)?"MOVED":"";return{state:c,tag:d,fired:n===o,selected:((y=e.marks.selected)==null?void 0:y.path)===n&&e.marks.selected.item==null}}function _d(e,n,s){var v,h,x;const r=lb(e,n.path),o=(v=e.marks.meta)==null?void 0:v[n.path],i=o!=null&&o.tool?$d(o.tool):null,c=(h=e.marks.ran)==null?void 0:h[n.path],d=o!=null&&o.decision?(c==null?void 0:c.model)??o.model:o==null?void 0:o.model;let u=`${n.label} (${n.kind}${i?`: ${i.tool} on ${i.server}, an MCP server's tool`:n.via?` via ${n.via}`:""}${o!=null&&o.provider?`, ${o.provider}${d?` ${d}`:""}`:""}${c&&!(o!=null&&o.decision)?`, ${pC(c)}`:""})`;r.state&&(u+=`: ${r.state.replace("-"," ")}`),r.tag&&(u+=`${r.state?", ":": "}${r.tag.toLowerCase()}`),(x=o==null?void 0:o.questions)!=null&&x.length&&(u+=`
|
|
632
|
-
${o.questions.map(b=>`• ${b.text}`).join(`
|
|
633
|
-
`)}`);const f=o!=null&&o.decision&&o.provider?`who-${o.provider==="parallel"||o.provider==="openrouter"?o.provider:"jev"}`:n.kind==="route"&&o&&!o.decision?"who-control":`who-${gz[n.kind]??"code"}`;let g=`node ${s} ${f}`;r.state&&(g+=` ${r.state}`),r.fired&&(g+=" fired"),r.tag&&(g+=` ${r.tag.toLowerCase()}`),r.selected&&(g+=" selected");const y=wt("g",{class:g,"data-path":n.path},wt("title",null,u));return e.svg.appendChild(y),y}const nl=e=>Ko(e,ab)+10;function _f(e,n,s,r,o="tag"){const i=nl(r);return Ss(e,[wt("rect",{x:n,y:s,width:i,height:13,class:`${o}-box`}),wt("text",{x:n+i/2,y:s+9.5,class:o,"text-anchor":"middle"},r)]),i}const vz=(e,n)=>{var s,r;return!!((r=(s=e.marks.meta)==null?void 0:s[n.path])!=null&&r.decision)},Ym=(e,n)=>vz(e,n)?oz:rz;function cb(e,n,s,r,o){var k,E,S,N,$;const i=lb(e,s.path),c=(k=e.marks.meta)==null?void 0:k[s.path],d=Ym(e,s),u=(E=e.marks.verdict)==null?void 0:E[s.path],f=i.state in Qf?Qf[i.state]:i.state,g=((S=c==null?void 0:c.questions)==null?void 0:S.length)??0,y=c!=null&&c.tool?$d(c.tool):null,v=(N=e.marks.ran)==null?void 0:N[s.path],h=(v&&!(c!=null&&c.decision)?ob(s.kind,v):s.kind)+(y?` · ${y.tool} on ${y.server}`:c!=null&&c.tool?` · ${c.tool}`:s.via?` · ${s.via}`:"")+(c!=null&&c.decision&&g?` · ${g} ${g===1?"question":"questions"}`:""),x=[($=c==null?void 0:c.images)!=null&&$.length?"IMG":"",c!=null&&c.web?"WEB":"",y?"MCP":""].filter(Boolean),b=x.reduce((_,O)=>_+nl(O)+4,0);i.selected&&n.appendChild(wt("rect",{x:r-4,y:o-4,width:cn+8,height:d+8,class:"sel"})),Ss(n,[wt("rect",{x:r,y:o,width:cn,height:d,class:"box"}),wt("rect",{x:r+10,y:o+9,width:8,height:8,class:"swatch"}),wt("text",{x:r+24,y:o+17,class:"label"},_r(s.label,Fo(cn-34-b,pz))),wt("text",{x:r+24,y:o+31,class:"kind"},_r(h,Fo(cn-34-(f?Ko(f,ab)+8:0),Zc))),f?wt("text",{x:r+cn-10,y:o+31,class:"state","text-anchor":"end"},f):null]);let j=r+cn-8;for(const _ of x.reverse())j-=nl(_),_f(n,j,o+7,_,"badge"),j-=4;if(c!=null&&c.decision&&c.provider){const _=_f(n,r+24,o+38,c.provider,"chip"),O=u?xz(u,Fo(cn-44-_-20,u0)):"",L=cn-40-_-(O?Ko(O,u0)+10:0),P=(v==null?void 0:v.model)??c.model;P&&L>24&&n.appendChild(wt("text",{x:r+24+_+6,y:o+47.5,class:"model"},_r(P,Fo(L,Zc)))),O&&n.appendChild(wt("text",{x:r+cn-10,y:o+47.5,class:"verdict","text-anchor":"end"},O))}else u&&n.appendChild(wt("text",{x:r+cn-10,y:o+17,class:"verdict","text-anchor":"end"},u));i.tag&&_f(n,r+cn-nl(i.tag),o-7,i.tag)}function bz(e,n){return{w:cn,h:Ym(e,n),cx:cn/2,place:(s,r)=>cb(e,_d(e,n,"card"),n,s,r)}}function xC(e,n,s){const r=lb(e,n.path),o=r.state==="done"?"passed":r.state in Qf?Qf[r.state]:r.state,i=_r(n.label===n.kind?"exit":`exit: ${n.label}`,40),c=Ko(i,Zc)+16;return{w:zi+c+(r.tag?6+nl(r.tag):0)+(o?6+Ko(o,ab):0),h:Tg,cx:0,exit:!0,place:(d,u)=>{const f=_d(e,n,"exit"),g=u+Tg/2;let y=d+zi+c;s&&f.appendChild(Bs(d,u,d,u+Tg,"spine")),r.selected&&f.appendChild(wt("rect",{x:d+zi-3,y:g-rf/2-3,width:c+6,height:rf+6,class:"sel"})),Ss(f,[Bs(d,g,d+zi,g,"exit-wire"),wt("rect",{x:d+zi,y:g-rf/2,width:c,height:rf,class:"exit-box"}),wt("text",{x:d+zi+8,y:g+3.5,class:"exit-text"},i)]),r.tag&&(_f(f,y+6,g-6.5,r.tag),y+=6+nl(r.tag)),o&&f.appendChild(wt("text",{x:y+6,y:g+3.5,class:"state"},o))}}}function yz(e,n,s){const r=s.map(d=>d.node.kind==="escalate"?xC(e,d.node,!1):Qm(e,d.node));let o=cn/2,i=cn/2,c=-_g;for(const d of r)o=Math.max(o,d.cx),i=Math.max(i,d.w-d.cx),c+=d.h+_g;return{w:o+i,h:c,cx:o,place:(d,u)=>{const f=_d(e,n,"chain"),g=d+o;let y=u,v=null;r.forEach((h,x)=>{x&&(y+=_g),h.exit?v===null&&(v=y):v!==null&&f.appendChild(Bs(g,v,g,y,"spine")),h.place(h.exit?g:g-h.cx,y),y+=h.h,h.exit||(v=y)}),r[r.length-1].exit&&v!==null&&f.appendChild(Bs(g,v,g,y,"spine"))}}}function wz(e,n,s){const r=Ym(e,n),o=s.map(h=>({kid:h,box:Qm(e,h.node),x:0,c:0}));let i=0,c=0;o.forEach((h,x)=>{x&&(i+=lz),h.x=i,h.c=i+h.box.cx,i+=h.box.w,c=Math.max(c,h.box.h)});const d=o.length-1,u=Math.round((o[0].c+o[d].c)/2),f=Math.min(0,u-cn/2),g=Math.max(i,u+cn/2),y=r+l0+az,v=y+c+iz;return{w:g-f,h:v,cx:u-f,place:(h,x)=>{const b=_d(e,n,"card"),j=h-f,k=x+r+l0,E=x+v;cb(e,b,n,j+u-cn/2,x),b.appendChild(Bs(j+u,x+r,j+u,k)),d&&Ss(b,[Bs(j+o[0].c,k,j+o[d].c,k),Bs(j+o[0].c,E,j+o[d].c,E)]),o.forEach((S,N)=>{const $=j+S.c,_=S.kid.node.path,O=e.taken.has(_);if(b.appendChild(wt("line",{x1:$,y1:k,x2:$,y2:x+y,class:O?"wire branch taken":"wire branch","data-to":_})),S.kid.name!==null){const L=(N<d?o[N+1].c-6:S.x+S.box.w)-S.c-12,P=_r(S.kid.name,Fo(L,Zc)),R=wt("text",{x:$+6,y:k+15,class:O?"branch-name taken":"branch-name"},P);b.appendChild(P===S.kid.name?R:wt("g",null,wt("title",null,S.kid.name),R))}b.appendChild(Bs($,x+y+S.box.h,$,E,O?"taken":void 0)),S.box.place(j+S.x,x+y)})}}}const jz=e=>e.replace(/^.*\//,"").replace(/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,"");function kz(e,n,s,r,o,i){const c=ib.has(s.status)?s.status:"pending",d=s.label?jz(s.label):`#${s.index+1}`,u=s.outcome??(c==="review"?"needs review":c==="not-run"?"not run":c),f=s.p!==void 0?s.p.toFixed(2):"",g=`#${s.index+1}${s.label?` ${s.label}`:""}: ${c==="review"?"needs review":c.replace("-"," ")}${s.outcome?`, ${s.outcome}`:""}${s.pNote?` (${s.pNote})`:""}`,y=wt("g",{class:`rcell ${c}${s.tone?` tone-${s.tone}`:""}${i?" picked":""}`,"data-path":n.path,"data-item":s.index},wt("title",null,g),wt("rect",{x:r,y:o,width:Oc,height:wx,class:"cell"}),wt("rect",{x:r,y:o,width:3,height:wx,class:"cell-edge"}),wt("text",{x:r+9,y:o+14,class:"cell-name"},_r(d,Fo(Oc-14,Rg))),wt("text",{x:r+9,y:o+27,class:"cell-out"},_r(u,Fo(Oc-18-(f?Ko(f,Rg)+6:0),Rg))),f?wt("text",{x:r+Oc-6,y:o+27,class:"cell-p","text-anchor":"end"},f):null);e.appendChild(y)}function Nz(e,n){var j;const s=((j=e.marks.items)==null?void 0:j[n.path])??[];if(!s.length)return null;const r=s.length<=fz,[o,i,c]=r?[Oc,wx,hz]:[of,of,cz],d=Math.min(s.length,r?mz:dz),u=Math.ceil(s.length/d),f=d*(o+c)-c,g=u*(i+c)-c+uz+(r?4:0),y={};for(const k of s)y[k.status]=(y[k.status]??0)+1;const v={};for(const k of s)k.outcome&&(v[k.outcome]=(v[k.outcome]??0)+1);const h=Object.entries(v).map(([k,E])=>`${E} ${k}`),b=[`${y.done??0}/${s.length} done`,y.working?`${y.working} working`:"",y.held?`${y.held} held`:"",y.failed?`${y.failed} failed`:"",y.review?`${y.review} review`:"",...h].filter(Boolean).join(" · ");return{w:Math.max(f,Ko(b,Zc)),h:g,place:(k,E,S)=>{const N=E-f/2,$=e.marks.selected;s.forEach((_,O)=>{const L=N+O%d*(o+c),P=S+Math.floor(O/d)*(i+c),R=ib.has(_.status)?_.status:"pending",A=($==null?void 0:$.path)===n.path&&$.item===_.index;if(r){kz(k,n,_,L,P,A);return}Ss(k,wt("rect",{x:L,y:P,width:of,height:of,class:`cell ${R}${A?" picked":""}`,"data-path":n.path,"data-item":_.index},wt("title",null,`#${_.index+1}${_.label?` ${_.label}`:""}: ${R==="review"?"needs review":R.replace("-"," ")}`)))}),Ss(k,wt("text",{x:E,y:S+g-4,class:"caption","text-anchor":"middle"},b))}}}function Sz(e,n,s){const r=Qm(e,s),o=Ym(e,n),i=n.kind==="map"?Nz(e,n):null,c=i?i.h+Us:0,d=Math.max(cn/2,r.cx,i?i.w/2:0)+Us,u=Math.max(cn/2,r.w-r.cx,i?i.w/2:0)+Us,f=o+Us+c+r.h+Us;return{w:d+u,h:f,cx:d,place:(g,y)=>{const v=_d(e,n,"card"),h=g+d;if(Ss(v,wt("rect",{x:g,y:y+o/2,width:d+u,height:f-o/2,class:"frame"})),i?(Ss(v,Bs(h,y+o,h,y+o+Us)),Ss(v,Bs(h,y+o+Us+i.h,h,y+o+Us+c))):Ss(v,Bs(h,y+o,h,y+o+Us)),Ss(v,Bs(h,y+o+Us+c+r.h,h,y+f)),cb(e,v,n,h-cn/2,y),i){const x=wt("g",{class:"items"});i.place(x,h,y+o+Us),v.appendChild(x)}r.place(h-r.cx,y+o+Us+c)}}}function vC(e,n){return e.kind==="escalate"?"exit":n.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function Qm(e,n){const s=e.kids[n.path]??[],r=vC(n,s);return r==="exit"?xC(e,n,!0):r==="leaf"?bz(e,n):r==="chain"?yz(e,n,s):r==="fan"?wz(e,n,s):Sz(e,n,s[0].node)}function db(e){const{byPath:n,kids:s}=gC(bC(e)),r=o=>{const i=s[o.path]??[],c=vC(o,i),d=c==="frame"?r(i[0].node):c==="chain"||c==="fan"?i.reduce((u,f)=>u+r(f.node),0):0;return(c==="chain"?0:1)+d};return n["/root"]?r(n["/root"]):0}const Jm=e=>`${e} ${e===1?"node":"nodes"}`,bC=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 Cz(e,n,s={}){var g;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const r=gC(bC(n)),o=(y,v)=>(e.setAttribute("viewBox",`0 0 ${y} ${v}`),e.setAttribute("width",String(y)),e.setAttribute("height",String(v)),e.style.setProperty("min-width",`${Math.min(y,480)}px`),{w:y,h:v});if(!r.byPath["/root"])return o(0,0);const i={svg:e,kids:r.kids,marks:s,taken:new Set(s.taken??[])},c=Qm(i,r.byPath["/root"]);c.place(Ii,Ii);let d=c.w,u=c.h;const f=(((g=s.diff)==null?void 0:g.removed)??[]).map(y=>`${y.label} (${y.kind})`);if(f.length){const y=["Removed:",...f.map(h=>_r(h,Fo(Math.max(d,300),d0)))],v=wt("g",{class:"removed-list"},wt("title",null,`Removed: ${f.join(", ")}`));y.forEach((h,x)=>{v.appendChild(wt("text",{x:Ii,y:Ii+u+33+x*c0,class:"removed"},h)),d=Math.max(d,Ko(h,d0))}),e.appendChild(v),u+=22+y.length*c0}return o(d+2*Ii,u+2*Ii)}function Ez(e){var o,i;const n=e,s=(o=n==null?void 0:n.closest)==null?void 0:o.call(n,"[data-item]");if(s)return{path:s.getAttribute("data-path"),item:Number(s.getAttribute("data-item"))};const r=(i=n==null?void 0:n.closest)==null?void 0:i.call(n,"g[data-path]");return!r||r.classList.contains("chain")?null:{path:r.getAttribute("data-path"),item:null}}const $z=1600;function Td({graph:e,marks:n,onSelect:s,className:r,label:o="Workflow graph",minScale:i=.8,maxScale:c=1.3}){const d=p.useRef(null),[u,f]=p.useState({w:0,h:0}),[g,y]=p.useState(0),v=p.useMemo(()=>JSON.stringify([(e==null?void 0:e.nodes)??null,n??null]),[e,n]);p.useEffect(()=>{if(!d.current)return;const x=Cz(d.current,e,n);f(b=>b.w===x.w&&b.h===x.h?b:x),d.current.style.setProperty("--wf-phase",`-${Date.now()%$z}ms`)},[v]),p.useEffect(()=>{var j;const x=(j=d.current)==null?void 0:j.parentElement;if(!x||typeof ResizeObserver>"u")return;const b=new ResizeObserver(([k])=>y(k.contentRect.width));return b.observe(x),()=>b.disconnect()},[]);const h=u.w&&g?Math.min(c,Math.max(i,g/u.w)):1;return t.jsx("svg",{ref:d,role:"img","aria-label":o,className:ae("wf select-none",r),style:u.w?{width:u.w*h,height:u.h*h,maxWidth:"none",minWidth:0}:void 0,onClick:x=>{const b=Ez(x.target);b&&s&&s(b)}})}function Rd({run:e=!1}){const n=[["hsl(var(--wf-jev))","Jev"],["hsl(var(--wf-parallel))","Parallel"],["hsl(var(--wf-openrouter))","OpenRouter"],["hsl(var(--wf-tool))","Tool"],["hsl(var(--muted-foreground))","Code"],["hsl(var(--primary))","Agent"]],s=[["border-success bg-success/40","Done"],["border-primary bg-primary/20","Working"],["border-dashed border-warning","Held (paused)"],["border-warning bg-warning/60","Needs review"],["border-destructive bg-destructive/60","Failed"],["border-dashed border-border-strong","Pending"]];return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 font-mono text-label text-muted-foreground",children:[n.map(([r,o])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block size-2",style:{background:r}}),o]},o)),e&&t.jsx("span",{className:"h-3 border-l","aria-hidden":!0}),e&&s.map(([r,o])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:ae("inline-block size-2.5 border",r)}),o]},o))]})}const _z=3e3,Tz=e=>e.word==="Held"||e.word==="Not decided",f0=e=>`${Math.round(e*100)}%`,yC=e=>`${e} ${e===1?"input":"inputs"}`;function Rz(e){if(!e)return"Replay started: its runs are queued.";const n=e.outcomes,s=n.answered+n.handed_back+n.failed+n.skipped_write;return`Checking on ${yC(e.inputs)} of the agent's own runs: ${s} of ${e.inputs} ended (${n.answered} answered alone, ${n.handed_back} handed back${n.failed?`, ${n.failed} failed`:""}${n.skipped_write?`, ${n.skipped_write} skipped`:""}).`}function Az(e){const n=e.reason?` ${e.reason.charAt(0).toUpperCase()}${e.reason.slice(1)}`:"",s=e.status==="failed"?`The replay did not finish.${n}`:e.decided==="promote"?`Promoted: it serves first now.${n}`:e.decided==="hold"?`Still held.${n}`:`Decided.${n}`,r=e.score;return{text:s,score:r.n>0?`Workflow ${f0(r.wf_acc)} vs agent ${f0(r.agent_acc)} on ${yC(r.n)} of the agent's own runs, ${r.agree} said what the agent said, ${r.handed_back} handed back`:null}}function Oz({v2:e,agentId:n,workflow:s,digest:r,offered:o,resume:i=null,onStarted:c,onDecided:d,pollMs:u=_z}){const[f,g]=p.useState(i?{at:"running",replay:i,read:null}:{at:"idle"});p.useEffect(()=>{i&&g(j=>j.at==="idle"?{at:"running",replay:i,read:null}:j)},[i]);const y=p.useRef(d);y.current=d;const v=f.at==="running"?f.replay:null,h=f.at==="running"?f.unread:void 0;p.useEffect(()=>{if(v===null||h!==void 0)return;let j=!0,k;const E=()=>{Promise.resolve().then(()=>e.learnedWorkflowReplay(n,s,r,v)).then(S=>{var N;if(j){if(S.status==="running"){g({at:"running",replay:v,read:S}),k=setTimeout(E,u);return}g({at:"decided",read:S}),(N=y.current)==null||N.call(y)}},S=>{j&&g(N=>N.at==="running"?{...N,unread:S instanceof Error?S.message:String(S)}:N)})};return E(),()=>{j=!1,k&&clearTimeout(k)}},[e,n,s,r,v,h,u]);const x=()=>{g({at:"starting"}),Promise.resolve().then(()=>e.startLearnedWorkflowReplay(n,s,r)).then(j=>{g({at:"running",replay:j.replay,read:null}),c==null||c()},j=>{const k=j==null?void 0:j.code;g({at:"refused",message:j instanceof Error?j.message:String(j),code:typeof k=="string"?k:null})})},b=f.at==="starting"||f.at==="running";return!o&&f.at==="idle"?null:t.jsxs("div",{className:"mt-2 space-y-1","data-testid":"replay-revision",children:[(f.at==="idle"||f.at==="starting"||(f.at==="refused"||f.at==="decided")&&o)&&t.jsx(B,{size:"sm",onClick:x,disabled:b,"aria-label":`Check revision ${r.slice(0,7)} on the inputs of the agent's own runs`,children:f.at==="starting"?"Starting…":f.at==="idle"?"Replay":"Replay again"}),f.at==="running"&&t.jsxs("p",{className:"break-words text-body",role:"status","data-testid":"replay-progress",children:[f.unread!==void 0?`Couldn't read the replay: ${f.unread} `:Rz(f.read),f.unread!==void 0&&t.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:()=>g({at:"running",replay:f.replay,read:f.read}),children:"Check again"})]}),f.at==="refused"&&t.jsxs("p",{className:"break-words text-body",role:"alert","data-testid":"replay-refused",children:[f.message,f.code&&t.jsx("span",{className:"ml-2 font-mono text-label text-muted-foreground",children:f.code})]}),f.at==="decided"&&(()=>{const j=Az(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 Ag=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},m0=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function Lz(e,n,s,r,o){const i=[e.length&&`added ${m0(e.length,"node")} (${Ag(e)})`,n.length&&`edited ${Ag(n)}`,s.length&&`removed ${m0(s.length,"node")} (${Ag(s)})`].filter(Boolean);if(!i.length)return r?"Nodes reordered":o?"Connections changed":"No node changed";const c=i.join(", ");return c.charAt(0).toUpperCase()+c.slice(1)}function Mz(e){const n=[];let s=null,r=0;for(const o of e){let i=null,c=null;try{i=o.text===null?null:JSON.parse(o.text),c=i===null?null:ml(i)}catch{c=null}if(!(c!=null&&c.nodes.length)){r+=1;continue}const d=s?w2(s,c):null,u=d?d.added.map(b=>b.path):c.nodes.map(b=>b.path),f=b=>{var j;return((j=c.nodes.find(k=>k.path===b))==null?void 0:j.kind)!=="chain"},g=d?[...d.changed.map(b=>b.next),...d.rewritten.map(b=>b.next)]:[],y=d?d.moved.map(b=>b.next):[],v=new Map(c.nodes.map(b=>[b.path,b.label])),h=d?d.removed.filter(b=>b.kind!=="chain").map(b=>b.label):[],x=d?d.edges.added.length+d.edges.removed.length:0;n.push({digest:o.digest??null,commit:o.commit,at:o.at,run:"run"in o.by?o.by.run:null,reason:o.reason,graph:c,marks:{meta:jd(i,c),diff:{added:u,edited:g,moved:y,removed:d?d.removed.map(({label:b,kind:j})=>({label:b,kind:j})):[]}},added:u,edited:g,removed:h,line:d?Lz(u.filter(f).map(b=>v.get(b)??b),g.filter(f).map(b=>v.get(b)??b),h,y.length,x):`First version: ${Jm(db(c))}`}),s=c}return{steps:n,unreadable:r}}const Pz=50,Iz=1800;function zz({v2:e,agentId:n,workflows:s,promotions:r=[],serving:o=[],cost:i=null,onReplayed:c}){const d=s.filter(y=>y.status==="active").map(y=>y.name),[u,f]=p.useState(null),g=u!==null&&d.includes(u)?u:d[0]??null;return g===null?null:t.jsx(Dz,{v2:e,agentId:n,name:g,choices:d,onPick:f,promotions:r,serving:o,stopped:nb(i,g),onReplayed:c},g)}const af="Learned workflow";function Dz({v2:e,agentId:n,name:s,choices:r,onPick:o,promotions:i,serving:c,stopped:d,onReplayed:u}){var j;const[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(0);p.useEffect(()=>{let k=!0;return v(null),Promise.resolve().then(()=>e.learnedWorkflowRevisions(n,s,Pz)).then(E=>{k&&g(E)},E=>{k&&v(E??new Error("unknown"))}),()=>{k=!1}},[e,n,s,h]);const b=t.jsxs("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-4 py-3",children:[t.jsxs("h2",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"caps text-small font-semibold",children:af})," ",t.jsx("span",{className:"ml-1 break-all font-mono text-body font-semibold",children:s})]}),r.length>1&&t.jsx(Et,{small:!0,className:"w-56 max-w-full",label:"Learned workflow",value:s,onChange:o,options:r.map(k=>({value:k,label:k}))})]});return y&&!f?t.jsxs("section",{className:"border","aria-label":af,children:[b,t.jsx("div",{className:"p-4",children:t.jsx(os,{problem:Ar(y,"the learned workflow"),onRetry:()=>x(k=>k+1),className:""})})]}):f?t.jsxs("section",{className:"border","aria-label":af,children:[b,t.jsx(Fz,{data:f,promotions:i,serving:((j=c.find(k=>k.workflow===f.name))==null?void 0:j.digest)??null,stopped:d,replay:{v2:e,agentId:n,onStarted:u,onDecided:()=>{x(k=>k+1),u==null||u()}}})]}):t.jsxs("section",{className:"border","aria-label":af,"aria-busy":!0,children:[b,t.jsx("div",{className:"p-4",children:t.jsx(xn,{className:"h-48 w-full"})})]})}function Fz({data:e,stepMs:n=Iz,promotions:s=[],serving:r=null,stopped:o=null,replay:i}){const{steps:c,unreadable:d}=p.useMemo(()=>Mz(e.revisions),[e.revisions]),[u,f]=p.useState(Math.max(0,c.length-1)),[g,y]=p.useState(!1),v=p.useRef(u);v.current=u;const h=p.useRef(c);if(p.useEffect(()=>{var L;const $=h.current;h.current=c;const _=((L=$[v.current])==null?void 0:L.digest)??null,O=$===c||v.current>=$.length-1||_===null?-1:c.findIndex(P=>P.digest===_);f(O>=0?O:Math.max(0,c.length-1)),y(!1)},[c]),p.useEffect(()=>{if(!g)return;const $=setInterval(()=>f(_=>Math.min(_+1,c.length-1)),n);return()=>clearInterval($)},[g,c.length,n]),p.useEffect(()=>{g&&u>=c.length-1&&y(!1)},[g,u,c.length]),!e.revisions.length)return null;if(!c.length)return t.jsxs("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:["This workflow's revisions can't be read as a workflow",d?`: ${d} ${d===1?"revision":"revisions"} did not read`:"","."]});const x=c[Math.min(u,c.length-1)],b=c.length,j=$=>{y(!1),f(Math.max(0,Math.min(b-1,$)))},k=()=>{if(g)return y(!1);u>=b-1&&f(0),y(!0)},E=`Revision ${Math.min(u,b-1)+1} of ${b}, ${ft(x.at)}`,S=tb(s,e.name,x.digest),N=Jc(S,{serving:r,stopped:o});return t.jsxs("div",{className:"space-y-3 p-4",children:[b>1&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsxs(B,{size:"sm",onClick:k,"aria-label":g?"Pause the replay":"Play the replay","aria-pressed":g,children:[g?t.jsx(il,{"aria-hidden":!0}):t.jsx(Jo,{"aria-hidden":!0}),g?"Pause":"Play"]}),t.jsx(B,{size:"icon",onClick:()=>j(u-1),disabled:u<=0,"aria-label":"Previous revision",children:t.jsx(FT,{"aria-hidden":!0})}),t.jsx(B,{size:"icon",onClick:()=>j(u+1),disabled:u>=b-1,"aria-label":"Next revision",children:t.jsx(_s,{"aria-hidden":!0})}),t.jsx(F5,{min:1,max:b,value:u+1,onChange:$=>j($-1),label:"Revision",valueText:E,className:"basis-full sm:min-w-[10rem] sm:flex-1 sm:basis-0"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{children:b>1?`Revision ${u+1} of ${b}`:"One revision"})," · ",t.jsx("time",{dateTime:x.at,children:ft(x.at)})," · ",x.run?t.jsxs("a",{href:`#/runs/${encodeURIComponent(x.run)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",sa(x.run)]}):"a person"]}),t.jsx("p",{className:"mt-1 break-words text-lead",role:"status","data-testid":"replay-line",children:x.line}),x.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-body text-muted-foreground",children:x.reason}),t.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-body","data-testid":"standing",children:[t.jsx(Se,{tone:N.tone,children:N.text}),t.jsx("span",{className:"min-w-0 break-words text-muted-foreground",children:S?Pa(S):x.digest?"No check yet: a new revision is checked on the inputs of the agent's own runs before it serves.":"Its file did not read: no standing."})]}),i&&x.digest&&t.jsx(Oz,{v2:i.v2,agentId:i.agentId,workflow:e.name,digest:x.digest,offered:Tz(N),resume:(S==null?void 0:S.decided)==="replaying"?S.replay_id??null:null,onStarted:i.onStarted,onDecided:i.onDecided},x.digest)]}),t.jsx("div",{className:"flex min-h-[280px] overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] p-4",children:t.jsx(Td,{graph:x.graph,marks:x.marks,label:`The workflow at revision ${u+1} of ${b}, as a graph`,minScale:.5,maxScale:1.6,className:"m-auto"})}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Rd,{}),t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:"NEW"})," first appears in this revision · ",t.jsx("span",{className:"font-semibold text-foreground",children:"EDITED"})," its prompt, code, inputs or tier changed"]})]}),(e.total>e.revisions.length||e.truncated||d>0)&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[e.total>e.revisions.length&&`The latest ${e.revisions.length} of ${e.total} revisions. `,e.truncated&&"Older changes are past the log this server keeps. ",d>0&&`${d} ${d===1?"revision":"revisions"} could not be read as a workflow and ${d===1?"is":"are"} left out.`]})]})}const h0=8,Uz={promote:"success",hold:"warning",revision:"active"};function p0({loop:e,promotions:n,serving:s=[],cost:r=null}){const[o,i]=p.useState(!1),c=[...((e==null?void 0:e.compiles)??[]).map(u=>({at:u.at,key:`c:${u.run_id}:${u.round}`,kind:"compile",compile:u})),...n.map((u,f)=>({at:u.at,key:`p:${f}`,kind:"promotion",record:u}))].sort((u,f)=>Date.parse(f.at)-Date.parse(u.at));if(!c.length)return null;const d=o?c:c.slice(0,h0);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(Hz,{compile:u.compile,promotions:n,serving:((f=s.find(g=>g.workflow===u.compile.workflow))==null?void 0:f.digest)??null,stopped:u.compile.workflow?nb(r,u.compile.workflow):null}):t.jsx(Bz,{record:u.record})},u.key)})}),c.length>h0&&t.jsx("div",{className:"flex justify-center border-t px-4 py-2",children:t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>i(u=>!u),children:o?"Show fewer":`Show all ${c.length}`})})]})}const Wz=({id:e})=>t.jsxs("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",sa(e)]}),wC=({at:e,run:n})=>t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[t.jsx("time",{dateTime:e,children:ft(e)}),n?t.jsxs(t.Fragment,{children:[" · ",t.jsx(Wz,{id:n})]}):null]});function Hz({compile:e,promotions:n,serving:s,stopped:r}){const o=e.digest===null||e.workflow===null,i=e.attempts.filter(u=>!u.ok),c=[...e.attempts.flatMap((u,f)=>u.ok?[]:u.errors.map(g=>({e:g,attempt:f+1}))),...e.draft_errors.map(u=>({e:u,attempt:null}))],d=o?null:Jc(tb(n,e.workflow,e.digest),{serving:s,stopped:r});return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?t.jsx(Se,{tone:"error",children:"Draft failed"}):t.jsx(Se,{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(Se,{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`:"",o?": it tries again on a later run.":"."]}),e.withheld?t.jsx("p",{className:"mt-1 text-small text-warning-text",role:"note",children:"The checks' words are withheld here: this run's handed values can't be read to cut them."}):c.length>0&&t.jsx("ul",{className:"mt-1 space-y-0.5","aria-label":"What the checks said","data-testid":"draft-errors",children:c.map(({e:u,attempt:f},g)=>t.jsxs("li",{className:"break-words font-mono text-small text-destructive-text",children:[f?`Attempt ${f}: `:"",u]},g))}),t.jsx(wC,{at:e.at,run:e.run_id})]})}function Bz({record:e}){var o;const n=eC(e),s=Jc(e,{serving:e.digest}),r=n==="promote"?s.tone:Uz[n];return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(Se,{tone:r,children:[eb[n]," · ",Fc[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:Pa(e)}),(o=e.check)!=null&&o.n?e.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-small text-muted-foreground",children:e.reason}):null,t.jsx(wC,{at:e.at})]})}const Gz={done:{icon:wl,word:"Done",ink:"text-success-text",edge:"border-t-success"},now:{icon:WT,word:"Next",ink:"text-run-active",edge:"border-t-run-active"},later:{icon:BT,word:"Later",ink:"text-muted-foreground",edge:"border-t-border"},warn:{icon:Ks,word:"Look",ink:"text-warning-text",edge:"border-t-warning"},watch:{icon:vm,word:"Watch",ink:"text-foreground",edge:"border-t-border-strong"}};function g0({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=Gz[n.state],o=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(o,{className:"size-3.5","aria-hidden":!0}),t.jsx("span",{className:"caps",children:r.word})]})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-lead font-semibold","data-testid":`stage-${n.key}-value`,children:n.value}),t.jsx("p",{className:"mt-0.5 break-words text-small text-muted-foreground",children:n.detail})]},n.key)})})}):null}function jC({id:e,checked:n,onChange:s,busy:r,disabled:o,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(vd,{checked:n,onChange:s,busy:r,disabled:o,labelledBy:e})]}),c==="off"&&t.jsx("p",{className:"font-mono text-label text-warning-text",children:"This server has learning turned off, so no run learns until it's on."}),d]})}function qz({fields:e,onFields:n,saved:s,server:r,error:o,warning:i}){const c=e.learning??s,d=gl(c),u=typeof s=="object"?s:!0,f=y=>y==="notes"?"notes":gl(y)?"full":void 0,g=y=>n({learning:y===!1&&s===void 0?void 0:y});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(jC,{id:"learning-switch",className:"border px-4 py-3",checked:d,server:r,onChange:y=>g(y?s==="notes"?"notes":u:!1)}),d&&t.jsx("fieldset",{"aria-label":"What it learns",className:"mt-2 space-y-2",children:[["full","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(([y,v,h])=>t.jsxs("label",{className:ae("flex items-start gap-3 border px-3 py-2.5",f(c)===y&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"learning-kind",className:"mt-1 accent-primary",checked:f(c)===y,onChange:()=>g(y==="full"?u:"notes")}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:v}),t.jsx("span",{className:"block text-small text-muted-foreground",children:h})]})]},y))}),o&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:o}),i&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:i})]})}const Kz="Not read: its front matter can't be read; fix the file to use it",Vz={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned",superseded:"Replaced"},kC=(e,n)=>`${Vz[e]} by ${n==="person"?"you":"a run"}`,jx=e=>e.readme??e.file,Og="Can't tell which version this is: reload.",Xm="It changed since you opened it.",Yz=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.",Qz=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.`,Jz="Making an agent from it takes your password sign-in in the console.",Xz="Restoring takes your password sign-in in the console.",NC=["feedback","project","reference","user"],Zz={user:"About you",feedback:"How to work",project:"About the work",reference:"Where to look"},SC=e=>Zz[e]??e,eD={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"},tD=["seeded","reflecting","proposed"],Zm=e=>!!e&&tD.includes(e.state),Ad=e=>Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&typeof n.file=="string"&&typeof n.name=="string"):[],CC=e=>Ad(e==null?void 0:e.given),EC=e=>Ad(e==null?void 0:e.read),ed=e=>(e==null?void 0:e.state)==="merged"?Ad(e.learned):[],ub=e=>Ad(e==null?void 0:e.pending),$C=e=>Ad(e),x0=e=>(e==null?void 0:e.state)==="merged"?$C(e.skills):[],v0=e=>(e==null?void 0:e.state)==="merged"?$C(e.workflows):[],nD=e=>ub(e).length>0,Jf=(e,n)=>`${e} ${n}${e===1?"":"s"}`,_C=e=>e.status==="pending",Xf=e=>{var n;return((n=e==null?void 0:e.learning)==null?void 0:n.pending)??0},fb=e=>`${e} learned ${e===1?"item waits":"items wait"} for your OK`;function sD(e){const n=e&&typeof e=="object"?e.learning:void 0;return n&&typeof n=="object"&&n.approve===!0?"yes":"password"}const TC="Approving needs your password sign-in. Until then it stays out of every run.",rD="It changes what this agent trusts or skips, so it waits for you.",oD="Runs that use bash on the host run as you. For untrusted tasks, use the sandbox.",RC="[redacted]",AC=e=>e===1?"1 note waits for your OK":e>1?`${e} notes wait for your OK`:"A note waits for your OK",sl=e=>`${e} ${e===1?"note":"notes"}`,Qa=e=>`${e} ${e===1?"run":"runs"}`,aD={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"},Zf=e=>aD[e??""]??"stopped",iD={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 mb(e){return e.detail&&e.detail.trim()?e.detail.trim():iD[e.reason??""]??"Not kept: learning stopped."}const lD=e=>e==="seeded"?"Learns after the run":"Looking back",em=e=>pl(Math.round(e)*1e3),Ia=e=>ro({usd:e,basis:"estimate",charge_state:null,cap_usd:null}),b0=(e,n)=>e>0?Math.round((n-e)/e*100):null,OC=e=>typeof e.before.median_cost_usd=="number"&&typeof e.after.median_cost_usd=="number",LC=e=>e.after.median_learning_usd;function cD(e){const n=[`answers in ${em(e.after.median_duration_s)} instead of ${em(e.before.median_duration_s)}`];OC(e)&&n.push(`${Ia(e.after.median_cost_usd)} instead of ${Ia(e.before.median_cost_usd)} a run`);const s=LC(e);return s!==null&&n.push(`learning itself ${Ia(s)} a run`),`Since it learned (${MC(e)}): ${n.join(" · ")}`}function MC(e){return`medians of ${Qa(e.after.runs)} started from what it learned`}const dD=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)},uD=/^---\n([\s\S]*?)\n?^---$\n?/m,kx=e=>/^"[^"]*"$|^'[^']*'$/.test(e)?e.slice(1,-1):e;function tm(e){const n=e.replace(/\r\n/g,`
|
|
634
|
-
`),s=n.startsWith(`---
|
|
635
|
-
`)?uD.exec(n):null;if(!s||s.index!==0)return{name:"",description:"",type:"project",body:n,rest:[]};const r={},o=[];for(const c of s[1].split(`
|
|
636
|
-
`)){const d=/^(name|description|type):(?:\s+(.*))?$/.exec(c);d&&!(d[1]in r)?r[d[1]]=kx((d[2]??"").trim()):c.trim()&&o.push(c)}const i=NC.includes(r.type??"")?r.type:"project";return{name:r.name??"",description:r.description??"",type:i,body:n.slice(s[0].length),rest:o}}const y0=e=>{const n=e.replace(/\s*\n\s*/g," ").trim();return/^["'].*["']$/.test(n)?n.includes('"')?`'${n}'`:`"${n}"`:n},fD=e=>`---
|
|
637
|
-
name: ${y0(e.name)}
|
|
638
|
-
description: ${y0(e.description)}
|
|
639
|
-
type: ${e.type}
|
|
640
|
-
${e.rest.map(n=>`${n}
|
|
641
|
-
`).join("")}---
|
|
642
|
-
${e.body.replace(/^\n*/,`
|
|
643
|
-
`)}`;function mD(e){const n=tm(e).rest.find(r=>/^supersedes:/.test(r)),s=n?kx(n.replace(/^supersedes:\s*/,"").trim()).trim():"";return s?(/^\[.*\]$/.test(s)?s.slice(1,-1).split(","):[s]).map(r=>kx(r.trim())).filter(Boolean):[]}const td=e=>tm(e).body.replace(/^\n+/,"");function w0(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 o=2;n.includes(r);o++)r=`${s}-${o}.md`;return r}const eh=(e,n=[])=>{const s=n.filter(o=>o!==RC),r=new URLSearchParams(s.map(o=>["note",o]));return`#/agents/${encodeURIComponent(e)}/learning${s.length?`?${r}`:""}`};function PC(e){return e.kind===Yr?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===Yr?{...e,kind:Yr,agent_label:null}:e}const Yr="learning",hD={seeded:0,reflecting:1,proposed:2,merged:3,dropped:3},Nx=e=>e?hD[e.state]??0:-1,pD=e=>{const n=e==null?void 0:e.learning;return n&&typeof n=="object"&&typeof n.state=="string"?n:void 0},j0=e=>e.charAt(0).toLowerCase()+e.slice(1);function gD(e){var s,r;if(!e||Nx(e)<2)return"Looking back on this run…";if(e.state==="proposed")return`Looking back: ${j0(((s=e.detail)==null?void 0:s.trim())||"Checking its new notes…")}`;const n=o=>o.map(i=>i.name.replace(/\s+/g," ").trim()).join(", ");if(e.state==="merged"){const o=ed(e),i=ub(e),c=[...o.length?[`kept ${sl(o.length)} (${n(o)})`]:[],...i.length?[`${j0(AC(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 Zf(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${mb(e)}`}function xD(e){var i;const n=PC(e),s=n.summary??"",r=v2(n)?`${s} (failed)`:s,o=(i=g2(n))==null?void 0:i.trimEnd();return o&&o.trim()!==s.trim()?`${r}
|
|
644
|
-
${o.replace(/^(?=.)/gm," ")}`:r}function vD(e,n){const s=e.filter(u=>u.agent_label===Yr&&u.kind!==Yr);if(!s.length)return e.map(PC);const r=e.findLast(u=>u.kind===Yr),o=pD(r),i=Nx(o)>Nx(n??void 0)?o:n&&{...n,detail:n.detail??(o==null?void 0:o.detail)??(r==null?void 0:r.summary)??null},c=s[0],d={id:c.id,seq:c.seq,timestamp:c.timestamp,created_at:c.created_at,kind:Yr,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:gD(i??void 0),text:[...s,...r?[r]:[]].map(xD).join(`
|
|
645
|
-
`)};return e.flatMap(u=>u===c?[d]:u.agent_label===Yr||u.kind===Yr?[]:[u])}const bD={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},k0=["Added","Replaced","Retired","Removed","Changed"];function yD(e){const n=[],s=[];let r=0;for(const o of e.split(`
|
|
646
|
-
`)){const i=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(o);i?((r||Number(i[1])>1)&&n.push({text:"…",mark:"gap"}),(r||Number(i[2])>1)&&s.push({text:"…",mark:"gap"}),r++):r&&o.startsWith(" ")?(n.push({text:o.slice(1),mark:"same"}),s.push({text:o.slice(1),mark:"same"})):r&&o.startsWith("-")?n.push({text:o.slice(1),mark:"removed"}):r&&o.startsWith("+")&&s.push({text:o.slice(1),mark:"added"})}return{before:n,after:s}}function wD(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:yD(d.patch)])),o=new Map([...CC(n),...EC(n),...ed(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(g=>g.mark!=="gap"&&/^name:\s*\S/.test(g.text));return o.get(d)??(f==null?void 0:f.text.replace(/^name:\s*/,"").trim())??d.replace(/\.md$/,"")};return s.map(d=>{var h,x;const u=r.get(d.path),f=i(d.path),g=((u==null?void 0:u.after)??[]).filter(b=>b.mark==="added").map(b=>b.text.trim()),y=((h=g.find(b=>b.startsWith("superseded_by:")))==null?void 0:h.replace(/^superseded_by:\s*/,""))??((x=ed(n).find(b=>{var j;return(j=b.supersedes)==null?void 0:j.includes(d.path)}))==null?void 0:x.file),v=d.status==="added"?`Added: ${f}`:d.status==="deleted"?`Removed: ${f}`:g.includes("status: superseded")||!u&&y?`Replaced: ${f}${y?` → ${i(y)}`:""}`:g.includes("status: retired")?`Retired: ${f}`:`Changed: ${f}`;return u?{file:d.path,said:v,before:d.status==="added"?null:u.before,after:d.status==="deleted"?null:u.after}:{file:d.path,said:v,before:null,after:null,withheld:bD[d.withheld??""]??"Not shown."}}).sort((d,u)=>k0.indexOf(d.said.split(":")[0])-k0.indexOf(u.said.split(":")[0]))}function jD(e){const n=new Map;for(const s of e)for(const r of s.files){const o=n.get(r)??{};"run"in s.by&&(o.run={id:s.by.run,at:s.at,reason:s.reason}),n.set(r,o)}return n}function Od(){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 Js(e=Od){let n=null;return{keyFor(s,r){const o=JSON.stringify([s,r]);return(n==null?void 0:n.request)!==o&&(n={request:o,key:e()}),n.key},done(){n=null}}}async function IC(e,n,s,r){const o=await r(n,s,e.keyFor(n,{content:s}));return e.done(),o}function kD(e=Od){const n=new Map;return s=>{let r=n.get(s);return r||(r=Js(e),n.set(s,r)),r}}function Sx(e,n){const s=new Set(e.map(r=>r.run_id));return[...e,...n.filter(r=>!s.has(r.run_id))]}const ri=(e,n,s)=>({...Ar(e,n),title:s}),ND=(e,n)=>{const s=e.get(n);return s!=null&&s.title?En(s):`run ${sa(n)}`},zC="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",SD=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),N0=20,CD=15e3;function Er(e,n=!1){const[s,r]=p.useState(n),o=p.useRef(Symbol("learning interaction")).current;return p.useEffect(()=>()=>{e.items.delete(o),e.changed(e.items.size>0)},[e,o]),[s,c=>{c?e.items.add(o):e.items.delete(o),e.changed(e.items.size>0),r(c)}]}function ED(e){return t.jsx($D,{...e},e.agent.agent_id)}function $D({agent:e,v2:n,focus:s=[],server:r,onAgent:o,places:i,onChanged:c}){var pe;const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState([]),[h,x]=p.useState([]),[b,j]=p.useState([]),[k,E]=p.useState(null),[S,N]=p.useState(null),[$,_]=p.useState({items:[],cursor:null,pages:0}),[O,L]=p.useState({items:[],cursor:null,pages:0}),[P,R]=p.useState(!1),A=p.useMemo(()=>({items:new Set,changed:R}),[]),[M,F]=Er(A),[I,q]=p.useState(0),[W,K]=p.useState(0),U=p.useRef(0),H=p.useRef(!1),G=p.useRef(!0),z=p.useRef(!1),[V,se]=p.useState(!1),J=p.useRef(()=>!1);J.current=()=>!M&&!A.items.size&&!H.current&&$.pages===0;const re=(he,He=!0)=>{const Je=he==="background";if(!G.current||Je&&(z.current||!J.current()))return Promise.resolve();const X=++U.current;He&&K(Ae=>Ae+1),z.current=!0,se(!0),H.current=!1,g(null);const ge=()=>G.current&&X===U.current&&(he==="write"||!A.items.size)&&(!Je||J.current()),_e=n.agentLearning(e.agent_id).then(Ae=>{ge()&&(u(Ae),_({items:[],cursor:Ae.notes.next_cursor,pages:0}),L({items:[],cursor:Ae.log.next_cursor,pages:0}))},Ae=>{ge()&&g(Ae??new Error("unknown"))});return n.listAgentRuns(e.agent_id,50,null,!!e.archived_at).then(Ae=>{ge()&&v(Ae.runs)},()=>{}),Promise.resolve().then(()=>n.learningPromotions(e.agent_id)).then(Ae=>{ge()&&(x(Ae.promotions),j(Ae.serving))},()=>{}),Promise.resolve().then(()=>n.learningLoop(e.agent_id)).then(Ae=>{ge()&&E(Ae)},()=>{}),_e.finally(()=>{X===U.current&&(z.current=!1,se(!1))})},ne=()=>re("manual"),me=p.useRef(()=>{});me.current=()=>{document.hidden||re("background")},p.useEffect(()=>{G.current=!0,re("manual",!1);const he=()=>me.current();window.addEventListener("focus",he),document.addEventListener("visibilitychange",he);const He=window.setInterval(he,CD);return()=>{G.current=!1,U.current++,window.removeEventListener("focus",he),document.removeEventListener("visibilitychange",he),window.clearInterval(He)}},[n,e.agent_id,e.archived_at]);const ve=()=>(c==null||c(),re("write")),je=()=>{if(!$.cursor||H.current)return;const he=U.current;H.current=!0,n.learningNotes(e.agent_id,$.cursor).then(He=>{he===U.current&&(H.current=!1,_(Je=>({items:[...Je.items,...He.items.filter(X=>!Je.items.some(ge=>ge.file===X.file))],cursor:He.next_cursor,pages:Je.pages+1})))},He=>{he===U.current&&(H.current=!1,_(Je=>({...Je,error:He??new Error("unknown")})))})},Ve=gl(e.definition.learning),de=!!e.archived_at,Oe=p.useMemo(()=>[...(d==null?void 0:d.notes.items)??[],...$.items],[d,$.items]),ze=Oe.filter(he=>he.status==="active"),De=Oe.filter(_C),Ne=(d==null?void 0:d.skills)??[],Q=(d==null?void 0:d.workflows)??[],[be,nt]=p.useState(void 0),Le=De.length>0||[...Ne,...Q].some(he=>he.status==="pending")||Q.some(he=>he.status==="active");p.useEffect(()=>{if(!Le||be!==void 0)return;let he=!0;return Promise.resolve().then(()=>n.capabilities()).then(He=>{he&&nt(sD(He))},()=>{he&&nt("password")}),()=>{he=!1}},[Le]);const Ye=Oe.filter(he=>he.status==="superseded"||he.status==="retired"),ht=p.useMemo(()=>{const he=new Map(Oe.map(Je=>[Je.file,Je])),He=new Map;for(const Je of Oe){if(Je.status==="superseded")continue;const ge=[...new Set([...mD(Je.text),...Oe.filter(_e=>_e.status==="superseded"&&_e.superseded_by===Je.file).map(_e=>_e.file)])].flatMap(_e=>{const Ae=he.get(_e);return Ae?Ae.status==="superseded"&&Ae.superseded_by===Je.file?[{file:_e,name:Ae.name}]:[]:[{file:_e,name:null}]});ge.length&&He.set(Je.file,ge)}return He},[Oe]),ie=p.useMemo(()=>new Map(y.map(he=>[he.run_id,he])),[y]),Ce=p.useMemo(()=>jD([...(d==null?void 0:d.log.items)??[],...O.items]),[d,O.items]),tt=s.filter(he=>!Oe.some(He=>He.file===he)).length>0;p.useEffect(()=>{d&&tt&&$.cursor&&$.error===void 0&&$.pages<N0&&je()},[d,tt,$.cursor,$.pages]);const Ie=Oe.some(he=>!Ce.has(he.file));p.useEffect(()=>{if(!d||!Ie||!O.cursor||O.pages>=N0)return;const he=U.current;n.learningLog(e.agent_id,O.cursor).then(He=>{he===U.current&&L(Je=>({items:[...Je.items,...He.items],cursor:He.next_cursor,pages:Je.pages+1}))},()=>{he===U.current&&L(He=>({...He,cursor:null}))})},[d,Ie,O.cursor]);const at=y.filter(he=>he.learning&&(he.learning.state==="merged"||he.learning.state==="dropped")).length,St=e.definition.native?"native":ns(e.definition)?"sdk":"hosted",st=eI({notes:ze.length,compiledNotes:Oe.filter(he=>he.status!=="retired"&&nC(he.text)!==null).length,runs:(k==null?void 0:k.completed_runs)??0,workflows:Q,cost:S,promotions:h,serving:b,loop:k,mode:e.definition.learning==="notes"?"notes":"full",execution:St,compileAfter:KP(e.definition.learning)}),ut=he=>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:P||V,onClick:()=>{!A.items.size&&!z.current&&ne()},children:t.jsx(Xo,{className:ae(V&&"animate-spin"),"aria-hidden":!0})})}),he]});if(f&&!d)return ut(t.jsx(os,{problem:Ar(f,"what this agent learned"),onRetry:ne,className:""}));if(!d)return ut(t.jsx(TD,{}));const Dt=f?t.jsx(_D,{error:f,onRetry:ne}):null,Ft=he=>t.jsx(AD,{agent:e,v2:n,onAgent:o,server:r,disabled:de,quiet:he}),Rt=Ve&&!de&&(St==="hosted"?t.jsx(SI,{v2:n,agentId:e.agent_id,onFinished:()=>{q(he=>he+1),ne()}}):t.jsxs(bt,{tone:"info",children:[St==="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:dn(e.agent_id,"runs"),className:"underline underline-offset-2",children:"Open the agent’s Run controls"}),"."]}));return!Oe.length&&!Ne.length&&!Q.length&&!M?ut(t.jsxs("div",{className:"space-y-6",children:[Dt,t.jsx(MD,{on:Ve,lookedBack:at,switchRow:Ft(!0),onAdd:de?void 0:()=>F(!0)}),Ve&&t.jsx(g0,{stages:st}),t.jsx(r0,{v2:n,agentId:e.agent_id,quiet:!0}),Rt,t.jsx(Vk,{v2:n,agentId:e.agent_id,on:Ve,quiet:!0,promotions:h,onCost:N,reads:W,execution:St},I),t.jsx(t0,{v2:n,agentId:e.agent_id,cost:S,serving:b}),t.jsx(p0,{loop:k,promotions:h,serving:b,cost:S}),t.jsx(C0,{runs:y})]})):ut(t.jsxs("div",{className:"space-y-6",children:[De.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:De.length})]}),t.jsx("p",{className:"px-4 pt-3 text-body text-muted-foreground",children:rD}),((pe=K2(e,i))==null?void 0:pe.place.mode)==="runner"&&(e.definition.tools??[]).includes("bash")&&t.jsx("p",{className:"px-4 pt-1 text-body text-muted-foreground",children:oD}),t.jsx("ul",{className:"space-y-3 p-4",children:De.map(he=>t.jsx("li",{children:t.jsx(S0,{note:he,v2:n,agentId:e.agent_id,readOnly:de,focused:s.includes(he.file),from:Ce.get(he.file),runs:ie,onChanged:ve,refreshHolds:A,approves:be,replaces:ht.get(he.file)})},he.file))})]}),t.jsx(g0,{stages:st}),t.jsx(r0,{v2:n,agentId:e.agent_id}),dD(d.impact)&&t.jsx(RD,{impact:d.impact}),Rt,t.jsx(Vk,{v2:n,agentId:e.agent_id,on:Ve,promotions:h,onCost:N,reads:W,execution:St},I),t.jsx(t0,{v2:n,agentId:e.agent_id,cost:S,serving:b}),t.jsx(zz,{v2:n,agentId:e.agent_id,workflows:Q,promotions:h,serving:b,cost:S,onReplayed:()=>{ne()}}),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:ze.length?`${sl(ze.length)} in use. Every later run reads ${ze.length===1?"it":"them"} before it starts.`:[...Ne,...Q].some(he=>he.status==="active")?"No note is in use.":"No note is in use: the next run starts with nothing learned."})]}),!de&&!M&&t.jsxs(B,{size:"sm",onClick:()=>F(!0),children:[t.jsx(jl,{"aria-hidden":!0})," Add a note"]})]}),Dt,!Ve&&t.jsx(LD,{server:r}),M&&t.jsx(HC,{title:"New note",v2:n,agentId:e.agent_id,taken:Oe.map(he=>he.file),onDone:he=>{F(!1),he&&ve()}},"new"),t.jsx("ul",{className:"space-y-3",children:ze.map(he=>t.jsx("li",{children:t.jsx(S0,{note:he,v2:n,agentId:e.agent_id,readOnly:de,focused:s.includes(he.file),from:Ce.get(he.file),runs:ie,onChanged:ve,refreshHolds:A,replaces:ht.get(he.file)})},he.file))}),$.error!==void 0&&t.jsx(os,{problem:Ar($.error,"more notes"),onRetry:je,className:""}),$.cursor&&t.jsx("div",{className:"flex justify-center",children:t.jsx(B,{size:"sm",onClick:je,children:"Load more notes"})}),Ye.length>0&&t.jsx(FD,{notes:Ye,all:Oe,from:Ce,focus:s,runs:ie,v2:n,agentId:e.agent_id,readOnly:de,onChanged:ve,refreshHolds:A})]}),["skill","workflow"].map(he=>{const He=he==="skill"?Ne:Q;if(!He.length)return null;const Je=he==="skill"?"Skills it learned":"Workflows it learned",X=He.filter(_e=>_e.status!=="retired"),ge=He.filter(_e=>_e.status==="retired");return t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":Je,children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:Je}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:X.length?he==="skill"?`${Jf(X.length,"skill")}: how to do a job it does again, given to every later run once active.`:`${Jf(X.length,"workflow")}: a job it does again, as steps a later run can call.`:`No ${he} is in use: the next run gets none.`})]}),X.length>0&&t.jsx("ul",{className:"space-y-3",children:X.map(_e=>t.jsx("li",{children:t.jsx(PD,{item:_e,kind:he,v2:n,agentId:e.agent_id,readOnly:de,runs:ie,approves:be,onChanged:ve,refreshHolds:A})},_e.file))}),ge.length>0&&t.jsx(UD,{kind:he,items:ge,v2:n,agentId:e.agent_id,runs:ie,readOnly:de,onChanged:ve,refreshHolds:A})]},he)})]}),t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[t.jsx(DC,{title:"Learning",children:Ft(!1)}),t.jsx(p0,{loop:k,promotions:h,serving:b,cost:S}),t.jsx(C0,{runs:y}),t.jsx(HD,{index:d.index,skills:Ne.filter(he=>he.status==="active").map(he=>he.name),off:!Ve||r==="off"})]})]})]}))}function _D({error:e,onRetry:n}){const s=Ar(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 DC({title:e,children:n,label:s}){return t.jsxs("section",{className:"border","aria-label":s??e,children:[t.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:e}),n]})}function TD(){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 RD({impact:e}){const{before:n,after:s}=e,r=[{label:"Answers in",now:em(s.median_duration_s),was:em(n.median_duration_s),delta:b0(n.median_duration_s,s.median_duration_s)},...OC(e)?[{label:"A run costs",now:Ia(s.median_cost_usd),was:Ia(n.median_cost_usd),delta:b0(n.median_cost_usd,s.median_cost_usd)}]:[]],o=LC(e),i=[`Medians of ${Qa(n.runs)} before it first learned and ${Qa(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":cD(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.jsx("span",{className:"font-mono text-label text-muted-foreground",title:i,children:MC(e)})]}),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)),o!==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:[Ia(o)," a run"]})]})]})]})})}function AD(e){return e.agent.definition.native?t.jsx("div",{className:"p-4",children:t.jsx(Y2,{agent:e.agent,v2:e.v2,learning:e.server,onAgent:e.onAgent})}):t.jsx(OD,{...e})}function OD({agent:e,v2:n,onAgent:s,server:r,disabled:o,quiet:i}){const[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,y]=p.useState(null),v=async h=>{d(!0),f(null),y(h);try{const{agent:x,etag:b}=await n.getAgent(e.agent_id),j=Nd(x,{learning:h},h?"Learning on":"Learning off");if(j.unchanged)s==null||s(x);else{const{unchanged:k,...E}=j;s==null||s((await n.updateDefinition(e.agent_id,E,b)).agent)}}catch(x){f(x??new Error("unknown"))}y(null),d(!1)};return t.jsx(jC,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:i,checked:g??gl(e.definition.learning),onChange:h=>void v(h),busy:c,disabled:o,server:r,problem:u?t.jsx(os,{problem:ri(u,"the agent","Learning was not changed."),className:"mt-2"}):null})}function LD({server:e}){return t.jsxs(bt,{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 MD({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(sv,{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:[Qa(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(jl,{"aria-hidden":!0})," Or write a note yourself"]})})]})}function S0({note:e,v2:n,agentId:s,readOnly:r,focused:o,from:i,runs:c,onChanged:d,approves:u,refreshHolds:f,replaces:g=[]}){const[y,v]=p.useState(!1),[h,x]=Er(f),[b,j]=Er(f),[k,E]=p.useState(o),[S,N]=p.useState(null),[$,_]=Er(f),[O,L]=p.useState(null),P=p.useRef(null),R=_C(e),A=async()=>{const q=W=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:W});_(!0),L(null);try{await n.approveNote(s,e.file,e.etag)}catch(W){_(!1),L(W instanceof Ue&&Vm(W).kind==="conflict"?q(`${Xm} Reload the tab to see the newest version.`):t.jsx(os,{problem:ri(W,"the note","The note was not approved."),className:""}));return}await d(),_(!1)};if(p.useEffect(()=>{var W,K;if(!o)return;E(!0),(K=(W=P.current)==null?void 0:W.scrollIntoView)==null||K.call(W,{block:"center",behavior:"smooth"});const q=setTimeout(()=>E(!1),2600);return()=>clearTimeout(q)},[o]),p.useEffect(()=>{if(!S)return;const q=setTimeout(()=>N(null),2400);return()=>clearTimeout(q)},[S]),h)return t.jsx(HC,{title:"Edit note",v2:n,agentId:s,file:e.file,seen:e,onDone:q=>{x(!1),q&&(N("Saved"),d())}});const M=td(e.text),F=Cx(e.last_change),I=nC(e.text);return t.jsxs("article",{ref:P,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(Se,{children:SC(e.type)}),e.origin==="you"&&t.jsx(Se,{tone:"muted",children:"From you"}),I&&t.jsxs(Se,{tone:"success",label:!0,title:`This note went into the learned workflow ${I}`,children:["Compiled into ",I]}),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}),R&&u==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:TC})]}),!r&&!b&&t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[R?u==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void A(),disabled:$,"aria-label":`Approve ${e.name}`,children:$?"Approving":"Approve"}):t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>x(!0),"aria-label":`Edit ${e.name}`,children:[t.jsx(tv,{"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}),M.trim()&&t.jsx(nh,{text:M}),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(th,{run:i.run.id,runs:c,at:i.run.at,reason:i.run.reason}),F&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(rv,{className:"size-3","aria-hidden":!0}),F]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Rf,{className:"size-3","aria-hidden":!0}),"Given to ",Qa(e.runs.given)]}),e.runs.read>0&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Rf,{className:"size-3","aria-hidden":!0}),"Read in ",Qa(e.runs.read)]}),g.length>0&&t.jsxs("button",{type:"button",onClick:()=>v(q=>!q),"aria-expanded":y,className:"flex items-center gap-1.5 hover:text-foreground",children:[t.jsx(XT,{className:"size-3","aria-hidden":!0}),"Replaces ",g.length," older ",g.length===1?"note":"notes",t.jsx(Mr,{className:ae("size-3 transition-transform",y&&"rotate-180"),"aria-hidden":!0})]})]}),y&&g.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:g.map(q=>t.jsx("li",{className:ae("break-words",q.name===null&&"font-mono text-small"),children:q.name??q.file},q.file))}),b&&t.jsx(UC,{name:e.name,kind:"note",retire:()=>n.retireNote(s,e.file,e.etag),onDone:async q=>{q&&await d(),j(!1)}})]})}function PD({item:e,kind:n,v2:s,agentId:r,readOnly:o,runs:i,approves:c,onChanged:d,refreshHolds:u}){const[f,g]=Er(u),[y,v]=p.useState(null),[h,x]=p.useState(null),[b,j]=p.useState(null),[k,E]=Er(u),[S,N]=Er(u),[$,_]=p.useState(null),O=e.status==="pending",[L,P]=Er(u),R=p.useRef(Js()).current,[A,M]=p.useState(null),F=n==="workflow"&&e.status==="active"&&c==="yes",I=async()=>{j(null),v(null),x(null);try{const H=await s.readNote(r,e.file);v(H.note),x(H.etag)}catch(H){j(H??new Error("unknown"))}},q=async()=>{if(f)return g(!1);g(!0),y===null&&await I()};p.useEffect(()=>{y===null&&h===null||(f?I():(v(null),x(null)))},[e.etag]);const W=n==="skill"&&f&&h?h:e.etag,K=async()=>{E(!0),_(null);try{await s.approveNote(r,jx(e),W)}catch(H){E(!1),_(H instanceof Ue&&Vm(H).kind==="conflict"?t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${Xm} Reload the tab to see the newest version.`}):t.jsx(os,{problem:ri(H,`the ${n}`,`The ${n} was not approved.`),className:""}));return}await d(),E(!1)},U=`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(Se,{tone:"warning",children:[t.jsx(Zx,{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:TC})]}),t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[!o&&!S&&!L&&t.jsxs(t.Fragment,{children:[O&&c==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void K(),disabled:k,"aria-label":`Approve ${e.name}`,children:k?"Approving":"Approve"}),F&&t.jsx(B,{size:"sm",onClick:()=>{M(null),P(!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 q(),"aria-expanded":f,"aria-label":`${f?"Hide":"Show"} ${U}`,children:[t.jsx(Mr,{className:ae("transition-transform",f&&"rotate-180"),"aria-hidden":!0}),f?"Hide":"Show"]})]})]}),$&&t.jsx("div",{className:"px-5 pt-3",children:$}),A&&t.jsxs("p",{className:"px-5 pt-3 text-body",role:"status",children:["Made the agent ",t.jsx("a",{href:dn(A.agent_id),className:"font-mono underline underline-offset-2",children:A.definition.name}),". Open it to run it."]}),f&&(b!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(os,{problem:Ar(b,U),onRetry:()=>void I(),className:""})}):y===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${U}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):n==="skill"?t.jsx(nh,{text:td(y)}):t.jsx(ID,{name:e.name,text:y})),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(th,{run:e.run,runs:i}),Cx(e.last_change)&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(rv,{className:"size-3","aria-hidden":!0}),Cx(e.last_change)]}),t.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),S&&t.jsx(UC,{name:e.name,kind:n,retire:()=>s.retireNote(r,jx(e),W),onDone:async H=>{H&&await d(),N(!1)}}),L&&t.jsx(DD,{name:e.name,keys:R,promote:H=>s.promoteWorkflow(r,e.name,H),onDone:H=>{P(!1),H&&M(H)}})]})}function ID({name:e,text:n}){const{doc:s,graph:r}=p.useMemo(()=>{try{const c=JSON.parse(n);return{doc:c,graph:ml(c)}}catch{return{doc:null,graph:null}}},[n]),o=p.useMemo(()=>r?{meta:jd(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(Td,{graph:r,marks:o,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),t.jsx(Rd,{}),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 Cx(e){return e&&e.kind!=="learned"?`${kC(e.kind,e.by)} · ${ft(e.at)}`:null}function FC(e){return(e==null?void 0:e.by)==="host"?Kz:e?`${kC("retired",e.by)} · ${ft(e.at)}`:"Retired"}function th({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(sv,{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:ND(n,e),children:sa(e)}),s&&t.jsxs("span",{className:"shrink-0",children:["· ",ft(s)]})]})}function nh({text:e}){const[n,s]=p.useState(!1),r=e.split(`
|
|
647
|
-
`).length>8||e.length>520,o=p.useMemo(()=>oo(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:zC,dangerouslySetInnerHTML:{__html:o}}),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(Mr,{className:ae("size-3.5 transition-transform",n&&"rotate-180"),"aria-hidden":!0}),n?"Show less":"Show all"]})]})}const zD={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 UC({name:e,kind:n,retire:s,onDone:r}){const[o,i]=p.useState(!1),[c,d]=p.useState(null),u=p.useRef(null);p.useEffect(()=>{var y;(y=u.current)==null||y.focus()},[]);const f=y=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:y}),g=async()=>{i(!0),d(null);try{await s()}catch(y){i(!1),d(y instanceof Ue&&Vm(y).kind==="conflict"?f(`${Xm} Reload the tab to see the newest version.`):t.jsx(os,{problem:ri(y,`the ${n}`,`The ${n} was not retired.`),className:""}));return}await r(!0)};return t.jsxs("div",{role:"alertdialog","aria-label":`Retire ${e}?`,onKeyDown:y=>{y.key==="Escape"&&(y.stopPropagation(),r(!1))},className:"flex flex-wrap items-center gap-3 border-t border-destructive/40 bg-destructive/5 px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Retire it?"})," ",zD[n]]}),c&&t.jsx("div",{className:"w-full",children:c}),t.jsx(B,{ref:u,size:"sm",variant:"destructive",onClick:()=>void g(),disabled:o,children:o?"Retiring":"Yes, retire"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>void r(!1),disabled:o,children:"Keep"})]})}function DD({name:e,keys:n,promote:s,onDone:r}){const[o,i]=p.useState(!1),[c,d]=p.useState(null),u=p.useRef(null);p.useEffect(()=>{var g;(g=u.current)==null||g.focus()},[]);const f=async()=>{var y;i(!0),d(null);let g;try{g=await s(n.keyFor("promote",e))}catch(v){return i(!1),v instanceof Ue&&v.status<500&&n.done(),v instanceof Ue&&v.status===403?void d(t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:Jz})):v instanceof Ue&&((y=v.problems)!=null&&y.length)?void d(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["No agent was made: ",v.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:v.problems.map((h,x)=>t.jsx("li",{children:h.detail},x))})]})):void d(t.jsx(os,{problem:ri(v,"the agent","No agent was made."),className:""}))}n.done(),r(g)};return t.jsxs("div",{role:"alertdialog","aria-label":`Make ${e} an agent?`,onKeyDown:g=>{g.key==="Escape"&&(g.stopPropagation(),o||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?"})," ",Qz(e)]}),c&&t.jsx("div",{className:"w-full",children:c}),t.jsx(B,{ref:u,size:"sm",variant:"solid",onClick:()=>void f(),disabled:o,children:o?"Making the agent":"Yes, make the agent"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>r(null),disabled:o,children:"Cancel"})]})}function WC({name:e,kind:n,from:s,restore:r,onChanged:o,onDone:i}){const[c,d]=p.useState(!1),[u,f]=p.useState(null),g=p.useRef(null);p.useEffect(()=>{var h;(h=g.current)==null||h.focus()},[]);const y=h=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:h}),v=async()=>{var h;d(!0),f(null);try{await r()}catch(x){if(d(!1),x instanceof Ue&&(x.status===412||x.code==="precondition_failed")){f(y(Xm)),await o();return}if(x instanceof Ue&&x.status===403)return void f(y(Xz));if(x instanceof Ue&&((h=x.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: ",x.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:x.problems.map((b,j)=>t.jsx("li",{children:b.detail},j))})]}));if(x instanceof Ue&&x.status===400){await o(),i();return}return void f(t.jsx(os,{problem:ri(x,`the ${n}`,`The ${n} was not restored.`),className:""}))}await o(),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?"})," ",Yz(s)]}),u&&t.jsx("div",{className:"w-full",children:u}),t.jsx(B,{ref:g,size:"sm",variant:"solid",onClick:()=>void v(),disabled:c,children:c?"Restoring":"Yes, restore"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:i,disabled:c,children:"Keep"})]})}function HC({title:e,v2:n,agentId:s,file:r,seen:o,taken:i=[],onDone:c}){const[d,u]=p.useState(o?tm(o.text):{name:"",description:"",type:"feedback",body:`
|
|
648
|
-
`,rest:[]}),[f,g]=p.useState((o==null?void 0:o.etag)??null),[y,v]=p.useState(null),[h,x]=p.useState(!1),[b,j]=p.useState([]),[k,E]=p.useState(null),[S,N]=p.useState(!1),[$,_]=p.useState(null),O=p.useRef(null),L=async()=>{if(r)try{const F=await n.readNote(s,r);u(tm(F.note)),g(F.etag),v(null)}catch(F){v(F??new Error("unknown"))}};p.useEffect(()=>{var F;(F=O.current)==null||F.focus()},[]);const P=F=>u(I=>({...I,...F})),R=d.name.trim()!==""&&d.description.trim()!==""&&!h,A=async()=>{if(!R)return;if(E(null),j([]),N(!1),r&&!f){E(Og);return}x(!0);const F=fD(d);try{await n.writeNote(s,r??w0(d.name,i),F,r?{etag:f??""}:{create:!0}),c(!0)}catch(I){x(!1);const q=I instanceof Ue?Vm(I,!r):null;(q==null?void 0:q.kind)==="conflict"?(_(F),await L()):(q==null?void 0:q.kind)==="refused"?j(q.problems):(q==null?void 0:q.kind)==="taken"?N(!0):E(I??new Error("unknown"))}},M=F=>{F.key==="Escape"?(F.preventDefault(),F.stopPropagation(),c(!1)):F.key==="Enter"&&(F.metaKey||F.ctrlKey||F.target.tagName==="INPUT")&&(F.preventDefault(),A())};return t.jsxs("section",{className:"border border-border-strong bg-card","aria-label":e,onKeyDown:M,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:[SD?"⌘":"Ctrl","+Enter"]})," save · ",t.jsx("kbd",{children:"Esc"})," cancel"]})]}),y!==null&&t.jsx(os,{problem:Ar(y,"the note"),onRetry:()=>{v(null),L()},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(Ks,{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(Pe,{ref:O,value:d.name,onChange:F=>P({name:F.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(Pe,{value:d.description,onChange:F=>P({description:F.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:NC.map(F=>t.jsxs("label",{className:ae("caps cursor-pointer border px-3 py-1.5 text-label",d.type===F?"border-foreground":"text-muted-foreground hover:text-foreground"),title:F,children:[t.jsx("input",{type:"radio",name:`type-${r??"new"}`,className:"sr-only",checked:d.type===F,onChange:()=>P({type:F})}),SC(F)]},F))}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:eD[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(nn,{value:d.body.replace(/^\n/,""),onChange:F=>P({body:`
|
|
649
|
-
${F.target.value}`}),rows:7,placeholder:"What to do, and why. Markdown.",className:"resize-y leading-[1.65]"})]}),b.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:b.map((F,I)=>t.jsx("li",{children:F.detail},I))})]}),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===Og?t.jsxs("p",{className:"text-body text-destructive-text",role:"alert",children:["Not saved: ",Og]}):k!==null&&t.jsx(os,{problem:ri(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 A(),disabled:!R,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:w0(d.name,i)})]})]})]})}function FD({notes:e,all:n,from:s,focus:r,runs:o,v2:i,agentId:c,readOnly:d,onChanged:u,refreshHolds:f}){const[g,y]=Er(f,null),[v,h]=p.useState(e.some(N=>r.includes(N.file))),[x,b]=p.useState(new Set),j=N=>b($=>{const _=new Set($);return _.has(N)?_.delete(N):_.add(N),_}),k=e.some(N=>r.includes(N.file));p.useEffect(()=>{k&&h(!0)},[k]);const E=N=>{var $;return(($=n.find(_=>_.file===N))==null?void 0:$.name)??N},S=N=>{var _;const $=document.getElementById(`note-${N}`);(_=$==null?void 0:$.scrollIntoView)==null||_.call($,{block:"center",behavior:"smooth"}),$==null||$.focus({preventScroll:!0})};return t.jsx(BC,{title:"Earlier notes",count:`${e.length} no longer read`,open:v,onToggle:()=>h(N=>!N),children:e.map(N=>{var L,P;const $=N.status==="retired",_=$&&x.has(N.file),O=(L=s.get(N.file))==null?void 0:L.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(Se,{tone:"muted",children:$?"Retired":"Replaced"}),$&&t.jsx(GC,{open:_,label:`the note ${N.name}`,onClick:()=>j(N.file)}),$&&!d&&N.etag&&g!==N.file&&t.jsxs(B,{size:"sm",onClick:()=>y(N.file),"aria-label":`Restore ${N.name}`,children:[t.jsx(VN,{"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:E(N.superseded_by)})]}):$?FC(N.retired):null}),g===N.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(WC,{name:N.name,kind:"note",from:(P=N.retired)==null?void 0:P.from,restore:()=>i.restoreNote(c,N.file,N.etag),onChanged:u,onDone:()=>y(null)})}),_&&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}),td(N.text).trim()&&t.jsx(nh,{text:td(N.text)}),O&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(th,{run:O.id,runs:o,at:O.at,reason:O.reason})})]})]},N.file)})})}function BC({title:e,count:n,open:s,onToggle:r,children:o}){return t.jsxs("section",{className:"border","aria-label":e,children:[t.jsxs("button",{type:"button","aria-expanded":s,onClick:r,className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[t.jsx(Mr,{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:o})]})}function UD({kind:e,items:n,v2:s,agentId:r,runs:o,readOnly:i,onChanged:c,refreshHolds:d}){const[u,f]=p.useState(!1),[g,y]=Er(d,null),[v,h]=p.useState(new Set),x=b=>h(j=>{const k=new Set(j);return k.has(b)?k.delete(b):k.add(b),k});return t.jsx(BC,{title:e==="skill"?"Earlier skills":"Earlier workflows",count:`${n.length} no longer given`,open:u,onToggle:()=>f(b=>!b),children:n.map(b=>{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:b.name}),t.jsx(Se,{tone:"muted",children:"Retired"}),t.jsx(GC,{open:v.has(b.file),label:`the ${e} ${b.name}`,onClick:()=>x(b.file)}),!i&&g!==b.file&&t.jsxs(B,{size:"sm",onClick:()=>y(b.file),"aria-label":`Restore ${b.name}`,children:[t.jsx(VN,{"aria-hidden":!0})," Restore"]})]}),b.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:b.description}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:FC(b.retired)}),g===b.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(WC,{name:b.name,kind:e,from:(j=b.retired)==null?void 0:j.from,restore:()=>s.restoreNote(r,jx(b),b.etag),onChanged:c,onDone:()=>y(null)})}),v.has(b.file)&&t.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[t.jsx(WD,{v2:s,agentId:r,file:b.file,etag:b.etag,kind:e,label:`the ${e} ${b.name}`}),b.run&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(th,{run:b.run,runs:o})})]})]},b.file)})})}function GC({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(Mr,{className:ae("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function WD({v2:e,agentId:n,file:s,etag:r,kind:o,label:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),g=p.useRef(0),y=async()=>{const v=++g.current;f(null),d(null);try{const h=await e.readNote(n,s);v===g.current&&d(h.note)}catch(h){v===g.current&&f(h??new Error("unknown"))}};return p.useEffect(()=>{y()},[s,r]),u!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(os,{problem:Ar(u,i),onRetry:()=>void y(),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"})}):o==="skill"?t.jsx(nh,{text:td(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 C0({runs:e}){const n=e.filter(o=>{var i;return((i=o.learning)==null?void 0:i.state)==="dropped"}),s=n.filter(o=>Zf(o.learning.reason)!=="nothing").slice(0,6),r=n.length-n.filter(o=>Zf(o.learning.reason)!=="nothing").length;return n.length?t.jsxs(DC,{title:"Kept nothing",children:[s.length>0&&t.jsx("ul",{children:s.map(o=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(o.run_id)}`,className:"block px-4 py-3 hover:bg-accent",children:[t.jsx("span",{className:"block text-body",children:mb(o.learning)}),t.jsxs("span",{className:"mt-1 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 truncate",title:En(o),children:En(o)}),t.jsxs("span",{className:"shrink-0",children:["· ",ft(o.created_at)]})]})]})},o.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`:`${Qa(r)} had`," nothing new to remember."]})]}):null}function HD({index:e,skills:n,off:s}){const[r,o]=p.useState(!1),i=s?0:e.split(`
|
|
650
|
-
`).filter(f=>f.trim()).length,c=p.useMemo(()=>oo(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:()=>o(f=>!f),className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[t.jsx(Mr,{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?sl(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(zC,"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 hb({run:e,link:n=!1,className:s}){var y;const r=CC(e.learning),o=EC(e.learning),i=ed(e.learning),c=Zm(e.learning)&&e.learning.state!=="seeded",d=ub(e.learning),u=nD(e.learning),f=[...x0(e.learning),...v0(e.learning)],g=((y=e.learning)==null?void 0:y.state)==="dropped"&&Zf(e.learning.reason)!=="nothing"?mb(e.learning):null;return!r.length&&!o.length&&!i.length&&!c&&!u&&!f.length&&!g?null:t.jsxs("span",{className:ae("inline-flex flex-wrap items-center gap-2",s),"aria-label":"Learning",children:[r.length>0&&t.jsx(lf,{agentId:e.agent_id,refs:r,link:n,kind:"given"}),o.length>0&&t.jsx(lf,{agentId:e.agent_id,refs:o,link:n,kind:"read"}),i.length>0&&t.jsx(lf,{agentId:e.agent_id,refs:i,link:n,kind:"learned",replaces:i.reduce((v,h)=>{var x;return v+(((x=h.supersedes)==null?void 0:x.length)??0)},0)}),u&&t.jsx(lf,{agentId:e.agent_id,refs:d,link:n,kind:"pending"}),g&&t.jsx(BD,{agentId:e.agent_id,said:g,link:n}),["skill","workflow"].flatMap(v=>{const h=(v==="skill"?x0:v0)(e.learning);return[!1,!0].map(x=>{const b=h.filter(j=>j.pending===!0===x);return b.length?t.jsx(GD,{agentId:e.agent_id,refs:b,link:n,kind:v,pending:x},`${v}-${x}`):null})}),c&&t.jsxs(Se,{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"})]}),lD(e.learning.state)]})]})}function BD({agentId:e,said:n,link:s}){const r=t.jsxs(Se,{tone:"muted",className:ae(s&&"cursor-pointer"),children:[t.jsx(HT,{className:"size-3","aria-hidden":!0}),"Kept nothing"]});return s?t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[t.jsx("a",{href:eh(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 GD({agentId:e,refs:n,link:s,kind:r,pending:o}){const i=o?`${Jf(n.length,r)} ${n.length===1?"waits":"wait"} for your OK`:`Learned ${Jf(n.length,r)}`,c=`${i}: ${n.map(f=>f.name).join(", ")}`,d=o?Zx:r==="skill"?Af:ti,u=t.jsxs(Se,{tone:o?"warning":void 0,className:ae(!o&&"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:eh(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 lf({agentId:e,refs:n,link:s,kind:r,replaces:o=0}){const i=r==="pending"?AC(n.length):r==="given"?`Started with: ${sl(n.length)}`:r==="read"?`Read: ${sl(n.length)}`:`Learned ${sl(n.length)}`,c=n.map(h=>h.name).join(", "),d=r==="given"||r==="read",u=d?Rf:r==="pending"?Zx:sv,f=t.jsxs(Se,{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]}),g=n.filter(h=>h.file!==RC),y=`${i}${c?`: ${c}`:""}${o?` (replaces ${o===1?"1 older note":`${o} older notes`})`:""}`;if(!s||!g.length&&r!=="pending")return t.jsx("span",{title:y,"aria-label":y,className:"inline-flex",children:f});const v=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))}),o>0&&t.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["Replaces ",o===1?"1 older note":`${o} older notes`,"."]}),t.jsx("span",{className:"mt-1.5 block text-label text-muted-foreground",children:"Open in Learning"})]});return t.jsx(W5,{tip:v,children:t.jsx("a",{href:eh(e,g.map(h=>h.file)),"aria-label":y,className:"inline-flex",children:f})})}function qD({n:e,className:n}){return e<=0?null:t.jsx("span",{"aria-label":fb(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 KD=["pi","claude-agent","codex","opencode"];function VD(e){const n=new Set,s=r=>{if(Array.isArray(r)){r.forEach(s);return}if(!r||typeof r!="object")return;const o=r;o.node==="call"&&typeof o.tool=="string"&&n.add(o.tool),Object.values(o).forEach(s)};return s(e),[...n].sort()}function YD(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 QD(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 pb="Refused on this server for every agent, whatever the agent's own setting or Never ask.",JD="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.",qC=(e,n,s,r)=>{var d;const o=s==null?void 0:s.find(u=>u.name===e);if(o)return o.permission==="deny"&&o.permission_from==="server";const i=qo(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 XD(e){return(e??[]).map(({name:n,permission:s,default_permission:r,permissions:o,ask_needs:i})=>({name:n,permission:s,default_permission:r,permissions:o,...i==="password"?{ask_needs:i}:{}}))}const ZD={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},KC={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."}}},nm=(e,n)=>{var s;return(n&&((s=KC[n])==null?void 0:s.label[e]))??ZD[e]??e},eF={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."},E0=(e,n)=>{var s;return(n&&((s=KC[n])==null?void 0:s.help[e]))??eF[e]};function VC(e,n){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:nm(e,n),unavailable:!1}:{text:"not known",unavailable:!1}}function YC(e,n,s,r,o){const{[n]:i,...c}=e,{[s]:d,...u}=i??{},f=r===void 0||r===o?u:{...u,[s]:r};return Object.keys(f).length?{...c,[n]:f}:c}const tF=(e,n,s,r)=>YC(e,n,"provider",s,r),nF=(e,n,s,r)=>YC(e,n,"permission",s,r);function Ex(e,n){const s=new Map(n.map(r=>[r.name,r.default_provider]));return Object.fromEntries(Object.entries(e).flatMap(([r,o])=>{if(!o||typeof o!="object")return[];const{provider:i,...c}=o,d=i!==void 0&&!(s.has(r)&&i===s.get(r))?{...c,provider:i}:c;return Object.keys(d).length?[[r,d]]:[]}))}function QC(e,n,s){const r={},o=[];for(const[i,c]of Object.entries(e)){if(n&&i!==n&&!i.startsWith(`${n}.`)&&!i.startsWith(`${n}/`))continue;const d=n?i.slice(n.length+1):i,u=[...s].sort((f,g)=>g.length-f.length).find(f=>d===f||d.startsWith(`${f}.`)||d.startsWith(`${f}/`));u?(r[u]??(r[u]=[])).push(c):o.push(c)}return{byTool:r,rest:o}}const sF=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),rF=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))]},oF=e=>typeof e=="string"?e:JSON.stringify(e);function aF(e){return Object.keys(e).sort().map(n=>{const s=e[n];if(sF(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=rF(s),o=r[0]===null,i=(o?r.slice(1):r).map(d=>oF(d));if(!i.length)return`${n} must be left out`;const c=i.length===1?i[0]:`one of ${i.join(", ")}`;return`${n} must be ${o?`left out or ${c}`:c}`}).join("; ")}const iF="Calls outside it are refused before they run or ask.",lF="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.",cF=[{id:"runs",label:"Runs",shows:()=>!0,Body:hF},{id:"versions",label:"Versions",shows:()=>!0,Body:CM},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:pF},{id:"learning",label:"Learning",shows:(e,n)=>e.kind==="agentic"&&n.learning!==!1,Body:e=>t.jsx(ED,{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:XM}],dn=(e,n)=>`#/agents/${encodeURIComponent(e)}${n?`/${n}`:e==="new"||e==="connect"?"/runs":""}`;function dF({v2:e,agentId:n,routePrefix:s,harnesses:r,go:o,tab:i,learning:c,notes:d,places:u}){const[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(0),[b,j]=p.useState(void 0);p.useEffect(()=>{let M=!0;return g(null),v(null),j(void 0),$(!1),S.current=++k.current,e.getAgent(n).then(F=>{M&&g(F.agent)},F=>{M&&v({cause:F})}),e.statsOver({from:Dv(D2),agent:n}).then(F=>{M&&j(F)},()=>{M&&j(null)}),()=>{M=!1,S.current=++k.current}},[e,n,h]);const k=p.useRef(0),E=p.useRef(0),S=p.useRef(0),[N,$]=p.useState(!1),_=(M=!1,F=!M)=>{const I=++k.current;return F&&(S.current=I),e.getAgent(n).then(q=>(I>E.current&&I>=S.current&&(E.current=I,g(W=>W&&W.agent_id===q.agent.agent_id?q.agent:W),$(!1)),E.current>=I),()=>(I===k.current&&!M&&$(!0),E.current>=I))},O=M=>{g(F=>({...M,tools:(F==null?void 0:F.tools)??M.tools})),_()},L=()=>void _(),P=()=>void _(!0,!1),R=()=>_(!0,!0),A=b===void 0?void 0:b!==null;return y?y.cause instanceof Ue&&y.cause.status===404?t.jsx(j2,{what:"agent",id:n,list:{href:"#/agents",label:"Open the agents list"}}):t.jsx(Jt,{problem:Ht(y.cause,"the agent"),onRetry:()=>x(M=>M+1)}):f?t.jsx(uF,{agent:f,onAgent:O,onSignInsAgent:g,reread:_,onChanged:L,poll:P,afterForget:R,stale:N,v2:e,go:o,stats:b,analytics:A,places:u,routePrefix:s,harnesses:r,tab:i,learning:c,notes:d},f.agent_id):t.jsx(wM,{})}function uF({agent:e,onAgent:n,onSignInsAgent:s,reread:r,onChanged:o,poll:i,afterForget:c,stale:d,v2:u,go:f,stats:g,analytics:y,routePrefix:v,harnesses:h,tab:x,learning:b,notes:j,places:k}){var Oe,ze,De,Ne;const E=mF(e,u,r,()=>r(!1,!1)),[S,N]=p.useState(!1),$=gg(),_=gg(),O=gg(),L=p.useRef(null),[P,R]=p.useState({heading:!1,description:!1});p.useEffect(()=>{const Q=L.current,be=O.current;if(!Q||!be||typeof ResizeObserver>"u")return;const nt=Ye=>Ye.scrollHeight>Ye.clientHeight+1,fe=()=>R(Ye=>{const ht={heading:nt(Q),description:nt(be)};return ht.heading===Ye.heading&&ht.description===Ye.description?Ye:ht}),Le=new ResizeObserver(fe);for(const Ye of[Q,be]){Le.observe(Ye);for(const ht of Ye.children)Le.observe(ht)}return fe(),()=>Le.disconnect()},[O,e.definition.name,e.definition.description,e.definition.approvals]);const A=Xf(e),M=e.definition,F=ns(M),{native:I,refresh:q}=AP(e,u),W=e.kind==="workflow",K=W?ti:FN,U=mC(M.harness??"pi",h),H=M.model?xl(M.model,v):U?(({text:Q,title:be})=>({text:`${Q} (default)`,title:be}))(xl(U,v)):{text:nz},G=W||I||F||h==null?void 0:h.find(Q=>Q.id===(M.harness??"pi")&&Q.available===!1),z=G?`${G.id} doesn't run on this server${G.reason?`: ${G.reason}`:"."}`:void 0,V=K2(e,k),se=`${pP(V==null?void 0:V.place)}${V!=null&&V.byDefault?" (server default)":""}`,J=!F&&!I&&!W&&!G&&!M.model&&!U&&(h==null?void 0:h.some(Q=>Q.id===(M.harness??"pi")&&Q.default_model===null)),re=[...F?[["Runtime",Qo(F.runtime)],["Model","Reported per run"],["Execution","Your backend"]]:I?[["Runtime",I.runtime],["Model",I.model??"Native default"],["Selector",I.selector.kind==="project"?"Project default":I.selector.name??I.selector.kind],["Machine",I.machine_id]]:W?[]:[["Harness",M.harness??"pi"],["Model",H.text,H.title],["Thinking",M.thinking??"default"],["Runs",se]],["Revision",`rev ${M.version} of ${e.revisions}`]],ne=cF.filter(Q=>Q.shows(e,{analytics:y===!0,learning:b===void 0?x==="learning"?void 0:!1:!!b})),me=ne.find(Q=>Q.id===x)??ne[0],ve=x==="analytics"&&y===void 0,je=((Oe=E.runs)==null?void 0:Oe.filter(fF))??[],Ve=((ze=e.runs)==null?void 0:ze.live)??(E.runs?`${je.length}${E.cursor?"+":""}`:"—"),de=[["Status",e.archived_at?"Archived":I?Cd(I):"Active"],["Live jobs",String(Ve)],...re];return t.jsx(OP,{native:I,children:t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":"Agent detail",children:[t.jsxs("header",{className:ae(pr,"flex-wrap gap-2 px-5 lg:flex-nowrap"),"aria-label":"Agent toolbar",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>f(e.archived_at?"#/agents?archived=true":"#/agents"),children:t.jsx(On,{"aria-hidden":!0})}),t.jsx(K,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 truncate text-body font-semibold",children:M.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:()=>{E.refresh(),q()},disabled:E.reading,children:t.jsx(Xo,{className:ae(E.reading&&"animate-spin"),"aria-hidden":!0})}),!I&&!F&&t.jsx(B,{size:"sm",onClick:()=>f(dn(e.agent_id,"edit")),children:"Detailed editor"}),t.jsx(sn,{label:"Edit agent",prompt:Go(location.origin,e.agent_id,!!I,F==null?void 0:F.runtime),playgroundHref:I||F?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),!e.archived_at&&t.jsx(sn,{variant:"primary",label:"Run agent",disabled:!!I&&(!I.connected||I.state!=="ready"||!I.capabilities.launch),prompt:Bv(location.origin,e.agent_id,F==null?void 0:F.runtime),playgroundHref:F?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`})]})]}),t.jsxs("main",{className:"grid min-h-0 flex-1 grid-cols-1 items-start gap-6 overflow-auto p-5 lg:grid-cols-[minmax(260px,320px)_minmax(0,1fr)] lg:grid-rows-[minmax(0,1fr)] lg:items-stretch lg:overflow-hidden md:p-8",children:[t.jsxs("aside",{className:"min-w-0 space-y-6 lg:flex lg:min-h-0 lg:flex-col","aria-label":"Agent overview",children:[t.jsxs("div",{ref:L,"data-agent-heading":!0,...P.heading?{tabIndex:0,role:"region","aria-label":"Agent name and description"}:{},className:"lg:-mr-4 lg:flex lg:max-h-[50%] lg:shrink-0 lg:flex-col lg:overflow-y-auto lg:overflow-x-hidden lg:pr-4 lg:[scrollbar-width:none]",children:[t.jsx("h1",{className:"text-2xl font-semibold lg:shrink-0",children:M.name}),M.approvals==="never"&&t.jsx(Se,{tone:"warning",className:"mt-2 lg:shrink-0 lg:self-start",title:"Never ask: a call of this agent never waits for you. A tool set to deny, and a template’s pins, still hold.",children:"Unattended"}),t.jsx("div",{ref:O,"data-agent-description":!0,...P.description?{tabIndex:0,role:"region","aria-label":"Agent description"}:{},className:ae("scroll-quiet min-w-0 lg:-mr-4 lg:overflow-y-auto lg:overflow-x-hidden lg:pr-2.5",M.description?"lg:min-h-7":"lg:min-h-0"),children:M.description&&t.jsx("p",{id:"agent-description",className:ae("mt-2 break-words text-body leading-relaxed text-muted-foreground",!S&&"max-sm:line-clamp-2"),children:M.description})}),t.jsx("p",{className:"mt-3 break-all font-mono text-label text-muted-foreground lg:shrink-0",children:e.agent_id})]}),t.jsxs("div",{ref:$,"data-agent-details":!0,className:"scroll-quiet min-w-0 space-y-6 lg:-ml-1 lg:-mr-4 lg:min-h-0 lg:flex-1 lg:overflow-y-auto lg:overflow-x-hidden lg:pb-6 lg:pl-1 lg:pr-2.5",children:[t.jsxs("button",{type:"button","aria-expanded":S,"aria-controls":M.description?"agent-description agent-facts":"agent-facts",onClick:()=>N(Q=>!Q),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(_s,{className:ae("size-3.5 shrink-0 transition-transform",S&&"rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:de.map(([,Q])=>Q).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(([Q,be,nt])=>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:Q}),t.jsx("dd",{className:"break-words text-body font-semibold",title:nt,children:be})]},Q)),!W&&!I&&!F&&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:!W&&e.tools?e.tools.length?t.jsx("ul",{className:"space-y-2","aria-label":"Tools",children:e.tools.map(Q=>t.jsxs("li",{children:[t.jsx("span",{title:Q.blurb,children:Q.name}),Q.provider?` · ${nm(Q.provider,Q.name)}`:"",Q.permission?` · ${Q.permission}`:"",VC(Q.resolved,Q.name).unavailable&&t.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:Q.resolved,children:" · unavailable"})]},Q.name))}):"none":M.tools.join(", ")||"None configured"})]})]}),z&&t.jsx(bt,{tone:"warning","aria-label":"Harness not available",children:z}),!e.archived_at&&J&&t.jsxs(bt,{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(bt,{tone:"error",children:["Couldn't refresh this agent. ",t.jsx(B,{size:"sm",onClick:()=>void r(),children:"Retry"})]}),(De=e.warnings)!=null&&De.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((Q,be)=>t.jsxs("li",{children:[t.jsx("span",{className:"text-muted-foreground",children:Q.field})," ",Q.message]},`${Q.field}:${be}`))})]}):null,t.jsx(IP,{agent:e,v2:u,onAgent:s,poll:i,refresh:c}),I&&t.jsx(LP,{agent:e,v2:u,learning:b,onAgent:n,onChanged:async()=>{q(),await r()}}),!I&&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:F?"Managed by your backend":M.skills.join(", ")||"None configured"})]})]}),M.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:M.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"}),je.length?t.jsx("ul",{className:"space-y-3",children:je.map(Q=>t.jsx("li",{children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(Q.run_id)}`,className:"flex items-center gap-2 text-small hover:text-primary-text",children:[t.jsx(Al,{run:Q}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:En(Q)}),t.jsx(hr,{className:"size-3 shrink-0","aria-hidden":!0})]})},Q.run_id))}):t.jsx("p",{className:"text-small leading-relaxed text-muted-foreground",children:E.runs?(Ne=e.runs)!=null&&Ne.live?"Live jobs are outside the loaded history. Load more runs to find them.":E.error?"Live jobs could not be refreshed.":"No live jobs.":"Loading live jobs…"})]})]})]}),t.jsxs("section",{ref:_,className:"scroll-quiet min-w-0 lg:-ml-1 lg:-mr-4 lg:min-h-0 lg:overflow-y-auto lg:overflow-x-hidden lg:pb-6 lg:pl-1 lg:pr-2.5","aria-label":"Agent workspace",children:[t.jsx(VS,{id:"agent-views",label:"Agent views",value:me.id,onChange:Q=>f(dn(e.agent_id,Q)),tabs:ne.map(Q=>({id:Q.id,label:t.jsxs(t.Fragment,{children:[Q.label,Q.id==="learning"&&t.jsx(qD,{n:A,className:"ml-1.5"})]})})),className:"mb-5 overflow-x-auto px-0 md:px-0"}),t.jsx("div",{...U5("agent-views",me.id),"aria-label":ve?void 0:me.label,children:ve?t.jsx(Hn,{label:"Loading the tab",rows:4}):t.jsx(me.Body,{agent:e,v2:u,go:f,stats:g,history:E,focus:j,learning:b,onAgent:n,onChanged:o,places:k})})]})]})]})})}const fF=e=>!e.imported_from&&["queued","working","paused","input_required"].includes(e.status);function mF(e,n,s,r){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,y]=p.useState(!1),[v,h]=p.useState(null),[x,b]=p.useState(!1),j=p.useRef(0),k=p.useRef([]),E=p.useRef(0),S=p.useRef(!1),N=async($,_=!1,O=!1,L=!1)=>{if(S.current)return;S.current=!0;const P=++j.current;f(!0),y(!!$);const R=_?L?r():s():Promise.resolve();try{let A=$,M=[];const F=$||O?void 0:k.current.at(-1),I=F?Date.parse(F.created_at):NaN,q=E.current+1;let W=!1;const K=new Set;do{if(K.size>=q){b(!0),h({title:"Run history could not be refreshed.",why:"Previous runs are still shown. The run list changed too much to refresh them safely.",next:"Try again, or reload the latest runs to reset the loaded history."});return}if(K.has(A))throw new Error("The runs list repeated a page. Refresh to try again.");K.add(A);const U=await n.listAgentRuns(e.agent_id,50,A,!!e.archived_at);if(P!==j.current)return;M=Sx(M,U.runs),A=U.next_cursor,W||(W=U.runs.some(H=>H.run_id===(F==null?void 0:F.run_id)||Date.parse(H.created_at)<I))}while(!$&&A&&F&&!W);P===j.current&&(k.current=$?Sx(k.current,M):M,E.current=$?E.current+1:K.size,i(k.current),d(A),h(null),b(!1))}catch(A){P===j.current&&h(Ht(A,$?"more runs":"the runs"))}finally{await R,P===j.current&&(S.current=!1,f(!1),y(!1))}};return p.useEffect(()=>{S.current=!1,k.current=[],E.current=0,i(null),d(null),h(null),b(!1),N(null);const $=()=>{document.hidden||N(null,!0,!1,!0)};window.addEventListener("focus",$),document.addEventListener("visibilitychange",$);const _=window.setInterval($,1e4);return()=>{j.current++,S.current=!1,window.clearInterval(_),window.removeEventListener("focus",$),document.removeEventListener("visibilitychange",$)}},[n,e.agent_id,e.archived_at]),{runs:o,cursor:c,reading:u,more:g,error:v,refresh:()=>{N(null,!0)},loadMore:()=>{c&&N(c)},reloadLatest:x?()=>{N(null,!0,!0)}:null}}function hF({agent:e,history:n}){const[s,r]=p.useState(""),{runs:o,cursor:i,reading:c,more:d,error:u,refresh:f,loadMore:g,reloadLatest:y}=n;if(u&&!o)return t.jsx(Jt,{problem:u,onRetry:f,className:""});if(!o)return t.jsx(Hn,{label:"Loading the runs",rows:5});const v=o.filter(h=>`${En(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:ae(fl,"flex w-56 min-w-0 items-center gap-2 px-3"),children:[t.jsx(wm,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,type:"search","aria-label":"Search this agent's runs",value:s,onChange:h=>r(h.target.value),placeholder:"Search runs…",className:"h-control-md w-full"})]}),t.jsxs("span",{className:"text-small text-muted-foreground",children:[o.length,i?"+":""," ",o.length===1&&!i?"run":"runs"]}),t.jsx("div",{className:"ml-auto",children:t.jsx(sn,{label:"Query",prompt:`${Bm(location.origin,e.agent_id)}
|
|
651
|
-
Current view: all statuses; ${e.archived_at?"archived runs":"non-archived runs"}.`,playgroundHref:Iv(e.agent_id,{archived:!!e.archived_at})})})]}),o.length?t.jsxs("div",{className:"overflow-x-auto",children:[t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Runs",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Status","Run","Started","Duration","Cost"].map(h=>t.jsx("th",{className:"whitespace-nowrap px-4 py-3 font-semibold",children:h},h))})}),t.jsx("tbody",{children:v.map(h=>t.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-accent/50",children:[t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:t.jsx(Al,{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:En(h)}),t.jsx(hr,{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(hb,{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:ft(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:pl(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||_l(h.cost))?ro(h.cost,{ended:Va(h.status)}):"—"})]},h.run_id))})]}),!v.length&&t.jsx("p",{className:"p-10 text-center text-body text-muted-foreground",children:"No loaded runs match your search."})]}):t.jsxs("div",{className:"px-4 py-12 text-center text-body text-muted-foreground",children:[t.jsx("p",{children:"No runs of this agent yet."}),!e.archived_at&&t.jsx("p",{className:"mt-2",children:"Choose Run agent to continue with your coding agent or the API playground."})]}),u&&t.jsxs("div",{className:"m-4 space-y-3",children:[t.jsx(Jt,{problem:u,onRetry:f,className:""}),y&&t.jsx(B,{size:"sm",onClick:y,disabled:c,children:"Reload latest runs"})]}),i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",onClick:g,disabled:c,children:d?"Loading":"Load more"})})]})}function pF({agent:e}){const n=e.definition.workflow,s=p.useMemo(()=>ml(n),[n]),r=p.useMemo(()=>({meta:jd(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:[Jm(db(s))," · rev ",e.definition.version]}),t.jsx("span",{className:"flex-1"}),t.jsx(sn,{label:"Edit workflow",prompt:Go(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(Td,{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(Rd,{})})]})}function JC({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 gF=20,xF=100,vF=4,Di=(e,n)=>(e==null?void 0:e.filter(s=>s.status===n).length)??0,XC=e=>`#/agents/${encodeURIComponent(e.agent_id)}/learning`,$x=e=>e.toLocaleString("en-US"),ZC=[{label:"Active notes",of:e=>e.view?{value:Di(e.notes,"active"),exact:!!e.complete}:null},{label:"Learned skills",of:e=>{var n;return(n=e.view)!=null&&n.skills?{value:Di(e.view.skills,"active"),exact:!0}:null}},{label:"Workflow drafts",of:e=>{var n;return(n=e.view)!=null&&n.workflows?{value:Di(e.view.workflows,"active"),exact:!0}:null}},{label:"Pending review",of:e=>e.view?{value:Di(e.notes,"pending")+Di(e.view.skills,"pending")+Di(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 eE(e,n){if(!e.length)return"0";const s=e.map(n);return s.every(r=>r===null)?"—":`${$x(s.reduce((r,o)=>r+((o==null?void 0:o.value)??0),0))}${e.some(r=>r.stale)?" (last read)":s.every(r=>r==null?void 0:r.exact)?"":"+"}`}function bF({v2:e,server:n}){const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),g=p.useRef(0),y=p.useRef(!1),v=p.useCallback(async()=>{if(n!=="on"&&n!=="off"||y.current)return;y.current=!0;const k=++g.current;d(!0),i(null),r(S=>(S==null?void 0:S.map(N=>N.view?{...N,stale:!0}:N))??null);const E=()=>g.current===k;try{let S=null;const N=new Set,$=await Qr(async R=>{if(!E())throw new Error("Read superseded");if(R&&N.has(R))throw new Error("The agent list repeated a page. Refresh to try again.");R&&N.add(R);const A=await e.listAgents({cursor:R});return S=A.next_cursor,A},R=>R.agents,xF);if(!E())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 _=[...new Map($.map(R=>[R.agent_id,R])).values()].map(R=>({agent:R}));r(R=>{const A=new Map(R==null?void 0:R.map(M=>[M.agent.agent_id,M]));return _.map(({agent:M})=>{const F=A.get(M.agent_id);return M.kind==="agentic"&&(F==null?void 0:F.agent.kind)==="agentic"&&F.view?{...F,agent:M,stale:!0,error:void 0,unavailable:void 0}:{agent:M}})});const O=_.filter(R=>R.agent.kind==="agentic");let L=0;const P=async()=>{for(;E()&&L<O.length;){const{agent:R}=O[L++];let A;try{const M=await e.agentLearning(R.agent_id);if(!E())return;const F=new Map(M.notes.items.map(K=>[K.file,K]));let I=M.notes.next_cursor,q;const W=new Set;for(let K=0;I&&K<gF&&E();K++){if(W.has(I)){q="The note list repeated a page.";break}W.add(I);try{const U=await e.learningNotes(R.agent_id,I);U.items.forEach(H=>F.set(H.file,H)),I=U.next_cursor}catch(U){q=Ht(U,"more notes").why;break}}A={agent:R,view:M,notes:[...F.values()],complete:!I,...I?{noteIssue:q??"More note pages are available in the agent's Learning tab."}:{}}}catch(M){A={agent:R,error:Ht(M,"Learning"),unavailable:M instanceof Ue&&M.status===404}}if(!E())return;r(M=>(M==null?void 0:M.map(F=>F.agent.agent_id!==R.agent_id?F:A.error&&!A.unavailable&&F.view?{...F,...A,stale:!0}:A))??null)}};await Promise.all(Array.from({length:Math.min(vF,O.length)},P)),E()&&f(new Date().toISOString())}catch(S){E()&&i(Ht(S,"Learning Dojo"))}finally{E()&&(y.current=!1,d(!1))}},[e,n]);p.useEffect(()=>{r(null),f(null),i(null),v();const k=()=>{document.hidden||v()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{g.current++,y.current=!1,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[v]),p.useEffect(()=>{if(n!=="on"&&n!=="off")return;const k=window.setInterval(()=>{document.hidden||v()},15e3);return()=>window.clearInterval(k)},[n,v]);const h=(s==null?void 0:s.filter(k=>k.agent.kind==="agentic"))??[],x=h.filter(k=>k.view).length,b=h.some(k=>k.stale),j=h.flatMap(k=>{var E;return(((E=k.view)==null?void 0:E.log.items)??[]).map(S=>({agent:k.agent,change:S}))}).sort((k,E)=>E.change.at.localeCompare(k.change.at)).slice(0,8);return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:ae(pr,"gap-2 px-5"),children:[t.jsxs("h1",{className:Bo,children:[t.jsx(JC,{size:16,className:"shrink-0"}),"Learning Dojo"]}),t.jsx(B,{className:"ml-auto",size:"icon","aria-label":"Refresh Learning Dojo",disabled:c||!n,onClick:()=>void v(),children:t.jsx(Xo,{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."}),o&&t.jsxs(t.Fragment,{children:[t.jsx(Jt,{problem:o,onRetry:()=>void v(),className:""}),s&&t.jsx("p",{className:"text-small text-warning-text",children:"Showing the last read. Refresh to update these counts."})]}),!s&&!o?t.jsx(Hn,{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:ZC.map(({label:k,of:E})=>t.jsxs("div",{"aria-label":k,className:"border bg-card p-4",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:k}),t.jsx("dd",{className:"mt-3 font-mono text-display",children:eE(h,E)})]},k))}),t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:[x," of ",h.length," agent histories read. Counts show active items; pending notes, skills and drafts are counted under review. + means a minimum from incomplete data; — means not reported.",b?" Last-read totals include saved histories that may have changed; they are not current minimums.":u&&!c?` Updated ${ft(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(yF,{row:k,server:n},k.agent.agent_id))}):t.jsxs("div",{className:"border px-6 py-10 text-center",children:[t.jsx("h3",{className:"font-semibold",children:"No agents yet"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"Create an agent, then open its Learning tab to let its runs build on what they learn."}),t.jsx("a",{className:"mt-4 inline-block text-lead text-primary-text underline underline-offset-4",href:"#/agents/new",children:"Build an agent"}),t.jsx("span",{className:"mx-3 text-muted-foreground",children:"·"}),t.jsx("a",{className:"text-lead text-primary-text underline underline-offset-4",href:"#/agents",children:"Import existing agents"})]}),h.length>0&&t.jsxs("section",{className:"overflow-hidden border","aria-label":"Recent learning changes",children:[t.jsxs("header",{className:"border-b px-5 py-4",children:[t.jsx("h3",{className:"text-lead font-semibold",children:"Recent learning changes"}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"Latest reported changes from the histories read above. Each agent's Learning tab has its full history and run outcomes."})]}),j.length?t.jsx("ul",{className:"divide-y",children:j.map(({agent:k,change:E})=>t.jsx("li",{children:t.jsxs("a",{href:"run"in E.by?`#/runs/${encodeURIComponent(E.by.run)}`:XC(k),className:"flex items-start gap-3 px-5 py-4 hover:bg-accent",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block text-lead",children:E.reason||"Learning updated"}),t.jsxs("span",{className:"mt-1 block text-small text-muted-foreground",children:[k.definition.name||k.agent_id," · ","run"in E.by?"From a run":"Edited by you"," · ",ft(E.at)]})]}),t.jsx(hr,{className:"mt-1 size-3.5 shrink-0","aria-hidden":!0})]})},`${k.agent_id}:${E.commit}`))}):t.jsx("p",{className:"px-5 py-7 text-lead text-muted-foreground",children:c?"Loading learning changes…":x<h.length?"No changes in the histories available so far.":"No saved learning changes yet."})]})]})]})]})]})}function yF({row:e,server:n}){const{agent:s,view:r,error:o}=e,i=s.kind==="agentic",c=gl(s.definition.learning);return t.jsxs("article",{className:"flex min-w-0 flex-col border bg-card p-5",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words text-lead font-semibold",children:s.definition.name||s.agent_id}),t.jsx(Se,{tone:i&&c&&n==="on"?"success":"plain",children:i?n==="off"&&c?"Paused by server":c?"Learning on":"Learning off":"Workflow"})]}),i?t.jsxs(t.Fragment,{children:[o&&t.jsxs("div",{role:"alert",className:"mt-4 text-small text-destructive-text",children:[t.jsx("p",{children:e.unavailable?"Learning unavailable for this agent.":o.title}),t.jsxs("p",{className:"mt-1",children:[o.why," ",o.said]})]}),r?t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"mt-5 grid grid-cols-2 gap-x-4 gap-y-3",children:ZC.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:eE([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:[$x(r.counts.merged)," runs kept learning · ",$x(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."})]}):!o&&t.jsx("p",{role:"status",className:"mt-4 text-lead text-muted-foreground",children:"Loading learning…"})]}):t.jsx("p",{className:"mt-4 text-lead text-muted-foreground",children:"Workflow runs do not learn. Enable learning on an agentic agent."}),t.jsxs("a",{className:"mt-5 inline-flex items-center gap-2 self-start text-small font-semibold text-primary-text hover:underline hover:underline-offset-4",href:i?XC(s):dn(s.agent_id),children:[i?"Open learning":"View agent",t.jsx(hr,{className:"size-3.5","aria-hidden":!0})]})]})}const wF=140,jF=32,kF=40,NF=60;function gb({value:e,name:n,note:s,blurb:r,description:o,tag:i,why:c,alert:d,on:u,disabled:f,warn:g,onToggle:y}){const[v,h]=p.useState(!1),x=p.useRef(null),b=p.useRef(null),j=p.useRef(null),k=p.useRef(null),E=cf(x,"width",v,n),S=cf(b,"height",v,o),N=cf(j,"width",v,i),$=cf(k,"width",v,d),_=E??n.length>jF,O=!!o&&(S??o.length>wF),L=!!i&&(N??i.length>kF),P=!!d&&($??d.length>NF),R=!!c&&(c!==i||L),A=!!o&&(!!r||O)||R||P||_,M=(I,q)=>!v&&I&&q?I:void 0,F=I=>{I.preventDefault(),I.stopPropagation(),h(q=>!q)};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",v?"min-h-36":"h-36 overflow-hidden",u&&"border-foreground",g&&"border-warning/60",f?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("input",{type:"checkbox",value:e,checked:u,disabled:f,onChange:y,className:"shrink-0 accent-primary"}),t.jsx("span",{ref:x,title:M(n,_),className:ae("min-w-0",v?"[overflow-wrap:anywhere]":"truncate"),children:n}),s&&t.jsx("span",{className:"shrink-0 font-sans text-label text-muted-foreground",children:s})]}),r?t.jsx("span",{"data-line":!0,className:"mt-1 truncate font-sans text-small text-muted-foreground",children:r}):o&&!v?t.jsx("span",{ref:b,"data-line":!0,className:"mt-1 line-clamp-3 font-sans text-label text-muted-foreground [overflow-wrap:anywhere]",title:M(o,O),children:o}):null,i&&t.jsx("span",{ref:j,"data-tag":!0,title:M(c,R),className:"mt-1 max-w-full self-start truncate border px-1.5 text-micro text-muted-foreground",children:i}),d&&!v&&t.jsx("span",{ref:k,className:"mt-1 truncate font-sans text-label text-warning-text",role:"alert",title:M(d,P),children:d}),v&&t.jsxs("span",{"data-more":!0,className:"mt-2 min-w-0 space-y-1 font-sans text-label text-muted-foreground",children:[o&&t.jsx("span",{className:"block whitespace-pre-wrap [overflow-wrap:anywhere]",children:o}),c&&c!==o&&t.jsx("span",{className:"block [overflow-wrap:anywhere]",children:c}),d&&t.jsx("span",{className:"block text-warning-text [overflow-wrap:anywhere]",role:"alert",children:d})]}),A&&t.jsx("button",{type:"button",onClick:F,"aria-expanded":v,className:"mt-auto self-start pt-1 font-sans text-label underline underline-offset-2 hover:text-foreground",children:v?"Less":"More"})]})}function cf(e,n,s,r){const[o,i]=p.useState(null);return p.useLayoutEffect(()=>{const c=e.current;if(s||!c)return;const d=()=>{(n==="width"?c.clientWidth>0:c.clientHeight>0)&&i(n==="width"?c.scrollWidth>c.clientWidth+1:c.scrollHeight>c.clientHeight+1)};d();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return u==null||u.observe(c),()=>u==null?void 0:u.disconnect()},[e,n,s,r]),o}function SF({servers:e,tools:n,harness:s,harnesses:r,onChange:o,onRetry:i}){const c=h=>o(n.includes(h)?n.filter(x=>x!==h):[...n,h]),d=n.filter(h=>qo(h)),u=!r||r.includes(s),f=(h,x,b,j,k,E)=>{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(gb,{value:h,name:x,note:E,description:b,alert:$,on:S,disabled:N,warn:!!j,onToggle:()=>c(h)})},h)},g=h=>t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:h}),y=!u&&t.jsxs("p",{className:"text-small text-warning-text",children:[s," doesn't run MCP tools on this server",r!=null&&r.length?`: ${r.join(" and ")} do`:"","."]});if(e==="failed")return t.jsxs("div",{className:"mt-4 space-y-2",children:[t.jsxs("p",{className:"font-mono text-small text-warning-text",role:"alert",children:["The MCP servers could not be read."," ",i&&t.jsx(B,{type:"button",onClick:i,size:"xs",className:"ml-1",children:"Retry"})]}),d.length>0&&g(d.map(h=>f(h,h,"Can't check right now whether its server still lists it.")))]});if(!e)return d.length?t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:"Reading the MCP servers..."}):null;const v=II(n,e);return!e.length&&!v.length?t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"No MCP server is saved: add one in Settings → MCP servers to grant its tools."}):t.jsxs("div",{className:"mt-4 space-y-4",children:[y,e.map(h=>t.jsxs("section",{"aria-label":`MCP server ${h.name}`,children:[t.jsxs("p",{className:"caps mb-2 text-label font-semibold text-muted-foreground",children:[h.name," · MCP server"]}),g(h.tools.map(x=>{var b;return f(cC(h.name,x.name),x.name,[x.title,x.description].filter(Boolean).join(": ")||void 0,void 0,PI(x,s)??(x.permission==="deny"?pb:void 0),(b=h.not_metered)!=null&&b.includes(x.name)?"not metered":void 0)}))]},h.name)),v.length>0&&t.jsxs("section",{"aria-label":"MCP grants that can't run",children:[t.jsx("p",{className:"caps mb-2 text-label font-semibold text-warning-text",children:"Granted, but not on a saved server"}),g(v.map(h=>f(h.grant,h.grant,void 0,h.why)))]})]})}const CF="[a-z][a-z0-9-]{0,31}",tE="[A-Za-z0-9_-]{1,64}",EF="[a-z0-9][a-z0-9.-]{0,63}",$F="[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}",_F=`[a-z][a-z0-9_-]{0,63}(?:\\.${tE})?`,TF="mcp:",RF="monid:",$0="*",AF=new RegExp(`^mcp:(${CF})/(\\*|${tE})$`),OF=new RegExp(`^monid:(${EF})/(\\*|${$F})$`),LF=new RegExp(`^${_F}$`);function MF(e){if(vl(e)){const s=OF.exec(e);return s?s[2]===$0?{kind:"monid-provider",provider:s[1]}:{kind:"monid",provider:s[1],endpoint:s[2]}:void 0}if(!IF(e))return LF.test(e)?{kind:"plain",name:e}:void 0;const n=AF.exec(e);if(n)return n[2]===$0?{kind:"mcp-server",server:n[1]}:{kind:"mcp",server:n[1],tool:n[2]}}const vl=e=>e.startsWith(RF),PF=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.`,IF=e=>e.startsWith(TF);function nE(e){const n=MF(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 zF=e=>nE(e)?void 0:PF(e);function DF(e){const n=e.trim();return!n||vl(n)?n:`monid:${n}`}function sE(e){return new Map(e.flatMap((n,s)=>vl(n)?[[`definition.tools[${s}]`,n]]:[]))}function FF(e,n){const s=sE(n),r=[],o=[];for(const i of e){const c=s.get(i.field);c?r.push({grant:c,warning:i}):o.push(i)}return{monid:r,rest:o}}const UF=e=>{const n=nE(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 WF({tools:e,listed:n=[],notes:s=[],refused:r=[],onChange:o}){const[i,c]=p.useState(""),[d,u]=p.useState(void 0),f=[...new Set([...n,...e].filter(vl))],g=v=>o(e.includes(v)?e.filter(h=>h!==v):[...e,v]),y=()=>{const v=DF(i);if(!v)return;const h=zF(v);u(h),!h&&(c(""),e.includes(v)||o([...e,v]))};return t.jsxs("section",{"aria-label":"monid endpoints",className:"mt-4 space-y-2",children:[t.jsx("p",{className:"caps text-label font-semibold text-muted-foreground",children:"monid · paid endpoints"}),f.length>0&&t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:f.map(v=>{const h=r.filter(x=>x.grant===v);return t.jsx("li",{className:"min-w-0",children:t.jsx(gb,{value:v,name:v,description:UF(v),alert:h.length?"The save was refused here: see below.":void 0,warn:h.length>0,on:e.includes(v),disabled:!1,onToggle:()=>g(v)})},v)})}),t.jsxs("form",{className:"flex flex-wrap items-start gap-2",onSubmit:v=>{v.preventDefault(),y()},children:[t.jsx(Pe,{"aria-label":"monid grant",value:i,onChange:v=>{c(v.target.value),u(void 0)},"aria-invalid":d?!0:void 0,placeholder:"monid:<provider>/<endpoint> or monid:<provider>/*",className:"min-w-0 flex-[1_1_18rem]",spellCheck:!1,autoCapitalize:"off",autoComplete:"off"}),t.jsxs(B,{type:"submit",size:"sm",className:"h-control-md",disabled:!i.trim(),children:[t.jsx(jl,{"aria-hidden":!0})," Grant"]})]}),d&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:d}),t.jsx("p",{className:"text-small text-muted-foreground",children:"A grant is priced and pinned when the agent is saved, from what monid lists then. monid's key is set in Settings → Tool keys."}),r.length>0&&t.jsx("ul",{className:"space-y-1 font-mono text-small text-destructive-text",role:"alert","aria-label":"monid grants refused",children:r.map((v,h)=>t.jsx("li",{children:v.message},`${v.grant}:${h}`))}),s.length>0&&t.jsx("ul",{className:"space-y-1 font-mono text-small text-warning-text",role:"status","aria-label":"monid save warnings",children:s.map((v,h)=>t.jsx("li",{children:v.message},`${v.grant}:${h}`))})]})}const HF=e=>e.offered&&(e.kind==="none"||e.providers.some(n=>n.ready)),BF=e=>{var n;return e.why??((n=e.providers.find(s=>!s.ready))==null?void 0:n.why)};function GF(e,n){var o;if(e.kind==="none")return{kind:"none"};const r=((n==null?void 0:n.kind)===e.kind&&e.providers.some(i=>i.ready&&i.id===n.provider)?n.provider:void 0)??((o=e.providers.find(i=>i.ready))==null?void 0:o.id);return r?{kind:e.kind,provider:r}:{kind:e.kind}}const qF=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},xb="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",vb=new Set(["sandbox","desktop","phone"]),KF=e=>e.charAt(0).toUpperCase()+e.slice(1);function VF({kinds:e,value:n,onChange:s,error:r,warning:o}){const i=e.find(c=>c.kind===n.kind);return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Kind"}),t.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-5",role:"radiogroup","aria-label":"Kind",children:e.map(c=>{const d=HF(c),u=d?void 0:BF(c),f=c.providers.filter(g=>g.ready).map(g=>g.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(GF(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:KF(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&&vb.has(i.kind)&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:xb}),!c.ready&&c.why&&t.jsx("span",{className:"mt-0.5 block text-small",children:c.why})]})]})},c.id))})]}),i&&i.tools.length>0&&t.jsxs("p",{className:"mt-4 border bg-muted/40 px-4 py-2.5 text-small","aria-label":"Tools this computer adds",children:["This computer adds these tools: ",t.jsx("span",{className:"font-mono",children:i.tools.join(", ")})]}),r&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:r}),o&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:o})]})}function YF({value:e,saved:n,places:s,tools:r,picked:o,onChange:i,error:c,warning:d}){var N;const u=e??kd(n),f=(u??Kv(!1,o,s)).mode,g=(N=s.boxes.find($=>$.available))==null?void 0:N.id,y=(u==null?void 0:u.mode)==="sandbox"?u.box:g,v=!g&&f!=="sandbox",h=new Set(r.filter($=>$.sandbox_only).map($=>$.name)),[x,b]=p.useState([]),j=()=>{const $=o.filter(_=>h.has(_));b($),i({place:{mode:"runner"},...$.length?{tools:o.filter(_=>!h.has(_))}:{}})},k=$=>{b([]),$&&i({place:{mode:"sandbox",box:$}})},E=$=>$.map(_=>_.charAt(0).toUpperCase()+_.slice(1)).join(" and "),S=($,_,O,L,P=!1)=>t.jsxs("label",{className:ae("flex items-start gap-3 border px-4 py-3",f===$?"border-foreground":"border-border",P?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsx("input",{type:"radio",name:"place",value:$,checked:f===$,disabled:P,onChange:L,className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"block text-lead font-semibold",children:_}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:O})]})]});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Where it runs"}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"radiogroup","aria-label":"Where it runs",children:[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(y),v)]}),v&&t.jsxs("div",{className:"mt-3 border px-4 py-3 text-small text-muted-foreground",role:"status",children:[t.jsx("p",{children:"No box is set up on this server, so this agent runs on the server."}),t.jsx("ul",{className:"mt-1",children:s.boxes.map($=>t.jsxs("li",{children:[t.jsx("span",{className:"font-mono",children:$.id}),$.reason?`: ${$.reason}`:""]},$.id))})]}),f==="sandbox"&&t.jsx("ul",{className:"mt-3 border","aria-label":"Box",children:s.boxes.map($=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("label",{className: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:y===$.id,disabled:!$.available&&y!==$.id,onChange:()=>k($.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-mono text-body",children:$.id}),!$.available&&$.reason&&t.jsx("span",{className:"mt-0.5 block text-small",children:$.reason})]})]})},$.id))}),f==="runner"&&x.length>0&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:[E(x)," ",x.length===1?"runs":"run"," only in a sandbox, so ",x.length===1?"it's":"they're"," turned off for this agent."]}),c&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:d})]})}function rE(e,n,s=n.map(r=>r.name)){return[...new Set([...s.filter(o=>e.some(i=>i.name===o)||n.some(i=>i.name===o)),...n.map(o=>o.name),...e.map(o=>o.name)])].map(o=>{const i=e.find(d=>d.name===o),c=n.find(d=>d.name===o);return{name:o,...i?{choice:i}:{},...c?{gate:c}:{}}})}function _x({setting:e,label:n="Pinned",also:s=!1}){return e!=null&&e.pin_broken?t.jsx("p",{className:"max-w-[640px] text-small text-warning-text",role:"note",children:lF}):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,":"]})," ",aF(e.pin),". ",iF,s?" This server pins it too; both hold.":""]}):null}const _0={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."]},QF=({effect:e})=>t.jsx("span",{"data-effect":e,children:t.jsx(Se,{tone:_0[e][0],title:_0[e][1],children:e})}),JF="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function bb({label:e,rows:n,settings:s,fallbackOf:r,permissionFallbackOf:o=E=>E.default_permission,resolvesOf:i,issues:c,busy:d=!1,refused:u=()=>!1,locked:f=!1,unattended:g=!1,noteOf:y,labelOf:v,detailOf:h,effectOf:x,confirmAllowOf:b=()=>!1,fallbackWordOf:j,onEdit:k}){const[E,S]=p.useState(null),N=p.useRef(null),$=p.useRef(null);p.useEffect(()=>{var F,I;if(E!==null||d||N.current===null)return;const M=`${N.current} permission`;N.current=null,(I=[...((F=$.current)==null?void 0:F.querySelectorAll("button[aria-label]"))??[]].find(q=>q.getAttribute("aria-label")===M))==null||I.focus()},[E,d]);const _=M=>{N.current=M,S(null)},O=n.some(M=>M.choice),L=n.some(M=>M.gate),P=n.some(M=>{var F;return((F=M.gate)==null?void 0:F.ask_needs)==="password"}),R=["Tool",...L?["Permission"]:[],...O?["Provider","Resolves to"]:[]],A=t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"—"});return t.jsxs(t.Fragment,{children:[P&&t.jsx("p",{className:"mb-2 text-small text-warning-text",children:JF}),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:[R.map(M=>t.jsx("th",{className:"caps px-3 py-2 text-label font-semibold text-muted-foreground",children:M},M)),t.jsx("th",{children:t.jsx("span",{className:"sr-only",children:"Reset"})})]})}),t.jsx("tbody",{children:n.map(({name:M,choice:F,gate:I})=>{var de,Oe,ze;const q=F?r(F):"",W=(de=s[M])==null?void 0:de.provider,K=F!==void 0&&W!==void 0&&W!==q,U=K?W:q,H=De=>k(Ne=>tF(Ne,M,De,q)),G=I?o(I):"allow",z=(Oe=s[M])==null?void 0:Oe.permission,V=I!==void 0&&z!==void 0&&z!==G,se=V?z:G,J=I!==void 0&&u(M,se),re=J&&f,ne=re?"deny":se,me=De=>k(Ne=>nF(Ne,M,De,G)),ve=x==null?void 0:x(M),je=(j==null?void 0:j(M))??"default",Ve=h==null?void 0:h(M);return t.jsxs(p.Fragment,{children:[t.jsxs("tr",{"data-tool":M,"data-set":K||V?"":void 0,className:"border-b align-top last:border-b-0",children:[t.jsxs("td",{className:"px-3 py-2.5 font-mono text-body",children:[t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[(v==null?void 0:v(M))??M,ve&&t.jsx(QF,{effect:ve})]}),Ve?t.jsx("span",{"data-tool-detail":!0,className:"mt-0.5 block text-small text-muted-foreground",children:Ve}):null]}),L&&t.jsx("td",{className:"px-3 py-2",children:I?t.jsxs(t.Fragment,{children:[t.jsx(Et,{small:!0,label:`${M} permission`,value:ne,disabled:d||re,onChange:De=>{const Ne=De;Ne==="allow"&&Ne!==ne&&b(M)?S(M):me(Ne)},className:ae("w-48",V&&"border-primary text-primary"),options:I.permissions.map(De=>({value:De,label:`${De}${De===G?` (${je})`:""}`,...De==="ask"&&I.ask_needs==="password"&&!g?{disabled:!0,title:"No one can approve a call here: it takes the owner's password sign-in."}:{}}))}),V&&!re&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",G,je==="default"?"":` (${je})`]}),J&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:pb}),ne==="deny"&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:JD}),ne==="ask"&&g&&!J&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),ne==="ask"&&I.ask_needs==="password"&&!g&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Each call is refused: no one can approve it here."})]}):A}),O&&t.jsx("td",{className:"px-3 py-2",children:F?t.jsxs(t.Fragment,{children:[t.jsx(Et,{small:!0,label:`${M} provider`,value:U,disabled:d,onChange:De=>H(De),className:ae("w-96 max-w-full",K&&"border-primary text-primary"),options:F.providers.map(De=>({value:De,label:`${nm(De,M)}${De===q?" (default)":""}`}))}),E0(U,M)&&t.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:E0(U,M)}),K&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",nm(q,M)]})]}):A}),O&&t.jsx("td",{className:"px-3 py-2.5",children:F?i(F,U):A}),t.jsx("td",{className:"px-2 py-2 text-right",children:K&&t.jsx(B,{size:"sm",variant:"ghost",disabled:d,"aria-label":`Reset ${M} to its default`,onClick:()=>H(void 0),children:"Reset"})})]}),E===M&&t.jsx("tr",{children:t.jsx("td",{colSpan:R.length+1,className:"px-3 pb-2.5",children:t.jsx(XF,{name:M,keep:ne==="ask"?"Keep asking":"Cancel",busy:d,onAllow:()=>{d||(_(M),me("allow"))},onKeep:()=>_(M)})})}),y!=null&&y(M)?t.jsx("tr",{"data-note":M,children:t.jsx("td",{colSpan:R.length+1,className:"px-3 pb-2.5",children:y(M)})}):null,(ze=c[M])!=null&&ze.length?t.jsx("tr",{children:t.jsx("td",{colSpan:R.length+1,className:"px-3 pb-2.5",children:c[M].map(De=>t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:De},De))})}):null]},M)})})]})})]})}function XF({name:e,keep:n,busy:s,onAllow:r,onKeep:o}){const i=p.useRef(null);return p.useEffect(()=>{var c;(c=i.current)==null||c.focus()},[]),t.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e} without asking?`,onKeyDown:c=>{c.key==="Escape"&&(c.stopPropagation(),o())},className:"flex flex-wrap items-center gap-3 border border-destructive/50 bg-card px-3 py-2.5",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Allow a destructive tool?"})," Its server marks ",t.jsx("span",{className:"break-all font-mono",children:e})," as one that may delete or overwrite: every call would run with no one asked."]}),t.jsx(B,{ref:i,type:"button",size:"sm",variant:"ghost",onClick:o,children:n}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",disabled:s,onClick:r,children:"Allow without asking"})]})}function Tx({value:e,prefix:n,tool:s}){const r=VC(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 ZF=({choice:e,harnesses:n=[]})=>t.jsx(t.Fragment,{children:KD.map(s=>{const r=n.find(o=>o.id===s&&!o.available);return r?t.jsxs("span",{title:r.reason,className:"block font-mono text-small text-muted-foreground",children:[s,": not offered here"]},s):t.jsx(Tx,{value:e.resolves[s],prefix:`${s}: `,tool:e.name},s)})});function e6({agent:e,harness:n,model:s,tools:r,choices:o,gates:i=[],mcpServers:c,serverSettings:d,focus:u,callTools:f,value:g,issues:y,unattended:v=!1,onChange:h}){const x=new Set(r),b=o.filter(A=>x.has(A.name)||!A.available),j=i.some(A=>A.ask_needs==="password"),k=A=>{var M;return(M=e==null?void 0:e.tools)==null?void 0:M.find(F=>F.name===A)},E=A=>{var F;const M=qo(A);return M?(F=c==null?void 0:c.find(I=>I.name===M.server))==null?void 0:F.tools.find(I=>I.name===M.tool):void 0},S=A=>{var F;const M=qo(A);return M?(F=g[`mcp:${M.server}/*`])==null?void 0:F.permission:void 0},N=f?f.flatMap(A=>i.filter(M=>M.name===A)):[...new Set(r)].flatMap(A=>{var I;const M=i.find(q=>q.name===A);if(M)return[M];const F=k(A)??E(A);return!((I=F==null?void 0:F.permissions)!=null&&I.length)||!F.default_permission?[]:[{name:A,permission:F.permission??F.default_permission,default_permission:F.default_permission,permissions:F.permissions,...j&&F.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),$=rE(b,N,[...i.map(A=>A.name),...o.map(A=>A.name)]),_=p.useRef(null);if(p.useEffect(()=>{var F,I;if(!u)return;const A=`${u} permission`,M=[...((F=_.current)==null?void 0:F.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(q=>q.getAttribute("aria-label")===A);(I=M==null?void 0:M.scrollIntoView)==null||I.call(M,{block:"center"}),M==null||M.focus()},[]),!$.length)return null;const O=(e==null?void 0:e.definition.tool_settings)??{},L=v!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:P,rest:R}=QC(y,"definition.tool_settings",$.map(A=>A.name));return t.jsxs("section",{"aria-label":"Tool settings",ref:_,children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Tool settings"})}),t.jsxs("p",{className:"-mt-1 mb-2 text-small text-muted-foreground",children:["Each of these tools takes this server's setting (its default here) unless it is changed here. ",f?"A call node can't wait for an approval: a tool set to ask stops the run from starting. Set it to allow.":v?"Never ask is on: a tool on ask runs without waiting for you. A tool set to deny still holds.":"A tool on ask makes the run wait for your approval at each call."]}),t.jsx(bb,{label:"This agent's tool settings",unattended:v,rows:$,settings:g,fallbackOf:A=>A.provider,issues:P,onEdit:A=>h(A(g)),effectOf:A=>{var M;return(M=E(A))==null?void 0:M.effect},confirmAllowOf:A=>{var M;return((M=E(A))==null?void 0:M.effect)==="destructive"},noteOf:A=>{const M=g[A],F=d==null?void 0:d[A],I=!!(M!=null&&M.pin||M!=null&&M.pin_broken);return!I&&!(F!=null&&F.pin)&&!(F!=null&&F.pin_broken)?null:t.jsxs(t.Fragment,{children:[I&&t.jsx(_x,{setting:M,label:"Pinned for this agent",also:!!(F!=null&&F.pin)}),(!I||(F==null?void 0:F.pin_broken))&&t.jsx(_x,{setting:F,label:"Pinned on this server"})]})},refused:A=>qC(A,i,e==null?void 0:e.tools,c),locked:!0,permissionFallbackOf:A=>{var M;return S(A.name)??((M=k(A.name))==null?void 0:M.default_permission)??A.permission},resolvesOf:A=>{var W,K,U,H,G,z;const M=(((W=g[A.name])==null?void 0:W.provider)??null)!==(((K=O[A.name])==null?void 0:K.provider)??null)||(((U=g[A.name])==null?void 0:U.permission)??null)!==(((H=O[A.name])==null?void 0:H.permission)??null)||L,F=(G=e==null?void 0:e.tools)==null?void 0:G.find(V=>V.name===A.name),I=F&&F.provider===(((z=g[A.name])==null?void 0:z.provider)??A.provider)?F.resolved:void 0,q=(s??"")===((e==null?void 0:e.definition.model)??"");return!M&&n===((e==null?void 0:e.definition.harness)??"pi")&&q&&I?t.jsx(Tx,{value:I,prefix:`${n}: `,tool:A.name}):!M&&!O[A.name]&&!s?t.jsx(Tx,{value:A.resolves[n],prefix:`${n}: `,tool:A.name}):t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),R.map(A=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:A},A))]})}const df=20,t6=400;function n6(e,n,s,r,o){const[i,c]=p.useState(null),[d,u]=p.useState(0),f=(r??[]).join(",");p.useEffect(()=>{if(!o||!s||i==="unsupported")return;const y=new AbortController,v=setTimeout(()=>{o({workflow:n,...r?{tools:r}:{}},y.signal).then(h=>{y.signal.aborted||c({text:e,check:h})},h=>{y.signal.aborted||((h==null?void 0:h.status)===404||(h==null?void 0:h.status)===405?c("unsupported"):c({text:e,failed:(h==null?void 0:h.message)||`the server answered ${(h==null?void 0:h.status)??"nothing"}`}))})},t6);return()=>{clearTimeout(v),y.abort()}},[e,s,f,o,d]);const g=()=>{c(null),u(y=>y+1)};return i==="unsupported"||!o?{mode:"lint",retry:g}:i&&i.text===e?"failed"in i?{mode:"failed",failed:i.failed,retry:g}:{mode:"server",check:i.check,retry:g}:{mode:"pending",retry:g}}function T0({text:e,onText:n,base:s,baseLabel:r,serverIssues:o,readOnly:i=!1,validate:c,tools:d}){var q;const u=p.useRef(null),f=p.useRef(null),[g,y]=p.useState(0),v=p.useMemo(()=>PM(e),[e]),h=p.useRef(null);v.ok&&(h.current={value:v.value,spans:v.spans});const x=(q=h.current)==null?void 0:q.value,b=p.useMemo(()=>ml(x),[x]),j=p.useMemo(()=>s===void 0?null:ml(s),[s]),k=p.useMemo(()=>j?w2(j,b):null,[j,b]),E=n6(e,v.ok?v.value:void 0,v.ok,d,i?void 0:c),S=p.useMemo(()=>v.ok&&!i?FM(v.value):[],[v,i]),N=p.useMemo(()=>E.mode!=="server"?S:[...E.check.issues.map(W=>({path:W.path,message:W.message,severity:"error"})),...E.check.warnings.map(W=>typeof W=="string"?{path:"",message:W,severity:"warning"}:{path:W.path??"",message:W.message,severity:"warning"})],[E.mode,E.mode==="server"?E.check:null,S]),$=v.ok?UM(v.spans,b.nodes.map(W=>W.path),g):null,_=p.useMemo(()=>({meta:jd(x,b),diff:k?{added:k.added.map(W=>W.path),edited:[...k.changed,...k.rewritten].map(W=>W.next),moved:k.moved.map(W=>W.next),removed:k.removed.map(({label:W,kind:K})=>({label:W,kind:K}))}:void 0,selected:$?{path:$}:null}),[x,b,k,$]),O=e.split(`
|
|
652
|
-
`).length,L=W=>IM(e,W),P=[];v.ok||P.push({...L(v.error.offset),message:`JSON: ${v.error.message}`,severity:"error",offset:v.error.offset});for(const W of N){const K=v.ok?Lk(v.spans,W.path):void 0,U=(K==null?void 0:K.start)??0;P.push({...L(U),message:W.message,severity:W.severity,offset:U,path:W.path})}for(const W of[...o??[]].reverse()){const K=W.path&&v.ok?Lk(v.spans,W.path):void 0;P.unshift({...K?L(K.start):{line:0,col:0},message:`Server: ${W.message}`,severity:"error",offset:(K==null?void 0:K.start)??-1})}const R=new Map;for(const W of P)W.line&&R.get(W.line)!=="error"&&R.set(W.line,W.severity);const A=(W,K=W)=>{const U=u.current;!U||W<0||(U.focus(),U.setSelectionRange(W,K),U.scrollTop=Math.max(0,(L(W).line-4)*df),y(W))};p.useEffect(()=>{const W=v.ok?v.spans.get("/root"):void 0;W&&u.current&&(u.current.scrollTop=Math.max(0,(L(W.start).line-2)*df))},[]);const M=k?k.edges.added.length+k.edges.removed.length:0,F=k?k.added.length+k.changed.length+k.rewritten.length+k.removed.length+k.moved.length+M:0,I=P.filter(W=>W.severity==="error").length;return t.jsxs("div",{className:"grid min-h-0 grid-cols-1 border xl:grid-cols-[minmax(420px,5fr)_7fr]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col border-b xl:border-b-0 xl:border-r",children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"workflow.json"}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[O," lines"]}),t.jsx("span",{className:"flex-1"}),i?t.jsx("span",{className:"caps text-label text-muted-foreground",children:"Read-only"}):t.jsxs(t.Fragment,{children:[E.mode==="failed"&&v.ok?t.jsxs("span",{className:"font-mono text-label text-warning-text",title:E.failed,children:["server check failed, showing local checks ",t.jsx(B,{type:"button",onClick:E.retry,size:"xs",className:"ml-1",children:"Retry"})]}):E.mode!=="lint"&&v.ok&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:E.mode==="pending"?"checking...":"checked by the server"}),I?t.jsxs("span",{className:"caps inline-flex items-center gap-1 text-label text-destructive-text",children:[t.jsx(al,{className:"size-3.5","aria-hidden":!0})," ",I," ",I===1?"problem":"problems"]}):t.jsx("span",{className:"caps text-label text-success-text",children:E.mode==="server"?"Valid":"Valid shape"})]})]}),t.jsxs("div",{className:"relative flex h-[560px] min-h-0 xl:h-[calc(100vh-390px)] xl:min-h-[440px]",children:[t.jsx("div",{ref:f,"aria-hidden":!0,className:"w-12 shrink-0 select-none overflow-hidden border-r bg-card py-3 text-right font-mono text-label text-muted-foreground",style:{lineHeight:`${df}px`},children:Array.from({length:O},(W,K)=>t.jsx("div",{className:ae("pr-2",R.get(K+1)==="error"&&"bg-destructive/15 text-destructive-text",R.get(K+1)==="warning"&&"bg-warning/15 text-warning-text"),children:K+1},K))}),t.jsx(nn,{bare:!0,ref:u,value:e,readOnly:i,spellCheck:!1,wrap:"off","aria-label":"Workflow JSON",onChange:W=>{i||n(W.target.value),y(W.target.selectionStart)},onSelect:W=>y(W.target.selectionStart),onScroll:W=>{f.current&&(f.current.scrollTop=W.target.scrollTop)},onKeyDown:W=>{if(W.key!=="Tab"||i)return;W.preventDefault();const K=W.currentTarget,U=K.selectionStart,H=K.selectionEnd;n(`${e.slice(0,U)} ${e.slice(H)}`),requestAnimationFrame(()=>K.setSelectionRange(U+2,U+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:`${df}px`,tabSize:2}})]}),!i&&t.jsxs("ul",{className:"max-h-48 min-h-[44px] overflow-auto border-t font-mono text-small","aria-label":"Problems",children:[P.length===0&&t.jsx("li",{className:"px-4 py-3 text-muted-foreground",children:E.mode==="server"?"No problems: the server's validator takes this workflow as it is.":"No problems the console can see. The server checks the workflow again when you save."}),P.map((W,K)=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>A(W.offset),className:"flex w-full items-start gap-2.5 border-b px-4 py-2 text-left hover:bg-accent",children:[W.severity==="error"?t.jsx(al,{className:"mt-0.5 size-3.5 shrink-0 text-destructive-text","aria-hidden":!0}):t.jsx(Ks,{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:W.line?`L${W.line}:${W.col}`:"—"}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:W.message})]})},K))]})]}),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:Jm(db(b))}),k&&(F?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&&M&&`${M} ${M===1?"connection":"connections"} changed`].filter(Boolean).join(" · ")," ",t.jsxs("span",{className:"text-muted-foreground",children:["against ",r??"the current revision"]})]}):t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Same as ",r??"the current revision"]})),t.jsx("span",{className:"flex-1"}),!v.ok&&h.current&&t.jsx("span",{className:"caps text-label text-warning-text",children:"Showing the last JSON that parsed"})]}),t.jsx("div",{className: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]",!v.ok&&"opacity-60"),children:b.nodes.length?t.jsx(Td,{graph:b,marks:_,label:"The workflow's graph",minScale:.55,onSelect:W=>{const K=v.ok?v.spans.get(`${W.path}/label`)??v.spans.get(W.path):void 0;K&&A(K.start,K.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(Rd,{})})]})]})}const s6="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function oE(){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:s6,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let qi=null;function uf(e,n){return qi?qi({to:e,replay:n}):!1}function aE(e){const[n,s]=p.useState(null),r=p.useRef(location.hash);return p.useEffect(()=>{if(!e)return;const o=c=>c.to===r.current?!1:(s(c),!0);qi=o;const i=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",i),()=>{qi===o&&(qi=null),window.removeEventListener("beforeunload",i)}},[e]),{asking:n!==null,stay:()=>s(null),leave:()=>{var o;if(n!==null){if(s(null),n.to===null){(o=n.replay)==null||o.call(n);return}if(qi=null,!n.replay){location.hash=n.to;return}location.hash!==r.current?window.addEventListener("hashchange",n.replay,{once:!0}):n.replay()}}}}const iE="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",Lg="custom",R0=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function r6(e,n){if((e==null?void 0:e.kind)!=="invalid")return null;const s=Object.entries(e.fields).filter(([r])=>r==="definition.workflow"||r.startsWith("definition.workflow/")).map(([r,o])=>({path:r.slice(19),message:o}));return s.length?s:n?[{path:"",message:e.message}]:null}function o6(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 a6=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:Za},{id:"workflow",label:"Workflow",note:"Its graph and its JSON",Icon:ti},{id:"computer",label:"Computer",note:"Where it runs and what it drives",Icon:ei},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:Af},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:YN},{id:"history",label:"History",note:"Revisions and the current one",Icon:dd}];function i6({agent:e,revisions:n=[],caps:s,onSave:r,onMakeCurrent:o,onArchive:i,onReload:c,onBack:d,step:u,problem:f=null,notice:g,draft:y,validate:v,providerChoices:h=[],permissionGates:x=[],focusTool:b,mcpServers:j=null,serverToolSettings:k,onRetryMcp:E}){var mn,Gn,Rs,qn,As,Os,Ln;const S=!e,N=e==null?void 0:e.definition,$=ns(N),_=!!(N!=null&&N.native)||!!$,[O,L]=p.useState(u??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),P=S?jg(s.places):void 0,[R,A]=p.useState({name:(N==null?void 0:N.name)??"",description:(N==null?void 0:N.description)??"",instructions:(N==null?void 0:N.instructions)??(S?kP:""),harness:(N==null?void 0:N.harness)??"pi",thinking:N==null?void 0:N.thinking,model:N==null?void 0:N.model,tools:S?kg("pi",s.tools,P):(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):"",...P?{place:P}:{},...(e==null?void 0:e.kind)==="workflow"?{workflowText:y??JSON.stringify(N.workflow,null,2)}:{}}),[M,F]=p.useState(!1),[I,q]=p.useState(!1),W=p.useRef(R);W.current=R;const[K,U]=p.useState(R),H=ee=>{const{maxCostText:Me,workflowText:mt,...Ot}=ee,Xt=Uk(Me),Be=R0(mt),te={...Ot,maxCost:Xt.ok?Xt.value??0:Me,...mt!==void 0?{workflowSent:Be!==void 0?Be:mt}:{}},ye=e?{...Nd(e,te,"").definition}:{...te};return delete ye.version,ye.tool_settings&&!Object.keys(ye.tool_settings).length&&delete ye.tool_settings,{...ye,tools:[...ye.tools??[]].sort(),approvals:ee.approvals??(N==null?void 0:N.approvals)??"ask"}},G=!tl(H(R),H(K)),[z,V]=p.useState([]),[se,J]=p.useState(!1),re=s.tools.map(ee=>`${ee.name}:${ee.available}:${(ee.harnesses??[]).join("+")}`).join(","),ne=JSON.stringify(jg(s.places)??null);p.useEffect(()=>{if(!S)return;const ee=Me=>{const mt=Me.place??jg(s.places);return{...Me,...mt?{place:mt}:{},...se?{}:{tools:kg(Me.harness??"pi",s.tools,mt)}}};A(ee),U(ee)},[re,ne]);const[me,ve]=p.useState(""),[je,Ve]=p.useState(()=>((N==null?void 0:N.tools)??[]).filter(vl)),[de,Oe]=p.useState(!1),[ze,De]=p.useState(!1),[Ne,Q]=p.useState(f),[be,nt]=p.useState(null),fe=ee=>{nt(null),L(ee)},Le=p.useRef(null),Ye=sE(Le.current??R.tools??[]),ht=(Ne==null?void 0:Ne.kind)==="invalid"?Object.entries(Ne.fields).flatMap(([ee,Me])=>{const mt=Ye.get(ee);return mt?[{grant:mt,message:Me}]:[]}):[],ie=ee=>(Ne==null?void 0:Ne.kind)==="invalid"&&Object.entries(Ne.fields).filter(([Me])=>!Ye.has(Me)&&(Me===`definition.${ee}`||Me.startsWith(`definition.${ee}[`)||Me.startsWith(`definition.${ee}.`))).map(([,Me])=>Me).join(" ")||void 0,{monid:Ce,rest:tt}=FF((e==null?void 0:e.warnings)??[],(N==null?void 0:N.tools)??[]),Ie=ee=>RP(tt,ee).map(Me=>Me.message).join(" ")||void 0,at=ee=>{S&&ze||A(Me=>({...Me,...ee}))},St=p.useRef(null);p.useEffect(()=>{var ee;((Ne==null?void 0:Ne.kind)==="invalid"||(Ne==null?void 0:Ne.kind)==="other")&&((ee=St.current)==null||ee.focus())},[Ne]);const st=(e==null?void 0:e.kind)==="workflow",ut=S&&hx(R.harness),Dt=[...(mn=R.name)!=null&&mn.trim()?[]:["Give the agent a name to create it."],...!st&&!ut&&!((Gn=R.instructions)!=null&&Gn.trim())?["Write its instructions to create it."]:[]],Ft=R.approvals??(N==null?void 0:N.approvals)??"ask",Rt=_P(s.harnesses,S?{available:!!s.decisionProvider}:void 0),pe={mcpHarnesses:s.mcpHarnesses,workflow:st},he=ee=>{if(ee.mode==="sandbox")return;const Me=new Set(s.tools.filter(mt=>mt.sandbox_only).map(mt=>mt.name));V(mt=>mt.filter(Ot=>!Me.has(Ot)))},He=ee=>{if(S&&!se){at({harness:ee,tools:kg(ee,s.tools,R.place)}),V([]);return}const Me=CP(ee,R.tools??[],z,s.tools,pe);at({harness:ee,tools:Me.tools}),V(Me.held)},Je=n.find(ee=>ee.revision===(e==null?void 0:e.revision))??n.find(ee=>ee.current),X=a6.filter(ee=>!(S&&ee.id==="history")&&(ee.id!=="workflow"||st)&&!(ut&&ee.id==="tools")&&(ee.id!=="computer"||!st&&!ut&&!!(s.computers||s.places))),ge=X.some(ee=>ee.id===O)?O:X[0].id,_e=X.findIndex(ee=>ee.id===ge),Ae=async()=>{if(!r)return;const ee=R;Le.current=R.tools??[],De(!0);let Me={...R,workflowText:void 0,maxCostText:void 0};if(!ut){const Xt=Uk(R.maxCostText);if(!Xt.ok){De(!1),Q({kind:"invalid",message:Xt.message,fields:{"definition.max_cost_usd":Xt.message}});return}const Be=typeof(N==null?void 0:N.max_cost_usd)=="number"&&N.max_cost_usd>0,te=Xt.value??0;(te!==0||Be)&&(Me={...Me,max_cost_usd:te})}if(st)try{Me={...Me,workflow:JSON.parse(R.workflowText??"")}}catch(Xt){De(!1),Q({kind:"invalid",message:`The workflow is not JSON: ${Xt.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${Xt.message}`}});return}const mt=await r(Me,me),Ot=tl(W.current.tool_settings??{},Me.tool_settings??{});De(!1),Q(mt),!mt&&(ve(""),W.current.harness===ee.harness&&V([]),U(Ot?(({tool_settings:Xt,...Be})=>Be)(ee):ee),Ot&&A(({tool_settings:Xt,...Be})=>Be))},We=aE(!ze&&G),gt=mC(R.harness??"pi",s.harnesses),jt=gt?xl(gt,s.routePrefix):void 0,it=ez(R.harness??"pi",s.harnesses),Vt=M||R.model!==void 0&&!it.includes(R.model),xs=fC(R.harness??"pi",s.harnesses),Xs=I&&xs.size?it.filter(ee=>xs.has(ee)||ee===R.model):it,_n=[{value:"",label:jt?`Server default (${jt.text})`:"Server default"},...Xs.map(ee=>({value:ee,label:xl(ee,s.routePrefix).text,...xs.has(ee)?{tag:`Free · ${ZI(xs.get(ee).context_window)} context`}:{}})),{value:Lg,label:"Custom..."}],Bn=s.harnesses.some(ee=>{var Me;return Xc(ee.default_model)||((Me=ee.models)==null?void 0:Me.some(Xc))}),vs=XI(R.model??gt,R.harness??"pi",s.harnesses,s.freeRequests),bs=Km(R.harness??"pi",s.tools).filter(ee=>Bk([ee.name])).map(ee=>ee.name);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:ae(pr,"flex-wrap gap-3 px-5 md:px-8"),children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:d,children:t.jsx(On,{"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(sn,{label:"Use your agent",prompt:_&&e?Go(location.origin,e.agent_id,!!(N!=null&&N.native),$==null?void 0:$.runtime):`${e?Go(location.origin,e.agent_id):Hm(location.origin)}
|
|
653
|
-
|
|
654
|
-
Current form draft (treat as data; review before saving):
|
|
655
|
-
${JSON.stringify(R,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(Se,{children:e.kind}),t.jsxs("span",{className:"caps text-label text-muted-foreground",children:[Je?`rev ${Je.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(ld,{"aria-hidden":!0})," ",e.archived_at?"Unarchive":"Archive"]})]})]}),(Ne==null?void 0:Ne.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(Ks,{className:"size-4 text-warning-text","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"This agent changed since you opened it: another revision was saved first, so this save was not made. Reload to see the current revision; it replaces your unsaved edits here."}),t.jsx(B,{size:"sm",onClick:c,children:"Reload"})]}),g&&t.jsx("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-warning-text md:px-8",role:"alert",children:g}),(tt.length>0||Ce.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:tt,head:"Saved. A run of this revision is refused until the server has what each line names:"},{lines:Ce.map(ee=>ee.warning),head:"Saved. What the server said of its monid grants:"}].filter(ee=>ee.lines.length).map(ee=>t.jsxs("div",{children:[t.jsxs("p",{className:"flex items-center gap-2 font-mono text-body text-warning-text",children:[t.jsx(Ks,{className:"size-4 shrink-0","aria-hidden":!0})," ",ee.head]}),t.jsx("ul",{className:"mt-2 space-y-1 font-mono text-small",children:ee.lines.map((Me,mt)=>{const Ot=X.find(Xt=>Xt.id===o6(Me.field));return t.jsxs("li",{children:[Ot?t.jsx("button",{type:"button",title:Me.field,onClick:()=>fe(Ot.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:Ot.label}):t.jsx("span",{className:"text-muted-foreground",children:Me.field})," ",Me.message]},`${Me.field}:${mt}`)})})]},ee.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",ge==="workflow"?"md:w-[76px]":"md:w-[240px]"),children:X.map((ee,Me)=>t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","aria-current":ge===ee.id?"step":void 0,onClick:()=>fe(ee.id),className:ae("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",ge===ee.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",ge===ee.id?"border-foreground bg-foreground text-background":Me<_e?"border-border-strong":"border-border"),children:Me<_e?t.jsx(wl,{className:"size-3","aria-hidden":!0}):Me+1}),t.jsxs("span",{className:ae("hidden min-w-0",ge!=="workflow"&&"md:block"),title:ge==="workflow"?ee.label:void 0,children:[t.jsxs("span",{className:"caps flex items-center gap-1.5 text-small",children:[t.jsx(ee.Icon,{className:"size-3.5","aria-hidden":!0})," ",ee.label]}),t.jsx("span",{className:"mt-0.5 block text-label text-muted-foreground",children:ee.note})]}),t.jsx("span",{className:"sr-only md:hidden",children:ee.label})]})},ee.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 ",_e+1]}),t.jsx("h2",{className:"mb-6 border-b pb-4 text-lg font-semibold",children:X[_e].label}),t.jsxs("fieldset",{disabled:S&&ze,className:"m-0 min-w-0 border-0 p-0",children:[ge==="context"&&t.jsxs("div",{className:"grid gap-x-10 gap-y-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,2fr)] xl:items-start",children:[t.jsxs("div",{className:"space-y-6",children:[t.jsx(xt,{label:"Name",id:"agent-name",required:S,note:S?void 0:"Set when the agent was created; an edit keeps it.",error:ie("name"),warning:Ie("name"),children:t.jsx(Pe,{id:"agent-name",value:R.name,readOnly:!S,onChange:ee=>at({name:ee.target.value}),placeholder:"e.g., Invoice checker"})}),t.jsx(xt,{label:"Description",id:"agent-description",optional:!0,note:S?void 0:"Set when the agent was created; an edit keeps it.",error:ie("description"),warning:Ie("description"),children:t.jsx(Pe,{id:"agent-description",value:R.description,readOnly:!S,onChange:ee=>at({description:ee.target.value}),placeholder:S?"Short summary for the agent list":"No description"})})]}),ut?t.jsx(xt,{group:!0,label:"Workflow",children:t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:R.harness===Gv?"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."})}):st?t.jsx(xt,{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:Ie("workflow"),children:t.jsxs(B,{size:"sm",onClick:()=>L("workflow"),children:[t.jsx(ti,{"aria-hidden":!0})," Open the workflow"]})}):t.jsxs(xt,{group:de?"heading":void 0,label:"Instructions",id:de?void 0:"agent-instructions",required:!0,error:ie("instructions"),warning:Ie("instructions"),aside:t.jsx("span",{className:"flex",children:["Preview","Edit"].map(ee=>t.jsx(B,{size:"xs",type:"button",onClick:()=>Oe(ee==="Preview"),className:ae("caps border px-2.5 py-1 text-label",ee==="Preview"===de?"border-foreground bg-foreground text-background":"text-muted-foreground"),children:ee},ee))}),children:[de?t.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:oo(R.instructions||"")}}):t.jsx(nn,{id:"agent-instructions",value:R.instructions,onChange:ee=>at({instructions:ee.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:ae(l6,"resize-y leading-[1.7]")}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(R.instructions??"").length," characters"]})]})]}),ge==="workflow"&&t.jsx(T0,{text:R.workflowText??"",onText:ee=>at({workflowText:ee}),base:st?N.workflow:void 0,baseLabel:Je?`rev ${Je.version}`:void 0,validate:v,tools:R.tools,serverIssues:r6(Ne,st)}),ge==="computer"&&!st&&!ut&&s.computers&&t.jsx("div",{className:"space-y-8",children:t.jsx(VF,{kinds:s.computers,value:R.computer??(N==null?void 0:N.computer)??mx(R.place??{mode:"runner"}),onChange:ee=>{const Me=qF(ee),mt=new Set(s.tools.filter(Ot=>Ot.sandbox_only).map(Ot=>Ot.name));at({computer:ee,place:Me,...Me.mode==="runner"?{tools:(R.tools??[]).filter(Ot=>!mt.has(Ot))}:{}}),he(Me)},error:ie("computer")??ie("place"),warning:Ie("computer")??Ie("place")})}),ge==="computer"&&!st&&!ut&&!s.computers&&s.places&&t.jsx("div",{className:"space-y-8",children:t.jsx(YF,{value:R.place,saved:N==null?void 0:N.place,places:s.places,tools:s.tools,picked:R.tools??[],onChange:ee=>{at({...ee,...ee.place?{computer:mx(ee.place)}:{}}),ee.place&&he(ee.place)},error:ie("computer")??ie("place"),warning:Ie("computer")??Ie("place")})}),ge==="tools"&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs(xt,{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:ie("tools"),warning:Ie("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(ee=>{var Me;return st||!ee.call_only||((Me=R.tools)==null?void 0:Me.includes(ee.name))}).map(ee=>{var Nt,It;const Me=px(R.harness??"pi",ee.name,s.tools,pe),mt=((Nt=R.tools)==null?void 0:Nt.includes(ee.name))??!1,Ot=h.find(lt=>lt.name===ee.name),Xt=(It=(R.tool_settings??(N==null?void 0:N.tool_settings)??{})[ee.name])==null?void 0:It.provider,Be=!!Ot&&Xt!==void 0&&Xt!==Ot.provider,te=EP(ee,R.place??kd(N==null?void 0:N.place)??Kv(st,[...R.tools??[],ee.name],s.places)),ye=qC(ee.name,x,e==null?void 0:e.tools)?pb:ee.call_only&&!st?"Workflow-only: a workflow's call node runs it, not an agent":Me?te??(!ee.available&&!Be?(Ot==null?void 0:Ot.reason)??ee.reason??`Needs ${(ee.missing??[]).join(", ")}`:void 0):Hk(R.harness??"pi",ee.name,s.tools),qe=ye?ee.call_only&&!st?"Workflow only":te&&Me&&ye===te?"Sandbox-only":ye:void 0;return t.jsx("li",{className:"min-w-0",children:t.jsx(gb,{value:ee.name,name:ee.name,blurb:ee.blurb,description:ee.summary,why:ye,tag:qe,on:mt,disabled:!!ye&&!mt,onToggle:()=>{J(!0),at({tools:mt?R.tools.filter(lt=>lt!==ee.name):[...R.tools??[],ee.name]})}})},ee.name)}),s.mcp&&!st&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(SF,{servers:j,tools:R.tools??[],harness:R.harness??"pi",harnesses:s.mcpHarnesses,onRetry:E,onChange:ee=>{J(!0),at({tools:ee})}})}),!st&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(WF,{tools:R.tools??[],listed:je,notes:Ce.map(({grant:ee,warning:Me})=>({grant:ee,message:Me.message})),refused:ht,onChange:ee=>{Ve(Me=>[...new Set([...Me,...ee.filter(vl)])]),J(!0),at({tools:ee})}})})]}),!st&&!Bk(R.tools??[])&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["This agent can't reach the web: ",bs.length?`tick ${bs.join(" or ")} in Tools.`:`${R.harness??"pi"} runs no web tool on this server.`]})]}),t.jsx(e6,{agent:e,unattended:!st&&Ft==="never",harness:R.harness??"pi",model:R.model,tools:R.tools??[],choices:st?[]:h,gates:x,mcpServers:Array.isArray(j)?j:void 0,serverSettings:k,focus:b,callTools:st?VD(R0(R.workflowText)??(N==null?void 0:N.workflow)):void 0,value:R.tool_settings??(N==null?void 0:N.tool_settings)??{},issues:(Ne==null?void 0:Ne.kind)==="invalid"?Ne.fields:{},onChange:ee=>!ze&&tl(ee,(N==null?void 0:N.tool_settings)??{})?A(({tool_settings:Me,...mt})=>mt):at({tool_settings:ee})}),!st&&!ut&&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(([ee,Me,mt])=>t.jsxs("label",{className:ae("flex items-start gap-3 border px-3 py-2.5",Ft===ee&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"approvals",value:ee,className:"mt-1 accent-primary",checked:Ft===ee,disabled:ze,onChange:()=>at({approvals:ee})}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:Me}),t.jsx("span",{className:"block text-small text-muted-foreground",children:mt})]})]},ee)),Ft==="never"&&t.jsx("p",{className:"text-small text-warning-text",children:iE})]}),t.jsx(xt,{group:!0,label:"Skills",note:"Skill files are saved with each revision and kept as they are by an edit.",children:(Rs=N==null?void 0:N.skills)!=null&&Rs.length?t.jsx("ul",{className:"border",children:N.skills.map(ee=>t.jsx("li",{className:"border-b px-3 py-2 font-mono text-body last:border-b-0",children:ee},ee))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No skills."})})]}),ge==="settings"&&t.jsxs("div",{className:"2xl:columns-2 2xl:gap-x-10 [&>*]:mb-8 [&>*]:mt-0 [&>*]:break-inside-avoid",children:[!st&&t.jsxs(xt,{group:"heading",label:"Harness",note:"What runtime runs this agent.",error:ie("harness"),warning:Ie("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:Rt.map(ee=>{const Me=t.jsxs(t.Fragment,{children:[t.jsx("input",{type:"radio",name:"harness",value:ee.id,checked:R.harness===ee.id,disabled:!ee.available&&R.harness!==ee.id,onChange:()=>He(ee.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:ee.label}),t.jsx("span",{className:"mt-0.5 block font-mono text-label text-muted-foreground",children:ee.available?hx(ee.id)?ee.id.slice(ee.id.indexOf(":")+1):ee.id:"Not available here"})]})]}),mt=ae("min-w-0 border px-4 py-3",R.harness===ee.id?"border-foreground":"border-border");return ee.available?t.jsx("label",{className:ae(mt,"flex cursor-pointer items-start gap-3"),children:Me},ee.id):t.jsxs("div",{className:ae(mt,"opacity-60"),children:[t.jsx("label",{className:"flex cursor-not-allowed items-start gap-3",children:Me}),ee.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:ee.reason})]})]},ee.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:[((qn=Rt.find(ee=>ee.id===R.harness))==null?void 0:qn.label)??R.harness," doesn't run ",z.length===1?"this tool":"these tools"," here, so ",z.length===1?"it's":"they're"," unticked. Switching back ticks ",z.length===1?"it":"them"," again."]}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:z.map(ee=>t.jsxs("li",{children:[ee,": ",t.jsx("span",{className:"text-muted-foreground",children:Hk(R.harness??"pi",ee,s.tools,s.mcpHarnesses)})]},ee))})]})]}),!st&&!ut&&t.jsx(xt,{group:"heading",label:"Thinking",note:"How hard the model thinks before it answers.",error:ie("thinking"),warning:Ie("thinking"),children:t.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Thinking",children:s.thinking.map(ee=>t.jsxs("label",{className:ae("caps cursor-pointer border px-3 py-2 text-small",R.thinking===ee?"border-foreground":"text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:R.thinking===ee,onChange:()=>at({thinking:ee})}),ee]},ee))})}),!ut&&t.jsxs(xt,{label:"Model",id:"agent-model",optional:!0,note:jt?t.jsxs(t.Fragment,{children:["Empty uses the server's default (",t.jsx("span",{title:jt.title,children:jt.text}),")."]}):tz,error:ie("model"),warning:Ie("model"),children:[t.jsx(Et,{id:"agent-model",label:"Model",className:"w-full",value:Vt?Lg:R.model??"",options:_n,onChange:ee=>{if(ee===Lg){F(!0);return}F(!1),at({model:ee||void 0})}}),Vt&&t.jsx(Pe,{id:"agent-model-custom","aria-label":"Custom model",className:"mt-2",value:R.model??"",onChange:ee=>{F(!0),at({model:ee.target.value||void 0})},placeholder:"provider/model"}),xs.size>0&&t.jsxs("label",{className:"mt-2 flex items-center gap-2 text-small text-muted-foreground",children:[t.jsx(vd,{checked:I,onChange:q,label:"Free models only"})," Free models only (",xs.size,"): $0 a request; the provider limits requests per day."]})]}),!ut&&t.jsx(xt,{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.",Bn&&t.jsx("span",{className:"mt-1 block",children:VI}),vs&&t.jsx("span",{className:"mt-1 block","data-note":"free-requests",children:vs})]}),hint:t.jsx(oE,{}),error:ie("max_cost_usd"),warning:Ie("max_cost_usd"),children:t.jsx(Pe,{id:"agent-max-cost",inputMode:"decimal",value:R.maxCostText??"",onChange:ee=>at({maxCostText:ee.target.value}),placeholder:"e.g., 2.50"})}),!st&&!ut&&s.learning&&t.jsx(qz,{fields:R,onFields:at,saved:N==null?void 0:N.learning,server:s.learning,error:ie("learning"),warning:Ie("learning")})]}),ge==="history"&&be&&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:()=>nt(null),children:[t.jsx(On,{"aria-hidden":!0})," Back to History"]}),t.jsxs("span",{className:"caps text-small",children:["rev ",be.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:be.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ft(be.created_at)}),t.jsx(B,{size:"sm",onClick:()=>o==null?void 0:o(be.revision),disabled:!o,children:"Make current"})]}),t.jsx(T0,{readOnly:!0,text:JSON.stringify((As=be.definition)==null?void 0:As.workflow,null,2),onText:()=>{},base:N.workflow,baseLabel:Je?`rev ${Je.version}, the current one`:"the current revision"})]}),ge==="history"&&!be&&t.jsx("ul",{className:"border",children:n.map(ee=>{var Me;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 ",ee.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:ee.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ft(ee.created_at)}),st&&!ee.current&&((Me=ee.definition)==null?void 0:Me.workflow)!==void 0&&t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>nt(ee),"aria-label":`View rev ${ee.version}`,children:[t.jsx(vm,{"aria-hidden":!0})," View"]}),ee.current?t.jsx(Se,{tone:"success",children:"Current"}):t.jsx(B,{size:"sm",onClick:()=>o==null?void 0:o(ee.revision),disabled:!o,children:"Make current"})]},ee.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:_e===0,onClick:()=>fe(X[_e-1].id),children:[t.jsx(On,{"aria-hidden":!0})," Previous"]}),ge!=="history"&&t.jsx(Pe,{value:me,onChange:ee=>ve(ee.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")}),ge==="history"&&t.jsx("span",{className:"flex-1"}),_e<X.length-1&&t.jsxs(B,{size:"sm",onClick:()=>fe(X[_e+1].id),children:["Next ",t.jsx(Jx,{"aria-hidden":!0})]}),!be&&t.jsx(B,{ref:St,size:"sm",variant:"solid",onClick:Ae,disabled:!r||ze||!S&&!G||!((Os=R.name)!=null&&Os.trim())||!st&&!ut&&!((Ln=R.instructions)!=null&&Ln.trim()),children:S?ze?"Creating…":"Create":ze?"Saving…":G?"Save revision":Je?`Saved · rev ${Je.version}`:"Saved"}),S&&!ze&&!be&&Dt.map(ee=>t.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:ee},ee)),(Ne==null?void 0:Ne.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: ",Ne.message]}),(Ne==null?void 0:Ne.kind)==="other"&&t.jsx("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:Ne.message})]}),t.jsxs(kv,{open:We.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:We.leave,onCancel:We.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 l6="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 c6({agents:e,archived:n=!1,onArchivedChange:s,actions:r={},error:o,handoff:i,observations:c}){var g;const[d,u]=p.useState(""),f=(e??[]).filter(y=>`${y.definition.name} ${y.definition.description??""}`.toLowerCase().includes(d.toLowerCase()));return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:ae(pr,"flex-wrap justify-between gap-3 px-5"),children:[t.jsxs("h1",{className:Bo,children:[t.jsx(Hc,{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(sn,{variant:"primary",label:"Build an agent",prompt:Hm(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(fl,"flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3"),children:[t.jsx(wm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,value:d,onChange:y=>u(y.target.value),placeholder:"Search agents by name or description...","aria-label":"Search agents",className:"h-full flex-1 max-sm:portrait:placeholder:text-transparent"})]}),t.jsxs(B,{size:"lg",variant:n?"primary":"outline","aria-pressed":n,onClick:()=>s==null?void 0:s(!n),children:[t.jsx(ld,{"aria-hidden":!0})," Archived"]})]}),o?t.jsx("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:o}):e?!f.length&&!((g=c==null?void 0:c.data)!=null&&g.sessions.length)?t.jsxs("div",{className:"border px-4 py-16 text-center",children:[t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:d?"No agent matches.":n?"No archived agents.":"No agents yet."}),!d&&!n&&t.jsx("a",{className:"mt-4 inline-block text-lead text-primary-text hover:underline",href:"#/agents/new",children:"Describe your agent or start from a template"})]}):t.jsxs(t.Fragment,{children:[!!f.length&&t.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[f.length," ",f.length===1?"agent":"agents"]}),t.jsx("ul",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 2xl:grid-cols-3",children:f.map(y=>t.jsx(d6,{agent:y,actions:r},y.agent_id))})]}):t.jsx(Hn,{label:"Loading the agents",rows:6}),c&&t.jsx("div",{className:"mt-6",children:t.jsx(Pv,{read:c,view:"cards",query:d})})]})]})}function d6({agent:e,actions:n}){var d;const s=e.kind==="workflow"?ti:FN,r=!!e.archived_at,o=Qv(e),i=ns(e.definition),c=Xf(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("span",{"data-agent-card-icon":!0,className:"flex h-6 shrink-0 items-center",children:t.jsx(s,{className:"size-4 text-muted-foreground","aria-hidden":!0})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-h-6 flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-base font-semibold",children:e.definition.name}),t.jsx(Se,{children:e.kind}),e.kind==="agentic"&&t.jsx(Se,{children:i?Qo(i.runtime):o?Sd(o.runtime):e.definition.harness??"pi"}),o&&t.jsx(Se,{tone:o.connected&&o.state==="ready"?"success":"warning",children:Cd(o)}),r&&t.jsx(Se,{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"?WM(e.definition.workflow):"No description.")})]})]}),o&&t.jsxs("p",{className:"mt-3 break-all font-mono text-small text-muted-foreground",children:[o.project," · ",o.machine_id]}),t.jsxs("div",{"data-testid":"agent-card-footer",className:"mt-auto flex min-w-0 flex-wrap items-start gap-x-2 gap-y-1 pt-5",children:[t.jsxs("div",{"data-testid":"agent-card-chips",className:"flex min-w-0 flex-auto flex-wrap items-center gap-x-2 gap-y-1.5 py-1.5",children:[t.jsxs(Se,{className:"shrink-0 whitespace-nowrap",children:[e.revisions," ",e.revisions===1?"revision":"revisions"]}),e.runs&&t.jsxs(Se,{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":fb(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(sn,{compact:!0,compactIcon:t.jsx(Jo,{className:"size-3.5","aria-hidden":!0}),label:`Run ${e.definition.name}`,disabled:!!o&&(!o.connected||o.state!=="ready"||!o.capabilities.launch),prompt:Bv(location.origin,e.agent_id,i==null?void 0:i.runtime),playgroundHref:i?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`}),t.jsx(sn,{compact:!0,compactIcon:t.jsx(tv,{className:"size-3.5","aria-hidden":!0}),label:`Edit ${e.definition.name}`,prompt:Go(location.origin,e.agent_id,!!o,i==null?void 0:i.runtime),playgroundHref:o||i?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),t.jsxs(B,{size:"sm",className:"gap-1 px-2",variant:"outline","aria-label":`Runs of ${e.definition.name}`,onClick:()=>{var u;return(u=n.onRuns)==null?void 0:u.call(n,e.agent_id)},children:[t.jsx(dd,{"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(zN,{"aria-hidden":!0}):t.jsx(ld,{"aria-hidden":!0})})]})]})]})}function u6({v2:e}){const[n,s]=p.useState(null),[r,o]=p.useState(!1),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(""),[y,v]=p.useState("live"),[h,x]=p.useState(null),[b,j]=p.useState(!1),[k,E]=p.useState(!1),[S,N]=p.useState(null),$=p.useRef(!1),_=p.useRef(!1),O=p.useRef(0),L=p.useRef(!0),P=G5(),R=p.useCallback(async()=>{if(_.current)return;_.current=!0,o(!0);const I=O.current;try{const q=await e.listConnectors();L.current&&I===O.current&&(s(q.connectors),c(null))}catch(q){L.current&&I===O.current&&c(Wt(q))}finally{_.current=!1,L.current&&o(!1)}},[e]);p.useEffect(()=>{L.current=!0,queueMicrotask(()=>{L.current&&R()});const I=()=>{!document.hidden&&!$.current&&R()},q=setInterval(I,15e3);return window.addEventListener("focus",I),document.addEventListener("visibilitychange",I),()=>{L.current=!1,O.current++,clearInterval(q),window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",I)}},[R]),p.useEffect(()=>{if(!h)return;const I=new Date(h.expires_at).getTime()-Date.now();if(I<=0){x(null),j(!0);return}const q=setTimeout(()=>{x(null),j(!0)},I);return()=>clearTimeout(q)},[h]);const A=async()=>{if(!$.current){$.current=!0,E(!0),u(null),j(!1);try{const I=await e.enrollConnector(f,{native_execution:y!=="history",history_import:y!=="live"});L.current&&x(I)}catch(I){L.current&&u(Wt(I))}finally{$.current=!1,L.current&&E(!1)}}},M=async()=>{if(!($.current||!S)){$.current=!0,E(!0),u(null),O.current++;try{const{connector:I}=await e.revokeConnector(S.connector_id);L.current&&(s(q=>(q==null?void 0:q.map(W=>W.connector_id===I.connector_id?I:W))??null),N(null))}catch(I){L.current&&u(Wt(I))}finally{$.current=!1,L.current&&E(!1)}}},F=async()=>{if(h)try{await navigator.clipboard.writeText(h.enrollment_token),P({title:"Connection code copied"})}catch{P({title:"Select and copy the connection code below",tone:"error"})}};return t.jsxs("div",{className:"space-y-6","aria-label":"Remote connections",children:[t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Connect another machine",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-lg font-semibold",children:"Connect remote agents"}),t.jsx(sn,{label:"Connect agent",prompt:lP(location.origin,y)})]}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect a Claude Code or Codex setup on your laptop, VM or container. Its files and native sign-in stay there."}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label",children:"Allow this connection to"}),t.jsx(xd,{name:"remote-connection-intent",label:"Connection scope",size:"sm",value:y,onChange:v,options:[{value:"live",label:"Live agent",disabled:k},{value:"history",label:"History only",disabled:k},{value:"both",label:"Both",disabled:k}]}),t.jsxs("p",{className:"max-w-prose text-small text-muted-foreground",children:[y==="live"?"Run future jobs with your existing setup. Past conversations are not shared.":y==="history"?"Upload completed conversations from one selected project and runtime. No executing worker or self-improvement is enabled.":"Connect for future jobs and upload completed conversations from the selected project and runtime."," ",y!=="live"&&" Preview and approve the history on the source machine before upload. History is not used as learning."]})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(xt,{label:"Machine label",hint:"Optional. A name you recognize in this console.",children:t.jsx(Pe,{value:f,onChange:I=>g(I.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 A(),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."}),b&&t.jsx(bt,{tone:"warning",children:"The connection code expired. Create a new one if you have not connected the machine."}),d&&!S&&t.jsx(bt,{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 R(),"aria-busy":r,children:r?"Refreshing…":"Refresh"})]}),i&&t.jsx(bt,{tone:"error",title:"Remote machines could not be read",actions:t.jsx(B,{size:"xs",disabled:r,onClick:()=>void R(),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(I=>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:I.label||I.connector_id}),t.jsx(Se,{tone:I.status==="revoked"||!I.capabilities.native_execution?"plain":I.status==="online"?"success":"warning",children:I.status==="revoked"?"Revoked":!I.capabilities.native_execution&&I.capabilities.history_import?"History only":I.status==="online"?"Online":"Offline"}),t.jsx(B,{size:"sm",disabled:k||I.status==="revoked",onClick:()=>{u(null),N(I)},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:I.last_seen_at?ft(I.last_seen_at):"Not yet seen"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Access"}),t.jsx("dd",{children:I.capabilities.native_execution?I.capabilities.history_import?"Live agents and history import":"Selected native agents and remote jobs":I.capabilities.history_import?"History import only":"Observation only"})]})]}),I.status==="offline"&&I.capabilities.native_execution&&t.jsx(bt,{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."}),I.targets.length>0?t.jsx("ul",{className:"divide-y border-t",children:I.targets.map(q=>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:q.name}),q.agent_id?t.jsx("a",{href:dn(q.agent_id),className:"text-small underline underline-offset-2",children:"Open agent"}):t.jsx(Se,{children:"Not imported"})]}),t.jsxs("p",{className:"break-words text-small text-muted-foreground",children:[Sd(q.runtime)," · ",q.machine_id," · ",q.history_only?"Imported history":I.status==="online"?q.state==="ready"&&q.capabilities.launch?"Ready to run":q.state==="needs_attention"?"Needs attention":"Needs verification":"Worker unavailable"]}),q.issues.length>0&&t.jsx("p",{className:"text-small text-warning-text",children:q.issues.join("; ")})]},q.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."})]},I.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(Dm,{open:h!==null,onClose:()=>x(null),title:"Connect this machine",description:"Enter this code directly in the source connector's secure prompt.",footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",onClick:()=>x(null),children:"Done"}),t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void F(),children:"Copy connection code"})]}),children:h&&t.jsxs(t.Fragment,{children:[t.jsx(xt,{label:"One-use connection code",hint:`Expires ${ft(h.expires_at)}. Closing this dialog clears it from the page.`,children:t.jsx(Pe,{readOnly:!0,value:h.enrollment_token,autoComplete:"off",spellCheck:!1,onFocus:I=>I.currentTarget.select()})}),t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"This grants a scoped connector credential. Keep it out of coding-agent prompts, URLs and source control. After pairing, the connector retains its own credential in its private state directory."})]})}),t.jsxs(kv,{open:S!==null,title:"Revoke this machine's access?",confirm:k?"Revoking…":"Revoke access",busy:k,onCancel:()=>{N(null),u(null)},onConfirm:()=>void M(),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(bt,{tone:"error",className:"mt-3",children:d})]})]})}function sh({variant:e}){return t.jsx(sn,{variant:e,label:"Connect agent",prompt:W2(location.origin),playgroundHref:"#/agents/connect",playgroundLabel:"Connection setup"})}function f6({v2:e,go:n,initialSource:s="server"}){const[r,o]=p.useState(s),[i,c]=p.useState(""),[d,u]=p.useState(null),[f,g]=p.useState([]),[y,v]=p.useState({}),[h,x]=p.useState(!1),[b,j]=p.useState(null),k=async()=>{x(!0),j(null),u(null),g([]),v({});try{u((await e.discoverNative(i.trim())).targets)}catch(S){j(Wt(S))}finally{x(!1)}},E=async()=>{x(!0),j(null);try{for(const S of f){if(y[S])continue;const{project:N,runtime:$,selector:_}=d[S],O=await e.connectNative({project:N,runtime:$,selector:_});v(L=>({...L,[S]:O.agent.agent_id}))}}catch(S){j(Wt(S))}finally{x(!1)}};return t.jsxs("section",{className:"mx-auto max-w-page space-y-6 p-5 md:p-8","aria-label":"Connect agent",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h1",{className:"mr-auto text-2xl font-semibold",children:"Connect agent"}),t.jsx(B,{size:"sm",onClick:()=>n("#/agents"),children:"Back to agents"})]}),t.jsx("p",{className:"max-w-prose text-lead text-muted-foreground",children:"Connect a native setup for new jobs, or observe an agent already running in its original application. Keep its instructions, tools, permissions and sign-in."}),t.jsx(bt,{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(xd,{name:"native-source",label:"Connection method",value:r,onChange:o,options:[{value:"server",label:"This server",disabled:h},{value:"remote",label:"Another machine",disabled:h},{value:"observe",label:"Existing application",disabled:h}]}),r==="observe"?t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Observe an existing application",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Observe your existing agent"}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect Claude Code or Codex running locally, in Docker, or on another server. Your application continues to start and control its jobs; AgentRun receives session activity, model and token usage."}),t.jsx("p",{className:"max-w-prose text-small text-muted-foreground",children:"The setup skill configures the existing CLI and telemetry collector for this server. Adding self-improvement requires the backend SDK integration."}),t.jsx(sn,{variant:"primary",label:"Connect agent",prompt:`${W2(location.origin)}
|
|
656
|
-
|
|
657
|
-
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(u6,{v2:e}):t.jsxs(t.Fragment,{children:[t.jsx(sh,{}),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(xt,{label:"Project on server host",hint:"Enter the absolute path on the machine running AgentRun.",children:t.jsx(Pe,{"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"})]}),b&&t.jsx(bt,{tone:"error",title:"Connection request failed",children:b}),d&&t.jsxs("section",{className:"space-y-4","aria-label":"Native targets",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Choose what to connect"}),!d.length&&t.jsx(bt,{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||!!y[N],checked:f.includes(N),onChange:$=>g(_=>$.target.checked?[..._,N]:_.filter(O=>O!==N))}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("strong",{className:"break-words text-body",children:Vv(S.selector)}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:[Sd(S.runtime)," · ",S.version??"Version unknown"]})]})]}),t.jsx(Se,{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(([$,_])=>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:_})]},$))}),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(bt,{tone:"warning",children:t.jsx("ul",{children:S.issues.map($=>t.jsx("li",{children:$},$))})}),y[N]&&t.jsxs("p",{role:"status",className:"text-body",children:["Connected. ",t.jsx("a",{href:dn(y[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 E(),disabled:h||!f.some(S=>!y[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 Ra=e=>e instanceof Ue?TP(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function m6({v2:e,archived:n,go:s}){const r=Mv(e,{active:!n}),[o,i]=p.useState(null),[c,d]=p.useState(null),u=p.useRef(0),f=()=>{const g=++u.current;i(null),d(null),Qr(y=>e.listAgents({archived:n,cursor:y}),y=>y.agents).then(y=>{g===u.current&&i(y)}).catch(y=>{g===u.current&&d(Ra(y).message)})};return p.useEffect(()=>{f();const g=()=>{document.hidden||f()};return window.addEventListener("focus",g),document.addEventListener("visibilitychange",g),()=>{window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",g)}},[e,n]),t.jsx(c6,{observations:r,agents:o,archived:n,onArchivedChange:g=>s(g?"#/agents?archived=true":"#/agents"),error:c,handoff:t.jsx(sh,{}),actions:{onOpen:g=>s(dn(g)),onEdit:g=>s(dn(g,"edit")),onNew:()=>s("#/agents/new"),onRuns:g=>s(dn(g,"runs")),onLearning:g=>s(dn(g,"learning")),onArchive:async(g,y)=>{try{await(y?e.archiveAgent(g):e.unarchiveAgent(g)),f()}catch(v){d(Ra(v).message)}}}})}function h6({v2:e,caps:n,choices:s=[],gates:r=[],focusTool:o,agentId:i,go:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState([]),[h,x]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(0),[S,N]=p.useState(null),$=p.useRef(!0);p.useEffect(()=>($.current=!0,()=>{$.current=!1}),[]);const _=U=>Qr(H=>e.listRevisions(U,H),H=>H.revisions),O=async()=>{if(i)try{const[{agent:U,etag:H},G]=await Promise.all([e.getAgent(i),_(i)]);u(U),g(H),v(G),N(U.revision),E(z=>z+1),j(null),x(null)}catch(U){d?j(`The agent could not be reloaded: ${Ra(U).message}`):x(Ra(U).message)}};p.useEffect(()=>{O()},[i]);const[L,P]=p.useState(null),R=p.useRef(0);p.useEffect(()=>{const U=++R.current;e.computers().then(H=>{U===R.current&&P(H.kinds)},()=>{U===R.current&&P(null)})},[e]);const[A,M]=p.useState(void 0);p.useEffect(()=>{let U=!0;return Promise.resolve().then(()=>e.toolSettings()).then(H=>{U&&M(H)},()=>{}),()=>{U=!1}},[e]);const[F,I]=p.useState(null),q=p.useRef(0),W=()=>{if(!n.mcp)return;const U=++q.current;I(null),e.listMcpServers().then(H=>{U===q.current&&I(H.servers)},()=>{U===q.current&&I("failed")})};p.useEffect(W,[e,n.mcp]);const K=async(U,H)=>{let G;try{G=await H()}catch(z){j(`${U} did not finish: ${Ra(z).message}`);return}u(G);try{const{agent:z,etag:V}=await e.getAgent(G.agent_id),se=await _(G.agent_id).catch(()=>y);u(z),g(V),v(se),z.revision!==S?(N(z.revision),E(J=>J+1),j(U==="Make current"?null:`${U} done. This agent changed since you opened it: the form now shows its current revision.`)):j(null)}catch(z){j(`${U} done. The page could not be refreshed: ${Ra(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&&ns(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(bt,{children:"This agent runs in your backend. Edit its application code with your coding agent; manage self-improving in its Learning tab."}),t.jsx(sn,{label:"Edit agent",prompt:Go(location.origin,d.agent_id,!1,ns(d.definition).runtime)}),t.jsx("a",{href:dn(d.agent_id),className:"block text-body underline underline-offset-2",children:"Back to agent"})]}):t.jsx(i6,{agent:d,revisions:y,caps:{...n,computers:L},providerChoices:s,permissionGates:r,mcpServers:F,serverToolSettings:A,onRetryMcp:W,...o?{focusTool:o,step:"tools"}:{},notice:b,validate:e.validateWorkflow,onBack:()=>c("#/agents"),onReload:()=>{O(),W()},onSave:async(U,H)=>{let G;try{if(!d){const J=await e.createAgent(NP({name:U.name??"",description:U.description??"",instructions:U.instructions??"",harness:U.harness??"pi",tools:U.tools??[],approvals:U.approvals,tool_settings:U.tool_settings,thinking:U.thinking,model:U.model,computer:U.computer,learning:U.learning,max_cost_usd:U.max_cost_usd,decisionProvider:n.decisionProvider}));return $.current&&c(dn(J.agent_id,J.kind==="workflow"?"workflow":void 0)),null}const z=Nd(d,U,H);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:V,...se}=z;G=await e.updateDefinition(d.agent_id,se,f)}catch(z){return Ra(z)}return u(G.agent),g(G.etag),N(G.agent.revision),e.getAgent(G.agent.agent_id).then(z=>u(V=>V&&V.revision===z.agent.revision?{...V,tools:z.agent.tools}:V)).catch(()=>{}),_(G.agent.agent_id).then(v).catch(()=>j("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:U=>{d&&K("Make current",()=>e.setCurrent(d.agent_id,U))},onArchive:U=>{d&&K(U?"Archive":"Unarchive",()=>U?e.archiveAgent(d.agent_id):e.unarchiveAgent(d.agent_id))}},`${(d==null?void 0:d.agent_id)??"new"}:${k}`)}function fr(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 p6={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},g6={tool:1,model:1,mcp:2,computer:2,source:2};function sm(e,n){const s=e.split(":"),r=g6[s[0]];return(r===void 0?"":s.slice(r).join(":"))||n||s.slice(1).join(":")}const x6="Sign in with your password to change secrets.",v6="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",b6="Open the console from the server's link to change secrets.",oi={sign_in:x6,no_accounts:v6,token:b6},lE=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,y6=e=>{var n;return((n=lE(e))==null?void 0:n.secrets_writable)===!0};function w6(e){const n=lE(e);return n!=null&&n.secrets_reason?n.secrets_reason:(n==null?void 0:n.accounts)===!1?"no_accounts":"sign_in"}function j6(e){const[n,s]=p.useState({writable:!1,whyNot:"sign_in"});return p.useEffect(()=>{let r=!0;return e.session().then(o=>{r&&s({writable:y6(o),whyNot:w6(o)})},()=>{}),()=>{r=!1}},[e]),n}const k6=2e3,Rx=e=>e instanceof Ue||e instanceof Error?e.message:String(e),yb=({children:e="Manage usage"})=>t.jsx("a",{href:WI,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:e});function N6(){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(yb,{})," in your ChatGPT settings."]}),t.jsx("p",{children:BI})]})}function Ax({v2:e,view:n,onView:s,writable:r=!0,whyNot:o="sign_in",beside:i}){const[c,d]=p.useState(n),[u,f]=p.useState(null),[g,y]=p.useState(!1),[v,h]=p.useState(!1),[x,b]=p.useState(!1),j=p.useRef(null),k=p.useRef(0);p.useEffect(()=>{d(n)},[n]);const E=P=>{d(P),s==null||s(P)},S=c.state==="pending";p.useEffect(()=>{if(!S)return;let P=!1;const R=()=>{if(P||document.visibilityState!=="visible")return;P=!0;const F=++k.current;e.chatGPT().then(I=>{const q=Yf(I);F===k.current&&q&&q.state!=="pending"&&E(q)},()=>{}).finally(()=>{P=!1})},A=setInterval(R,k6),M=()=>{document.visibilityState==="visible"&&R()};return document.addEventListener("visibilitychange",M),()=>{clearInterval(A),document.removeEventListener("visibilitychange",M)}},[e,S]);const N=async()=>{f(null),y(!0);const P=window.open("","_blank");k.current++;try{const R=await e.startChatGPT();P&&(P.opener=null,P.location.href=R.authorize_url),E({state:"pending",authorize_url:R.authorize_url,expires_at:R.expires_at})}catch(R){P==null||P.close(),f(Rx(R))}finally{y(!1)}},$=async P=>{var M;P.preventDefault();const R=(M=j.current)==null?void 0:M.value.trim();if(!R)return;f(null),y(!0),h(!0),k.current++;const A=F=>{j.current&&(j.current.value=""),b(!1),E(F)};try{A(await e.finishChatGPT(R))}catch(F){const I=await e.chatGPT().then(Yf,()=>null);(I==null?void 0:I.state)==="signed_in"?A(I):f(Rx(F))}finally{y(!1),h(!1)}},_=u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u});if(c.state==="signed_in")return t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-body font-semibold",children:JI(c)}),t.jsx(N6,{})]});if(!r)return t.jsx("p",{className:"text-body",role:"status",children:oi[o]});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:g,onClick:()=>void N(),children:"Continue with ChatGPT"}),i]}),_]});const O=fr(c.authorize_url),L=c.expires_at;return t.jsxs("form",{onSubmit:P=>void $(P),autoComplete:"off",className:"space-y-3 border bg-card p-4","aria-label":"Finish signing in with ChatGPT",children:[t.jsx("p",{className:"text-body",children:HI}),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&&L&&" · ",L&&`Waits until ${qa(L)}`]}),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(Pe,{ref:j,name:"redirect_url",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:"127.0.0.1:1455/auth/callback?code=…",onInput:()=>{var P;return b(!!((P=j.current)!=null&&P.value.trim()))}})]}),_,t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!x||g,children:v?"Finishing…":"Finish sign-in"}),t.jsx(B,{type:"button",size:"sm",disabled:g,onClick:()=>void N(),children:"Start again"})]})]})}const S6={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 C6({v2:e,writable:n,whyNot:s,onChange:r}){var b;const[o,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,y]=p.useState(null);if(p.useEffect(()=>{let j=!0;return e.chatGPT().then(k=>{j&&i(Yf(k))},()=>{j&&i(null)}),()=>{j=!1}},[e]),!o)return null;const v=async()=>{y(null);let j;try{j=await e.signOutChatGPT()}catch(k){y(Rx(k));return}d(!1),i({state:"signed_out"}),f(typeof j=="object"&&(j==null?void 0:j.revoked)===!1?{words:j.message||qI,settings:!0}:{words:GI}),r==null||r()},h=j=>{i(j),j.state!=="pending"&&f(null),j.state==="signed_in"&&(r==null||r())},x=S6[o.state];return t.jsxs("li",{"aria-label":"ChatGPT plan",className:"border-b p-4 last:border-b-0",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:"ChatGPT plan"}),t.jsx(Se,{tone:x.tone,children:x.words})]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:dC}),t.jsxs("div",{className:"mt-3 space-y-3",children:[o.state==="expired"&&t.jsx("p",{className:"text-body text-warning-text",children:KI}),o.state==="signed_in"&&((b=o.models)!=null&&b.length)?t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Models: ",o.models.join(" · ")]}):null,t.jsx(Ax,{v2:e,view:o,onView:h,writable:n,whyNot:s}),o.state==="signed_in"&&n&&!c&&t.jsx(B,{size:"sm",onClick:()=>{d(!0),y(null)},children:"Sign out"}),c&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Sign out of ChatGPT on this server? Codex and pi agents then need a key to run here."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void v(),children:"Sign out"}),t.jsx(B,{size:"sm",onClick:()=>d(!1),children:"Keep"})]}),g&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:g}),u&&t.jsxs("p",{className:"text-body",role:"status",children:[u.words,u.settings&&t.jsxs(t.Fragment,{children:[" ",t.jsx(yb,{children:"ChatGPT settings"})]})]})]})]})}function E6(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 cE({harnesses:e,routePrefix:n}){return e.length?t.jsxs("section",{"aria-label":"What runs here",children:[t.jsx("h2",{className:"caps mb-2 text-small font-semibold text-muted-foreground",children:"What runs here"}),t.jsx("ul",{className:"border",children:e.map(s=>{var o;const r=E6(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:Kf(s.id)}),t.jsx(Se,{tone:r.tone,children:r.text}),s.available&&!((o=s.needs)!=null&&o.length)?s.default_model&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:xl(s.default_model,n).text}):s.reason&&t.jsx("span",{className:"text-small text-muted-foreground",children:s.reason})]},s.id)})})]}):null}const ff=(e,n,s)=>{if(!/^\d{1,2}$/.test(e))return null;const r=Number(e);return r>=n&&r<=s?r:null};function $6(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const[s,r,o,i,c]=n,d=ff(s,0,59);if(d===null||i!=="*")return null;if(r==="*")return o==="*"&&c==="*"?{kind:"hourly",minute:d}:null;const u=ff(r,0,23);if(u===null)return null;const f={hour:u,minute:d};if(o==="*"&&c==="*")return{kind:"daily",at:f};if(o==="*"&&c==="1-5")return{kind:"weekdays",at:f};if(o==="*"){const g=ff(c,0,6);return g===null?null:{kind:"weekly",day:g,at:f}}if(c==="*"){const g=ff(o,1,31);return g===null?null:{kind:"monthly",date:g,at:f}}return null}function _6(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 T6(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 A0=e=>String(e).padStart(2,"0"),R6=e=>`${A0(e.hour)}:${A0(e.minute)}`;function A6(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 Mg={exports:{}},O0;function O6(){return O0||(O0=1,(function(e,n){(function(r,o){e.exports=o()})(globalThis,()=>(()=>{var s={6949(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.CronParser=void 0;var f=u(9515),g=(function(){function y(v,h,x){h===void 0&&(h=!0),x===void 0&&(x=!1),this.expression=v,this.dayOfWeekStartIndexZero=h,this.monthStartIndexZero=x}return y.prototype.parse=function(){var v,h,x=(v=this.expression)!==null&&v!==void 0?v:"";if(x==="@reboot")return h=["@reboot","","","","","",""],h;if(x.startsWith("@")){var b=this.parseSpecial(this.expression);h=this.extractParts(b)}else h=this.extractParts(this.expression);return this.normalize(h),this.validate(h),h},y.prototype.parseSpecial=function(v){var h={"@yearly":"0 0 1 JAN *","@annually":"0 0 1 JAN *","@monthly":"0 0 1 * *","@weekly":"0 0 * * SUN","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},x=h[v];if(!x)throw new Error("Unknown special expression.");return x},y.prototype.extractParts=function(v){if(!this.expression)throw new Error("cron expression is empty");for(var h=v.trim().split(/[ ]+/),x=0;x<h.length;x++)if(h[x].includes(",")){var b=h[x].split(",").map(function(k){return k.trim()}).filter(function(k){return k!==""}).map(function(k){return isNaN(Number(k))?k:Number(k)}).filter(function(k){return k!==null&&k!==""});b.length===0&&b.push("*"),b.sort(function(k,E){return k!==null&&E!==null?k-E:0}),h[x]=b.map(function(k){return k!==null?k.toString():""}).join(",")}if(h.length<5)throw new Error("Expression has only ".concat(h.length," part").concat(h.length==1?"":"s",". At least 5 parts are required."));if(h.length==5)h.unshift(""),h.push("");else if(h.length==6){var j=/\d{4}$/.test(h[5])||h[4]=="?"||h[2]=="?";j?h.unshift(""):h.push("")}else if(h.length>7)throw new Error("Expression has ".concat(h.length," parts; too many!"));return h},y.prototype.normalize=function(v){var h=this;v[3]=v[3].replace("?","*"),v[5]=v[5].replace("?","*"),v[2]=v[2].replace("?","*"),v[0].indexOf("0/")==0&&(v[0]=v[0].replace("0/","*/")),v[1].indexOf("0/")==0&&(v[1]=v[1].replace("0/","*/")),v[2].indexOf("0/")==0&&(v[2]=v[2].replace("0/","*/")),v[3].indexOf("1/")==0&&(v[3]=v[3].replace("1/","*/")),!this.monthStartIndexZero&&v[4].indexOf("1/")==0&&(v[4]=v[4].replace("1/","*/")),v[6].indexOf("1/")==0&&(v[6]=v[6].replace("1/","*/")),v[5]=v[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,function(_){var O=_.replace(/\D/,""),L=O;return h.dayOfWeekStartIndexZero?O=="7"&&(L="0"):L=(parseInt(O)-1).toString(),_.replace(O,L)}),v[5]=="L"&&(v[5]="6"),v[3]=="?"&&(v[3]="*");var x=/^\d{1,2}W[+-]\d{1,2}$/;if(v[3].indexOf("W")>-1&&(v[3].indexOf(",")>-1||/[-+]/.test(v[3]))&&!x.test(v[3]))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var b={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var j in b)v[5]=v[5].replace(new RegExp(j,"gi"),b[j].toString());v[4]=v[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,function(_){var O=_.replace(/\D/,""),L=O;return h.monthStartIndexZero&&(L=(parseInt(O)+1).toString()),_.replace(O,L)});var k={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var E in k)v[4]=v[4].replace(new RegExp(E,"gi"),k[E].toString());v[0]=="0"&&(v[0]=""),!/\*|\-|\,|\//.test(v[2])&&(/\*|\//.test(v[1])||/\*|\//.test(v[0]))&&(v[2]+="-".concat(v[2]));for(var S=0;S<v.length;S++)if(v[S].indexOf(",")!=-1&&(v[S]=v[S].split(",").filter(function(_){return _!==""}).join(",")||"*"),v[S]=="*/1"&&(v[S]="*"),v[S].indexOf("/")>-1&&!/^\*|\-|\,/.test(v[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 $=v[S].split("/");v[S]="".concat($[0],"-").concat(N,"/").concat($[1])}}},y.prototype.validate=function(v){var h="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(v[0],h),this.validateOnlyExpectedCharactersFound(v[1],h),this.validateOnlyExpectedCharactersFound(v[2],h),this.validateOnlyExpectedCharactersFound(v[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(v[4],h),this.validateOnlyExpectedCharactersFound(v[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(v[6],h),this.validateAnyRanges(v)},y.prototype.validateAnyRanges=function(v){v.forEach(function(h){return f.default.stepRange(h)}),f.default.secondRange(v[0]),f.default.minuteRange(v[1]),f.default.hourRange(v[2]),f.default.dayOfMonthRange(v[3]),f.default.monthRange(v[4],this.monthStartIndexZero),f.default.dayOfWeekRange(v[5],this.dayOfWeekStartIndexZero)},y.prototype.validateOnlyExpectedCharactersFound=function(v,h){var x=v.match(new RegExp("[^".concat(h,"]+"),"gi"));if(x&&x.length)throw new Error("Expression contains invalid values: '".concat(x.toString(),"'"))},y})();d.CronParser=g},8333(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.ExpressionDescriptor=void 0;var f=u(1823),g=u(6949),y=(function(){function v(h,x){if(this.expression=h,this.options=x,this.expressionParts=new Array(5),!this.options.locale&&v.defaultLocale&&(this.options.locale=v.defaultLocale),!v.locales[this.options.locale]){var b=Object.keys(v.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(b,"'.")),this.options.locale=b}this.i18n=v.locales[this.options.locale],x.use24HourTimeFormat===void 0&&(x.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return v.toString=function(h,x){var b=x===void 0?{}:x,j=b.throwExceptionOnParseError,k=j===void 0?!0:j,E=b.verbose,S=E===void 0?!1:E,N=b.dayOfWeekStartIndexZero,$=N===void 0?!0:N,_=b.monthStartIndexZero,O=_===void 0?!1:_,L=b.use24HourTimeFormat,P=b.trimHoursLeadingZero,R=P===void 0?!1:P,A=b.locale,M=A===void 0?null:A,F=b.logicalAndDayFields,I=F===void 0?!1:F,q={throwExceptionOnParseError:k,verbose:S,dayOfWeekStartIndexZero:$,monthStartIndexZero:O,use24HourTimeFormat:L,trimHoursLeadingZero:R,locale:M,logicalAndDayFields:I};q.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var W=new v(h,q);return W.getFullDescription()},v.initialize=function(h,x){x===void 0&&(x="en"),v.specialCharacters=["/","-",",","*"],v.defaultLocale=x,h.load(v.locales)},v.prototype.getFullDescription=function(){var h,x,b="";try{var j=new g.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=j.parse(),this.expressionParts[0]==="@reboot")return((x=(h=this.i18n).atReboot)===null||x===void 0?void 0:x.call(h))||"Run once, at startup";var k=this.getTimeOfDayDescription(),E=this.getDayOfMonthDescription(),S=this.getMonthDescription(),N=this.getDayOfWeekDescription(),$=this.getYearDescription();b+=k+E+N+S+$,b=this.transformVerbosity(b,!!this.options.verbose),b=b.charAt(0).toLocaleUpperCase()+b.substr(1)}catch(_){if(!this.options.throwExceptionOnParseError)b=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(_)}return b},v.prototype.getTimeOfDayDescription=function(){var h=this.expressionParts[0],x=this.expressionParts[1],b=this.expressionParts[2],j="";if(!f.StringUtilities.containsAny(x,v.specialCharacters)&&!f.StringUtilities.containsAny(b,v.specialCharacters)&&!f.StringUtilities.containsAny(h,v.specialCharacters))j+=this.i18n.atSpace()+this.formatTime(b,x,h);else if(!h&&x.indexOf("-")>-1&&!(x.indexOf(",")>-1)&&!(x.indexOf("/")>-1)&&!f.StringUtilities.containsAny(b,v.specialCharacters)){var k=x.split("-");j+=f.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(b,k[0],""),this.formatTime(b,k[1],""))}else if(!h&&b.indexOf(",")>-1&&b.indexOf("-")==-1&&b.indexOf("/")==-1&&!f.StringUtilities.containsAny(x,v.specialCharacters)){var E=b.split(",");j+=this.i18n.at();for(var S=0;S<E.length;S++)j&&(j+=" "),j+=this.formatTime(E[S],x,""),S<E.length-2&&(j+=","),S==E.length-2&&(j+=this.i18n.spaceAnd())}else{var N=this.getSecondsDescription(),$=this.getMinutesDescription(),_=this.getHoursDescription();if(j+=N,j&&$&&(j+=", "),j+=$,$===_)return j;j&&_&&(j+=", "),j+=_}return j},v.prototype.getSecondsDescription=function(){var h=this,x=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(b){return b},function(b){return f.StringUtilities.format(h.i18n.everyX0Seconds(b),b)},function(b){return h.i18n.secondsX0ThroughX1PastTheMinute()},function(b){return b=="0"?"":parseInt(b)<20?h.i18n.atX0SecondsPastTheMinute(b):h.i18n.atX0SecondsPastTheMinuteGt20()||h.i18n.atX0SecondsPastTheMinute(b)},{min:0,max:59});return x},v.prototype.getMinutesDescription=function(){var h=this,x=this.expressionParts[0],b=this.expressionParts[2],j=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(k){return k},function(k){return f.StringUtilities.format(h.i18n.everyX0Minutes(k),k)},function(k){return h.i18n.minutesX0ThroughX1PastTheHour()},function(k){var E,S;try{return k=="0"&&b.indexOf("/")==-1&&x==""?h.i18n.everyHour():k=="0"?((S=(E=h.i18n).onTheHour)===null||S===void 0?void 0:S.call(E))||h.i18n.atX0MinutesPastTheHour(k):parseInt(k)<20?h.i18n.atX0MinutesPastTheHour(k):h.i18n.atX0MinutesPastTheHourGt20()||h.i18n.atX0MinutesPastTheHour(k)}catch{return h.i18n.atX0MinutesPastTheHour(k)}},{min:0,max:59});return j},v.prototype.getHoursDescription=function(){var h=this,x=this.expressionParts[2],b=0,j=[];x.split("/")[0].split(",").forEach(function(S){var N=S.split("-");N.length===2&&j.push({value:N[1],index:b+1}),b+=N.length});var k=0,E=this.getSegmentDescription(x,this.i18n.everyHour(),function(S){var N=j.find(function(_){return _.value===S&&_.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 E},v.prototype.getDayOfWeekDescription=function(){var h=this,x=this.i18n.daysOfTheWeek(),b=null;return this.expressionParts[5]=="*"?b="":b=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(j,k){var E=j;j.indexOf("#")>-1?E=j.substring(0,j.indexOf("#")):j.indexOf("L")>-1&&(E=E.replace("L",""));var S=parseInt(E),N=h.i18n.daysOfTheWeekInCase?h.i18n.daysOfTheWeekInCase(k)[S]:x[S];if(j.indexOf("#")>-1){var $=null,_=j.substring(j.indexOf("#")+1),O=j.substring(0,j.indexOf("#"));switch(_){case"1":$=h.i18n.first(O);break;case"2":$=h.i18n.second(O);break;case"3":$=h.i18n.third(O);break;case"4":$=h.i18n.fourth(O);break;case"5":$=h.i18n.fifth(O);break}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("-")),E=h.expressionParts[3]!="*";return E?h.i18n.commaAndX0ThroughX1(k):h.i18n.commaX0ThroughX1(k)},function(j){var k=null;if(j.indexOf("#")>-1){var E=j.substring(j.indexOf("#")+1),S=j.substring(0,j.indexOf("#"));k=h.i18n.commaOnThe(E,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}),b},v.prototype.getMonthDescription=function(){var h=this,x=this.i18n.monthsOfTheYear(),b=this.getSegmentDescription(this.expressionParts[4],"",function(j,k){return k&&h.i18n.monthsOfTheYearInCase?h.i18n.monthsOfTheYearInCase(k)[parseInt(j)-1]:x[parseInt(j)-1]},function(j){return parseInt(j)==1?"":f.StringUtilities.format(h.i18n.commaEveryX0Months(j),j)},function(j){return h.i18n.commaMonthX0ThroughMonthX1()||h.i18n.commaX0ThroughX1()},function(j){return h.i18n.commaOnlyInMonthX0?h.i18n.commaOnlyInMonthX0():h.i18n.commaOnlyInX0()});return b},v.prototype.getDayOfMonthDescription=function(){var h=this,x,b,j,k,E=null,S=this.expressionParts[3];switch(S){case"L":E=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":E=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]),_=$==1?this.i18n.firstWeekday():f.StringUtilities.format(this.i18n.weekdayNearestDayX0(),$.toString()),O=N[4];O?N[3]=="-"?E=f.StringUtilities.format(((b=(x=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||b===void 0?void 0:b.call(x,O))||", %s days before the %s of the month",O,_):E=f.StringUtilities.format(((k=(j=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||k===void 0?void 0:k.call(j,O))||", %s days after the %s of the month",O,_):E=f.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),_);break}else{var L=S.match(/L-(\d{1,2})/);if(L){var P=L[1];E=f.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(P),P);break}else{if(S=="*"&&this.expressionParts[5]!="*")return"";E=this.getSegmentDescription(S,this.i18n.commaEveryDay(),function(R){return R=="L"?h.i18n.lastDay():h.i18n.dayX0?f.StringUtilities.format(h.i18n.dayX0(),R):R},function(R){return R=="1"?h.i18n.commaEveryDay():h.i18n.commaEveryX0Days(R)},function(R){return h.i18n.commaBetweenDayX0AndX1OfTheMonth(R)},function(R){return h.i18n.commaOnDayX0OfTheMonth(R)})}break}}return E},v.prototype.getYearDescription=function(){var h=this,x=this.getSegmentDescription(this.expressionParts[6],"",function(b){return/^\d+$/.test(b)?new Date(parseInt(b),1).getFullYear().toString():b},function(b){return f.StringUtilities.format(h.i18n.commaEveryX0Years(b),b)},function(b){return h.i18n.commaYearX0ThroughYearX1()||h.i18n.commaX0ThroughX1()},function(b){return h.i18n.commaOnlyInYearX0?h.i18n.commaOnlyInYearX0():h.i18n.commaOnlyInX0()});return x},v.prototype.getSegmentDescription=function(h,x,b,j,k,E,S){var N=null,$=h.indexOf("/")>-1,_=h.indexOf("-")>-1,O=h.indexOf(",")>-1;if(!h)N="";else if(h==="*")N=x;else if(!$&&!_&&!O)N=f.StringUtilities.format(E(h),b(h));else if(O){for(var L=h.split(","),P="",R=this.i18n.spaceAnd(),A=0;A<L.length;A++)if(A>0&&L.length>2&&(P+=",",A<L.length-1&&(P+=" ")),A>0&&L.length>1&&(A==L.length-1||L.length==2)&&(P+=R==","&&L.length>2?" ":"".concat(R," ")),L[A].indexOf("/")>-1||L[A].indexOf("-")>-1){var M=L[A].indexOf("-")>-1&&L[A].indexOf("/")==-1,F=this.getSegmentDescription(L[A],x,b,j,M?this.i18n.commaX0ThroughX1:k,E);M?F=F.replace(", ",""):A>0&&F.startsWith(", ")&&(F=F.substring(2)),P+=F}else if(!$)P+=b(L[A]);else{var I=this.getSegmentDescription(L[A],x,b,j,k,E);A>0&&I&&I.startsWith(", ")&&(I=I.substring(2)),P+=I}$?N=P:N=f.StringUtilities.format(E(h),P)}else if($){var L=h.split("/");if(N=f.StringUtilities.format(j(L[1]),L[1]),L[0].indexOf("-")>-1){var q=this.generateRangeSegmentDescription(L[0],k,b);q.indexOf(", ")!=0&&(N+=", "),N+=q}else if(L[0].indexOf("*")==-1){var W=f.StringUtilities.format(E(L[0]),b(L[0]));W=W.replace(", ",""),N+=f.StringUtilities.format(this.i18n.commaStartingX0(),W)}N+=this.getWrappingIncrementDescription(h,S,x,b,j,k,E)}else _&&(N=this.generateRangeSegmentDescription(h,k,b));return N},v.prototype.getWrappingIncrementDescription=function(h,x,b,j,k,E,S){if(!this.options.verbose||!x)return"";var N=h.split("/"),$=N[0],_=N[1],O=parseInt(_),L=x.max-x.min+1,P=$==="*",R=Number.isInteger(O)&&O>1,A=R&&L%O===0;if(!P||!R||A)return"";for(var M=[],F=x.min;F<=x.max;F+=O)M.push(F);if(M.length<2)return"";var I=this.getSegmentDescription(M.join(","),b,j,k,E,S);return I?", ".concat(I):""},v.prototype.generateRangeSegmentDescription=function(h,x,b){var j="",k=h.split("-"),E=b(k[0],1),S=b(k[1],2),N=x(h);return j+=f.StringUtilities.format(N,E,S),j},v.prototype.formatTime=function(h,x,b){var j=0,k=0,E=parseInt(h)+j,S=parseInt(x)+k;S>=60?(S-=60,E+=1):S<0&&(S+=60,E-=1),E>=24?E=E-24:E<0&&(E=24+E);var N="",$=!1;this.options.use24HourTimeFormat||($=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),N=$?"".concat(this.getPeriod(E)," "):" ".concat(this.getPeriod(E)),E>12&&(E-=12),E===0&&(E=12));var _="";b&&(_=":".concat(("00"+b).substring(b.length)));var O=E.toString(),L=("00"+O).substring(O.length),P=S.toString(),R=("00"+P).substring(P.length),A=this.options.trimHoursLeadingZero?O:L;return"".concat($?N:"").concat(A,":").concat(R).concat(_).concat($?"":N)},v.prototype.transformVerbosity=function(h,x){if(!x&&(h=h.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),h=h.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),h=h.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),h=h.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var b=0,j=Object.entries(this.i18n.conciseVerbosityReplacements());b<j.length;b++){var k=j[b],E=k[0],S=k[1];h=h.replace(new RegExp(E,"g"),S)}return h},v.prototype.getPeriod=function(h){return h>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},v.locales={},v})();d.ExpressionDescriptor=y},3747(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.enLocaleLoader=void 0;var f=u(9486),g=(function(){function y(){}return y.prototype.load=function(v){v.en=new f.en},y})();d.enLocaleLoader=g},9486(c,d){Object.defineProperty(d,"__esModule",{value:!0}),d.en=void 0;var u=function(g){return Number(g)===1},f=(function(){function g(){}return g.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},g.prototype.atX0MinutesPastTheHourGt20=function(){return null},g.prototype.commaMonthX0ThroughMonthX1=function(){return null},g.prototype.commaYearX0ThroughYearX1=function(){return null},g.prototype.use24HourTimeFormatByDefault=function(){return!1},g.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},g.prototype.everyMinute=function(){return"every minute"},g.prototype.everyHour=function(){return"every hour"},g.prototype.atSpace=function(){return"At "},g.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},g.prototype.at=function(){return"At"},g.prototype.spaceAnd=function(){return" and"},g.prototype.everySecond=function(){return"every second"},g.prototype.everyX0Seconds=function(y){return u(y)?"every %s second":"every %s seconds"},g.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},g.prototype.atX0SecondsPastTheMinute=function(y){return u(y)?"at %s second past the minute":"at %s seconds past the minute"},g.prototype.everyX0Minutes=function(y){return u(y)?"every %s minute":"every %s minutes"},g.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},g.prototype.atX0MinutesPastTheHour=function(y){return u(y)?"at %s minute past the hour":"at %s minutes past the hour"},g.prototype.everyX0Hours=function(y){return u(y)?"every %s hour":"every %s hours"},g.prototype.betweenX0AndX1=function(){return"between %s and %s"},g.prototype.atX0=function(){return"at %s"},g.prototype.commaEveryDay=function(){return", every day"},g.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},g.prototype.commaX0ThroughX1=function(){return", %s through %s"},g.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},g.prototype.first=function(){return"first"},g.prototype.second=function(){return"second"},g.prototype.third=function(){return"third"},g.prototype.fourth=function(){return"fourth"},g.prototype.fifth=function(){return"fifth"},g.prototype.commaOnThe=function(){return", on the "},g.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},g.prototype.lastDay=function(){return"the last day"},g.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},g.prototype.commaOnlyOnX0=function(){return", only on %s"},g.prototype.commaAndOnX0=function(){return", and on %s"},g.prototype.commaEveryX0Months=function(){return", every %s months"},g.prototype.commaOnlyInX0=function(){return", only in %s"},g.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},g.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},g.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(y){return u(y)?", %s day before the last day of the month":", %s days before the last day of the month"},g.prototype.firstWeekday=function(){return"first weekday"},g.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},g.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},g.prototype.commaDaysBeforeTheX0OfTheMonth=function(y){return u(y)?", %s day before the %s of the month":", %s days before the %s of the month"},g.prototype.commaDaysAfterTheX0OfTheMonth=function(y){return u(y)?", %s day after the %s of the month":", %s days after the %s of the month"},g.prototype.commaEveryX0Days=function(){return", every %s days in a month"},g.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},g.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},g.prototype.commaEveryHour=function(){return", every hour"},g.prototype.commaEveryX0Years=function(y){return u(y)?", every %s year":", every %s years"},g.prototype.commaStartingX0=function(){return", starting %s"},g.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},g.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},g.prototype.atReboot=function(){return"Run once, at startup"},g.prototype.onTheHour=function(){return"on the hour"},g})();d.en=f},9515(c,d){Object.defineProperty(d,"__esModule",{value:!0});function u(y,v){if(!y)throw new Error(v)}function f(y){var v=[];if(!isNaN(parseInt(y,10))){v.push(parseInt(y,10));var h=y.match(/^\d+-(-?\d+)/);h&&v.push(parseInt(h[1],10))}return v}var g=(function(){function y(){}return y.stepRange=function(v){for(var h=v.split(","),x=0;x<h.length;x++){var b=h[x].split("/")[1];u(b===void 0||!/^0+$/.test(b),"step value must be greater than 0")}},y.secondRange=function(v){for(var h=v.split(","),x=0;x<h.length;x++)for(var b=0,j=f(h[x]);b<j.length;b++){var k=j[b];u(k>=0&&k<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(v){for(var h=v.split(","),x=0;x<h.length;x++)for(var b=0,j=f(h[x]);b<j.length;b++){var k=j[b];u(k>=0&&k<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(v){for(var h=v.split(","),x=0;x<h.length;x++)for(var b=0,j=f(h[x]);b<j.length;b++){var k=j[b];u(k>=0&&k<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(v){for(var h=v.split(","),x=0;x<h.length;x++)for(var b=0,j=f(h[x]);b<j.length;b++){var k=j[b];u(k>=1&&k<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(v,h){for(var x=v.split(","),b=0;b<x.length;b++)for(var j=0,k=f(x[b]);j<k.length;j++){var E=k[j];u(E>=1&&E<=12,h?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(v,h){for(var x=v.split(","),b=0;b<x.length;b++){if(x[b].indexOf("#")>-1){var j=x[b].substring(x[b].indexOf("#")+1);u(/^[1-5]$/.test(j),"DOW nth weekday must be >= 1 and <= 5")}for(var k=0,E=f(x[b]);k<E.length;k++){var S=E[k];u(S>=0&&S<=6,h?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}}},y})();d.default=g},1823(c,d){Object.defineProperty(d,"__esModule",{value:!0}),d.StringUtilities=void 0;var u=(function(){function f(){}return f.format=function(g){for(var y=[],v=1;v<arguments.length;v++)y[v-1]=arguments[v];return g.replace(/%s/g,function(h){return y.shift()})},f.containsAny=function(g,y){return y.some(function(v){return g.indexOf(v)>-1})},f})();d.StringUtilities=u}},r={};function o(c){var d=r[c];if(d!==void 0)return d.exports;var u=r[c]={exports:{}};return s[c](u,u.exports,o),u.exports}var i={};return(()=>{var c=i;Object.defineProperty(c,"__esModule",{value:!0}),c.toString=void 0;var d=o(8333),u=o(3747);d.ExpressionDescriptor.initialize(new u.enLocaleLoader),c.default=d.ExpressionDescriptor;var f=d.ExpressionDescriptor.toString;c.toString=f})(),i})())})(Mg)),Mg.exports}var L6=O6();const M6=MN(L6),Ld={rules:20,conditions:20,list:20,pointer:512,text:200,value:1024},Cn=Ld,dE={in:"is one of",prefix:"starts with",exists:"exists",missing:"is missing"},P6=Object.keys(dE);let I6=0;const rh=()=>`r${++I6}`,z6=()=>({key:rh(),pointer:"",op:"in",value:""}),uE=()=>({key:rh(),event:"",actions:"",where:[]});function fE(e){const n=e.trim();try{return JSON.parse(n)}catch{return n}}function mE(e){return typeof e!="string"?JSON.stringify(e):e!==""&&e===e.trim()&&!/[,\r\n]/.test(e)&&fE(e)===e?e:JSON.stringify(e)}const D6=e=>"in"in e?`${e.pointer} is one of ${e.in.map(mE).join(", ")}`:"exists"in e?`${e.pointer} ${e.exists?"exists":"is missing"}`:`${e.pointer} starts with ${JSON.stringify(e.prefix)}`,Uo=(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(D6).join(" and ")}`:""}`};function hE(e){return"in"in e?{pointer:e.pointer,op:"in",value:e.in.map(mE).join(`
|
|
658
|
-
`)}:"exists"in e?{pointer:e.pointer,op:e.exists?"exists":"missing",value:""}:{pointer:e.pointer,op:"prefix",value:e.prefix}}const pE=e=>({key:rh(),...hE(e),was:e}),gE=e=>{if(!e.was)return!1;const n=hE(e.was);return n.pointer===e.pointer&&n.op===e.op&&n.value===e.value},xE=e=>(e??[]).join(", "),rm=e=>({key:rh(),event:e.event,actions:xE(e.actions),where:(e.where??[]).map(pE),was:e}),F6=(e,n)=>e.length===n.length&&e.every((s,r)=>s===n[r]),U6=e=>e.split(/[\s,]+/).filter(Boolean),L0=/^[!-~]+$/,Uc=e=>[...e].length,W6=/^(\/([^~]|~[01])*)?$/;function H6(e,n,s){return e.length>Cn.conditions&&(s[`${n}.where`]=`At most ${Cn.conditions} conditions a rule.`),e.map((r,o)=>{if(gE(r))return r.was;const i=`${n}.where[${o}]`,c=r.pointer;if(c?c.startsWith("/")?W6.test(c)?Uc(c)>Cn.pointer&&(s[`${i}.pointer`]=`At most ${Cn.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?Uc(u)>Cn.text&&(s[`${i}.prefix`]=`At most ${Cn.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(fE);return d.length?d.length>Cn.list?s[`${i}.in`]=`At most ${Cn.list} values.`:d.some(u=>Uc(JSON.stringify(u))>Cn.value)&&(s[`${i}.in`]=`Each value is at most ${Cn.value} characters.`):s[`${i}.in`]="Give at least one value, one a line.",{pointer:c,in:d}})}function B6(e,n,s){var g;const r=`source.accept[${n}]`,o=e.was,i=o&&e.event===o.event?o.event:e.event.trim();i?i!==(o==null?void 0:o.event)&&(!L0.test(i)||Uc(i)>Cn.text)&&(s[`${r}.event`]=`An event's name has no spaces: printable characters only, at most ${Cn.text}.`):s[`${r}.event`]="Name the event.";const c=o&&(typeof e.actions=="string"?e.actions===xE(o.actions):F6(e.actions,o.actions??[])),d=c?[...o.actions??[]]:typeof e.actions=="string"?U6(e.actions):e.actions;if(o&&c&&i===o.event&&e.where.length===(((g=o.where)==null?void 0:g.length)??0)&&e.where.every((y,v)=>gE(y)&&y.was===o.where[v]))return o;d.length>Cn.list?s[`${r}.actions`]=`At most ${Cn.list} actions.`:d.some(y=>!L0.test(y)||Uc(y)>Cn.text)&&(s[`${r}.actions`]=`An action's name is printable characters, at most ${Cn.text}.`);const f=H6(e.where,r,s);return{event:i,...d.length?{actions:d}:{},...f.length?{where:f}:{}}}function wb(e){const n={};return e.length>Cn.rules&&(n["source.accept"]=`At most ${Cn.rules} rules.`),{accept:e.map((s,r)=>B6(s,r,n)),issues:n}}function Md(e){const n=new Set(["source.accept"]);return e.forEach((s,r)=>{const o=`source.accept[${r}]`;for(const i of["",".event",".actions",".where"])n.add(`${o}${i}`);for(let i=0;i<s;i++)for(const c of["",".pointer",".in",".prefix",".exists"])n.add(`${o}.where[${i}]${c}`)}),n}const Ki=(e,n)=>n&&e===Lx(n)?n:t8(e),Ol=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",vE=(e="")=>({name:"",kind:"cron",cron:"",timezone:Ol(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),oh={seconds:1,minutes:60,hours:3600};function jb(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 bE(e){try{return M6.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const Aa=e=>String(e).padStart(2,"0"),om=(e,n)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:n});function yE(e,n){const s=i=>{var c;return((c=new Intl.DateTimeFormat(i,{timeZone:n,timeZoneName:"short"}).formatToParts(e).find(d=>d.type==="timeZoneName"))==null?void 0:c.value)??n},r=s("en-US");if(!/^GMT[+-]/.test(r))return r;const o=s("en-GB");return/^GMT[+-]/.test(o)?r:o}const M0=(e,n)=>{const s=new Date(e);return`${s.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:n}).replace(",","")}, ${om(s,n)} ${yE(s,n)}`};function P0(e,{zone:n=Ol(),now:s=Date.now()}={}){const r=new Date(e),o=c=>c.toLocaleDateString("en-US",{year:"numeric",month:"numeric",day:"numeric",timeZone:n});return`Pick a time in the future: ${o(r)===o(new Date(s))?`${om(r,n)} today`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:n})}, ${om(r,n)} ${yE(r,n)}`} has already passed.`}function am(e,n){const s={};for(const{type:r,value:o}of new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).formatToParts(e))s[r]=o;return Date.UTC(Number(s.year),Number(s.month)-1,Number(s.day),Number(s.hour),Number(s.minute))}function G6(e,n,s,r){const o=new Date(am(e,n)),i=Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),s,r);let c=i;for(let d=0;d<2;d++)c+=i-am(new Date(c),n);return new Date(c)}const q6=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 K6(e,n,s,r,o){const i=bE(e),c=n!==s,d=q6(e),u=d&&`At ${Aa(d.hour)}:${Aa(d.minute)}`;if(d&&u&&i.startsWith(u))try{const f=r??G6(o,n,d.hour,d.minute),g=d.days?Math.floor(am(f,s)/864e5)-Math.floor(am(f,n)/864e5):0,y=g>0?" the next day":g<0?" the day before":"";return`At ${om(f,s)} your time${y}${c?` (${u.slice(3)} ${n})`:""}${i.slice(u.length)}`}catch{}return`${i}${c?` (${n})`:""}`}function kb(e,n,{zone:s=Ol(),instead:r,now:o=Date.now()}={}){const i=r?` · ${r}`:n?` · next ${M0(n,s)}`:" · no next time";return"cron"in e?`${K6(e.cron,e.timezone,s,n?new Date(n):null,new Date(o))}${i}`:"at"in e?`Once, ${M0(e.at,s)}${!r&&n&&Date.parse(n)===Date.parse(e.at)?"":i}`:`Every ${jb(e.every_s)}${i}`}const oa=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,V6=e=>`${oa(e)} a run`,Y6=(e,n)=>typeof e=="number"?V6(e):typeof n=="number"&&n>0?`Agent's default (${oa(n)})`:"Agent's default";function Nb(e,n,s=[]){if(e.source.kind!=="schedule"||!("at"in e.source)||e.next_at!==null)return null;const r=Date.parse(e.source.at);if(r>n)return null;const o=[e.last_firing,...s].find(i=>i&&i.status==="started"&&Date.parse(i.nominal_at)===r);return o?{ran:o}:{passed:e.source.at}}const Sb=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",Cb=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",wE=e=>e.source.kind==="github"&&e.target.kind==="start_run",ah=[{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"}],nd=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,Eb="This server's address as this page sees it: behind a proxy, use its public address.",Ox={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)"},jE=e=>{var n;return(n=e.accept)!=null&&n.length?`Only signed requests for ${e.accept.map(s=>Uo(s,!1)).join(" or ")}`:"On each signed request"},Q6={schedule:"On schedule",manual:"Run now",webhook:"On a request",github:"On a GitHub event",composio:"On an app event",email:"On an email",feed:"On a feed item"},kE=e=>`On ${e.event} from ${e.server}`,J6=e=>{var n;return(n=e.accept)!=null&&n.length?`On email in ${e.mailbox} for ${e.accept.map(s=>Uo(s,!1)).join(" or ")}`:`On each email in ${e.mailbox}`},NE=e=>{var s;const n=e.urls.length===1?X6(e.urls[0]):`${e.urls.length} feeds`;return(s=e.accept)!=null&&s.length?`On items in ${n} for ${e.accept.map(r=>Uo(r,!1)).join(" or ")}`:`On each new item in ${n}`},X6=e=>{try{return new URL(e).host}catch{return e}},SE=e=>`On GitHub ${e.accept.map(n=>Uo(n,!1)).join(" or ")}`;function im(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 CE(e){var s;const n=(r,o)=>o?`${r}: ${o}`:r;switch(e.status){case"started":return"Started";case"skipped":return n("Skipped",e.reason);case"missed":return n(`Missed ${e.count??1} ${e.count===1||e.count===void 0?"time":"times"}`,e.reason);case"failed":return n("Failed",((s=e.error)==null?void 0:s.message)??e.reason);case"due":return e.retry_at?`Due: the server was full, tries again at ${qa(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const Z6={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},e8=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function t8(e){if(!e8.test(e))return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toISOString().replace(/\.\d{3}Z$/,"Z")}function Lx(e){const n=new Date(e);return`${n.getFullYear()}-${Aa(n.getMonth()+1)}-${Aa(n.getDate())}T${Aa(n.getHours())}:${Aa(n.getMinutes())}${n.getSeconds()?`:${Aa(n.getSeconds())}`:""}`}const I0=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function $b(e){const n=jb(e);return/^\d/.test(n)?`At least ${n}.`:`At least ${n==="hour"?"an":"a"} ${n}.`}const sd="A number is needed.",rd=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function z0(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()||Ol()};else if(e.kind==="at"){const d=Ki(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=rd(e.every);e.every.trim()?d===void 0&&(s["source.every_s"]=sd):s["source.every_s"]="A number is needed.";const u=e.startAt?Ki(e.startAt,(c=e.read)==null?void 0:c.startAt):null;r={kind:"schedule",every_s:Math.round((d??0)*oh[e.everyUnit]),...u?{start_at:u}:{}}}e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const o=rd(e.maxCost);return e.maxCost.trim()?o===void 0&&(s["target.max_cost_usd"]=sd):n||(s["target.max_cost_usd"]="A cost cap is needed: every run a schedule starts is capped."),Object.keys(s).length?{issues:s}:{body:{...e.name.trim()?{name:e.name.trim()}:{},enabled:e.enabled,source:r,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...o!==void 0?{max_cost_usd:o}:{}}}}}const n8=()=>({name:"",signature:"standard",accept:[],agentId:"",content:"",maxCost:""});function EE(e,n){const{accept:s,issues:r}=wb(n);return{source:{kind:"webhook",...e.signature!==void 0?{signature:e.signature}:{},...s.length?{accept:s}:{}},issues:r}}function s8(e,n=!1){const{source:s,issues:r}=EE({signature:e.signature},e.accept);return lh(e,s,r,n,"a webhook")}const r8=()=>({name:"",events:["pull_request:opened"],where:{},other:[],agentId:"",content:"",maxCost:""}),$E=[...new Set(ah.map(e=>e.event))],o8=(e,n)=>e.length===n.length&&e.every(s=>n.includes(s));function ih(e){var i;const s=[...$E.flatMap(c=>{var f;const d=ah.filter(g=>g.event===c&&e.events.includes(`${g.event}:${g.action}`)).map(g=>g.action);if(!d.length)return[];const u=(f=e.read)==null?void 0:f.rules[c];return[{id:`event:${c}`,event:c,actions:u!=null&&u.actions&&o8(d,u.actions)?[...u.actions]:d,where:e.where[c]??[],...u?{was:u}:{}}]}),...e.other.map(c=>({...c,id:`other:${c.key}`}))],r=((i=e.read)==null?void 0:i.order)??[],o=c=>{const d=r.indexOf(c.id);return d<0?r.length:d};return s.map((c,d)=>({r:c,i:d})).sort((c,d)=>o(c.r)-o(d.r)||c.i-d.i).map(({r:c})=>c)}function _E(e){const{accept:n,issues:s}=wb(ih(e));return n.length||(s["source.accept"]="Pick at least one event."),{source:{kind:"github",accept:n},issues:s}}function a8(e){var s;const n={events:[],where:{},other:[],read:{order:[],rules:{}}};for(const r of e){const o=ah.filter(c=>c.event===r.event).map(c=>c.action);if(!(!!((s=r.actions)!=null&&s.length)&&r.actions.every(c=>o.includes(c))&&new Set(r.actions).size===r.actions.length&&!(r.event in n.where))){const c=rm(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(pE),n.read.order.push(`event:${r.event}`),n.read.rules[r.event]=r}return n}const _b=e=>e.source.kind==="composio"&&e.target.kind==="start_run";function i8(e,n=[]){const s=(e==null?void 0:e.properties)??{},r=new Set(Array.isArray(e==null?void 0:e.required)?e.required.filter(o=>typeof o=="string"):[]);return Object.entries(s).filter(([,o])=>o&&typeof o=="object"&&o.deprecated!==!0).map(([o,i])=>{const c=(Array.isArray(i.type)?i.type:[i.type]).filter(g=>g!=="null"),d=c.length===1&&["string","number","integer","boolean"].includes(String(c[0]))?c[0]:"json",u=d==="string"&&Array.isArray(i.enum)&&i.enum.every(g=>typeof g=="string")?i.enum:void 0,f=i.default===void 0?d==="boolean"?"false":"":d==="json"?JSON.stringify(i.default):String(i.default);return{name:o,title:typeof i.title=="string"&&i.title.trim()?i.title:o,...typeof i.description=="string"&&i.description.trim()?{description:i.description}:{},required:r.has(o),type:d,...u?{options:u}:{},initial:f,...n.includes(o)?{sealed:!0}:{}}})}function l8(e,n,s){const r={};for(const o of e){const i=(n[o.name]??o.initial).trim(),c=`source.config.${o.name}`;if(!i){o.required&&(s[c]=`${o.title} is required.`);continue}if(o.type==="boolean")r[o.name]=i==="true";else if(o.type==="number"||o.type==="integer"){const d=rd(i);d===void 0||o.type==="integer"&&!Number.isInteger(d)?s[c]=o.type==="integer"?"A whole number is needed.":sd:r[o.name]=d}else if(o.type==="json")try{r[o.name]=JSON.parse(i)}catch{s[c]="Give it as JSON."}else r[o.name]=i}return r}const c8=()=>({name:"",server:"",event:"",config:{},where:[],agentId:"",content:"",maxCost:""});function Tb(e,n,s=[],r){var i;const o=n.length||r&&!((i=r.where)!=null&&i.length)?[{event:e,actions:"",where:n,...r?{was:r}:{}}]:[];return wb([...o,...s])}function d8(e,n,s=[],r){const{accept:o,...i}=e,{accept:c,issues:d}=Tb(e.event,n,s,r);return{source:{...i,...c.length?{accept:c}:{}},issues:d}}function u8(e,n,s=!1){const r={};e.server||(r["source.server"]="Pick a Composio server."),e.event||(r["source.event"]="Pick an event.");const o=e.event?l8(n,e.config,r):{},{accept:i,issues:c}=Tb(e.event,e.where);Object.assign(r,c);const d={kind:"composio",server:e.server,event:e.event,config:o,...i.length?{accept:i}:{}};return lh(e,d,r,s,"a trigger")}const TE=e=>e.source.kind==="feed"&&e.target.kind==="start_run",Mx=20,RE=900,f8="item",AE=()=>({name:"",urls:"",every:"15",everyUnit:"minutes",items:"",id:"",where:[],others:[],agentId:"",content:"",maxCost:""});function m8(e){const n=e.source,s=n.every_s??RE,r=s%3600===0?"hours":s%60===0?"minutes":"seconds",o=(n.accept??[]).map(rm),i=o[0]&&!o[0].actions.trim()?o[0]:null;return{...AE(),urls:n.urls.join(`
|
|
659
|
-
`),every:String(s/oh[r]),everyUnit:r,items:n.items??"",id:n.id??"",where:(i==null?void 0:i.where)??[],others:o.slice(i?1:0),read:n}}const h8=e=>{try{return new URL(e)}catch{return null}};function OE(e){const n=e.split(/\r\n|\r|\n/).map(r=>r.trim()).filter(Boolean),s={};return n.length?n.length>Mx?s["source.urls"]=`${Mx} feeds at most: this has ${n.length}.`:n.forEach((r,o)=>{const i=h8(r);!i||i.protocol!=="http:"&&i.protocol!=="https:"||!i.hostname?s[`source.urls[${o}]`]=`${r} isn't an http or https URL.`:i.username||i.password?s[`source.urls[${o}]`]=`${i.host}'s URL holds a user or password: leave it out.`:n.indexOf(r)<o&&(s[`source.urls[${o}]`]=`${r} is here twice: each feed is read once.`)}):s["source.urls"]="Add a feed's URL, one a line.",{urls:n,issues:s}}function LE(e,n){var f,g,y,v,h;const{urls:s,issues:r}=OE(e.urls),o=rd(e.every),i=Math.round((o??0)*oh[e.everyUnit]);o===void 0?r["source.every_s"]=sd:n&&i<n&&(r["source.every_s"]=$b(n));const c=x=>{var j;const b=e[x];return b||((j=e.read)==null?void 0:j[x])===""?{[x]:b}:{}},{accept:d,issues:u}=Tb(f8,e.where,e.others,(g=(f=e.read)==null?void 0:f.accept)!=null&&g[0]&&!((y=e.read.accept[0].actions)!=null&&y.length)?e.read.accept[0]:void 0);return Object.assign(r,u),{source:{kind:"feed",urls:s,every_s:i,...c("items"),...c("id"),...((v=e.read)==null?void 0:v.updated)!==void 0?{updated:e.read.updated}:{},...(h=e.read)!=null&&h.fields?{fields:e.read.fields}:{},...d.length?{accept:d}:{}},issues:r}}function p8(e,n,s=!1){const{source:r,issues:o}=LE(e,n);return lh(e,r,o,s,"a feed trigger")}function g8(e,n){return new Set(["name","source.urls",...Array.from({length:e},(s,r)=>`source.urls[${r}]`),"source.every_s","source.items","source.id","target.agent_id","target.input","target.max_cost_usd",...Md(n)])}function x8(e,n=!1){const{source:s,issues:r}=_E(e);return lh(e,s,r,n,"a GitHub trigger")}function lh(e,n,s,r,o){e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const i=rd(e.maxCost);return e.maxCost.trim()?i===void 0&&(s["target.max_cost_usd"]=sd):r||(s["target.max_cost_usd"]=`A cost cap is needed: every run ${o} starts is capped.`),Object.keys(s).length?{issues:s}:{body:{...e.name.trim()?{name:e.name.trim()}:{},source:n,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...i!==void 0?{max_cost_usd:i}:{}}}}}function v8(e){const n=e.source,s="cron"in n?n.timezone:Ol(),r={...vE(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:Lx(n.at),read:{at:n.at}};const o=n.every_s%3600===0?"hours":n.every_s%60===0?"minutes":"seconds";return{...r,kind:"every",every:String(n.every_s/oh[o]),everyUnit:o,startAt:Lx(n.start_at),read:{startAt:n.start_at}}}const od=(e,n)=>{if(e===n)return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null||Array.isArray(e)!==Array.isArray(n))return!1;const[s,r]=[Object.keys(e),Object.keys(n)];return s.length===r.length&&s.every(o=>od(e[o],n[o]))};function D0(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&&!od(s,e.source)?{source:s}:{},...r&&!od(r,e.target)?{target:r}:{}}}const b8=["name","enabled","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd"];function Ll(e){var r;if(!(e instanceof Ue))return{fields:{},rest:[e instanceof Error?e.message:String(e)]};if(e.status!==422||!((r=e.fields)!=null&&r.length))return{fields:{},rest:[`${e.code}: ${e.message}`]};const n={},s=[];for(const o of e.fields){const i=o.field.startsWith("target.input")?"target.input":o.field;(b8.includes(i)||i.startsWith("source.accept")||i==="source.server"||i==="source.event"||i==="source.config"||i.startsWith("source.config.")||/^source\.urls(\[\d+\])?$/.test(i)||i==="source.items"||i==="source.id")&&!n[i]?n[i]=o.message:s.push(o.message)}return{fields:n,rest:s}}const y8=[{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"}],w8=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),j8=Array.from({length:31},(e,n)=>({value:String(n+1),label:String(n+1)})),k8=Array.from({length:60},(e,n)=>({value:String(n),label:`:${String(n).padStart(2,"0")}`}));function ME({value:e,onChange:n,label:s,name:r}){const o=$6(e),[i,c]=p.useState(()=>e.trim()!==""&&!o),d=p.useId(),u=i||e.trim()!==""&&!o,f=v=>n(_6(v)),g=v=>{if(v==="custom"){c(!0);return}c(!1),f(T6(v,o))},y=o&&"at"in o?o.at:null;return t.jsxs("div",{className:"space-y-2","data-schedule-when":!0,children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Et,{label:s,className:"min-w-56 flex-1",value:u?"custom":(o==null?void 0:o.kind)??"",onChange:g,placeholder:"Pick when it runs",options:y8}),!u&&(o==null?void 0:o.kind)==="weekly"&&t.jsx(Et,{id:`${d}-day`,label:"Day of the week",className:"w-40",value:String(o.day),onChange:v=>f({...o,day:Number(v)}),options:w8}),!u&&(o==null?void 0:o.kind)==="monthly"&&t.jsx(Et,{id:`${d}-date`,label:"Day of the month",className:"w-24",value:String(o.date),onChange:v=>f({...o,date:Number(v)}),options:j8}),!u&&(o==null?void 0:o.kind)==="hourly"&&t.jsx(Et,{id:`${d}-minute`,label:"Minutes past the hour",className:"w-24",value:String(o.minute),onChange:v=>f({...o,minute:Number(v)}),options:k8}),!u&&o&&y&&t.jsx(Pe,{id:`${d}-at`,type:"time","aria-label":"At",className:"w-32",value:R6(y),onChange:v=>{const h=A6(v.target.value);h&&f({...o,at:h})}})]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Pe,{id:`${d}-line`,name:r,"aria-label":"Custom schedule",value:e,onChange:v=>n(v.target.value),placeholder:"30 1 * * *",spellCheck:!1}),t.jsx("p",{className:"text-small text-muted-foreground","aria-live":"polite",children:e.trim()?bE(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const F0=Intl.supportedValuesOf,mf=typeof F0=="function"?F0("timeZone"):[],hf=mf.length&&!mf.includes("UTC")?["UTC",...mf]:mf;function PE({value:e,onChange:n,label:s,name:r,id:o,className:i}){if(!hf.length)return t.jsx(Pe,{id:o,name:r,"aria-label":s,className:i,value:e,onChange:d=>n(d.target.value),placeholder:"Europe/Madrid"});const c=e&&!hf.includes(e)?[e,...hf]:hf;return t.jsx(Et,{id:o,name:r,label:s,className:i,value:e,onChange:n,placeholder:"Pick a time zone",options:c.map(d=>({value:d,label:d.replace(/_/g," ")}))})}function N8(e,n){var i,c,d;let s;if(e==="agentic"&&n.json)try{s=JSON.parse(n.text)}catch{return{ok:!1,field:"input",message:"The agent's input is JSON: this is not."}}else if(e==="agentic"&&n.typed){if(n.typed.contentRequired&&!n.text.trim())return{ok:!1,field:"input",message:"Write the run's message."};s={...n.text.trim()?{content:n.text}:{},...n.typed.fields}}else if(e==="agentic"){if(!n.text.trim())return{ok:!1,field:"input",message:"Write the run's first message."};s={content:n.text}}else try{s=JSON.parse(n.text)}catch{return{ok:!1,field:"input",message:"The workflow's input is JSON: this is not."}}const r={input:s};if(n.revision&&(r.revision=n.revision),n.effort&&(r.effort=n.effort),e==="agentic"&&((i=n.maxCostUsd)!=null&&i.trim())){const u=Number(n.maxCostUsd);if(!Number.isFinite(u)||u<=0)return{ok:!1,field:"max_cost_usd",message:"A spend cap is a positive number of dollars."};r.max_cost_usd=u}(c=n.fileIds)!=null&&c.length&&(r.file_ids=[...n.fileIds]);const o=e==="agentic"?(d=n.repo)==null?void 0:d.trim():void 0;if(o){if(!/^[^/\s]+\/[^/\s]+$/.test(o))return{ok:!1,field:"repo",message:"A repository is owner/name, like Parcha-ai/agentrun."};r.repo=o}return{ok:!0,body:r}}function S8(e,n){return s=>{var o,i,c,d;const r=new Set;for(;s!=null&&s.$ref&&!r.has(s.$ref);){r.add(s.$ref);const u=(i=(o=/^#\/(?:definitions|\$defs)\/(.+)$/.exec(s.$ref))==null?void 0:o[1])==null?void 0:i.replace(/~1/g,"/").replace(/~0/g,"~"),f=u===void 0?void 0:((c=e.definitions)==null?void 0:c[u])??((d=e.$defs)==null?void 0:d[u])??(Object.hasOwn(n,u)?n[u]:void 0);if(!f)break;s=f}return s}}function C8(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 E8(e){var r,o;const n=e,s=(r=n==null?void 0:n.input)!=null&&r.schemaId?(o=n.schemas)==null?void 0:o[n.input.schemaId]:void 0;return s?IE(s,(n==null?void 0:n.schemas)??{}):null}function IE(e,n={}){var u;const s=S8(e,n),r=s(e),o=Object.entries(r.properties??{}).map(([f,g])=>{const y=s(g);return{name:f,...y!=null&&y.description?{note:y.description}:{}}}),i=((u=r.examples)==null?void 0:u[0])??r.default;if(i!==void 0)return{text:JSON.stringify(i,null,2),from:"example",fields:o,optional:[]};const c=(f,g=0)=>{var h,x;const y=s(f);if(!y||g>4)return null;if((h=y.examples)!=null&&h.length)return y.examples[0];if(y.default!==void 0)return y.default;if((x=y.enum)!=null&&x.length)return y.enum[0];const v=Array.isArray(y.type)?y.type[0]:y.type;return v==="object"||y.properties?Object.fromEntries(Object.entries(y.properties??{}).filter(([b])=>(y.required??[]).includes(b)).map(([b,j])=>[b,c(j,g+1)])):v==="array"?[]:v==="string"?"":v==="number"||v==="integer"?0:v==="boolean"?!1:null},d=new Set(r.required??[]);return{text:JSON.stringify(c(r),null,2),from:"shape",fields:o,optional:o.map(f=>f.name).filter(f=>!d.has(f))}}const Pg=e=>`'${e.replace(/'/g,"'\\''")}'`;function $8(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(`
|
|
660
|
-
`)}const _8=e=>e>=200&&e<300;async function T8(e,n,s,r){const o=await r(n,s,e.keyFor(n,s));return _8(o.status)&&e.done(),o}const Wo=(e,n={})=>(e.display_name||e.name).replace(/\$\{parameters\.([A-Za-z0-9_]+)\}/g,(s,r)=>(Object.hasOwn(n,r)?Ab(n[r]).join(", "):"")||"…"),zE=e=>`#/templates/${encodeURIComponent(e)}`;function rl(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 R8(e,n){var r,o;if(e===void 0)return{};const s={error:"This prepared template request is invalid. Open a fresh request to review its settings."};try{const i=JSON.parse(e),c=v=>v!==null&&typeof v=="object"&&!Array.isArray(v);if(!c(i)||i.template!==n.id||typeof i.version!="string")return s;if(i.version!==n.version)return{error:"This template's version changed. Open a fresh request to review the current package before applying."};if(n.sha&&i.sha!==n.sha)return{error:"This template's commit changed. Open a fresh request to review the current package before applying."};const d=i.body,u=(v,h)=>v==="boolean"?typeof h=="boolean":v==="string"?typeof h=="string":(v==="number"||v==="integer")&&typeof h=="number"&&Number.isFinite(h);if(!c(d)||Object.keys(d).some(v=>!["parameters","grants","servers","overrides"].includes(v))||!c(d.parameters)||d.grants!==void 0&&(!Array.isArray(d.grants)||d.grants.some(v=>typeof v!="string"||!n.mcp.some(h=>h.tools.some(x=>x.tool===v))))||d.servers!==void 0&&(!c(d.servers)||Object.entries(d.servers).some(([v,h])=>!n.mcp.some(x=>x.toolkit===v)||typeof h!="string"||!/^[a-z][a-z0-9-]{0,31}$/.test(h)))||!c(d.overrides)||Object.keys(d.overrides).some(v=>v!=="approvals"&&v!=="choice")||d.overrides.approvals!=="ask"&&d.overrides.approvals!=="never"||d.overrides.choice!==void 0&&(typeof d.overrides.choice!="string"||!((o=(r=n.model)==null?void 0:r.choices)!=null&&o.map(v=>v.id).includes(d.overrides.choice))))return s;const f=ch(n.parameters);if(!f)return s;const g=new Map(f),y=[];for(const[v,h]of Object.entries(d.parameters)){const x=g.get(v);if(!x)return s;if(h==="")continue;if(x.array?!Array.isArray(h)||!h.every(k=>u(x.type,k)):!u(x.type,h))return s;const b=Array.isArray(h)?h.map(String).join(`
|
|
661
|
-
`):String(h),j=uh({fields:[[v,x]],contentRequired:!1},{[v]:b})[v];if(JSON.stringify(j)!==JSON.stringify(h))return s;y.push([v,h])}return{body:{...d,parameters:Object.fromEntries(y)}}}catch{return s}}const A8=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function Rb(e,{secrets:n=!0,mcp:s=!0}={}){var o,i;const r=[];return n&&e.secrets.length&&r.push(["Keys",e.secrets.join(", ")]),s&&e.mcp.length&&r.push(["MCP",e.mcp.map(c=>`${c.toolkit} (${Ed[c.source]}${c.required?"":", optional"})`).join(", ")]),e.triggers.length&&r.push(["Triggers",A8(e.triggers.length,"trigger")]),(o=e.budget)!=null&&o.per_run_usd&&r.push(["Budget",`${so(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 Pd(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 O8(e){return Object.fromEntries(Object.entries(e).flatMap(([n,s])=>s.array?[]:s.type==="boolean"?typeof s.default=="boolean"?[[n,String(s.default)]]:[]:Pd(s)?[]:s.format==="timezone"?[[n,Ol()]]:s.format==="cron"?typeof s.default=="string"?[[n,s.default]]:[]:[]))}const L8=(e,n)=>n.filter(s=>s.source===e.source&&s.toolkit===e.toolkit).map(s=>s.name).sort();function M8(e){const n=encodeURIComponent(e.toolkit);if(e.source==="composio")return`#/settings/mcp?add=${n}&preset=composio&toolkit=${n}&tools=${e.tools.map(r=>encodeURIComponent(r.name)).join(",")}`;if(e.source==="github")return"#/settings/mcp?add=github&auth=github_app";const s=rb.find(r=>r.name===e.toolkit);return`#/settings/mcp?add=${n}${s?`&preset=${s.id}`:""}`}const lm=e=>e.mcp.length===0&&e.secrets.length===0,P8=e=>{const n=e.source;return typeof n=="object"&&n!==null&&"kind"in n?n.kind:void 0},U0=[{id:"email",what:"the email account",needs:e=>(e.tools??[]).some(n=>n.startsWith("email_"))||e.triggers.some(n=>P8(n)==="email"),met:async e=>(await e.emailAccount()).configured,unmet:{before:"Connect your mailbox under ",link:"Settings → Email",href:"#/settings/email",after:" first."}}],I8=(e,n)=>e.mcp.flatMap(s=>s.tools.map(r=>r.tool)).filter(s=>n.has(s)),z8=(e,n)=>e.filter(s=>s.field===n);function cm(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 D8(e){const n=Pd(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 F8(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: ${DE(s).join(", ")}.`;case"bad_format":return`${r} isn't in the form its description asks for.`;default:return e.message}}const DE=e=>{var n;return(n=e.enum)!=null&&n.length?e.enum.map(String):Pd(e)??[]};function FE(e,n){var c;if(e.array){const d=Ab(n);return d.length?d.every(u=>FE({...e,array:!1,required:!0},u)):!e.required}if(n==="")return!e.required;const s=Pd(e);if(s)return s.includes(n);const r=Number(n),o=(e.minimum===void 0||r>=e.minimum)&&(e.maximum===void 0||r<=e.maximum);if(e.type==="integer")return n.trim()!==""&&Number.isSafeInteger(r)&&o;if(e.type==="number")return n.trim()!==""&&Number.isFinite(r)&&o;if(e.type==="boolean")return(n==="true"||n==="false")&&(!((c=e.enum)!=null&&c.length)||DE(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 Ab=e=>(e??"").split(`
|
|
662
|
-
`).map(n=>n.trim()).filter(n=>n!==""),UE=FE,za=e=>!!e&&typeof e=="object"&&!Array.isArray(e),U8=new Set(["string","number","integer","boolean"]),W8=["oneOf","anyOf","allOf","not","if","$ref","const"],Px=e=>W8.some(n=>n in e),pf=e=>typeof e=="string"?e:void 0,gf=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,H8=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0));function B8(e,n){if(!za(e)||Px(e))return null;const s=e.type==="array",r=s?e.items:e;if(!za(r)||Px(r)||typeof r.type!="string"||!U8.has(r.type))return null;const o=Array.isArray(r.enum)&&r.enum.every(i=>["string","number","boolean"].includes(typeof i))?r.enum:void 0;return H8({type:r.type,...s?{array:!0}:{},required:n,title:pf(e.title),description:pf(e.description),examples:Array.isArray(e.examples)?e.examples:void 0,default:e.default,enum:o,pattern:pf(r.pattern),format:pf(r.format),minimum:gf(r.minimum),maximum:gf(r.maximum),minLength:gf(r.minLength),maxLength:gf(r.maxLength)})}function ch(e,n){const s=za(e)&&za(e.properties)?e.properties:{},r=za(e)&&Array.isArray(e.required)?e.required:[],o=[];for(const[i,c]of Object.entries(s)){if(i===n)continue;const d=B8(c,r.includes(i));if(!d)return null;o.push([i,d])}return o}function G8(e){if(!za(e))return{kind:"message"};const n=()=>({kind:"json",example:IE(e)});if(Px(e))return n();const s=za(e.properties)?e.properties:{},r=Array.isArray(e.required)?e.required.filter(i=>typeof i=="string"):[];if(r.some(i=>i!=="content"&&!Object.hasOwn(s,i)))return n();const o=ch(e,"content");return o?o.length?{kind:"fields",form:{fields:o,contentRequired:r.includes("content")||!r.some(i=>i!=="content")}}:{kind:"message"}:n()}const dh=(e,n)=>n.title||e;function q8(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(`
|
|
663
|
-
`):typeof n=="object"?JSON.stringify(n):String(n)}function K8(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=Ab(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 WE(e){const n=O8(Object.fromEntries(e.fields));for(const[s,r]of e.fields){const o=r.array?null:Pd(r);o&&r.default!==void 0&&o.includes(String(r.default))&&(n[s]=String(r.default))}return n}function uh(e,n){const s={};for(const[r,o]of e.fields){const i=K8(o,n[r]);i!==void 0&&(s[r]=i)}return s}const V8=(e,n,s)=>({...n.trim()?{content:n}:{},...uh(e,s)}),Ix=(e,n="input")=>e.startsWith(`${n}.`)?e.slice(n.length+1).split(".")[0]:null,HE=e=>e.type==="integer"?"a whole number":e.type==="number"?"a number":e.type==="boolean"?"true or false":"text",Y8={string:"text",integer:"whole numbers",number:"numbers",boolean:"true or false"},Q8=e=>e.array?`a list of ${Y8[e.type]}`:HE(e);function BE(e,n,s){var o;const r=dh(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 ${HE(s)}.`:s.array&&e.reason==="not_an_option"&&((o=s.enum)!=null&&o.length)?`Each line of ${r} is one of: ${s.enum.map(String).join(", ")}.`:F8(e,n,s,r)}const J8={date:"date",email:"email",uri:"url"};function GE({field:e,label:n,help:s,value:r,onChange:o}){const i=q8(e),c=D8(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(Et,{label:n,className:"w-full",value:r,onChange:o,options:c}):e.array?t.jsx(nn,{rows:3,value:r,required:e.required,placeholder:i,onChange:d=>o(d.target.value),className:"resize-y leading-[1.6]"}):e.format==="cron"&&e.type==="string"?t.jsx(ME,{label:n,value:r,onChange:o}):e.format==="timezone"&&e.type==="string"?t.jsx(PE,{label:n,className:"w-full",value:r,onChange:o}):e.type==="boolean"?t.jsx("input",{type:"checkbox",className:"size-4 accent-primary",checked:r==="true",onChange:d=>o(d.target.checked?"true":"false")}):t.jsx(Pe,{type:e.type==="string"?J8[e.format??""]??"text":"number",step:e.type==="integer"?1:"any",value:r,required:e.required,placeholder:i,min:e.minimum,max:e.maximum,minLength:e.minLength,maxLength:e.maxLength,onChange:d=>o(d.target.value)})]})}function 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,o)=>t.jsxs("li",{children:[n&&t.jsxs("span",{className:"font-mono",children:[r.field," "]}),s(r),r.fix&&t.jsx("span",{className:"block text-foreground/80",children:r.fix})]},`${r.field}:${o}`))}):null}const qE={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."},X8='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.',Wc=(e,n)=>e[n]?t.jsx("span",{"data-issue":n,children:e[n]}):void 0,mr=({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 fh({name:e,at:n,where:s,onChange:r,issues:o,label:i}){const c=(f,g)=>r(s.map((y,v)=>v===f?{...y,...g}:y)),d=(f,g)=>c(f,g==="prefix"?{op:g,value:s[f].value.split(/\r\n|\r|\n/).find(y=>y.trim())??""}:{op:g}),u=s.length>=Ld.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(mr,{issues:o,field:`${n}.where`}),s.map((f,g)=>{const y=`${n}.where[${g}]`,v=`${e}-where-${g}`;return t.jsxs("div",{"data-condition":v,className:"space-y-3 border p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t.jsx(xt,{label:"Field",className:"min-w-40 flex-1",error:Wc(o,`${y}.pointer`),children:t.jsx(Pe,{name:`${v}-pointer`,value:f.pointer,onChange:h=>c(g,{pointer:h.target.value}),placeholder:"/title",autoComplete:"off",spellCheck:!1})}),t.jsx(xd,{name:`${v}-op`,label:`Condition ${g+1}'s test`,value:f.op,onChange:h=>d(g,h),options:P6.map(h=>({value:h,label:dE[h]}))}),t.jsx(B,{type:"button",size:"icon",variant:"ghost","aria-label":`Remove condition ${g+1}`,onClick:()=>r(s.filter((h,x)=>x!==g)),children:t.jsx(Zo,{"aria-hidden":!0})})]}),f.op==="in"&&t.jsx(xt,{label:"Values",hint:X8,error:Wc(o,`${y}.in`),children:t.jsx(nn,{name:`${v}-value`,rows:3,value:f.value,onChange:h=>c(g,{value:h.target.value}),spellCheck:!1})}),f.op==="prefix"&&t.jsx(xt,{label:"Text",hint:"Its first line, trimmed, starts with this, in any case.",error:Wc(o,`${y}.prefix`),children:t.jsx(Pe,{name:`${v}-value`,value:f.value,onChange:h=>c(g,{value:h.target.value}),autoComplete:"off",spellCheck:!1})}),t.jsx(mr,{issues:o,field:y}),t.jsx(mr,{issues:o,field:`${y}.exists`})]},f.key)}),t.jsxs(B,{type:"button",size:"sm",onClick:()=>r([...s,z6()]),disabled:u,children:[t.jsx(jl,{"aria-hidden":!0})," Add a condition"]})]})}function KE({name:e,rules:n,onChange:s,issues:r,indexOf:o=g=>g,room:i,eventHint:c,eventPlaceholder:d,addLabel:u="Add a rule",empty:f}){const g=(y,v)=>s(n.map((h,x)=>x===y?{...h,...v}:h));return t.jsxs("div",{className:"min-w-0 space-y-3",children:[!n.length&&f,n.map((y,v)=>{const h=`source.accept[${o(v)}]`,x=`${e}-${v}`;return t.jsxs("section",{"data-rule":x,"aria-label":`Rule ${v+1}`,className:"space-y-4 border p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Rule ",v+1]}),t.jsxs(B,{type:"button",size:"xs",variant:"ghost","aria-label":`Remove rule ${v+1}`,onClick:()=>s(n.filter((b,j)=>j!==v)),children:[t.jsx(XN,{"aria-hidden":!0})," Remove"]})]}),t.jsx(mr,{issues:r,field:h}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(xt,{label:"Event",hint:c,error:Wc(r,`${h}.event`),children:t.jsx(Pe,{name:`${x}-event`,value:y.event,onChange:b=>g(v,{event:b.target.value}),placeholder:d,autoComplete:"off",spellCheck:!1})}),t.jsx(xt,{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:Wc(r,`${h}.actions`),children:t.jsx(Pe,{name:`${x}-actions`,value:y.actions,onChange:b=>g(v,{actions:b.target.value}),placeholder:"opened, edited",autoComplete:"off",spellCheck:!1})})]}),t.jsx(fh,{name:x,at:h,where:y.where,onChange:b=>g(v,{where:b}),issues:r,label:"Only when"})]},y.key)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>s([...n,uE()]),disabled:i<=0,children:[t.jsx(jl,{"aria-hidden":!0})," ",u]}),i<=0&&t.jsxs("span",{className:"text-small text-muted-foreground",children:[Ld.rules," rules, the most a trigger takes."]})]})]})}const Un=e=>`#/triggers/${encodeURIComponent(e)}`,bl=e=>ft(e),Z8={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function eU({v2:e,view:n,go:s,agentName:r,minEvery:o,failuresToPause:i,publicUrl:c,refreshMs:d=15e3,now:u=Date.now}){const f=c===!1;return n.trigger===void 0?t.jsx(rU,{v2:e,go:s,agentName:r,every:d*2,now:u,failuresToPause:i,noAddress:f}):n.trigger===null?n.kind==="webhook"?t.jsx(fU,{v2:e,go:s}):n.kind==="github"?t.jsx(mU,{v2:e,go:s}):n.kind==="composio"?t.jsx(hU,{v2:e,go:s,noAddress:f}):n.kind==="feed"?t.jsx(r$,{v2:e,go:s,minEvery:o}):t.jsx(ZE,{v2:e,go:s,minEvery:o,now:u}):n.edit?t.jsx(dU,{v2:e,go:s,id:n.trigger,minEvery:o,now:u},n.trigger):t.jsx(cU,{v2:e,go:s,agentName:r,id:n.trigger,every:d,now:u,failuresToPause:i},n.trigger)}function VE(e,n,s){const r=p.useRef(e);r.current=e,p.useEffect(()=>{const o=()=>document.visibilityState!=="hidden",i=setInterval(()=>{o()&&r.current()},n),c=()=>{o()&&r.current()};return document.addEventListener("visibilitychange",c),()=>{clearInterval(i),document.removeEventListener("visibilitychange",c)}},[n,...s])}const YE=e=>e?"ran"in e?`Done · ran ${bl(e.ran.nominal_at)}`:`Its time passed · ${bl(e.passed)}`:null,tU=/has already passed\.?$/;function QE({trigger:e}){return e.disabled?t.jsx(Se,{tone:"warning",children:"Turned off"}):t.jsx(Se,{tone:"muted",children:"Paused"})}const nU=e=>e.last_firing?`${CE(e.last_firing)}${e.last_firing.catch_up?" · caught up late":""} · ${bl(e.last_firing.nominal_at)}`:"Not fired yet",sU=e=>`${e.ok?"Checked":"Check failed"} ${bl(e.at)}: ${e.message}`,Ob="App triggers need this server's public address: set AGENTRUN_PUBLIC_URL and restart.";function rU({v2:e,go:n,agentName:s,every:r,now:o,failuresToPause:i,noAddress:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState(0),h=p.useRef(!1),x=p.useRef(!0);p.useEffect(()=>(x.current=!0,()=>{x.current=!1}),[]);const b=()=>{h.current||(h.current=!0,e.listTriggers().then(j=>{x.current&&(u(j.triggers),g(null))},j=>{x.current&&g(Ht(j,"the triggers"))}).finally(()=>{h.current=!1}))};return p.useEffect(b,[e,y]),VE(b,r,[e]),t.jsxs("section",{className:"flex min-h-full flex-col","aria-label":"Triggers",children:[t.jsxs("header",{className:ae(pr,"flex-wrap justify-between gap-3 px-5"),children:[t.jsxs("h1",{className:Bo,children:[t.jsx(cd,{className:"size-4","aria-hidden":!0}),"Triggers"]}),!(d&&!d.length)&&t.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:[t.jsxs(B,{size:"sm",disabled:c,onClick:()=>n("#/triggers/new-composio"),children:[t.jsx(gm,{"aria-hidden":!0})," New app trigger"]}),t.jsxs(B,{size:"sm",onClick:()=>n("#/triggers/new-github"),children:[t.jsx(bm,{"aria-hidden":!0})," New GitHub trigger"]}),t.jsxs(B,{size:"sm",onClick:()=>n("#/triggers/new-webhook"),children:[t.jsx(ll,{"aria-hidden":!0})," New webhook"]}),t.jsxs(B,{size:"sm",onClick:()=>n("#/triggers/new-feed"),children:[t.jsx(nv,{"aria-hidden":!0})," New feed trigger"]}),t.jsxs(B,{size:"sm",variant:"primary",onClick:()=>n("#/triggers/new"),children:[t.jsx(jl,{"aria-hidden":!0})," New schedule"]})]})]}),t.jsxs("div",{className:"px-5 py-5 md:py-6",children:[c&&d&&d.length>0&&t.jsx("p",{className:"mb-4 text-small text-muted-foreground",children:Ob}),f&&!d?t.jsx(Jt,{problem:f,onRetry:()=>v(j=>j+1),className:""}):d?d.length?t.jsx("ul",{className:"border",children:d.map(j=>t.jsxs("li",{"data-trigger":j.id,className:"grid grid-cols-1 gap-x-6 gap-y-1.5 border-b px-4 py-3 last:border-b-0 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("a",{href:Un(j.id),className:"min-w-0 break-words text-prose font-semibold hover:underline",children:j.name}),t.jsx(Se,{children:aU[j.source.kind]}),!j.enabled&&!Nb(j,o())&&t.jsx(QE,{trigger:j})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:JE(j),children:iU(j,s,o())}),im(j,i)&&t.jsx("p",{className:"mt-1 break-words text-small text-warning-text",children:im(j,i)})]}),t.jsxs("div",{className:"min-w-0 font-mono text-small text-muted-foreground md:text-right",children:[t.jsx("p",{className:"break-words",children:nU(j)}),j.last_check&&t.jsx("p",{"data-last-check":j.last_check.ok?"ok":"failed",className:`mt-1 break-words ${j.last_check.ok?"":"text-warning-text"}`,children:sU(j.last_check)})]})]},j.id))}):t.jsx(oU,{go:n,noAddress:c}):t.jsx(Hn,{label:"Loading the triggers",rows:4}),d&&f&&t.jsx(Jt,{problem:f,className:"mt-4"})]})]})}function oU({go:e,noAddress:n}){const s=[{Icon:cd,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:ll,name:"Webhook",what:"On each signed request another system sends to its URL.",action:"New webhook",to:"#/triggers/new-webhook"},{Icon:bm,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:gm,name:"From an app",what:"On an event in an app a saved Composio server connects, such as a new issue in a GitHub repository. Save the server in Settings first.",action:"New app trigger",to:"#/triggers/new-composio"},{Icon:nv,name:"Feed",what:"On each new item in the feeds you name, read every few minutes: a status page's incidents, a blog, or an API's JSON list such as a repository's pull requests.",action:"New feed trigger",to:"#/triggers/new-feed"}];return t.jsxs("section",{"aria-labelledby":"first-trigger",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"No triggers yet"}),t.jsx("h2",{id:"first-trigger",className:"mt-2 text-xl font-semibold",children:"Start runs without being here"}),t.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A trigger starts a run of an agent for you, and each run it starts stops at a spend cap. Pick what should start it."}),t.jsx("ul",{className:"mt-5 grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:s.map(({Icon:r,name:o,what:i,action:c,to:d})=>t.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[t.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[t.jsx(r,{className:"size-4 text-muted-foreground","aria-hidden":!0}),o]}),t.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:i}),n&&d==="#/triggers/new-composio"&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:Ob}),t.jsx(B,{size:"sm",className:"mt-4 self-start",disabled:n&&d==="#/triggers/new-composio",onClick:()=>e(d),children:c})]},o))})]})}const aU={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"},JE=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function iU(e,n,s){return`${e.source.kind==="schedule"?kb(e.source,e.next_at,{instead:YE(Nb(e,s)),now:s}):e.source.kind==="github"?SE(e.source):e.source.kind==="composio"?kE(e.source):e.source.kind==="email"?J6(e.source):e.source.kind==="feed"?NE(e.source):jE(e.source)} · ${e.target.kind==="start_run"?n(e.target.agent_id)||e.target.agent_id:`messages run ${sa(e.target.run_id)}`}`}const lU={on:"On",off:"Off",missing:"Composio no longer has it: delete this trigger and make it again.",unknown:"Composio didn't say"};function XE(){return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(On,{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 cU({v2:e,go:n,agentName:s,id:r,every:o,now:i,failuresToPause:c}){var nt,fe,Le,Ye,ht;const[d,u]=p.useState(null),[f,g]=p.useState([]),[y,v]=p.useState(null),[h,x]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),[$,_]=p.useState(null),O=p.useRef(!1),[L,P]=p.useState(!1),[R,A]=p.useState(null),[M,F]=p.useState(null),[I,q]=p.useState(null),[W,K]=p.useState(0),U=p.useRef(!1),H=p.useRef(!1),G=p.useRef(0),z=()=>{H.current=!0;const ie=G.current;return Promise.all([e.getTrigger(r),e.triggerFirings(r)]).then(([Ce,tt])=>{ie===G.current&&(u(Ce),g(tt.firings),v(null))}).finally(()=>{H.current=!1})};p.useEffect(()=>{z().catch(ie=>v(Ht(ie,"the trigger")))},[e,r,W]),VE(()=>{!H.current&&!U.current&&I===null&&z().catch(()=>{})},o,[e,r]);const[V,se]=p.useState(void 0),J=d&&d.target.kind==="start_run"&&typeof d.target.max_cost_usd!="number"?d.target.agent_id:null;p.useEffect(()=>{if(!J)return;let ie=!0;return e.getAgent(J).then(Ce=>{ie&&se(typeof Ce.agent.definition.max_cost_usd=="number"?Ce.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{ie=!1}},[e,J]);const re=(d==null?void 0:d.source.kind)==="composio"?d.source.server:null;if(p.useEffect(()=>{if(!re)return;let ie=!0;return e.composioTriggers(re).then(Ce=>{var tt;ie&&A(((tt=Ce.triggers.find(Ie=>Ie.id===r))==null?void 0:tt.on_composio)??"unknown")},()=>{ie&&A(null)}),()=>{ie=!1}},[e,re,r,d==null?void 0:d.enabled]),I!==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(On,{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:I}),t.jsx("a",{href:"#/triggers",className:"mt-4 inline-block text-body underline underline-offset-2",children:"All triggers"})]});if(!d)return y?t.jsx(Jt,{problem:y,onRetry:()=>K(ie=>ie+1),link:{href:"#/triggers",label:"All triggers"}}):t.jsx(Hn,{label:"Loading the trigger",rows:4});const ne=Cb(d)?d:null,me=wE(d)?d:null,ve=_b(d)?d:null,je=TE(d)?d:null;if(!ne&&!me&&!ve&&!je&&!Sb(d))return t.jsx(XE,{});const Ve=d,de=Nb(d,i(),f),Oe=async(ie,Ce,tt)=>{j(ie),x(null);try{await Ce()}catch(Ie){x(Ht(Ie,tt))}finally{j(null)}},ze=()=>Oe("pause",async()=>{G.current++,F(null);const{composio:ie,...Ce}=await e.updateTrigger(r,{enabled:!d.enabled});G.current++,u(Ce),F((ie==null?void 0:ie.note)??null)},d.enabled?"the pause":"the resume"),De=()=>Oe("delete",async()=>{const ie=await e.deleteTrigger(r);ie!=null&&ie.composio?q(ie.composio.note):n("#/triggers")},"the delete"),Ne=async()=>{if(!O.current){O.current=!0,P(!0),x(null),_(null);try{_((await e.rotateTriggerSecret(r)).signing_secret??null)}catch(ie){x(Ht(ie,"the new secret"))}finally{O.current=!1,P(!1)}}},Q=async()=>{if(!U.current){U.current=!0,j("fire"),x(null),G.current++;try{const ie=await e.fireTrigger(r,Od());G.current++,g(Ce=>[ie,...Ce.filter(tt=>tt.key!==ie.key)]),await z().catch(()=>{})}catch(ie){x(Ht(ie,"the run now"))}finally{U.current=!1,j(null)}}},be=typeof Ve.target.input.content=="string"?Ve.target.input.content:null;return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(On,{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&&!de&&t.jsx(QE,{trigger:d})]}),t.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:ne?`Webhook · ${jE(ne.source)}`:me?`GitHub · ${SE(me.source)}`:ve?`App · ${kE(ve.source)}`:je?`Feed · ${NE(je.source)}`:t.jsx("span",{title:JE(d),children:kb(Ve.source,d.next_at,{instead:YE(de),now:i()})})})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 self-stretch sm:self-auto",children:[!(de&&"ran"in de)&&t.jsx(B,{size:"sm",onClick:()=>void ze(),disabled:b!==null,children:d.enabled?t.jsxs(t.Fragment,{children:[t.jsx(il,{"aria-hidden":!0})," Pause"]}):t.jsxs(t.Fragment,{children:[t.jsx(Jo,{"aria-hidden":!0})," Resume"]})}),t.jsxs(B,{size:"sm",onClick:()=>n(`${Un(r)}/edit`),children:[t.jsx(tv,{"aria-hidden":!0})," ",ne||me||ve?"Edit filter":je?"Edit feed":"Edit"]}),ne&&(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),Ne()},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:b!==null||L,children:[t.jsx(Da,{"aria-hidden":!0})," Rotate secret"]})),k?t.jsxs("span",{className:"flex items-center gap-2 border border-destructive/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Delete this trigger?",children:[t.jsx("span",{children:"Delete for good? Its runs stay."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>{E(!1),De()},children:"Yes, delete"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>E(!1),children:"Keep"})]}):t.jsxs(B,{size:"sm",variant:"destructive",onClick:()=>E(!0),disabled:b!==null,children:[t.jsx(XN,{"aria-hidden":!0})," Delete"]}),t.jsxs(B,{size:"sm",variant:"solid",onClick:()=>void Q(),disabled:b==="fire",children:[t.jsx(xR,{"aria-hidden":!0})," ",b==="fire"?"Starting":"Run now"]})]})]}),im(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:[im(d,c)," ",((nt=d.disabled)==null?void 0:nt.reason)==="source_unreadable"?je?"Edit its feeds, then Resume.":"Edit its when, then Resume.":((fe=d.disabled)==null?void 0:fe.reason)==="auto_paused"?de&&"passed"in de?"Its time has passed: edit its time first, then Resume.":de?"":"Resume turns it on again.":""]}),h&&t.jsx(Jt,{problem:h,className:"mt-4"}),M&&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:M}),ne&&$&&t.jsx(Lb,{label:"The webhook's new secret",secret:$}),je&&t.jsx(vU,{check:je.last_check??null,newest:f[0]}),t.jsxs("dl",{className:"mt-5 grid grid-cols-1 gap-x-6 gap-y-3 border p-4 text-body sm:grid-cols-[max-content_minmax(0,1fr)]",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Agent"}),t.jsx("dd",{className:"min-w-0 break-words",children:t.jsx("a",{href:dn(Ve.target.agent_id),className:"hover:underline",children:s(Ve.target.agent_id)||Ve.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:be??JSON.stringify(Ve.target.input)}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),t.jsx("dd",{className:"font-mono",children:Y6(Ve.target.max_cost_usd,V)}),ne?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:nd(ne)}),t.jsx(e$,{text:nd(ne),label:"Copy URL"}),t.jsx("span",{className:"basis-full text-small text-muted-foreground",children:Eb})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("dd",{children:Ox[ne.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:(Le=ne.source.accept)!=null&&Le.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ne.source.accept.map((ie,Ce)=>t.jsx("li",{children:Uo(ie)},Ce))}):"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(([ie,Ce])=>{var tt;return t.jsxs("li",{children:[ie,": ",(tt=ve.source.sealed_config)!=null&&tt.includes(ie)?t.jsx("span",{"data-sealed-config":ie,className:"text-muted-foreground",children:"Sealed: kept here, never shown"}):typeof Ce=="string"?Ce:JSON.stringify(Ce)]},ie)})}):"None"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(Ye=ve.source.accept)!=null&&Ye.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ve.source.accept.map((ie,Ce)=>t.jsx("li",{children:Uo(ie)},Ce))}):"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:R?t.jsx("span",{"data-on-composio":R,className:R==="missing"?"text-warning-text":void 0,children:lU[R]}):t.jsx("span",{className:"text-muted-foreground",children:"Not read"})})]}):me?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:me.source.accept.map((ie,Ce)=>t.jsx("li",{children:Uo(ie)},Ce))}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):je?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Feeds"}),t.jsx("dd",{className:"min-w-0 break-words",children:t.jsx("ul",{className:"space-y-1 font-mono text-small",children:je.source.urls.map(ie=>t.jsx("li",{className:"break-all",children:fr(ie)?t.jsx("a",{href:fr(ie),target:"_blank",rel:"noreferrer",className:"hover:underline",children:ie}):ie},ie))})}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Read"}),t.jsxs("dd",{children:["Every ",jb(je.source.every_s??RE)]}),(je.source.items!==void 0||je.source.id!==void 0)&&t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"JSON list"}),t.jsxs("dd",{className:"min-w-0 break-words font-mono text-small",children:["Items at ",je.source.items?je.source.items:"the whole document"," · Id at ",je.source.id??"/id"]})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(ht=je.source.accept)!=null&&ht.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:je.source.accept.map((ie,Ce)=>t.jsx("li",{children:Uo(ie)},Ce))}):"Every new or updated item"})]}):t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"While a run is going"}),t.jsx("dd",{children:"The next time is skipped."})]})]}),t.jsxs("section",{className:"mt-6","aria-label":"Firings",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Firings"}),f.length?t.jsx("ul",{className:"mt-3 border",children:f.map(ie=>t.jsxs("li",{"data-firing":ie.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(Se,{tone:Z8[ie.status],children:Z6[ie.status]}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:bl(ie.nominal_at)})]}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:ie.status==="started"?`${Q6[ie.by]}${ie.catch_up?", caught up late":""}`:`${CE(ie)}${ie.catch_up?" · caught up late":""}${ie.by==="manual"?" · Run now":""}`}),ie.run_id&&t.jsxs("a",{href:`#/runs/${encodeURIComponent(ie.run_id)}`,className:"shrink-0 font-mono text-small underline-offset-2 hover:underline",children:["Run ",sa(ie.run_id)]})]},ie.key))}):t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function dU({v2:e,go:n,id:s,minEvery:r,now:o}){const[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(0);return p.useEffect(()=>{e.getTrigger(s).then(c,y=>u(Ht(y,"the trigger")))},[e,s,f]),i?Cb(i)||wE(i)||_b(i)?t.jsx(xU,{v2:e,go:n,trigger:i}):TE(i)?t.jsx(r$,{v2:e,go:n,trigger:i,minEvery:r}):Sb(i)?t.jsx(ZE,{v2:e,go:n,trigger:i,minEvery:r,now:o}):t.jsx(XE,{}):d?t.jsx(Jt,{problem:d,onRetry:()=>g(y=>y+1)}):t.jsx(Hn,{label:"Loading the trigger",rows:4})}function Mt({label:e,field:n,issue:s,hint:r,children:o}){return t.jsx(xt,{className:"min-w-0",label:e,hint:r,error:s?t.jsx("span",{"data-issue":n,children:s}):void 0,children:o})}const Id=e=>e!==void 0?`${oa(e)}, the agent's default`:void 0;async function zd(e){const n=[];let s=null;for(let r=0;r<20;r++){const o=await e.listAgents({cursor:s});if(n.push(...o.agents),s=o.next_cursor,!s)break}return n}function ZE({v2:e,go:n,trigger:s,minEvery:r,now:o=Date.now}){var F,I,q;const[i,c]=p.useState(()=>s?v8(s):vE()),[d,u]=p.useState(null),[f,g]=p.useState({}),[y,v]=p.useState([]),[h,x]=p.useState(!1),b=p.useRef(Js()).current;p.useEffect(()=>{zd(e).then(u,()=>u([]))},[e]);const j=W=>K=>c(U=>({...U,[W]:K})),k=W=>{var U;j("at")(W);const K=Ki(W,(U=i.read)==null?void 0:U.at);K!==null&&Date.parse(K)>o()?g(({"source.at":H,...G})=>G):K!==null&&g(H=>H["source.at"]?{...H,"source.at":P0(K,{now:o()})}:H)},E=new Set(["name","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd",...s?[]:["enabled"]]),S=(F=(d??[]).find(W=>W.agent_id===i.agentId))==null?void 0:F.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,_=async W=>{var H;W.preventDefault();const{body:K,issues:U}=z0(i,$);if(v([]),!K){g(U??{});return}g({}),x(!0);try{if(s){const G=D0(s,K);Object.keys(G).length&&await e.updateTrigger(s.id,G),n(Un(s.id))}else{const G=await e.createTrigger(K,b.keyFor("createTrigger",K));n(Un(G.id))}}catch(G){const z=Ll(G),V=i.kind==="at"?Ki(i.at,(H=i.read)==null?void 0:H.at):null,se=z.fields["source.at"];se&&V!==null&&(Date.parse(V)<=o()||tU.test(se))&&(z.fields["source.at"]=P0(V,{now:o()})),g(Object.fromEntries(Object.entries(z.fields).filter(([J])=>E.has(J)))),v([...z.rest,...Object.entries(z.fields).filter(([J])=>!E.has(J)).map(([,J])=>J)]),x(!1)}},O=s?z0(i,$).body:void 0,L=!!(s&&O&&D0(s,O).source),P=i.kind==="at"?Ki(i.at,(I=i.read)==null?void 0:I.at):null,R=i.startAt?Ki(i.startAt,(q=i.read)==null?void 0:q.startAt):null,A=Tl((d??[]).filter(W=>!W.archived_at||W.agent_id===i.agentId)),M=[{kind:"cron",label:"Repeats"},{kind:"at",label:"Once"},{kind:"every",label:"Every"}];return t.jsxs("form",{onSubmit:W=>void _(W),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Un(s.id):"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(On,{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(cd,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit schedule":"New schedule"]}),y.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:y.map((W,K)=>t.jsx("p",{children:W},K))}),t.jsxs("div",{className:`mt-5 ${gd}`,children:[t.jsx(Mt,{label:"Name",field:"name",issue:f.name,children:t.jsx(Pe,{name:"name",value:i.name,onChange:W=>j("name")(W.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:M.map(({kind:W,label:K})=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${i.kind===W?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"kind",value:W,checked:i.kind===W,onChange:()=>j("kind")(W),className:"accent-primary"}),K]},W))}),t.jsxs("div",{className:"mt-3 grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-4",children:[i.kind==="cron"&&t.jsx(Mt,{label:"Runs",field:"source.cron",issue:f["source.cron"],children:t.jsx(ME,{label:"Runs",name:"cron",value:i.cron,onChange:j("cron")})}),i.kind==="at"&&t.jsx(Mt,{label:"At, your time",field:"source.at",issue:f["source.at"],hint:P?`= ${I0(P)}`:void 0,children:t.jsx(Pe,{name:"at",type:"datetime-local",step:60,value:i.at,onChange:W=>k(W.target.value)})}),i.kind==="every"&&t.jsx(Mt,{label:"Every",field:"source.every_s",issue:f["source.every_s"],hint:r?$b(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Pe,{name:"every",inputMode:"decimal",value:i.every,onChange:W=>j("every")(W.target.value),placeholder:"5"}),t.jsx(Et,{id:"schedule-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:i.everyUnit,onChange:W=>j("everyUnit")(W),options:["seconds","minutes","hours"].map(W=>({value:W,label:W}))})]})}),i.kind==="cron"&&t.jsx(Mt,{label:"Time zone",field:"source.timezone",issue:f["source.timezone"],hint:"The time zone this schedule runs in.",children:t.jsx(PE,{name:"timezone",label:"Time zone",className:"w-full",value:i.timezone,onChange:j("timezone")})}),i.kind==="every"&&t.jsx(Mt,{label:"Starting, your time (optional)",field:"source.start_at",issue:f["source.start_at"],hint:R?`= ${I0(R)}`:void 0,children:t.jsx(Pe,{name:"startAt",type:"datetime-local",step:60,value:i.startAt,onChange:W=>j("startAt")(W.target.value)})})]}),L&&t.jsx("p",{className:"mt-3 text-small text-warning-text",role:"note",children:"Changing when restarts the schedule from now."})]}),t.jsx(Mt,{label:"Agent",field:"target.agent_id",issue:f["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:i.agentId,onChange:W=>j("agentId")(W),options:[{value:"",label:d?"Pick an agent":"Loading the agents"},...A.map(W=>({value:W.agent_id,label:`${W.definition.name||W.agent_id}${W.kind==="workflow"?" (workflow)":""}`})),...i.agentId&&d&&!A.some(W=>W.agent_id===i.agentId)?[{value:i.agentId,label:i.agentId}]:[]]})}),t.jsx(Mt,{label:"Each run is asked",field:"target.input",issue:f["target.input"],children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:i.content,onChange:W=>j("content")(W.target.value)})}),t.jsx(Mt,{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 (${oa(N)}) if empty.`:$?"Uses the agent's default if empty.":"Required: each run this schedule starts stops at this spend.",children:t.jsx(Pe,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:i.maxCost,onChange:W=>j("maxCost")(W.target.value),placeholder:Id(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:W=>j("enabled")(W.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?Un(s.id):"#/triggers"),children:"Cancel"})]})]})}function e$({text:e,label:n}){const[s,r]=p.useState(null),o="The browser won't copy here. Select it and copy it.",i=()=>{const c=typeof navigator<"u"?navigator.clipboard:void 0;if(!(c!=null&&c.writeText)){r(o);return}c.writeText(e).then(()=>r("Copied"),()=>r(o))};return t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[t.jsxs(B,{type:"button",size:"sm",onClick:i,children:[t.jsx(Xa,{"aria-hidden":!0})," ",n]}),s&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:s})]})}function Lb({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(zx,{title:"URL",text:s,label:"Copy URL",hint:Eb}),t.jsx(zx,{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 zx({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(e$,{text:n,label:s})]}),r&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:r})]})}const uU=["standard","github"];function fU({v2:e,go:n}){var $;const[s,r]=p.useState(n8),[o,i]=p.useState(null),[c,d]=p.useState({}),[u,f]=p.useState([]),[g,y]=p.useState(!1),[v,h]=p.useState(null),x=p.useRef(Js()).current;p.useEffect(()=>{zd(e).then(i,()=>i([]))},[e]);const b=_=>O=>r(L=>({...L,[_]:O})),j=($=(o??[]).find(_=>_.agent_id===s.agentId))==null?void 0:$.definition.max_cost_usd,k=typeof j=="number"&&j>0?j:void 0,E=async _=>{_.preventDefault();const O=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd",...Md(s.accept.map(R=>R.where.length))]),{body:L,issues:P}=s8(s,k!==void 0);if(f([]),!L){d(P??{});return}d({}),y(!0);try{h(await e.createTrigger(L,x.keyFor("createTrigger",L)))}catch(R){const A=Ll(R);d(Object.fromEntries(Object.entries(A.fields).filter(([M])=>O.has(M)))),f([...A.rest,...Object.entries(A.fields).filter(([M])=>!O.has(M)).map(([,M])=>M)])}finally{y(!1)}},S=t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(On,{className:"size-3.5","aria-hidden":!0})," Triggers"]});if(v)return t.jsxs("div",{className:"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(ll,{className:"size-5 text-primary-text","aria-hidden":!0}),v.name]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:`Send each request to this URL, signed with this secret (${Ox[v.source.kind==="webhook"?v.source.signature??"standard":"standard"]}). Each one starts a run.`}),v.signing_secret?t.jsx(Lb,{label:"The webhook's URL and secret",url:nd(v),secret:v.signing_secret}):t.jsxs("section",{"aria-label":"The webhook's URL and secret",className:"mt-4 space-y-3 border p-4 text-body",children:[t.jsx(zx,{title:"URL",text:nd(v),label:"Copy URL",hint:Eb}),v.note&&t.jsx("p",{role:"note",children:v.note})]}),t.jsx("div",{className:"mt-6",children:t.jsx(B,{type:"button",size:"lg",variant:"solid",onClick:()=>n(Un(v.id)),children:"Done"})})]});const N=Tl((o??[]).filter(_=>!_.archived_at));return t.jsxs("form",{onSubmit:_=>void E(_),className:"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(ll,{className:"size-5 text-primary-text","aria-hidden":!0}),"New webhook"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each signed request to its URL starts a capped run of the agent. Its URL and signing secret show once it is made."}),u.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:u.map((_,O)=>t.jsx("p",{children:_},O))}),t.jsxs("div",{className:`mt-5 ${gd}`,children:[t.jsx(Mt,{label:"Name",field:"name",issue:c.name,children:t.jsx(Pe,{name:"name",value:s.name,onChange:_=>b("name")(_.target.value),placeholder:"on deploy"})}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:uU.map(_=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${s.signature===_?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"signature",value:_,checked:s.signature===_,onChange:()=>b("signature")(_),className:"accent-primary"}),Ox[_]]},_))}),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(t$,{signature:s.signature,rules:s.accept,onChange:b("accept"),issues:c,cap:null}),t.jsx(Mt,{label:"Agent",field:"target.agent_id",issue:c["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:s.agentId,onChange:_=>b("agentId")(_),options:[{value:"",label:o?"Pick an agent":"Loading the agents"},...N.map(_=>({value:_.agent_id,label:`${_.definition.name||_.agent_id}${_.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Mt,{label:"Each run is asked",field:"target.input",issue:c["target.input"],children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:s.content,onChange:_=>b("content")(_.target.value)})}),t.jsx(Mt,{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 (${oa(k)}) if empty.`:"Required: each run this webhook starts stops at this spend.",children:t.jsx(Pe,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:s.maxCost,onChange:_=>b("maxCost")(_.target.value),placeholder:Id(k)})})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:g,children:g?"Creating":"Create webhook"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function mU({v2:e,go:n}){var A;const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(0),[u,f]=p.useState(r8),[g,y]=p.useState(null),[v,h]=p.useState({}),[x,b]=p.useState([]),[j,k]=p.useState(!1),E=p.useRef(Js()).current,S=p.useRef(!0);p.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]),p.useEffect(()=>{let M=!0;return i(null),e.githubConnection().then(F=>{M&&r(!!F&&"app_id"in F&&!!F.app_id)},F=>{M&&(F instanceof Ue&&F.status===404?r(!1):i(Ht(F,"GitHub's connection")))}),()=>{M=!1}},[e,c]),p.useEffect(()=>{zd(e).then(y,()=>y([]))},[e]);const N=M=>F=>f(I=>({...I,[M]:F})),$=(A=(g??[]).find(M=>M.agent_id===u.agentId))==null?void 0:A.definition.max_cost_usd,_=typeof $=="number"&&$>0?$:void 0,O=async M=>{M.preventDefault();const F=new Set(["name","target.agent_id","target.input","target.max_cost_usd",...Md(ih(u).map(W=>W.where.length))]),{body:I,issues:q}=x8(u,_!==void 0);if(b([]),!I){h(q??{});return}h({}),k(!0);try{const W=await e.createTrigger(I,E.keyFor("createTrigger",I));S.current&&n(Un(W.id))}catch(W){const K=Ll(W);h(Object.fromEntries(Object.entries(K.fields).filter(([U])=>F.has(U)))),b([...K.rest,...Object.entries(K.fields).filter(([U])=>!F.has(U)).map(([,U])=>U)]),k(!1)}},L=t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(On,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),P=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(bm,{className:"size-5 text-primary-text","aria-hidden":!0}),"New GitHub trigger"]});if(o)return t.jsxs("div",{className:"p-5 md:p-8",children:[L,P,t.jsx(Jt,{problem:o,onRetry:()=>d(M=>M+1),className:"mt-4"})]});if(s===null)return t.jsx(Hn,{label:"Reading GitHub's connection",rows:3});if(!s)return t.jsxs("div",{className:"p-5 md:p-8",children:[L,P,t.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Connect GitHub first: ",t.jsx("a",{href:"#/settings/github",className:"underline underline-offset-2",children:"Settings → GitHub"}),". A GitHub trigger takes events from this server's GitHub App."]})]});const R=Tl((g??[]).filter(M=>!M.archived_at));return t.jsxs("form",{onSubmit:M=>void O(M),className:"p-5 md:p-8",noValidate:!0,children:[L,P,t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event it takes from this server's GitHub App starts a capped run of the agent."}),x.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:x.map((M,F)=>t.jsx("p",{children:M},F))}),t.jsxs("div",{className:`mt-5 ${gd}`,children:[t.jsx(Mt,{label:"Name",field:"name",issue:v.name,children:t.jsx(Pe,{name:"name",value:u.name,onChange:M=>N("name")(M.target.value),placeholder:"review PRs"})}),t.jsx(n$,{picks:u,onChange:M=>f(F=>({...F,...M})),issues:v}),t.jsx(Mt,{label:"Agent",field:"target.agent_id",issue:v["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:u.agentId,onChange:M=>N("agentId")(M),options:[{value:"",label:g?"Pick an agent":"Loading the agents"},...R.map(M=>({value:M.agent_id,label:`${M.definition.name||M.agent_id}${M.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Mt,{label:"Each run is asked",field:"target.input",issue:v["target.input"],hint:"The event's payload comes with it.",children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:u.content,onChange:M=>N("content")(M.target.value)})}),t.jsx(Mt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:v["target.max_cost_usd"],hint:_!==void 0?`Uses the agent's default (${oa(_)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(Pe,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:u.maxCost,onChange:M=>N("maxCost")(M.target.value),placeholder:Id(_)})})]}),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 hU({v2:e,go:n,noAddress:s}){var Ve;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(0),[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(0),[b,j]=p.useState(c8),[k,E]=p.useState(null),[S,N]=p.useState({}),[$,_]=p.useState([]),[O,L]=p.useState(null),[P,R]=p.useState(null),[A,M]=p.useState(!1),F=p.useRef(Js()).current,I=p.useRef(!0);p.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]),p.useEffect(()=>{let de=!0;return c(null),e.listMcpServers().then(Oe=>{if(!de)return;const ze=Oe.servers.filter(De=>De.source==="composio");o(ze),ze.length===1&&j(De=>De.server?De:{...De,server:ze[0].name})},Oe=>{de&&c(Ht(Oe,"the saved MCP servers"))}),()=>{de=!1}},[e,d]),p.useEffect(()=>{if(!b.server)return;let de=!0;const Oe=b.server;return g(null),v(null),e.composioEvents(Oe).then(ze=>{de&&g({server:Oe,events:ze.events})},ze=>{de&&v(Ht(ze,`${Oe}'s events`))}),()=>{de=!1}},[e,b.server,h]),p.useEffect(()=>{zd(e).then(E,()=>E([]))},[e]);const q=de=>{R(null),j(de)},W=de=>Oe=>q(ze=>({...ze,[de]:Oe})),K=de=>q(Oe=>Oe.server===de?Oe:{...Oe,server:de,event:"",config:{},where:[]}),U=de=>{q(Oe=>Oe.event===de?Oe:{...Oe,event:de,config:{},where:[]}),N({})},H=(f==null?void 0:f.server)===b.server?f.events.find(de=>de.slug===b.event):void 0,G=i8(H==null?void 0:H.config,H==null?void 0:H.sealed),z=(Ve=(k??[]).find(de=>de.agent_id===b.agentId))==null?void 0:Ve.definition.max_cost_usd,V=typeof z=="number"&&z>0?z:void 0,se=async de=>{var ze,De;const Oe=new Set(["name","source.server","source.event","source.config",...G.map(Ne=>`source.config.${Ne.name}`),"target.agent_id","target.input","target.max_cost_usd",...b.where.length?Md([b.where.length]):[]]);N({}),_([]),L(null),R(null),M(!0);try{const Ne=await e.createTrigger(de,F.keyFor("createTrigger",de));I.current&&n(Un(Ne.id));return}catch(Ne){if(Ne instanceof Ue&&Ne.code==="composio_subscription_elsewhere")R({url:typeof((ze=Ne.details)==null?void 0:ze.webhook_url)=="string"?Ne.details.webhook_url:"another address",body:de});else if(Ne instanceof Ue&&Ne.code.startsWith("composio_"))_([Ne.message]),Ne.code==="composio_not_connected"&&L(fr(typeof((De=Ne.details)==null?void 0:De.connect_url)=="string"?Ne.details.connect_url:null)??null);else{const Q=Ll(Ne);N(Object.fromEntries(Object.entries(Q.fields).filter(([be])=>Oe.has(be)))),_([...Q.rest,...Object.entries(Q.fields).filter(([be])=>!Oe.has(be)).map(([,be])=>be)])}}M(!1)},J=()=>u8(b,G,V!==void 0),re=de=>{de.preventDefault();const{body:Oe,issues:ze}=J();if(_([]),L(null),!Oe){N(ze??{});return}se(Oe)},ne=()=>{const de=P;R(null),de&&se({...de.body,source:{...de.body.source,move_subscription:!0}})},me=t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(On,{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(gm,{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:[me,ve,t.jsx(Jt,{problem:i,onRetry:()=>u(de=>de+1),className:"mt-4"})]});if(r===null)return t.jsx(Hn,{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:[me,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 je=Tl((k??[]).filter(de=>!de.archived_at));return t.jsxs("form",{onSubmit:re,className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[me,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:Ob}),$.length>0&&t.jsxs("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:[$.map((de,Oe)=>t.jsx("p",{className:"break-words",children:de},Oe)),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(Mt,{label:"Name",field:"name",issue:S.name,children:t.jsx(Pe,{name:"name",value:b.name,onChange:de=>W("name")(de.target.value),placeholder:"new issues"})}),t.jsx(Mt,{label:"Composio server",field:"source.server",issue:S["source.server"],children:t.jsx(Et,{name:"server",label:"Composio server",className:"w-full",value:b.server,onChange:K,options:[{value:"",label:"Pick a server"},...r.map(de=>({value:de.name,label:de.toolkit?`${de.name} (${de.toolkit})`:de.name}))]})}),b.server&&(y?t.jsx(Jt,{problem:y,onRetry:()=>x(de=>de+1),className:""}):t.jsx(Mt,{label:"Event",field:"source.event",issue:S["source.event"],hint:H==null?void 0:H.description,children:t.jsx(Et,{name:"event",label:"Event",className:"w-full",value:b.event,onChange:U,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(de=>({value:de.slug,label:de.name||de.slug}))]})})),H&&t.jsxs(t.Fragment,{children:[H.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."}),H.instructions&&t.jsx("p",{className:"whitespace-pre-wrap text-small text-muted-foreground",children:H.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:H.slug}),"."]}),t.jsx(mr,{issues:S,field:"source.config"}),G.length?t.jsx("div",{className:"space-y-4",children:G.map(de=>t.jsx(pU,{field:de,value:b.config[de.name]??de.initial,issue:S[`source.config.${de.name}`],onChange:Oe=>q(ze=>({...ze,config:{...ze.config,[de.name]:Oe}}))},`${H.slug}:${de.name}`))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"This event takes no config."})]}),t.jsx(s$,{where:b.where,onChange:W("where"),issues:S})]}),t.jsx(Mt,{label:"Agent",field:"target.agent_id",issue:S["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:b.agentId,onChange:de=>W("agentId")(de),options:[{value:"",label:k?"Pick an agent":"Loading the agents"},...je.map(de=>({value:de.agent_id,label:`${de.definition.name||de.agent_id}${de.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Mt,{label:"Each run is asked",field:"target.input",issue:S["target.input"],hint:"What Composio delivered comes with it.",children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:b.content,onChange:de=>W("content")(de.target.value)})}),t.jsx(Mt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:S["target.max_cost_usd"],hint:V!==void 0?`Uses the agent's default (${oa(V)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(Pe,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:b.maxCost,onChange:de=>W("maxCost")(de.target.value),placeholder:Id(V)})})]}),P&&t.jsxs("div",{role:"alertdialog","aria-label":"Move the subscription here?",className:"mt-6 space-y-3 border border-warning/50 p-4 text-body",children:[t.jsxs("p",{children:["Composio sends this project's events to ",t.jsx("code",{className:"break-all font-mono text-small",children:P.url})," now. Moving them here stops them arriving there: anything listening at ",t.jsx("code",{className:"break-all font-mono text-small",children:P.url})," (another AgentRun server, or a tool of yours) gets no more events."]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"solid",onClick:ne,children:"Move it here"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>R(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:A||!!P||s,children:A?"Creating":"Create app trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function pU({field:e,value:n,issue:s,onChange:r}){const o=`config-${e.name}`,i=s?t.jsx("span",{"data-issue":`source.config.${e.name}`,children:s}):void 0;return e.type==="boolean"?t.jsxs("div",{"data-config-field":e.name,children:[t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:o,checked:n==="true",onChange:c=>r(c.target.checked?"true":"false"),className:"accent-primary"})," ",e.title]}),e.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.description}),s&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert",children:i})]}):t.jsx("div",{"data-config-field":e.name,children:t.jsx(xt,{className:"min-w-0",label:e.title,required:e.required,optional:!e.required,hint:e.description,error:i,children:e.options?t.jsx(Et,{name:o,label:e.title,className:"w-full",value:n,onChange:r,options:[...e.required?[]:[{value:"",label:"None"}],...e.options.map(c=>({value:c,label:c}))],placeholder:"Pick one"}):e.type==="json"?t.jsx(nn,{name:o,rows:3,className:"p-3 font-mono",value:n,onChange:c=>r(c.target.value),spellCheck:!1}):t.jsx(Pe,{name:o,type:e.sealed?"password":void 0,inputMode:e.type==="string"?void 0:"decimal",value:n,onChange:c=>r(c.target.value),autoComplete:e.sealed?"new-password":"off",spellCheck:!1})})})}function gU(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 t$({signature:e,rules:n,onChange:s,issues:r,cap:o}){return t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(mr,{issues:r,field:"source.accept"}),t.jsx(KE,{name:"accept",rules:n,onChange:s,issues:r,room:Ld.rules-n.length,eventHint:qE[e],eventPlaceholder:e==="github"?"issues":"issue.opened"}),t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:gU(n.length>0,o)})]})]})}function n$({picks:e,onChange:n,issues:s}){const r=i=>n({...e,events:e.events.includes(i)?e.events.filter(c=>c!==i):[...e.events,i]}),o=ih(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:$E.map(i=>{const c=o.indexOf(`event:${i}`),d=`source.accept[${c}]`;return t.jsxs("div",{"data-github-event":i,className:"space-y-1",children:[ah.filter(u=>u.event===i).map(({event:u,action:f,label:g})=>{const y=`${u}:${f}`;return t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"event",value:y,checked:e.events.includes(y),onChange:()=>r(y),className:"accent-primary"}),g," ",t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[u," ",f]})]},y)}),c>=0&&t.jsxs("div",{className:"ml-6 space-y-1 pt-1",children:[[d,`${d}.event`,`${d}.actions`].map(u=>t.jsx(mr,{issues:s,field:u},u)),t.jsx(fh,{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(KE,{name:"other",rules:e.other,onChange:i=>n({...e,other:i}),issues:s,indexOf:i=>{var c;return o.indexOf(`other:${(c=e.other[i])==null?void 0:c.key}`)},room:Ld.rules-o.length,eventHint:qE.github,eventPlaceholder:"issues",addLabel:"Add another event"})]})]})}function xU({v2:e,go:n,trigger:s}){const r=Cb(s)?s:null,o=_b(s)?s:null,[i,c]=p.useState(()=>r?(r.source.accept??[]).map(rm):o?(o.source.accept??[]).map(rm):[]),[d,u]=p.useState(()=>r||o?{events:[],where:{},other:[]}:a8(s.source.accept)),f=o&&i[0]&&!i[0].actions.trim()?i[0]:null,g=o?i.slice(f?1:0):[],[y,v]=p.useState({}),[h,x]=p.useState([]),[b,j]=p.useState(!1),k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const E=async $=>{$.preventDefault();const{source:_,issues:O}=r?EE(r.source,i):o?d8(o.source,(f==null?void 0:f.where)??[],g,f==null?void 0:f.was):_E(d);if(x([]),Object.keys(O).length){v(O);return}v({}),j(!0);try{od(_,s.source)||await e.updateTrigger(s.id,{source:_}),k.current&&n(Un(s.id))}catch(L){if(!k.current)return;const P=Ll(L),R=Md(r||o?i.map(A=>A.where.length):ih(d).map(A=>A.where.length));v(Object.fromEntries(Object.entries(P.fields).filter(([A])=>R.has(A)))),x([...P.rest,...Object.entries(P.fields).filter(([A])=>!R.has(A)).map(([,A])=>A)]),j(!1)}},S=r?ll:o?gm:bm,N=$=>c(f?$.length?[{...f,where:$},...g]:g:$.length?[{...uE(),event:o.source.event,where:$},...g]:g);return t.jsxs("form",{onSubmit:$=>void E($),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:Un(s.id),className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(On,{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.":o?`Which ${o.source.event} events from ${o.source.server} start a run. Its event, its config and its instance on Composio stay as they are.`:"Which events from this server's GitHub App start a run."}),h.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:h.map(($,_)=>t.jsx("p",{children:$},_))}),t.jsx("div",{className:"mt-5 space-y-5",children:r?t.jsx(t$,{signature:r.source.signature??"standard",rules:i,onChange:c,issues:y,cap:s.max_active_runs??null}):o?t.jsx(s$,{where:(f==null?void 0:f.where)??[],onChange:N,issues:y,others:g.map($=>$.event+($.actions.trim()?` (${$.actions.trim()})`:""))}):t.jsx(n$,{picks:d,onChange:u,issues:y})}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:b,children:b?"Saving":"Save filter"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(Un(s.id)),children:"Cancel"})]})]})}function s$({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(mr,{issues:s,field:"source.accept"}),t.jsx(mr,{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(fh,{name:"composio",at:"source.accept[0]",where:e,onChange:n,issues:s,label:"Only when"}),r.length>0&&t.jsxs("p",{className:"text-small text-muted-foreground",role:"note",children:[r.length===1?"One more rule, made through the API, is kept as it is":`${r.length} more rules, made through the API, are kept as they are`,": ",r.join(", "),"."]})]})]})}function vU({check:e,newest:n}){const s=n&&n.by==="feed"&&n.status==="skipped"&&!n.run_id&&n.reason?n.reason:null;return t.jsxs("section",{"aria-label":"Last check","data-last-check":e?e.ok?"ok":"failed":"none",className:`mt-4 border px-4 py-3 text-body ${e&&!e.ok?"border-warning/50 bg-warning/10":"border-primary/50 bg-primary/5"}`,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:e?`${e.ok?"Last check":"Last check failed"} · ${bl(e.at)}`:"Not checked yet"}),e&&t.jsx("p",{className:`mt-1 break-words ${e.ok?"":"text-warning-text"}`,children:e.message}),s&&t.jsx("p",{className:"mt-1 break-words","data-note":!0,children:s})]})}function r$({v2:e,go:n,trigger:s,minEvery:r}){var P;const[o,i]=p.useState(()=>s?m8(s):AE()),[c,d]=p.useState(null),[u,f]=p.useState({}),[g,y]=p.useState([]),[v,h]=p.useState(!1),[x,b]=p.useState(()=>!!s&&(s.source.items!==void 0||s.source.id!==void 0));p.useEffect(()=>{(u["source.items"]||u["source.id"])&&b(!0)},[u]);const j=p.useRef(Js()).current,k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]),p.useEffect(()=>{s||zd(e).then(d,()=>d([]))},[e,s]);const E=R=>A=>i(M=>({...M,[R]:A})),S=(P=(c??[]).find(R=>R.agent_id===o.agentId))==null?void 0:P.definition.max_cost_usd,N=typeof S=="number"&&S>0?S:void 0,$=async R=>{R.preventDefault();const A=g8(OE(o.urls).urls.length,[o.where.length,...o.others.map(q=>q.where.length)]);y([]);const M=q=>{if(!k.current)return;const W=Ll(q);f(Object.fromEntries(Object.entries(W.fields).filter(([K])=>A.has(K)))),y([...W.rest,...Object.entries(W.fields).filter(([K])=>!A.has(K)).map(([,K])=>K)]),h(!1)};if(s){const{source:q,issues:W}=LE(o,r);if(Object.keys(W).length){f(W);return}f({}),h(!0);try{od(q,s.source)||await e.updateTrigger(s.id,{source:q}),k.current&&n(Un(s.id))}catch(K){M(K)}return}const{body:F,issues:I}=p8(o,r,N!==void 0);if(!F){f(I??{});return}f({}),h(!0);try{const q=await e.createTrigger(F,j.keyFor("createTrigger",F));k.current&&n(Un(q.id))}catch(q){M(q)}},_=Object.entries(u).filter(([R])=>/^source\.urls(\[\d+\])?$/.test(R)),O=Tl((c??[]).filter(R=>!R.archived_at)),L=o.others.map(R=>R.event+(R.actions.trim()?` (${R.actions.trim()})`:""));return t.jsxs("form",{onSubmit:R=>void $(R),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Un(s.id):"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(On,{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(nv,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit feed":"New feed trigger"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:s?"The feeds it reads, how often, and which items start a run. Its name, its agent and what each run is asked stay as they are.":"Each new or updated item in its feeds starts a capped run of the agent. The items already there when it is made start none: its first check, on its page once it is made, says how many."}),g.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:g.map((R,A)=>t.jsx("p",{children:R},A))}),t.jsxs("div",{className:`mt-5 ${gd}`,children:[!s&&t.jsx(Mt,{label:"Name",field:"name",issue:u.name,children:t.jsx(Pe,{name:"name",value:o.name,onChange:R=>E("name")(R.target.value),placeholder:"vendor outages"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(xt,{className:"min-w-0",label:"Feed URLs",hint:`One a line, 1 to ${Mx}: RSS, Atom, JSON Feed, or an API's JSON list. Plain http is read on a public address alone.`,error:_.length?t.jsx(t.Fragment,{children:_.map(([R,A])=>t.jsx("span",{"data-issue":R,className:"block",children:A},R))}):void 0,children:t.jsx(nn,{name:"urls",rows:4,className:"p-3 font-mono text-small",value:o.urls,onChange:R=>E("urls")(R.target.value),placeholder:"https://www.githubstatus.com/history.atom",spellCheck:!1})}),s&&t.jsx("p",{className:"mt-2 text-small text-warning-text",role:"note",children:"A feed you add starts from now: what's in it already won't start runs."})]}),t.jsx(Mt,{label:"Every",field:"source.every_s",issue:u["source.every_s"],hint:r?$b(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Pe,{name:"every",inputMode:"decimal",value:o.every,onChange:R=>E("every")(R.target.value),placeholder:"15"}),t.jsx(Et,{id:"feed-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:o.everyUnit,onChange:R=>E("everyUnit")(R),options:["seconds","minutes","hours"].map(R=>({value:R,label:R}))})]})}),t.jsxs("details",{"data-json-list":!0,open:x,onToggle:R=>b(R.currentTarget.open),className:"min-w-0 border p-3",children:[t.jsxs("summary",{className:"cursor-pointer text-body font-semibold",children:["JSON list ",t.jsx("span",{className:"font-normal text-small text-muted-foreground",children:"(optional: a feed that is an API's JSON, such as GitHub's pull requests)"})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(Mt,{label:"Items at",field:"source.items",issue:u["source.items"],hint:"A JSON Pointer to the array of items: empty for the whole document, /data/items for one inside it.",children:t.jsx(Pe,{name:"items",value:o.items,onChange:R=>E("items")(R.target.value),placeholder:"/data/items",autoComplete:"off",spellCheck:!1})}),t.jsx(Mt,{label:"Each item's id at",field:"source.id",issue:u["source.id"],hint:"A JSON Pointer into an item to what names it: empty for /id, /number for a pull request.",children:t.jsx(Pe,{name:"id",value:o.id,onChange:R=>E("id")(R.target.value),placeholder:"/id",autoComplete:"off",spellCheck:!1})})]})]}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(mr,{issues:u,field:"source.accept"}),t.jsx(mr,{issues:u,field:"source.accept[0]"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"A condition reads the item: /title, /link, /summary, /author, /categories, /feed/url, and /update (true for an item seen before that was updated). A JSON list's item is under /item."}),t.jsx(fh,{name:"feed",at:"source.accept[0]",where:o.where,onChange:E("where"),issues:u,label:"Only when"}),L.length>0&&t.jsxs("p",{className:"text-small text-muted-foreground",role:"note",children:[L.length===1?"One more rule, made through the API, is kept as it is":`${L.length} more rules, made through the API, are kept as they are`,": ",L.join(", "),"."]})]})]}),!s&&t.jsxs(t.Fragment,{children:[t.jsx(Mt,{label:"Agent",field:"target.agent_id",issue:u["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:o.agentId,onChange:R=>E("agentId")(R),options:[{value:"",label:c?"Pick an agent":"Loading the agents"},...O.map(R=>({value:R.agent_id,label:`${R.definition.name||R.agent_id}${R.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Mt,{label:"Each run is asked",field:"target.input",issue:u["target.input"],hint:"The item comes with it: its title, link, summary and feed.",children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:o.content,onChange:R=>E("content")(R.target.value)})}),t.jsx(Mt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:u["target.max_cost_usd"],hint:N!==void 0?`Uses the agent's default (${oa(N)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(Pe,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:o.maxCost,onChange:R=>E("maxCost")(R.target.value),placeholder:Id(N)})})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:v,children:v?s?"Saving":"Creating":s?"Save feed":"Create feed trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(s?Un(s.id):"#/triggers"),children:"Cancel"})]})]})}const o$=e=>e?"#/playground?operation=apply-template":"#/templates";function W0({v2:e,name:n,install:s,go:r,playground:o=!1,draft:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),[g,y]=p.useState(0);p.useEffect(()=>{if(s!==void 0)return;let b=!0;return f(null),e.listTemplates().then(j=>{b&&d(j.templates)},j=>{b&&f(Ht(j,"the templates"))}),()=>{b=!1}},[e,g,s]);const v=n===void 0||c==null?void 0:c.find(b=>b.id===n),h=s!==void 0?t.jsx(yU,{v2:e,source:s,go:r}):u&&!c?t.jsx(Jt,{problem:u,onRetry:()=>y(b=>b+1),className:""}):c?n===void 0?t.jsx(bU,{v2:e,templates:c,go:r,playground:o,onRemoved:()=>y(b=>b+1)}):v?t.jsx(NU,{v2:e,template:v,go:r,playground:o,draft:i},`${v.id}:${i??""}`):t.jsxs("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",role:"alert",children:["This server offers no template named ",n,". ",t.jsx("a",{href:o$(o),className:"underline",children:"See its templates"}),"."]}):t.jsx(Hn,{label:"Loading the templates",rows:3});if(o)return t.jsx("div",{className:"p-5 md:p-8",children:h});const x=s===void 0&&n===void 0;return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsx("header",{className:ae(pr,"flex-wrap gap-2 px-5 md:px-6"),children:x?t.jsxs("h1",{className:Bo,children:[t.jsx(ym,{className:"size-4","aria-hidden":!0}),"Templates"]}):t.jsx("nav",{"aria-label":"Breadcrumb",children:t.jsxs("a",{href:"#/templates",className:ae(Bo,"text-muted-foreground hover:text-foreground"),children:[t.jsx(On,{className:"size-4","aria-hidden":!0}),"Templates"]})})}),t.jsx("div",{className:"p-5 md:p-6",children:h})]})}function Mb({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 bU({v2:e,templates:n,go:s,playground:r,onRemoved:o}){const i=r?"h2":"h1",c=r?"h3":"h2",[d,u]=p.useState(""),[f,g]=p.useState(null),[y,v]=p.useState(null),h=async x=>{g(x.id),v(null);try{await e.deleteTemplate(x.id),o()}catch(b){v(b instanceof Error?b.message:String(b))}finally{g(null)}};return t.jsxs(t.Fragment,{children:[r&&t.jsx(i,{className:"mb-5 text-2xl font-semibold",children:"Templates"}),t.jsxs("form",{"aria-label":"Add from URL",className:"mb-5 flex flex-wrap items-end gap-2 border bg-card px-4 py-3",onSubmit:x=>{x.preventDefault(),d.trim()&&s(wU(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(Pe,{type:"text",value:d,placeholder:"github:owner/repo/templates/name@main",onChange:x=>u(x.target.value)})]}),t.jsx(B,{size:"sm",variant:"solid",type:"submit",disabled:!d.trim(),children:"Read it"})]}),y&&t.jsx("p",{className:"mb-3 text-body text-destructive-text",role:"alert",children:y}),n.length?t.jsx("ul",{className:"grid gap-3 md:grid-cols-2",children:n.map(x=>t.jsx("li",{children:t.jsxs("article",{"aria-label":Wo(x),className:"flex h-full flex-col border bg-card px-5 py-4",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx(ym,{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:Wo(x)}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:x.version}),x.category&&t.jsx(Se,{tone:"muted",children:x.category}),!x.bundled&&t.jsx(Se,{tone:"muted",children:"Imported"})]}),t.jsx(Mb,{t:x}),t.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:x.description}),x.tags.length>0&&t.jsx("p",{"aria-label":"Tags",className:"mt-1.5 break-words font-mono text-small text-muted-foreground",children:x.tags.join(" · ")}),t.jsx("dl",{className:"mt-3 space-y-1 font-mono text-small text-muted-foreground",children:Rb(x).map(([b,j])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0",children:b}),t.jsx("dd",{className:"min-w-0 break-words text-foreground/80",children:j})]},b))}),t.jsxs("div",{className:"mt-auto flex flex-wrap items-center justify-end gap-2 pt-4",children:[!x.bundled&&t.jsx(B,{size:"sm",onClick:()=>void h(x),disabled:f===x.id,children:f===x.id?"Removing…":"Remove"}),r?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>s(rl(x)),children:"Configure"}):t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:lm(x)?"primary":"outline",onClick:()=>s(zE(x.id)),children:"Configure"}),t.jsx(sn,{variant:lm(x)?"outline":"primary",label:"Run",prompt:fx(location.origin,x),playgroundHref:rl(x)})]})]})]})},x.id))}):t.jsx("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",children:"This server offers no templates yet."})]})}function yU({v2:e,source:n,go:s}){var k;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[y,v]=p.useState(null);p.useEffect(()=>{let E=!0;if(!n){c("Give a package's source: github:owner/repo/path@ref.");return}return e.importTemplate(n,{dryRun:!0}).then(S=>{E&&o(S)},S=>{E&&c(H0(S))}),()=>{E=!1}},[e,n]);const h=async()=>{g(!0),v(null);try{if(!r)return;const E=await e.importTemplate(`${r.template.id}@${r.template.sha}`,{trustPublisher:d});s(zE(E.template.id))}catch(E){v(H0(E))}finally{g(!1)}};if(i)return t.jsx("div",{className:"max-w-3xl",children:t.jsx("p",{className:"border px-4 py-6 font-mono text-body text-destructive-text",role:"alert",children:i})});if(!r)return t.jsx(Hn,{label:"Reading the package from GitHub",rows:3});const x=r.template,b=x.publisher??"",j=Object.entries(r.skill_files);return t.jsxs("section",{"aria-label":"Install from GitHub",className:"max-w-3xl",children:[t.jsxs("h1",{className:"font-mono text-2xl font-semibold",children:[Wo(x)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:x.version})]}),t.jsxs("dl",{className:"mt-3 space-y-1 border bg-card px-4 py-3 font-mono text-small",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Publisher"}),t.jsxs("dd",{"data-publisher":!0,children:[b,r.publisher_trusted?" (trusted here)":" (new here)"]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Commit"}),t.jsx("dd",{className:"break-all","data-sha":!0,children:x.sha})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Source"}),t.jsx("dd",{className:"break-all",children:x.source})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Installs as"}),t.jsxs("dd",{className:"break-all",children:[x.id,r.replaced?`, replacing the one read at ${r.replaced.slice(0,12)}`:""]})]})]}),t.jsx("p",{className:"mt-3 text-lead leading-[1.6]",children:x.description}),t.jsx(ur,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:Rb(x,{mcp:!1}).map(([E,S])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:E}),t.jsx("dd",{className:"min-w-0 break-words",children:S})]},E))})}),x.mcp.length>0&&t.jsx(ur,{title:"MCP tools it asks for",note:"None is granted by installing: the Apply screen asks you to tick each one.",children:x.mcp.map(E=>t.jsxs("div",{"data-mcp":E.toolkit,className:"px-4 py-3",children:[t.jsx(a$,{m:E}),t.jsx("p",{className:"mt-1 break-words font-mono text-small",children:E.tools.map(S=>S.name).join(", ")})]},E.toolkit))}),t.jsx(i$,{t:x}),t.jsx(l$,{t:x}),t.jsx(ur,{title:"Instructions",note:"What the agent is told, in full: a package from someone else says this to your agent.",children:t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-instructions":!0,children:r.instructions})}),((k=x.output)==null?void 0:k.json_schema)&&t.jsx(ur,{title:"Output schema",note:`What the agent is told to answer in (${x.output.schema}), in full: its descriptions are instructions too.`,children:t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-output-schema":!0,children:JSON.stringify(x.output.json_schema,null,2)})}),j.length>0&&t.jsx(ur,{title:"Skill files",note:"Every file the agent is given, in full.",children:j.map(([E,S])=>t.jsxs("details",{className:"px-4 py-2","data-skill-file":E,children:[t.jsx("summary",{className:"cursor-pointer font-mono text-body",children:E}),t.jsx("pre",{className:"mt-2 max-h-[32rem] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:S})]},E))}),!r.publisher_trusted&&t.jsxs("label",{className:"mt-6 flex items-start gap-2.5 border border-warning/50 px-4 py-3",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:d,onChange:E=>u(E.target.checked)}),t.jsxs("span",{children:[t.jsxs("span",{className:"font-mono text-body",children:["I trust ",b]}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:["This server has no package from ",b," yet. Ticked, it remembers that you trust them."]})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void h(),disabled:f||!r.publisher_trusted&&!d,children:f?"Installing…":"Install"}),t.jsx("span",{className:"text-small text-muted-foreground",children:"Installing stores it; nothing runs and nothing is granted until you apply it."}),y&&t.jsx("p",{className:"w-full text-body text-destructive-text",role:"alert",children:y})]})]})}function H0(e){var n;return e instanceof Ue&&((n=e.fields)!=null&&n.length)?[...new Set([e.message,...e.fields.map(s=>s.message)])].join(" "):e instanceof Error?e.message:String(e)}const wU=e=>`#/templates/install?src=${encodeURIComponent(e)}`,jU=3e3;function kU(e,n){let s;const r=new Promise(o=>s=setTimeout(()=>o(void 0),n));return Promise.race([e,r]).finally(()=>clearTimeout(s))}function NU({v2:e,template:n,go:s,playground:r=!1,draft:o}){var St,st,ut,Dt,Ft,Rt,pe,he,He,Je;const i=r?"h2":"h1",c={fields:ch(n.parameters)??[]},d=R8(o,n),[u,f]=p.useState(()=>{var X;return{...Object.fromEntries(c.fields.filter(([,ge])=>ge.type==="boolean"&&!ge.array).map(([ge])=>[ge,"false"])),...WE(c),...Object.fromEntries(Object.entries(((X=d.body)==null?void 0:X.parameters)??{}).map(([ge,_e])=>[ge,Array.isArray(_e)?_e.map(String).join(`
|
|
664
|
-
`):String(_e)]))}}),[g,y]=p.useState(()=>{var X;return new Set(((X=d.body)==null?void 0:X.grants)??[])}),[v,h]=p.useState(((st=(St=d.body)==null?void 0:St.overrides)==null?void 0:st.approvals)??n.approvals_default??"ask"),[x,b]=p.useState(((Dt=(ut=d.body)==null?void 0:ut.overrides)==null?void 0:Dt.choice)??""),[j,k]=p.useState(null),[E,S]=p.useState(null),[N,$]=p.useState(0),[_,O]=p.useState(()=>{var X;return((X=d.body)==null?void 0:X.servers)??{}}),[L,P]=p.useState(!1),[R,A]=p.useState([]),[M,F]=p.useState(null),[I,q]=p.useState(null),[W,K]=p.useState([]),[U,H]=p.useState({}),G=p.useRef(Js()).current,z=p.useRef(!0);p.useEffect(()=>(z.current=!0,()=>{z.current=!1}),[]),p.useEffect(()=>{let X=!0;return S(null),e.listMcpServers().then(ge=>{X&&k(ge.servers)},ge=>{X&&S(Ht(ge,"the saved MCP servers"))}),()=>{X=!1}},[e,N]);const V=I8(n,g),se=n.mcp.map(X=>{const ge=j?L8(X,j):[];return{m:X,matches:ge,uses:ge.length===1?ge[0]:ge.includes(_[X.toolkit]??"")?_[X.toolkit]:void 0}}),J=Object.fromEntries(se.flatMap(({m:X,uses:ge})=>ge?[[X.toolkit,ge]]:[])),re=se.filter(({matches:X,uses:ge})=>X.length>1&&!ge).map(({m:X})=>X.toolkit),ne=n.mcp.length>0&&j===null,me=j&&se.some(({m:X,matches:ge})=>{var _e,Ae;return((Ae=(_e=d.body)==null?void 0:_e.servers)==null?void 0:Ae[X.toolkit])!==void 0&&!ge.includes(d.body.servers[X.toolkit])}),ve=d.error??(me?"This prepared server choice no longer matches the saved MCP servers. Open a fresh request to review the current accounts.":void 0),je=!!ve||ne||re.length>0,Ve=r||lm(n),de=!r&&lm(n)?U0.filter(X=>X.needs(n)):[],[Oe,ze]=p.useState({}),[De,Ne]=p.useState(0),Q=de.map(X=>X.id).join(" ");p.useEffect(()=>{let X=!0;for(const ge of U0.filter(_e=>Q.split(" ").includes(_e.id)))ge.met(e).then(_e=>{X&&ze(Ae=>({...Ae,[ge.id]:_e?"met":"unmet"}))},()=>{X&&ze(_e=>({..._e,[ge.id]:"unread"}))});return()=>{X=!1}},[e,Q,De]);const be=de.filter(X=>Oe[X.id]!=="met"),nt=be.find(X=>Oe[X.id]===void 0),fe=be.length>0;p.useEffect(()=>{if(!fe)return;const X=()=>Ne(ge=>ge+1);return window.addEventListener("focus",X),()=>window.removeEventListener("focus",X)},[fe]);const Le={parameters:uh(c,u),...V.length?{grants:V}:{},...Object.keys(J).length?{servers:J}:{},overrides:{approvals:v,...x?{choice:x}:{}}},Ye=X=>z8(R,X),ht=(X,ge,_e)=>{f(Ae=>({...Ae,[X]:_e})),UE(ge,_e)&&A(Ae=>Ae.filter(We=>Ix(We.field,"parameters")!==X))},ie=async()=>{var ge,_e;if(!Ve||je||be.length)return;P(!0),A([]),F(null);const X=u;try{const Ae=await e.applyTemplate(n.id,Le,G.keyFor(n.id,Le));G.done();const We=async()=>(await Promise.all(Ae.trigger_ids.map(it=>kU(e.getTrigger(it),jU).catch(()=>null)))).filter(it=>it!=null&&Sb(it));if(Ae.warnings.length||(ge=Ae.webhook_secrets)!=null&&ge.length){H(X),q(Ae),We().then(K,()=>{});return}const gt=Ae.trigger_ids.length?await We():[];if(!z.current)return;if(!gt.length){s(dn(Ae.agent_id));return}H(X),K(gt),q(Ae)}catch(Ae){Ae instanceof Ue&&((_e=Ae.fields)!=null&&_e.length)?(A(Ae.fields),F({text:Ae.message,withIssues:!0}),Ae.fields.some(We=>We.field.startsWith("servers.")||We.field.startsWith("mcp."))&&$(We=>We+1)):F({text:Ae instanceof Error?Ae.message:String(Ae),withIssues:!1})}finally{P(!1)}},Ce=c.fields,tt=X=>X.filter(ge=>!n.secrets.includes(ge)),Ie=(Rt=(Ft=n.model)==null?void 0:Ft.choices)==null?void 0:Rt.find(X=>X.id===x),at=X=>{var ge,_e;return/^(parameters|mcp|servers)\./.test(X.field)||/^grants\.\d+$/.test(X.field)||X.field==="overrides.choice"&&!!((_e=(ge=n.model)==null?void 0:ge.choices)!=null&&_e.length)||X.field.startsWith("secrets.")&&[...n.secrets,...tt((Ie==null?void 0:Ie.secrets)??[])].includes(X.field.slice(8))};return I?t.jsxs("section",{"aria-label":"Applied",className:"max-w-page",children:[t.jsxs(i,{className:"mb-4 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(wl,{className:"size-5 text-success-text","aria-hidden":!0})," ",Wo(n,U)," applied"]}),I.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:I.warnings.map((X,ge)=>{var gt,jt;const _e=/^triggers\.(\d+)\.secret$/.exec(X.field),Ae=_e?I.trigger_ids[Number(_e[1])]:void 0,We=_e?(gt=n.triggers[Number(_e[1])])==null?void 0:gt.name:void 0;return Ae&&((jt=I.webhook_secrets)!=null&&jt.some(it=>it.trigger_id===Ae))?t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:X.field})," ",X.message]},`${X.field}:${ge}`):t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:X.field})," ",X.message,X.fix?t.jsx("span",{className:"block text-muted-foreground",children:X.fix}):null,Ae&&t.jsxs("a",{href:`#/triggers/${encodeURIComponent(Ae)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",typeof We=="string"&&We?We:Ae," to get its signing secret (Rotate)"]})]},`${X.field}:${ge}`)})})]}),(pe=I.webhook_secrets)==null?void 0:pe.map(X=>{var We;const ge=I.trigger_ids.indexOf(X.trigger_id),_e=ge>=0?(We=n.triggers[ge])==null?void 0:We.name:void 0,Ae=typeof _e=="string"&&_e?_e:X.trigger_id;return X.signing_secret?t.jsx(Lb,{label:`The webhook's URL and secret (${Ae})`,url:nd({id:X.trigger_id}),secret:X.signing_secret},X.trigger_id):t.jsxs("div",{className:"mt-4 border px-4 py-3 text-body",children:[X.note&&t.jsx("p",{className:"text-muted-foreground",role:"note",children:X.note}),t.jsxs("a",{href:`#/triggers/${encodeURIComponent(X.trigger_id)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",Ae," to get its signing secret (Rotate)"]})]},X.trigger_id)}),W.length>0&&t.jsx("ul",{className:"mt-4 divide-y border","aria-label":"Schedules",children:W.map(X=>t.jsxs("li",{"data-trigger":X.id,className:"px-4 py-3",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(X.id)}`,className:"break-words text-prose font-semibold hover:underline",children:X.name}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",children:kb(X.source,X.next_at)})]},X.id))}),t.jsx("div",{className:"mt-5"}),t.jsx("a",{href:dn(I.agent_id),className:"inline-flex border px-3 py-2 font-mono text-body font-semibold hover:bg-accent",children:"Open the agent"})]}):t.jsxs("div",{children:[r&&t.jsxs("a",{href:o$(r),className:"caps mb-4 inline-flex min-h-6 items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[t.jsx(On,{className:"size-3.5","aria-hidden":!0})," Templates"]}),t.jsxs(i,{className:"text-2xl font-semibold",children:[Wo(n,u)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:n.version})]}),t.jsx(Mb,{t:n}),t.jsx("p",{className:"mt-2 max-w-prose text-lead leading-[1.6]",children:n.description}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:r?"Apply creates an agent and its triggers. It does not start a run.":Ve?"Apply creates an agent and its triggers. It does not start a run. Or set it up with your coding agent, which asks for any missing inputs and runs the task.":"Run with your coding agent. It sets up this template, asks for any missing inputs, and runs the task."}),ve&&t.jsxs("p",{className:"mt-3 text-body text-destructive-text",role:"alert",children:[ve," ",t.jsx("a",{href:rl(n),className:"underline",children:"Open a fresh request"}),"."]}),t.jsxs("div",{className:`mt-6 ${gd}`,children:[Ce.length>0&&t.jsx(ur,{title:"Parameters",children:Ce.map(([X,ge])=>t.jsxs("div",{"data-field":`parameters.${X}`,className:"px-4 py-3",children:[t.jsx(GE,{field:ge,label:dh(X,ge),help:cm(ge),value:u[X]??"",onChange:_e=>ht(X,ge,_e)}),t.jsx(Mo,{issues:R.filter(_e=>Ix(_e.field,"parameters")===X),words:_e=>BE(_e,X,ge)})]},X))}),n.mcp.length>0&&t.jsxs(ur,{title:"Tools you grant",note:"Nothing is granted until you tick it. A tool you tick is granted and follows this server's tool settings: a write asks you first unless you allowed it in Settings or choose Never ask, and a read runs without asking where you turned on Allow reads for its server. A tool you leave unticked is not given to the agent, even when it never asks: you can add it later on the agent's page.",children:[E&&!j&&t.jsx("div",{"data-servers-unread":!0,className:"px-4 py-3",children:t.jsx(Jt,{problem:E,onRetry:()=>$(X=>X+1),className:""})}),se.map(({m:X,matches:ge,uses:_e})=>t.jsxs("div",{"data-mcp":X.toolkit,className:"px-4 py-3",children:[t.jsx(a$,{m:X,children:j&&ge.length<2&&t.jsx("span",{className:"text-small text-muted-foreground",children:_e?`Uses ${_e}`:"Not set up here"})}),j&&ge.length>1&&t.jsxs("label",{className:"mt-2 flex flex-wrap items-center gap-2 text-small text-muted-foreground",children:["Uses",t.jsx(Et,{small:!0,label:`Server for ${X.toolkit}`,value:_e??"",placeholder:"Pick one",onChange:Ae=>O(We=>({...We,[X.toolkit]:Ae})),options:ge.map(Ae=>({value:Ae,label:Ae}))}),!_e&&t.jsxs("span",{"data-unpicked":X.toolkit,children:[ge.length," saved servers are ",Ed[X.source]," ",X.toolkit,": pick the one the agent uses."]})]}),j&&ge.length===0&&t.jsxs("p",{role:"status","data-missing-mcp":X.toolkit,className:"mt-2 border border-warning/50 px-3 py-2 text-small text-warning-text",children:[X.required?`${X.toolkit} is required and not set up here: Apply is refused until it is.`:`${X.toolkit} is not set up here: Apply makes the agent without its tools (${X.tools.map(Ae=>Ae.name).join(", ")}).`," ",t.jsx("a",{href:M8(X),className:"font-mono text-primary-text underline-offset-2 hover:underline",children:X.source==="github"?"Set up GitHub App access":X.source==="composio"?`Add ${X.toolkit} from Composio`:`Set up ${X.toolkit}`})]}),t.jsx(Mo,{issues:[...Ye(`mcp.${X.toolkit}`),...Ye(`servers.${X.toolkit}`)]}),t.jsx("ul",{className:"mt-2 space-y-2",children:X.tools.map(Ae=>{const We=V.indexOf(Ae.tool);return t.jsxs("li",{"data-tool":Ae.tool,children:[t.jsxs("label",{className:"flex items-start gap-2.5",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:g.has(Ae.tool),onChange:()=>y(gt=>{const jt=new Set(gt);return jt.has(Ae.tool)?jt.delete(Ae.tool):jt.add(Ae.tool),jt})}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body",children:Ae.name})," ",t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Ae.tool}),t.jsx("span",{className:"block text-small text-muted-foreground",children:Ae.asks==="allow"?"The template asks you to grant this.":"The template does not ask for this; unticked, the agent doesn't get it."})]})]}),We>=0&&t.jsx(Mo,{issues:Ye(`grants.${We}`)})]},Ae.tool)})})]},X.toolkit))]}),n.secrets.length>0&&t.jsx(ur,{title:"Keys it uses",note:"Saved on this server by name; a run is given them.",children:n.secrets.map(X=>t.jsxs("div",{"data-secret":X,className:"px-4 py-3 font-mono text-body",children:[X,t.jsx(Mo,{issues:Ye(`secrets.${X}`)})]},X))}),(He=(he=n.model)==null?void 0:he.choices)!=null&&He.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 ${(Je=n.harness)!=null&&Je.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(X=>t.jsxs("label",{"data-choice":X.id||"(default)",className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"model-choice",value:X.id,className:"mt-1 accent-primary",checked:x===X.id,onChange:()=>{b(X.id),A(ge=>ge.filter(_e=>_e.field!=="overrides.choice"&&!(_e.field.startsWith("secrets.")&&!n.secrets.includes(_e.field.slice(8)))))}}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body","data-choice-label":!0,children:X.label}),"model"in X&&t.jsxs("span",{className:"block font-mono text-label text-muted-foreground",children:[X.model," on ",X.harness]}),X.warning&&t.jsx("span",{className:"mt-1 block text-small text-warning-text","data-choice-warning":X.id,children:X.warning}),X.note&&t.jsx("span",{className:"mt-1 block text-small text-muted-foreground","data-choice-note":X.id,children:X.note}),"secrets"in X&&x===X.id&&t.jsx("span",{"data-choice-keys":X.id,children:t.jsx(Mo,{issues:tt(X.secrets).flatMap(ge=>Ye(`secrets.${ge}`))})})]})]},X.id||"(default)"))}),t.jsx(Mo,{issues:Ye("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(([X,ge,_e])=>t.jsxs("label",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"approvals",value:X,className:"mt-1 accent-primary",checked:v===X,onChange:()=>h(X)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:ge}),t.jsx("span",{className:"block text-small text-muted-foreground",children:_e})]})]},X))}),v==="never"&&t.jsx("p",{className:"mt-2 text-small text-warning-text",children:iE})]}),t.jsx(i$,{t:n}),t.jsx(l$,{t:n}),t.jsx(ur,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:Rb(n,{secrets:!1,mcp:!1}).map(([X,ge])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:X}),t.jsx("dd",{className:"min-w-0 break-words",children:ge})]},X))})})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[Ve?t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void ie(),disabled:L||je||be.length>0,title:ne?E?"The saved MCP servers couldn't be read: try again first":"Reading the saved MCP servers…":re.length?`Pick the server for ${re.join(", ")} first`:nt?`Reading ${nt.what}…`:void 0,children:L?"Applying…":"Apply"}),!r&&t.jsx(sn,{variant:"outline",label:"Set it up with an agent",disabled:je,prompt:fx(location.origin,n,Le),playgroundHref:rl(n,Le)}),be.map(X=>Oe[X.id]==="unmet"?t.jsxs("p",{role:"status","data-requirement":X.id,className:"min-w-0 text-body text-warning-text",children:[X.unmet.before,t.jsx("a",{href:X.unmet.href,className:"font-mono text-primary-text underline-offset-2 hover:underline",children:X.unmet.link}),X.unmet.after]},X.id):Oe[X.id]==="unread"?t.jsxs("p",{role:"alert","data-requirement-unread":X.id,className:"flex min-w-0 flex-wrap items-center gap-2 text-body text-destructive-text",children:[`${X.what[0].toUpperCase()}${X.what.slice(1)} couldn't be read.`,t.jsx(B,{size:"sm",onClick:()=>Ne(ge=>ge+1),children:"Try again"})]},X.id):null)]}):t.jsx(sn,{variant:"primary",label:"Run",disabled:je,prompt:fx(location.origin,n,Le),playgroundHref:rl(n,Le)}),M&&(!M.withIssues||R.length>0)&&t.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:M.text})]}),R.filter(X=>!at(X)).length>0&&t.jsx("div",{className:"mt-2",children:t.jsx(Mo,{issues:R.filter(X=>!at(X)),named:!0})})]})}function a$({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(Se,{tone:"muted",children:Ed[e.source]}),t.jsx(Se,{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 i$({t:e}){if(!e.input_schema)return null;const n=ch(e.input_schema,"content");return n&&!n.length?null:t.jsx(ur,{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:dh(s,r)}),r.title&&t.jsx("span",{className:"text-small text-muted-foreground",children:s}),t.jsx(Se,{tone:"muted",children:Q8(r)}),t.jsx(Se,{tone:r.required?"plain":"muted",children:r.required?"Required":"Optional"})]}),cm(r)&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:cm(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 l$({t:e}){const n=e.evals.length;return t.jsx(ur,{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 ur({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 dm(e){return{definition:{version:1,name:"New agent",instructions:e.trim(),harness:"pi",tools:[],skills:[]}}}function B0(e){return`#/playground?${new URLSearchParams({operation:"create-agent",draft:JSON.stringify(e)})}`}function SU(e){if(!e)return null;try{const n=JSON.parse(e);if(!n||typeof n!="object"||!("definition"in n))return null;const s=n.definition;if(!s||typeof s!="object"||Array.isArray(s))return null;const r=s;return r.version!==1||typeof r.name!="string"||typeof r.instructions!="string"||r.harness!=="pi"||r.description!==void 0&&typeof r.description!="string"||!Array.isArray(r.tools)||!r.tools.every(o=>typeof o=="string")||!Array.isArray(r.skills)||r.skills.length!==0?null:{definition:{version:1,name:r.name,instructions:r.instructions,harness:"pi",tools:[...r.tools],skills:[],...typeof r.description=="string"?{description:r.description}:{}}}}catch{return null}}const CU={"code-review":xm,"inbound-lead":wm,kyb:mR,"market-monitor":uR,"release-notes":Za};function EU({origin:e,v2:n}){const[s,r]=p.useState(""),[o,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(null),[g,y]=p.useState(null),[v,h]=p.useState(0),x=p.useId(),b=Hm(e,s),j=dm(s);p.useEffect(()=>{let S=!0;return y(null),n.listTemplates().then(N=>{S&&f(N.templates)},N=>{S&&y(Ht(N,"the template catalog"))}),()=>{S=!1}},[n,v]);const k=c.trim().toLocaleLowerCase(),E=(u??[]).filter(S=>`${Wo(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":`${x}-heading`,children:[t.jsxs("header",{className:"text-center",children:[t.jsx("h1",{id:`${x}-heading`,className:"text-2xl font-semibold leading-tight tracking-tight md:text-display",children:"What do you want to build?"}),t.jsx("p",{className:"mt-3 text-base text-muted-foreground",children:"Describe your agent, or pick a template to start from."})]}),t.jsxs("div",{className:"mx-auto mt-8 max-w-page",children:[t.jsxs("div",{className:ae(fl,"!rounded-composer overflow-hidden bg-card transition-colors"),"data-agent-composer":!0,children:[t.jsx("label",{htmlFor:`${x}-brief`,className:"sr-only",children:"Describe your agent"}),t.jsx(nn,{bare:!0,id:`${x}-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(sn,{variant:"primary",label:"Build an agent",prompt:b,playgroundHref:B0(j)})})]}),t.jsxs("details",{className:"mt-3 text-small text-muted-foreground",children:[t.jsx("summary",{className:"ml-auto w-fit cursor-pointer hover:text-foreground",children:"View coding-agent prompt"}),t.jsx("label",{htmlFor:`${x}-prompt`,className:"sr-only",children:"Coding-agent prompt"}),t.jsx(nn,{id:`${x}-prompt`,value:b,readOnly:!0,rows:8,spellCheck:!1,className:"mt-3 w-full border bg-card p-4 font-mono text-small leading-relaxed text-foreground"})]})]}),t.jsxs("section",{className:"mt-10 md:mt-12","aria-labelledby":`${x}-templates`,children:[t.jsxs("div",{className:"mb-5 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("h2",{id:`${x}-templates`,className:"text-lead font-semibold",children:"Start from a template"}),t.jsx("span",{role:"status",className:"text-small text-muted-foreground",children:u===null&&!g?"Loading templates…":u?`${E.length} of ${u.length}`:""})]}),t.jsxs("div",{className:ae(fl,"flex w-full items-center gap-2 px-3 sm:w-72"),children:[t.jsx(wm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{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"})]})]}),g&&t.jsx(Jt,{problem:g,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&&!E.length&&t.jsxs("p",{role:"status",className:"border border-border px-5 py-10 text-center text-muted-foreground",children:["No templates match “",c,"”."]}),t.jsx("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3",children:E.map(S=>{const N=o===S.id,$=CU[S.name]??ym,_=`${x}-${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":_,"aria-label":`Start with ${Wo(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:Wo(S)}),t.jsx(Mb,{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(Jx,{className:"ml-auto size-3.5","aria-hidden":!0})]})]}),N&&t.jsxs("div",{id:_,className:"flex flex-wrap items-center justify-end gap-2 border-t px-4 py-4",children:[t.jsxs("span",{className:"mr-auto font-mono text-small text-muted-foreground",children:["v",S.version]}),t.jsx(sn,{variant:"primary",label:"Use this template",prompt:aP(e,S,s),playgroundHref:rl(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:B0(dm("")),children:"start from a blank agent"}),"."]})]})}const c$=p.createContext(new Map),$U={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"};function d$({run:e}){const n=p.useContext(c$);if(!e.trigger)return null;const{id:s}=e.trigger,r=n.get(s),o=r?`${$U[r.kind]??"Trigger"}: ${r.name}`:`Trigger: ${s}`;return t.jsx("a",{href:`#/triggers/${encodeURIComponent(s)}`,onClick:i=>i.stopPropagation(),className:"inline-flex max-w-full",title:o,children:t.jsxs(Se,{className:"max-w-full",children:[t.jsx(cd,{className:"size-3 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"truncate",children:o})]})})}const um=["queued","working","paused","input_required","completed","failed","cancelled"],_U={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function TU({runs:e,agentName:n,onOpen:s,error:r,onRetry:o,onMore:i,loadingMore:c,filter:d={},onFilter:u,agentId:f,observations:g}){var v,h;const y=!!d.archived;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:ae(pr,"flex-wrap gap-2 px-5 md:px-6"),children:[t.jsxs("h1",{className:ae(Bo,"mr-auto"),children:[t.jsx(dd,{className:"size-4","aria-hidden":!0}),y?"Archived runs":"Runs"]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Et,{label:"Runs in one state",value:d.status??"",onChange:x=>u({...d,status:x||void 0}),className:"h-control-sm w-48",options:[{value:"",label:"Any state"},...um.map(x=>({value:x,label:_U[x]}))]}),t.jsxs(B,{size:"sm",variant:y?"primary":"outline","aria-pressed":y,onClick:()=>u({...d,archived:!y}),children:[t.jsx(ld,{"aria-hidden":!0})," Archived"]})]}),t.jsx(sn,{label:"Query",prompt:`${Bm(location.origin,f)}
|
|
665
|
-
Current view: ${d.status?`status ${d.status}`:"all statuses"}; ${y?"archived runs":"non-archived runs"}.`,playgroundHref:Iv(f,d)})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[r&&!e?t.jsx(Jt,{problem:r,onRetry:o,className:""}):e?!e.length&&!((v=g==null?void 0:g.data)!=null&&v.sessions.length)&&!d.status&&!y?t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(RU,{})}):!e.length&&((h=g==null?void 0:g.data)!=null&&h.sessions.length)?null:e.length?t.jsx(AU,{runs:e,agentName:n,onOpen:s}):t.jsx("p",{className:"px-4 py-16 text-center text-body text-muted-foreground",children:d.status?"No run matches.":y?"No archived runs.":"No runs yet."}):t.jsx(Hn,{label:"Loading the runs"}),g&&t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Pv,{read:g})}),e&&r&&t.jsx(Jt,{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 RU(){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:cl({variant:"solid",size:"lg"}),children:[t.jsx(Jo,{"aria-hidden":!0})," Start a run"]}),t.jsx("a",{href:"#/templates",className:cl({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function AU({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(Al,{run:r})}),t.jsxs("td",{className:"px-3 py-2.5 align-top",children:[t.jsxs("button",{type:"button",className:"flex items-start gap-1 text-left",onClick:o=>{o.stopPropagation(),s(r.run_id)},children:[t.jsx("span",{className:"line-clamp-2",children:En(r)}),t.jsx(hr,{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(d$,{run:r})}),t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground md:hidden",children:[n(r.agent_id)," · ",ft(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:ft(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:ro(r.cost,{ended:Va(r.status)})})]},r.run_id))})]})}function OU({agentId:e,details:n}){const{denied:s,asks:r}=YD(n),o=[...new Set([...s,...r])];return o.length?t.jsxs("p",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1",children:[o.map(i=>t.jsxs("a",{href:`#/agents/${encodeURIComponent(e)}/edit?tool=${encodeURIComponent(i)}`,className:"underline underline-offset-4",children:["Set ",i," for this agent"]},i)),t.jsxs("span",{children:["or for every agent: ",t.jsx("a",{href:"#/settings/tools",className:"underline underline-offset-4",children:"Settings → Tools"})]})]}):null}function LU(e,{base:n="/v2",onProgress:s,signal:r,request:o=()=>new XMLHttpRequest}={}){return new Promise((i,c)=>{if(r!=null&&r.aborted)return c(new Ue(0,"aborted","The upload was stopped."));const d=o();d.open("POST",`${n}/files?path=${encodeURIComponent(e.name)}`),d.setRequestHeader("accept","application/json"),e.type&&d.setRequestHeader("content-type",e.type),d.upload.onprogress=u=>{u.lengthComputable&&u.total>0&&(s==null||s(Math.min(1,u.loaded/u.total)))},d.onload=()=>{let u=null;try{u=JSON.parse(d.responseText)}catch{}if(d.status===201||d.status===200){const y=u==null?void 0:u.file;return y!=null&&y.file_id?(s==null||s(1),i(y)):c(new Ue(d.status,"bad_answer","The server's answer named no file."))}const f=u==null?void 0:u.error,g=new Ue(d.status,(f==null?void 0:f.code)??"http_error",(f==null?void 0:f.message)??`The server answered ${d.status}.`,(f==null?void 0:f.retryable)??!1,f==null?void 0:f.request_id);f!=null&&f.fields&&(g.fields=f.fields),c(g)},d.onerror=()=>c(new Ue(0,"network","The upload did not reach the server.")),d.onabort=()=>c(new Ue(0,"aborted","The upload was stopped.")),r==null||r.addEventListener("abort",()=>d.abort(),{once:!0}),d.send(e)})}const MU=(e,n,s)=>LU(e,{onProgress:n,signal:s});function Ig(e){if(!(e instanceof Ue))return e instanceof Error?e.message:String(e);const n=(e.fields??[]).filter(s=>s.message!==e.message).map(s=>s.message);return[e.message,...n].join(" ")}function PU({upload:e,remove:n,limits:s,frozen:r=!1}){const[o,i]=p.useState([]),[c,d]=p.useState([]),u=p.useRef(new Map),f=p.useRef(0),g=p.useRef(0);g.current=o.length;const y=p.useRef({items:o,frozen:r,remove:n});y.current={items:o,frozen:r,remove:n};const v=p.useRef(!0);p.useEffect(()=>{v.current=!0;const k=u.current;return()=>{var $;v.current=!1;for(const _ of k.values())_.abort();const{items:E,frozen:S,remove:N}=y.current;if(!S)for(const _ of E)_.file&&!_.removing&&(($=N==null?void 0:N(_.file.file_id))==null||$.catch(()=>{}))}},[]);const h=p.useCallback(k=>{if(y.current.frozen)return;const E=[],S=s?s.max_files_per_run-g.current:1/0,N=(s==null?void 0:s.max_upload_bytes)??null,$=[];for(const O of k)N!==null&&O.size>N?E.push({text:`${O.name} is ${Ka(O.size)}: this server takes files up to ${Ka(N)}.`}):$.length>=S?E.push({text:`${O.name} is not added: a run names at most ${s==null?void 0:s.max_files_per_run} files here.`}):$.push(O);d(E);const _=$.map(O=>({key:`f${f.current++}`,name:O.name,size:O.size,progress:0}));g.current+=_.length,i(O=>[...O,..._]),_.forEach((O,L)=>{const P=new AbortController;u.current.set(O.key,P);const R=A=>{v.current&&i(M=>M.map(F=>F.key===O.key?{...F,...A}:F))};e($[L],A=>R({progress:A}),P.signal).then(A=>{var M,F,I;if(u.current.delete(O.key),P.signal.aborted){(I=(F=(M=y.current).remove)==null?void 0:F.call(M,A.file_id))==null||I.catch(q=>{v.current&&d(W=>[...W,{text:`${O.name} was sent before it was stopped, and was not removed: ${Ig(q)}`}])});return}R({file:A,progress:1})},A=>{u.current.delete(O.key),!(P.signal.aborted||!v.current)&&(i(M=>M.filter(F=>F.key!==O.key)),d(M=>[...M,{text:`${O.name}: ${Ig(A)}`}]))})})},[s==null?void 0:s.max_files_per_run,s==null?void 0:s.max_upload_bytes,e]),x=p.useCallback(k=>{var _;const{items:E,frozen:S,remove:N}=y.current,$=E.find(O=>O.key===k);if(!(S||!$||$.removing)){if(!$.file||!N){(_=u.current.get(k))==null||_.abort(),u.current.delete(k),i(O=>O.filter(L=>L.key!==k));return}i(O=>O.map(L=>L.key===k?{...L,removing:!0}:L)),d(O=>O.filter(L=>L.about!==k)),N($.file.file_id).then(()=>{v.current&&i(O=>O.filter(L=>L.key!==k))},O=>{v.current&&(i(L=>L.map(P=>P.key===k?{...P,removing:!1}:P)),d(L=>[...L,{about:k,text:`${$.name} was not removed: ${Ig(O)}`}]))})}},[]),b=p.useCallback(()=>{y.current={...y.current,items:[]},i([]),d([])},[]),j=o.flatMap(k=>k.file&&!k.removing?[k.file.file_id]:[]);return{items:o,refusals:c.map(k=>k.text),add:h,drop:x,clear:b,fileIds:j,frozen:r,busy:o.some(k=>!k.file||k.removing)}}function G0({attachments:e,limits:n,disabled:s,compact:r=!1}){const o=p.useRef(null),[i,c]=p.useState(!1),{items:d,refusals:u,add:f,drop:g}=e,y=s||e.frozen,v=n?[`up to ${n.max_files_per_run} files`,...n.max_upload_bytes!==null?[`${Ka(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=>{y||(h.preventDefault(),c(!0))},onDragLeave:()=>c(!1),onDrop:h=>{h.preventDefault(),c(!1),y||f([...h.dataTransfer.files])},role:"group","aria-label":"Files for the run",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>{var h;return(h=o.current)==null?void 0:h.click()},disabled:y,title:r?`Attach files${v?` (${v})`:""}`:void 0,className:ae(r&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[t.jsx(cR,{"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",v?` (${v})`:"",". The run finds them in inputs/."]}),t.jsx("input",{ref:o,type:"file",multiple:!0,hidden:!0,"aria-label":"Pick files",onChange:h=>{f([...h.target.files??[]]),h.target.value=""}})]}),d.length>0&&t.jsx("ul",{className:"mt-2 flex flex-wrap gap-2","aria-label":"Attached files",children:d.map(h=>t.jsxs("li",{className:"flex h-7 items-center gap-2 border bg-card px-2 font-mono text-small",children:[t.jsx("span",{className:"max-w-[16rem] truncate",title:h.name,children:h.name}),t.jsx("span",{className:"text-muted-foreground",children:Ka(h.size)}),!h.file&&t.jsxs("span",{className:"text-muted-foreground","aria-label":`${h.name} sent ${Math.round(h.progress*100)}%`,children:[Math.round(h.progress*100),"%"]}),h.removing&&t.jsx("span",{className:"text-muted-foreground",children:"removing"}),t.jsx("button",{type:"button",onClick:()=>g(h.key),disabled:y||h.removing,"aria-label":`Remove ${h.name}`,className:"text-muted-foreground hover:text-foreground disabled:opacity-45",children:t.jsx(Zo,{className:"size-3.5","aria-hidden":!0})})]},h.key))}),d.some(h=>!h.file)&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:"The run can start once every file is sent."}),u.length>0&&t.jsx("ul",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:u.map((h,x)=>t.jsx("li",{children:h},`${x}:${h}`))})]})}const xf={"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."},Pb=(e,n)=>e instanceof Ue?{status:e.status,ms:n,body:{error:{...e.toApiError(),...e.fields?{fields:e.fields}:{}}}}:{status:0,ms:n,body:{error:{code:"network",message:String(e)}}};function IU({agents:e,revisions:n=[],efforts:s,origin:r,agentId:o,onAgent:i,onSend:c,onOpenRun:d,result:u=null,live:f,limits:g,upload:y=MU,removeUpload:v}){var Dt,Ft,Rt;const[h,x]=p.useState(o??((Dt=e[0])==null?void 0:Dt.agent_id)??"");p.useEffect(()=>{var pe;o&&o!==h&&e.some(he=>he.agent_id===o)?x(o):e.some(he=>he.agent_id===h)||x(((pe=e[0])==null?void 0:pe.agent_id)??"")},[e,o]);const b=e.find(pe=>pe.agent_id===h),j=Qv(b),k=ns(b==null?void 0:b.definition),E=(b==null?void 0:b.kind)??"agentic",[S,N]=p.useState(""),[$,_]=p.useState(""),O=$?(Ft=n.find(pe=>pe.revision===$))==null?void 0:Ft.definition:void 0,L=E==="agentic"?JSON.stringify(((Rt=O??(b==null?void 0:b.definition))==null?void 0:Rt.input_schema)??null):"null",P=p.useMemo(()=>E==="agentic"?G8(JSON.parse(L)):null,[E,L]),R=(P==null?void 0:P.kind)==="fields"?P.form:null,A=E==="workflow"||(P==null?void 0:P.kind)==="json",[M,F]=p.useState({});p.useEffect(()=>{F(R?WE(R):{})},[h,L]);const I=E==="workflow"?E8(b==null?void 0:b.definition.workflow):(P==null?void 0:P.kind)==="json"?P.example:null,q=p.useRef("");p.useEffect(()=>{if(S.trim()&&S!==q.current)return;const pe=(I==null?void 0:I.text)??"";q.current=pe,N(pe)},[h,I==null?void 0:I.text]);const[W,K]=p.useState(""),[U,H]=p.useState(""),[G,z]=p.useState(""),[V,se]=p.useState("form"),[J,re]=p.useState(u?"response":"code"),[ne,me]=p.useState("curl"),[ve,je]=p.useState(()=>!(typeof window<"u"&&typeof window.matchMedia=="function")||window.matchMedia("(min-width: 1024px) and (min-height: 501px)").matches),Ve=p.useId(),[de,Oe]=p.useState(u),ze=new Set((R==null?void 0:R.fields.map(([pe])=>pe))??[]),De=pe=>{const he=Ix(pe);return he!==null&&ze.has(he)?he:null},Ne=p.useMemo(()=>{var Je,X;const pe=de&&de.status>=400?(Je=de.body)==null?void 0:Je.error:void 0;if(!pe||typeof pe.message!="string")return;const he=Array.isArray(pe.fields)?pe.fields.filter(ge=>!!ge&&typeof ge.field=="string"&&typeof ge.message=="string"):[],He=he.filter(ge=>ge.message!==pe.message&&De(ge.field)===null);return{message:pe.message,more:He,issues:he,box:typeof((X=pe.details)==null?void 0:X.box)=="string"?pe.details.box:void 0,details:pe.code==="agent_not_runnable"?pe.details:void 0}},[de,L]),[Q,be]=p.useState(new Set);p.useEffect(()=>{be(new Set)},[de]);const nt=(pe,he,He)=>{F(Je=>({...Je,[pe]:He})),be(Je=>{const X=new Set(Je);return UE(he,He)?X.add(pe):X.delete(pe),X})},fe=pe=>Q.has(pe)?[]:((Ne==null?void 0:Ne.issues)??[]).filter(he=>De(he.field)===pe),[Le,Ye]=p.useState(!1),ht=p.useMemo(()=>Js(),[]),ie=PU({upload:y,remove:v,limits:g,frozen:Le}),Ce=N8(E,{text:S,revision:$,effort:W,maxCostUsd:U,fileIds:ie.fileIds,repo:G,...R?{typed:{fields:uh(R,M),contentRequired:R.contentRequired}}:{},...(P==null?void 0:P.kind)==="json"?{json:!0}:{}}),tt=Ce.ok?Ce.body:{input:A?S:R?V8(R,S,M):{content:S},...ie.fileIds.length?{file_ids:ie.fileIds}:{}},Ie=h?ht.keyFor(h,tt):"",at=ne==="curl"?$8(r,h,tt,Ie):`const res = await fetch(${JSON.stringify(`${r}/v2/agents/${h||"{agent_id}"}/runs`)}, {
|
|
666
|
-
method: "POST",
|
|
667
|
-
headers: {
|
|
668
|
-
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
669
|
-
"Content-Type": "application/json",
|
|
670
|
-
"Idempotency-Key": ${JSON.stringify(Ie)},
|
|
671
|
-
},
|
|
672
|
-
body: JSON.stringify(${JSON.stringify(tt,null,2).replace(/\n/g,`
|
|
673
|
-
`)}),
|
|
674
|
-
});
|
|
675
|
-
console.log(res.status, await res.json());`,St=!!j&&(!j.connected||j.state!=="ready"||!j.capabilities.launch||!!U.trim()||!!W||!!G.trim()||ie.fileIds.length>0||ie.busy),st=async()=>{if(k||St||!Ce.ok||!c||ie.busy)return;Ye(!0);const pe=await T8(ht,h,Ce.body,c);Ye(!1),Oe(pe),re("response"),je(!0),pe.status>=200&&pe.status<300&&ie.clear()},ut=A?E==="workflow"?'{ "subject": "...", "body": "..." }':"The agent's input, as JSON":`The run's ${R?"message":"first message"}, e.g. Summarize the standup: we ship Friday.`;return 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(Et,{id:"playground-agent",label:"Agent",value:h,onChange:pe=>{x(pe),_(""),i==null||i(pe)},options:Tl(e).map(pe=>({value:pe.agent_id,label:pe.definition.name})),className:"w-56 max-w-[60vw]"})]}),k?t.jsxs("span",{className:"font-mono text-small",children:[Qo(k.runtime)," · Your backend"]}):t.jsxs("span",{className:"font-mono text-small",children:[t.jsx("span",{className:"text-primary-text",children:"POST"})," ",t.jsxs("span",{className:"text-muted-foreground",children:["/v2/agents/",h||"{agent_id}","/runs"]})]})]}),k?t.jsxs("section",{className:"space-y-4 p-5 md:p-8",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Run through your backend"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"This agent keeps its existing SDK, tools and job entrypoint. Your coding agent can run it there; AgentRun records its progress and learning."}),t.jsx(sn,{variant:"primary",label:"Run agent",prompt:Bv(r,h,k.runtime)})]}):t.jsxs("div",{className:ae("relative grid min-h-0 flex-1 grid-cols-1",ve?"lg:[@media(min-height:501px)]:grid-cols-2":"grid-rows-[minmax(0,1fr)_auto]"),children:[t.jsxs("section",{"aria-label":"Request",className:ae("flex min-h-0 flex-col border-b",ve?"lg:border-b-0 lg:border-r short:hidden":"lg:[@media(min-height:501px)]:border-b-0 short:border-b-0"),children:[t.jsxs("header",{className:ae("flex items-center justify-between border-b px-5 py-3 md:px-6",!ve&&"lg:[@media(min-height:501px)]:min-h-[57px] lg:[@media(min-height:501px)]:pr-80 short:min-h-[57px] short:pr-72"),children:[t.jsx("span",{className:"text-lead font-semibold",children:"Request"}),t.jsx("span",{role:"group","aria-label":"Request as",className:"flex gap-4 text-small",children:["form","json"].map(pe=>t.jsx("button",{type:"button","aria-pressed":V===pe,onClick:()=>se(pe),className:ae("min-h-6 border-b pb-1 capitalize",V===pe?"border-primary":"border-transparent text-muted-foreground"),children:pe==="json"?"JSON":"Form"},pe))})]}),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."]}),St&&t.jsx("p",{className:"text-warning-text",children:G.trim()?"This request selects a repository. Native execution uses its source project.":U.trim()?"This request has a spend cap. Native execution cannot enforce it.":W||ie.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."}),!!G.trim()&&t.jsx(B,{size:"sm",onClick:()=>z(""),children:"Use native source repository"}),!!W&&t.jsx(B,{size:"sm",onClick:()=>K(""),children:"Use native configured effort"}),ie.fileIds.length>0&&t.jsx(B,{size:"sm",onClick:()=>ie.clear(),children:"Remove uploaded attachments"}),!!U.trim()&&t.jsx(B,{size:"sm",onClick:()=>H(""),children:"Remove cap for native execution"}),t.jsx("a",{href:dn(h),className:"underline underline-offset-2",children:"Open native connection"})]}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Start a run"}),t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:[b?`${b.definition.name}: ${E==="agentic"?"an":"a"} ${E} agent.`:"Pick an agent."," The server answers 202 with the run; follow it on its page."]})]}),V==="json"?t.jsxs(t.Fragment,{children:[t.jsx("pre",{className:"overflow-auto border bg-card p-4 font-mono text-small leading-[1.7]",children:JSON.stringify(tt,null,2)}),!j&&t.jsx(Ca,{name:"file_ids",note:xf.file_ids,children:t.jsx(G0,{attachments:ie,limits:g})})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Ca,{htmlFor:"playground-input",name:A?"input":"input.content",required:!R||R.contentRequired,optional:!!R&&!R.contentRequired,error:!Ce.ok&&Ce.field==="input"&&S?Ce.message:void 0,children:[t.jsx(nn,{id:"playground-input",value:S,onChange:pe=>N(pe.target.value),rows:A?7:4,placeholder:ut,className:q0}),I&&t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[C8(I,"start",E==="workflow"?"workflow":"agent"),I.fields.length>0&&t.jsxs(t.Fragment,{children:[" Fields: ",I.fields.map((pe,he)=>t.jsxs("span",{title:pe.note,children:[he?", ":"",t.jsx("span",{className:"text-foreground",children:pe.name})]},pe.name)),"."]})]})]}),R==null?void 0:R.fields.map(([pe,he])=>t.jsxs("div",{"data-field":`input.${pe}`,children:[t.jsx(GE,{field:he,label:dh(pe,he),help:cm(he),value:M[pe]??"",onChange:He=>nt(pe,he,He)}),t.jsx(Mo,{issues:fe(pe),words:He=>BE(He,pe,he)})]},pe)),!j&&t.jsx(Ca,{name:"file_ids",note:xf.file_ids,children:t.jsx(G0,{attachments:ie,limits:g})}),t.jsx(Ca,{name:"revision",note:"Empty runs the current revision.",children:t.jsx(Et,{label:"Revision",value:$,onChange:_,className:"w-full",options:[{value:"",label:"The current revision"},...n.map(pe=>({value:pe.revision,label:`rev ${pe.version}${pe.current?" (current)":""}${pe.note?`: ${pe.note}`:""}`}))]})}),!j&&t.jsx(Ca,{name:"effort",note:"How hard the model thinks. Empty uses the agent's own.",children:t.jsx(Et,{label:"Effort",value:W,onChange:K,className:"w-full",options:["",...s].map(pe=>({value:pe,label:pe||"Agent default"}))})}),E==="agentic"&&!j&&t.jsx(Ca,{htmlFor:"playground-repo",name:"repo",note:xf.repo,error:!Ce.ok&&Ce.field==="repo"?Ce.message:void 0,children:t.jsx(Pe,{id:"playground-repo",value:G,onChange:pe=>z(pe.target.value),placeholder:"owner/name"})}),E==="agentic"&&!j&&t.jsxs(Ca,{htmlFor:"playground-cap",name:"max_cost_usd",note:"A spend cap in dollars; empty means none.",error:!Ce.ok&&Ce.field==="max_cost_usd"?Ce.message:void 0,children:[t.jsx(Pe,{id:"playground-cap",value:U,onChange:pe=>H(pe.target.value),inputMode:"decimal",placeholder:"e.g. 0.50",className:q0}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:t.jsx(oE,{})})]})]})]}),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(sn,{size:"lg",label:"Use your agent",prompt:iP(r,h,tt),disabled:St||!Ce.ok||!h||ie.busy}),t.jsxs(B,{variant:"primary",size:"lg",onClick:st,disabled:St||!Ce.ok||!c||Le||!h||ie.busy,title:ie.busy?"Waiting for the files to be sent":void 0,children:[t.jsx(Jo,{"aria-hidden":!0})," ",Le?"Sending":"Send request"]})]})]})]}),t.jsxs("section",{"aria-label":"Code and response",className:ae("flex min-h-0 flex-col",!ve&&"lg:[@media(min-height:501px)]:absolute lg:[@media(min-height:501px)]:right-6 lg:[@media(min-height:501px)]:top-3 short:absolute short:right-5 short:top-3"),children:[t.jsxs("header",{className:ae("flex flex-wrap items-center justify-between gap-x-3 gap-y-2 px-5 md:px-6",ve?"border-b py-3":"py-2 lg:[@media(min-height:501px)]:p-0 short:p-0"),children:[t.jsxs("span",{role:"group","aria-label":"Show",className:ae("flex gap-4 text-body",!ve&&"hidden"),children:[t.jsx("button",{type:"button","aria-pressed":J==="code",onClick:()=>re("code"),className:ae("border-b pb-1",J==="code"?"border-primary":"border-transparent text-muted-foreground"),children:"Code"}),t.jsxs("button",{type:"button","aria-pressed":J==="response",onClick:()=>re("response"),disabled:!de,className:ae("border-b pb-1 disabled:opacity-45",J==="response"?"border-primary":"border-transparent text-muted-foreground"),children:["Response",de&&t.jsx("span",{className:ae("ml-2 font-mono max-sm:hidden",de.status<300?"text-success-text":"text-destructive-text"),children:de.status})]})]}),t.jsx("span",{className:"ml-auto flex items-center gap-2",children:t.jsxs(B,{type:"button",size:"sm",className:"max-sm:px-2","aria-expanded":ve,"aria-controls":Ve,onClick:()=>je(pe=>!pe),children:[ve?t.jsx(VT,{"aria-hidden":!0}):t.jsx(vm,{"aria-hidden":!0})," ",ve?"Hide code and response":"Show code and response"]})})]}),t.jsx("div",{id:Ve,className:ae("flex min-h-0 flex-1 flex-col",!ve&&"hidden"),children:J==="code"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b px-5 md:px-6",children:[t.jsx("div",{role:"group","aria-label":"Code in",className:"flex gap-5 text-small",children:["curl","fetch"].map(pe=>t.jsx("button",{type:"button","aria-pressed":ne===pe,onClick:()=>me(pe),className:ae("-mb-px border-b-2 py-2.5",ne===pe?"border-primary":"border-transparent text-muted-foreground"),children:pe==="curl"?"cURL":"JavaScript"},pe))}),t.jsx(B,{size:"icon",variant:"outline","aria-label":"Copy code",onClick:()=>{var pe;return void((pe=navigator.clipboard)==null?void 0:pe.writeText(at))},children:t.jsx(Xa,{"aria-hidden":!0})})]}),t.jsx("pre",{tabIndex:0,"aria-label":"The request as code",className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words px-5 py-5 font-mono text-small leading-[1.8] md:px-6",children:at}),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."})]}):de&&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:de.status<300?"text-success-text":"text-destructive-text",children:de.status})," ",t.jsxs("span",{className:"text-muted-foreground",children:[de.ms," ms"]})]}),Ne&&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: ",Ne.message,Ne.box?t.jsxs("span",{className:"text-muted-foreground",children:[" (box: ",Ne.box,")"]}):null,t.jsx(OU,{agentId:h,details:Ne.details}),Ne.more.length>0&&t.jsx("span",{className:"mt-1 block",children:Ne.more.map(pe=>t.jsxs("span",{className:"block",children:[pe.field,": ",pe.message]},`${pe.field}:${pe.message}`))})]}),de.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(de.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(de.body,null,2)})]})]}):t.jsx("pre",{tabIndex:0,"aria-label":"Response body",className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words px-5 py-5 font-mono text-small leading-[1.8] md:px-6",children:JSON.stringify(de.body,null,2)}),de.runId&&t.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(de.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(Jx,{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(xf).map(([pe,he])=>t.jsxs("div",{children:[t.jsx("dt",{className:"font-mono text-body",children:pe}),t.jsx("dd",{className:"text-small text-muted-foreground",children:he})]},pe))}),t.jsxs("code",{className:"text-small",children:["/v2/agents/","{agent_id}","/runs"]})]})}const q0="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 Ca({name:e,htmlFor:n,required:s,optional:r,note:o,error:i,children:c}){const d=p.useId();return t.jsxs("div",{role:n?void 0:"group","aria-labelledby":n?void 0:d,children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[n?t.jsx("label",{htmlFor:n,className:"font-mono text-body",children:e}):t.jsx("span",{id:d,className:"font-mono text-body",children:e}),s?t.jsx("span",{className:"text-label text-muted-foreground",children:"required"}):r&&t.jsx("span",{className:"text-label text-muted-foreground",children:"optional"})]}),c,o&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:o}),i&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-destructive-text",role:"alert",children:i})]})}const K0="h-11 w-full border bg-card px-3 text-lead outline-none focus:border-primary",zU=e=>`'${e.replaceAll("'","'\\''")}'`;function DU({v2:e,origin:n,agentId:s,filter:r={}}){const[o,i]=p.useState(r.status??""),[c,d]=p.useState(!!r.archived),[u,f]=p.useState(50),[g,y]=p.useState(""),[v,h]=p.useState("code"),[x,b]=p.useState("curl"),[j,k]=p.useState(null),[E,S]=p.useState(null),[N,$]=p.useState(!1),[_,O]=p.useState(!1),L=p.useRef(0);p.useEffect(()=>(L.current++,i(r.status??""),d(!!r.archived),y(""),S(null),k(null),$(!1),()=>{L.current++}),[s,r.status,r.archived]);const P={...o?{status:o}:{},...c?{archived:!0}:{}},R=s?`/v2/agents/${encodeURIComponent(s)}/runs`:"/v2/runs",A=new URLSearchParams({limit:String(u)});g&&A.set("cursor",g),o&&A.set("status",o),c&&A.set("archived","true");const M=`${n}${R}?${A}`,F=x==="curl"?`curl -X GET ${zU(M)} \\
|
|
676
|
-
-H "Authorization: Bearer $AGENTRUN_API_KEY"`:`const response = await fetch(${JSON.stringify(M)}, {
|
|
677
|
-
method: "GET",
|
|
678
|
-
headers: { Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\` },
|
|
679
|
-
});
|
|
680
|
-
console.log(response.status, await response.json());`,I=`${Bm(n,s)}
|
|
681
|
-
|
|
682
|
-
Prepared read-only request: GET ${M}
|
|
683
|
-
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.`,q=()=>{L.current++,y(""),S(null),k(null),O(!1)},W=async(K=g)=>{if(N)return;const U=++L.current;$(!0),S(null),k(null),y(K),O(!1);const H=performance.now();try{const G=s?await e.listAgentRuns(s,u,K||void 0,P):await e.listRuns(u,K||void 0,P);if(L.current!==U)return;S(G),k({status:200,ms:performance.now()-H,body:G})}catch(G){if(L.current!==U)return;k(Pb(G,performance.now()-H))}finally{L.current===U&&($(!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(Pe,{className:K0,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(Et,{label:"Run status",value:o,disabled:N,onChange:K=>{i(K),q()},options:[{value:"",label:"All statuses"},...um.map(K=>({value:K,label:K.replaceAll("_"," ")}))]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Archive"}),t.jsx(Et,{label:"Archived runs",value:String(c),disabled:N,onChange:K=>{d(K==="true"),q()},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(Et,{label:"Page size",value:String(u),disabled:N,onChange:K=>{f(Number(K)),q()},options:[10,25,50,100].map(K=>({value:String(K),label:String(K)}))})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Cursor"}),t.jsx(Pe,{"aria-label":"Cursor",className:`${K0} font-mono text-small`,value:g,disabled:N,placeholder:"First page",onChange:K=>{L.current++,y(K.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(sn,{size:"md",label:"Use your agent",prompt:I}),t.jsxs(B,{variant:"primary",disabled:N,onClick:()=>void W(),children:[t.jsx(Jo,{"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(K=>t.jsx("button",{onClick:()=>h(K),className:ae("h-12 border-b text-small capitalize",v===K?"border-primary":"border-transparent text-muted-foreground"),children:K},K)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{var K;(K=navigator.clipboard)==null||K.writeText(F).then(()=>O(!0),()=>O(!1))},children:t.jsx(Xa,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:_?"Code copied":""})]}),v==="code"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-12 shrink-0 gap-5 border-b px-6",children:["curl","fetch"].map(K=>t.jsx("button",{onClick:()=>b(K),className:ae("border-b text-small",x===K?"border-primary":"border-transparent text-muted-foreground"),children:K==="curl"?"cURL":"JavaScript"},K))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:F})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:j?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[j.status||"Network error"," · ",Math.round(j.ms)," ms"]}),E&&t.jsxs(t.Fragment,{children:[E.runs.length?t.jsx("ul",{className:"divide-y border",children:E.runs.map(K=>t.jsx("li",{children:t.jsxs("a",{className:"flex items-center gap-3 p-3 text-lead hover:bg-accent",href:`#/runs/${encodeURIComponent(K.run_id)}`,children:[t.jsx(Al,{run:K}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:K.title||K.run_id}),t.jsx(hr,{className:"size-3.5 shrink-0","aria-hidden":!0})]})},K.run_id))}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"No runs match this request."}),E.next_cursor&&t.jsx(B,{size:"sm",disabled:N,onClick:()=>void W(E.next_cursor),children:"Next page"})]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(j.body,null,2)})]}):t.jsx("p",{className:"text-lead text-muted-foreground",children:N?"Loading runs…":"Send a request to see its response."})})]})]})}const Cc=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Fi="w-full border bg-card px-3 py-3 text-lead outline-none focus:border-primary";function FU({v2:e,origin:n,operation:s,agentId:r,draft:o,harnesses:i=[]}){const c=s==="edit-agent",d=SU(o??null),[u,f]=p.useState(null),[g,y]=p.useState(null),[v,h]=p.useState(void 0),[x,b]=p.useState(d??dm("")),[j,k]=p.useState(JSON.stringify(d??dm(""),null,2)),[E,S]=p.useState(j),N=aE(j!==E),[$,_]=p.useState("form"),[O,L]=p.useState("code"),[P,R]=p.useState("curl"),[A,M]=p.useState(null),[F,I]=p.useState(null),[q,W]=p.useState(null),[K,U]=p.useState(!1),[H,G]=p.useState(!1),[z,V]=p.useState(0),[se,J]=p.useState(!1);p.useEffect(()=>{if(!c)return;if(!r){M("Choose an agent from Connected agents to edit its definition.");return}let ie=!0;return f(null),h(void 0),M(null),e.getAgent(r).then(({agent:Ce,etag:tt})=>{if(!ie)return;f(Ce),y(tt);const Ie={definition:{...Ce.definition,version:Ce.revisions+1}},at=JSON.stringify(Ie,null,2);b(Ie),k(at),S(at),I(null),G(!1)}).catch(Ce=>{ie&&M(String(Ce instanceof Error?Ce.message:Ce))}),()=>{ie=!1}},[e,c,r,z]);const re=(ie,Ce)=>{const tt={...x.definition,[ie]:ie==="model"?Ce.trim():Ce};ie==="model"&&!Ce.trim()&&!c&&delete tt.model;const Ie={...x,definition:tt};b(Ie),k(JSON.stringify(Ie,null,2))};let ne=x,me=null;if($==="json")try{const ie=JSON.parse(j);!Cc(ie)||!Cc(ie.definition)?me="Include a definition object in the request.":ne=ie}catch{me="Enter valid JSON before sending the request."}!me&&ne.note!==void 0&&typeof ne.note!="string"&&(me="note must be a string.");for(const ie of["description","instructions","harness","model"])!me&&ne.definition[ie]!==void 0&&typeof ne.definition[ie]!="string"&&(me=`definition.${ie} must be a string.`);!me&&typeof ne.definition.name!="string"&&(me="Give this agent a name.");const ve=!me;!me&&!ne.definition.name.trim()&&(me="Give this agent a name."),!me&&!ne.definition.workflow&&(typeof ne.definition.instructions!="string"||!ne.definition.instructions.trim())&&(me="Add instructions for this agent.");const je=ne;if(!me&&c&&u){const ie=Cc(ne.definition.workflow),Ce=Object.keys(u.definition).filter(Ie=>!Object.hasOwn(ne.definition,Ie));for(const Ie of["id","name","description"])!me&&ne.definition[Ie]!==u.definition[Ie]&&(me=`definition.${Ie} is fixed when the agent is created. Restore its current value.`);for(const Ie of["native","sdk"])!me&&u.definition[Ie]!==void 0&&Ce.includes(Ie)&&(me=`Cannot remove definition.${Ie} here. Edit the original source configuration with your agent.`);if(!me&&!ie)for(const Ie of["input_schema","output_schema"])Ce.includes(Ie)&&(me=`Cannot remove definition.${Ie}: the API keeps an omitted schema. Restore it or supply a replacement schema.`);!me&&Ce.includes("harness")&&(me='Cannot remove definition.harness: the API keeps it. Select an explicit harness, such as "pi" for the default.'),!me&&(u.definition.computer!==void 0||u.definition.place!==void 0)&&!Object.hasOwn(ne.definition,"computer")&&!Object.hasOwn(ne.definition,"place")&&(me='Cannot remove definition.computer and definition.place together: the API keeps the setting. Set computer to {"kind":"none"} or place to {"mode":"runner"} explicitly.');const tt=Cc(ne.skills)&&Object.keys(ne.skills).length===0;if(!me&&!Object.hasOwn(ne.definition,"skills")&&!tt&&(u.definition.skills.length>0||Cc(ne.skills)&&Object.keys(ne.skills).length>0)&&(me="Cannot remove definition.skills while skill files are retained or supplied. Give their skill names, or use definition.skills: [] with skills: {} to clear them."),!me){const Ie=Object.fromEntries(Ce.map(ut=>[ut,ut==="learning"?ie?void 0:!1:ut==="max_cost_usd"?0:ut==="checkout"?ie?void 0:"none":ut==="tools"||ut==="skills"?[]:void 0])),{unchanged:at,...St}=Nd(u,{...Ie,...ne.definition},ne.note??""),st=ne.skills!==void 0&&!tl(ne.skills,v);at&&!st&&(me="Change the definition before saving a revision."),st&&(St.definition.version=u.revisions+1),ne={...ne,...St}}}c&&u&&!g&&(me="This server did not provide a revision ETag. Reload the current revision before editing.");const Ve=c?"PUT":"POST",de=c?`/v2/agents/${encodeURIComponent(r??"")}/definition`:"/v2/agents",Oe=`${n}${de}`,ze=JSON.stringify(ne,null,2),De=ie=>`'${ie.replaceAll("'","'\\''")}'`,Ne={"Content-Type":"application/json",...c&&g?{"If-Match":g}:{}},Q=P==="curl"?`curl -X ${Ve} ${De(Oe)} \\
|
|
684
|
-
-H "Authorization: Bearer $AGENTRUN_API_KEY" \\
|
|
685
|
-
${Object.entries(Ne).map(([ie,Ce])=>` -H ${De(`${ie}: ${Ce}`)} \\
|
|
686
|
-
`).join("")} -d ${De(ze)}`:`const response = await fetch(${JSON.stringify(Oe)}, {
|
|
687
|
-
method: ${JSON.stringify(Ve)},
|
|
688
|
-
headers: {
|
|
689
|
-
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
690
|
-
${Object.entries(Ne).map(([ie,Ce])=>` ${JSON.stringify(ie)}: ${JSON.stringify(Ce)},`).join(`
|
|
691
|
-
`)}
|
|
692
|
-
},
|
|
693
|
-
body: JSON.stringify(${ze}),
|
|
694
|
-
});
|
|
695
|
-
console.log(response.status, await response.json());`,be=ns(u==null?void 0:u.definition),nt=c&&(!!(u!=null&&u.definition.native)||!!be),fe=nt&&u?Go(n,u.agent_id,!!u.definition.native,be==null?void 0:be.runtime):`${c?Go(n,r??""):Hm(n)}
|
|
696
|
-
|
|
697
|
-
Prepared request: ${Ve} ${Oe}${c&&g?`
|
|
698
|
-
If-Match: ${g}`:""}. 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.
|
|
699
|
-
|
|
700
|
-
${ze}`,Le=!me&&!A&&(!c||!!u)&&!K&&!H,Ye=async()=>{if(!Le)return;U(!0),W(null);const ie=performance.now();try{const Ce=c?await e.updateDefinition(r,ne,g):{agent:await e.createAgent(ne),etag:null};W(Ce.agent.agent_id),S(j),I({status:c?200:201,ms:performance.now()-ie,body:Ce.agent}),c?(f(Ce.agent),y(Ce.etag),ne.skills!==void 0&&h(ne.skills)):G(!0)}catch(Ce){const tt=Pb(Ce,performance.now()-ie);I(tt),!c&&(tt.status===0||tt.status>=500)&&G(!0)}finally{U(!1),L("response")}},ht=t.jsxs(kv,{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 A?t.jsxs(t.Fragment,{children:[ht,t.jsxs("div",{className:"m-6 border p-5",role:"alert",children:[t.jsx("p",{children:A}),r&&t.jsx(B,{className:"mt-3",onClick:()=>V(ie=>ie+1),children:"Reload agent"})]})]}):c&&!u?t.jsxs(t.Fragment,{children:[ht,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(ie=>t.jsx("button",{onClick:()=>{if(ie==="form"&&$==="json"){if(!ve)return;b(je)}_(ie)},className:ae("h-12 border-b text-small",$===ie?"border-primary":"border-transparent text-muted-foreground"),children:ie==="json"?"JSON":"Form"},ie))})]}),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."})]}),o&&!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(nn,{value:j,onChange:ie=>k(ie.target.value),className:`${Fi} min-h-[360px] font-mono text-small`,spellCheck:!1})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ui,{name:"Name",children:t.jsx(Pe,{value:x.definition.name,readOnly:c,onChange:ie=>re("name",ie.target.value),className:Fi})}),t.jsx(Ui,{name:"Description",children:t.jsx(Pe,{value:x.definition.description??"",readOnly:c,onChange:ie=>re("description",ie.target.value),className:Fi})}),x.definition.workflow?t.jsx(Ui,{name:"Workflow",children:t.jsx("pre",{className:`${Fi} overflow-auto font-mono text-small`,children:JSON.stringify(x.definition.workflow,null,2)})}):t.jsxs(t.Fragment,{children:[t.jsx(Ui,{name:"Instructions",children:t.jsx(nn,{value:x.definition.instructions??"",rows:5,onChange:ie=>re("instructions",ie.target.value),className:Fi})}),t.jsx(Ui,{name:"Harness",children:t.jsx(Et,{label:"Harness",value:x.definition.harness??"pi",onChange:ie=>re("harness",ie),options:[...new Set([x.definition.harness??"pi",...i.map(ie=>ie.id)])].map(ie=>{var Ce;return{value:ie,label:`${ie}${((Ce=i.find(tt=>tt.id===ie))==null?void 0:Ce.available)===!1?" (not set up)":""}`}})})}),t.jsx(Ui,{name:"Model",children:t.jsx(Pe,{value:x.definition.model??"",onChange:ie=>re("model",ie.target.value),placeholder:"Server default",className:Fi})})]}),t.jsx("button",{className:"text-lead text-primary-text",onClick:()=>_("json"),children:"Edit all fields in JSON →"})]}),me&&t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:me}),c&&u&&!g&&t.jsx(B,{size:"sm",onClick:()=>V(ie=>ie+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(sn,{size:"md",label:"Use your agent",prompt:fe,disabled:!nt&&!!me}),t.jsxs(B,{variant:"primary",onClick:()=>void Ye(),disabled:!Le,children:[t.jsx(Jo,{"aria-hidden":!0}),K?"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(ie=>t.jsx("button",{onClick:()=>L(ie),className:ae("h-12 border-b text-small capitalize",O===ie?"border-primary":"border-transparent text-muted-foreground"),children:ie},ie)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{navigator.clipboard.writeText(Q).then(()=>J(!0),()=>J(!1))},children:t.jsx(Xa,{"aria-hidden":!0})}),t.jsx("span",{role:"status",className:"sr-only",children:se?"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(ie=>t.jsx("button",{onClick:()=>R(ie),className:ae("border-b text-small",P===ie?"border-primary":"border-transparent text-muted-foreground"),children:ie==="curl"?"cURL":"JavaScript"},ie))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:Q})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:F?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[F.status||"Network error"," · ",Math.round(F.ms)," ms"]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(F.body,null,2)}),q&&t.jsxs("a",{className:"inline-flex items-center gap-2 text-lead text-primary-text",href:dn(q),children:["Open agent",t.jsx(hr,{className:"size-4"})]}),F.status===412&&t.jsx(B,{onClick:()=>V(ie=>ie+1),children:"Reload current revision"}),H&&!q&&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."})})]}),ht]})}function Ui({name:e,children:n}){const s=p.useId();return t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:s,className:"block text-lead",children:e}),p.cloneElement(n,{id:s,"aria-label":e})]})}const UU=[{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"}],Vo="p-5 md:p-8",ai="mb-6 max-w-prose",ii="[&>:not(section)]:mb-6";function Or({title:e,titleId:n,note:s,aside:r,label:o,children:i}){const c=p.useId(),d=n??c;return t.jsxs("section",{"aria-label":o,"aria-labelledby":o?void 0:d,className:"border-t py-6 xl:grid xl:grid-cols-[minmax(14rem,20rem)_minmax(0,1fr)] xl:items-start xl:gap-x-10",children:[t.jsxs("div",{className:"max-xl:mb-3",children:[t.jsx("h2",{id:d,className:"caps text-small font-semibold",children:e}),s&&t.jsx("div",{className:"mt-1.5 space-y-1.5 text-body text-muted-foreground",children:s}),r&&t.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:r})]}),t.jsx("div",{className:"min-w-0 space-y-3",children:i})]})}function WU({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:qS,children:UU.filter(r=>n.includes(r.id)).map(r=>t.jsx("a",{href:`#/settings/${r.id}`,"aria-current":e===r.id?"page":void 0,className:KS(e===r.id),children:r.label},r.id))}),t.jsx("div",{className:"min-h-0 flex-1",children:s})]})}async function mh(e,n){var d;let s;try{s=((d=navigator.clipboard)==null?void 0:d.readText().catch(()=>""))??Promise.resolve("")}catch{s=Promise.resolve("")}Cs.flushSync(e);const r=n();if(!r||r.disabled||r.readOnly)return;r.focus();const o=r.value;let i=!1;const c=()=>{i=!0};r.addEventListener("input",c);try{const u=await s;if(!u||!r.isConnected||i||r.value!==o||r.disabled||r.readOnly)return;Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value").set.call(r,u),r.dispatchEvent(new Event("input",{bubbles:!0}))}finally{r.removeEventListener("input",c)}}function aa({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(Ks,{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 HU={anthropic:"claude.ai",openai:"chatgpt.com",openrouter:"openrouter.ai",parallel:"parallel.ai",monid:"monid.ai",browserbase:"browserbase.com",kernel:"kernel.sh",typesafe:"typesafe.ai"},BU={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"},GU=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function qU({id:e,className:n}){const[s,r]=p.useState(!1),o=HU[e],i=BU[e];return o&&!s?t.jsx("img",{"data-provider-icon":e,src:GU(o),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(Da,{className:ae("size-4 shrink-0 text-muted-foreground",n),"aria-hidden":!0})}const KU=/^(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,VU=40;function YU(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&&KU.test(r))return[];const o=r.split(/,?\s+or\s+|,\s+/i).map(c=>c.trim()).filter(Boolean);if(o.length<2||o.length>4||!/\bor\b/i.test(r))return[];const i=o.map(c=>c.replace(/^(the|a|an)\s+/i,"").replace(/\s+instead$/i,""));return i.some(c=>!c||c.length>VU)?[]:i.map(c=>/\s/.test(c)?c[0].toUpperCase()+c.slice(1):c)}function QU(e){var r,o;const n=new Map;for(const i of e){if(i.imported_from)continue;const c=((o=(r=i.error)==null?void 0:r.message)==null?void 0:o.trim())||"The run failed.";n.set(c,[...n.get(c)??[],i])}const s=i=>Date.parse(i.ended_at??i.created_at);return[...n].map(([i,c])=>({message:i,runs:c.sort((d,u)=>s(u)-s(d))})).sort((i,c)=>s(c.runs[0])-s(i.runs[0]))}const u$=e=>e.filter(n=>!n.imported_from).length,JU=864e5;function XU(e,n){return e.some(s=>!s.imported_from)||n.some(s=>s.source==="live"&&s.runs>0)}function Ml(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 ZU(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 eW(e,n){let s=!1,r;const o=()=>{s||e().catch(()=>{}).finally(()=>{s||(r=setTimeout(o,n))})};return o(),()=>{s=!0,clearTimeout(r)}}const f$=e=>e.pending!=null&&e.pending.kind!=="stopped",tW=e=>e.status==="input_required"&&e.state!=="waiting"&&!f$(e),nW=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function V0(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 nW.forEach(([o,i],c)=>{const d=n[c];(d==null?void 0:d.status)==="fulfilled"?s[o]=d.value:d&&r.push(`${i} could not be read: ${d.reason instanceof Error?d.reason.message:String(d.reason)}`)}),{needs:s,problem:r.length?r.join(" · "):null}}function hh({field:e,label:n,writable:s,required:r=!0,stateSaid:o=!1,actionsInline:i=!1,now:c=Date.now,note:d,onPaste:u,onRemove:f}){const g=e.source==="env",y=s&&!g;return t.jsxs("li",{"data-secret":e.name,"data-source":e.source??"none",className:ae("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",g&&"opacity-60"),children:[t.jsxs("span",{children:[sm(e.name,n),!r&&t.jsx("span",{className:"ml-2 font-sans text-label text-muted-foreground",children:"Optional"})]}),t.jsx("span",{"data-state":e.set?"set":r?"missing":"optional-missing",className:o?"sr-only":d?"text-warning-text":e.set?"text-success-text":"text-muted-foreground",children:e.set?"Set":"Missing"}),e.source&&t.jsx("span",{className:"text-muted-foreground",children:p6[e.source]}),e.changed_at&&t.jsxs("span",{className:"text-muted-foreground",children:["Changed ",Ml(e.changed_at,c())," ago"]}),d&&t.jsx("span",{className:"text-warning-text",children:d}),y&&t.jsxs("span",{className:ae("flex gap-2 font-sans",!i&&"ml-auto"),children:[u&&t.jsx(B,{type:"button",size:"sm",variant:e.set?"outline":"primary",onClick:u,children:e.set?"Replace":"Paste"}),f&&e.set&&t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:f,children:"Remove"})]})]})}const Y0={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-…"}},sW=e=>Object.prototype.hasOwnProperty.call(Y0,e)?Y0[e]:void 0,rW={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."},Q0=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function J0(e,n){return n?n.state==="accepted"?`${e} accepted this key · ${ft(n.at)}`:`Not checked: ${n.reason}${n.at?` · ${ft(n.at)}`:""}`:null}const oW="can't be opened: paste it again",aW=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],Dx="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function iW({v2:e,onChange:n,writable:s,whyNot:r="sign_in",plan:o,harnesses:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),[g,y]=p.useState(null),[v,h]=p.useState(null),x=p.useRef(0),b=()=>{const _=++x.current;e.listToolKeys().then(O=>{_===x.current&&(d(O),f(null))}).catch(O=>{_===x.current&&f(Q0(O))})};p.useEffect(b,[e]);const j=_=>y(O=>O===_?null:O),k=_=>{j(_),b(),n==null||n()},E=(_,O,L,P)=>{h({id:_,title:O,error:Q0(L)}),L instanceof Ue&&L.code==="key_set_by_server"&&(j(P),b())};if(!c)return u?t.jsx(X0,{error:u,onRetry:b}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Hn,{label:"Loading the tool keys",rows:3})});const S=c.reenter,N=aW.map(_=>({..._,keys:c.keys.filter(O=>O.kind==="model"==(_.kind==="model"))})).filter(_=>_.keys.length),$=_=>t.jsx(lW,{tool:_,writable:s,again:!!S&&_.fields.some(O=>O.stored_unreadable||S.fields.includes(O.name)),open:(g==null?void 0:g.id)===_.id?g.mode:null,problem:(v==null?void 0:v.id)===_.id?v:null,onOpen:O=>{y(O?{id:_.id,mode:O}:null),h(null)},onSave:async O=>{const L=g;try{await e.saveToolKey(_.id,O)}catch(P){return P instanceof Ue&&P.status===422?P:(E(_.id,"The key was not saved",P,L),null)}return k(L),null},onRemove:async()=>{const O=g;try{await e.removeToolKey(_.id)}catch(L){E(_.id,"The key was not removed",L,O);return}k(O)}},_.id);return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Vo,children:[t.jsxs("div",{className:ai,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Keys"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"A model provider's key, which every agent runs on, and a tool's key, for every agent that uses the tool, kept on this server. A saved key is never shown again."})]}),t.jsxs("div",{className:ii,children:[!s&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:oi[r]}),u&&t.jsx(X0,{inline:!0,error:u,onRetry:b}),S&&t.jsxs(bt,{tone:"warning",role:"alert","aria-label":"Keys to enter again",title:"Enter these keys again",children:[t.jsx("p",{children:rW[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(_=>t.jsx(Or,{label:_.label,title:_.label,note:_.kind==="model"?t.jsx("p",{children:Dx}):void 0,children:t.jsxs("ul",{className:"border",children:[_.kind==="model"&&o,_.keys.map($)]})},_.label)),i&&t.jsx(cE,{harnesses:i})]})]})})}function X0({error:e,onRetry:n,inline:s=!1}){return t.jsx(bt,{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 lW({tool:e,writable:n,again:s,open:r,problem:o,onOpen:i,onSave:c,onRemove:d}){var h;const u=p.useRef(null),f=x=>e.secrets.find(b=>sm(b.name)===x.name),g=x=>e.fields.find(b=>b.name===sm(x.name)),y=e.fields.filter(x=>{var b;return((b=f(x))==null?void 0:b.source)!=="env"}),v=e.secrets.filter(x=>x.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(qU,{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(Se,{tone:v===e.secrets.length?"success":"plain",children:v===e.secrets.length?"set":v?`${v} of ${e.secrets.length} set`:"not set"}),s&&t.jsx(Se,{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(", ")}`]}),J0(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:J0(e.label,e.check)}),t.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(x=>{var b;return t.jsx(hh,{field:x,stateSaid:e.secrets.length===1,writable:n&&r===null,note:(b=g(x))!=null&&b.stored_unreadable?oW:void 0,onPaste:()=>void mh(()=>i("edit"),()=>{var j,k,E;return(E=(j=u.current)==null?void 0:j.querySelector("form"))==null?void 0:E.elements.namedItem(((k=g(x))==null?void 0:k.name)??"")}),onRemove:x.source==="console"?()=>i("remove"):void 0},x.name)})}),!y.length&&t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"Set when the server starts, and that one wins: change it where the server is started."})]})]}),r==="edit"&&t.jsx(m$,{tool:e,fields:y,onSave:c,onCancel:()=>i(null)}),r==="remove"&&t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove the ",e.label," key saved here?",e.secrets.some(x=>x.source==="env")?" The one set in the environment stays.":""]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void d(),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>i(null),children:"Keep"})]}),o&&t.jsx("div",{className:"mt-4 border",children:t.jsx(aa,{error:o.error,title:o.title})})]})}function m$({tool:e,fields:n,onSave:s,onCancel:r}){const o=p.useRef(null),[i,c]=p.useState(!1),[d,u]=p.useState(!1),[f,g]=p.useState(null),y=()=>n.some(b=>{var j,k;return(k=(j=o.current)==null?void 0:j.elements.namedItem(b.name))==null?void 0:k.value}),v=()=>{var b;(b=o.current)==null||b.reset(),c(!1)},h=async b=>{var N,$;b.preventDefault();const j={};for(const _ of n){const O=($=(N=o.current)==null?void 0:N.elements.namedItem(_.name))==null?void 0:$.value;O&&(j[_.name]=O)}if(!Object.keys(j).length)return;u(!0),g(null);const k=await s(j);if(u(!1),!k){v();return}const E={},S=[];for(const _ of k.fields??[]){const O=_.field.startsWith("values.")?_.field.slice(7):null;O&&n.some(L=>L.name===O)?E[O]=_.message:S.push(_.message)}g({fields:E,message:S.length?S.join(" "):Object.keys(E).length?null:k.message})},x=sW(e.id);return t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:b=>void h(b),onInput:()=>c(!!y()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e.label} key`,children:[x&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:e.label})," · No key yet?"," ",t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Get a key"})," (opens in a new tab)"]}),n.map(b=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:b.name}),b.set&&t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"Saved already. A new value replaces it; leave it empty to keep it."}),t.jsx(Pe,{type:"password",name:b.name,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:x&&n.length===1?x.placeholder:void 0}),(f==null?void 0:f.fields[b.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[b.name]})]},b.name)),(f==null?void 0:f.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f.message}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!i||d,children:d?"Saving":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{v(),r()},children:"Cancel"})]})]})}const Dd=p.createContext(null);function Z0({connection:e,children:n}){return t.jsx(Dd.Provider,{value:e,children:n})}const cW={state:"online"},dW=()=>()=>{},eN=()=>cW;function Ib(){const e=p.useContext(Dd);return p.useSyncExternalStore(e?e.subscribe:dW,e?e.link:eN,eN)}function h$(e){const n=p.useContext(Dd),s=p.useRef(e);s.current=e,p.useEffect(()=>n==null?void 0:n.onResume(()=>s.current()),[n])}function p$(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 uW(){const e=p.useContext(Dd),n=Ib(),s=p$(n.state==="offline"?n.retryAt:null);return!e||n.state==="online"?null:n.state==="resumed"?t.jsxs(bt,{bar:!0,tone:"success",icon:Xo,"data-connection":"resumed",children:[t.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):t.jsxs(bt,{bar:!0,tone:"warning",icon:ZN,"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 fW(){const e=p.useContext(Dd),n=Ib(),s=p$(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(ZN,{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 mW=(e,n)=>e.flatMap(s=>s.tools.flatMap(r=>{var o;return(o=r.permissions)!=null&&o.length&&r.default_permission?[{name:cC(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"}:{}}]:[]})),tN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function hW({v2:e,choices:n,gates:s=[],harnesses:r,mcp:o=!1,onSaved:i,onOpen:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),y=()=>{o&&(g(null),e.listMcpServers().then(H=>g(H.servers),()=>g("failed")))};p.useEffect(y,[e,o]);const[v,h]=p.useState(null),[x,b]=p.useState(null),[j,k]=p.useState(!1),[E,S]=p.useState(null),N=p.useRef(0),$=()=>{const H=++N.current;e.toolSettings().then(G=>{H===N.current&&(u(G),h(null))},G=>{H===N.current&&h(tN(G))})};p.useEffect($,[e]);const[_,O]=p.useState("reading"),L=()=>{O("reading"),Promise.resolve(c==null?void 0:c()).then(H=>O(H===!1?"failed":"landed"))},P=()=>{$(),L()};if(p.useEffect(L,[]),!d)return v?t.jsx(bt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:$,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The tool settings could not be read: ",v.code,": ",v.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const R=Ex(d,n),A=E?E(R):R,M=rE(n,[...s,...Array.isArray(f)?mW(f,s.some(H=>H.ask_needs==="password")):[]]),F=H=>{var z;const G=qo(H);return G?(z=A[`mcp:${G.server}/*`])==null?void 0:z.permission:void 0},I=Object.entries(A).filter(([,H])=>(H==null?void 0:H.pin)||(H==null?void 0:H.pin_broken)),q=H=>{var z;const G=s.find(V=>V.name===H);return!G||(((z=A[H])==null?void 0:z.permission)??G.default_permission)===G.permission},{byTool:W,rest:K}=QC((x==null?void 0:x.fields)??{},"",M.map(H=>H.name)),U=async H=>{var se;const G=E?J=>H(E(J)):H;k(!0),b(null);const z=++N.current;let V;try{V=await e.toolSettings()}catch{S(()=>G),b({fields:{},error:null,unread:!0}),k(!1);return}try{const J=await e.saveToolSettings(G(Ex(V,n)));S(null),z===N.current&&(u(J),h(null)),i()}catch(J){b(J instanceof Ue&&J.status===422&&((se=J.fields)!=null&&se.length)?{fields:Object.fromEntries(J.fields.map(re=>[re.field,re.message])),error:null}:{fields:{},error:tN(J)})}k(!1)};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Tools"}),t.jsxs("div",{className:"mt-2 grid gap-x-10 gap-y-2 xl:grid-cols-2",children:[t.jsx("p",{className:"text-lead text-muted-foreground",children:"This server's provider for each tool that has a choice, and what it resolves to on each harness. A change is saved at once and applies to every run launched from then on. An agent with a provider of its own keeps it."}),s.length>0&&t.jsxs("p",{className:"text-lead text-muted-foreground",children:["Each tool's permission: ",t.jsx("span",{className:"font-mono text-body",children:"allow"})," runs it, ",t.jsx("span",{className:"font-mono text-body",children:"ask"})," makes the run wait for your approval at each call, ",t.jsx("span",{className:"font-mono text-body",children:"deny"})," refuses it and tells the agent why. A permission applies at the next call, in runs already going too. An agent's own allow or ask takes the place of this server's; deny here refuses it for every agent."]})]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("section",{"aria-label":"This server's providers",children:[M.length?t.jsx(bb,{label:"This server's tool settings",rows:M,settings:A,fallbackOf:H=>H.default_provider,issues:W,busy:j,onEdit:H=>void U(H),permissionFallbackOf:H=>F(H.name)??H.default_permission,refused:(H,G)=>G==="deny",resolvesOf:(H,G)=>G===H.provider&&q(H.name)?t.jsx(ZF,{choice:H,harnesses:r}):_==="reading"?t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"reading…"}):t.jsxs("span",{className:"block text-small text-muted-foreground",children:[_==="failed"?"What it resolves to couldn't be read.":"It changed while this page read it."," ",t.jsx(B,{type:"button",onClick:P,disabled:j,size:"xs",className:"ml-1",children:"Retry"})]})}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"This server offers no tool with a choice of provider."}),f==="failed"&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"alert",children:["The MCP servers' tools could not be read, so they are not listed. ",t.jsx(B,{type:"button",size:"xs",className:"ml-1",onClick:y,disabled:j,children:"Retry"})]}),K.map(H=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:H},H)),(x==null?void 0:x.error)&&t.jsx("div",{className:"mt-3 border",children:t.jsx(aa,{error:x.error,title:"The change was not saved"})}),(x==null?void 0:x.unread)&&t.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[t.jsx("p",{className:"font-mono text-small text-destructive-text",children:"Couldn't read the current settings, so nothing was saved. Try again."}),t.jsx(B,{type:"button",size:"xs",className:"mt-2",onClick:()=>void U(H=>H),disabled:j,children:"Try again"})]}),v&&t.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[t.jsxs("p",{className:"font-mono text-small text-destructive-text",children:["The tool settings could not be read again: ",v.code,": ",v.message]}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The table shows the last ones read."}),t.jsx(B,{type:"button",onClick:P,disabled:j,size:"xs",className:"mt-2",children:"Try again"})]})]}),I.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:I.map(([H,G])=>t.jsxs("li",{"data-pin":H,className:"border-b px-3 py-2.5 last:border-b-0",children:[t.jsx("p",{className:"font-mono text-body",children:H}),t.jsx(_x,{setting:G})]},H))})]})]})]})})}function pW(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 nN={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."},gW=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(nN,e.reason)?nN[e.reason]:"The connection didn't finish. Try again.";function xW(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 vW({note:e}){const n=e.lastIndexOf(": "),s=n>=0?e.slice(n+2).trim():"",r=s?fr(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 bW({v2:e,returned:n}){const[s,r]=p.useState(void 0),[o,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(!1),[g,y]=p.useState(null),[v,h]=p.useState(null),[x,b]=p.useState(null),[j,k]=p.useState(!1),[E,S]=p.useState(null),N=p.useRef(!1),$=p.useRef(null),_=p.useCallback(async()=>{try{const R=await e.githubConnection();r(R.connected?R:null),i(null)}catch(R){i(R instanceof Error?R.message:String(R))}},[e]);p.useEffect(()=>{_()},[_]),p.useEffect(()=>{n&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),p.useEffect(()=>{var R;g&&((R=$.current)==null||R.submit())},[g]);const O=async()=>{var R;if(!N.current){N.current=!0,f(!0),h(null),b(null),S(null);try{const A=await e.connectGitHub(c.trim()||void 0),M=xW(A.action,fr);if(!M){h("GitHub's address didn't look right, so nothing was sent."),N.current=!1,f(!1);return}y({action:M,manifest:JSON.stringify(A.manifest)})}catch(A){if(N.current=!1,f(!1),h(A instanceof Error?A.message:String(A)),A instanceof Ue&&A.code==="github_wrong_origin"){const M=(R=A.details)==null?void 0:R.public_url;b(typeof M=="string"&&fr(M)||null)}A instanceof Ue&&A.code==="github_already_connected"&&_()}}},L=async()=>{k(!1),f(!0),h(null),b(null);try{S(await e.disconnectGitHub()),r(null)}catch(R){R instanceof Ue&&(R.status===404||R.code==="github_not_connected")?await _():h(R instanceof Error?R.message:String(R))}finally{f(!1)}},P=s?fr(`https://github.com/apps/${encodeURIComponent(s.slug)}`):void 0;return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Vo,children:[t.jsxs("div",{className:ai,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"GitHub"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"One GitHub App for this server: its templates and triggers reach GitHub through it."})]}),t.jsxs("div",{className:ii,children:[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:gW(n)}),(v||x)&&t.jsx("div",{role:"alert",className:"border border-destructive/50 px-4 py-3 text-lead text-destructive-text",children:x?t.jsxs("p",{children:["Open this server at ",t.jsx("a",{href:x,className:"break-all underline underline-offset-2",children:x})," to connect GitHub."]}):t.jsx("p",{children:v})}),E&&t.jsxs("section",{"aria-label":"Disconnected",className:"border p-4 text-lead",children:[t.jsx("p",{children:t.jsx(vW,{note:E.note})}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:E.triggers_off?`${E.triggers_off} GitHub ${E.triggers_off===1?"trigger":"triggers"} turned off.`:"No GitHub trigger was on."})]}),o&&t.jsx(bt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:()=>void _(),children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["GitHub's connection could not be read: ",o]})}),t.jsxs(Or,{title:"Connection",children:[s===void 0&&!o&&t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading..."}),s===null&&t.jsxs("section",{"aria-label":"Connect GitHub",className:"border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[t.jsxs("label",{className:"flex min-w-[240px] flex-1 flex-col gap-1 text-body",children:[t.jsx("span",{className:"text-muted-foreground",children:"Organization (optional): the App is made under it"}),t.jsx(Pe,{name:"org",value:c,onChange:R=>d(R.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(gj,{"aria-hidden":!0}),g?"Opening GitHub…":"Connect GitHub"]})]}),t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"GitHub asks you to create the App, then to install it on the accounts it may use. You come back here after."})]}),s&&t.jsxs("section",{"aria-label":"GitHub App",className:"border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-lead",children:[t.jsx(gj,{className:"size-4 text-muted-foreground","aria-hidden":!0}),P?t.jsx("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"font-mono underline underline-offset-2",children:s.slug}):t.jsx("span",{className:"font-mono",children:s.slug}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["App ",s.app_id]})]}),s.installations.length?t.jsx("ul",{"aria-label":"Installations",className:"mt-3 space-y-1 font-mono text-body",children:s.installations.map(R=>t.jsx("li",{children:R.account},R.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 L(),children:"Disconnect GitHub"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>k(!1),children:"Cancel"})]}):t.jsx(B,{type:"button",variant:"outline",className:"mt-4",disabled:u,onClick:()=>k(!0),children:"Disconnect"})]})]}),g&&t.jsx("form",{"data-github-manifest":!0,ref:$,method:"post",action:g.action,hidden:!0,children:t.jsx("input",{type:"hidden",name:"manifest",defaultValue:g.manifest})})]})]})})}const yW=8,wW={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function jW({v2:e,signIn:n,add:s,writable:r,whyNot:o="sign_in",open:i=d=>location.assign(d),choices:c=[]}){var H,G,z,V,se;const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState(!1),[h,x]=p.useState(null),[b,j]=p.useState(null),k=(s==null?void 0:s.preset)==="composio"?s:void 0,[E,S]=p.useState(s&&!k?{add:s}:null),[N,$]=p.useState(k&&r?k:!1),[_,O]=p.useState(null),L=s?JSON.stringify(s):"",P=p.useRef(L);p.useEffect(()=>{if(L===P.current)return;P.current=L;const J=L?JSON.parse(L):void 0;S(J&&J.preset!=="composio"?{add:J}:null),$((J==null?void 0:J.preset)==="composio"&&r?J:!1)},[L]);const R=p.useRef(0),A=p.useRef(null),M=()=>{const J=++R.current;e.listMcpServers().then(re=>{J===R.current&&(u(re.servers),j(null))},re=>{J===R.current&&j(io(re))})};p.useEffect(M,[e]),p.useEffect(()=>{e.toolSettings().then(g,()=>g(null))},[e]);const F=p.useRef(!1),I=async(J,re)=>{if(!F.current){F.current=!0,v(!0),x(null);try{const ne=await e.toolSettings();g(await e.saveToolSettings(re(Ex(ne,c)))),M()}catch(ne){x({server:J,problem:io(ne)})}F.current=!1,v(!1)}},q=p.useRef(null);s&&d&&((H=q.current)==null?void 0:H.key)!==L&&(q.current={key:L,name:g$(s.name,d)});const W=J=>{var re;return((re=q.current)==null?void 0:re.key)===JSON.stringify(J)&&q.current.name!==J.name?{...J,toolkit:J.toolkit??J.name,name:q.current.name}:J},K=d!==null||b!==null;p.useEffect(()=>{n&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[n]);const U=async(J,re)=>i((await e.startMcpSignIn(J,re)).authorization_url);return t.jsx("div",{ref:A,className:"h-full overflow-auto",children:t.jsxs("div",{className:Vo,children:[t.jsxs("div",{className:ai,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"MCP servers"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"A remote MCP server's tools, for any agent you grant them to in its Tools step. A saved credential is never shown again."})]}),t.jsxs("div",{className:ii,children:[n&&t.jsx("p",{className:`border p-4 text-body ${n.ok?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:n.ok?`Signed in to ${n.server}. Its tools are saved.`:`Signing in to ${n.server} failed: ${DI(n.error)}.`}),!r&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:oi[o]}),_&&t.jsx("p",{className:`border p-4 text-body ${_.removed?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:_.note}),b&&t.jsx(bt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:M,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The MCP servers could not be read. ",b.text]})}),t.jsxs(Or,{title:"Servers",aside:!E&&!N&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",disabled:!r,onClick:()=>$(!0),children:"Add from Composio"}),t.jsx(B,{size:"sm",variant:"primary",onClick:()=>S({}),children:"Add server"})]}),children:[E&&(!E.add||K)&&t.jsx(MW,{v2:e,saved:E.saved,add:E.add&&W(E.add),given:E.problem,writable:r,taken:d,signIn:U,onCancel:()=>S(null),onSaved:(J=>re=>{re&&O(re),S(ne=>ne===J?null:ne),M()})(E)},`${((G=E.saved)==null?void 0:G.name)??"new"}|${((z=E.add)==null?void 0:z.name)??""}|${((V=E.add)==null?void 0:V.auth)??""}|${((se=E.add)==null?void 0:se.preset)??""}`),N&&(typeof N!="object"||K)&&t.jsx(RW,{v2:e,add:typeof N=="object"?W(N):void 0,onClose:()=>$(!1),onSaved:M},typeof N=="object"?L:"new"),d&&(d.length?t.jsx("ul",{className:"border",children:d.map(J=>t.jsx(NW,{v2:e,server:J,settings:f,settingsBusy:y,settingsProblem:(h==null?void 0:h.server)===J.name?h.problem:null,onSettings:re=>void I(J.name,re),writable:r&&!E,signIn:U,onChange:re=>S({saved:J,...re?{problem:re}:{}}),onPaste:()=>void mh(()=>S({saved:J}),()=>{var re;return((re=A.current)==null?void 0:re.querySelector('input[name="mcp-token"], input[name="mcp-header-value-0"]'))??null}),onChanged:M,onDeleted:re=>{O(re??null),M()}},J.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(_W,{v2:e})]})]})})}const yl=({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})]}),Lc=(e,n)=>`mcp:${e}/${n}`,kW=["allow","ask","deny"];function NW({v2:e,server:n,settings:s,settingsBusy:r,settingsProblem:o,onSettings:i,writable:c,signIn:d,onChange:u,onPaste:f,onChanged:g,onDeleted:y}){var P,R;const[v,h]=p.useState(!1),[x,b]=p.useState(!1),[j,k]=p.useState(null),[E,S]=p.useState(null),N=async A=>{h(!0),S(null);try{await A()}catch(M){S(io(M))}h(!1)},[$,_]=n.credential?wW[n.credential]??[n.credential,"plain"]:["no credential","plain"],O=n.auth.type==="oauth",L=j&&[["Added",j.added],["Removed",j.removed],["Changed",j.changed]].filter(([,A])=>A.length).map(([A,M])=>`${A} ${M.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(dR,{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(Se,{tone:_,children:$}),!!((P=n.not_metered)!=null&&P.length)&&t.jsx(Se,{tone:"plain",children:"not metered"}),n.source&&t.jsxs(t.Fragment,{children:[t.jsx(Se,{tone:"muted",children:Ed[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",(R=n.auth.headers)!=null&&R.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 ${ft(n.oauth.expires_at)}`:""]}),s&&t.jsx(EW,{server:n,settings:s,busy:r,onSettings:i}),o&&t.jsx("div",{className:"mt-2",children:t.jsx(yl,{problem:o})}),t.jsxs("details",{className:"mt-2",children:[t.jsxs("summary",{className:"cursor-pointer font-mono text-small",children:[n.tools.length," tool",n.tools.length===1?"":"s"]}),t.jsx("div",{className:"mt-2",children:t.jsx($W,{server:n,settings:s,busy:r,onSettings:i})})]}),n.secret&&t.jsx("ul",{className:"mt-2",children:t.jsx(hh,{field:n.secret,label:LW[n.auth.type],writable:c,onPaste:O?void 0:f})}),n.source==="composio"&&t.jsx(CW,{v2:e,server:n.name,writable:c}),L&&t.jsx("p",{className:"mt-2 font-mono text-small",role:"status",children:L.length?L.join(" · "):"No change: it lists the same tools."})]}),!x&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[O&&n.credential!=="sealed"&&c&&t.jsx(B,{size:"sm",variant:"primary",disabled:v,onClick:()=>void N(()=>{var A;return d(n.name,{url:n.url,...(A=n.oauth)!=null&&A.scopes.length?{scopes:n.oauth.scopes}:{}})}),children:"Sign in again"}),t.jsx(B,{size:"sm",disabled:v,onClick:()=>void N(async()=>{try{k(await e.refreshMcpServer(n.name))}finally{g()}}),children:"Refresh"}),t.jsx(B,{size:"sm",disabled:v,onClick:()=>u(),children:"Change"}),t.jsx(B,{size:"sm",variant:"destructive",disabled:v,onClick:()=>b(!0),children:"Delete"})]})]}),x&&t.jsxs("div",{role:"alertdialog","aria-label":`Delete ${n.name}`,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Delete ",n.name,"? Its credential goes with it, and an agent that grants its tools can't call them."]}),t.jsx(B,{size:"sm",variant:"destructive",disabled:v,onClick:()=>void N(async()=>{var A;y((A=await e.deleteMcpServer(n.name))==null?void 0:A.composio)}),children:"Delete"}),t.jsx(B,{size:"sm",onClick:()=>b(!1),children:"Keep"})]}),E&&t.jsxs("div",{className:"mt-3",children:[t.jsx(yl,{problem:E}),E.needsClient&&c&&t.jsx(B,{className:"mt-2",size:"sm",variant:"primary",onClick:()=>u(E),children:"Enter a Client ID"})]})]})}const SW={on:"on at Composio",off:"off at Composio",missing:"Composio no longer has it",unknown:"Composio didn't say"};function CW({v2:e,server:n,writable:s}){const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[y,v]=p.useState(!1),[h,x]=p.useState(!1);if(p.useEffect(()=>{let k=!0;return e.composioTriggers(n).then(E=>{k&&o(E)},E=>{k&&(E instanceof Ue&&E.status===404?u(!0):c(io(E)))}),()=>{k=!1}},[e,n]),d)return null;const b=async()=>{g(!1),v(!0),c(null),x(!1);try{await e.rotateComposioSecret(n),x(!0)}catch(k){c(io(k))}v(!1)},j=r==null?void 0:r.subscription;return t.jsxs("section",{"data-composio-triggers":!0,"aria-label":`${n}'s triggers`,className:"mt-3 border p-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Triggers"}),r?t.jsxs(t.Fragment,{children:[r.triggers.length?t.jsx("ul",{className:"mt-2 space-y-1",children:r.triggers.map(k=>t.jsxs("li",{"data-trigger":k.id,className:"flex flex-wrap items-center gap-x-2 text-body",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(k.id)}`,className:"font-semibold hover:underline",children:k.name}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:k.event}),t.jsxs("span",{className:`font-mono text-small ${k.on_composio==="missing"?"text-warning-text":"text-muted-foreground"}`,children:["· ",SW[k.on_composio],k.enabled?"":" · paused here"]})]},k.id))}):t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["No trigger uses it yet. ",t.jsx("a",{href:"#/triggers/new-composio",className:"underline underline-offset-2",children:"New app trigger"})]}),r.composio_error&&t.jsxs("p",{className:"mt-2 text-small text-warning-text",children:["Composio didn't answer: ",r.composio_error]}),j&&(j.ours?t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"The project's webhook subscription sends its events here."}):t.jsxs("p",{className:"mt-2 break-all text-small text-muted-foreground",children:["The project's webhook subscription sends its events to ",t.jsx("span",{className:"font-mono",children:j.webhook_url}),", not here: a new trigger asks before it moves it."]})),(j==null?void 0:j.ours)&&s&&!f&&t.jsx(B,{className:"mt-2",size:"sm",disabled:y,onClick:()=>g(!0),children:"Rotate secret"}),f&&t.jsxs("div",{role:"alertdialog","aria-label":"Rotate the subscription's secret?",className:"mt-2 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Rotate the subscription's secret? Composio makes a new one and this server keeps it; a delivery signed with the old one is refused from then on."}),t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void b(),children:"Yes, rotate"}),t.jsx(B,{size:"sm",onClick:()=>g(!1),children:"Keep"})]}),h&&t.jsx("p",{className:"mt-2 text-small text-success-text",role:"status",children:"Rotated: Composio signs with the new secret from now on."})]}):!i&&t.jsx("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:"Reading its triggers"}),i&&t.jsx("div",{className:"mt-2",children:t.jsx(yl,{problem:i})})]})}function EW({server:e,settings:n,busy:s,onSettings:r}){var g;const o=Lc(e.name,"*"),i=((g=n[o])==null?void 0:g.allow_reads)===!0,c=e.tools.filter(y=>y.effect==="read").length,d=`allow-reads-${e.name}`,u=`${d}-words`,f=y=>r(v=>{const{[o]:h,...x}=v,{allow_reads:b,...j}=h??{},k=y?{...j,allow_reads:!0}:j;return Object.keys(k).length?{...x,[o]:k}:x});return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(vd,{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 $W({server:e,settings:n,busy:s,onSettings:r}){const o=n==null?void 0:n[Lc(e.name,"*")],i=new Map(e.tools.map(u=>[Lc(e.name,u.name),u])),c=e.tools.map(u=>{var f;return{name:Lc(e.name,u.name),...n?{gate:{name:Lc(e.name,u.name),permission:u.permission??"ask",default_permission:u.default_permission??"ask",permissions:(f=u.permissions)!=null&&f.length?u.permissions:kW}}:{}}}),d=u=>{var g,y;const f=(g=e.prices)==null?void 0:g[u];return f!==void 0?`$${f} a call`:(y=e.not_metered)!=null&&y.includes(u)?"not metered":null};return t.jsx(bb,{label:`${e.name}'s tools`,rows:c,settings:n??{},busy:s,issues:{},fallbackOf:()=>"",resolvesOf:()=>null,onEdit:r,labelOf:u=>{var f;return((f=i.get(u))==null?void 0:f.name)??u},detailOf:u=>{var f;return d(((f=i.get(u))==null?void 0:f.name)??"")},effectOf:u=>{var f;return(f=i.get(u))==null?void 0:f.effect},confirmAllowOf:u=>{var f;return((f=i.get(u))==null?void 0:f.effect)==="destructive"},refused:(u,f)=>f==="deny",fallbackWordOf:u=>{var f;return(f=i.get(u))!=null&&f.fallback_allow_reads?"allow reads":void 0},permissionFallbackOf:u=>{var f;return(f=i.get(u.name))!=null&&f.fallback_allow_reads?"allow":(o==null?void 0:o.permission)??u.default_permission}})}function _W({v2:e}){const[n,s]=p.useState(null),[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(""),y=()=>void e.mcpPrivateHosts().then(x=>{s(x.hosts),o(null)},x=>o(io(x)));p.useEffect(y,[e]);const v=async x=>{u(!0),c(null);try{return s((await e.saveMcpPrivateHosts(x)).hosts),!0}catch(b){return c(io(b)),!1}finally{u(!1)}},h=async x=>{x.preventDefault(),n&&f.trim()&&await v([...n,f.trim()])&&g("")};return t.jsxs(Or,{titleId:"mcp-private-hosts",title:"Private network hosts",note:t.jsx("p",{children:"Off by default. A host listed here may run an MCP server's sign-in on your private network (10.x, 172.16–31.x, 192.168.x, 100.64–127.x, fc00::/7), over https only; never this machine, loopback or a link-local address such as cloud metadata."}),children:[r&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The private network hosts could not be read. ",r.text]}),t.jsx(B,{size:"sm",onClick:y,className:"mt-3",children:"Try again"})]}),n&&(n.length?t.jsx("ul",{"aria-label":"Allowed private network hosts",className:"border",children:n.map(x=>t.jsxs("li",{"data-host":x,className:"flex items-center justify-between gap-3 border-b px-3 py-2 last:border-b-0",children:[t.jsx("span",{className:"break-all font-mono text-body",children:x}),t.jsx(B,{size:"sm",disabled:d,onClick:()=>void v(n.filter(b=>b!==x)),children:"Remove"})]},x))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No host is allowed: a sign-in on a private network is refused."})),n&&t.jsxs("form",{onSubmit:x=>void h(x),"aria-label":"Allow a private network host",className:"flex gap-2",children:[t.jsx(Pe,{name:"mcp-private-host","aria-label":"Host name or IP address",value:f,onChange:x=>g(x.target.value),placeholder:"auth.corp.example",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:d||!f.trim(),children:"Allow"})]}),i&&t.jsx(yl,{problem:i})]})}const TW=32;function g$(e,n){const s=new Set(n.map(r=>r.name));if(!s.has(e))return e;for(let r=2;;r++){const o=`-${r}`,i=`${e.slice(0,TW-o.length).replace(/-+$/,"")}${o}`;if(!s.has(i))return i}}function RW({v2:e,add:n,onClose:s,onSaved:r}){var R;const o=p.useRef(null),[i,c]=p.useState((n==null?void 0:n.toolkit)??""),[d,u]=p.useState((n==null?void 0:n.name)??""),[f,g]=p.useState(null),[y,v]=p.useState([]),[h,x]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(!1),S=()=>{var A,M;return(((M=(A=o.current)==null?void 0:A.elements.namedItem("composio-key"))==null?void 0:M.value)??"").trim()},N=async A=>{E(!0),j(null);try{await A()}catch(M){j(io(M))}E(!1)},$=p.useRef(0),_=()=>{$.current++,g(null)},O=()=>N(async()=>{const A=++$.current;g(null),v([]);const M=await e.composioTools(S(),i.trim().toLowerCase());A===$.current&&(g(M),n!=null&&n.tools&&M.toolkit===n.toolkit&&v(M.tools.map(F=>F.slug).filter(F=>n.tools.includes(F))))}),L=()=>N(async()=>{var M,F;const A=await e.saveComposioServer(d.trim(),S(),f.toolkit,y);(M=o.current)==null||M.reset(),r(),A.connect_url||(F=A.not_served)!=null&&F.length||A.composio?x({connect:A.connect_url,notServed:A.not_served,composio:A.composio}):s()}),P=A=>v(M=>M.includes(A)?M.filter(F=>F!==A):[...M,A]);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"]})}),(R=h.notServed)!=null&&R.length?t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:["Composio's server doesn't list ",h.notServed.join(", "),": a run can't call ",h.notServed.length===1?"it":"them","."]}):null,h.composio&&t.jsx("p",{className:`border p-4 text-body ${h.composio.removed?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:h.composio.note}),t.jsx(B,{size:"sm",onClick:s,children:"Done"})]}):t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:A=>{A.preventDefault(),f&&y.length&&d.trim()&&L()},"aria-label":"Add from Composio",className:"space-y-4 border bg-card p-4",onInput:A=>{A.target.name==="composio-key"&&_()},children:[t.jsx("p",{className:"text-small text-muted-foreground",children:"Composio runs the toolkit's actions for you. This saves an MCP server that grants only the actions you tick, with your Composio key sealed like any credential."}),(n==null?void 0:n.tools)&&t.jsxs("p",{role:"note",className:"text-small text-muted-foreground",children:["A template uses ",n.tools.join(", "),": enter your key and load the actions, and those are ticked."]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Composio API key"}),t.jsx(Pe,{name:"composio-key",...Tf})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),t.jsx(Pe,{name:"composio-toolkit",value:i,onChange:A=>{c(A.target.value),_()},placeholder:"github",spellCheck:!1})]}),b&&t.jsx(yl,{problem:b}),f&&t.jsxs("fieldset",{className:"space-y-2",children:[t.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Actions to grant"}),f.tools.length?t.jsx("ul",{className:"divide-y border",children:f.tools.map(A=>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:A.slug,checked:y.includes(A.slug),onChange:()=>P(A.slug),className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono",children:A.name}),t.jsx("span",{className:"ml-2 font-mono text-small text-muted-foreground",children:A.slug}),A.description&&t.jsx("span",{className:"block text-small text-muted-foreground",children:A.description})]})]})},A.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(Pe,{name:"composio-name",value:d,onChange:A=>u(A.target.value),spellCheck:!1})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:k||!i.trim(),onClick:()=>void O(),children:"Load actions"}),f&&t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:k||!y.length||!d.trim(),children:k?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",disabled:k,onClick:()=>{var A;(A=o.current)==null||A.reset(),s()},children:"Cancel"})]})]})}const AW=/^mcp-(token|scopes|client-id|client-secret|header-(name|value)-\d+)$/,Tf={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},OW=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"],["github_app","GitHub App"]],LW={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in",github_app:"Headers"};function MW({v2:e,saved:n,add:s,given:r,writable:o,taken:i,signIn:c,onCancel:d,onSaved:u}){var De,Ne,Q,be,nt;const f=p.useRef(null),g=n?void 0:lC(s==null?void 0:s.preset),[y,v]=p.useState(g),[h,x]=p.useState((n==null?void 0:n.name)??(s==null?void 0:s.name)??""),[b,j]=p.useState((n==null?void 0:n.url)??((s==null?void 0:s.auth)==="github_app"?Vf:(g==null?void 0:g.url)??"")),[k,E]=p.useState((n==null?void 0:n.auth.type)??(s==null?void 0:s.auth)??(g==null?void 0:g.auth)??"none"),[S,N]=p.useState(Math.max(1,((De=n==null?void 0:n.auth.headers)==null?void 0:De.length)??0)),$=k==="github_app"?"github":(n==null?void 0:n.source)==="composio"?"composio":"url",[_,O]=p.useState((n==null?void 0:n.toolkit)??(g?g.name:s&&!s.auth?s.toolkit??s.name:"")),L=$==="github"?"github":_.trim(),P=()=>{if(k==="github_app")return{};const fe=L||null;return n?fe!==n.toolkit?{toolkit:fe}:{}:fe?{toolkit:fe}:{}},R=!n&&!!(i!=null&&i.some(fe=>fe.name===h.trim())),A=!!n||!!i&&!R,[M,F]=p.useState(null),[I,q]=p.useState(r??null),[W,K]=p.useState(!1),U=p.useRef(0),H=()=>{U.current++,F(null)},G=fe=>{var Le,Ye;return(((Ye=(Le=f.current)==null?void 0:Le.elements.namedItem(fe))==null?void 0:Ye.value)??"").trim()},[z,V]=p.useState(!1),se=fe=>{try{return new URL(fe).origin}catch{return fe}},J=(fe=k)=>{var Le;return V(!!n&&fe==="oauth"&&(n.auth.type!=="oauth"||G("mcp-scopes")!==(((Le=n.oauth)==null?void 0:Le.scopes.join(" "))??"")||!!G("mcp-client-id")||!!G("mcp-client-secret")||se(G("mcp-url"))!==se(n.url)))};p.useEffect(()=>J(),[k]);const re=()=>{if(k==="bearer")return G("mcp-token")?{type:k,token:G("mcp-token")}:{type:k};if(k!=="headers"&&k!=="github_app")return{type:k};const fe=Object.fromEntries(Array.from({length:S},(Le,Ye)=>[G(`mcp-header-name-${Ye}`),G(`mcp-header-value-${Ye}`)]).filter(([Le,Ye])=>Le&&Ye));return Object.keys(fe).length?{type:k,headers:fe}:{type:k}},ne=async fe=>{K(!0),q(null);try{await fe()}catch(Le){q(io(Le))}K(!1)},me=!!(I!=null&&I.needsClient);p.useEffect(()=>{me&&E("oauth")},[me]),p.useEffect(()=>{var fe,Le;me&&k==="oauth"&&((Le=(fe=f.current)==null?void 0:fe.elements.namedItem("mcp-client-id"))==null||Le.focus())},[me,k]);const ve=()=>A&&ne(()=>{const fe=G("mcp-scopes").split(/\s+/).filter(Boolean),Le=G("mcp-client-id");return c(h.trim(),{url:b.trim(),...fe.length?{scopes:fe}:{},...Le?{client_id:Le,...G("mcp-client-secret")?{client_secret:G("mcp-client-secret")}:{}}:{},...P()})}),je=()=>{const fe=U.current;ne(async()=>{try{const Le=await e.previewMcpServer(b.trim(),re(),n==null?void 0:n.name);fe===U.current&&F(Le)}catch(Le){if(fe===U.current)throw Le}})},Ve=fe=>{if(fe.preventDefault(),!!A){if(k==="oauth"&&(!n||z))return void ve();ne(async()=>{var Ye;const Le=await e.saveMcpServer(h.trim(),b.trim(),re(),P());(Ye=f.current)==null||Ye.reset(),u(Le.composio)})}},de=!W&&A&&!!h.trim()&&!!b.trim()&&(!!n||!!M),Oe=fe=>{var Le;if(i){for(const Ye of Array.from(((Le=f.current)==null?void 0:Le.elements)??[]))Ye instanceof HTMLInputElement&&AW.test(Ye.name)&&(Ye.value="");N(1),v(fe),x(g$(fe.name,i)),j(fe.url),E(fe.auth),O(fe.name),q(null),H()}},ze=fe=>(n==null?void 0:n.credential)==="sealed"&&n.auth.type===k&&t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Saved. ",fe]});return t.jsxs("form",{ref:f,autoComplete:"off",onSubmit:Ve,"aria-label":n?`Change ${n.name}`:"Add an MCP server",className:"space-y-4 border bg-card p-4",onInput:fe=>{["mcp-name","mcp-toolkit"].includes(fe.target.name)||H(),J()},children:[!n&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("span",{className:"caps block text-small font-semibold",children:"Presets"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:rb.map(fe=>t.jsx(B,{type:"button",size:"sm",variant:(y==null?void 0:y.id)===fe.id?"solid":"outline","aria-pressed":(y==null?void 0:y.id)===fe.id,disabled:W||!i||!o&&fe.auth!=="none",onClick:()=>Oe(fe),children:fe.label},fe.id))}),!i&&t.jsx("p",{className:"text-small text-muted-foreground",children:"The presets wait for the saved servers to be read, so the name one picks is free."}),y&&t.jsx("p",{role:"note","data-mcp-preset":y.id,className:"text-small text-muted-foreground",children:y.note}),(y==null?void 0:y.readOnly)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(vd,{checked:b===y.readOnly,label:"Read-only",disabled:W,onChange:fe=>{j(fe?y.readOnly:y.url),H()}}),t.jsx("span",{className:"text-small text-muted-foreground",children:"Read-only: its address that lists only the read tools."})]}),t.jsx("p",{className:"caps pt-2 text-small font-semibold",children:"Or any MCP URL"})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",h.trim()||"<name>","/<tool>."]}),t.jsx(Pe,{name:"mcp-name",value:h,readOnly:!!n,onChange:fe=>x(fe.target.value),spellCheck:!1}),R&&t.jsxs("span",{role:"alert",className:"mt-1 block text-small text-destructive-text",children:[h.trim()," is saved already: saving would replace it. Change it from its row, or choose another name."]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Address"}),t.jsx(Pe,{name:"mcp-url",value:b,onChange:fe=>{j(fe.target.value),I!=null&&I.needsClient&&q(null)},placeholder:"https://mcp.example.com/mcp",spellCheck:!1})]}),t.jsxs("div",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Source"}),t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"What made it: GitHub App access is GitHub, the Composio preset is Composio, anything else is URL."}),t.jsx("span",{"data-mcp-source":$,className:"font-mono text-body",children:Ed[$]})]}),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:",L||"<toolkit>","/<tool>): applying one uses this server for them."]}),t.jsx(Pe,{name:"mcp-toolkit",value:$==="github"?"github":_,readOnly:$==="github",onChange:fe=>O(fe.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:OW.map(([fe,Le])=>t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"radio",name:"mcp-auth",value:fe,checked:k===fe,disabled:!o&&fe!=="none",onChange:()=>{E(fe),fe==="github_app"&&!b.trim()&&j(Vf),H()},className:"accent-primary"}),Le]},fe))})]}),k==="bearer"&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),ze("A new token replaces it; leave this empty to keep it."),t.jsx(Pe,{name:"mcp-token",...Tf})]}),k==="github_app"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Uses this server's GitHub App (Settings → GitHub): a token for the repository of each run is made when the run starts, and an agent never sees it. The address is GitHub's hosted MCP, the only one this credential goes to. Headers are optional."}),(k==="headers"||k==="github_app")&&t.jsxs("div",{className:"space-y-2",children:[ze(`Its headers: ${(Ne=n==null?void 0:n.auth.headers)==null?void 0:Ne.join(", ")}. New ones replace them all; leave the values empty to keep them.`),Array.from({length:S},(fe,Le)=>{var Ye;return t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Pe,{name:`mcp-header-name-${Le}`,"aria-label":`Header ${Le+1} name`,placeholder:"X-Api-Key",defaultValue:(Ye=n==null?void 0:n.auth.headers)==null?void 0:Ye[Le],spellCheck:!1}),t.jsx(Pe,{name:`mcp-header-value-${Le}`,"aria-label":`Header ${Le+1} value`,...Tf})]},Le)}),S<yW&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>N(fe=>fe+1),children:"Add header"})]}),k==="oauth"&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-small text-muted-foreground",children:"This server signs in for you and keeps the tokens; an agent never sees one. Sign in opens the server's own page to approve it, and its tools are saved once you do."}),((Q=n==null?void 0:n.oauth)==null?void 0:Q.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(Pe,{name:"mcp-scopes",placeholder:"read write",defaultValue:(be=n==null?void 0:n.oauth)==null?void 0:be.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:me?"Client ID (this server needs one)":"Client ID (optional)"}),t.jsx(Pe,{name:"mcp-client-id",spellCheck:!1})]}),o&&t.jsxs("label",{className:"block flex-1",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:me?"Client secret (if its app has one)":"Client secret (optional)"}),t.jsx(Pe,{name:"mcp-client-secret",...Tf})]})]})]}),I&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(yl,{problem:I}),I.signIn&&k!=="oauth"&&o&&t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:W||!A||!h.trim(),onClick:()=>void ve(),children:"Sign in"})]}),M&&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 ",M.protocol,(nt=M.server_info)!=null&&nt.name?` · ${M.server_info.name}${M.server_info.version?` ${M.server_info.version}`:""}`:""," · ",M.tools.length," tool",M.tools.length===1?"":"s"]}),M.instructions&&t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:M.instructions}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:MI}),t.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:M.tools.map(fe=>t.jsxs("li",{className:"px-3 py-2",children:[t.jsx("span",{className:"font-mono text-body",children:fe.name}),fe.title&&t.jsx("span",{className:"ml-2 text-small",children:fe.title}),fe.description&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:fe.description})]},fe.name))})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[k==="oauth"&&!o?null:k==="oauth"&&z?t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:W||!b.trim(),children:"Sign in again with these settings"}):k==="oauth"?t.jsx(B,{type:"button",size:"sm",variant:n?"outline":"primary",disabled:W||!A||!h.trim()||!b.trim(),onClick:()=>void ve(),children:n?"Sign in again":"Sign in"}):t.jsx(B,{type:"button",size:"sm",disabled:W||!b.trim(),onClick:je,children:"Preview"}),(k!=="oauth"||n&&!z)&&t.jsx(B,{type:"submit",size:"sm",variant:I!=null&&I.signIn&&k!=="oauth"&&o?"outline":"primary",disabled:!de,children:W?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{var fe;(fe=f.current)==null||fe.reset(),d()},children:"Cancel"})]})]})}const sN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function PW({v2:e,needs:n,model:s,onSaved:r,writable:o,whyNot:i="sign_in",plan:c,onPlan:d,onDone:u,harnesses:f}){const[g,y]=p.useState(null),[v,h]=p.useState(null),[x,b]=p.useState(null),[j,k]=p.useState(null),[E,S]=p.useState(c??null);p.useEffect(()=>{S(c??null)},[c]);const[N,$]=p.useState(!1),_=p.useRef(0),O=()=>{const K=++_.current;e.listToolKeys().then(U=>{K===_.current&&(y(U.keys.filter(H=>H.kind==="model")),h(null))}).catch(U=>{K===_.current&&h(sN(U))})};p.useEffect(()=>{n!=="model"&&O()},[e,n]);const L=s!=null&&s.includes("/")&&!Xc(s)?s.slice(0,s.indexOf("/")):void 0,P=g==null?void 0:g.find(K=>K.id===L),R=P?[P]:g,A=g==null?void 0:g.find(K=>K.id===x),M=(A==null?void 0:A.fields.filter(K=>{var U;return((U=A.secrets.find(H=>sm(H.name)===K.name))==null?void 0:U.source)!=="env"}))??[],F=!!E&&n!=="model"&&!L,I=n!=="model"&&(!F||N),q=K=>{S(K),d==null||d(K)},W=f&&t.jsx(cE,{harnesses:f});return F&&E.state==="signed_in"?t.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Da,{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(Ax,{v2:e,view:E,onView:q}),W,t.jsx(B,{type:"button",size:"sm",onClick:()=>u==null?void 0:u(),children:"Done"})]})]})}):t.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Da,{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":F?"Sign in with ChatGPT or add a model key to run agents":"Add a model key to run agents"}),n==="model"?t.jsx("p",{className:"text-body text-muted-foreground",children:"The server's AGENT_MODEL names a model it doesn't know, so an agent that names no model can't run. Set AGENT_MODEL to a provider/model-id where the server starts, or name a model in each agent."}):P?t.jsxs("p",{className:"text-body text-muted-foreground",children:["This server's default model is ",t.jsx("span",{className:"font-mono",children:s}),", and no ",P.label," key is set, so an agent that names no model can't run. Save the ",P.label," key: such an agent then runs on that model."]}):F?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(Ax,{v2:e,view:E,onView:q,writable:o,whyNot:i,beside:t.jsx(B,{type:"button",size:"sm","aria-expanded":N,onClick:()=>$(K=>!K),children:"Add a key"})}),t.jsx("p",{className:"text-body text-muted-foreground",children:dC}),N&&t.jsx("p",{className:"text-body text-muted-foreground",children:Dx})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"No model provider's key is set on this server, so an agent that names no model can't run. Save one: such an agent then runs on that provider's everyday model."}),t.jsx("p",{className:"text-body text-muted-foreground",children:Dx})]}),I&&v&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The keys could not be read: ",v.code,": ",v.message]}),t.jsx(B,{type:"button",onClick:O,size:"sm",className:"mt-2",children:"Try again"})]}),I&&g&&!o&&t.jsx("p",{className:"text-body",role:"status",children:oi[i]}),I&&g&&o&&t.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:R.map(K=>t.jsx(B,{size:"sm",variant:x===K.id?"solid":"primary","aria-pressed":x===K.id,onClick:()=>{b(x===K.id?null:K.id),k(null)},children:K.label},K.id))}),I&&A&&o&&(M.length?t.jsx(m$,{tool:A,fields:M,onCancel:()=>b(null),onSave:async K=>{k(null);try{await e.saveToolKey(A.id,K)}catch(U){return U instanceof Ue&&U.status===422?U:(k(sN(U)),null)}return b(null),O(),r==null||r(),null}},A.id):t.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",A.label," key when it starts: change it there."]})),j&&t.jsx("div",{className:"border",children:t.jsx(aa,{error:j,title:"The key was not saved"})}),W,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 IW({needs:e,settings:n,model:s,source:r,chatgpt:o=!1}){return t.jsx("p",{role:"status","aria-label":"No model",className:"border-b bg-card px-5 py-3 text-body text-warning-text md:px-8",children:e==="model"?"This server's default model doesn't run here: set AGENT_MODEL to a model it knows, and restart.":t.jsxs(t.Fragment,{children:["No model yet."," ",r==="gateway"?t.jsxs(t.Fragment,{children:["This server sends its models to a gateway: name the gateway's model in AGENT_MODEL where AgentRun starts, and restart",n?t.jsxs(t.Fragment,{children:[", or ",t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"add a model key in Settings → Model keys"})]}):null,"."]}):s?`This server's default model is ${s}: set its provider's key where AgentRun starts, and restart.`:o&&n?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"Continue with ChatGPT"})," in Settings → Model keys: Codex and pi agents run on your ChatGPT plan. Add a key there for the rest (one OpenRouter key gives every harness its model), and it takes effect at once."]}):n?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"Add a key in Settings → Model keys"})," (one OpenRouter key gives every harness its model), and it takes effect at once. Or set OPENROUTER_API_KEY, ANTHROPIC_API_KEY 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 rN=[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"icloud",label:"iCloud"},{value:"other",label:"Other"}],zW={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."})},DW="Outlook needs Microsoft sign-in, which this server doesn't do yet.";function FW(e){return e==="other"?"Password":"App password"}const UW={configured:!1,preset:null,address:null,user:null,imap:null,smtp:null,password_unreadable:!1},oN=e=>{var n,s,r,o;return{preset:(e==null?void 0:e.preset)??"gmail",address:(e==null?void 0:e.address)??"",user:e!=null&&e.user&&e.user!==e.address?e.user:"",imapHost:(e==null?void 0:e.preset)==="other"?((n=e.imap)==null?void 0:n.host)??"":"",imapPort:(e==null?void 0:e.preset)==="other"?String(((s=e.imap)==null?void 0:s.port)??""):"993",smtpHost:(e==null?void 0:e.preset)==="other"?((r=e.smtp)==null?void 0:r.host)??"":"",smtpPort:(e==null?void 0:e.preset)==="other"?String(((o=e.smtp)==null?void 0:o.port)??""):"465"}},aN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},WW=e=>Object.fromEntries((e instanceof Ue?e.fields??[]:[]).map(n=>[n.field,n.message]));function HW({v2:e,writable:n,whyNot:s="sign_in"}){var H;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(oN(null)),[f,g]=p.useState(""),[y,v]=p.useState(null),[h,x]=p.useState({}),[b,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),$=p.useRef(0),_=G=>{o(G),u(oN(G))},O=()=>{const G=++$.current;e.emailAccount().then(z=>{G===$.current&&(_(z),c(null))}).catch(z=>{G===$.current&&c(aN(z))})};p.useEffect(()=>{n&&O()},[e,n]);const L=G=>{u(G),j(null)},P=G=>z=>L(V=>({...V,[G]:z.target.value})),R=()=>{const G=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(),...G?{user:G}:{},...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}},A=async(G,z)=>{v(null),x({}),N(!0);try{await z()}catch(V){const se=WW(V);Object.keys(se).length?x(se):v({title:G,error:aN(V)})}finally{N(!1)}},M=G=>{G.preventDefault(),A("The account was not saved",async()=>{_(await e.saveEmailAccount(R())),g(""),j(null)})},F=()=>A("The account was not tested",async()=>{j(null),j(await e.testEmailAccount(R()))}),I=()=>A("The account was not removed",async()=>{E(!1),await e.removeEmailAccount(),_(UW),g(""),j(null)}),q=t.jsxs("div",{className:ai,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:Vo,children:[q,t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:oi[s]})]})});if(!r)return i?t.jsx(bt,{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 W=r.configured||r.password_unreadable,K=d.preset==="other",U=(G,z,V)=>t.jsxs("div",{className:"grid grid-cols-[1fr_7rem] gap-2",children:[t.jsx(xt,{label:`${z} server`,error:h[`${G}.host`],children:t.jsx(Pe,{name:`${G}_host`,value:G==="imap"?d.imapHost:d.smtpHost,onChange:P(G==="imap"?"imapHost":"smtpHost"),placeholder:V,spellCheck:!1,autoCapitalize:"off"})}),t.jsx(xt,{label:"Port",error:h[`${G}.port`],children:t.jsx(Pe,{name:`${G}_port`,inputMode:"numeric",value:G==="imap"?d.imapPort:d.smtpPort,onChange:P(G==="imap"?"imapPort":"smtpPort")})})]});return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Vo,children:[q,t.jsxs("div",{className:ii,children:[y&&t.jsx(aa,{error:y.error,title:y.title}),i&&t.jsx(bt,{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(Or,{title:"Account",children:[t.jsxs("section",{className:"border bg-card p-4","aria-label":"Email account",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(nR,{className:"size-4 text-muted-foreground","aria-hidden":!0}),W?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(Se,{tone:"success",children:"saved"}),W&&r.preset&&t.jsx(Se,{children:((H=rN.find(G=>G.value===r.preset))==null?void 0:H.label)??r.preset})]}),W&&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(Ks,{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:M,children:[t.jsxs("fieldset",{disabled:S,className:"min-w-0 space-y-4",children:[t.jsx(xt,{label:"Provider",group:"heading",note:DW,error:h.preset,children:t.jsx(xd,{name:"email-preset",label:"Provider",value:d.preset,onChange:G=>L(z=>({...z,preset:G})),options:rN})}),t.jsx("p",{className:"text-small text-muted-foreground",children:zW[d.preset]}),t.jsx(xt,{label:"Address",error:h.address,children:t.jsx(Pe,{name:"address",inputMode:"email",autoComplete:"username",spellCheck:!1,autoCapitalize:"off",placeholder:"you@example.com",value:d.address,onChange:P("address")})}),t.jsx(xt,{label:"Sign-in name",optional:!0,note:"When the server's sign-in isn't the address.",error:h.user,children:t.jsx(Pe,{name:"user",spellCheck:!1,autoCapitalize:"off",value:d.user,onChange:P("user")})}),t.jsx(xt,{label:FW(d.preset),error:h.password,children:t.jsx(Pe,{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:G=>{g(G.target.value),j(null)}})}),K&&U("imap","IMAP","imap.example.com"),K&&U("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 F(),children:"Test"}),W&&!k&&t.jsx(B,{type:"button",variant:"outline",disabled:S,onClick:()=>E(!0),children:"Remove"})]}),k&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-body",children:[t.jsx("span",{children:"The agents' email tools and email triggers stop until an account is saved again."}),t.jsx(B,{type:"button",variant:"destructive",disabled:S,onClick:()=>void I(),children:"Remove the account"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>E(!1),children:"Cancel"})]}),b&&t.jsxs("div",{"aria-label":"Test",className:"space-y-1 font-mono text-body",children:[["imap","smtp"].map(G=>t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Se,{tone:b[G].ok?"success":"error",children:G==="imap"?"IMAP":"SMTP"}),t.jsx("span",{className:b[G].ok?"":"text-destructive-text",children:b[G].message})]},G)),t.jsx("p",{className:"text-small text-muted-foreground",children:b.ok?"Both signed in. Nothing was sent, and nothing was saved by the test.":"Nothing was sent, and nothing was saved by the test."})]})]})]})]})]})})}const iN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},BW={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 GW({v2:e}){const[n,s]=p.useState(null),[r,o]=p.useState([]),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(!1),[b,j]=p.useState(!1),[k,E]=p.useState(""),S=p.useRef(0),N=()=>{const O=++S.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([L,P])=>{O===S.current&&(s(L),o(P.attempts),c(null))}).catch(L=>{O===S.current&&c(iN(L))})};p.useEffect(N,[e]);const $=async(O,L)=>{g(null),j(!0);try{await L()}catch(P){g({title:O,error:iN(P)})}finally{j(!1)}N()},_=O=>{O.preventDefault(),$("The webhook was not saved",async()=>{const L=await e.saveWebhook(k.trim());L.signing_secret&&u(L.signing_secret);const{signing_secret:P,...R}=L;s(R)})};return n?t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Vo,children:[t.jsxs("div",{className:ai,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Webhook"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"One URL this server POSTs to when a run needs its person (`run.needs_input`) and when it ends (`run.ended`), signed by the Standard Webhooks spec, so a receiver checks each message with any of that spec's libraries."})]}),t.jsxs("div",{className:ii,children:[f&&t.jsx(aa,{error:f.error,title:f.title}),i&&t.jsx(bt,{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.jsx(Or,{title:"Endpoint",children:t.jsxs("section",{className:"border bg-card p-4","aria-label":"Webhook URL",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ll,{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(Se,{tone:"error",children:"off"}):n.signing==="sealed"?t.jsx(Se,{tone:"success",children:"on"}):t.jsx(Se,{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,", ",ft(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(Ks,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),BW[n.signing]]}),t.jsxs("form",{className:"mt-4 flex flex-wrap gap-2",onSubmit:_,children:[t.jsx(Pe,{name:"url",type:"url",required:!0,maxLength:2048,placeholder:n.configured?"The whole URL, to change it or save it again":"https://...",value:k,onChange:O=>E(O.target.value),className:"h-9 min-w-[280px] flex-1","aria-label":"Webhook URL"}),t.jsx(B,{type:"submit",variant:"solid",disabled:b||!k.trim(),children:"Save"}),n.configured&&t.jsx(B,{type:"button",variant:"outline",disabled:b,onClick:()=>$("The test was not sent",async()=>v(await e.testWebhook())),children:"Send a test"}),n.configured&&!h&&t.jsx(B,{type:"button",variant:"outline",disabled:b,onClick:()=>x(!0),children:"Remove"})]}),h&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-body",children:[t.jsx("span",{children:"Its pending messages are dropped; the log of attempts stays."}),t.jsx(B,{type:"button",variant:"destructive",disabled:b,onClick:()=>{x(!1),E(""),v(null),$("The webhook was not removed",async()=>{await e.removeWebhook(),s({configured:!1,secret:{name:"webhook:outbound",set:!1,source:null,changed_at:null}}),u(null)})},children:"Remove the webhook"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>x(!1),children:"Cancel"})]}),y&&t.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",lN(y)]})]})}),t.jsx(Or,{label:"Deliveries",title:"Last deliveries",aside:t.jsx(B,{type:"button",size:"sm",onClick:N,children:"Refresh"}),children:r.length===0?t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:"No message has been tried yet."}):t.jsx("ul",{className:"border",children:r.map((O,L)=>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:ft(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:lN(O)}),O.redelivery&&t.jsx(Se,{children:"redelivery"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:O.webhook_id,children:[O.webhook_id.slice(0,12),"…"]}),t.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:b,onClick:()=>$("The message was not sent again",()=>e.redeliverWebhook(O.webhook_id)),children:"Redeliver"})]},`${O.webhook_id}:${O.at}:${L}`))})})]})]})}):i?t.jsx(bt,{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 lN(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 ${ft(e.retry_at)}`:""}`}const qW={none:{label:"None",gives:"The run's folder only."},sandbox:{label:"Sandbox",gives:"A Linux container."},desktop:{label:"Desktop",gives:"A screen, with a pointer and keys."},phone:{label:"Phone",gives:"A phone's screen and its apps."},browser:{label:"Browser",gives:"A browser the agent drives."}},Fx=e=>qW[e]??{label:e,gives:""},KW=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},Ux=e=>e.slice(e.lastIndexOf(":")+1),VW=e=>e.secrets.some(n=>n.set)&&e.required.every(n=>e.secrets.some(s=>s.name===n&&s.set)),YW=2e3;function QW({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(null),[y,v]=p.useState({}),[h,x]=p.useState(new Set),b=p.useRef(0),j=p.useRef({}),k=p.useCallback(()=>{const _=++b.current;c(null),e.computers().then(O=>{_===b.current&&o(O)},O=>{_===b.current&&c(KW(O))})},[e]);if(p.useEffect(k,[k]),!r)return i?t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The computers could not be read: ",i.code,": ",i.message]}),t.jsx(B,{size:"sm",onClick:k,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Hn,{label:"Loading the computers",rows:3})});const E=new Set(r.paired.map(_=>_.id)),S=_=>r.kinds.filter(O=>O.providers.some(L=>L.id===_)).map(O=>O.kind),N=async(_,O,L)=>{g(null);try{await e.saveComputerKeys(O.id,L)}catch(P){return P instanceof Ue&&P.status===422?P:(g({at:_,words:Wt(P)}),null)}return u(null),j.current[O.id]=(j.current[O.id]??0)+1,v(P=>{const R={...P};return delete R[O.id],R}),k(),null},$=async _=>{const O=j.current[_.id]??0;x(P=>new Set(P).add(_.id));let L;try{const P=await e.testComputer(_.id);L=P.ok?{ok:!0,words:P.detail,at:new Date().toISOString()}:{ok:!1,words:P.why,at:new Date().toISOString()}}catch(P){L={ok:!1,words:Wt(P),at:new Date().toISOString()}}(j.current[_.id]??0)===O&&v(P=>({...P,[_.id]:L})),x(P=>{const R=new Set(P);return R.delete(_.id),R})};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Vo,children:[t.jsxs("div",{className:ai,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Computers"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The computers an agent can be given, and who provides them. An agent can have a kind once one of its providers is ready. Keys are kept sealed on this server and never shown again."})]}),t.jsxs("div",{className:ii,children:[t.jsx(ZW,{v2:e,paired:r.paired,reload:k}),!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:oi[s]}),r.kinds.map(_=>t.jsx(e9,{kind:_,providers:_.providers.filter(O=>!E.has(O.id)),own:_.providers.filter(O=>E.has(O.id)).map(O=>O.name),children:_.providers.filter(O=>!E.has(O.id)).map(O=>{const L=`${_.kind}/${O.id}`;return t.jsx(t9,{v2:e,kind:_.kind,provider:O,writable:n,serves:S(O.id),tested:y[O.id],testing:h.has(O.id),open:(d==null?void 0:d.at)===L?d.mode:null,problem:(f==null?void 0:f.at)===L?f.words:null,onOpen:P=>{u(P?{at:L,mode:P}:null),g(null)},onSave:P=>N(L,O,P),onRemove:async P=>{var A;const R=await N(L,O,{[P]:null});R&&g({at:L,words:((A=R.fields)==null?void 0:A.map(M=>M.message).join(" "))||R.message})},onTest:()=>void $(O)},O.id)})},_.kind))]})]})})}function JW(e){const n=e.device?`${e.device.maker} ${e.device.model}`:null,s=e.os_version?`${e.os} ${e.os_version}`:e.os,r=e.screen?`screen ${e.screen.width}×${e.screen.height} at ${e.screen.scale}x`:null;return[e.serves.map(o=>Fx(o).label).join(", ")||Fx(e.kind).label,n,s,e.arch,r].filter(Boolean).join(" · ")}function XW(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 ZW({v2:e,paired:n,reload:s}){const[r,o]=p.useState(null),[i,c]=p.useState(!1),[d,u]=p.useState(()=>Date.now()),[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(null),b=r?Date.parse(r.code.expires_at)-d:0,j=r!==null&&b>0;p.useEffect(()=>{if(!j)return;const N=setInterval(()=>u(Date.now()),1e3),$=setInterval(s,YW);return()=>{clearInterval(N),clearInterval($)}},[j,s]),p.useEffect(()=>{if(!r)return;const N=n.find($=>$.pairing===r.code.id);N&&(g(N.name),o(null))},[n,r]);const k=async()=>{c(!0),x(null),g(null);try{const N=await e.createPairing();u(Date.now()),o({code:N})}catch(N){x(Wt(N))}c(!1)},E=async N=>{x(null);try{await e.removeComputer(N)}catch($){x(Wt($));return}v(null),s()},S=`${Math.floor(Math.max(0,b)/6e4)}:${String(Math.floor(Math.max(0,b)%6e4/1e3)).padStart(2,"0")}`;return t.jsxs(Or,{label:"Your computers",title:"Your computers",note:t.jsx("p",{children:"A computer or phone of your own, attached by the driver you run on it. An agent can be given it as its computer."}),aside:!r&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void k(),disabled:i,children:i?"Making…":"Pair a computer"}),f&&t.jsxs("p",{role:"status",className:"text-body text-success-text",children:["Paired ",f,"."]})]}),children:[r&&t.jsxs("div",{"data-pairing":!0,className:"space-y-3 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Server address"}),t.jsx("p",{"data-address":!0,className:"mt-1 font-mono text-prose font-semibold",children:window.location.origin})]}),t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Pairing code"}),t.jsx("p",{"data-code":!0,className:"mt-1 font-mono text-2xl font-semibold",children:r.code.code})]})]}),j?t.jsxs("p",{className:"text-body",children:["Type both into the driver on the computer. The code pairs one computer, once, in the next ",t.jsx("span",{"data-countdown":!0,className:"font-mono",children: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:()=>o(null),children:"Done"})]})]}),h&&t.jsx("p",{role:"alert",className:"border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:h}),n.length?t.jsx("ul",{className:"border",children:n.map(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(JN,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}):t.jsx(ei,{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(Se,{tone:"success",children:"Online"}):t.jsx(Se,{tone:"muted",children:"Offline"}),N.held_by_run&&t.jsxs(Se,{tone:"active",children:["In use by run ",sa(N.held_by_run)]}),N.unserved&&t.jsx(Se,{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 ",ft(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:JW(N)}),N.groups.length>0&&t.jsx("p",{"data-offers":!0,className:"mt-1 text-small text-muted-foreground",children:XW(N)}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:`Driver ${N.driver} · paired ${ft(N.created_at)}${N.seen_at?` · last attached ${ft(N.seen_at)}`:""}`})]}),t.jsx(B,{size:"sm",onClick:()=>{v(N.id),x(null)},disabled:y!==null,children:"Remove"})]}),y===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 E(N.id),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>v(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 e9({kind:e,providers:n,own:s,children:r}){const{label:o,gives:i}=Fx(e.kind);return t.jsx(Or,{label:o,title:o,note:(i||!e.offered||s.length>0)&&t.jsxs(t.Fragment,{children:[i&&t.jsx("p",{children:i}),!e.offered&&t.jsx("p",{children:t.jsx(Se,{tone:"muted",children:"Not offered here"})}),!e.offered&&e.why&&t.jsx("p",{className:"font-mono text-small",children:e.why}),s.length>0&&t.jsxs("p",{className:"text-small",children:["Also served by your computers: ",s.join(", "),"."]})]}),children:n.length?t.jsx("ul",{className:"border",children:r}):t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:e.kind==="none"?"Nothing to set up.":s.length?"No other provider serves it on this server.":"No provider serves it on this server."})})}function t9({v2:e,kind:n,provider:s,writable:r,serves:o,tested:i,testing:c,open:d,problem:u,onOpen:f,onSave:g,onRemove:y,onTest:v}){const h=p.useRef(null),x=d&&"paste"in d?d.paste:null,b=d&&"remove"in d?d.remove:null,j=VW(s);return t.jsxs("li",{ref:h,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(ei,{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(Se,{tone:"success",children:"Ready"}):t.jsx(Se,{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&&vb.has(n)&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:xb}),s.secrets.length>0&&t.jsx("ul",{className:"mt-3 space-y-1.5",children:s.secrets.map(k=>{var N;const E=Ux(k.name),S=((N=s.picked)==null?void 0:N.includes(k.name))??!1;return t.jsx(hh,{field:k,required:s.required.includes(k.name),writable:r&&!d,actionsInline:!0,onPaste:S?void 0:()=>void mh(()=>f({paste:E}),()=>{var $,_;return(_=($=h.current)==null?void 0:$.querySelector("form"))==null?void 0:_.elements.namedItem(E)}),onRemove:()=>f({remove:E})},k.name)})}),s.picked&&s.picked.length>0&&s.required.every(k=>s.secrets.some(E=>E.name===k&&E.set))&&t.jsx(n9,{v2:e,provider:s,writable:r&&!d,onSave:g}),j&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsx(B,{size:"sm",onClick:v,disabled:c,children:c?"Testing…":"Test connection"}),i&&t.jsx("p",{"data-test":!0,className:`text-small ${i.ok?"text-success-text":"text-destructive-text"}`,children:`${i.ok?"Passed":"Failed"} · ${qa(i.at)} · ${i.words}`})]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:[s.secrets.length?"":"No key. ","Serves: ",o.join(", ")]})]})]}),r&&x&&t.jsx(s9,{provider:s.name,name:x,set:s.secrets.some(k=>Ux(k.name)===x&&k.set),onSave:g,onCancel:()=>f(null)}),r&&b&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",b," saved on this server?"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void y(b),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>f(null),children:"Cancel"})]}),u&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:u})]})}function n9({v2:e,provider:n,writable:s,onSave:r}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(null),g=n.secrets.map(v=>`${v.name}:${v.set}:${v.changed_at??""}`).join(" ");p.useEffect(()=>{let v=!0;return i(null),d(null),e.computerChoices(n.id).then(h=>{v&&i(h)},h=>{v&&d(Wt(h))}),()=>{v=!1}},[e,n.id,g]);const y=async(v,h)=>{var b;f({key:v.key,value:h}),d(null);const x=await r({[v.key]:h});f(null),x&&d(((b=x.fields)==null?void 0:b.map(j=>j.message).join(" "))||x.message)};return c&&!o?t.jsx("p",{role:"alert",className:"mt-3 font-mono text-small text-destructive-text",children:`The choices could not be read: ${c}`}):o?t.jsxs("div",{className:"mt-3 space-y-3",children:[o.choices.map(v=>{const h=n.secrets.find(b=>Ux(b.name)===v.key),x=(h==null?void 0:h.source)==="env";return t.jsxs("div",{"data-choices":v.key,className:"border bg-card p-3",children:[t.jsx("p",{className:"caps mb-2 text-small font-semibold",children:v.key}),"why"in v?t.jsx("p",{"data-why":!0,className:"font-mono text-small text-warning-text",children:v.why}):t.jsxs(t.Fragment,{children:[t.jsx(Et,{label:`${n.name} ${v.key}`,value:(u==null?void 0:u.key)===v.key?u.value:v.saved??"",disabled:!s||x||u!==null,options:v.options.map(b=>({value:b.value,label:b.label})),placeholder:"Pick one",onChange:b=>void y(v,b),className:"w-full max-w-md"}),t.jsx("p",{"data-choice-note":!0,className:`mt-2 text-small ${h!=null&&h.set&&v.saved===void 0?"text-warning-text":"text-muted-foreground"}`,children:x?`Set in the environment where AgentRun starts, and that one is used: change ${v.key} there.`:v.saved!==void 0?"Picked and saved on this server.":h!=null&&h.set?`The ${v.key} saved on this server is not one of these any more, and runs still ask for it: pick one.`:v.options.length===1?`The only one, ${v.options[0].label}, is used while none is picked.`:`${v.options.length} to pick from. Pick the one this server's computers use.`})]})]},v.key)}),c&&t.jsx("p",{role:"alert",className:"font-mono text-small text-destructive-text",children:c})]}):t.jsx("p",{role:"status",className:"mt-3 text-small text-muted-foreground",children:"Reading the choices…"})}function s9({provider:e,name:n,set:s,onSave:r,onCancel:o}){const i=p.useRef(null),[c,d]=p.useState(!1),[u,f]=p.useState(!1),[g,y]=p.useState(null),v=()=>{var b,j;return((j=(b=i.current)==null?void 0:b.elements.namedItem(n))==null?void 0:j.value)??""},h=()=>{var b;(b=i.current)==null||b.reset(),d(!1)},x=async b=>{var N;b.preventDefault();const j=v();if(!j)return;f(!0),y(null);const k=await r({[n]:j});if(f(!1),!k){h();return}const E=(N=k.fields)==null?void 0:N.find($=>$.field===n),S=(k.fields??[]).filter($=>$.field!==n).map($=>$.message);y(E?{field:E.message,message:S.join(" ")}:{field:null,message:S.join(" ")||k.message})};return t.jsxs("form",{ref:i,autoComplete:"off",onSubmit:b=>void x(b),onInput:()=>d(!!v()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e} ${n}`,children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:n}),s&&t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"A new value replaces the one saved."}),t.jsx(Pe,{type:"password",name:n,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(g==null?void 0:g.field)&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:g.field})]}),(g==null?void 0:g.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:g.message}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Kept sealed on this server. It is never shown again, here or anywhere."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!c||u,children:u?"Saving":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{h(),o()},children:"Cancel"})]})]})}const r9="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.",cN=[{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)"}],o9=e=>({region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),kr="ARCHIL_API_KEY",a9=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function i9({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState({region:"",s3Url:"",image:""}),[f,g]=p.useState(null),[y,v]=p.useState(null),[h,x]=p.useState(!1),[b,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),[$,_]=p.useState(!1),[O,L]=p.useState(!1),P=p.useRef(null),R=p.useRef(0),A=p.useCallback(U=>{o(U),u(o9(U))},[]),M=p.useCallback(()=>{const U=++R.current;c(null),e.archil().then(H=>{U===R.current&&A(H)},H=>{U===R.current&&c(a9(H))})},[e,A]);if(p.useEffect(M,[M]),!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:M,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Hn,{label:"Loading Archil's settings",rows:2})});const F=()=>{var U,H;return((H=(U=P.current)==null?void 0:U.elements.namedItem(kr))==null?void 0:H.value)??""},I=async U=>{const H={region:d.region,s3Url:d.s3Url,...d.image?{image:d.image}:{},...U!==void 0?{keys:{[kr]:U}}:{}};x(!0),g(null),v(null);try{const G=await e.saveArchil(H);_(!1),L(!1),A(G)}catch(G){if(G instanceof Ue&&G.status===422){const z={},V=[];for(const se of G.fields??[]){const J=se.field.startsWith("keys.")?se.field.slice(5):se.field;cN.some(re=>re.name===J)||J===kr?z[J]=se.message:V.push(se.message)}g({fields:z,message:V.length?V.join(" "):Object.keys(z).length?null:G.message})}else v(Wt(G))}finally{x(!1)}},q=U=>{U.preventDefault(),I($&&F()?F():void 0)},W=async()=>{E(!0);try{const U=await e.testArchil();j(U.ok?{ok:!0,words:U.detail,at:new Date().toISOString()}:{ok:!1,words:U.why,at:new Date().toISOString()})}catch(U){j({ok:!1,words:Wt(U),at:new Date().toISOString()})}finally{E(!1)}},K=async()=>{v(null);try{A(await e.archilOff()),N(!1)}catch(U){v(Wt(U))}};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Vo,children:[t.jsxs("div",{className:ai,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:r9})]}),t.jsxs("div",{className:ii,children:[!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:oi[s]}),t.jsx(Or,{title:"Disk",children:t.jsxs("section",{"aria-label":"Archil",className:"border p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(JT,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"font-mono text-prose font-semibold",children:"Archil"}),t.jsx("span",{"data-archil-state":!0,children:r.on?t.jsx(Se,{tone:"success",children:"On"}):t.jsx(Se,{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 W(),disabled:k,children:k?"Testing…":"Test"}),r.on&&t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Turn off"})]}),b&&t.jsx("p",{"data-test":!0,className:`mt-3 text-small ${b.ok?"text-success-text":"text-destructive-text"}`,children:`${b.ok?"Passed":"Failed"} · ${qa(b.at)} · ${b.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 K(),children:"Turn off"}),t.jsx(B,{size:"sm",onClick:()=>N(!1),children:"Cancel"})]}),y&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:y}),t.jsxs("form",{ref:P,autoComplete:"off",onSubmit:q,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[cN.map(U=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:U.label}),t.jsx(Pe,{name:U.name,value:d[U.name],placeholder:U.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:H=>{const G=H.currentTarget.value;u(z=>({...z,[U.name]:G}))}}),(f==null?void 0:f.fields[U.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[U.name]})]},U.name)),t.jsx("ul",{children:t.jsx(hh,{field:r.secret,label:kr,writable:n&&!$&&!O,onPaste:()=>void mh(()=>_(!0),()=>{var U;return(U=P.current)==null?void 0:U.elements.namedItem(kr)}),onRemove:()=>L(!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 ",kr," saved on this server?"]}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:()=>void I(null),children:"Remove"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>L(!1),children:"Cancel"})]}),n&&$&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:kr}),t.jsx(Pe,{type:"password",name:kr,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(f==null?void 0:f.fields[kr])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[kr]})]}),n&&$&&t.jsx(B,{type:"button",size:"sm",onClick:()=>_(!1),children:"Cancel"}),(f==null?void 0:f.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f.message}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:h,children:h?"Saving":r.on?"Save":"Turn on"})]})]})})]})]})})}const x$="tool_approval_requested";function l9(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 c9(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 ${so(e)} per call`:null}function d9(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(`
|
|
701
|
-
`)}const u9={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 v$(e){var n;if(e instanceof Ue){const s=((n=e.details)==null?void 0:n.reason)==="already_answered"&&typeof e.details.decision=="string"?u9[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 Wt(e)}const f9=2e3;function b$({pending:e,onAnswer:n,compact:s=!1,heading:r}){const[o,i]=p.useState(""),[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,y]=p.useState(null),[v,h]=p.useState(!1),x=e.destructive===!0,b=p.useRef(!1),j=p.useRef(null),k=p.useRef(!1);p.useEffect(()=>{var N;v||!k.current||(k.current=!1,(N=j.current)==null||N.focus())},[v]);const E=c9(e.price),S=async(N,$)=>{if(b.current)return;b.current=!0,d(!0),f(null),h(!1);const _=o.trim(),O=await($?n(N,void 0,$):n(N,N==="deny"&&_?_:void 0));b.current=!1,d(!1),O?f(O):y(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(QN,{className:"size-3.5","aria-hidden":!0})," Approval required"]}),t.jsxs("p",{className:"mt-2 text-prose leading-snug",children:["The agent wants to run ",t.jsx("span",{className:"break-all font-mono text-lead",children:e.tool}),".",x&&t.jsxs(t.Fragment,{children:[" ",t.jsx(Se,{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:d9(e.args_preview)}),E&&t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:E}),g?t.jsx("p",{className:"mt-3 font-mono text-body text-success-text",role:"status",children:g==="allow"?"Allowed. The run goes on.":"Denied. The agent reads why and goes on."}):t.jsxs("div",{className:"mt-3 space-y-2",children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-small text-muted-foreground",children:"Tell the agent why (optional, sent with Deny)"}),t.jsx(nn,{value:o,onChange:N=>i(N.target.value),maxLength:f9,rows:s?1:2,disabled:c,className:"mt-1 block resize-y py-2 font-sans text-lead"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{ref:j,type:"button",variant:"solid",size:"sm",disabled:c||v,onClick:()=>x?h(!0):void 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…"})]}),v&&t.jsx(m9,{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 m9({tool:e,onAllow:n,onBack:s}){const r=p.useRef(null);return p.useEffect(()=>{var o;(o=r.current)==null||o.focus()},[]),t.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e}?`,onKeyDown:o=>{o.key==="Escape"&&(o.stopPropagation(),s())},className:"flex flex-wrap items-center gap-3 border border-destructive/50 bg-card px-3 py-2.5",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Allow a destructive call?"})," Its server marks ",t.jsx("span",{className:"break-all font-mono",children:e})," as one that may delete or overwrite."]}),t.jsx(B,{ref:r,type:"button",size:"sm",variant:"ghost",onClick:s,children:"Back"}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:n,children:"Allow this destructive call"})]})}const h9={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 p9({mode:e,onSend:n,sending:s,sent:r,purpose:o}){const i=o??h9[e],[c,d]=p.useState(""),[u,f]=p.useState(!1),g=s||u,y=async()=>{if(!c.trim()||!n||g)return;f(!0);const v=await n(c.trim());f(!1),v!==!1&&d("")};return t.jsxs("form",{className:"border bg-card focus-within:border-foreground",onSubmit:v=>{v.preventDefault(),y()},children:[t.jsx(nn,{bare:!0,id:"composer",rows:2,value:c,readOnly:g,"aria-busy":g,onChange:v=>d(v.target.value),placeholder:i.placeholder,onKeyDown:v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),y())},className:"block w-full resize-none px-4 pt-3"}),t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 pb-3",children:[t.jsxs("span",{className:"min-w-0 text-label text-muted-foreground",children:[t.jsx("label",{htmlFor:"composer",className:"font-semibold text-foreground",children:i.label})," · ",r?"Sent. It appears on the timeline when the run takes it.":i.does]}),t.jsxs(B,{type:"submit",size:"sm",disabled:!c.trim()||!n||g,children:[g?"Sending":"Send"," ",t.jsx(GT,{"aria-hidden":!0})]})]})]})}function Zr(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 y$=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${Zr(e.cap_usd)} `:""}spend cap`;function g9({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(Xx,{className:"size-3.5","aria-hidden":!0})," ",y$(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 w$=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,j$=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function x9(e){var n,s;return e instanceof Ue?e.status===422?((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message:e.status===409?"This run has ended, so its cap can't be raised.":e.status===404?"This run is no longer on the server.":e.message:e instanceof Error?e.message:String(e)}function k$({cap:e,suggested:n,least:s=null,paused:r,onRaise:o}){const[i,c]=p.useState(n===null?"":String(n)),[d,u]=p.useState(!1),[f,g]=p.useState(null),[y,v]=p.useState(null),h=p.useRef(!1),x=Number(i),b=i.trim()!==""&&Number.isFinite(x)&&x>0,j=async k=>{if(k==null||k.preventDefault(),!(!b||h.current)){h.current=!0,u(!0),g(null),v(null);try{const E=await o(x);E.note&&v(E.note)}catch(E){g(x9(E))}finally{h.current=!1,u(!1)}}};return t.jsxs("form",{className:"border border-warning/50 p-4","aria-label":"Raise the cap",onSubmit:k=>void j(k),children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("label",{className:"flex items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"text-muted-foreground",children:"$"}),t.jsx(Pe,{"aria-label":"New cap in dollars",inputMode:"decimal",value:i,onChange:k=>c(k.target.value),disabled:d,placeholder:`more than ${Zr(e)}`,className:"h-9 w-32"})]}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:d||!b,children:d?"Raising":r?"Raise the cap and continue":"Raise the cap"})]}),(s!==null||n!==null)&&t.jsxs("ul",{className:"mt-2 space-y-0.5 font-mono text-small","aria-label":"Cap figures",children:[s!==null&&t.jsxs("li",{"data-cap-figure":"least",children:["Least to continue: ",Zr(s)]}),n!==null&&t.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",Zr(n)]})]}),n!==null&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The suggestion is prefilled; change it before you raise, if you like."}),f&&t.jsx("p",{className:"mt-2 text-body text-destructive-text",role:"alert",children:f}),y&&t.jsx("p",{className:"mt-2 text-body text-muted-foreground",role:"status",children:y})]})}function v9({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(ev,{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(il,{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 ol=0;const Wx=()=>{var n;const e=(n=history.state)==null?void 0:n.console_at;return typeof e=="number"?e:void 0},dN=e=>{ol=e,history.replaceState({...history.state??{},console_at:e},"")};function b9(){const e=Wx();e===void 0?dN(0):ol=e;const n=()=>{const s=Wx();s===void 0?dN(ol+1):ol=s};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)}function y9(){const e=Wx();return e===void 0?-1:ol-e}function w9(e){ol>0?history.back():location.hash=e}const j9=(e,n)=>{const s=_l(e),r=yd(e)?uC:void 0;return s?r?`${kk(s,{ended:n})} ${r}`:kk(s,{ended:n}):e&&e.usd!==null&&f2(e)?r?`A local estimate, not a bill. ${r}`:"A local estimate, not a bill":r};function k9({run:e,agentName:n,actions:s={},costText:r}){var E,S,N;const o=ns(e),i=o?"your backend":gP(e.place),c=qm(e.status,e.state,e.kind,Gm,!0,e.error,e.review,e.computer),d=o?{...c,canStop:!1,canCancel:!1}:c,[u,f]=p.useState(!1),g=!!e.archived_at,y=(E=e.cost)==null?void 0:E.cap_usd,v=!!e.pending&&e.pending.kind!=="budget"&&e.pending.kind!=="stopped",h=!o&&!!s.onRaiseCap&&!d.final&&typeof y=="number"&&!v,[x,b]=p.useState(!1),j=((S=e.pending)==null?void 0:S.kind)==="budget"?e.pending:null,k=!!yd(e.cost);return t.jsxs("header",{children:[t.jsxs("nav",{className:ae(pr,"caps min-w-0 gap-2 px-5 text-label text-muted-foreground md:px-8"),"aria-label":"Breadcrumb",children:[t.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:()=>w9(dn(e.agent_id)),className:"-m-1.5 shrink-0 p-1.5 hover:text-foreground",children:t.jsx(On,{className:"size-3.5","aria-hidden":!0})}),t.jsx("a",{href:dn(e.agent_id),className:"-my-1 truncate py-1 hover:text-foreground hover:underline",children:n}),t.jsx("span",{"aria-hidden":!0,children:"/"}),t.jsxs("span",{className:"truncate",children:["Run ",sa(e.run_id)]})]}),t.jsxs("div",{"data-title-block":!0,className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[t.jsxs("div",{"data-phone-row":!0,className:"flex flex-col items-start gap-x-6 gap-y-3 max-sm:mt-2 max-sm:flex-row max-sm:flex-wrap max-sm:items-center max-sm:gap-x-3 max-sm:gap-y-2 sm:flex-row sm:flex-wrap",children:[t.jsxs("div",{className:"min-w-0 flex-1 self-stretch max-sm:contents sm:basis-64",children:[t.jsx("h1",{className:"line-clamp-2 break-words text-2xl font-semibold leading-tight max-sm:basis-full max-sm:text-lg",title:En(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?n:En(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(Al,{run:e}),g&&t.jsx(Se,{tone:"muted",children:"Archived"}),e.approvals==="never"&&t.jsx(Se,{tone:"warning",title:"This run's agent never asks: no call of it waits for you.",children:"Unattended"}),t.jsxs("span",{className:"font-mono",children:[e.kind," · rev ",e.agent_version,i&&` · ${i}`]}),o&&t.jsxs("span",{className:"font-mono",children:[Qo(o.runtime)," · ",((N=e.sdk)==null?void 0:N.model)??"Model not reported"]}),t.jsx("span",{className:"font-mono",children:ft(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:Nk(e.cost,y,{text:r})}):t.jsxs("span",{className:"font-mono",title:j9(e.cost,Va(e.status)),children:[Nk(e.cost,y,{ended:Va(e.status)}),k&&t.jsxs(t.Fragment,{children:[" · ",t.jsx(yb,{})]})]}),t.jsx(hb,{run:e,link:!0}),t.jsx(d$,{run:e})]}),e.status==="completed"&&e.review&&t.jsxs("p",{className:"mt-2 text-body text-warning-text max-sm:mt-0 max-sm:basis-full",children:["Needs review: ",e.review.reason]})]}),(d.canStop||d.canCancel||s.onArchive||h)&&t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[h&&t.jsxs(B,{size:"sm",onClick:()=>b($=>!$),"aria-expanded":x,title:`Raise its ${Zr(y)} spend cap.`,children:[t.jsx(Xx,{"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(hR,{"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(DN,{"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:g?"Show it in the runs list again.":"Hide it from the runs list. Its history is kept.",children:[g?t.jsx(zN,{"aria-hidden":!0}):t.jsx(ld,{"aria-hidden":!0})," ",s.busy==="archive"?g?"Unarchiving":"Archiving":g?"Unarchive":"Archive"]})]})]}),h&&x&&t.jsx("div",{className:"mt-3 max-w-xl",children:t.jsx(k$,{cap:y,suggested:w$(j),least:j$(j),paused:!!j,onRaise:s.onRaiseCap},j?`${e.run_id}:${j.at}`:`${e.run_id}:working`)})]})]})}const N9=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function S9({view:e,onView:n}){return t.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:N9.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 N$=(e,n)=>n?e:e.filter(s=>!P2(s.path));function C9({files:e,onOpen:n,showHidden:s,onShowHidden:r}){const o=e.filter(d=>P2(d.path)).length,i=N$(e,s),c=i.reduce((d,u)=>d+u.size_bytes,0);return t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center gap-3",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(YT,{className:"size-3.5","aria-hidden":!0})," Files · ",i.length," ",i.length===1?"file":"files"," (",Ka(c),")"]}),o>0&&t.jsxs("button",{type:"button",className:"caps ml-auto text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline","aria-pressed":s,onClick:()=>r(!s),children:[s?"Hide":"Show"," ",o," hidden"]})]}),i.length===0?t.jsx("p",{className:"border px-4 py-8 text-center font-mono text-body text-muted-foreground",children:o?`Only files in hidden folders (${o}).`:"This run wrote no files."}):t.jsx("ul",{className:"border",children:i.map(d=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("button",{type:"button",onClick:()=>n(d),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left hover:bg-accent",children:[t.jsx(Za,{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:ft(d.modified_at)}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Ka(d.size_bytes)})]})},d.path))})]})}function E9({file:e,text:n,onClose:s,files:r=[],onOpen:o}){const[i,c]=p.useState(!1),d=p.useRef(null);p.useEffect(()=>{var k;const b=document.activeElement,j=d.current;return j&&!j.open&&((k=j.showModal)==null||k.call(j)),()=>{var E;j!=null&&j.open&&j.close(),(E=b==null?void 0:b.focus)==null||E.call(b)}},[]),p.useEffect(()=>c(!1),[e.path]);const u=p.useRef(!1),f=p.useRef(!1),g=YM(e),[y,v]=p.useState(g==="markdown"?"rendered":"raw");p.useEffect(()=>v(g==="markdown"?"rendered":"raw"),[e.path]);const h=Lv(b=>{const j=r.find(k=>k.path===b);j&&(o==null||o(j))}),x=()=>{if(n===null)return;const b=URL.createObjectURL(new Blob([n],{type:e.content_type??"application/octet-stream"}));Object.assign(document.createElement("a"),{href:b,download:e.path.split("/").pop()}).click(),URL.revokeObjectURL(b)};return t.jsx("dialog",{ref:d,"aria-label":e.path,onCancel:b=>{b.preventDefault(),s()},onMouseDown:b=>{u.current=b.target===b.currentTarget},onMouseUp:b=>{f.current=b.target===b.currentTarget},onClick:b=>{u.current&&f.current&&b.target===b.currentTarget&&s(),u.current=f.current=!1},className:"m-0 h-full max-h-none w-full max-w-none border-0 bg-transparent p-0 text-foreground backdrop:bg-overlay/60 md:p-8",children:t.jsxs("div",{className:"mx-auto flex h-full w-full max-w-5xl flex-col border bg-background",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2.5",children:[t.jsx(B,{size:"icon",variant:"ghost",onClick:s,"aria-label":"Close",children:t.jsx(Zo,{"aria-hidden":!0})}),t.jsx(Za,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:e.path}),g!=="download"&&t.jsx("div",{className:"order-last basis-full sm:order-none sm:basis-auto",children:t.jsx(S9,{view:y,onView:v})}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:async()=>{var b;n!==null&&(await((b=navigator.clipboard)==null?void 0:b.writeText(n)),c(!0))},children:[t.jsx(Xa,{"aria-hidden":!0})," ",i?"Copied":"Copy"]}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:x,children:[t.jsx(HN,{"aria-hidden":!0})," Download"]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 py-8 md:px-16",children:n===null?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading the file..."}):g==="download"?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This file type is not shown here. Download it to open it."}):y==="rendered"?t.jsx("article",{className:"report mx-auto max-w-3xl",onClick:h,dangerouslySetInnerHTML:{__html:oo(n,o&&{paths:r.map(b=>b.path),from:e.path.split("/").slice(0,-1).join("/")})}}):t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-small leading-[1.8]",children:n})}),t.jsxs("footer",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["File · ",n===null?"...":`${n.length.toLocaleString("en-US")} characters`," · ",e.content_type??"unknown type"]})]})})}function $9(e){const n=e.replace(/\r\n?/g,`
|
|
702
|
-
`).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(`
|
|
703
|
-
`);let o;for(let c=0;c<r.length;c++){const d=/^ {0,3}(`{3,}|~{3,})([^`]*)$/.exec(r[c]);if(!d)continue;const u=d[1],f=new RegExp(`^ {0,3}${u[0]==="`"?"`":"~"}{${u.length},}\\s*$`),g=r.findIndex((v,h)=>h>c&&f.test(v));if(g<0)break;const y=d[2].trim().toLowerCase();o=y==="json"||y===""?{open:c,end:g}:void 0,c=g}if(o&&o.end===r.length-1){const c=s(r.slice(o.open+1,o.end).join(`
|
|
704
|
-
`));return c?{words:r.slice(0,o.open).join(`
|
|
705
|
-
`).trim(),record:c}:null}const i=s(n);if(i)return{words:"",record:i};for(let c=n.lastIndexOf(`
|
|
706
|
-
{`);c>=0;c=n.lastIndexOf(`
|
|
707
|
-
{`,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 _9=e=>e.replace(/[_-]+/g," ").trim()||e,Ec=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;function fm(e,n){let s=Ec(e);for(let r=0;s&&typeof s.$ref=="string"&&s.$ref.startsWith("#")&&r<8;r++){const o=s.$ref.slice(1).split("/").filter(Boolean).map(f=>decodeURIComponent(f).replaceAll("~1","/").replaceAll("~0","~")),{$ref:i,...c}=s,d=Ec(o.reduce((f,g)=>{var y;return(y=Ec(f))==null?void 0:y[g]},n))??{},u=d.properties||c.properties?{...Ec(d.properties),...Ec(c.properties)}:void 0;s={...d,...c,...u?{properties:u}:{}}}return s}const T9=(e,n)=>{var s;return((s=fm(e,n))==null?void 0:s.contentMediaType)==="text/markdown"};function zb({value:e,schema:n,root:s,linked:r}){var o;if(e==null)return t.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"—"});if(Array.isArray(e)){if(!e.length)return t.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"none"});const i=(o=fm(n,s))==null?void 0:o.items;return t.jsx("ul",{"data-json":"array",className:"list-disc space-y-1 pl-5",children:e.map((c,d)=>t.jsx("li",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:t.jsx(zb,{value:c,schema:i,root:s,linked:r})},d))})}return typeof e=="object"?t.jsx(S$,{record:e,schema:n,root:s,linked:r}):typeof e=="string"&&T9(n,s)?t.jsx("article",{"data-json-markdown":!0,className:"report max-w-none",dangerouslySetInnerHTML:{__html:oo(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 S$({record:e,schema:n,root:s,linked:r}){var i;const o=(i=fm(n,s))==null?void 0:i.properties;return t.jsx("dl",{"data-json":"object",className:"min-w-0 space-y-3 border-l pl-4",children:Object.entries(e).map(([c,d])=>{var g;const u=o==null?void 0:o[c],f=(g=fm(u,s))==null?void 0:g.title;return t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"caps break-words [overflow-wrap:anywhere] text-label text-muted-foreground",children:typeof f=="string"&&f.trim()?f:_9(c)}),t.jsx("dd",{className:"mt-1 min-w-0 text-prose leading-relaxed",children:t.jsx(zb,{value:d,schema:u,root:s,linked:r})})]},c)})})}function uN({record:e,schema:n,linked:s}){const[r,o]=p.useState(!1);return t.jsxs("section",{className:"min-w-0 space-y-3",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(B,{type:"button",size:"xs",onClick:()=>o(i=>!i),children:r?"Show fields":"Show raw JSON"})}),r?t.jsx("pre",{"aria-label":"The answer's JSON",className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(e,null,2)}):t.jsx("div",{"aria-label":"The answer's fields",className:"min-w-0 [&>dl]:border-l-0 [&>dl]:pl-0",children:t.jsx(S$,{record:e,schema:n,root:n,linked:s})})]})}function R9({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(zb,{value:e,schema:n,root:n,linked:s})})}function A9({run:e,rows:n,files:s=[],onOpen:r,schema:o}){var y,v,h,x,b;const i=((y=e.result)==null?void 0:y.final_answer)??((v=n.findLast(j=>j.kind==="final_answer"))==null?void 0:v.text)??null,c=r?{paths:s.map(j=>j.path)}:void 0,d=Lv(j=>{const k=s.find(E=>E.path===j);k&&(r==null||r(k))}),u=(h=e.result)==null?void 0:h.output;if(e.kind==="agentic"&&u!==void 0&&u!==null)return t.jsx("div",{className:"min-w-0",onClick:d,children:typeof u=="object"&&!Array.isArray(u)?t.jsx(uN,{record:u,schema:o,linked:c}):t.jsx(R9,{value:u,schema:o,linked:c})});const f=e.kind==="agentic"?(x=e.result)==null?void 0:x.output_error:void 0,g=f?t.jsx(bt,{tone:"warning",title:"The answer did not match the output schema",children:f}):null;if(i!=null&&i.trim()){const j=$9(i);return j?t.jsxs("div",{className:"min-w-0 space-y-6",children:[g,j.words&&t.jsx("article",{className:"report max-w-none",onClick:d,dangerouslySetInnerHTML:{__html:oo(j.words,c)}}),t.jsx(uN,{record:j.record})]}):t.jsxs("div",{className:"min-w-0 space-y-6",children:[g,t.jsx("article",{className:"report max-w-none",onClick:d,dangerouslySetInnerHTML:{__html:oo(i,c)}})]})}if(g)return g;if(((b=e.result)==null?void 0:b.output)!==void 0&&e.result.output!==null){const j=e.result.output,k=j&&typeof j=="object"&&!Array.isArray(j)?Object.entries(j).filter(S=>typeof S[1]=="string"&&S[1].includes(`
|
|
708
|
-
`)&&S[1].length>80):[],E=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:oo(N,c)}})]},S)),(!k.length||Object.keys(E).length>0)&&t.jsxs("section",{children:[t.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:k.length?"The rest of the output":"Output"}),t.jsx("pre",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(E,null,2)})]})]})}return null}function O9({native:e,agentId:n}){const s=[{label:"Task usage",usage:e.usage.task},...e.usage.reflection.length?e.usage.reflection.map((r,o)=>({label:`Reflection usage · turn ${o+1}`,usage:r})):[{label:"Reflection usage",usage:null}]];return t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Native run details",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Native run"}),t.jsx("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[["Runtime",Sd(e.runtime)],["Project",e.project],["Selector",Vv(e.selector)],["Machine",e.machine_id],["Native session",e.session_id??"Not reported"],["Model",e.model??"Unknown"],["Configuration fingerprint",e.fingerprint],["Pinned learning revision",e.learning_revision??"None supplied"]].map(([r,o])=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"text-muted-foreground",children:r}),t.jsx("dd",{className:"break-all font-mono",children:o})]},r))}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Native usage by phase",children:[t.jsx("thead",{children:t.jsx("tr",{children:["Phase","Uncached input","Output tokens","Cache read","Cache write","Cost"].map(r=>t.jsx("th",{className:"whitespace-nowrap border-b px-2 py-2 font-semibold",children:r},r))})}),t.jsx("tbody",{children:s.map(({label:r,usage:o})=>{const i=e.runtime==="codex"?(o==null?void 0:o.input_tokens)==null||o.cache_read_tokens==null||o.cache_write_tokens==null?null:Math.max(0,o.input_tokens-o.cache_read_tokens-o.cache_write_tokens):o==null?void 0:o.input_tokens;return t.jsxs("tr",{children:[t.jsx("th",{className:"whitespace-nowrap px-2 py-2 font-normal",children:r}),[i,o==null?void 0:o.output_tokens,o==null?void 0:o.cache_read_tokens,o==null?void 0:o.cache_write_tokens].map((c,d)=>t.jsx("td",{className:"px-2 py-2 font-mono",children:c==null?"Unknown":c.toLocaleString("en-US")},d)),t.jsx("td",{className:"px-2 py-2 font-mono",children:(o==null?void 0:o.cost_usd)==null?"Unknown":so(o.cost_usd)})]},r)})})]})}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Grading usage belongs to the separate learning run.",n&&t.jsxs(t.Fragment,{children:[" ",t.jsx("a",{href:`#/agents/${encodeURIComponent(n)}/learning`,className:"underline underline-offset-2",children:"Open learning evidence"}),"."]})," Unreported native counters and model request totals stay unknown."]})]})}const L9={seeded:"Prepared",reflecting:"Reflecting",proposed:"Under review",merged:"Saved",dropped:"Not saved",pending:"Awaiting approval"},vf=e=>typeof e=="number"&&Number.isFinite(e)?e.toLocaleString("en-US"):"Not reported";function M9({run:e,read:n,onViewChanges:s}){var b,j,k,E,S,N,$,_,O,L,P;const[r,o]=p.useState({data:void 0,reading:!0}),[i,c]=p.useState(0),d=p.useRef(n);d.current=n;const u=!!n,f=e.run_id,g=(b=e.learning)==null?void 0:b.state,y=(j=e.learning)==null?void 0:j.at;p.useEffect(()=>{let R=!0;if(!u){o({data:void 0,reading:!1});return}return o(A=>({...A,error:void 0,reading:!0})),Promise.resolve().then(()=>d.current()).then(A=>{if(A&&A.run!==f)throw new Error("The learning result belongs to a different run. Refresh to try again.");R&&o({data:A,reading:!1})}).catch(A=>{R&&o(M=>({...M,error:A??new Error("The learning result could not be read."),reading:!1}))}),()=>{R=!1}},[f,g,y,u,i]),p.useEffect(()=>{const R=()=>{document.hidden||c(A=>A+1)};return window.addEventListener("focus",R),document.addEventListener("visibilitychange",R),()=>{window.removeEventListener("focus",R),document.removeEventListener("visibilitychange",R)}},[]);const v=r.data,h=()=>c(R=>R+1),x=(k=v==null?void 0:v.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"}),v&&t.jsx(Se,{children:L9[v.state]??v.state}),t.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[t.jsxs("a",{href:`#/agents/${encodeURIComponent(e.agent_id)}/learning`,className:"inline-flex items-center gap-1 text-small text-muted-foreground hover:text-primary-text",children:["Agent learning",t.jsx(hr,{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(Xo,{"aria-hidden":!0})})]})]}),r.reading&&t.jsx("p",{className:"px-5 py-3 text-body text-muted-foreground",role:"status",children:v===void 0?"Reading learning result…":"Refreshing learning result…"}),r.error!==void 0&&t.jsxs("div",{className:"space-y-2 p-4",children:[v!==void 0&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Showing the last result read."}),t.jsx(Jt,{problem:Ht(r.error,"the learning result"),onRetry:h,className:""})]}),!u&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"Detailed learning results are unavailable in this view."}),u&&v===null&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"No learning result was recorded for this run."}),v&&t.jsxs("div",{className:"space-y-6 p-5",children:[t.jsxs("div",{children:[v.detail&&t.jsx("p",{className:"break-words text-body leading-relaxed",children:v.detail}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-label text-muted-foreground",children:[v.at&&t.jsxs("span",{children:["Updated ",ft(v.at)]}),v.reason&&t.jsxs("span",{children:["Reason: ",v.reason]})]})]}),t.jsxs("section",{"aria-label":"Grader decision",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"Grader decision"}),v.verdict?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-small text-muted-foreground",children:v.verdict.merge?(E=v.verdict.items)!=null&&E.some(R=>!R.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:v.verdict.reason}),(S=v.verdict.items)!=null&&S.length?t.jsx("ul",{className:"mt-3 divide-y border",children:v.verdict.items.map((R,A)=>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:R.file}),t.jsx(Se,{tone:R.pending?"warning":R.keep?"success":"muted",children:R.pending?"Needs approval":R.keep?"Keep":"Do not keep"})]}),t.jsx("p",{className:"break-words text-body leading-relaxed text-muted-foreground",children:R.why}),R.question&&t.jsx("p",{className:"text-small",children:R.question}),R.origin&&t.jsx("p",{className:"text-label text-muted-foreground",children:R.origin==="you"?"From your instruction":`Origin: ${R.origin}`})]},`${R.file}-${A}`))}):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:Zm(v)?"No grader decision recorded yet.":"No grader decision was recorded for this run."})]}),!!((N=v.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:[v.pending.map(R=>R.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"}),($=v.problems)!=null&&$.length||(_=v.draft_errors)!=null&&_.length?t.jsxs("ul",{className:"space-y-3",children:[(O=v.problems)==null?void 0:O.map((R,A)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"text-body",children:R.detail}),t.jsx("p",{className:"mt-1 break-all font-mono text-label text-muted-foreground",children:[R.rule,R.path].filter(Boolean).join(" · ")})]},`problem-${A}`)),(L=v.draft_errors)==null?void 0:L.map((R,A)=>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:R})]},`draft-${A}`))]}):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((P=v.cost_usd)==null?void 0:P.grade)=="number"?Ia(v.cost_usd.grade):"Not reported"],["Input",vf(x==null?void 0:x.input)],["Output",vf(x==null?void 0:x.output)],["Cache reads",vf(x==null?void 0:x.cache_read)],["Cache writes",vf(x==null?void 0:x.cache_write)]].map(([R,A])=>t.jsxs("div",{className:"border p-3",children:[t.jsx("dt",{className:"mb-1 text-label text-muted-foreground",children:R}),t.jsx("dd",{className:"font-mono text-body",children:A})]},R))}),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(hr,{"aria-hidden":!0})]})]}),t.jsxs("dl",{className:"space-y-3 text-small",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"mb-1 text-muted-foreground",children:"Seed commit"}),t.jsx("dd",{className:"break-all font-mono",children:v.seed??"Not reported"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"mb-1 text-muted-foreground",children:"Merge commit"}),t.jsx("dd",{className:"break-all font-mono",children:v.merged??"Not merged"})]})]})]})]})]})}const fN=32,P9=360,I9=.7;function z9(e,n){const s=e.getBoundingClientRect().top;if(!n)return window.innerHeight-(s+window.scrollY)-fN;const r=s-n.getBoundingClientRect().top+n.scrollTop;return n.clientHeight-r-fN}const D9=(e,n)=>Math.round(Math.max(P9,Math.min(e,n*I9)));function F9(e,n,s=3e3,r=Math.min(s,U9),o=!1){const[i,c]=p.useState(null),[d,u]=p.useState(!1),f=p.useRef(e);f.current=e;const g=p.useRef(!1),y=p.useRef(!1),v=p.useRef(0),h=p.useRef(null),x=p.useRef(null),b=p.useRef(o);b.current=o,p.useEffect(()=>{o&&(x.current=null)},[o]);const j=!!e;p.useEffect(()=>{if(!j||d)return;if(n||(x.current=null),!n&&g.current&&!y.current){c(O=>O&&mN(O));return}let E=!0,S;const N=O=>{clearTimeout(S),S=setTimeout(()=>{h.current=null,_()},O),h.current=()=>N(r)};let $=!1;const _=async()=>{try{const O=await f.current();if(!E)return;g.current=!0,O.state==="live"&&!b.current&&(x.current=O.kind);const L=O.state==="none"&&O.session==="opening"&&O.kind!=="browser"&&O.kind===x.current?{...O,session:"closed"}:O;y.current=L.state==="none"&&L.session==="unopened",$=L.state==="none"&&L.session==="opening"||L.state==="live"&&L.hold==="pending",L.state==="off"?c(null):c(n?P=>H9(P,L)?P:L:mN(L))}catch(O){if(!E)return;if(O instanceof Ue&&O.status===401){u(!0),c(L=>L?{state:"signed_out"}:null);return}if(O instanceof Ue&&O.status===403){u(!0),c(null);return}}E&&n&&N($||Date.now()<v.current?r:s)};return _(),()=>{E=!1,clearTimeout(S),h.current=null}},[j,n,s,r,d]);const k=p.useCallback(E=>{var S;c(N=>N&&N.state==="live"&&N.hold!==E?{...N,hold:E}:N),v.current=Date.now()+W9,(S=h.current)==null||S.call(h)},[]);return{view:i,held:k}}const U9=400,W9=4e3,H9=(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))},mN=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"},B9={browser:GN,desktop:ei,phone:JN,sandbox:gR},G9={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},q9={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function K9({runId:e,screen:n,machine:s,opens:r,followUp:o,metered:i,waitsFor:c,keptUntil:d,onTake:u,onHand:f,recordings:g=[],fileUrl:y}){const v=p.useRef({viewer:"",n:0});(n==null?void 0:n.state)==="live"&&n.viewer!==v.current.viewer&&(v.current={viewer:n.viewer,n:v.current.n+1});const h=n&&n.state!=="signed_out"?n.kind:(s==null?void 0:s.kind)??"browser",x=(n==null?void 0:n.state)==="live"?X9(n.viewer,e):void 0,b=x&&h!=="browser"?`${x}${x.includes("#")?"&":"#"}hands=page`:x,j=B9[h],k=(n==null?void 0:n.state)==="live"?n:null,[E,S]=p.useState(!1),[N,$]=p.useState(null),_=async G=>{if(!(!G||E)){S(!0),$(null);try{$(await G())}finally{S(!1)}}},O=k&&b&&h!=="browser"?k:null,[L,P]=p.useState(!1),R=p.useRef(null),A=p.useRef(null),M=p.useRef(null),F=p.useRef(!1),I=!!(k&&b);p.useEffect(()=>{I||P(!1)},[I]);const[q,W]=p.useState(void 0);p.useLayoutEffect(()=>{const G=R.current;if(h!=="phone"||L||!I||!G)return;const z=G.closest("[data-scroll-pane]"),V=()=>W(D9(z9(G,z),window.innerHeight));V();const se=typeof ResizeObserver=="function"&&z?new ResizeObserver(V):void 0;if(z)for(const J of[z,...z.children])se==null||se.observe(J);return window.addEventListener("resize",V),()=>{se==null||se.disconnect(),window.removeEventListener("resize",V)}},[h,L,I,N,i,v.current.n]),p.useEffect(()=>{var G,z,V;if(L){F.current=!0,(z=(G=A.current)==null?void 0:G.querySelector("button"))==null||z.focus();return}F.current&&(F.current=!1,(V=M.current)==null||V.focus())},[L]),p.useEffect(()=>{if(!L)return;const G=re=>{if(re.key==="Escape"){P(!1);return}if(re.key!=="Tab"||!A.current)return;const ne=[...A.current.querySelectorAll("button:not([disabled]), iframe")];if(!ne.length)return;const me=ne[0],ve=ne[ne.length-1],je=document.activeElement;A.current.contains(je)?re.shiftKey&&je===me?(re.preventDefault(),ve.focus()):!re.shiftKey&&je===ve&&(re.preventDefault(),me.focus()):(re.preventDefault(),me.focus())},z=re=>{re.key==="Escape"&&P(!1)};document.addEventListener("keydown",G);const V=R.current;let se=null;const J=()=>{try{se==null||se.removeEventListener("keydown",z,!0)}catch{}try{se=(V==null?void 0:V.contentWindow)??null,se==null||se.addEventListener("keydown",z,!0)}catch{se=null}};return J(),V==null||V.addEventListener("load",J),()=>{document.removeEventListener("keydown",G),V==null||V.removeEventListener("load",J);try{se==null||se.removeEventListener("keydown",z,!0)}catch{}}},[L,v.current.n]);const K=k?h==="browser"?"browser · take over in the view below":`${q9[k.hold]} · ${h}`:"",U=O&&(O.hold==="person"?t.jsx(B,{size:"sm",variant:"solid",disabled:E,onClick:()=>void _(f),children:"Hand back"}):t.jsx(B,{size:"sm",variant:"solid",disabled:E||O.hold==="pending",onClick:()=>void _(u),children:O.hold==="pending"?"Taking over":"Take over"})),H=I&&t.jsx(B,{ref:L?void 0:M,size:"sm",variant:"ghost",onClick:()=>P(G=>!G),"aria-label":L?"Exit full window (Esc)":"Fill the window",title:L?"Exit full window (Esc)":"Fill the window","aria-pressed":L,children:L?t.jsx(aR,{className:"size-4","aria-hidden":!0}):t.jsx(sR,{className:"size-4","aria-hidden":!0})});return t.jsxs("section",{"aria-label":"Screen",className:"border",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2.5",children:[t.jsx(j,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:k?"Live":G9[h]}),t.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:K}),g.some(G=>!G.finished)&&t.jsx(Se,{tone:"active",title:"A video of this screen is being recorded",children:"Recording"}),y&&g.filter(G=>G.finished).map((G,z,V)=>t.jsxs("a",{href:`${y(G.path)}?download=1`,download:!0,className:cl({variant:"ghost",size:"sm"}),"aria-label":`Export ${G.path} (${Ka(G.bytes)})`,children:[t.jsx(HN,{"aria-hidden":!0})," Export",V.length>1?` ${z+1}`:""]},G.path)),!L&&H,!L&&U]}),i&&h!=="browser"&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:xb}),!L&&N&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:N}),k&&b?t.jsxs("div",{ref:A,"data-testid":"screen-frame",className:L?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:L?"dialog":void 0,"aria-modal":L?!0:void 0,"aria-label":L?"The run's screen, filling the window":void 0,children:[L&&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:K}),H,U]}),L&&N&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:N}),t.jsx("iframe",{ref:R,src:b,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:L?"block min-h-0 w-full flex-1 bg-background":h==="phone"?ae("mx-auto block aspect-[9/19] max-w-full bg-background",q===void 0&&"h-[70vh]"):"block aspect-[16/10] w-full bg-background",style:!L&&h==="phone"&&q!==void 0?{height:`${q}px`}:void 0},v.current.n)]}):t.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:J9(h,n,s,r,o,c,d)})]})}const V9={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."},Y9=/^The (desktop|phone) is kept for (\d+) minutes while you decide\.$/;function Q9(e,n){for(let s=e.length-1;s>=0;s-=1){const r=e[s];if(r.kind!=="phase")continue;const o=r.summary??r.text??"";if(o.startsWith(`The ${n} is ready`))return;const i=Y9.exec(o);if(!i||i[1]!==n)continue;const c=Date.parse(r.timestamp);return Number.isNaN(c)?void 0:new Date(c+Number(i[2])*6e4).toISOString()}}function J9(e,n,s,r,o,i,c){if((n==null?void 0:n.state)==="live")return"The live view can't be shown here.";if((n==null?void 0:n.state)==="signed_out")return"Signed out: sign in to watch.";if(e==="sandbox")return"A sandbox has no screen. What the agent runs in it is on the timeline.";if((s==null?void 0:s.state)==="failed")return`The ${e} didn't start.${s.why?` ${s.why}`:""}`;if(r&&i&&c&&(n==null?void 0:n.state)==="none"&&!n.ended)return`${V9[i]} The ${e} is kept until ${hN(c).replace(/^at /,"")}.`;if(r&&(n==null?void 0:n.state)==="none"&&n.ended)return e==="browser"?`${n.ended.why} (${hN(n.ended.at)}). A new browser opens when the run goes on.`:n.ended.why;const d=(n==null?void 0:n.state)==="none"?n.session:void 0;return d==="unopened"?r?e==="browser"?"This run hasn't opened its browser. The agent's page shows here if it opens one.":`This run hasn't opened its ${e}. Its screen shows here if the agent opens one.`:`This run didn't open its ${e}.${o?" A follow-up opens one if the agent needs it.":""}`:r&&d==="closed"?e==="browser"?"The run's browser isn't open now. The agent's page shows here if it opens one again.":`This ${e} has been released.`:r?e==="browser"?"Waiting for the browser. The agent's page shows here once it opens one.":`Waiting for the ${e}. Its screen shows here once it is up.`:`The ${e} closed when the run ended.${o?" A follow-up opens a new one if the agent needs it.":""}`}function hN(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:`at ${n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function X9(e,n){let s;try{s=new URL(e,location.origin).href}catch{return}const r=fr(s);if(!r)return;const o=new URL(r);return o.origin===location.origin&&o.pathname.startsWith(`/v2/runs/${encodeURIComponent(n)}/computer/live/`)?r:void 0}const Vi=e=>{var n,s;return e.status==="input_required"&&(((n=e.pending)==null?void 0:n.kind)==="browser"||((s=e.pending)==null?void 0:s.kind)==="computer")?e.pending:null},C$=e=>e.kind==="computer"?e.computer:"browser";function Hx(e,n){var s;if(e instanceof Ue&&e.code==="handoff_answered"){const r=(s=e.details)==null?void 0:s.outcome;return r==="expired"?"The ask expired before your answer: the agent was told.":r==="done"||r==="cancelled"?`It was already answered: ${r}.`:e.message}return e instanceof Ue&&e.code==="computer_not_live"?e.message:e instanceof Ue&&e.status===404?n==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof Ue&&e.status===403?"Sign in with your password to do this from here.":`${n==="hand"?"Not answered":"Not taken"}: ${Wt(e)}`}function E$({ask:e,onAnswer:n,open:s,heading:r,compact:o=!1}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),f=p.useRef(!1),g=async y=>{if(!n||f.current)return;f.current=!0,c(!0),u(null);let v=!1;try{const h=await n(y);v=h===null,u(h)}finally{v||(f.current=!1,c(!1))}};return t.jsxs("section",{"aria-label":"Waiting for you at the computer",className:o?"px-4 py-3":"border border-warning/50 bg-warning/5 p-4",children:[r,t.jsxs("p",{className:ae("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-1"),children:[t.jsx(ei,{className:"size-3.5","aria-hidden":!0})," Waiting for you · ",C$(e)]}),t.jsxs("div",{"data-agent-request":!0,className:ae("border-l-2 border-warning/60 pl-3",o?"mt-1":"mt-2"),children:[t.jsxs("p",{className:o?"text-prose leading-snug":"text-prose leading-relaxed",children:["The agent asks you to: ",e.instruction]}),t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["Done when: ",e.completion_condition]})]}),t.jsx("p",{className:"mt-2 text-small font-semibold",children:"You never need to type your AgentRun password for this."}),t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:["Expires ",ft(e.expires_at)," unanswered"]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s,t.jsx("span",{className:"flex-1"}),n&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"solid",disabled:i,onClick:()=>void g("done"),children:"Done"}),t.jsx(B,{size:"sm",variant:"ghost",disabled:i,onClick:()=>void g("cancelled"),children:"Cancel"})]})]}),d&&t.jsx("p",{className:"mt-2 text-small text-warning-text",role:"alert",children:d})]})}function Z9(e,n){const s=!!n&&ed(e.learning).length>0,[r,o]=p.useState({state:"reading"}),[i,c]=p.useState(0);return p.useEffect(()=>{if(!s)return;let d=!0;return o({state:"reading"}),Promise.resolve().then(()=>n()).then(u=>{d&&o({state:"read",changes:wD(u,e.learning)})},u=>{d&&o({state:"failed",error:u??new Error("unknown")})}),()=>{d=!1}},[e.run_id,s,i]),s?{got:r,retry:()=>c(d=>d+1)}:null}function eH({got:e,retry:n}){if(e.state==="read"&&!e.changes.length)return null;const s=e.state==="failed"?Ht(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(tH,{change:r})},r.file))})]})}function tH({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(_s,{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(pN,{name:"before",lines:e.before,none:"Not there before."}),t.jsx(pN,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function pN({name:e,lines:n,none:s}){return t.jsxs("div",{className:"min-w-0 border","data-side":e,children:[t.jsx("p",{className:"caps border-b px-3 py-2 text-label text-muted-foreground",children:e==="before"?"Before":"After"}),n===null?t.jsx("p",{className:"px-3 py-2 text-body text-muted-foreground",children:s}):t.jsx("pre",{className:"max-h-80 overflow-auto py-2 font-mono text-small leading-[1.7]",children:n.map((r,o)=>t.jsxs("span",{className: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})]},o))})]})}const nH=4e3,sH=e=>!!e.learning&&e.learning.reason!=="use",rH="The agent looks back on your words: what was wrong, and what a right answer does.",oH="A look-back needs words. Without them the grade is still kept.",aH='A JSON object of the fields a right answer holds, like {"total": 42}. Replays of a learned workflow are scored against it.',gN='Write it as a JSON object, like {"total": 42}, or leave it empty.';function iH(e){if(!e.trim())return{};try{const n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{value:n}:{error:gN}}catch{return{error:gN}}}function lH(e){const n=Ht(e,"the grade");return e instanceof Ue&&e.status<500&&n.said?n.said:`${n.why} ${n.next}`}const cH="The review could not run.";function dH(e,n){return e.feedback&&e.feedback_status==="not_run"?cH:e.feedback==="look_back"?n?"The agent is looking back on your words.":"The agent looked back on your words.":"Kept for this agent."}function uH({run:e,graded:n,onGrade:s,onOpenTimeline:r}){const[o,i]=p.useState("auto"),[c,d]=p.useState(""),[u,f]=p.useState(""),[g,y]=p.useState(!1),[v,h]=p.useState(!1),[x,b]=p.useState(null),j=p.useRef(!1),k=Va(e.status),E=n!=null&&n.feedback?n.feedback_status:null,S=E==="running"||E==="ended"&&Zm(e.learning??void 0);if(!sH(e)||!k&&!n)return null;const N=o==="auto"?n?"closed":"choose":o,$=k&&!S,_=iH(u),O=n?dH(n,S):null,L=async P=>{if(j.current||!s)return;const R=P?"":c.trim();if(!P&&_.error){y(!0);return}j.current=!0,h(!0),b(null);try{await s({correct:P,...R?{label:R}:{},...!P&&_.value?{expected:_.value}:{}}),i("auto"),d(""),f(""),y(!1)}catch(A){b(lH(A))}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(Se,{tone:n.correct?"success":"error",children:["Graded ",n.correct?"right":"wrong"]}),S&&t.jsx(Se,{tone:"active",children:"Reviewing"}),t.jsx("span",{className:"flex-1"}),n&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ft(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"),b(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:v||!s,onClick:()=>void L(!0),children:"Right"}),t.jsx(B,{type:"button",size:"sm",disabled:v||!s,onClick:()=>{i("wrong"),b(null)},children:"Wrong"}),n&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",disabled:v,onClick:()=>i("closed"),children:"Cancel"}),v&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),$&&N==="wrong"&&t.jsxs("form",{className:"space-y-4","aria-label":"Grade wrong",onSubmit:P=>{P.preventDefault(),L(!1)},children:[t.jsx(xt,{label:"What was wrong?",note:rH,warning:c.trim()?void 0:oH,children:t.jsx(nn,{value:c,onChange:P=>d(P.target.value),maxLength:nH,rows:3,disabled:v,className:"resize-y font-sans text-lead"})}),t.jsx(xt,{label:"Correct answer",optional:!0,note:aH,error:g?_.error:void 0,children:t.jsx(nn,{value:u,onChange:P=>{f(P.target.value),y(!1)},rows:2,disabled:v,spellCheck:!1,placeholder:'{"total": 42}',className:"resize-y"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:v,children:"Send grade"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",disabled:v,onClick:()=>{i(n?"closed":"choose"),y(!1)},children:"Cancel"}),v&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),x&&t.jsxs("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:["Your grade wasn't taken: ",x]})]})]})}const fH=(e,n)=>n&&(!e||Date.parse(n.graded_at)>Date.parse(e.graded_at))?n:e;function mH(e,n,s){const r=!!s&&!!e.learning,[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,y]=p.useState(0);p.useEffect(()=>{if(!r)return;let j=!0;return Promise.resolve().then(()=>s()).then(k=>{j&&(i(k??null),f(0))},()=>{j&&(i(null),f(k=>k+1))}),()=>{j=!1}},[e.run_id,r,n,e.ended_at,g]);const v=p.useCallback(({expected:j,...k})=>{d({run:k.run_id,grade:{...k,feedback_status:k.feedback?"running":null}})},[]),h=r?o:null,x=fH((h==null?void 0:h.graded)??null,(c==null?void 0:c.run)===e.run_id?c.grade:null),b=r&&(x==null?void 0:x.feedback_status)==="running";return p.useEffect(()=>{if(!b||u===0||u>hH)return;const j=setTimeout(()=>y(k=>k+1),dx(u-1));return()=>clearTimeout(j)},[b,u]),{read:h,grade:x,graded:v}}const hH=8,pH=e=>e===1?"once":e===2?"twice":`${e} times`;function gH({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:eh(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(Rf,{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(Se,{tone:"success",children:"Read"}):t.jsx(Se,{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(ti,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Workflow"}),t.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:s.name}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Called ",pH(s.calls)]}),s.failed>0&&t.jsxs(Se,{tone:"error",children:[s.failed," failed"]})]},`workflow:${s.name}`))]})]})}const Wi=(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}),Lr=(e,n=[])=>({type:"object",additionalProperties:!1,properties:e,...n.length?{required:n}:{}}),xH={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:Lr({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},vH=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."}),bH=e=>`Browse and automate websites in the persistent browser. ${vH.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"}]}.`,yH={name:"run",label:"Browser: run",description:bH(),parameters:Lr({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},Wi("click"),Wi("hover"),Wi("fill",{value:{type:"string"}}),Wi("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),Wi("press",{key:{type:"string"}}),Wi("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},wH={name:"screenshot",label:"Browser: screenshot",description:'Capture a screenshot of the active page. For size-constrained MCP clients, prefer a viewport JPEG: {"type":"jpeg","quality":40,"fullPage":false}.',parameters:Lr({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:{...Lr({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"},jH={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:Lr({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},kH={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:Lr({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},NH={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:Lr({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"},SH={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:Lr({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"},CH={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:Lr({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},EH={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:Lr({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"},$H=Object.freeze([xH,yH,wH,jH,kH,NH,SH,CH,EH]),_H=Object.freeze($H.map(e=>e.name)),TH={"com.apple.systempreferences":"System Settings","com.apple.iCal":"Calendar","com.apple.finder":"Finder","com.android.settings":"Settings","com.android.chrome":"Chrome","com.android.deskclock":"Clock","com.android.contacts":"Contacts","com.android.documentsui":"Files","org.wikipedia":"Wikipedia","xfce4-terminal":"Terminal","org.xfce.terminal":"Terminal",xterm:"XTerm","firefox-esr":"Firefox","google-chrome":"Chrome"};function RH(e){const n=e.split(".").at(-1)||e;return TH[e]??(n?n[0].toUpperCase()+n.slice(1):e)}const AH=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"]),OH=new Set(["ctrl","alt","super"]);function LH(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=>OH.has(r))||s.every(r=>AH.has(r))?e:void 0}const MH=["press","set","perform","click","type","key","nav","scroll","drag"];function PH(e,n){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=MH.find(u=>u in s)??"step",o=r==="type"?s.into:s[r],i=typeof o=="string"?n(o):void 0,c=r==="key"?LH(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 IH={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"},zH=new Set(["button","link","menuitem","tab","listitem","row","cell","radio","generic","text","heading"]);function DH(e){if(!e)return;const n=IH[e.role]??(e.role==="generic"?"element":e.role);return e.name?zH.has(e.role)?`“${e.name}”`:`the ${n} “${e.name}”`:`the ${n}`}const FH={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"]},UH={super:"⌘",shift:"⇧",alt:"⌥",ctrl:"⌃"},zg={enter:"Return",escape:"Esc",tab:"Tab",space:"Space",backspace:"Delete",delete:"Forward Delete",up:"↑",down:"↓",left:"←",right:"→"},gn=(e,n,s="")=>({did:`${e}${s}`,tried:`${n}${s}`});function WH(e){const n=e.endsWith("++")?[...e.slice(0,-2).split("+"),"+"]:e.split("+"),s=n.at(-1)??"",r=n.slice(0,-1).map(c=>c.toLowerCase()),o=n.length===1&&zg[s.toLowerCase()]?zg[s.toLowerCase()]:`${r.map(c=>UH[c]??`${c}+`).join("")}${zg[s.toLowerCase()]??(s.length===1?s.toUpperCase():s)}`,i=r.length===1&&r[0]==="super"?FH[s.toLowerCase()]:void 0;return i?gn(i[0],i[1],` (${o})`):gn("Pressed","press",` ${o}`)}const HH={back:["Went","go"," back"],home:["Went","go"," home"],app_switch:["Opened","open"," the recent apps"]};function BH(e){const n=DH(e.on),s=r=>` ${n??r}`;switch(e.do){case"press":return gn("Pressed","press",s("an element"));case"click":return gn("Clicked","click",n?` ${n}`:" at a point");case"set":return gn("Set","set",s("an element"));case"perform":return gn("Acted on","act on",s("an element"));case"type":return n?gn("Typed into","type into",` ${n}`):gn("Typed text","type text");case"key":return e.keys?WH(e.keys):gn("Pressed a key","press a key");case"nav":{const[r,o,i]=e.nav&&HH[e.nav]||["Navigated","navigate",""];return gn(r,o,i)}case"scroll":return n?gn("Scrolled","scroll",` ${n}`):gn("Scrolled","scroll");case"drag":return gn("Dragged","drag"," across the screen");default:return gn("Acted","act")}}function xN(e){const n=BH(e);return e.error===void 0?n.did:`Could not ${n.tried}`}const vN=3,Bx=e=>e[0].toLowerCase()+e.slice(1);function GH(e){const n=e.slice(0,vN).map(xN),s=e.slice(vN),r=s.findIndex(i=>i.error!==void 0),o=r<0?s.length:s.length-1;return[n[0],...n.slice(1).map(Bx),...o>0?[`+${o} more`]:[],...r<0?[]:[Bx(xN(s[r]))]].join(", ")}const qH={"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 Tr(e){const n=e.app?RH(e.app):void 0,s=(()=>{var r;switch(e.method){case"apps.launch":return gn("Opened","open",` ${n??"an app"}`);case"apps.terminate":return gn("Quit","quit",` ${n??"an app"}`);case"ui.observe":return gn("Looked at","look at",` ${n??"the window"}`);case"ui.act":return e.ok&&((r=e.steps)!=null&&r.length)?{did:GH(e.steps),tried:""}:e.ok?gn("Waited for","wait for",` ${n??"the window"}${e.expect==="unmet"?" (not seen)":""}`):gn("Acted on","act on",` ${n??"the computer"}`);default:{const[o,i]=qH[e.method]??[e.method,e.method];return gn(o,i)}}})();return e.ok?s.did:`Could not ${s.tried}`}const KH=e=>e.map((n,s)=>s===0?Tr(n):Bx(Tr(n))).join(", "),$$='\\s"`<>\\\\',VH=new RegExp(`https?://[^${$$}|]+`,"gi"),YH=new RegExp(`https?://[^${$$}]+`,"gi"),QH=".,;:!?*)]}'",JH={")":"(","]":"[","}":"{"};function XH(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&&QH.includes(e[s-1]);s--){const r=e[s-1],o=JH[r];if(o&&n[o]>=n[r])break;o&&(n[r]-=1)}return e.slice(0,s)}new RegExp(`\\]\\(|${VH.source}`,"gi");const Yo=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,un=e=>typeof e=="string"?e:void 0,Ja=(e,n)=>e.length>n?`${e.slice(0,n-3)}...`:e,_$=e=>e.split(`
|
|
709
|
-
`).map(n=>n.trim()).find(Boolean)??"";function mm(e){try{return Yo(JSON.parse(e))}catch{return}}const ZH=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function ad(e){const n=ZH.exec(e.trim());return Ja(n?`${n[1]}${n[2]==="/"?"":n[2]}`:e.split(/[?#]/)[0]??"",80)}const e7="…",t7=/https?:\/\//gi,n7=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i,s7=/(https?:\/\/)[^@/?#\s]*@/gi,r7=/[A-Za-z0-9]/;function Db(e){return e.replace(YH,n=>{const s=[0];let[r,o]=[0,!1];for(const i of n.matchAll(t7)){if(i.index===0)continue;for(;r<i.index;r++)o||(o=n[r]==="?"||n[r]==="#");if(o)continue;let c=!1;for(let d=i.index-1;d>s.at(-1)&&!r7.test(n[d]);d--)c||(c=n[d]==="'");c&&s.push(i.index)}return s.map((i,c)=>o7(n.slice(i,s[c+1]??n.length))).join("")})}function o7(e){const n=XH(e).length,s=n7.exec(e.slice(0,n));if(!s)return e;const r=i=>i.replace(s7,"$1"),o=[...new Set((s[4]??"").split("&").map(i=>r(i.split("=")[0])).filter(Boolean))];return`${s[1]}${r(`${s[2]}${s[3]}`)}${o.length?`?${o.map(i=>`${i}=${e7}`).join("&")}`:""}${e.slice(n)}`}const a7=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),i7=new Map,l7=new Map,T$=new Map,c7=new Set;function fn(e,n,s,{name:r,saysFailure:o}={}){i7.set(e,n),s&&l7.set(e,s),r&&T$.set(e,r),o&&c7.add(e)}const d7=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,u7=/^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/,f7=e=>{const n=u7.exec(e)??d7.exec(e);return n&&n[1]!=="hands"?`${n[1]} · ${n[2]}`:void 0},m7=e=>T$.get(e)??f7(e)??e,h7=new Map;function Fb(e,n){h7.set(e,n)}const p7=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...p7];const Ub=e=>un(e.path)??un(e.file_path),g7=/page\.goto\(\s*["'`]([^"'`]+)/;fn("read",e=>`Read ${Ub(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});fn("write",e=>`Wrote ${Ub(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});fn("edit",e=>`Edited ${Ub(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});fn("bash",e=>`Ran \`${Ja(Db(_$(un(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const R$=e=>{const n=e&&Yo(mm(e.text)??mm(_$(e.text)));if((n==null?void 0:n.ok)!==!1)return;const s=un(n.refused);return s!==void 0?{refused:!0,detail:s.replace(/^refused:\s*/,"")}:{refused:!1,detail:un(n.error)??un(n.message)??"no detail"}},x7=(e,n)=>`${R$(n)?"Tried to fetch":"Fetched"} ${ad(un(e.url)??"a page")}`,v7={many:e=>`Fetched ${e} pages`,subject:e=>e?ad(e):void 0},b7=e=>{const n=R$(e);return n&&{failed:!0,text:`${n.refused?"refused":"failed"}: ${n.detail}`}};fn("web_fetch",x7,v7,{name:"Fetch web pages"});Fb("web_fetch",b7);fn("web_search",e=>{const n=un(e.query);return n?`Searched the web for "${Ja(Db(n),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${Ja(e,40)}"`:void 0},{name:"Search the web"});Fb("web_search",e=>{var s;const n=un((s=Yo(mm(e.text)))==null?void 0:s.error);return n!==void 0?{failed:!0,text:`failed: ${n}`}:void 0});fn("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 "${Ja(Db(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?ad(s):void 0}},{name:"Read the browser's page"});fn("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});fn("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});fn("run",(e,n)=>{var i,c;const s=(i=g7.exec(un(e.code)??""))==null?void 0:i[1];if(s)return`Opened ${ad(s)}`;const r=(c=Yo(n==null?void 0:n.details))==null?void 0:c.sent,o=Array.isArray(r)?r.flatMap(d=>{const u=Yo(d),[f,g]=[un(u==null?void 0:u.method),un(u==null?void 0:u.url)];return f&&g?`${f} ${ad(g)}`:[]}):[];return o.length?`Acted on the page (${o.length} request${o.length===1?"":"s"} sent: ${a7(o)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});fn("browser_downloads",(e,n)=>{var o;const s=n&&((o=mm(n.text))==null?void 0:o.fetched),r=Array.isArray(s)?s.flatMap(i=>{var c;return un((c=Yo(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"});fn("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});fn("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});fn("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});fn("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});fn("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const y7=/^(\d+)\. [a-z_.]+(?: into)?(?: @\S+ ([a-z]+)(?: ("(?:[^"\\]|\\.)*"))?)?(?: \[secure\])?: (.*)$/,w7=e=>{if(e!==void 0)try{return un(JSON.parse(e))}catch{return}};function A$(e){var s;const n=new Map;for(const r of(e??"").split(`
|
|
710
|
-
`)){const o=y7.exec(r);if(!o)continue;const i=w7(o[3]),c=(s=/^refused \([^)]*\): (.*)$/.exec(o[4]))==null?void 0:s[1],d=o[2]===void 0?void 0:{role:o[2],...i?{name:i}:{}};n.set(Number(o[1]),{...d?{on:d}:{},...c!==void 0?{refused:c}:{}})}return n}function j7(e,n){return{...PH(e,()=>n==null?void 0:n.on),...(n==null?void 0:n.refused)!==void 0?{error:"refused"}:{}}}fn("computer_act",(e,n)=>{var d;const s=Array.isArray(e.steps)?e.steps.flatMap(u=>{const f=Yo(u);return f?[f]:[]}):[],r={method:"ui.act",started_at:"",ms:0,...un(e.app)?{app:un(e.app)}:{}};if(n!=null&&n.isError)return Tr({...r,ok:!1});const o=n===void 0?void 0:A$(n.text),i=o===void 0?s:s.filter((u,f)=>o.has(f+1));if(s.length>0&&i.length===0)return Tr({...r,ok:!1});const c=n&&((d=/^expect: (met|unmet)$/m.exec(n.text))==null?void 0:d[1]);return Tr({...r,ok:!0,steps:i.map((u,f)=>j7(u,o==null?void 0:o.get(f+1))),...c==="met"||c==="unmet"?{expect:c}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Act on the computer",saysFailure:!0});Fb("computer_act",e=>{for(const[n,s]of A$(e.text))if(s.refused!==void 0)return{failed:!0,text:`step ${n} refused: ${s.refused}`}});const bN=/^state \S+ · (\S+)/,k7=/^screen \S+ px · (?:\S+ in front|no app in front)/;fn("computer_observe",(e,n)=>{var r;if(n&&!n.isError&&!bN.test(n.text)){const o=k7.test(n.text),i=(d,u)=>({method:d,started_at:"",ms:0,ok:!0,...u?{app:u}:{}}),c=o?un(e.app):void 0;return KH([...c?[i("apps.launch",c)]:[],i("screen.shot"),...o?[i("apps.list")]:[]])}const s=un(e.app)??(n&&((r=bN.exec(n.text))==null?void 0:r[1]));return Tr({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});fn("computer_screenshot",(e,n)=>Tr({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 yN={"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"};fn("computer_op",(e,n)=>{var i;const s=un(e.op),r=s!==void 0&&Object.hasOwn(yN,s)?yN[s]:void 0;if(!r)return n!=null&&n.isError?"Could not act on the computer":"Acted on the computer";const o=r==="apps.launch"?un((i=Yo(e.args))==null?void 0:i.id):void 0;return Tr({method:r,ok:(n==null?void 0:n.isError)!==!0,...o?{app:o}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Use the computer's apps, shell and files",saysFailure:!0});fn("computer_script",(e,n)=>{var r;const s=(r=un(e.title))==null?void 0:r.replace(/\s+/g," ").trim();return n!=null&&n.isError?s?`Could not run the script “${Ja(s,120)}”`:"Could not run a script on the computer":s?Ja(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 N7=["schedule","webhook","slack","github","composio","email","feed"];new Set(N7);const S7=":feedback",C7=e=>{var n;return e.kind==="user_message"&&((n=e.id)==null?void 0:n.endsWith(S7))===!0},E7={user_message:rv,thinking:Hc,tool_use:Af,tool_result:Af,waiting:ev,usage:Xx,final_answer:Za,phase:BN,error:al,decision:fR,text_block:oR,tool_approval_requested:QN},wN=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},jN=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),Wb=e=>e.origin==="server",O$=e=>e.origin==="trigger",L$=e=>{var i;const n=e.summary??"",s=(i=e.trigger)==null?void 0:i.name,r=s?n.indexOf(` ${s}: `):-1;if(s&&r>0&&!n.slice(0,r).includes(" "))return{who:n.slice(0,r+1+s.length),said:n.slice(r+s.length+3).trimStart()};const o=/^([^:]+):\s*/.exec(n);return o?{who:o[1],said:n.slice(o[0].length)}:{who:null,said:n}};function M$(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:M$(s.slice(2,-2))},r))}const $7=e=>{var r;const n=O$(e)?L$(e).said:(e.summary??"").replace(Wb(e)?/^AgentRun:\s*/:/^(You|Thinking|Asked you|Waiting for you):\s*/,"");if(e.kind==="user_message"&&n.startsWith("{"))try{return Object.entries(JSON.parse(n)).map(([o,i])=>`${o}: ${typeof i=="string"?i:JSON.stringify(i)}`).join(" · ")}catch{}const s=(e.text??"").split(`
|
|
711
|
-
`).filter(o=>o.trim()).length>1?"…":"";return e.kind==="final_answer"?!n.trim()&&!((r=e.text)!=null&&r.trim())?I2:`${n.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${s}`:e.kind==="user_message"?`${n}${s}`:n},id=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,_7=new Set(_H),T7=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 R7(e){const n=T7.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 kN=e=>e&&(UI(e)??(_7.has(e)?m7(e):R7(e))),NN=e=>Wb(e)?"AgentRun":O$(e)?L$(e).who??"Trigger":C7(e)?"Your grade":{user_message:"You",thinking:"Thinking",tool_use:kN(e.tool_name)??"Tool",tool_result:kN(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,A7={budget:"Paused at cap"};function O7({step:e,last:n,ended:s,waitingChip:r,files:o,onOpen:i}){var b,j;const c=e.row,[d,u]=p.useState(!1),g=oM(c)?WN:E7[c.kind]??BN,y=e.above?c.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":$7(c),v=e.above?null:e.detail??g2(c),h=v&&v.trim()!==y.trim()?v:null,x=v2(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"||jN(c))&&"border-warning/60 text-warning-text",x&&"border-destructive/60 text-destructive-text"),children:t.jsx(g,{className:"size-3.5","aria-hidden":!0})}),!n&&t.jsx("span",{className:"w-px flex-1 bg-border","aria-hidden":!0})]}),t.jsxs("div",{className:"min-w-0 flex-1 border-b py-3",children:[t.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:()=>u(k=>!k),"aria-expanded":d,disabled:!h,children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-body text-muted-foreground",children:[t.jsx("span",{"data-label":!0,className:"min-w-0 truncate",title:NN(c),children:NN(c)}),(c.kind==="tool_use"||c.kind==="tool_result")&&c.usage&&t.jsxs("span",{className:"font-mono text-label",children:["· ",ZL(c.usage,{ended:s})]}),c.kind==="waiting"&&t.jsx(Se,{tone:"warning",children:r??"Input required"}),jN(c)&&t.jsx(Se,{tone:"warning",children:"Approval required"}),x&&t.jsx(Se,{tone:"error",children:"Error"}),x2(c)&&t.jsx(Se,{tone:"muted",title:"Not run: refused before it ran",children:"Refused"}),c.agent_label&&t.jsx(Se,{label:!0,title:c.agent_label,children:c.agent_label}),e.ms!==void 0&&t.jsx("span",{className:"font-mono text-label",children:id(e.ms)}),e.times&&t.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${id(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",Wb(c)&&"text-muted-foreground"),children:M$(y)}),e.saved&&t.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),wN(c)&&t.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:wN(c)})]}),t.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:qa(c.timestamp)}),h&&t.jsx(_s,{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:Lv(k=>{const E=o==null?void 0:o.find(S=>S.path===k);E&&(i==null||i(E))}),dangerouslySetInnerHTML:{__html:oo(h,i&&o?{paths:o.map(k=>k.path)}:void 0)}}),d&&h&&c.kind!=="final_answer"&&t.jsx("pre",{className:"mt-3 max-h-80 overflow-auto whitespace-pre-wrap break-words border bg-card p-3 font-mono text-small leading-[1.7]",children:h}),(b=c.learned_nodes)!=null&&b.length?t.jsx(P7,{nodes:c.learned_nodes}):null,(j=c.computer_calls)!=null&&j.length?t.jsx(L7,{calls:c.computer_calls,dropped:c.computer_calls_dropped??0}):null]})]})}function L7({calls:e,dropped:n}){const[s,r]=p.useState(!1),o=e.filter(u=>!u.ok).length,i=e.length+n,c=[`${i} computer ${i===1?"call":"calls"}`,...o?[`${o} failed`]:[]].join(" · "),d=Date.parse(e[0].started_at);return t.jsxs("div",{className:"mt-2",children:[t.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>r(u=>!u),"aria-expanded":s,"aria-label":`${s?"Hide":"Show"} the computer calls`,children:[t.jsx(_s,{className:ae("size-3 transition-transform",s&&"rotate-90"),"aria-hidden":!0}),t.jsx(ei,{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:["+",id(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:Tr(u),children:Tr(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:id(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 M7={ok:"success",failed:"error",escalated:"warning"};function P7({nodes:e}){const[n,s]=p.useState(!1),r=Object.entries(e.reduce((i,c)=>({...i,[c.status]:(i[c.status]??0)+1}),{})).filter(([i])=>i!=="ok"),o=[`${e.length} ${e.length===1?"node":"nodes"}`,...r.map(([i,c])=>`${c} ${i}`)].join(" · ");return t.jsxs("div",{className:"mt-2",children:[t.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>s(i=>!i),"aria-expanded":n,"aria-label":`${n?"Hide":"Show"} the workflow's ${e.length===1?"node":"nodes"}`,children:[t.jsx(_s,{className:ae("size-3 transition-transform",n&&"rotate-90"),"aria-hidden":!0}),t.jsx(ti,{className:"size-3","aria-hidden":!0}),o]}),n&&t.jsx("ol",{"aria-label":"The workflow's nodes",className:"mt-2 divide-y border bg-card",children:e.map((i,c)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[t.jsx("span",{"data-status":i.status,className:"contents",children:t.jsx(Se,{tone:M7[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:pC(i)||void 0,children:ob(i.kind,i)}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:id(i.duration_ms)})]},c))})]})}function I7({rows:e,live:n,fold:s=6,asking:r,waitingOn:o,files:i,onOpen:c,ended:d=!1}){var b;const u=o==="budget"?e.findLastIndex(j=>j.paused===!0):-1,f=u>=0?(b=e.slice(u+1).findLast(j=>j.kind==="waiting"))==null?void 0:b.id:void 0,[g,y]=p.useState(!1),v=aM(e).map(j=>r&&j.row.id===r?{...j,above:!0}:j),h=g?0:Math.max(0,v.length-s),x=v.slice(h);return e.length?t.jsxs("div",{children:[h>0&&t.jsxs("button",{type:"button",className:"caps mb-1 ml-10 flex items-center gap-1 py-2 text-label text-muted-foreground hover:text-foreground",onClick:()=>y(!0),children:[t.jsx(_s,{className:"size-3","aria-hidden":!0})," ",h," earlier ",h===1?"step":"steps"]}),t.jsx("ol",{children:x.map((j,k)=>t.jsx(O7,{step:j,last:k===x.length-1&&!n,ended:d,waitingChip:j.row.id===f&&o?A7[o]:void 0,files:i,onOpen:c},j.row.id))}),n&&t.jsx(Gx,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):t.jsx(Gx,{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 Gx({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(GS,{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 z7={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."},D7={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 F7(e,n){var r,o;if(e.status==="input_required"&&((r=e.pending)==null?void 0:r.kind)==="budget"){const{cap_usd:i,spent_usd:c,held_usd:d}=e.pending,u=typeof i=="number"&&Number.isFinite(i),f=typeof d=="number"&&d>0?`, and holds ${Zr(d)} for steps still running`:"";return{title:"Paused at its spend cap",note:`${u&&typeof c=="number"?`It has spent ${Zr(c)} of its ${Zr(i)} cap${f}.`:u?`Its ${Zr(i)} cap is reached.`:"Its spend cap is reached."} Raise the cap above to continue.`,spin:!1}}if(e.status==="input_required"&&((o=e.pending)==null?void 0:o.kind)==="approval")return{title:"Waiting for your approval",note:`The run continues once you answer the approval above${n.canMessage?", or send a message below to decline it":""}.`,spin:!1};const s=Vi(e);return s?{title:`Waiting for you at the ${C$(s)}`,note:"The run continues once you answer the ask above, or hand the computer back on the Screen tab.",spin:!1}:e.status==="input_required"&&e.state==="waiting"?{title:"Waiting for your answer",note:n.messageMode==="answer"?"The run continues when you reply below.":"The run continues once the question is answered.",spin:!1}:e.status==="input_required"?{title:"Stopped",note:`Stopped before it wrote an answer.${n.canMessage?" Send a message below to continue it.":""}`,spin:!1}:e.status==="paused"?{title:"Paused",note:"No new step starts until it's resumed. The answer appears here when it finishes.",spin:!1}:{title:"Writing the answer",note:"The answer appears here when the run finishes. Follow it on the timeline.",spin:n.live}}function U7({run:e,agentName:n,messages:s,harnessSteers:r,rows:o,files:i,outputSchema:c,readFile:d,fileUrl:u,openFile:f=null,actions:g,onMessage:y,onApprove:v,tab:h,graphView:x,costText:b,readLearningDiff:j,readLearning:k,readLearningResult:E,readComputer:S,computerEvery:N,onTakeOver:$,onHandBack:_,readComputers:O,onGrade:L}){var he,He,Je,X,ge,_e,Ae;const P=e.native,R=ns(e),A=((he=e.pending)==null?void 0:he.kind)==="budget"?e.pending:null,M=Vi(e),F=!R&&!P&&M?r&&s.steer?"steer":s.follow_up?"follow_up":null:null,I=qm(e.status,e.state,e.kind,s,r,e.error,e.review,e.computer),q=R||P||A?{...I,canMessage:!1,messageMode:null}:M?{...I,canMessage:F!==null,messageMode:F}:I,W=x?"graph":q.final&&e.status==="completed"?"report":"timeline",[K,U]=p.useState(h??W),H=K==="graph"&&!x?W:K,[G,z]=p.useState(!1),[V,se]=p.useState(f?{file:f,text:null}:null),J=l9(e),re=J||M?null:VM(e.status,e.state,o),ne=J?o.findLast(We=>We.kind===x$&&We.tool_use_id===J.call_id):void 0,[me,ve]=p.useState(null),je=async(We,gt,jt,it)=>{const Vt=v?await(it?v(We,gt,jt,it):v(We,gt,jt)):"This page can't answer an approval.";return ve(Vt?{id:We,text:Vt}:null),Vt},Ve=p.useRef(z2()).current,de=async We=>{const gt=Ve.begin();if(se({file:We,text:null}),!d)return;const jt=await d(We);Ve.current(gt)&&se({file:We,text:jt})},Oe=()=>{Ve.cancel(),se(null)},ze=Z9(e,j),{read:De,grade:Ne,graded:Q}=mH(e,q.final,k),be=L&&(async We=>{const gt=await L(We);return Q(gt),gt}),nt=q.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",fe=e.computer,Le=fe?Q9(o,fe.kind):void 0,{view:Ye,held:ht}=F9(S,!q.final,N,void 0,e.status==="queued"||Le!==void 0),ie=!!Ye||!!fe||!!M,Ce=p.useRef(!1);p.useEffect(()=>{if(ie){Ce.current=!0;return}Ce.current&&H==="screen"&&U(W),Ce.current=!1},[ie,H,W]);const[tt,Ie]=p.useState(!1);p.useEffect(()=>{if(!fe||!vb.has(fe.kind)||!O)return;let We=!0;return O().then(gt=>{var jt,it;We&&Ie(!!((it=(jt=gt.kinds.find(Vt=>Vt.kind===fe.kind))==null?void 0:jt.providers.find(Vt=>Vt.id===fe.provider))!=null&&it.metered))}).catch(()=>{}),()=>{We=!1}},[fe==null?void 0:fe.kind,fe==null?void 0:fe.provider]);const at=M?`${M.kind}:${M.asked_at}`:null,St=p.useRef(null);p.useEffect(()=>{!at||St.current===at||!ie||(St.current=at,U("screen"))},[at,ie]);const st=async()=>{if(!$)return"This page can't take the computer over.";try{return ht((await $()).hold),null}catch(We){return Hx(We,"take")}},ut=async We=>{if(!_)return"This page can't hand the computer back.";try{return ht((await _(We)).hold),null}catch(gt){return Hx(gt,"hand")}},[Dt,Ft]=p.useState(null),Rt=async We=>{const gt=(M==null?void 0:M.asked_at)??"",jt=await ut(We);return Ft(jt?{at:gt,text:jt}:null),jt};p.useEffect(()=>{f&&d&&de(f)},[f]);const pe=[...x?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],...e.learning?[["learning","Learning"]]:[],["files",`Files ${N$(i,G).length}`],...ie?[["screen","Screen"]]:[]];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[t.jsx(k9,{run:e,agentName:n,actions:g,costText:b}),t.jsx(VS,{id:"run-views",label:"Run views",value:H,onChange:We=>U(We),tabs:pe.map(([We,gt])=>({id:We,label:gt}))}),H==="graph"?t.jsx("div",{className:"min-h-0 flex-1 short:min-h-96",children:x}):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:[P&&t.jsx(O9,{native:P,agentId:e.agent_id}),e.status==="failed"&&e.error&&t.jsx(aa,{error:e.error,title:H2(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."]})]}),me&&me.id!==(J==null?void 0:J.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: ",me.text]}),Dt&&Dt.at!==(M==null?void 0:M.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: ",Dt.text]}),J?t.jsx(b$,{pending:J,onAnswer:(We,gt,jt)=>jt?je(J.id,We,gt,jt):je(J.id,We,gt)},J.id):M?t.jsx(E$,{ask:M,onAnswer:_?Rt:void 0,open:H!=="screen"?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>U("screen"),children:"Open the screen"}):null},at):!P&&q.needsYou&&(A?t.jsx(g9,{pending:A}):t.jsx(v9,{waiting:re})),q.needsYou&&A&&typeof A.cap_usd=="number"&&(g==null?void 0:g.onRaiseCap)&&t.jsx(k$,{cap:A.cap_usd,suggested:w$(A),least:j$(A),paused:!0,onRaise:g.onRaiseCap},`${e.run_id}:${A.at}`),H==="report"&&t.jsx(A9,{run:e,rows:o,files:i,onOpen:de,schema:c}),H==="report"&&!e.result&&!q.final&&t.jsx(Gx,{...F7(e,q)}),H==="report"&&q.final&&!((Je=(He=e.result)==null?void 0:He.final_answer)!=null&&Je.trim())&&!((X=e.result)!=null&&X.output)&&!o.some(We=>{var gt;return We.kind==="final_answer"&&((gt=We.text)==null?void 0:gt.trim())})&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:[I2,q.canMessage?" Send a follow-up below to ask for one.":""]}),H==="timeline"&&t.jsx(I7,{rows:vD(o,e.learning),live:q.live,ended:Va(e.status),asking:(ne==null?void 0:ne.id)??(q.needsYou&&!A?re==null?void 0:re.id:void 0),waitingOn:e.status==="input_required"?(ge=e.pending)==null?void 0:ge.kind:void 0,files:i,onOpen:de}),(H==="report"||H==="timeline")&&t.jsx(uH,{run:e,graded:Ne,onGrade:be,onOpenTimeline:H==="timeline"?void 0:()=>U("timeline")}),(H==="report"||H==="timeline")&&t.jsx(gH,{used:(De==null?void 0:De.used)??null,agentId:e.agent_id}),(H==="report"||H==="timeline")&&ze&&t.jsx(eH,{got:ze.got,retry:ze.retry}),H==="learning"&&t.jsx(M9,{run:e,read:E,onViewChanges:ze?()=>U("report"):void 0},e.run_id),H==="files"&&t.jsx(C9,{files:i,onOpen:de,showHidden:G,onShowHidden:z}),H==="screen"&&ie&&t.jsx(K9,{runId:e.run_id,screen:Ye,machine:fe,opens:nt,followUp:q.canMessage&&q.messageMode==="follow_up",metered:tt,waitsFor:e.status==="input_required"&&((_e=e.pending)==null?void 0:_e.kind)!=="stopped"?(Ae=e.pending)==null?void 0:Ae.kind:void 0,keptUntil:e.status==="input_required"?Le:void 0,onTake:$?st:void 0,onHand:_?()=>ut():void 0,recordings:e.recordings,fileUrl:u})]})}),P&&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."]}),R&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:[Qo(R.runtime)," runs in your backend. Start, stop and follow up through that application's controls. AgentRun records the result and checked learning."]}),q.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(p9,{mode:q.messageMode,onSend:y,purpose:J?z7:M&&F?D7[F]:void 0})})}),V&&t.jsx(E9,{file:V.file,text:V.text,onClose:Oe,files:i,onOpen:de})]})}const P$=new Set(["chain","parallel","route","map","loop","workflow"]),W7={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},H7=e=>e==="review"?"needs review":e.replace("-"," ");function Hb({state:e}){const n=qf(e)??"pending";return t.jsx(Se,{tone:W7[n]??"plain",className:"whitespace-nowrap",children:H7(n)})}function Bb({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 I$={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},Gb=(e,n)=>e&&n?Date.parse(n)-Date.parse(e):void 0;function B7({data:e,selected:n,onSelect:s,onClose:r,fileUrl:o}){var j,k,E,S,N,$;const i=e.graph.nodes.find(_=>_.path===n.path),[c,d]=p.useState(null);if(!i)return null;const u=e.nodes[i.path],f=Uv(e.workflow,i.path,i),g=i.kind==="map"?i.path:(j=e.graph.nodes.find(_=>_.kind==="map"&&i.path.startsWith(`${_.path}/body/`)))==null?void 0:j.path,y=n.item!=null&&g?(E=(k=e.nodes[g])==null?void 0:k.items)==null?void 0:E.find(_=>_.index===n.item):void 0,v=e.decisions.filter(_=>_.node===i.path),h=e.effects.filter(_=>_.node===i.path),x=!!g&&i.kind!=="map",b=Gb(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:ob(i.kind,u),f.tool?` · ${F$(f.tool)}`:i.via?` · ${i.via}`:"",f.tool&&$d(f.tool)&&t.jsx(U$,{}),y&&t.jsxs(t.Fragment,{children:[t.jsx(_s,{className:"size-3","aria-hidden":!0})," item ",y.index+1]})]}),t.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:y?Qc(e,g,y.index)??`Item ${y.index+1}`:i.label}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t.jsx(Hb,{state:y?y.status:u==null?void 0:u.status}),y&&(()=>{const _=Wv(e,g,y);return _.outcome?t.jsxs("span",{className:"font-mono text-label",title:_.pNote,children:["outcome ",t.jsx("b",{className:I$[_.tone??""],children:_.outcome}),_.p!==void 0&&t.jsxs("span",{className:"text-muted-foreground",children:[" · ",qs(_.p)]})]}):null})(),f.decision&&t.jsx(Bb,{provider:f.provider}),f.decision&&((u==null?void 0:u.model)??f.model)&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:(u==null?void 0:u.model)??f.model}),(u==null?void 0:u.branch)&&t.jsxs("span",{className:"font-mono text-label",children:["took ",t.jsx("b",{children:u.branch})]}),!y&&b!==void 0&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:el(b)})]})]}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:r,children:t.jsx(Zo,{"aria-hidden":!0})})]}),y&&t.jsxs("button",{type:"button",className:"caps mt-3 text-label text-muted-foreground hover:text-foreground",onClick:()=>s({path:g,item:null}),children:["All ",(N=(S=e.nodes[g])==null?void 0:S.items)==null?void 0:N.length," items of ",($=e.graph.nodes.find(_=>_.path===g))==null?void 0:$.label]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[y?t.jsx(V7,{data:e,mapPath:g,index:y.index,status:y.status,fileUrl:o,zoom:d}):i.kind==="map"?t.jsx(G7,{data:e,mapPath:i.path,onSelect:s}):x&&(v.length||h.length)?t.jsx(q7,{data:e,path:i.path,mapPath:g,onSelect:s}):t.jsxs(t.Fragment,{children:[i.kind==="parallel"&&t.jsx(K7,{data:e,path:i.path,onSelect:s}),v.map((_,O)=>t.jsx(D$,{d:_,fileUrl:o,zoom:d},_.id??O)),h.map((_,O)=>t.jsx(W$,{e:_,fileUrl:o,zoom:d},O)),!v.length&&!h.length&&i.kind!=="parallel"&&t.jsx(z$,{kind:i.kind,status:u==null?void 0:u.status,meta:f})]}),t.jsx(Z7,{workflow:e.workflow,path:i.path,kind:i.kind})]}),c&&t.jsx(eB,{src:c,onClose:()=>d(null)})]})}function z$({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.":P$.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 G7({data:e,mapPath:n,onSelect:s}){var i;const r=((i=e.nodes[n])==null?void 0:i.items)??[],o=L2(r);return t.jsxs("section",{children:[t.jsx("div",{className:"mb-3 grid grid-cols-5 border",children:[["Items",o.total],["Done",o.done],["Working",o.working],["Review",o.review],["Failed",o.failed]].map(([c,d])=>t.jsxs("div",{className:"border-r px-3 py-2 last:border-r-0",children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:c}),t.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:d})]},c))}),t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"caps text-left text-micro text-muted-foreground",children:[t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"#"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Item"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"State"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Verdict"}),t.jsx("th",{className:"border-b py-1.5 text-right font-normal",children:"Cost"})]})}),t.jsx("tbody",{children:r.map(c=>{const d=e.decisions.filter(g=>{var y;return g.item===c.index&&!!((y=g.node)!=null&&y.startsWith(`${n}/body`))}),u=Wv(e,n,c),f=d.length?d.some(g=>g.cost_usd===null)?null:d.reduce((g,y)=>g+(y.cost_usd??0),0):void 0;return t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>s({path:n,item:c.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:c.index+1}),t.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:Qc(e,n,c.index),children:Qc(e,n,c.index)??"—"}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:t.jsx(Hb,{state:c.status})}),t.jsx("td",{className:"max-w-[150px] truncate whitespace-nowrap border-b py-1.5 pr-2",title:[u.pNote,...d.map(g=>hl(g))].filter(Boolean).join(", "),children:u.outcome?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:ae("font-semibold",I$[u.tone??""]),children:u.outcome}),u.p!==void 0&&t.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:qs(u.p)})]}):d.map(g=>hl(g)).filter(Boolean).join(", ")||t.jsx("span",{className:"text-muted-foreground",children:"—"})}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums",children:f===void 0?t.jsx("span",{className:"text-muted-foreground",children:"—"}):Rl(f)})]},c.index)})})]})]})}function q7({data:e,path:n,mapPath:s,onSelect:r}){var g;const o=e.decisions.filter(y=>y.node===n),i=e.effects.filter(y=>y.node===n),c=(((g=e.nodes[s])==null?void 0:g.items)??[]).map(y=>({it:y,d:o.find(v=>v.item===y.index),e:i.find(v=>v.item===y.index)})).filter(y=>y.d||y.e),d=o.filter(y=>y.cost_usd!==null),u=o.filter(y=>y.latency_ms!==null),f=u.length?u.reduce((y,v)=>y+(v.latency_ms??0),0)/u.length:void 0;return t.jsxs("section",{children:[o.length>0&&t.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[o.length," asked · ",Rl(d.reduce((y,v)=>y+(v.cost_usd??0),0)),d.length<o.length?` + ${o.length-d.length} unknown`:""," · mean ",el(f)]}),t.jsx("table",{className:"w-full border-collapse font-mono text-small",children:t.jsx("tbody",{children:c.map(({it:y,d:v,e:h})=>t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>r({path:s,item:y.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:y.index+1}),t.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:Qc(e,s,y.index)}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:v?hl(v):h?t.jsx(Hb,{state:h.status}):null}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:v?el(v.latency_ms):h?el(Gb(h.startedAt,h.endedAt)):""})]},y.index))})})]})}function K7({data:e,path:n,onSelect:s}){var v,h;const r=`${n}/branches/`,o=e.decisions.filter(x=>{var b;return((b=x.node)==null?void 0:b.startsWith(r))&&/^\d+$/.test(x.node.slice(r.length))&&x.item===null}),i=new Set(o.flatMap(x=>Object.keys(x.answers??{}))),[c]=[...i],d=o.map(x=>{var b;return{d:x,a:(b=x.answers)==null?void 0:b[c]}}).filter(x=>{var b;return((b=x.a)==null?void 0:b.type)==="noul"});if(i.size!==1||d.length<2)return t.jsx(z$,{kind:"parallel",meta:{decision:!1}});const u=d.map(x=>x.a.noul),f=u.reduce((x,b)=>x+b,0)/u.length,g=Math.max(...u)-Math.min(...u),y=x=>{var b;return((b=e.graph.nodes.find(j=>j.path===x.node))==null?void 0:b.label)??x.node};return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"border-b px-4 py-2.5",children:[t.jsxs("p",{className:"caps text-micro text-muted-foreground",children:["Jury · ",d.length," models · ",c]}),t.jsx("p",{className:"mt-1 text-body leading-snug",children:((h=(v=o[0].questions)==null?void 0:v[c])==null?void 0:h.instructions)??c})]}),t.jsx("ul",{className:"divide-y",children:d.map(({d:x,a:b})=>t.jsx("li",{children:t.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-2 text-left font-mono text-small hover:bg-accent",onClick:()=>s({path:x.node,item:null}),children:[t.jsx("span",{className:"w-[92px] shrink-0",children:t.jsx(Bb,{provider:x.provider})}),t.jsx("span",{className:"w-[132px] shrink-0 truncate",title:x.model??"",children:x.model??y(x)}),t.jsx(qx,{p:b.noul,strong:!0,tick:.5,tone:b.noul>=.5?"fg":"muted"}),t.jsx("span",{className:"w-10 text-right tabular-nums",children:qs(b.noul)})]})},x.id??x.executionPath))}),t.jsxs("dl",{className:"grid grid-cols-3 border-t font-mono text-small",children:[t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Mean P(yes)"}),t.jsx("dd",{className:"font-semibold tabular-nums",children:qs(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",g>.3&&"text-warning-text"),children:qs(g)})]}),t.jsxs("div",{className:"px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),t.jsx("dd",{className:"tabular-nums",children:Rl(d.some(x=>x.d.cost_usd===null)?null:d.reduce((x,b)=>x+(b.d.cost_usd??0),0))})]})]})]})}function V7({data:e,mapPath:n,index:s,status:r,fileUrl:o,zoom:i}){const d=e.graph.nodes.filter(u=>u.path.startsWith(`${n}/body`)).map(u=>({n:u,ds:e.decisions.filter(f=>f.node===u.path&&f.item===s),es:e.effects.filter(f=>f.node===u.path&&f.item===s)})).filter(u=>!P$.has(u.n.kind)||u.ds.length||u.es.length);return r==="pending"?t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"Not started: this item waits for a free slot in the map."}):t.jsxs("div",{className:"space-y-5",children:[d.map(({n:u,ds:f,es:g})=>f.length||g.length?t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:u.label}),g.map((y,v)=>t.jsx(W$,{e:y,fileUrl:o,zoom:i,compact:!0},v)),f.map((y,v)=>t.jsx(D$,{d:y,fileUrl:o,zoom:i},y.id??v))]},u.path):null),r==="working"&&!d.some(u=>u.ds.length)&&t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"In flight: the verdict shows here when it comes back."})]})}const SN=e=>`${Math.round(e*100)}%`,qs=e=>e.toFixed(2);function qx({p:e,strong:n,tick:s,tone:r="fg"}){const o={fg:"bg-foreground",success:"bg-success",warning:"bg-warning",muted:"bg-muted-foreground/50"}[r];return t.jsxs("span",{className:"relative block h-2 flex-1 bg-muted",children:[t.jsx("span",{className:ae("absolute inset-y-0 left-0 transition-[width] duration-slow",n?o:"bg-muted-foreground/45"),style:{width:SN(Math.max(0,Math.min(1,e)))}}),s!==void 0&&t.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:SN(s)},title:`threshold ${qs(s)}`})]})}function Y7({id:e,q:n,a:s,rule:r}){const o=d=>{var u;return(r==null?void 0:r.kind)==="pick"&&(n==null?void 0:n.type)==="choice"&&typeof((u=n.criteria)==null?void 0:u[d])=="string"?n.criteria[d]:d},i=(n==null?void 0:n.instructions)??e,c=(r==null?void 0:r.kind)==="route"?r.unsure:null;return t.jsxs("div",{className:"py-2.5",children:[t.jsxs("p",{className:"mb-2 text-body leading-snug",children:[t.jsx("span",{className:"mr-2 font-mono text-label text-muted-foreground",children:e}),i]}),s?s.type==="refusal"?t.jsx("p",{className:"font-mono text-small text-warning-text",children:"Refused to answer."}):s.type==="noul"?t.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[t.jsx("span",{className:ae("w-8 font-semibold",s.noul>=.5?"text-foreground":"text-muted-foreground"),children:s.noul>=.5?"YES":"NO"}),t.jsx(qx,{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) ",qs(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:o(d),children:s.type==="score"?`${d} ${s.legend[d]??""}`:o(d)}),t.jsx(qx,{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:qs(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 Q7(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 ${qs(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) ≥ ${qs(e.gte)}.`;case"sift":return e.keep?`Keep an item when its ${e.keep.id} ${e.keep.measure} ≥ ${qs(e.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function J7(e){var s,r,o,i;const n=e.action;if(n==null)return e.status==="cancelled"?"None: the outcome is unknown, so it goes to review and is not asked again.":"None.";if(((s=e.rule)==null?void 0:s.kind)==="route"){const c=((o=(r=e.answers)==null?void 0:r.branch)==null?void 0:o.type)==="choice"?e.answers.branch.confidence:void 0;return n.unsure?`Took "${String(n.taken)}": "${String(n.branch)}" at ${c!==void 0?qs(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?`"${A2(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 D$({d:e,fileUrl:n,zoom:s}){var i,c,d;const r=Array.from(new Set([...Object.keys(e.questions??{}),...Object.keys(e.answers??{})])),o=e.status==="answered"?"success":e.status==="cancelled"?"warning":"error";return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-2 border-b px-4 py-2.5",children:[t.jsx(Bb,{provider:e.provider}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:e.model??"default model"}),t.jsx(Se,{tone:o,children:e.status==="cancelled"?"outcome unknown":e.status})]}),t.jsxs("dl",{className:"grid grid-cols-[minmax(0,1fr)_100px_92px] border-b font-mono text-small",children:[t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:Object.keys(e.answers??{}).length>1&&((i=e.rule)==null?void 0:i.kind)!=="route"?"Least sure answer":"Verdict"}),t.jsx("dd",{className:"break-words font-semibold",children:hl(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:Rl(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:el(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)||fr(u.url)})).filter(({src:u})=>u).map(({img:u,src:f})=>t.jsxs("figure",{className:"flex gap-3",children:[t.jsx("button",{type:"button",className:"block shrink-0 border bg-white hover:border-foreground",onClick:()=>s(f),"aria-label":`Open ${u.ref}`,children:t.jsx("img",{src:f,alt:`The page the model saw as ${u.token}`,className:"block h-[155px] w-[120px] object-cover object-top",loading:"lazy"})}),t.jsxs("figcaption",{className:"min-w-0 flex-1 space-y-1.5 font-mono text-label",children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:"What the model saw"}),t.jsxs("p",{children:[t.jsx("span",{className:"text-muted-foreground",children:"token "}),u.token]}),t.jsxs("p",{className:"break-all",children:[t.jsx("span",{className:"text-muted-foreground",children:"page "}),u.ref]}),u.sha256&&t.jsxs("p",{className:"break-all",title:u.sha256,children:[t.jsx("span",{className:"text-muted-foreground",children:"sha256 "}),u.sha256.slice(0,16),"…"]}),(u.mime||u.bytes)&&t.jsx("p",{className:"text-muted-foreground",children:[u.mime,u.bytes?`${Math.round(u.bytes/1024)} KB`:null].filter(Boolean).join(" · ")})]})]},u.token))}),t.jsx("div",{className:"divide-y px-4",children:r.map(u=>{var f,g;return t.jsx(Y7,{id:u,q:(f=e.questions)==null?void 0:f[u],a:(g=e.answers)==null?void 0:g[u],rule:e.rule},u)})}),t.jsxs("dl",{className:"space-y-2 border-t px-4 py-3 text-body",children:[t.jsxs("div",{className:"flex gap-3",children:[t.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Rule"}),t.jsx("dd",{children:Q7(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:J7(e)})]})]}),!!((d=e.evidence)!=null&&d.length)&&t.jsx(X7,{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(_s,{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(hm,{value:e.state})]})]})}function X7({evidence:e}){return t.jsxs("section",{className:"border-t px-4 py-3",children:[t.jsxs("p",{className:"caps mb-2 text-micro text-muted-foreground",children:["Sources · ",e.length]}),t.jsx("ol",{className:"space-y-3",children:e.map((n,s)=>{let r=n.url;try{r=new URL(n.url).host}catch{}const o=fr(n.url);return t.jsxs("li",{className:"flex gap-3",children:[t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:s+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[o?t.jsxs("a",{href:o,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-start gap-1 text-body font-semibold leading-snug hover:underline",children:[n.title??r,t.jsx(KT,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}):t.jsx("span",{className:"break-all text-body font-semibold leading-snug",children:n.title??r}),t.jsxs("p",{className:"mt-0.5 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[r,n.scope&&t.jsx("span",{className:"border px-1",children:n.scope})]}),n.excerpts.slice(0,2).map((i,c)=>t.jsx("blockquote",{className:"mt-1.5 line-clamp-3 border-l-2 border-wf-parallel/[.6] pl-2.5 text-body leading-snug text-muted-foreground",children:i},c))]})]},s)})})]})}const F$=e=>{const n=$d(e);return n?`${n.tool} on ${n.server}`:e},U$=()=>t.jsx(Se,{tone:"muted",title:"An MCP server's tool",children:t.jsx("span",{"data-mcp":!0,children:"MCP"})});function W$({e,fileUrl:n,zoom:s,compact:r=!1}){var g;const o=e.output,i=o!=null,c=o&&typeof o=="object"?o:null,d=!e.endedAt&&!["done","ok","failed","stopped"].includes(e.status),u=e.error??(c!=null&&c.error?`${c.error.code?`${c.error.code}: `:""}${c.error.message??""}`:null),f=e.status==="done"||e.status==="ok"?"success":e.status==="failed"?"error":e.status==="stopped"?"muted":"active";return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"flex items-center gap-2 border-b px-4 py-2.5",children:[t.jsx("span",{className:"caps inline-flex h-5 items-center border border-wf-tool/[.6] bg-wf-tool/[.12] px-1.5 text-micro leading-none text-wf-tool",children:"tool"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",title:e.tool,children:F$(e.tool)}),$d(e.tool)&&t.jsx(U$,{}),t.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?el(Gb(e.startedAt,e.endedAt)):""}),t.jsx(Se,{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(hm,{value:e.input,small:!0})]}),u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",children:u}),!!((g=c==null?void 0:c.pages)!=null&&g.length)&&t.jsx("div",{className:"flex flex-wrap gap-3",children:c.pages.map(y=>t.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>s(n(y.image)),"aria-label":`Open page ${y.page}`,children:t.jsx("img",{src:n(y.image),alt:`Page ${y.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},y.page))}),i&&!u&&t.jsxs("details",{className:"group",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[t.jsx(_s,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),t.jsx(hm,{value:o,small:!0})]}),!i&&!u&&t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:e.status==="stopped"?"Stopped before it answered.":d?"Running…":"Finished with no output."})]})]})}function Z7({workflow:e,path:n,kind:s}){const r=T2(e,n);if(!r)return null;const o=Object.fromEntries(Object.entries(r).map(([i,c])=>[i,(i==="steps"||i==="branches"&&s==="parallel")&&Array.isArray(c)?`… ${Jm(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(_s,{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(hm,{value:o})]})}function hm({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 eB({src:e,onClose:n}){return t.jsx(Dm,{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 H$=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function tB(e,{everyMs:n=1e3,key:s="",enabled:r=!0}={}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,y]=p.useState(0),v=p.useRef(e);return v.current=e,p.useEffect(()=>{if(!r)return;const h=new AbortController;let x;const b=async()=>{try{const j=Date.now(),k=await v.current(h.signal);if(h.signal.aborted||(i(k),d(null),f(j),wd(k.run.status)))return}catch(j){if(h.signal.aborted)return;d(j);const k=j;if(k.retryable){x=setTimeout(b,Math.min(n,k.retryAfterMs??500));return}if(H$(j))return}x=setTimeout(b,n)};return b(),()=>{h.abort(),clearTimeout(x)}},[s,n,g,r]),{data:o,error:c,readAt:u,reload:()=>y(h=>h+1)}}function nB({data:e,actions:n={},fileUrl:s,initial:r=null,lastRead:o}){const[i,c]=p.useState(r),d=p.useMemo(()=>BM(e,i),[e,i]),u=wd(e.run.status),[f,g]=p.useState(()=>Date.now()),y=p.useMemo(()=>Date.now(),[e]);return p.useEffect(()=>{if(u||e.run.paused)return;const v=setInterval(()=>g(Date.now()),1e3);return()=>clearInterval(v)},[u,e.run.paused]),t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsx(sB,{data:e,readAt:y,now:f,actions:n,stale:!u&&o&&f-o>5e3?Math.max(1e3,f-o):0}),e.run.paused&&t.jsx("p",{className:"border-b border-warning/40 bg-warning/10 px-5 py-2 font-mono text-small text-warning-text md:px-8",role:"status",children:"Paused. Calls already in flight finish; no new node starts until you resume. The run keeps its place across a restart."}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[t.jsx("div",{className:"min-h-[320px] min-w-0 flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px]",children:t.jsx("div",{className:"px-5 py-6 md:px-8",children:t.jsx(Td,{graph:e.graph,marks:d,onSelect:v=>c(h=>h&&h.path===v.path&&(h.item??null)===v.item?null:v),label:"The run's workflow graph"})})}),i&&t.jsx("div",{className:"flex min-h-0 shrink-0 flex-col border-t lg:w-[460px] lg:border-l lg:border-t-0",children:t.jsx(B7,{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(Rd,{run:!0})})]})}function sB({data:e,readAt:n,now:s,actions:r,stale:o}){const i=wd(e.run.status),c=e.graph.nodes.find(y=>{var v,h;return y.kind==="map"&&((h=(v=e.nodes[y.path])==null?void 0:v.items)==null?void 0:h.length)}),d=c?L2(e.nodes[c.path].items):null,{usd:u,unknown:f}=M2(e),g=[["Elapsed",pl(KM(e,n,s))],["Cost",t.jsxs(t.Fragment,{children:[Rl(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",oB(e),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return d&&g.push(["Items",t.jsxs(t.Fragment,{children:[t.jsx("span",{children:d.done}),t.jsxs("span",{className:"text-muted-foreground",children:["/",d.total]}),d.failed>0&&t.jsxs("span",{className:"ml-2 text-label text-destructive-text",children:[d.failed," failed"]}),d.review>0&&t.jsxs("span",{className:"ml-2 text-label text-warning-text",children:[d.review," review"]})]})]),t.jsxs("div",{className:"flex flex-wrap items-stretch border-b",children:[e.run.paused&&t.jsx("div",{className:"flex items-center pl-5 md:pl-8",children:t.jsxs(Se,{tone:"warning",children:[t.jsx(il,{className:"size-3","aria-hidden":!0})," Paused"]})}),g.map(([y,v,h],x)=>t.jsxs("div",{className:ae("px-4 py-2",x?"border-l":"pl-5 md:pl-8"),title:h,children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:y}),t.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:v})]},y)),t.jsxs("div",{className:"flex flex-1 items-center justify-end gap-3 px-5 py-2 md:px-8",children:[o>0&&t.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",pl(o)," ago, reading again"]}),!i&&(e.run.paused?t.jsxs(B,{size:"sm",variant:"solid",onClick:r.onResume,disabled:!r.onResume||!!r.busy,children:[t.jsx(Jo,{"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(il,{"aria-hidden":!0})," ",r.busy==="pause"?"Pausing":"Pause"]}))]})]})}const rB=new Set(["agent","decide","extract","report","artifact"]),oB=e=>e.graph.nodes.filter(n=>{var s;return rB.has(n.kind)&&!["pending","not_run"].includes(((s=e.nodes[n.path])==null?void 0:s.status)??"pending")}).length;function aB({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 iB(e,n){return!n||e.state==="loading"?{messages:Gm,steers:!1}:e.state==="failed"?{messages:n.features.messages,steers:!1}:{messages:n.features.messages,steers:cP(e.id,n.harnesses)}}async function lB(e,n){try{let s=null;do{const r=await e.listRevisions(n.agent_id,s),o=r.revisions.find(c=>c.revision===n.revision),i=o==null?void 0:o.definition.output_schema;if(o)return{state:"read",id:o.definition.harness,...i?{outputSchema:i}:{}};s=r.next_cursor}while(s)}catch{}return{state:"failed"}}const CN=new Set(["completed","failed","cancelled"]),cB={firstMs:2e3,maxMs:16e3,totalMs:12e4};function dB(e,n,s,r=cB){var g;const o=!!e&&CN.has(e.status)&&Zm(e.learning),i=p.useRef(n);i.current=n;const c=p.useRef(s);c.current=s;const d=(g=e==null?void 0:e.learning)==null?void 0:g.state,u=!!e&&CN.has(e.status),f=p.useRef(d);p.useEffect(()=>{var v;const y=f.current;f.current=d,y!==void 0&&y!==d&&u&&((v=c.current)==null||v.call(c))},[d,u]),p.useEffect(()=>{if(!o)return;let y,v=0,h=r.firstMs,x=!1,b=!1;const j=()=>{b||v+h>r.totalMs||(y=setTimeout(k,h))},k=()=>{if(y=void 0,document.visibilityState==="hidden"){x=!0;return}v+=h,h=Math.min(h*2,r.maxMs),i.current(),j()},E=()=>{x&&document.visibilityState!=="hidden"&&(x=!1,k())};return document.addEventListener("visibilitychange",E),j(),()=>{b=!0,y&&clearTimeout(y),document.removeEventListener("visibilitychange",E)}},[o])}const EN=new Set(["completed","failed","cancelled"]),uB=e=>{const n=M2(e);return`${Rl(n.usd)}${n.unknown?` + ${n.unknown} unknown`:""}`},fB=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},Hi=e=>({api:fB(e),title:SM(e),cause:e}),mB=3e3;function $N({v2:e,runId:n,caps:s,agentName:r}){var se;const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[g,y]=p.useState([]),[v,h]=p.useState(null),[x,b]=p.useState(null),[j,k]=p.useState(0),E=p.useRef(""),S=p.useRef(z2()).current,N=p.useRef(Js()).current,$=p.useRef(0),_=p.useRef(""),[O,L]=p.useState({state:"loading"});p.useEffect(()=>{o&&O.state==="loading"&&lB(e,o).then(L)},[o==null?void 0:o.revision]);const P=iB(O,s);dB(o,()=>R(),()=>k(J=>J+1));const R=async()=>{const J=S.begin();try{const[re,ne]=await Promise.all([e.getRun(n),e.listFiles(n)]);S.current(J)&&(i(re),y(ne.files))}catch(re){S.current(J)&&h(Hi(re))}};p.useEffect(()=>{R()},[n]),h$(()=>{R()});const A=((se=o==null?void 0:o.recordings)==null?void 0:se.some(J=>!J.finished))===!0;p.useEffect(()=>{if(!A)return;const J=setInterval(()=>{R()},mB);return()=>clearInterval(J)},[A,n]),p.useEffect(()=>{const J=new AbortController;return d(null),b2(e,n,{signal:J.signal,onRows:re=>{f(re);const ne=re.filter(ve=>ve.kind===x$).map(ve=>`${ve.id}\0${ve.summary}`).join("");ne!==_.current&&(_.current=ne,R());const me=re.filter(ve=>ve.kind==="tool_result").length;me>$.current&&($.current=me,R())},onPage:re=>{re.cost&&d(re.cost);const ne=`${re.status}/${re.state}`;(ne!==E.current||re.status==="input_required"&&!re.unchanged)&&(E.current=ne,R())}}).catch(re=>{J.signal.aborted||h(Hi(re))}),()=>J.abort()},[n,j]);const M=async J=>{b(J);try{await e[J](n),h(null)}catch(re){h(Hi(re))}b(null),await R(),k(re=>re+1)},F=async()=>{if(o){b("archive");try{const J=await(o.archived_at?e.unarchiveRun(n):e.archiveRun(n));i(re=>re?{...re,archived_at:J.archived_at}:J),h(null)}catch(J){h(Hi(J))}b(null),R()}},I=async J=>{const re=await J();return await R(),k(ne=>ne+1),re},q=J=>I(()=>e.raiseCap(n,J)),W=J=>I(()=>e.gradeRun(n,J)),K=async J=>{let re=!0;try{await IC(N,n,J,e.sendMessage),h(null)}catch(ne){h(Hi(ne)),re=!1}return await R(),k(ne=>ne+1),re},U=async(J,re,ne,me)=>{let ve=null;try{await e.answerApproval(n,J,re,ne,me)}catch(je){ve=v$(je)}return await R(),k(je=>je+1),ve},H=async J=>{try{return await J()}finally{R(),k(re=>re+1)}},G=tB(J=>e.getRunGraph(n,J),{key:n,enabled:(o==null?void 0:o.kind)==="workflow"}),z=!G.data&&H$(G.error);if(!o)return v?v.cause instanceof Ue&&v.cause.status===404?t.jsx(j2,{what:"run",id:n,list:{href:"#/runs",label:"Open the runs list"}}):t.jsx(Jt,{problem:Ht(v.cause,"the run"),onRetry:()=>{h(null),R(),k(J=>J+1)}}):t.jsx(yM,{});const V=c&&!EN.has(o.status)?{...o,cost:c}:o;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[v&&t.jsx("div",{className:"border-b p-3",children:t.jsx(aa,{title:v.title,error:v.api})}),t.jsx(U7,{run:V,agentName:r(o.agent_id),messages:P.messages,harnessSteers:P.steers,graphView:o.kind==="workflow"&&!z?t.jsx(hB,{v2:e,runId:n,graph:G,onMoved:()=>{R()}}):void 0,costText:o.kind==="workflow"&&!EN.has(o.status)&&G.data?uB(G.data):void 0,outputSchema:O.state==="read"?O.outputSchema:void 0,rows:u,files:g,readFile:J=>e.readFile(n,J.path),fileUrl:J=>e.fileUrl(n,J),readLearningDiff:()=>e.runLearningDiff(n),readLearning:()=>e.runLearning(n),readLearningResult:()=>e.runLearningResult(n),readComputer:()=>e.runComputer(n),onTakeOver:()=>H(()=>e.takeOverComputer(n)),onHandBack:J=>H(()=>e.handBackComputer(n,J)),readComputers:()=>e.computers(),onMessage:K,onApprove:U,onGrade:W,actions:{onStop:()=>void M("stop"),onCancel:()=>void M("cancel"),onArchive:()=>void F(),onRaiseCap:q,busy:x}},o.run_id)]})}function hB({v2:e,runId:n,graph:s,onMoved:r}){const{data:o,error:i,readAt:c,reload:d}=s,[u,f]=p.useState(null),[g,y]=p.useState(null),[v,h]=p.useState(null),x=async j=>{f(j);try{const k=await(j==="pause"?e.pauseRun(n):e.resumeRun(n));h({paused:k.paused,status:k.status,at:Date.now()}),y(null)}catch(k){y(Hi(k))}f(null),d(),r()},b=o&&v&&c<v.at?{...o,run:{...o.run,paused:v.paused,...v.status?{status:v.status}:{}}}:o;return b?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[g&&t.jsx("div",{className:"border-b p-3",children:t.jsx(aa,{title:g.title,error:g.api})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(nB,{data:b,lastRead:c,fileUrl:j=>e.fileUrl(n,j),actions:{onPause:()=>void x("pause"),onResume:()=>void x("resume"),busy:u}})})]}):t.jsx(aB,{error:i})}function _N({actions:e,children:n}){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:ae(pr,"flex-wrap justify-between gap-2 px-5 md:px-6"),children:[t.jsxs("h1",{className:Bo,children:[t.jsx(qN,{className:"size-4","aria-hidden":!0}),"Mission Control"]}),e&&t.jsx("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:e})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n})]})}function pB({view:e,error:n,onRetry:s,scope:r,needsYou:o,asking:i,failed:c,live:d,startHere:u,actions:f,observations:g,hasObservedSessions:y=!1}){if(!e)return t.jsx(_N,{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(Jt,{problem:n,onRetry:s}):t.jsx(bM,{}),g]})});const v=b=>{var j;return((j=e.perAgent.find(k=>k.agentId===b))==null?void 0:j.name)??b},h=r!=null&&r.agent?e.perAgent.filter(b=>b.agentId===r.agent):e.perAgent,x=[["Agents",String(e.agents),"#/agents"],["Runs",String(e.runs.total),"#/runs"],["Active",String(e.runs.active),void 0,void 0,[typeof d=="number"&&d!==e.runs.active?`${d} running now`:"",e.runs.statusUnknown?`${e.runs.statusUnknown} unknown`:""].filter(Boolean).join(" · ")||void 0],["Needs input",i===null?"–":String(i??e.runs.needsInput),"#/runs?status=input_required",i??e.runs.needsInput?"text-warning-text":void 0],c===void 0?["Failed",String(e.runs.failed),"#/runs?status=failed",e.runs.failed?"text-destructive-text":void 0,TN(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}`,TN(e.runs.needsReview)??""].filter(Boolean).join(" · ")]];return t.jsx(_N,{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(Jt,{problem:n,onRetry:s,className:""}),u,o,t.jsxs("section",{className:"space-y-4","aria-label":y?"Registered agents and runs":void 0,children:[y&&t.jsx("h2",{className:"text-lead font-semibold",children:"Registered agents & runs"}),t.jsx("ul",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:x.map(([b,j,k,E,S])=>{const N=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:b}),t.jsx("p",{className:ae("mt-3 font-mono text-display leading-none",E),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})},b)})})]}),g,t.jsxs("section",{className:"space-y-4","aria-label":"Analytics",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-6 gap-y-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Activity & usage"}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:gB(e)})]}),r&&t.jsx(E2,{range:r.range,onRange:r.onRange,agent:r.agent,agents:e.perAgent,onAgent:r.onAgent})]}),t.jsx($2,{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(Hc,{className:"size-4","aria-hidden":!0}),"Runs per agent"]}),h.length?t.jsx("ul",{children:h.map(b=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:dn(b.agentId,"runs"),className:"flex items-center justify-between gap-3 px-4 py-3 text-lead hover:bg-accent",children:[t.jsx("span",{className:"min-w-0 truncate",children:b.name}),t.jsx("span",{className:"font-mono text-body text-muted-foreground",children:b.runs})]})},b.agentId))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No agents yet."})]}),t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsxs("h2",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:[t.jsx(dd,{className:"size-4","aria-hidden":!0}),"Recent runs"]}),e.recent.length?t.jsx("ul",{children:e.recent.map(b=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(b.run_id)}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-accent",children:[t.jsx(Al,{run:b}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-lead",children:En(b)}),t.jsx(hb,{run:b,className:"hidden sm:inline-flex"}),tW(b)&&t.jsx("span",{className:"shrink-0 text-small text-muted-foreground",children:"send a message to continue"})]}),t.jsx("span",{className:"hidden shrink-0 text-body text-muted-foreground md:inline",children:v(b.agent_id)}),b.ended_at&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",title:"How long it ran",children:pl(Date.parse(b.ended_at)-Date.parse(b.created_at))}),b.cost&&(b.cost.usd!==null||_l(b.cost))&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:ro(b.cost,{ended:Va(b.status)})}),t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:ft(b.created_at)})]})},b.run_id))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs yet."})]})]})]})})}const TN=e=>e?`${e} ${e===1?"needs":"need"} review`:void 0;function gB(e,n=Date.now()){var i;const s=e.analytics.filter,r=s.from?Math.round((Math.floor(n/864e5)*864e5-Date.parse(s.from))/864e5)+1:null,o=s.from?zv.some(c=>c.days===r)?`Runs started in the last ${r} days`:`Runs started since ${s.from.slice(0,10)}`:"All runs";return s.agent?`${o}, of ${((i=e.perAgent.find(c=>c.agentId===s.agent))==null?void 0:i.name)??s.agent}`:o}const gs=e=>`#/runs/${encodeURIComponent(e)}`;function xB({asking:e,failed:n,failedAll:s,live:r,learning:o=[],agentName:i,onAnswer:c,onApprove:d,onHandBack:u,onRunAgain:f,onStop:g,problem:y,now:v=Date.now}){const h=QU(n.filter(A=>!ns(A))),x=n.filter(A=>!A.imported_from&&ns(A)),[,b]=p.useState(0);p.useEffect(()=>{if(!r.length)return;const A=setInterval(()=>b(M=>M+1),1e3);return()=>clearInterval(A)},[r.length]);const[j,k]=p.useState([]),E=(A,M,F)=>{const I=e.find(W=>W.run_id===A),q=I?En(I):A;k(W=>[...W.filter(K=>K.runId!==A),...F?[{runId:A,what:M,title:q,text:F}]:[]])},S=d&&(async(A,M,F,I,q)=>{const W=await(q?d(A,M,F,I,q):d(A,M,F,I));return E(A,M,W),W}),N=u&&(async(A,M,F)=>{const I=await u(A,F);return E(A,`ask:${M.asked_at}`,I),I}),$=A=>{var F;const M=Vi(A);return((F=A.pending)==null?void 0:F.kind)==="approval"?A.pending.id:M?`ask:${M.asked_at}`:null},_=u$(n),O=o.filter(A=>A.pending>0),L=O.reduce((A,M)=>A+M.pending,0),P=e.length+_+L;if(!P&&!r.length&&!y&&!j.length)return null;const R=v();return t.jsxs("section",{"aria-label":"Needs you",className:"space-y-3",children:[P>0&&t.jsxs("h2",{className:"caps text-small font-semibold",children:["Needs you ",t.jsxs("span",{className:"text-warning-text",children:["· ",P]})]}),y&&t.jsx("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:y}),j.filter(A=>!e.some(M=>M.run_id===A.runId&&$(M)===A.what)).map(A=>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:gs(A.runId),className:"underline-offset-4 hover:underline",children:A.title}),": your answer wasn't taken. ",A.text]}),t.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>k(M=>M.filter(F=>F.runId!==A.runId)),children:"Dismiss"})]},A.runId)),e.length>0&&t.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(A=>{var M,F,I;return A.native?t.jsxs("li",{className:"space-y-2 border p-4",children:[t.jsx("a",{href:gs(A.run_id),className:"text-body underline underline-offset-2",children:En(A)}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native sessions cannot receive another message. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(A.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," to continue."]})]},A.run_id):((M=A.pending)==null?void 0:M.kind)==="approval"?t.jsx(vB,{run:A,pending:A.pending,agentName:i(A.agent_id),at:R,onApprove:S},`${A.run_id}:${A.pending.id}`):Vi(A)?t.jsx(bB,{run:A,ask:Vi(A),agentName:i(A.agent_id),at:R,onHandBack:N},`${A.run_id}:${Vi(A).asked_at}`):t.jsx(yB,{run:A,agentName:i(A.agent_id),at:R,onAnswer:c},`${A.run_id}:${((F=A.pending)==null?void 0:F.kind)==="question"?A.pending.asked_at:((I=A.pending)==null?void 0:I.kind)==="budget"?A.pending.at??"":""}`)})}),(h.length>0||x.length>0)&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps flex items-center justify-between gap-3 border-b px-4 py-2.5 text-label text-muted-foreground",children:[t.jsxs("span",{children:["Failed in the last 24 h · ",_]}),t.jsx("a",{href:"#/runs?status=failed",className:"-my-1 py-1 normal-case tracking-normal hover:text-foreground",children:s===void 0?"All failed runs →":`All ${s} failed ${s===1?"run":"runs"} →`})]}),t.jsxs("ul",{children:[h.map(A=>t.jsx(kB,{message:A.message,runs:A.runs,agentName:i,at:R,onRunAgain:f},A.message)),x.map(A=>t.jsx(RN,{run:A,agentName:i(A.agent_id)},A.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 · ",L]}),t.jsx("ul",{children:O.map(A=>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:A.name}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:fb(A.pending)}),t.jsx("a",{href:`#/agents/${encodeURIComponent(A.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},A.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(A=>ns(A)?t.jsx(RN,{run:A,agentName:i(A.agent_id)},A.run_id):t.jsx(NB,{run:A,agentName:i(A.agent_id),at:R,onStop:g},A.run_id))})]})]})}function vB({run:e,pending:n,agentName:s,at:r,onApprove:o}){return t.jsx("li",{"data-run":e.run_id,className:"min-w-0",children:t.jsx(b$,{compact:!0,pending:n,heading:t.jsx(qb,{run:e,agentName:s,since:`asked ${Ml(n.requested_at,r)} ago`}),onAnswer:(i,c,d)=>o?d?o(e.run_id,n.id,i,c,d):o(e.run_id,n.id,i,c):Promise.resolve("Open the run to answer it.")})})}function bB({run:e,ask:n,agentName:s,at:r,onHandBack:o}){return t.jsx("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5",children:t.jsx(E$,{compact:!0,ask:n,heading:t.jsx(qb,{run:e,agentName:s,since:`asked ${Ml(n.asked_at,r)} ago`}),open:t.jsx("a",{href:gs(e.run_id),className:"text-body underline underline-offset-2",children:"Open its screen"}),onAnswer:o&&(i=>o(e.run_id,n,i))})})}function yB(e){var n;return((n=e.run.pending)==null?void 0:n.kind)==="budget"?t.jsx(wB,{run:e.run,pending:e.run.pending,agentName:e.agentName}):t.jsx(jB,{...e})}function wB({run:e,pending:n,agentName:s}){return t.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[t.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:s}),t.jsx("a",{href:gs(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:En(e)})]}),t.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:y$(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:gs(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})})]})}function qb({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:gs(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:En(e)}),s&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:s})]})}function jB({run:e,agentName:n,at:s,onAnswer:r}){var j;const o=((j=e.pending)==null?void 0:j.kind)==="question"?e.pending:null,i=(o==null?void 0:o.question)??"",c=YU(i),[d,u]=p.useState(""),[f,g]=p.useState(!1),[y,v]=p.useState(null),[h,x]=p.useState(null),b=async k=>{k.preventDefault();const E=d.trim();if(!E||f)return;g(!0),v(null);const S=await r(e.run_id,E);g(!1),S?v(S):x(E)};return t.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[t.jsx(qb,{run:e,agentName:n,since:o!=null&&o.asked_at?`asked ${Ml(o.asked_at,s)} ago`:void 0}),t.jsx("p",{className:"mt-2 text-base leading-snug",children:i}),h?t.jsxs("p",{className:"mt-3 font-mono text-body text-success-text",children:["Answered: ",h," · ",t.jsx("a",{href:gs(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})]}):t.jsxs("form",{onSubmit:k=>void b(k),className:"mt-3 flex flex-wrap items-center gap-2",children:[c.map(k=>t.jsx("button",{type:"button",onClick:()=>u(k),className: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(Pe,{value:d,onChange:k=>u(k.target.value),"aria-label":`Answer ${n}`,placeholder:c.length?"Or type an answer…":"Type an answer…",className:"h-9 min-w-[9rem] flex-1 font-sans text-lead"}),t.jsx(B,{type:"submit",variant:"solid",size:"sm",disabled:f||!d.trim(),children:f?"Sending…":"Send"}),y&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:y})]})]})}function kB({message:e,runs:n,agentName:s,at:r,onRunAgain:o}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),[f,g]=p.useState(new Set),y=n.filter(k=>!f.has(k.run_id)),v=n.length-y.length,h=async()=>{c(!0),u(null);const{started:k,problem:E}=await o(y);c(!1),u(E),g(S=>new Set([...S,...k]))},x=v>0&&t.jsxs("span",{className:"font-mono text-small text-success-text",children:["Started again: ",v===1?"1 run":`${v} runs`]});if(!y.length)return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-border-strong","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 truncate font-mono text-small text-muted-foreground",children:e}),x]});const b=y[0],j=y.length===1;return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-destructive","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[j?t.jsxs("p",{className:"flex min-w-0 gap-3 text-lead",children:[t.jsx("span",{className:"shrink-0 font-mono text-small leading-5",children:s(b.agent_id)}),t.jsx("a",{href:gs(b.run_id),className:"min-w-0 truncate hover:underline",children:En(b)})]}):t.jsxs("p",{className:"text-lead",children:[y.length," runs failed ",t.jsxs("span",{className:"text-muted-foreground",children:["· ",[...new Set(y.map(k=>s(k.agent_id)))].join(", ")]})]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-small text-destructive-text",children:e}),!j&&t.jsxs("details",{className:"mt-1 text-body",children:[t.jsx("summary",{className:"cursor-pointer font-mono text-small text-muted-foreground",children:"The runs"}),t.jsx("ul",{className:"mt-1 space-y-1",children:y.map(k=>t.jsxs("li",{children:[t.jsx("a",{href:gs(k.run_id),className:"hover:underline",children:En(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:[Ml(b.ended_at??b.created_at,r)," ago"]}),x,t.jsx(B,{type:"button",size:"sm",disabled:i,onClick:()=>void h(),children:j?"Run again":"Run all again"})]})}function RN({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," · ",Qo(ns(e).runtime)]}),t.jsx("a",{href:gs(e.run_id),className:"text-lead hover:underline",children:En(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:gs(e.run_id),className:"caps shrink-0 text-small text-muted-foreground hover:text-foreground",children:"Open"})]})}function NB({run:e,agentName:n,at:s,onStop:r}){var g;const[o,i]=p.useState(!1),[c,d]=p.useState(null),u=(g=e.cost)==null?void 0:g.usd,f=yd(e.cost)?`${ro(e.cost)} so far`:u===0?"nothing spent yet":typeof u=="number"?`${ro(e.cost)} so far`:_l(e.cost)?ro(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:gs(e.run_id),className:"min-w-0 flex-1 truncate text-lead hover:underline",children:En(e)}),t.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",pl(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:gs(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Steer"}),qm(e.status,e.state,e.kind,Gm,!0,e.error,e.review).canStop?t.jsx(B,{type:"button",size:"sm",disabled:o,onClick:async()=>{i(!0),d(await r(e.run_id)),i(!1)},children:"Stop"}):t.jsx("a",{href:gs(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 SB=[{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 B$(e){var r;const n=["pi","claude-agent","codex"],s=e.filter(o=>o.available&&o.default_model);return s.sort((o,i)=>(n.indexOf(o.id)+1||99)-(n.indexOf(i.id)+1||99)),((r=s[0])==null?void 0:r.id)??null}function CB(e,n,s){const r=Km(n,[...s]).filter(i=>i.available).map(i=>i.name),o=e.tools.find(i=>!r.includes(i));return o?{ok:!1,reason:`${o} can't run on this server yet`}:{ok:!0}}async function EB(e,n,s,r=Js()){const i=(await Qr(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 G$="agentrun.console.start-here.dismissed",$B={hello:Za,web:GN,plan:ZT};function _B(){try{return localStorage.getItem(G$)==="true"}catch{return!1}}function TB({harnesses:e,tools:n,onTry:s,imported:r=0,keySettings:o=!1,importAction:i,modelSetup:c}){const[d,u]=p.useState(_B),[f,g]=p.useState(!1),[y,v]=p.useState(!1),[h,x]=p.useState(null),[b,j]=p.useState(null),k=B$(e),E=async S=>{x(S.id),j(null);try{j(await s(S))}finally{x(null)}};return d?null:t.jsxs("section",{"aria-label":"Start here",className:"border bg-card p-5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-base font-semibold",children:"Bring your agents into view"}),t.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:"Connect your Claude Code or Codex setup on this server or another machine. Your coding agent helps choose a live connection or a history import. No model key needed to connect."}),r>0&&t.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:[r," imported ",r===1?"session":"sessions"," · ",t.jsx("a",{href:"#/runs",className:"text-primary-text underline-offset-4 hover:underline",children:"Browse history"})]})]}),t.jsx("button",{type:"button","aria-label":"Dismiss introduction",className:"shrink-0 p-1 text-muted-foreground hover:bg-accent hover:text-foreground",onClick:()=>{u(!0);try{localStorage.setItem(G$,"true")}catch{}},children:t.jsx(Zo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[t.jsx(sh,{}),i,t.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-body text-muted-foreground hover:text-foreground","aria-expanded":f,onClick:()=>{v(!0),g(S=>!S)},children:["Run an agent here ",t.jsx(Mr,{className:`size-3.5 transition-transform ${f?"rotate-180":""}`,"aria-hidden":!0})]})]}),y&&t.jsxs("div",{hidden:!f,className:"mt-4 border-t pt-4",children:[c,k?t.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:SB.map(S=>{const N=CB(S,k,n),$=$B[S.id]??Za;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",size:"sm",className:"mt-4 self-start",disabled:h!==null,onClick:()=>void E(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. ",o?t.jsx("a",{href:"#/settings/keys",className:"text-primary-text underline-offset-4 hover:underline",children:"Set up models in Settings"}):"Configure a model where this server runs, then return here."]}),t.jsxs("p",{className:"mt-3 text-body text-muted-foreground",children:["Or ",t.jsx("a",{href:"#/agents/new",className:"text-primary-text underline-offset-4 hover:underline",children:"Create your own"}),": name it, say what it does, pick its tools."]}),b&&t.jsx("p",{className:"mt-3 font-mono text-body text-destructive-text",role:"alert",children:b})]})]})}const RB=["system","light","dark"],Kx="agentrun.theme",AB="(prefers-color-scheme: dark)",ph=()=>{try{return globalThis.localStorage??null}catch{return null}},q$=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(AB):null;let Vx=null;function OB(e=ph()){try{const n=e==null?void 0:e.getItem(Kx);return n==="light"||n==="dark"?n:"system"}catch{return"system"}}const Yx=(e=ph())=>Vx??OB(e);function LB(e,n=ph()){Vx=null;try{e==="system"?n==null||n.removeItem(Kx):n==null||n.setItem(Kx,e)}catch{Vx=e}}function Qx(e,n=document.documentElement,s=q$()){const r=e==="dark"||e==="system"&&!!(s!=null&&s.matches);n.classList.toggle("dark",r),n.classList.toggle("light",!r)}function MB(e=document.documentElement,n=q$(),s=ph()){Qx(Yx(s),e,n);const r=()=>{Yx(s)==="system"&&Qx("system",e,n)};return n==null||n.addEventListener("change",r),()=>n==null?void 0:n.removeEventListener("change",r)}const PB={mission:"Mission Control",playground:"Playground",agents:"Agents",runs:"Runs",dojo:"Dojo",templates:"Templates",triggers:"Triggers",settings:"Settings"},IB={mission:"#/",playground:"#/playground",agents:"#/agents",runs:"#/runs",dojo:"#/dojo",templates:"#/templates",triggers:"#/triggers",settings:"#/settings/keys"},zB={system:["System",ei],light:["Light",pR],dark:["Dark",iR]};function DB(){const[e,n]=p.useState(()=>Yx()),s=r=>{LB(r),Qx(r),n(r)};return t.jsx("div",{role:"group","aria-label":"Theme",className:"flex gap-1 border p-1",children:RB.map(r=>{const[o,i]=zB[r];return t.jsx(B,{variant:"ghost",size:"sm","aria-label":o,title:o,"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 AN(){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 FB({active:e,settings:n=!1,triggers:s=!1,banners:r,building:o=!1,onBuild:i,onNavigate:c,onSignOut:d,onSignOutEverywhere:u,children:f}){const[g,y]=p.useState(!1),[v,h]=p.useState(!1),x=p.useRef(null),b=p.useRef(null),j=p.useRef(!1);p.useEffect(()=>{var P,R;v?(P=b.current)==null||P.focus():j.current&&((R=x.current)==null||R.focus())},[v]);const k=()=>{j.current=!0,h(!1)},[E,S]=p.useState(!0),N=e==="agents"||e==="runs"||e==="templates";p.useEffect(()=>{(N||o)&&S(!0)},[e,o]);const $=P=>{c?c(P):location.hash=IB[P],y(!1)},_=()=>{i?i():location.hash="#/agents/new",y(!1)},O=PB[e];p.useEffect(()=>{document.title=O?`${O} · AgentRun`:"AgentRun"},[O]);const L=p.useRef(null);return t.jsxs("div",{className:"relative flex h-dvh min-h-0 flex-col overflow-hidden bg-background text-foreground roomy:flex-row",children:[t.jsx(B,{type:"button",size:"sm",onClick:()=>{var P;return(P=L.current)==null?void 0:P.focus()},className:"sr-only focus-visible:not-sr-only focus-visible:absolute focus-visible:left-2 focus-visible:top-2 focus-visible:z-toast focus-visible:inline-flex focus-visible:bg-card focus-visible:px-3",children:"Skip to the page"}),t.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b px-4 roomy:hidden",children:[t.jsx("button",{type:"button",onClick:()=>$("mission"),"aria-label":"AgentRun home",children:t.jsx(AN,{})}),t.jsx(B,{size:"icon","aria-label":"Navigation","aria-expanded":g,onClick:()=>y(P=>!P),children:t.jsx(rR,{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",g?"flex max-h-[60dvh] overflow-y-auto border-b roomy:max-h-none":"hidden"),children:[t.jsx("div",{className:"hidden h-12 shrink-0 items-center border-b px-4 roomy:flex",children:t.jsx("button",{type:"button",onClick:()=>$("mission"),"aria-label":"AgentRun home",children:t.jsx(AN,{})})}),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(jr,{className:"w-full",active:e==="mission",onClick:()=>$("mission"),children:[t.jsx(qN,{className:"size-4 shrink-0","aria-hidden":!0}),"Mission Control"]}),t.jsxs(jr,{className:"w-full",active:e==="playground",onClick:()=>$("playground"),children:[t.jsx(xm,{className:"size-4 shrink-0","aria-hidden":!0}),"API playground"]}),t.jsxs("div",{children:[t.jsxs(jr,{className:ae("w-full",N&&"text-primary-text"),"aria-expanded":E,"aria-controls":"agent-navigation",onClick:()=>S(P=>!P),children:[t.jsx(Hc,{className:"size-4 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"flex-1",children:"Agents"}),t.jsx(Mr,{className:ae("size-3.5 transition-transform",!E&&"-rotate-90"),"aria-hidden":!0})]}),t.jsxs("div",{id:"agent-navigation",hidden:!E,className:"space-y-0.5",children:[t.jsxs(jr,{className:"w-full pl-8",active:o,onClick:_,children:[t.jsx(QT,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Build"]}),t.jsxs(jr,{className:"w-full pl-8",active:e==="agents"&&!o,onClick:()=>$("agents"),children:[t.jsx(Hc,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Connected agents"]}),t.jsxs(jr,{className:"w-full pl-8",active:e==="templates",onClick:()=>$("templates"),children:[t.jsx(ym,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Templates"]}),t.jsxs(jr,{className:"w-full pl-8",active:e==="runs",onClick:()=>$("runs"),children:[t.jsx(dd,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Runs"]})]})]}),s&&t.jsxs(jr,{className:"w-full",active:e==="triggers",onClick:()=>$("triggers"),children:[t.jsx(cd,{className:"size-4 shrink-0","aria-hidden":!0}),"Triggers"]}),t.jsxs(jr,{className:"w-full",active:e==="dojo",onClick:()=>$("dojo"),children:[t.jsx(JC,{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(jr,{className:"w-full",active:e==="settings",onClick:()=>$("settings"),children:[t.jsx(YN,{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(DB,{}),t.jsxs(B,{onClick:d,className:"w-full justify-start",children:[t.jsx(tR,{"aria-hidden":!0}),"Sign out"]}),u&&(v?t.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:P=>{P.key==="Escape"&&k()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[t.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"xs",variant:"destructive",onClick:()=>{h(!1),u()},children:"Sign out everywhere"}),t.jsx(B,{size:"xs",ref:b,onClick:k,children:"Cancel"})]})]}):t.jsx(B,{size:"sm",variant:"ghost",ref:x,onClick:()=>h(!0),className:"mt-1 w-full justify-start text-muted-foreground hover:text-foreground",children:"Sign out everywhere"}))]})]}),t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx(uW,{}),r,t.jsx("main",{ref:L,tabIndex:-1,className:"relative min-h-0 min-w-0 flex-1 overflow-auto outline-none",children:f})]})]})}const K$=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.accounts)===!1};function UB(e,n){if(K$(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 WB=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.setup_code)===!0},V$=e=>/\.onrender\.com$/i.test(e),Y$=e=>/\.up\.railway\.app$/i.test(e);function HB(e){const n="find the newest line that starts “Set up this server:”. Open that line's link, or paste what follows code= here.";return V$(e)?["This server is on Render. In the Render dashboard, open this service's Environment tab and paste the value of AGENTRUN_TOKEN here.",`Or open the service's Logs tab and ${n}`,"A code works once and lasts 30 minutes. When it has run out, Get a new code below prints a fresh one in the Logs tab. AGENTRUN_TOKEN does not expire."]:Y$(e)?["This server is on Railway. In the Railway dashboard, open this service's Variables tab and paste the value of AGENTRUN_TOKEN here.",`Or open the Deploy Logs of the service's latest deployment and ${n}`,"A code works once and lasts 30 minutes. When it has run out, Get a new code below prints a fresh one in the Deploy Logs. AGENTRUN_TOKEN does not expire."]:[`The server printed it in its log: ${n}`,"The log is the terminal the server runs in. In Docker: docker logs <container>, or docker compose logs. On Render: the service's Logs tab.","A code works once and lasts 30 minutes. When it has run out, Get a new code below prints a fresh one in the log. The server's API token works here too and does not expire: AGENTRUN_TOKEN (on Render, in the service's Environment tab), else the .token file in the server's data folder."]}function BB(e,n){const r=`it is the newest “Set up this server:” line in ${V$(e)?"the service's Logs tab in the Render dashboard":Y$(e)?"the Deploy Logs of the service's latest deployment in the Railway dashboard":"the server's log (the terminal it runs in, docker logs <container>, or Render's Logs tab)"}.`;return n.printed?`The server printed a new code: ${r} It works once, until ${qa(n.expires_at)}.`:`The current code is still good until ${qa(n.expires_at)}, so no new one was printed: ${r}`}const GB=e=>{const n=e.retryAfterMs===void 0?60:Math.max(1,Math.ceil(e.retryAfterMs/1e3));return`Try again in ${n===1?"a second":n>=60?"a minute":`${n} seconds`}.`};function qB(e){return e.status===403&&/has its owner/.test(e.message)?"This server has its owner already: sign in.":e.message}function KB(e){var n,s;return e.status===401?"That is not the password.":e.status===429?`Too many sign-ins. ${GB(e)}`:e.status===403&&/has its owner/.test(e.message)?"This server has its owner already: sign in.":e.status===403&&/a new one is in the server's log/.test(e.message)?"That setup code expired (a code lasts 30 minutes) or was voided after too many wrong tries. The server printed a new one: use the newest “Set up this server:” line in its log (on Render, the Logs tab).":e.status===403&&/takes the setup code/.test(e.message)?"Enter the setup code from the server's log.":e.status===403&&/setup code/.test(e.message)?"That setup code was refused: open the newest setup link in the server's log, or paste the server's token (AGENTRUN_TOKEN) here. A code works once and lasts 30 minutes: Get a new code prints a fresh one when it has run out.":((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message}function Q$(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 Dg={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},ON={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 VB({mode:e,code:n=null,codeNeeded:s=!1,onSubmit:r,onNewCode:o,problem:i=null,offer:c=null,host:d=typeof window>"u"?"":window.location.hostname}){const[u,f]=p.useState(""),[g,y]=p.useState([]),[v,h]=p.useState(""),[x,b]=p.useState(n??"");p.useEffect(()=>{n!==null&&b(n)},[n]);const[j,k]=p.useState(i),[E,S]=p.useState(!1),[N,$]=p.useState(null),[_,O]=p.useState(!1),L=async()=>{if(!(!o||_)){O(!0);try{$(await o()),k(null)}catch(I){$(null),k(I instanceof Error?I.message:String(I))}finally{O(!1)}}},P=e==="setup",R=P&&c!==null&&!("sessions"in c&&c.sessions===0),A=P&&(s||n!==null),M=e!=="token_link"&&u.length>0&&(!P||u===v&&u.length>=12)&&(!A||x.trim()!==""),F=async()=>{if(!M||!r)return;S(!0);const I=P&&c&&"candidates"in c?(c.candidates??[]).map(W=>W.id):[],q=await r(u,A&&x.trim()?x.trim():void 0,g.filter(W=>I.includes(W)));S(!1),k(q)};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(_s,{className:"size-5 text-primary-text","aria-hidden":!0}),t.jsxs("span",{children:["agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl font-semibold",children:ON[e].title}),t.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:ON[e].body}),e!=="token_link"&&t.jsxs("form",{className:"space-y-5",onSubmit:I=>{I.preventDefault(),F()},children:[A&&t.jsx(xt,{label:"Setup code",id:"setup-code",hint:HB(d).map((I,q)=>t.jsx("span",{className:ae("block leading-relaxed",q>0&&"mt-1.5"),children:I},q)),children:t.jsx(Pe,{name:"setup-code",value:x,onChange:I=>b(I.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),A&&o&&t.jsxs("div",{className:"!mt-3",children:[t.jsx(B,{type:"button",size:"sm",disabled:_,"aria-busy":_||void 0,onClick:()=>void L(),children:"Get a new code"}),N&&t.jsx("p",{className:"mt-2 text-small leading-relaxed text-foreground",role:"status",children:N})]}),t.jsx(xt,{label:Dg[e].label,note:P?"12 characters or more.":void 0,children:t.jsxs("span",{className:ae(fl,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Da,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,type:"password",value:u,onChange:I=>f(I.target.value),autoComplete:Dg[e].autocomplete,autoFocus:!0,"aria-label":Dg[e].label,className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),P&&t.jsx(xt,{label:"Again",note:v&&v!==u?"The two passwords differ.":void 0,children:t.jsxs("span",{className:ae(fl,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Da,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,type:"password",value:v,onChange:I=>h(I.target.value),autoComplete:"new-password","aria-label":"Password again",className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),R&&t.jsx(QB,{offer:c,chosen:g,onChange:y}),t.jsx(B,{type:"submit",variant:"solid",disabled:!M||E,"aria-busy":E||void 0,className:"w-full text-body",children:E?"Signing in":P?"Set password and continue":"Continue"}),j&&t.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:j}),!P&&t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:["Forgot it? Where the server runs: ",t.jsx("code",{className:"font-mono text-foreground",children:"npx @parcha/agentrun reset-password"})," (add"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data DIR"})," if you started it with one). For a server you started yourself:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"agentrun-serve reset-password --data DIR"})," (in the image:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data /data"}),"). The next visit here sets a new one."]})]})]})})}const $c=(e,n)=>`${e.toLocaleString("en-US")} ${n}${e===1?"":"s"}`,YB={"claude-code":"Claude Code",codex:"Codex",pi:"pi"},Fg="Import sessions from this machine";function QB({offer:e,chosen:n,onChange:s}){if("counting"in e)return t.jsx(xt,{group:!0,label:Fg,children:t.jsxs("p",{className:"flex items-center gap-2 text-small text-muted-foreground",role:"status",children:[t.jsx(GS,{}),"Looking for this machine's Claude Code, Codex and pi sessions…"]})});const r=e.candidates??[];if(e.sessions===null||e.projects===null||!r.length)return t.jsx(xt,{group:!0,label:Fg,children:t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:"This machine's sessions couldn't be listed, so there is nothing to choose here. To import them later, run agentrun-serve import with the server stopped."})});const o=r.filter(d=>n.includes(d.id)),i=o.length===r.length,c=Date.now();return t.jsx(xt,{group:!0,label:Fg,aside:t.jsx(B,{type:"button",size:"xs",variant:"ghost",onClick:()=>s(i?[]:r.map(d=>d.id)),children:i?"Clear":"Select all"}),note:`${$c(e.sessions,"session")} in ${$c(e.projects,"project")}, from Claude Code, Codex and pi. Tick the projects to import: each becomes an agent, each session a run you can read. Nothing is imported unless you tick it.${e.projects>r.length?` The ${r.length.toLocaleString("en-US")} most recently active are listed.`:""}`,hint:t.jsx("span",{"aria-live":"polite",children:o.length?`${$c(o.length,"project")}, ${$c(o.reduce((d,u)=>d+u.sessions,0),"session")} chosen.`:"None chosen: nothing will be imported."}),children:t.jsx("div",{className:"max-h-56 space-y-3 overflow-y-auto border p-3",children:r.map(d=>t.jsx(BS,{name:"import",value:d.id,checked:n.includes(d.id),onChange:u=>s(u.target.checked?[...n,d.id]:n.filter(f=>f!==d.id)),label:t.jsx("span",{className:"break-all font-mono",children:d.name}),note:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block",children:[$c(d.sessions,"session"),d.sources.map(u=>YB[u]??u).join(", "),...d.last_active?[`active ${Ml(d.last_active,c)} ago`]:[]].join(" · ")}),t.jsx("span",{className:"block break-all font-mono",children:d.path})]})},d.id))})})}function JB({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(_s,{className:"size-5 text-primary-text","aria-hidden":!0}),t.jsxs("span",{children:["agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl font-semibold",children:n?"This server is starting":"Can't read this server's sign-in"}),t.jsx("p",{className:"mb-4 text-prose leading-relaxed text-muted-foreground",children:n?"Its address answers for it until it is up (a first start, a redeploy or a wake can take a minute or two). Trying again…":"The page asked the server whether it has its owner yet, and got no answer it could read, so it can't show setup or sign-in. It asks again on its own."}),t.jsx("p",{className:"mb-6 break-words font-mono text-body text-destructive-text",role:"alert",children:e}),t.jsx(B,{type:"button",variant:"solid",onClick:s,className:"w-full text-body",children:"Retry now"})]})})}const XB=1e4;function LN(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 g=c.get("template");return{section:"playground",operation:u,...g?{template:g}:{},...f!==null?{draft:f}:{}}}return{section:"playground",...d?{playgroundAgent:d}:{},...u==="create-agent"||u==="edit-agent"||u==="list-runs"?{operation:u}:{},...f!==null?{draft:f}:{},...u==="list-runs"&&um.includes(c.get("status"))?{status:c.get("status")}:{},...u==="list-runs"&&c.get("archived")==="true"?{archived:!0}:{}}}if(s=e.match(/^#\/templates\/install\?(.*)$/),s)return{section:"templates",install:new URLSearchParams(s[1]).get("src")??""};if(s=e.match(/^#\/templates\/([^/?]+)$/),s)return{section:"templates",template:decodeURIComponent(s[1])};if(e.startsWith("#/templates"))return{section:"templates"};if(e==="#/triggers/new")return{section:"triggers",trigger:null,kind:"schedule"};if(e==="#/triggers/new-webhook")return{section:"triggers",trigger:null,kind:"webhook"};if(e==="#/triggers/new-github")return{section:"triggers",trigger:null,kind:"github"};if(e==="#/triggers/new-composio")return{section:"triggers",trigger:null,kind:"composio"};if(e==="#/triggers/new-feed")return{section:"triggers",trigger:null,kind:"feed"};if(s=e.match(/^#\/triggers\/([^/?]+)(\/edit)?$/),s)return{section:"triggers",trigger:decodeURIComponent(s[1]),...s[2]?{edit:!0}:{}};if(e.startsWith("#/triggers"))return{section:"triggers"};if(s=e.match(/^#\/settings\/mcp(?:\?(.*))?$/),s){const c=LI(s[1]);return{section:"settings",settings:"mcp",signIn:FI(s[1]),...c?{add:c}:{}}}if(s=e.match(/^#\/settings\/github(?:\?(.*))?$/),s){const c=pW(s[1]);return{section:"settings",settings:"github",...c?{github:c}:{}}}if(s=e.match(/^#\/settings(?:\/(keys|tools|email|computers|workspace|webhook))?$/),s)return{section:"settings",settings:s[1]??"keys"};if(e===""||e==="#"||e==="#/"||e.startsWith("#/start")||e.startsWith("#/mission"))return{section:"mission"};if(!e.startsWith("#/runs?"))return{section:"runs"};const r=new URLSearchParams(e.slice(7)),o=r.get("agent"),i=r.get("status");return{section:"runs",...o?{runsOf:o}:{},...i&&um.includes(i)?{status:i}:{},...r.get("archived")==="true"?{archived:!0}:{}}}function ZB({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 Ug;function eG(){if(!Ug){const{code:e,rest:n}=Q$(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${n}`),Ug={code:e}}return Ug.code}const tG=e=>Math.min(1e3*2**e,3e4),J$=1e3,nG=30;function sG(e){return e.state==="running"?"Importing this machine's sessions: agents appear as they arrive.":e.state==="stopped"?"The import of this machine's sessions stopped. It goes on when the server starts again.":e.state==="failed"?"The import of this machine's sessions was given up before it finished. The server's log says why.":`Imported ${`${e.runs.toLocaleString("en-US")} session${e.runs===1?"":"s"}`} into ${e.agents.toLocaleString("en-US")} agent${e.agents===1?"":"s"}${e.skipped?`; ${e.skipped.toLocaleString("en-US")} left out`:""}.`}function rG(){const[e]=p.useState(kM),[n,s]=p.useState(null),[r,o]=p.useState(!1),i=p.useRef(null);i.current=n;const c=p.useRef(!1),d=p.useRef(async()=>{}),u=p.useMemo(()=>lM({fetch:e.fetch,onSignedOut:()=>void d.current()}),[e]),[f,g]=p.useState(eG);p.useEffect(()=>{if(n!=="setup")return;const _=()=>{const{code:O,rest:L}=Q$(location.hash);O!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${L}`),g(O))};return window.addEventListener("hashchange",_),_(),()=>window.removeEventListener("hashchange",_)},[n]);const[y,v]=p.useState(!1),h=async()=>{const _=await u.session(),O=K$(_)?await u.listAgents().then(()=>200,L=>L instanceof Ue?L.status:0):void 0;return{mode:UB(_,O),codeNeeded:WB(_)}},x=async()=>{const _=await h();return v(_.codeNeeded),_.mode},b=async()=>s(await x());d.current=async()=>{if(!(i.current!=="signed_in"||c.current)){c.current=!0;try{const _=await x();_!=="signed_in"&&i.current==="signed_in"&&(o(!0),s(_))}catch{}finally{c.current=!1}}};const[j,k]=p.useState(null),[E,S]=p.useState(0);p.useEffect(()=>{let _=!0,O;return h().then(L=>{!_||i.current!==null||(v(L.codeNeeded),s(L.mode),k(null))},L=>{if(!_||i.current!==null)return;const P=tG(E),R=L instanceof Ue?L:null,A=(R==null?void 0:R.code)==="http_error",M=A&&[502,503,504].includes(R.status);k({problem:R===null?Wt(L):M?`Its address answered ${R.status}, not the server.`:`GET /v2/auth/session answered ${R.status}${A?", not as this server answers":`: ${R.message}`}`,starting:M}),O=setTimeout(()=>S(F=>F+1),P)}),()=>{_=!1,clearTimeout(O)}},[u,E]);const[N,$]=p.useState(null);return p.useEffect(()=>{if(n!=="setup")return;let _=!0;return(async()=>{for(let O=!1;_;){const L=await u.setupImport().then(P=>P,()=>{});if(!_)return;if(L===void 0&&O)return void $({projects:null,sessions:null});if(L!==void 0&&(!L||!("counting"in L||"sessions"in L)||($(L),O=!0,!("counting"in L))))return;await new Promise(P=>setTimeout(P,J$))}})(),()=>{_=!1}},[u,n]),n===null&&j!==null?t.jsx(JB,{problem:j.problem,starting:j.starting,onRetry:()=>S(_=>_+1)}):n===null?t.jsx(Z0,{connection:e,children:t.jsx(oG,{})}):n!=="signed_in"?t.jsx(VB,{mode:n,code:f,codeNeeded:y,offer:N,problem:r&&n==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async(_,O,L)=>{try{return await(n==="setup"?u.setup(_,O,L):u.signIn(_)),o(!1),s("signed_in"),null}catch(P){return P instanceof Ue&&P.status===403&&n==="setup"&&await b().catch(()=>{}),P instanceof Ue?KB(P):P instanceof Error?P.message:String(P)}},onNewCode:async()=>{try{return BB(window.location.hostname,await u.setupCode())}catch(_){throw _ instanceof Ue&&_.status===403&&await b().catch(()=>{}),new Error(_ instanceof Ue?qB(_):_ instanceof Error?_.message:String(_))}}},n):t.jsx(Z0,{connection:e,children:t.jsx(aG,{v2:u,onSignedOut:()=>{o(!1),s("sign_in")}})})}function oG(){return Ib().state==="offline"?t.jsx(fW,{}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function aG(e){const n=p.useMemo(Od,[e.v2]);return t.jsx(iG,{...e},n)}function iG({v2:e,onSignedOut:n}){var ia,ys,Fd,as,Ud,Wd,Hd,la,ca,uo,da,Bd,Gd,ci,Pl,di,fo,qd,ui,$t,Il,zl,fi,Dl,Fl,Ul,mi,ua,Zs,er,tr;const{writable:s,whyNot:r}=j6(e),[o,i]=p.useState(null),[c,d]=p.useState(()=>LN()),[u,f]=p.useState(null),g=((ys=(ia=u==null?void 0:u.features)==null?void 0:ia.triggers)==null?void 0:ys.routes)===!0,[y,v]=p.useState(new Map);p.useEffect(()=>{if(!g)return;let xe=!0;return e.listTriggers().then($e=>{xe&&v(new Map($e.triggers.map(Fe=>[Fe.id,{name:Fe.name,kind:Fe.source.kind}])))},()=>{}),()=>{xe=!1}},[e,g,c.section,c.trigger]);const[h,x]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(0),[S,N]=p.useState("30d"),$=S==="7d"?7:30,_=Mv(e,{active:c.section==="mission"||c.section==="runs"&&!c.run&&!c.runsOf&&!c.archived&&!c.status,days:$}),[O,L]=p.useState(null),[P,R]=p.useState(!1),A=p.useRef(!1),[M,F]=p.useState(null),[I,q]=p.useState(null),[W,K]=p.useState(null),[U,H]=p.useState(0),G=p.useRef(null),[z,V]=p.useState(!1),[se,J]=p.useState(!1),[re,ne]=p.useState(!1),[me,ve]=p.useState(null),[je,Ve]=p.useState(null),[de,Oe]=p.useState(!1),[ze,De]=p.useState({}),[Ne,Q]=p.useState(!1),be=p.useRef(0),[nt,fe]=p.useState([]),Le=p.useRef(-1),[Ye,ht]=p.useState(null),[ie,Ce]=p.useState(0),tt=p.useRef(0),Ie=xe=>{uf(xe)||(location.hash=xe)},[at,St]=p.useState(null),[st,ut]=p.useState(0);p.useEffect(()=>{let xe=!0;return(async()=>{let $e=!1;for(let Fe=0;xe&&Fe<nG;){const _t=await e.setupImport().then(kt=>kt,()=>{});if(!xe)return;if(_t===void 0)Fe+=1;else{if(Fe=0,!_t||!("state"in _t))return;if(St(_t),_t.state!=="running")return void($e&&ut(kt=>kt+1));$e=!0}await new Promise(kt=>setTimeout(kt,J$))}})(),()=>{xe=!1}},[e]),p.useEffect(()=>{const xe=()=>{const $e=y9();uf(location.hash,()=>{$e&&history.go(-$e)})?$e&&history.go($e):d(LN())};return window.addEventListener("hashchange",xe),()=>window.removeEventListener("hashchange",xe)},[]),p.useEffect(()=>b9(),[]);const Dt=p.useRef(0),Ft=p.useRef(!1),Rt=()=>{const xe=++Dt.current;return e.capabilities().then($e=>(xe===Dt.current&&f($e),!0),()=>!1)};p.useEffect(()=>{Rt()},[e]),p.useEffect(()=>{if(be.current&&c.section!=="runs"&&c.section!=="mission"&&Le.current===st)return;Le.current=st;const xe=++be.current;Q(!1),Promise.allSettled([!1,!0].map($e=>Qr(Fe=>e.listAgents({archived:$e,cursor:Fe}),Fe=>Fe.agents))).then($e=>{if(xe!==be.current)return;const Fe=Object.fromEntries($e.flatMap(kt=>kt.status==="fulfilled"?kt.value:[]).map(kt=>[kt.agent_id,kt.definition.name??kt.agent_id])),_t=$e.every(kt=>kt.status==="fulfilled");De(kt=>_t?Fe:{...kt,...Fe}),Q(_t)})},[e,c,st]);const pe={status:c.status,archived:c.archived};p.useEffect(()=>{if(c.section!=="runs"||c.run)return;const xe=++tt.current;ve(null),ht(null),(c.runsOf?e.listAgentRuns(c.runsOf,50,null,pe):e.listRuns(50,null,pe)).then($e=>{xe===tt.current&&(ve($e.runs),Ve($e.next_cursor))}).catch($e=>{xe===tt.current&&ht(Ht($e,"the runs"))})},[e,c,st,ie]);const he=xe=>{var $e;return ze[xe]??(($e=it==null?void 0:it.find(Fe=>Fe.agent_id===xe))==null?void 0:$e.definition.name)??(Ne?xe:"")},He=u,Je={harnesses:(He==null?void 0:He.harnesses)??[],tools:SP(He==null?void 0:He.tools),thinking:((Fd=He==null?void 0:He.features)==null?void 0:Fd.thinking)??[],...typeof((as=u==null?void 0:u.limits)==null?void 0:as.free_model_requests)=="number"?{freeRequests:u.limits.free_model_requests}:{}},X=QD(He==null?void 0:He.tools),ge=XD(He==null?void 0:He.tools),_e=[...(Wd=(Ud=u==null?void 0:u.features)==null?void 0:Ud.tool_keys)!=null&&Wd.routes?["keys"]:[],...X.length||ge.length?["tools"]:[],"mcp","github","email","computers","workspace",...(la=(Hd=u==null?void 0:u.features)==null?void 0:Hd.webhooks)!=null&&la.routes?["webhook"]:[]],Ae=xe=>Ie({runs:"#/runs",agents:"#/agents",playground:"#/playground",dojo:"#/dojo",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${_e[0]??"keys"}`}[xe]),We=p.useRef(Js()).current,gt=async xe=>{const $e=B$(Je.harnesses);if(!$e)return"This server has no model to run it on yet.";try{const Fe=await EB(e,xe,$e,We);return Ie(`#/runs/${encodeURIComponent(Fe)}`),null}catch(Fe){return Wt(Fe)}},jt=((h==null?void 0:h.analytics.by_source)??[]).filter(xe=>xe.source!=="live").reduce((xe,$e)=>xe+$e.runs,0),[it,Vt]=p.useState(null),[xs,Xs]=p.useState([]),[_n,Bn]=p.useState(null),vs=p.useRef(_n);vs.current=_n;const[bs,mn]=p.useState(null),[Gn,Rs]=p.useState(0),qn=p.useRef(0);p.useEffect(()=>{Vt(null),mn(null),Bn(null),vs.current=null},[e,c.section,c.operation,c.playgroundAgent]),p.useEffect(()=>{if(c.section!=="playground"||c.operation)return;mn(null);const xe=++qn.current;return Qr($e=>e.listAgents({cursor:$e}),$e=>$e.agents).then($e=>{var kt;if(xe!==qn.current)return;const Fe=$e.filter(is=>!is.archived_at),_t=vs.current??c.playgroundAgent;if(_t&&!Fe.some(is=>is.agent_id===_t)){Vt(null),Bn(null),mn("The selected agent is unavailable or archived. Choose another agent from Agents.");return}Vt($e),Bn(_t??((kt=Fe[0])==null?void 0:kt.agent_id)??null)}).catch($e=>{if(xe===qn.current){const Fe=Ht($e,"the agents");mn(`${Fe.why} ${Fe.next}${Fe.said?` (${Fe.said})`:""}`)}}),()=>{qn.current++}},[e,c.section,c.operation,c.playgroundAgent,Gn,st]),p.useEffect(()=>{if(c.section!=="mission")return;let xe=!0;A.current=!0,j(null),R(!0);const $e=Dv(S);return Promise.all([e.statsOver({...$e?{from:$e}:{},...O?{agent:O}:{}}),O?e.listAgentRuns(O,10):e.listRuns(10)]).then(([Fe,_t])=>{xe&&(x(RM(Fe,_t.runs)),O||K(kt=>kt||XU(_t.runs,Fe.analytics.by_source)))}).catch(Fe=>{xe&&j(Ht(Fe,"Mission Control"))}).finally(()=>{xe&&(A.current=!1,R(!1))}),()=>{xe=!1,A.current=!1}},[e,c.section,k,S,O,st]),h$(()=>E(xe=>xe+1)),p.useEffect(()=>{if(c.section!=="mission")return;const xe=()=>{!document.hidden&&!A.current&&E(Fe=>Fe+1)};window.addEventListener("focus",xe),document.addEventListener("visibilitychange",xe);const $e=setInterval(xe,15e3);return()=>{window.removeEventListener("focus",xe),document.removeEventListener("visibilitychange",xe),clearInterval($e)}},[c.section]),p.useEffect(()=>{if(c.section!=="mission"){G.current=null;return}let xe=!0;const $e=G,Fe=Kn=>Qr(Vn=>e.listRuns(50,Vn,{status:Kn}),Vn=>Vn.runs,2),_t=()=>Qr(Kn=>e.listAgents({archived:!1,cursor:Kn}),Kn=>Kn.agents).then(Kn=>{xe&&fe(Kn.filter(Vn=>Xf(Vn)>0).map(Vn=>({agent_id:Vn.agent_id,name:Vn.definition.name??Vn.agent_id,pending:Xf(Vn)})))},()=>{}),is=eW(()=>Promise.allSettled([Fe("input_required"),Fe("failed"),Fe("working"),_t()]).then(([Kn,Vn,hi])=>{var mo,ho,Ir;if(!xe)return;const Pr=[Kn,Vn,hi],gh=Date.now()-JU;if(q(V0(null,Pr).problem),((mo=Pr[0])==null?void 0:mo.status)==="fulfilled"&&V(!0),((ho=Pr[1])==null?void 0:ho.status)==="fulfilled"){J(!0);const zr=Pr[1].value.map(xr=>xr.run_id),po=$e.current;po&&zr.some(xr=>!po.has(xr))&&E(xr=>xr+1),$e.current=new Set(zr)}((Ir=Pr[2])==null?void 0:Ir.status)==="fulfilled"&&ne(!0),F(zr=>{const{needs:po}=V0(zr,Pr);return{asking:po.asking.filter(f$),failed:po.failed.filter(xr=>Date.parse(xr.ended_at??xr.created_at)>gh),live:po.live}})}),1e4);return()=>{xe=!1,is()}},[e,c.section,U]);const As=p.useRef(kD()).current,Os=()=>setTimeout(()=>H(xe=>xe+1),2500),Ln=async(xe,$e)=>{try{return await IC(As(xe),xe,$e,e.sendMessage),Os(),null}catch(Fe){return Wt(Fe)}},ee=p.useRef(new Map).current,Me=async xe=>{const $e=[];try{for(const Fe of xe){const _t=ZU(Fe.kind==="workflow"?Fe:await e.getRun(Fe.run_id));if("refusal"in _t)throw new Error(_t.refusal);const kt=ee.get(Fe.run_id)??Od();ee.set(Fe.run_id,kt),await e.startRun(Fe.agent_id,_t.body,kt),$e.push(Fe.run_id)}return Os(),{started:$e,problem:null}}catch(Fe){return $e.length&&Os(),{started:$e,problem:Wt(Fe)}}},mt=async xe=>{try{return await e.stop(xe),Os(),null}catch($e){return Wt($e)}},Ot=async(xe,$e,Fe,_t,kt)=>{let is=null;try{await e.answerApproval(xe,$e,Fe,_t,kt)}catch(Kn){is=v$(Kn)}return H(Kn=>Kn+1),is},Xt=async(xe,$e)=>{let Fe=null;try{await e.handBackComputer(xe,$e)}catch(_t){Fe=Hx(_t,"hand")}return H(_t=>_t+1),Fe},Be=p.useRef(0);p.useEffect(()=>{const xe=++Be.current;Xs([]),_n&&Qr($e=>e.listRevisions(_n,$e),$e=>$e.revisions).then($e=>{xe===Be.current&&Xs($e)}).catch(()=>{})},[e,_n]);const te=async(xe,$e,Fe)=>{const _t=performance.now();try{const kt=await e.startRun(xe,$e,Fe);return{status:kt.status,ms:Math.round(performance.now()-_t),body:kt.run,runId:kt.run.run_id}}catch(kt){return Pb(kt,Math.round(performance.now()-_t))}},ye=((ca=u==null?void 0:u.features)==null?void 0:ca.efforts)??[],qe=u?((uo=u.features)==null?void 0:uo.learning)??null:void 0;Je.learning=qe??void 0;const Nt=(da=u==null?void 0:u.models)==null?void 0:da.ready;p.useEffect(()=>{if(Nt!==!1)return;const xe=()=>{Ft.current||(Ft.current=!0,Rt().finally(()=>{Ft.current=!1}))},$e=()=>Rt(),Fe=setInterval(xe,XB);return window.addEventListener("focus",$e),()=>{clearInterval(Fe),window.removeEventListener("focus",$e)}},[e,Nt]);const[It,lt]=p.useState(null);p.useEffect(()=>{if(Nt!==!1)return;let xe=!0;return e.chatGPT().then($e=>{xe&<(Yf($e))},()=>{xe&<(null)}),()=>{xe=!1}},[e,Nt]);const[jn,Tn]=p.useState(!1),gr=xe=>{lt(xe),(xe.state==="pending"||xe.state==="signed_in")&&Tn(!0),xe.state==="signed_in"&&Rt()},Bt=(Bd=it==null?void 0:it.find(xe=>xe.agent_id===_n))==null?void 0:Bd.definition,li=(Bt==null?void 0:Bt.native)||ns(Bt),co=c.operation?c.playgroundAgent:_n??c.playgroundAgent;return t.jsx(c$.Provider,{value:y,children:t.jsx(FB,{active:c.section,building:c.section==="agents"&&c.agent===null,onBuild:()=>Ie("#/agents/new"),settings:_e.length>0,triggers:g,onNavigate:Ae,onSignOut:()=>{const xe=()=>void e.signOut().then(n,$e=>i($e instanceof Ue?$e.message:"The sign-out did not reach the server. Try again."));uf(null,xe)||xe()},onSignOutEverywhere:()=>{const xe=()=>void e.signOutEverywhere().then(n,$e=>i($e instanceof Ue?$e.message:"The sign-out did not reach the server. Try again."));uf(null,xe)||xe()},banners:t.jsxs(t.Fragment,{children:[o&&t.jsxs("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-destructive-text md:px-8",role:"alert",children:["Not signed out: ",o]}),at&&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:sG(at)}),at.state!=="running"&&t.jsx(B,{size:"xs",type:"button",onClick:()=>St(null),children:"Dismiss"})]})]}),children:c.section==="settings"?t.jsx(WU,{active:c.settings??"keys",offered:_e,children:c.settings==="tools"?t.jsx(hW,{v2:e,choices:X,gates:ge,harnesses:Je.harnesses,mcp:!!((Gd=u==null?void 0:u.features)!=null&&Gd.mcp_client),onSaved:Rt,onOpen:Rt}):c.settings==="mcp"?t.jsx(jW,{v2:e,signIn:c.signIn,add:c.add,writable:s,whyNot:r,choices:X}):c.settings==="github"?t.jsx(bW,{v2:e,returned:c.github}):c.settings==="email"?t.jsx(HW,{v2:e,writable:s,whyNot:r}):c.settings==="computers"?t.jsx(QW,{v2:e,writable:s,whyNot:r}):c.settings==="workspace"?t.jsx(i9,{v2:e,writable:s,whyNot:r}):c.settings==="webhook"?t.jsx(GW,{v2:e}):t.jsx(iW,{v2:e,onChange:Rt,writable:s,whyNot:r,harnesses:Je.harnesses,plan:t.jsx(C6,{v2:e,writable:s,whyNot:r,onChange:()=>void Rt()})})}):c.section==="dojo"?t.jsx(bF,{v2:e,server:qe},st):c.section==="mission"?t.jsx("div",{className:"flex h-full flex-col",children:t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(pB,{hasObservedSessions:!!((ci=_.data)!=null&&ci.sessions.length),observations:t.jsx(Pv,{read:_,view:"summary",days:$}),view:h,error:b,onRetry:()=>E(xe=>xe+1),actions:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"icon","aria-label":"Refresh Mission Control",disabled:P,onClick:()=>{E(xe=>xe+1),H(xe=>xe+1)},children:t.jsx(Xo,{className:"size-4","aria-hidden":!0})}),t.jsx(sn,{label:"Query",prompt:Bm(location.origin,O??void 0),playgroundHref:Iv(O??void 0)}),t.jsx(sh,{variant:"primary"})]}),scope:{range:S,onRange:N,agent:O,onAgent:L,refreshing:P&&h!==null},asking:M&&z?M.asking.length:null,failed:M&&se?u$(M.failed):null,live:M&&re?M.live.length:null,needsYou:M&&t.jsx(xB,{asking:M.asking,failed:M.failed,failedAll:h==null?void 0:h.runs.failed,live:M.live,learning:nt,problem:I,agentName:he,onAnswer:Ln,onApprove:Ot,onHandBack:Xt,onRunAgain:Me,onStop:mt}),startHere:W===!1&&!((Pl=_.data)!=null&&Pl.sessions.length)?t.jsx(TB,{harnesses:Je.harnesses,tools:Je.tools,onTry:gt,imported:jt,keySettings:((fo=(di=u==null?void 0:u.features)==null?void 0:di.tool_keys)==null?void 0:fo.routes)===!0&&u.features.tool_keys.at_rest==="sealed",modelSetup:u&&(u.models.ready===!1||jn)?t.jsx(PW,{v2:e,needs:u.models.needs,model:u.models.default,onSaved:Rt,writable:s,whyNot:r,plan:It,harnesses:Je.harnesses,onPlan:gr,onDone:()=>Tn(!1)}):void 0}):void 0})})}):c.section==="templates"?t.jsx(W0,{v2:e,name:c.template,install:c.install,go:Ie},c.install!==void 0?`install:${c.install}`:c.template??""):c.section==="triggers"?t.jsx(eU,{v2:e,view:{trigger:c.trigger,kind:c.kind,edit:c.edit},go:Ie,agentName:he,minEvery:(ui=(qd=u==null?void 0:u.features)==null?void 0:qd.triggers)==null?void 0:ui.min_every_s,failuresToPause:(Il=($t=u==null?void 0:u.features)==null?void 0:$t.triggers)==null?void 0:Il.failures_to_pause,publicUrl:(fi=(zl=u==null?void 0:u.features)==null?void 0:zl.triggers)==null?void 0:fi.public_url}):c.section==="playground"?t.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[t.jsx("header",{className:ae(pr,"gap-2 px-5"),children:t.jsxs("h1",{className:Bo,children:[t.jsx(xm,{className:"size-4","aria-hidden":!0}),"API playground"]})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-6 py-4",children:[t.jsx("label",{className:"sr-only",htmlFor:"api-operation",children:"API operation"}),t.jsx(Et,{id:"api-operation",label:"API operation",steady:!0,value:c.operation??"run",onChange:xe=>{const $e=co,Fe=new URLSearchParams;xe!=="run"&&Fe.set("operation",xe),xe!=="create-agent"&&xe!=="apply-template"&&$e&&Fe.set("agent",$e),Ie(`#/playground${Fe.size?`?${Fe}`:""}`)},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:!co}]}),t.jsx("span",{className:"min-w-0 break-all font-mono text-small text-muted-foreground",children:c.operation==="apply-template"?`/v2/templates/${c.template?encodeURIComponent(c.template):"{template}"}/apply`:c.operation==="list-runs"?c.playgroundAgent?`/v2/agents/${c.playgroundAgent}/runs`:"/v2/runs":c.operation==="create-agent"?"/v2/agents":c.operation==="edit-agent"?`/v2/agents/${c.playgroundAgent??"{agent_id}"}/definition`:"/v2/agents/{agent_id}/runs"})]}),c.operation==="apply-template"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(W0,{v2:e,name:c.template,go:Ie,playground:!0,draft:c.draft},c.template??"")}):c.operation==="list-runs"?t.jsx(DU,{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(FU,{v2:e,operation:c.operation,origin:location.origin,agentId:c.playgroundAgent,draft:c.draft,harnesses:Je.harnesses},`${c.operation}:${c.playgroundAgent??""}:${c.draft??""}`):t.jsxs(t.Fragment,{children:[!li&&((Dl=u==null?void 0:u.models)==null?void 0:Dl.ready)===!1&&t.jsx(IW,{needs:u.models.needs,source:u.models.source,model:u.models.default,settings:((Ul=(Fl=u.features)==null?void 0:Fl.tool_keys)==null?void 0:Ul.routes)===!0&&u.features.tool_keys.at_rest==="sealed",chatgpt:(It==null?void 0:It.state)==="signed_out"||(It==null?void 0:It.state)==="expired"}),bs&&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: ",bs]}),t.jsx(B,{size:"sm",className:"mt-3",type:"button",onClick:()=>Rs(xe=>xe+1),children:"Try again"})]}),it&&t.jsx(IU,{agents:it.filter(xe=>!xe.archived_at),revisions:xs,efforts:ye,origin:location.origin,agentId:_n??void 0,onAgent:Bn,onSend:te,limits:u==null?void 0:u.limits,removeUpload:e.deleteUpload,onOpenRun:xe=>Ie(`#/runs/${encodeURIComponent(xe)}`),live:xe=>t.jsx($N,{v2:e,runId:xe,caps:u,agentName:he},xe)})]})]}):c.section==="agents"?c.observation?t.jsx(dM,{v2:e,sessionId:c.observation,go:Ie}):c.nativeConnect?t.jsx(f6,{v2:e,go:Ie,initialSource:c.connectionSource}):c.agent===void 0?t.jsx(m6,{v2:e,archived:!!c.archived,go:Ie},st):c.agent===null?t.jsx(EU,{origin:location.origin,v2:e}):c.agent!==null&&!c.edit?t.jsx(dF,{v2:e,agentId:c.agent,tab:c.tab,notes:c.notes,learning:qe,routePrefix:(mi=He==null?void 0:He.models)==null?void 0:mi.route_prefix,harnesses:Je.harnesses,efforts:ye,limits:u==null?void 0:u.limits,places:Fk(u),go:Ie},c.agent):t.jsx(h6,{v2:e,choices:X,gates:ge,focusTool:c.tool,caps:{...Je,routePrefix:(ua=He==null?void 0:He.models)==null?void 0:ua.route_prefix,decisionProvider:jP(u==null?void 0:u.workflows),places:Fk(u),mcp:!!((Zs=u==null?void 0:u.features)!=null&&Zs.mcp_client),mcpHarnesses:(tr=(er=u==null?void 0:u.features)==null?void 0:er.mcp_client)==null?void 0:tr.harnesses},agentId:c.agent,go:Ie},`${c.agent??"new"}:${c.tool??""}`):c.run?t.jsx($N,{v2:e,runId:c.run,caps:u,agentName:he},c.run):t.jsx(TU,{observations:!c.runsOf&&!c.archived&&!c.status?_:void 0,runs:me,agentName:he,agentId:c.runsOf,error:Ye,onRetry:()=>Ce(xe=>xe+1),onOpen:xe=>Ie(`#/runs/${encodeURIComponent(xe)}`),loadingMore:de,filter:pe,onFilter:xe=>Ie(ZB({runsOf:c.runsOf,...xe})),onMore:je?()=>{const xe=tt.current;Oe(!0),(c.runsOf?e.listAgentRuns(c.runsOf,50,je,pe):e.listRuns(50,je,pe)).then($e=>{xe===tt.current&&(ve(Fe=>Sx(Fe??[],$e.runs)),Ve($e.next_cursor),ht(null))}).catch($e=>ht(Ht($e,"more runs"))).finally(()=>Oe(!1))}:void 0})})})}MB();MT.createRoot(document.getElementById("root")).render(t.jsx(p.StrictMode,{children:t.jsx(V5,{children:t.jsx(rG,{})})}));
|