@parcha/agentrun-serve 0.1.0-beta.40 → 0.1.0-beta.41
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 +77 -0
- package/README.md +78 -15
- package/dist/api-only.d.ts +3 -1
- package/dist/api-only.js +4 -2
- package/dist/api-token.d.ts +30 -0
- package/dist/api-token.js +89 -0
- package/dist/cli.js +19 -5
- package/dist/composio-made.d.ts +54 -0
- package/dist/composio-made.js +83 -0
- package/dist/composio-preset.d.ts +16 -8
- package/dist/composio-preset.js +106 -43
- package/dist/composio-triggers.d.ts +7 -2
- package/dist/composio-triggers.js +13 -7
- package/dist/computer-attach.d.ts +29 -11
- package/dist/computer-attach.js +141 -47
- package/dist/computer-keys.d.ts +4 -0
- package/dist/computer-keys.js +5 -0
- package/dist/computers.d.ts +11 -1
- package/dist/computers.js +21 -12
- package/dist/console/assets/{index-B8Zn1Iqn.css → index-C3gNPz58.css} +1 -1
- package/dist/console/assets/index-COGhx_2Z.js +711 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.js +9 -2
- package/dist/eval-feed.d.ts +26 -0
- package/dist/eval-feed.js +68 -0
- package/dist/eval-mailbox.d.ts +4 -1
- package/dist/eval-mailbox.js +11 -3
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/feed/feed-faux.d.ts +62 -0
- package/dist/feed/feed-faux.js +123 -0
- package/dist/feed/fetch.d.ts +41 -0
- package/dist/feed/fetch.js +128 -0
- package/dist/feed/parse.d.ts +41 -0
- package/dist/feed/parse.js +300 -0
- package/dist/learn/check.d.ts +3 -1
- package/dist/learn/check.js +57 -2
- package/dist/learn/compile.js +1 -1
- package/dist/learned-nodes.d.ts +21 -4
- package/dist/learned-nodes.js +21 -8
- package/dist/learned-workflow.d.ts +3 -3
- package/dist/learned-workflow.js +14 -5
- package/dist/mcp-oauth.d.ts +15 -1
- package/dist/mcp-oauth.js +39 -5
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +4 -3
- package/dist/mcp-servers-store.d.ts +58 -5
- package/dist/mcp-servers-store.js +136 -17
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +2 -2
- package/dist/observation/http.d.ts +4 -1
- package/dist/observation/http.js +5 -4
- package/dist/openapi.js +46 -12
- package/dist/print.d.ts +6 -3
- package/dist/print.js +4 -2
- package/dist/run-labels.d.ts +23 -0
- package/dist/run-labels.js +79 -0
- package/dist/run-secrets.js +12 -4
- package/dist/runner/adapter-loop.js +91 -10
- package/dist/runner/adapter-run-spec.d.ts +4 -0
- package/dist/runner/adapter-run-spec.js +38 -31
- package/dist/runner/beside.d.ts +6 -3
- package/dist/runner/beside.js +9 -7
- package/dist/runner/cli-run-spec.js +32 -26
- package/dist/runner/conformance/harness.js +69 -14
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/main.d.ts +1 -1
- package/dist/runner/main.js +2 -2
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/mcp-run.d.ts +4 -0
- package/dist/runner/mcp-run.js +5 -3
- package/dist/runner/model-route.d.ts +4 -2
- package/dist/runner/model-route.js +8 -8
- package/dist/runner/promotion.d.ts +8 -0
- package/dist/runner/promotion.js +43 -1
- package/dist/runner/workflow-first.d.ts +6 -5
- package/dist/runner/workflow-first.js +9 -7
- package/dist/runs-over-store.js +5 -2
- package/dist/sdk/runs.d.ts +7 -1
- package/dist/sdk/runs.js +19 -6
- package/dist/secret-cut.js +3 -1
- package/dist/secrets.js +3 -1
- package/dist/server.d.ts +27 -2
- package/dist/server.js +168 -50
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/postgres/dialect.js +1 -0
- package/dist/store/postgres/migrations/0015_run_labels.sql +5 -0
- package/dist/store/postgres/migrations/0016_minted_tokens.sql +21 -0
- package/dist/store/schema.d.ts +9 -0
- package/dist/store/schema.js +26 -2
- package/dist/store/sqlite/connection.js +11 -3
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +3 -2
- package/dist/store/sqlite/store.js +64 -10
- package/dist/store/store.d.ts +38 -1
- package/dist/store-reads/journal.js +2 -1
- package/dist/store-reads/learning.js +6 -1
- package/dist/store-reads/runs.d.ts +4 -3
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.js +4 -2
- package/dist/template-eval.d.ts +4 -0
- package/dist/template-eval.js +127 -50
- package/dist/templates.d.ts +10 -0
- package/dist/templates.js +75 -17
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/trigger-adapter.d.ts +9 -4
- package/dist/trigger-adapters.js +2 -1
- package/dist/trigger-feed.d.ts +12 -0
- package/dist/trigger-feed.js +371 -0
- package/dist/triggers.d.ts +2 -1
- package/dist/triggers.js +23 -5
- package/dist/webhooks.js +9 -5
- package/dist/workspace/computer-deps.d.ts +5 -1
- package/dist/workspace/computer-deps.js +2 -2
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/index.js +2 -0
- package/dist/workspace/resolve-computer.d.ts +32 -3
- package/dist/workspace/resolve-computer.js +47 -9
- package/launcher/agentrun-serve +6 -1
- package/package.json +10 -9
- package/templates/README.md +27 -2
- package/dist/console/assets/index-Jbxjcmdp.js +0 -705
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
var aT=Object.defineProperty;var iT=(e,n,s)=>n in e?aT(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var Rt=(e,n,s)=>iT(e,typeof n!="symbol"?n+"":n,s);function lT(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 EN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fp={exports:{}},ic={},Up={exports:{}},xt={};/**
|
|
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 ej;function cT(){if(ej)return xt;ej=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"),b=Symbol.iterator;function x(z){return z===null||typeof z!="object"?null:(z=b&&z[b]||z["@@iterator"],typeof z=="function"?z:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,y={};function j(z,Y,J){this.props=z,this.context=Y,this.refs=y,this.updater=J||h}j.prototype.isReactComponent={},j.prototype.setState=function(z,Y){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,Y,"setState")},j.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function k(){}k.prototype=j.prototype;function E(z,Y,J){this.props=z,this.context=Y,this.refs=y,this.updater=J||h}var S=E.prototype=new k;S.constructor=E,v(S,j.prototype),S.isPureReactComponent=!0;var N=Array.isArray,$=Object.prototype.hasOwnProperty,_={current:null},M={key:!0,ref:!0,__self:!0,__source:!0};function O(z,Y,J){var X,le={},se=null,fe=null;if(Y!=null)for(X in Y.ref!==void 0&&(fe=Y.ref),Y.key!==void 0&&(se=""+Y.key),Y)$.call(Y,X)&&!M.hasOwnProperty(X)&&(le[X]=Y[X]);var xe=arguments.length-2;if(xe===1)le.children=J;else if(1<xe){for(var Ne=Array(xe),ge=0;ge<xe;ge++)Ne[ge]=arguments[ge+2];le.children=Ne}if(z&&z.defaultProps)for(X in xe=z.defaultProps,xe)le[X]===void 0&&(le[X]=xe[X]);return{$$typeof:e,type:z,key:se,ref:fe,props:le,_owner:_.current}}function L(z,Y){return{$$typeof:e,type:z.type,key:Y,ref:z.ref,props:z.props,_owner:z._owner}}function A(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function R(z){var Y={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(J){return Y[J]})}var P=/\/+/g;function D(z,Y){return typeof z=="object"&&z!==null&&z.key!=null?R(""+z.key):Y.toString(36)}function W(z,Y,J,X,le){var se=typeof z;(se==="undefined"||se==="boolean")&&(z=null);var fe=!1;if(z===null)fe=!0;else switch(se){case"string":case"number":fe=!0;break;case"object":switch(z.$$typeof){case e:case n:fe=!0}}if(fe)return fe=z,le=le(fe),z=X===""?"."+D(fe,0):X,N(le)?(J="",z!=null&&(J=z.replace(P,"$&/")+"/"),W(le,Y,J,"",function(ge){return ge})):le!=null&&(A(le)&&(le=L(le,J+(!le.key||fe&&fe.key===le.key?"":(""+le.key).replace(P,"$&/")+"/")+z)),Y.push(le)),1;if(fe=0,X=X===""?".":X+":",N(z))for(var xe=0;xe<z.length;xe++){se=z[xe];var Ne=X+D(se,xe);fe+=W(se,Y,J,Ne,le)}else if(Ne=x(z),typeof Ne=="function")for(z=Ne.call(z),xe=0;!(se=z.next()).done;)se=se.value,Ne=X+D(se,xe++),fe+=W(se,Y,J,Ne,le);else if(se==="object")throw Y=String(z),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return fe}function K(z,Y,J){if(z==null)return z;var X=[],le=0;return W(z,X,"","",function(se){return Y.call(J,se,le++)}),X}function H(z){if(z._status===-1){var Y=z._result;Y=Y(),Y.then(function(J){(z._status===0||z._status===-1)&&(z._status=1,z._result=J)},function(J){(z._status===0||z._status===-1)&&(z._status=2,z._result=J)}),z._status===-1&&(z._status=0,z._result=Y)}if(z._status===1)return z._result.default;throw z._result}var q={current:null},F={transition:null},G={ReactCurrentDispatcher:q,ReactCurrentBatchConfig:F,ReactCurrentOwner:_};function U(){throw Error("act(...) is not supported in production builds of React.")}return xt.Children={map:K,forEach:function(z,Y,J){K(z,function(){Y.apply(this,arguments)},J)},count:function(z){var Y=0;return K(z,function(){Y++}),Y},toArray:function(z){return K(z,function(Y){return Y})||[]},only:function(z){if(!A(z))throw Error("React.Children.only expected to receive a single React element child.");return z}},xt.Component=j,xt.Fragment=s,xt.Profiler=o,xt.PureComponent=E,xt.StrictMode=r,xt.Suspense=u,xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,xt.act=U,xt.cloneElement=function(z,Y,J){if(z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+z+".");var X=v({},z.props),le=z.key,se=z.ref,fe=z._owner;if(Y!=null){if(Y.ref!==void 0&&(se=Y.ref,fe=_.current),Y.key!==void 0&&(le=""+Y.key),z.type&&z.type.defaultProps)var xe=z.type.defaultProps;for(Ne in Y)$.call(Y,Ne)&&!M.hasOwnProperty(Ne)&&(X[Ne]=Y[Ne]===void 0&&xe!==void 0?xe[Ne]:Y[Ne])}var Ne=arguments.length-2;if(Ne===1)X.children=J;else if(1<Ne){xe=Array(Ne);for(var ge=0;ge<Ne;ge++)xe[ge]=arguments[ge+2];X.children=xe}return{$$typeof:e,type:z.type,key:le,ref:se,props:X,_owner:fe}},xt.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},xt.createElement=O,xt.createFactory=function(z){var Y=O.bind(null,z);return Y.type=z,Y},xt.createRef=function(){return{current:null}},xt.forwardRef=function(z){return{$$typeof:d,render:z}},xt.isValidElement=A,xt.lazy=function(z){return{$$typeof:g,_payload:{_status:-1,_result:z},_init:H}},xt.memo=function(z,Y){return{$$typeof:f,type:z,compare:Y===void 0?null:Y}},xt.startTransition=function(z){var Y=F.transition;F.transition={};try{z()}finally{F.transition=Y}},xt.unstable_act=U,xt.useCallback=function(z,Y){return q.current.useCallback(z,Y)},xt.useContext=function(z){return q.current.useContext(z)},xt.useDebugValue=function(){},xt.useDeferredValue=function(z){return q.current.useDeferredValue(z)},xt.useEffect=function(z,Y){return q.current.useEffect(z,Y)},xt.useId=function(){return q.current.useId()},xt.useImperativeHandle=function(z,Y,J){return q.current.useImperativeHandle(z,Y,J)},xt.useInsertionEffect=function(z,Y){return q.current.useInsertionEffect(z,Y)},xt.useLayoutEffect=function(z,Y){return q.current.useLayoutEffect(z,Y)},xt.useMemo=function(z,Y){return q.current.useMemo(z,Y)},xt.useReducer=function(z,Y,J){return q.current.useReducer(z,Y,J)},xt.useRef=function(z){return q.current.useRef(z)},xt.useState=function(z){return q.current.useState(z)},xt.useSyncExternalStore=function(z,Y,J){return q.current.useSyncExternalStore(z,Y,J)},xt.useTransition=function(){return q.current.useTransition()},xt.version="18.3.1",xt}var tj;function dm(){return tj||(tj=1,Up.exports=cT()),Up.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 nj;function dT(){if(nj)return ic;nj=1;var e=dm(),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,b={},x=null,h=null;f!==void 0&&(x=""+f),u.key!==void 0&&(x=""+u.key),u.ref!==void 0&&(h=u.ref);for(g in u)r.call(u,g)&&!i.hasOwnProperty(g)&&(b[g]=u[g]);if(d&&d.defaultProps)for(g in u=d.defaultProps,u)b[g]===void 0&&(b[g]=u[g]);return{$$typeof:n,type:d,key:x,ref:h,props:b,_owner:o.current}}return ic.Fragment=s,ic.jsx=c,ic.jsxs=c,ic}var sj;function uT(){return sj||(sj=1,Fp.exports=dT()),Fp.exports}var t=uT(),p=dm();const Ke=EN(p),Mg=lT({__proto__:null,default:Ke},[p]);var Du={},Wp={exports:{}},us={},Hp={exports:{}},Bp={};/**
|
|
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 rj;function fT(){return rj||(rj=1,(function(e){function n(F,G){var U=F.length;F.push(G);e:for(;0<U;){var z=U-1>>>1,Y=F[z];if(0<o(Y,G))F[z]=G,F[U]=Y,U=z;else break e}}function s(F){return F.length===0?null:F[0]}function r(F){if(F.length===0)return null;var G=F[0],U=F.pop();if(U!==G){F[0]=U;e:for(var z=0,Y=F.length,J=Y>>>1;z<J;){var X=2*(z+1)-1,le=F[X],se=X+1,fe=F[se];if(0>o(le,U))se<Y&&0>o(fe,le)?(F[z]=fe,F[se]=U,z=se):(F[z]=le,F[X]=U,z=X);else if(se<Y&&0>o(fe,U))F[z]=fe,F[se]=U,z=se;else break e}}return G}function o(F,G){var U=F.sortIndex-G.sortIndex;return U!==0?U:F.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var u=[],f=[],g=1,b=null,x=3,h=!1,v=!1,y=!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(F){for(var G=s(f);G!==null;){if(G.callback===null)r(f);else if(G.startTime<=F)r(f),G.sortIndex=G.expirationTime,n(u,G);else break;G=s(f)}}function N(F){if(y=!1,S(F),!v)if(s(u)!==null)v=!0,H($);else{var G=s(f);G!==null&&q(N,G.startTime-F)}}function $(F,G){v=!1,y&&(y=!1,k(O),O=-1),h=!0;var U=x;try{for(S(G),b=s(u);b!==null&&(!(b.expirationTime>G)||F&&!R());){var z=b.callback;if(typeof z=="function"){b.callback=null,x=b.priorityLevel;var Y=z(b.expirationTime<=G);G=e.unstable_now(),typeof Y=="function"?b.callback=Y:b===s(u)&&r(u),S(G)}else r(u);b=s(u)}if(b!==null)var J=!0;else{var X=s(f);X!==null&&q(N,X.startTime-G),J=!1}return J}finally{b=null,x=U,h=!1}}var _=!1,M=null,O=-1,L=5,A=-1;function R(){return!(e.unstable_now()-A<L)}function P(){if(M!==null){var F=e.unstable_now();A=F;var G=!0;try{G=M(!0,F)}finally{G?D():(_=!1,M=null)}}else _=!1}var D;if(typeof E=="function")D=function(){E(P)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,K=W.port2;W.port1.onmessage=P,D=function(){K.postMessage(null)}}else D=function(){j(P,0)};function H(F){M=F,_||(_=!0,D())}function q(F,G){O=j(function(){F(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(F){F.callback=null},e.unstable_continueExecution=function(){v||h||(v=!0,H($))},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return s(u)},e.unstable_next=function(F){switch(x){case 1:case 2:case 3:var G=3;break;default:G=x}var U=x;x=G;try{return F()}finally{x=U}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(F,G){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var U=x;x=F;try{return G()}finally{x=U}},e.unstable_scheduleCallback=function(F,G,U){var z=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?z+U:z):U=z,F){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=U+Y,F={id:g++,callback:G,priorityLevel:F,startTime:U,expirationTime:Y,sortIndex:-1},U>z?(F.sortIndex=U,n(f,F),s(u)===null&&F===s(f)&&(y?(k(O),O=-1):y=!0,q(N,U-z))):(F.sortIndex=Y,n(u,F),v||h||(v=!0,H($))),F},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(F){var G=x;return function(){var U=x;x=G;try{return F.apply(this,arguments)}finally{x=U}}}})(Bp)),Bp}var oj;function mT(){return oj||(oj=1,Hp.exports=fT()),Hp.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 aj;function hT(){if(aj)return us;aj=1;var e=dm(),n=mT();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={},b={};function x(a){return u.call(b,a)?!0:u.call(g,a)?!1:f.test(a)?b[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 v(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 y(a,l,m,w,C,T,I){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=I}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){j[a]=new y(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 y(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){j[a]=new y(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){j[a]=new y(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 y(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){j[a]=new y(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){j[a]=new y(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){j[a]=new y(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){j[a]=new y(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 y(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 y(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 y(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){j[a]=new y(a,1,!1,a.toLowerCase(),null,!1,!1)}),j.xlinkHref=new y("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){j[a]=new y(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")&&(v(l,m,C,w)&&(m=null),w||C===null?x(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"),M=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),A=Symbol.for("react.provider"),R=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),K=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),q=Symbol.for("react.offscreen"),F=Symbol.iterator;function G(a){return a===null||typeof a!="object"?null:(a=F&&a[F]||a["@@iterator"],typeof a=="function"?a:null)}var U=Object.assign,z;function Y(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 J=!1;function X(a,l){if(!a||J)return"";J=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ue){var w=ue}Reflect.construct(a,[],l)}else{try{l.call()}catch(ue){w=ue}a.call(l.prototype)}else{try{throw Error()}catch(ue){w=ue}a()}}catch(ue){if(ue&&w&&typeof ue.stack=="string"){for(var C=ue.stack.split(`
|
|
35
|
+
`),T=w.stack.split(`
|
|
36
|
+
`),I=C.length-1,V=T.length-1;1<=I&&0<=V&&C[I]!==T[V];)V--;for(;1<=I&&0<=V;I--,V--)if(C[I]!==T[V]){if(I!==1||V!==1)do if(I--,V--,0>V||C[I]!==T[V]){var Z=`
|
|
37
|
+
`+C[I].replace(" at new "," at ");return a.displayName&&Z.includes("<anonymous>")&&(Z=Z.replace("<anonymous>",a.displayName)),Z}while(1<=I&&0<=V);break}}}finally{J=!1,Error.prepareStackTrace=m}return(a=a?a.displayName||a.name:"")?Y(a):""}function le(a){switch(a.tag){case 5:return Y(a.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("SuspenseList");case 0:case 2:case 15:return a=X(a.type,!1),a;case 11:return a=X(a.type.render,!1),a;case 1:return a=X(a.type,!0),a;default:return""}}function se(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 M:return"Fragment";case _:return"Portal";case L:return"Profiler";case O:return"StrictMode";case D:return"Suspense";case W:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case R:return(a.displayName||"Context")+".Consumer";case A:return(a._context.displayName||"Context")+".Provider";case P:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case K:return l=a.displayName||null,l!==null?l:se(a.type)||"Memo";case H:l=a._payload,a=a._init;try{return se(a(l))}catch{}}return null}function fe(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 se(l);case 8:return l===O?"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 xe(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function Ne(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function ge(a){var l=Ne(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(I){w=""+I,T.call(this,I)}}),Object.defineProperty(a,l,{enumerable:m.enumerable}),{getValue:function(){return w},setValue:function(I){w=""+I},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function me(a){a._valueTracker||(a._valueTracker=ge(a))}function Le(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var m=l.getValue(),w="";return a&&(w=Ne(a)?a.checked?"true":"false":a.value),a=w,a!==m?(l.setValue(a),!0):!1}function Ue(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 U({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??a._wrapperState.initialChecked})}function Ee(a,l){var m=l.defaultValue==null?"":l.defaultValue,w=l.checked!=null?l.checked:l.defaultChecked;m=xe(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 re(a,l){l=l.checked,l!=null&&S(a,"checked",l,!1)}function _e(a,l){re(a,l);var m=xe(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")?he(a,l.type,m):l.hasOwnProperty("defaultValue")&&he(a,l.type,xe(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(a.defaultChecked=!!l.defaultChecked)}function Qe(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 he(a,l,m){(l!=="number"||Ue(a.ownerDocument)!==a)&&(m==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+m&&(a.defaultValue=""+m))}var Ie=Array.isArray;function et(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=""+xe(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 pt(a,l){if(l.dangerouslySetInnerHTML!=null)throw Error(s(91));return U({},l,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function oe(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(Ie(m)){if(1<m.length)throw Error(s(93));m=m[0]}l=m}l==null&&(l=""),m=l}a._wrapperState={initialValue:xe(m)}}function $e(a,l){var m=xe(l.value),w=xe(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 st(a){var l=a.textContent;l===a._wrapperState.initialValue&&l!==""&&l!==null&&(a.value=l)}function Oe(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 dt(a,l){return a==null||a==="http://www.w3.org/1999/xhtml"?Oe(l):a==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var Tt,nt=(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(Tt=Tt||document.createElement("div"),Tt.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=Tt.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}});function ft(a,l){if(l){var m=a.firstChild;if(m&&m===a.lastChild&&m.nodeType===3){m.nodeValue=l;return}}a.textContent=l}var Kt={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},Dt=["Webkit","ms","Moz","O"];Object.keys(Kt).forEach(function(a){Dt.forEach(function(l){l=l+a.charAt(0).toUpperCase()+a.substring(1),Kt[l]=Kt[a]})});function ye(a,l,m){return l==null||typeof l=="boolean"||l===""?"":m||typeof l!="number"||l===0||Kt.hasOwnProperty(a)&&Kt[a]?(""+l).trim():l+"px"}function de(a,l){a=a.style;for(var m in l)if(l.hasOwnProperty(m)){var w=m.indexOf("--")===0,C=ye(m,l[m],w);m==="float"&&(m="cssFloat"),w?a.setProperty(m,C):a[m]=C}}var We=U({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ze(a,l){if(l){if(We[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 at(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 Q=null;function ve(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var He=null,Se=null,Je=null;function Nt(a){if(a=ql(a)){if(typeof He!="function")throw Error(s(280));var l=a.stateNode;l&&(l=eu(l),He(a.stateNode,a.type,l))}}function zt(a){Se?Je?Je.push(a):Je=[a]:Se=a}function it(){if(Se){var a=Se,l=Je;if(Je=Se=null,Nt(a),l)for(a=0;a<l.length;a++)Nt(l[a])}}function An(a,l){return a(l)}function ps(){}var Qs=!1;function En(a,l,m){if(Qs)return a(l,m);Qs=!0;try{return An(a,l,m)}finally{Qs=!1,(Se!==null||Je!==null)&&(ps(),it())}}function Wn(a,l){var m=a.stateNode;if(m===null)return null;var w=eu(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 gs=!1;if(d)try{var xs={};Object.defineProperty(xs,"passive",{get:function(){gs=!0}}),window.addEventListener("test",xs,xs),window.removeEventListener("test",xs,xs)}catch{gs=!1}function fn(a,l,m,w,C,T,I,V,Z){var ue=Array.prototype.slice.call(arguments,3);try{l.apply(m,ue)}catch(je){this.onError(je)}}var Hn=!1,_s=null,Bn=!1,Ts=null,Rs={onError:function(a){Hn=!0,_s=a}};function On(a,l,m,w,C,T,I,V,Z){Hn=!1,_s=null,fn.apply(Rs,arguments)}function ee(a,l,m,w,C,T,I,V,Z){if(On.apply(this,arguments),Hn){if(Hn){var ue=_s;Hn=!1,_s=null}else throw Error(s(198));Bn||(Bn=!0,Ts=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 At(a){if(Me(a)!==a)throw Error(s(188))}function Jt(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 At(C),a;if(T===w)return At(C),l;T=T.sibling}throw Error(s(188))}if(m.return!==w.return)m=C,w=T;else{for(var I=!1,V=C.child;V;){if(V===m){I=!0,m=C,w=T;break}if(V===w){I=!0,w=C,m=T;break}V=V.sibling}if(!I){for(V=T.child;V;){if(V===m){I=!0,m=T,w=C;break}if(V===w){I=!0,w=T,m=C;break}V=V.sibling}if(!I)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=Jt(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 be=n.unstable_scheduleCallback,qe=n.unstable_cancelCallback,kt=n.unstable_shouldYield,Lt=n.unstable_requestPaint,lt=n.unstable_now,bn=n.unstable_getCurrentPriorityLevel,$n=n.unstable_ImmediatePriority,mr=n.unstable_UserBlockingPriority,Ht=n.unstable_NormalPriority,ri=n.unstable_LowPriority,io=n.unstable_IdlePriority,aa=null,vs=null;function Pd(a){if(vs&&typeof vs.onCommitFiberRoot=="function")try{vs.onCommitFiberRoot(aa,a,void 0,(a.current.flags&128)===128)}catch{}}var rs=Math.clz32?Math.clz32:zd,Ld=Math.log,Id=Math.LN2;function zd(a){return a>>>=0,a===0?32:31-(Ld(a)/Id|0)|0}var ia=64,la=4194304;function lo(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 ca(a,l){var m=a.pendingLanes;if(m===0)return 0;var w=0,C=a.suspendedLanes,T=a.pingedLanes,I=m&268435455;if(I!==0){var V=I&~C;V!==0?w=lo(V):(T&=I,T!==0&&(w=lo(T)))}else I=m&~C,I!==0?w=lo(I):T!==0&&(w=lo(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-rs(l),C=1<<m,w|=a[m],l&=~C;return w}function Dd(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 Fd(a,l){for(var m=a.suspendedLanes,w=a.pingedLanes,C=a.expirationTimes,T=a.pendingLanes;0<T;){var I=31-rs(T),V=1<<I,Z=C[I];Z===-1?((V&m)===0||(V&w)!==0)&&(C[I]=Dd(V,l)):Z<=l&&(a.expiredLanes|=V),T&=~V}}function oi(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function _l(){var a=ia;return ia<<=1,(ia&4194240)===0&&(ia=64),a}function ai(a){for(var l=[],m=0;31>m;m++)l.push(a);return l}function co(a,l,m){a.pendingLanes|=l,l!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,l=31-rs(l),a[l]=m}function Ud(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-rs(m),T=1<<C;l[C]=0,w[C]=-1,a[C]=-1,m&=~T}}function ii(a,l){var m=a.entangledLanes|=l;for(a=a.entanglements;m;){var w=31-rs(m),C=1<<w;C&l|a[w]&l&&(a[w]|=l),m&=~C}}var Et=0;function Tl(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var Rl,li,Al,Ol,Ml,ci=!1,da=[],Js=null,Xs=null,Zs=null,pe=new Map,Te=new Map,ze=[],$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 jt(a,l){switch(a){case"focusin":case"focusout":Js=null;break;case"dragenter":case"dragleave":Xs=null;break;case"mouseover":case"mouseout":Zs=null;break;case"pointerover":case"pointerout":pe.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Te.delete(l.pointerId)}}function os(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=ql(l),l!==null&&li(l)),a):(a.eventSystemFlags|=w,l=a.targetContainers,C!==null&&l.indexOf(C)===-1&&l.push(C),a)}function Gn(a,l,m,w,C){switch(l){case"focusin":return Js=os(Js,a,l,m,w,C),!0;case"dragenter":return Xs=os(Xs,a,l,m,w,C),!0;case"mouseover":return Zs=os(Zs,a,l,m,w,C),!0;case"pointerover":var T=C.pointerId;return pe.set(T,os(pe.get(T)||null,a,l,m,w,C)),!0;case"gotpointercapture":return T=C.pointerId,Te.set(T,os(Te.get(T)||null,a,l,m,w,C)),!0}return!1}function qn(a){var l=ua(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,Ml(a.priority,function(){Al(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 di(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var m=mh(a.domEventName,a.eventSystemFlags,l[0],a.nativeEvent);if(m===null){m=a.nativeEvent;var w=new m.constructor(m.type,m);Q=w,m.target.dispatchEvent(w),Q=null}else return l=ql(m),l!==null&&li(l),a.blockedOn=m,!1;l.shift()}return!0}function Mr(a,l,m){di(a)&&m.delete(l)}function uh(){ci=!1,Js!==null&&di(Js)&&(Js=null),Xs!==null&&di(Xs)&&(Xs=null),Zs!==null&&di(Zs)&&(Zs=null),pe.forEach(Mr),Te.forEach(Mr)}function uo(a,l){a.blockedOn===l&&(a.blockedOn=null,ci||(ci=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,uh)))}function fo(a){function l(C){return uo(C,a)}if(0<da.length){uo(da[0],a);for(var m=1;m<da.length;m++){var w=da[m];w.blockedOn===a&&(w.blockedOn=null)}}for(Js!==null&&uo(Js,a),Xs!==null&&uo(Xs,a),Zs!==null&&uo(Zs,a),pe.forEach(l),Te.forEach(l),m=0;m<ze.length;m++)w=ze[m],w.blockedOn===a&&(w.blockedOn=null);for(;0<ze.length&&(m=ze[0],m.blockedOn===null);)qn(m),m.blockedOn===null&&ze.shift()}var Pr=N.ReactCurrentBatchConfig,Lr=!0;function mo(a,l,m,w){var C=Et,T=Pr.transition;Pr.transition=null;try{Et=1,fh(a,l,m,w)}finally{Et=C,Pr.transition=T}}function hr(a,l,m,w){var C=Et,T=Pr.transition;Pr.transition=null;try{Et=4,fh(a,l,m,w)}finally{Et=C,Pr.transition=T}}function fh(a,l,m,w){if(Lr){var C=mh(a,l,m,w);if(C===null)Th(a,l,w,Wd,m),jt(a,w);else if(Gn(C,a,l,m,w))w.stopPropagation();else if(jt(a,w),l&4&&-1<$t.indexOf(a)){for(;C!==null;){var T=ql(C);if(T!==null&&Rl(T),T=mh(a,l,m,w),T===null&&Th(a,l,w,Wd,m),T===C)break;C=T}C!==null&&w.stopPropagation()}else Th(a,l,w,null,m)}}var Wd=null;function mh(a,l,m,w){if(Wd=null,a=ve(w),a=ua(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 Wd=a,null}function Fy(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(bn()){case $n:return 1;case mr:return 4;case Ht:case ri:return 16;case io:return 536870912;default:return 16}default:return 16}}var ho=null,hh=null,Hd=null;function Uy(){if(Hd)return Hd;var a,l=hh,m=l.length,w,C="value"in ho?ho.value:ho.textContent,T=C.length;for(a=0;a<m&&l[a]===C[a];a++);var I=m-a;for(w=1;w<=I&&l[m-w]===C[T-w];w++);return Hd=C.slice(a,1<w?1-w:void 0)}function Bd(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 Gd(){return!0}function Wy(){return!1}function ys(a){function l(m,w,C,T,I){this._reactName=m,this._targetInst=C,this.type=w,this.nativeEvent=T,this.target=I,this.currentTarget=null;for(var V in a)a.hasOwnProperty(V)&&(m=a[V],this[V]=m?m(T):T[V]);return this.isDefaultPrevented=(T.defaultPrevented!=null?T.defaultPrevented:T.returnValue===!1)?Gd:Wy,this.isPropagationStopped=Wy,this}return U(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=Gd)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=Gd)},persist:function(){},isPersistent:Gd}),l}var ui={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ph=ys(ui),Pl=U({},ui,{view:0,detail:0}),O$=ys(Pl),gh,xh,Ll,qd=U({},Pl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yh,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!==Ll&&(Ll&&a.type==="mousemove"?(gh=a.screenX-Ll.screenX,xh=a.screenY-Ll.screenY):xh=gh=0,Ll=a),gh)},movementY:function(a){return"movementY"in a?a.movementY:xh}}),Hy=ys(qd),M$=U({},qd,{dataTransfer:0}),P$=ys(M$),L$=U({},Pl,{relatedTarget:0}),vh=ys(L$),I$=U({},ui,{animationName:0,elapsedTime:0,pseudoElement:0}),z$=ys(I$),D$=U({},ui,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),F$=ys(D$),U$=U({},ui,{data:0}),By=ys(U$),W$={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},H$={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},B$={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function G$(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=B$[a])?!!l[a]:!1}function yh(){return G$}var q$=U({},Pl,{key:function(a){if(a.key){var l=W$[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=Bd(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?H$[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yh,charCode:function(a){return a.type==="keypress"?Bd(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Bd(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),K$=ys(q$),V$=U({},qd,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gy=ys(V$),Y$=U({},Pl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yh}),Q$=ys(Y$),J$=U({},ui,{propertyName:0,elapsedTime:0,pseudoElement:0}),X$=ys(J$),Z$=U({},qd,{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}),e_=ys(Z$),t_=[9,13,27,32],bh=d&&"CompositionEvent"in window,Il=null;d&&"documentMode"in document&&(Il=document.documentMode);var n_=d&&"TextEvent"in window&&!Il,qy=d&&(!bh||Il&&8<Il&&11>=Il),Ky=" ",Vy=!1;function Yy(a,l){switch(a){case"keyup":return t_.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qy(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var fi=!1;function s_(a,l){switch(a){case"compositionend":return Qy(l);case"keypress":return l.which!==32?null:(Vy=!0,Ky);case"textInput":return a=l.data,a===Ky&&Vy?null:a;default:return null}}function r_(a,l){if(fi)return a==="compositionend"||!bh&&Yy(a,l)?(a=Uy(),Hd=hh=ho=null,fi=!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 qy&&l.locale!=="ko"?null:l.data;default:return null}}var o_={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 Jy(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!o_[a.type]:l==="textarea"}function Xy(a,l,m,w){zt(w),l=Jd(l,"onChange"),0<l.length&&(m=new ph("onChange","change",null,m,w),a.push({event:m,listeners:l}))}var zl=null,Dl=null;function a_(a){gb(a,0)}function Kd(a){var l=xi(a);if(Le(l))return a}function i_(a,l){if(a==="change")return l}var Zy=!1;if(d){var wh;if(d){var jh="oninput"in document;if(!jh){var eb=document.createElement("div");eb.setAttribute("oninput","return;"),jh=typeof eb.oninput=="function"}wh=jh}else wh=!1;Zy=wh&&(!document.documentMode||9<document.documentMode)}function tb(){zl&&(zl.detachEvent("onpropertychange",nb),Dl=zl=null)}function nb(a){if(a.propertyName==="value"&&Kd(Dl)){var l=[];Xy(l,Dl,a,ve(a)),En(a_,l)}}function l_(a,l,m){a==="focusin"?(tb(),zl=l,Dl=m,zl.attachEvent("onpropertychange",nb)):a==="focusout"&&tb()}function c_(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Kd(Dl)}function d_(a,l){if(a==="click")return Kd(l)}function u_(a,l){if(a==="input"||a==="change")return Kd(l)}function f_(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var er=typeof Object.is=="function"?Object.is:f_;function Fl(a,l){if(er(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)||!er(a[C],l[C]))return!1}return!0}function sb(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function rb(a,l){var m=sb(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=sb(m)}}function ob(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?ob(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function ab(){for(var a=window,l=Ue();l instanceof a.HTMLIFrameElement;){try{var m=typeof l.contentWindow.location.href=="string"}catch{m=!1}if(m)a=l.contentWindow;else break;l=Ue(a.document)}return l}function kh(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 m_(a){var l=ab(),m=a.focusedElem,w=a.selectionRange;if(l!==m&&m&&m.ownerDocument&&ob(m.ownerDocument.documentElement,m)){if(w!==null&&kh(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=rb(m,T);var I=rb(m,w);C&&I&&(a.rangeCount!==1||a.anchorNode!==C.node||a.anchorOffset!==C.offset||a.focusNode!==I.node||a.focusOffset!==I.offset)&&(l=l.createRange(),l.setStart(C.node,C.offset),a.removeAllRanges(),T>w?(a.addRange(l),a.extend(I.node,I.offset)):(l.setEnd(I.node,I.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 h_=d&&"documentMode"in document&&11>=document.documentMode,mi=null,Nh=null,Ul=null,Sh=!1;function ib(a,l,m){var w=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;Sh||mi==null||mi!==Ue(w)||(w=mi,"selectionStart"in w&&kh(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}),Ul&&Fl(Ul,w)||(Ul=w,w=Jd(Nh,"onSelect"),0<w.length&&(l=new ph("onSelect","select",null,l,m),a.push({event:l,listeners:w}),l.target=mi)))}function Vd(a,l){var m={};return m[a.toLowerCase()]=l.toLowerCase(),m["Webkit"+a]="webkit"+l,m["Moz"+a]="moz"+l,m}var hi={animationend:Vd("Animation","AnimationEnd"),animationiteration:Vd("Animation","AnimationIteration"),animationstart:Vd("Animation","AnimationStart"),transitionend:Vd("Transition","TransitionEnd")},Ch={},lb={};d&&(lb=document.createElement("div").style,"AnimationEvent"in window||(delete hi.animationend.animation,delete hi.animationiteration.animation,delete hi.animationstart.animation),"TransitionEvent"in window||delete hi.transitionend.transition);function Yd(a){if(Ch[a])return Ch[a];if(!hi[a])return a;var l=hi[a],m;for(m in l)if(l.hasOwnProperty(m)&&m in lb)return Ch[a]=l[m];return a}var cb=Yd("animationend"),db=Yd("animationiteration"),ub=Yd("animationstart"),fb=Yd("transitionend"),mb=new Map,hb="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 po(a,l){mb.set(a,l),i(l,[a])}for(var Eh=0;Eh<hb.length;Eh++){var $h=hb[Eh],p_=$h.toLowerCase(),g_=$h[0].toUpperCase()+$h.slice(1);po(p_,"on"+g_)}po(cb,"onAnimationEnd"),po(db,"onAnimationIteration"),po(ub,"onAnimationStart"),po("dblclick","onDoubleClick"),po("focusin","onFocus"),po("focusout","onBlur"),po(fb,"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 Wl="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(" "),x_=new Set("cancel close invalid load scroll toggle".split(" ").concat(Wl));function pb(a,l,m){var w=a.type||"unknown-event";a.currentTarget=m,ee(w,l,void 0,a),a.currentTarget=null}function gb(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 I=w.length-1;0<=I;I--){var V=w[I],Z=V.instance,ue=V.currentTarget;if(V=V.listener,Z!==T&&C.isPropagationStopped())break e;pb(C,V,ue),T=Z}else for(I=0;I<w.length;I++){if(V=w[I],Z=V.instance,ue=V.currentTarget,V=V.listener,Z!==T&&C.isPropagationStopped())break e;pb(C,V,ue),T=Z}}}if(Bn)throw a=Ts,Bn=!1,Ts=null,a}function Bt(a,l){var m=l[Lh];m===void 0&&(m=l[Lh]=new Set);var w=a+"__bubble";m.has(w)||(xb(l,a,2,!1),m.add(w))}function _h(a,l,m){var w=0;l&&(w|=4),xb(m,a,w,l)}var Qd="_reactListening"+Math.random().toString(36).slice(2);function Hl(a){if(!a[Qd]){a[Qd]=!0,r.forEach(function(m){m!=="selectionchange"&&(x_.has(m)||_h(m,!1,a),_h(m,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[Qd]||(l[Qd]=!0,_h("selectionchange",!1,l))}}function xb(a,l,m,w){switch(Fy(l)){case 1:var C=mo;break;case 4:C=hr;break;default:C=fh}m=C.bind(null,l,m,a),C=void 0,!gs||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 Th(a,l,m,w,C){var T=w;if((l&1)===0&&(l&2)===0&&w!==null)e:for(;;){if(w===null)return;var I=w.tag;if(I===3||I===4){var V=w.stateNode.containerInfo;if(V===C||V.nodeType===8&&V.parentNode===C)break;if(I===4)for(I=w.return;I!==null;){var Z=I.tag;if((Z===3||Z===4)&&(Z=I.stateNode.containerInfo,Z===C||Z.nodeType===8&&Z.parentNode===C))return;I=I.return}for(;V!==null;){if(I=ua(V),I===null)return;if(Z=I.tag,Z===5||Z===6){w=T=I;continue e}V=V.parentNode}}w=w.return}En(function(){var ue=T,je=ve(m),Ce=[];e:{var we=mb.get(a);if(we!==void 0){var Ge=ph,Ye=a;switch(a){case"keypress":if(Bd(m)===0)break e;case"keydown":case"keyup":Ge=K$;break;case"focusin":Ye="focus",Ge=vh;break;case"focusout":Ye="blur",Ge=vh;break;case"beforeblur":case"afterblur":Ge=vh;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=Hy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ge=P$;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ge=Q$;break;case cb:case db:case ub:Ge=z$;break;case fb:Ge=X$;break;case"scroll":Ge=O$;break;case"wheel":Ge=e_;break;case"copy":case"cut":case"paste":Ge=F$;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ge=Gy}var Xe=(l&4)!==0,on=!Xe&&a==="scroll",ie=Xe?we!==null?we+"Capture":null:we;Xe=[];for(var ne=ue,ce;ne!==null;){ce=ne;var Ae=ce.stateNode;if(ce.tag===5&&Ae!==null&&(ce=Ae,ie!==null&&(Ae=Wn(ne,ie),Ae!=null&&Xe.push(Bl(ne,Ae,ce)))),on)break;ne=ne.return}0<Xe.length&&(we=new Ge(we,Ye,null,m,je),Ce.push({event:we,listeners:Xe}))}}if((l&7)===0){e:{if(we=a==="mouseover"||a==="pointerover",Ge=a==="mouseout"||a==="pointerout",we&&m!==Q&&(Ye=m.relatedTarget||m.fromElement)&&(ua(Ye)||Ye[Ir]))break e;if((Ge||we)&&(we=je.window===je?je:(we=je.ownerDocument)?we.defaultView||we.parentWindow:window,Ge?(Ye=m.relatedTarget||m.toElement,Ge=ue,Ye=Ye?ua(Ye):null,Ye!==null&&(on=Me(Ye),Ye!==on||Ye.tag!==5&&Ye.tag!==6)&&(Ye=null)):(Ge=null,Ye=ue),Ge!==Ye)){if(Xe=Hy,Ae="onMouseLeave",ie="onMouseEnter",ne="mouse",(a==="pointerout"||a==="pointerover")&&(Xe=Gy,Ae="onPointerLeave",ie="onPointerEnter",ne="pointer"),on=Ge==null?we:xi(Ge),ce=Ye==null?we:xi(Ye),we=new Xe(Ae,ne+"leave",Ge,m,je),we.target=on,we.relatedTarget=ce,Ae=null,ua(je)===ue&&(Xe=new Xe(ie,ne+"enter",Ye,m,je),Xe.target=ce,Xe.relatedTarget=on,Ae=Xe),on=Ae,Ge&&Ye)t:{for(Xe=Ge,ie=Ye,ne=0,ce=Xe;ce;ce=pi(ce))ne++;for(ce=0,Ae=ie;Ae;Ae=pi(Ae))ce++;for(;0<ne-ce;)Xe=pi(Xe),ne--;for(;0<ce-ne;)ie=pi(ie),ce--;for(;ne--;){if(Xe===ie||ie!==null&&Xe===ie.alternate)break t;Xe=pi(Xe),ie=pi(ie)}Xe=null}else Xe=null;Ge!==null&&vb(Ce,we,Ge,Xe,!1),Ye!==null&&on!==null&&vb(Ce,on,Ye,Xe,!0)}}e:{if(we=ue?xi(ue):window,Ge=we.nodeName&&we.nodeName.toLowerCase(),Ge==="select"||Ge==="input"&&we.type==="file")var tt=i_;else if(Jy(we))if(Zy)tt=u_;else{tt=c_;var rt=l_}else(Ge=we.nodeName)&&Ge.toLowerCase()==="input"&&(we.type==="checkbox"||we.type==="radio")&&(tt=d_);if(tt&&(tt=tt(a,ue))){Xy(Ce,tt,m,je);break e}rt&&rt(a,we,ue),a==="focusout"&&(rt=we._wrapperState)&&rt.controlled&&we.type==="number"&&he(we,"number",we.value)}switch(rt=ue?xi(ue):window,a){case"focusin":(Jy(rt)||rt.contentEditable==="true")&&(mi=rt,Nh=ue,Ul=null);break;case"focusout":Ul=Nh=mi=null;break;case"mousedown":Sh=!0;break;case"contextmenu":case"mouseup":case"dragend":Sh=!1,ib(Ce,m,je);break;case"selectionchange":if(h_)break;case"keydown":case"keyup":ib(Ce,m,je)}var ot;if(bh)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 fi?Yy(a,m)&&(ct="onCompositionEnd"):a==="keydown"&&m.keyCode===229&&(ct="onCompositionStart");ct&&(qy&&m.locale!=="ko"&&(fi||ct!=="onCompositionStart"?ct==="onCompositionEnd"&&fi&&(ot=Uy()):(ho=je,hh="value"in ho?ho.value:ho.textContent,fi=!0)),rt=Jd(ue,ct),0<rt.length&&(ct=new By(ct,a,null,m,je),Ce.push({event:ct,listeners:rt}),ot?ct.data=ot:(ot=Qy(m),ot!==null&&(ct.data=ot)))),(ot=n_?s_(a,m):r_(a,m))&&(ue=Jd(ue,"onBeforeInput"),0<ue.length&&(je=new By("onBeforeInput","beforeinput",null,m,je),Ce.push({event:je,listeners:ue}),je.data=ot))}gb(Ce,l)})}function Bl(a,l,m){return{instance:a,listener:l,currentTarget:m}}function Jd(a,l){for(var m=l+"Capture",w=[];a!==null;){var C=a,T=C.stateNode;C.tag===5&&T!==null&&(C=T,T=Wn(a,m),T!=null&&w.unshift(Bl(a,T,C)),T=Wn(a,l),T!=null&&w.push(Bl(a,T,C))),a=a.return}return w}function pi(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function vb(a,l,m,w,C){for(var T=l._reactName,I=[];m!==null&&m!==w;){var V=m,Z=V.alternate,ue=V.stateNode;if(Z!==null&&Z===w)break;V.tag===5&&ue!==null&&(V=ue,C?(Z=Wn(m,T),Z!=null&&I.unshift(Bl(m,Z,V))):C||(Z=Wn(m,T),Z!=null&&I.push(Bl(m,Z,V)))),m=m.return}I.length!==0&&a.push({event:l,listeners:I})}var v_=/\r\n?/g,y_=/\u0000|\uFFFD/g;function yb(a){return(typeof a=="string"?a:""+a).replace(v_,`
|
|
38
|
+
`).replace(y_,"")}function Xd(a,l,m){if(l=yb(l),yb(a)!==l&&m)throw Error(s(425))}function Zd(){}var Rh=null,Ah=null;function Oh(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 Mh=typeof setTimeout=="function"?setTimeout:void 0,b_=typeof clearTimeout=="function"?clearTimeout:void 0,bb=typeof Promise=="function"?Promise:void 0,w_=typeof queueMicrotask=="function"?queueMicrotask:typeof bb<"u"?function(a){return bb.resolve(null).then(a).catch(j_)}:Mh;function j_(a){setTimeout(function(){throw a})}function Ph(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),fo(l);return}w--}else m!=="$"&&m!=="$?"&&m!=="$!"||w++;m=C}while(m);fo(l)}function go(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 wb(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 gi=Math.random().toString(36).slice(2),pr="__reactFiber$"+gi,Gl="__reactProps$"+gi,Ir="__reactContainer$"+gi,Lh="__reactEvents$"+gi,k_="__reactListeners$"+gi,N_="__reactHandles$"+gi;function ua(a){var l=a[pr];if(l)return l;for(var m=a.parentNode;m;){if(l=m[Ir]||m[pr]){if(m=l.alternate,l.child!==null||m!==null&&m.child!==null)for(a=wb(a);a!==null;){if(m=a[pr])return m;a=wb(a)}return l}a=m,m=a.parentNode}return null}function ql(a){return a=a[pr]||a[Ir],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function xi(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(s(33))}function eu(a){return a[Gl]||null}var Ih=[],vi=-1;function xo(a){return{current:a}}function Gt(a){0>vi||(a.current=Ih[vi],Ih[vi]=null,vi--)}function Ft(a,l){vi++,Ih[vi]=a.current,a.current=l}var vo={},Mn=xo(vo),as=xo(!1),fa=vo;function yi(a,l){var m=a.type.contextTypes;if(!m)return vo;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 is(a){return a=a.childContextTypes,a!=null}function tu(){Gt(as),Gt(Mn)}function jb(a,l,m){if(Mn.current!==vo)throw Error(s(168));Ft(Mn,l),Ft(as,m)}function kb(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,fe(a)||"Unknown",C));return U({},m,w)}function nu(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||vo,fa=Mn.current,Ft(Mn,a),Ft(as,as.current),!0}function Nb(a,l,m){var w=a.stateNode;if(!w)throw Error(s(169));m?(a=kb(a,l,fa),w.__reactInternalMemoizedMergedChildContext=a,Gt(as),Gt(Mn),Ft(Mn,a)):Gt(as),Ft(as,m)}var zr=null,su=!1,zh=!1;function Sb(a){zr===null?zr=[a]:zr.push(a)}function S_(a){su=!0,Sb(a)}function yo(){if(!zh&&zr!==null){zh=!0;var a=0,l=Et;try{var m=zr;for(Et=1;a<m.length;a++){var w=m[a];do w=w(!0);while(w!==null)}zr=null,su=!1}catch(C){throw zr!==null&&(zr=zr.slice(a+1)),be($n,yo),C}finally{Et=l,zh=!1}}return null}var bi=[],wi=0,ru=null,ou=0,As=[],Os=0,ma=null,Dr=1,Fr="";function ha(a,l){bi[wi++]=ou,bi[wi++]=ru,ru=a,ou=l}function Cb(a,l,m){As[Os++]=Dr,As[Os++]=Fr,As[Os++]=ma,ma=a;var w=Dr;a=Fr;var C=32-rs(w)-1;w&=~(1<<C),m+=1;var T=32-rs(l)+C;if(30<T){var I=C-C%5;T=(w&(1<<I)-1).toString(32),w>>=I,C-=I,Dr=1<<32-rs(l)+C|m<<C|w,Fr=T+a}else Dr=1<<T|m<<C|w,Fr=a}function Dh(a){a.return!==null&&(ha(a,1),Cb(a,1,0))}function Fh(a){for(;a===ru;)ru=bi[--wi],bi[wi]=null,ou=bi[--wi],bi[wi]=null;for(;a===ma;)ma=As[--Os],As[Os]=null,Fr=As[--Os],As[Os]=null,Dr=As[--Os],As[Os]=null}var bs=null,ws=null,Vt=!1,tr=null;function Eb(a,l){var m=Is(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 $b(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,bs=a,ws=go(l.firstChild),!0):!1;case 6:return l=a.pendingProps===""||l.nodeType!==3?null:l,l!==null?(a.stateNode=l,bs=a,ws=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(m=ma!==null?{id:Dr,overflow:Fr}:null,a.memoizedState={dehydrated:l,treeContext:m,retryLane:1073741824},m=Is(18,null,null,0),m.stateNode=l,m.return=a,a.child=m,bs=a,ws=null,!0):!1;default:return!1}}function Uh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Wh(a){if(Vt){var l=ws;if(l){var m=l;if(!$b(a,l)){if(Uh(a))throw Error(s(418));l=go(m.nextSibling);var w=bs;l&&$b(a,l)?Eb(w,m):(a.flags=a.flags&-4097|2,Vt=!1,bs=a)}}else{if(Uh(a))throw Error(s(418));a.flags=a.flags&-4097|2,Vt=!1,bs=a}}}function _b(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;bs=a}function au(a){if(a!==bs)return!1;if(!Vt)return _b(a),Vt=!0,!1;var l;if((l=a.tag!==3)&&!(l=a.tag!==5)&&(l=a.type,l=l!=="head"&&l!=="body"&&!Oh(a.type,a.memoizedProps)),l&&(l=ws)){if(Uh(a))throw Tb(),Error(s(418));for(;l;)Eb(a,l),l=go(l.nextSibling)}if(_b(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){ws=go(a.nextSibling);break e}l--}else m!=="$"&&m!=="$!"&&m!=="$?"||l++}a=a.nextSibling}ws=null}}else ws=bs?go(a.stateNode.nextSibling):null;return!0}function Tb(){for(var a=ws;a;)a=go(a.nextSibling)}function ji(){ws=bs=null,Vt=!1}function Hh(a){tr===null?tr=[a]:tr.push(a)}var C_=N.ReactCurrentBatchConfig;function Kl(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(I){var V=C.refs;I===null?delete V[T]:V[T]=I},l._stringRef=T,l)}if(typeof a!="string")throw Error(s(284));if(!m._owner)throw Error(s(290,a))}return a}function iu(a,l){throw a=Object.prototype.toString.call(l),Error(s(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a))}function Rb(a){var l=a._init;return l(a._payload)}function Ab(a){function l(ie,ne){if(a){var ce=ie.deletions;ce===null?(ie.deletions=[ne],ie.flags|=16):ce.push(ne)}}function m(ie,ne){if(!a)return null;for(;ne!==null;)l(ie,ne),ne=ne.sibling;return null}function w(ie,ne){for(ie=new Map;ne!==null;)ne.key!==null?ie.set(ne.key,ne):ie.set(ne.index,ne),ne=ne.sibling;return ie}function C(ie,ne){return ie=Eo(ie,ne),ie.index=0,ie.sibling=null,ie}function T(ie,ne,ce){return ie.index=ce,a?(ce=ie.alternate,ce!==null?(ce=ce.index,ce<ne?(ie.flags|=2,ne):ce):(ie.flags|=2,ne)):(ie.flags|=1048576,ne)}function I(ie){return a&&ie.alternate===null&&(ie.flags|=2),ie}function V(ie,ne,ce,Ae){return ne===null||ne.tag!==6?(ne=Mp(ce,ie.mode,Ae),ne.return=ie,ne):(ne=C(ne,ce),ne.return=ie,ne)}function Z(ie,ne,ce,Ae){var tt=ce.type;return tt===M?je(ie,ne,ce.props.children,Ae,ce.key):ne!==null&&(ne.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===H&&Rb(tt)===ne.type)?(Ae=C(ne,ce.props),Ae.ref=Kl(ie,ne,ce),Ae.return=ie,Ae):(Ae=Ru(ce.type,ce.key,ce.props,null,ie.mode,Ae),Ae.ref=Kl(ie,ne,ce),Ae.return=ie,Ae)}function ue(ie,ne,ce,Ae){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==ce.containerInfo||ne.stateNode.implementation!==ce.implementation?(ne=Pp(ce,ie.mode,Ae),ne.return=ie,ne):(ne=C(ne,ce.children||[]),ne.return=ie,ne)}function je(ie,ne,ce,Ae,tt){return ne===null||ne.tag!==7?(ne=ja(ce,ie.mode,Ae,tt),ne.return=ie,ne):(ne=C(ne,ce),ne.return=ie,ne)}function Ce(ie,ne,ce){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=Mp(""+ne,ie.mode,ce),ne.return=ie,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case $:return ce=Ru(ne.type,ne.key,ne.props,null,ie.mode,ce),ce.ref=Kl(ie,null,ne),ce.return=ie,ce;case _:return ne=Pp(ne,ie.mode,ce),ne.return=ie,ne;case H:var Ae=ne._init;return Ce(ie,Ae(ne._payload),ce)}if(Ie(ne)||G(ne))return ne=ja(ne,ie.mode,ce,null),ne.return=ie,ne;iu(ie,ne)}return null}function we(ie,ne,ce,Ae){var tt=ne!==null?ne.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return tt!==null?null:V(ie,ne,""+ce,Ae);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:return ce.key===tt?Z(ie,ne,ce,Ae):null;case _:return ce.key===tt?ue(ie,ne,ce,Ae):null;case H:return tt=ce._init,we(ie,ne,tt(ce._payload),Ae)}if(Ie(ce)||G(ce))return tt!==null?null:je(ie,ne,ce,Ae,null);iu(ie,ce)}return null}function Ge(ie,ne,ce,Ae,tt){if(typeof Ae=="string"&&Ae!==""||typeof Ae=="number")return ie=ie.get(ce)||null,V(ne,ie,""+Ae,tt);if(typeof Ae=="object"&&Ae!==null){switch(Ae.$$typeof){case $:return ie=ie.get(Ae.key===null?ce:Ae.key)||null,Z(ne,ie,Ae,tt);case _:return ie=ie.get(Ae.key===null?ce:Ae.key)||null,ue(ne,ie,Ae,tt);case H:var rt=Ae._init;return Ge(ie,ne,ce,rt(Ae._payload),tt)}if(Ie(Ae)||G(Ae))return ie=ie.get(ce)||null,je(ne,ie,Ae,tt,null);iu(ne,Ae)}return null}function Ye(ie,ne,ce,Ae){for(var tt=null,rt=null,ot=ne,ct=ne=0,kn=null;ot!==null&&ct<ce.length;ct++){ot.index>ct?(kn=ot,ot=null):kn=ot.sibling;var _t=we(ie,ot,ce[ct],Ae);if(_t===null){ot===null&&(ot=kn);break}a&&ot&&_t.alternate===null&&l(ie,ot),ne=T(_t,ne,ct),rt===null?tt=_t:rt.sibling=_t,rt=_t,ot=kn}if(ct===ce.length)return m(ie,ot),Vt&&ha(ie,ct),tt;if(ot===null){for(;ct<ce.length;ct++)ot=Ce(ie,ce[ct],Ae),ot!==null&&(ne=T(ot,ne,ct),rt===null?tt=ot:rt.sibling=ot,rt=ot);return Vt&&ha(ie,ct),tt}for(ot=w(ie,ot);ct<ce.length;ct++)kn=Ge(ot,ie,ct,ce[ct],Ae),kn!==null&&(a&&kn.alternate!==null&&ot.delete(kn.key===null?ct:kn.key),ne=T(kn,ne,ct),rt===null?tt=kn:rt.sibling=kn,rt=kn);return a&&ot.forEach(function($o){return l(ie,$o)}),Vt&&ha(ie,ct),tt}function Xe(ie,ne,ce,Ae){var tt=G(ce);if(typeof tt!="function")throw Error(s(150));if(ce=tt.call(ce),ce==null)throw Error(s(151));for(var rt=tt=null,ot=ne,ct=ne=0,kn=null,_t=ce.next();ot!==null&&!_t.done;ct++,_t=ce.next()){ot.index>ct?(kn=ot,ot=null):kn=ot.sibling;var $o=we(ie,ot,_t.value,Ae);if($o===null){ot===null&&(ot=kn);break}a&&ot&&$o.alternate===null&&l(ie,ot),ne=T($o,ne,ct),rt===null?tt=$o:rt.sibling=$o,rt=$o,ot=kn}if(_t.done)return m(ie,ot),Vt&&ha(ie,ct),tt;if(ot===null){for(;!_t.done;ct++,_t=ce.next())_t=Ce(ie,_t.value,Ae),_t!==null&&(ne=T(_t,ne,ct),rt===null?tt=_t:rt.sibling=_t,rt=_t);return Vt&&ha(ie,ct),tt}for(ot=w(ie,ot);!_t.done;ct++,_t=ce.next())_t=Ge(ot,ie,ct,_t.value,Ae),_t!==null&&(a&&_t.alternate!==null&&ot.delete(_t.key===null?ct:_t.key),ne=T(_t,ne,ct),rt===null?tt=_t:rt.sibling=_t,rt=_t);return a&&ot.forEach(function(oT){return l(ie,oT)}),Vt&&ha(ie,ct),tt}function on(ie,ne,ce,Ae){if(typeof ce=="object"&&ce!==null&&ce.type===M&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:e:{for(var tt=ce.key,rt=ne;rt!==null;){if(rt.key===tt){if(tt=ce.type,tt===M){if(rt.tag===7){m(ie,rt.sibling),ne=C(rt,ce.props.children),ne.return=ie,ie=ne;break e}}else if(rt.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===H&&Rb(tt)===rt.type){m(ie,rt.sibling),ne=C(rt,ce.props),ne.ref=Kl(ie,rt,ce),ne.return=ie,ie=ne;break e}m(ie,rt);break}else l(ie,rt);rt=rt.sibling}ce.type===M?(ne=ja(ce.props.children,ie.mode,Ae,ce.key),ne.return=ie,ie=ne):(Ae=Ru(ce.type,ce.key,ce.props,null,ie.mode,Ae),Ae.ref=Kl(ie,ne,ce),Ae.return=ie,ie=Ae)}return I(ie);case _:e:{for(rt=ce.key;ne!==null;){if(ne.key===rt)if(ne.tag===4&&ne.stateNode.containerInfo===ce.containerInfo&&ne.stateNode.implementation===ce.implementation){m(ie,ne.sibling),ne=C(ne,ce.children||[]),ne.return=ie,ie=ne;break e}else{m(ie,ne);break}else l(ie,ne);ne=ne.sibling}ne=Pp(ce,ie.mode,Ae),ne.return=ie,ie=ne}return I(ie);case H:return rt=ce._init,on(ie,ne,rt(ce._payload),Ae)}if(Ie(ce))return Ye(ie,ne,ce,Ae);if(G(ce))return Xe(ie,ne,ce,Ae);iu(ie,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,ne!==null&&ne.tag===6?(m(ie,ne.sibling),ne=C(ne,ce),ne.return=ie,ie=ne):(m(ie,ne),ne=Mp(ce,ie.mode,Ae),ne.return=ie,ie=ne),I(ie)):m(ie,ne)}return on}var ki=Ab(!0),Ob=Ab(!1),lu=xo(null),cu=null,Ni=null,Bh=null;function Gh(){Bh=Ni=cu=null}function qh(a){var l=lu.current;Gt(lu),a._currentValue=l}function Kh(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 Si(a,l){cu=a,Bh=Ni=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&l)!==0&&(ls=!0),a.firstContext=null)}function Ms(a){var l=a._currentValue;if(Bh!==a)if(a={context:a,memoizedValue:l,next:null},Ni===null){if(cu===null)throw Error(s(308));Ni=a,cu.dependencies={lanes:0,firstContext:a}}else Ni=Ni.next=a;return l}var pa=null;function Vh(a){pa===null?pa=[a]:pa.push(a)}function Mb(a,l,m,w){var C=l.interleaved;return C===null?(m.next=m,Vh(l)):(m.next=C.next,C.next=m),l.interleaved=m,Ur(a,w)}function Ur(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 bo=!1;function Yh(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Pb(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 Wr(a,l){return{eventTime:a,lane:l,tag:0,payload:null,callback:null,next:null}}function wo(a,l,m){var w=a.updateQueue;if(w===null)return null;if(w=w.shared,(St&2)!==0){var C=w.pending;return C===null?l.next=l:(l.next=C.next,C.next=l),w.pending=l,Ur(a,m)}return C=w.interleaved,C===null?(l.next=l,Vh(w)):(l.next=C.next,C.next=l),w.interleaved=l,Ur(a,m)}function du(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,ii(a,m)}}function Lb(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 I={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};T===null?C=T=I:T=T.next=I,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 uu(a,l,m,w){var C=a.updateQueue;bo=!1;var T=C.firstBaseUpdate,I=C.lastBaseUpdate,V=C.shared.pending;if(V!==null){C.shared.pending=null;var Z=V,ue=Z.next;Z.next=null,I===null?T=ue:I.next=ue,I=Z;var je=a.alternate;je!==null&&(je=je.updateQueue,V=je.lastBaseUpdate,V!==I&&(V===null?je.firstBaseUpdate=ue:V.next=ue,je.lastBaseUpdate=Z))}if(T!==null){var Ce=C.baseState;I=0,je=ue=Z=null,V=T;do{var we=V.lane,Ge=V.eventTime;if((w&we)===we){je!==null&&(je=je.next={eventTime:Ge,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var Ye=a,Xe=V;switch(we=l,Ge=m,Xe.tag){case 1:if(Ye=Xe.payload,typeof Ye=="function"){Ce=Ye.call(Ge,Ce,we);break e}Ce=Ye;break e;case 3:Ye.flags=Ye.flags&-65537|128;case 0:if(Ye=Xe.payload,we=typeof Ye=="function"?Ye.call(Ge,Ce,we):Ye,we==null)break e;Ce=U({},Ce,we);break e;case 2:bo=!0}}V.callback!==null&&V.lane!==0&&(a.flags|=64,we=C.effects,we===null?C.effects=[V]:we.push(V))}else Ge={eventTime:Ge,lane:we,tag:V.tag,payload:V.payload,callback:V.callback,next:null},je===null?(ue=je=Ge,Z=Ce):je=je.next=Ge,I|=we;if(V=V.next,V===null){if(V=C.shared.pending,V===null)break;we=V,V=we.next,we.next=null,C.lastBaseUpdate=we,C.shared.pending=null}}while(!0);if(je===null&&(Z=Ce),C.baseState=Z,C.firstBaseUpdate=ue,C.lastBaseUpdate=je,l=C.shared.interleaved,l!==null){C=l;do I|=C.lane,C=C.next;while(C!==l)}else T===null&&(C.shared.lanes=0);va|=I,a.lanes=I,a.memoizedState=Ce}}function Ib(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 Vl={},gr=xo(Vl),Yl=xo(Vl),Ql=xo(Vl);function ga(a){if(a===Vl)throw Error(s(174));return a}function Qh(a,l){switch(Ft(Ql,l),Ft(Yl,a),Ft(gr,Vl),a=l.nodeType,a){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:dt(null,"");break;default:a=a===8?l.parentNode:l,l=a.namespaceURI||null,a=a.tagName,l=dt(l,a)}Gt(gr),Ft(gr,l)}function Ci(){Gt(gr),Gt(Yl),Gt(Ql)}function zb(a){ga(Ql.current);var l=ga(gr.current),m=dt(l,a.type);l!==m&&(Ft(Yl,a),Ft(gr,m))}function Jh(a){Yl.current===a&&(Gt(gr),Gt(Yl))}var Xt=xo(0);function fu(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 Xh=[];function Zh(){for(var a=0;a<Xh.length;a++)Xh[a]._workInProgressVersionPrimary=null;Xh.length=0}var mu=N.ReactCurrentDispatcher,ep=N.ReactCurrentBatchConfig,xa=0,Zt=null,xn=null,wn=null,hu=!1,Jl=!1,Xl=0,E_=0;function Pn(){throw Error(s(321))}function tp(a,l){if(l===null)return!1;for(var m=0;m<l.length&&m<a.length;m++)if(!er(a[m],l[m]))return!1;return!0}function np(a,l,m,w,C,T){if(xa=T,Zt=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,mu.current=a===null||a.memoizedState===null?R_:A_,a=m(w,C),Jl){T=0;do{if(Jl=!1,Xl=0,25<=T)throw Error(s(301));T+=1,wn=xn=null,l.updateQueue=null,mu.current=O_,a=m(w,C)}while(Jl)}if(mu.current=xu,l=xn!==null&&xn.next!==null,xa=0,wn=xn=Zt=null,hu=!1,l)throw Error(s(300));return a}function sp(){var a=Xl!==0;return Xl=0,a}function xr(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return wn===null?Zt.memoizedState=wn=a:wn=wn.next=a,wn}function Ps(){if(xn===null){var a=Zt.alternate;a=a!==null?a.memoizedState:null}else a=xn.next;var l=wn===null?Zt.memoizedState:wn.next;if(l!==null)wn=l,xn=a;else{if(a===null)throw Error(s(310));xn=a,a={memoizedState:xn.memoizedState,baseState:xn.baseState,baseQueue:xn.baseQueue,queue:xn.queue,next:null},wn===null?Zt.memoizedState=wn=a:wn=wn.next=a}return wn}function Zl(a,l){return typeof l=="function"?l(a):l}function rp(a){var l=Ps(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=a;var w=xn,C=w.baseQueue,T=m.pending;if(T!==null){if(C!==null){var I=C.next;C.next=T.next,T.next=I}w.baseQueue=C=T,m.pending=null}if(C!==null){T=C.next,w=w.baseState;var V=I=null,Z=null,ue=T;do{var je=ue.lane;if((xa&je)===je)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 Ce={lane:je,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};Z===null?(V=Z=Ce,I=w):Z=Z.next=Ce,Zt.lanes|=je,va|=je}ue=ue.next}while(ue!==null&&ue!==T);Z===null?I=w:Z.next=V,er(w,l.memoizedState)||(ls=!0),l.memoizedState=w,l.baseState=I,l.baseQueue=Z,m.lastRenderedState=w}if(a=m.interleaved,a!==null){C=a;do T=C.lane,Zt.lanes|=T,va|=T,C=C.next;while(C!==a)}else C===null&&(m.lanes=0);return[l.memoizedState,m.dispatch]}function op(a){var l=Ps(),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 I=C=C.next;do T=a(T,I.action),I=I.next;while(I!==C);er(T,l.memoizedState)||(ls=!0),l.memoizedState=T,l.baseQueue===null&&(l.baseState=T),m.lastRenderedState=T}return[T,w]}function Db(){}function Fb(a,l){var m=Zt,w=Ps(),C=l(),T=!er(w.memoizedState,C);if(T&&(w.memoizedState=C,ls=!0),w=w.queue,ap(Hb.bind(null,m,w,a),[a]),w.getSnapshot!==l||T||wn!==null&&wn.memoizedState.tag&1){if(m.flags|=2048,ec(9,Wb.bind(null,m,w,C,l),void 0,null),jn===null)throw Error(s(349));(xa&30)!==0||Ub(m,l,C)}return C}function Ub(a,l,m){a.flags|=16384,a={getSnapshot:l,value:m},l=Zt.updateQueue,l===null?(l={lastEffect:null,stores:null},Zt.updateQueue=l,l.stores=[a]):(m=l.stores,m===null?l.stores=[a]:m.push(a))}function Wb(a,l,m,w){l.value=m,l.getSnapshot=w,Bb(l)&&Gb(a)}function Hb(a,l,m){return m(function(){Bb(l)&&Gb(a)})}function Bb(a){var l=a.getSnapshot;a=a.value;try{var m=l();return!er(a,m)}catch{return!0}}function Gb(a){var l=Ur(a,1);l!==null&&or(l,a,1,-1)}function qb(a){var l=xr();return typeof a=="function"&&(a=a()),l.memoizedState=l.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Zl,lastRenderedState:a},l.queue=a,a=a.dispatch=T_.bind(null,Zt,a),[l.memoizedState,a]}function ec(a,l,m,w){return a={tag:a,create:l,destroy:m,deps:w,next:null},l=Zt.updateQueue,l===null?(l={lastEffect:null,stores:null},Zt.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 Kb(){return Ps().memoizedState}function pu(a,l,m,w){var C=xr();Zt.flags|=a,C.memoizedState=ec(1|l,m,void 0,w===void 0?null:w)}function gu(a,l,m,w){var C=Ps();w=w===void 0?null:w;var T=void 0;if(xn!==null){var I=xn.memoizedState;if(T=I.destroy,w!==null&&tp(w,I.deps)){C.memoizedState=ec(l,m,T,w);return}}Zt.flags|=a,C.memoizedState=ec(1|l,m,T,w)}function Vb(a,l){return pu(8390656,8,a,l)}function ap(a,l){return gu(2048,8,a,l)}function Yb(a,l){return gu(4,2,a,l)}function Qb(a,l){return gu(4,4,a,l)}function Jb(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 Xb(a,l,m){return m=m!=null?m.concat([a]):null,gu(4,4,Jb.bind(null,l,a),m)}function ip(){}function Zb(a,l){var m=Ps();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&tp(l,w[1])?w[0]:(m.memoizedState=[a,l],a)}function ew(a,l){var m=Ps();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&tp(l,w[1])?w[0]:(a=a(),m.memoizedState=[a,l],a)}function tw(a,l,m){return(xa&21)===0?(a.baseState&&(a.baseState=!1,ls=!0),a.memoizedState=m):(er(m,l)||(m=_l(),Zt.lanes|=m,va|=m,a.baseState=!0),l)}function $_(a,l){var m=Et;Et=m!==0&&4>m?m:4,a(!0);var w=ep.transition;ep.transition={};try{a(!1),l()}finally{Et=m,ep.transition=w}}function nw(){return Ps().memoizedState}function __(a,l,m){var w=So(a);if(m={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null},sw(a))rw(l,m);else if(m=Mb(a,l,m,w),m!==null){var C=Vn();or(m,a,w,C),ow(m,l,w)}}function T_(a,l,m){var w=So(a),C={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null};if(sw(a))rw(l,C);else{var T=a.alternate;if(a.lanes===0&&(T===null||T.lanes===0)&&(T=l.lastRenderedReducer,T!==null))try{var I=l.lastRenderedState,V=T(I,m);if(C.hasEagerState=!0,C.eagerState=V,er(V,I)){var Z=l.interleaved;Z===null?(C.next=C,Vh(l)):(C.next=Z.next,Z.next=C),l.interleaved=C;return}}catch{}finally{}m=Mb(a,l,C,w),m!==null&&(C=Vn(),or(m,a,w,C),ow(m,l,w))}}function sw(a){var l=a.alternate;return a===Zt||l!==null&&l===Zt}function rw(a,l){Jl=hu=!0;var m=a.pending;m===null?l.next=l:(l.next=m.next,m.next=l),a.pending=l}function ow(a,l,m){if((m&4194240)!==0){var w=l.lanes;w&=a.pendingLanes,m|=w,l.lanes=m,ii(a,m)}}var xu={readContext:Ms,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},R_={readContext:Ms,useCallback:function(a,l){return xr().memoizedState=[a,l===void 0?null:l],a},useContext:Ms,useEffect:Vb,useImperativeHandle:function(a,l,m){return m=m!=null?m.concat([a]):null,pu(4194308,4,Jb.bind(null,l,a),m)},useLayoutEffect:function(a,l){return pu(4194308,4,a,l)},useInsertionEffect:function(a,l){return pu(4,2,a,l)},useMemo:function(a,l){var m=xr();return l=l===void 0?null:l,a=a(),m.memoizedState=[a,l],a},useReducer:function(a,l,m){var w=xr();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=__.bind(null,Zt,a),[w.memoizedState,a]},useRef:function(a){var l=xr();return a={current:a},l.memoizedState=a},useState:qb,useDebugValue:ip,useDeferredValue:function(a){return xr().memoizedState=a},useTransition:function(){var a=qb(!1),l=a[0];return a=$_.bind(null,a[1]),xr().memoizedState=a,[l,a]},useMutableSource:function(){},useSyncExternalStore:function(a,l,m){var w=Zt,C=xr();if(Vt){if(m===void 0)throw Error(s(407));m=m()}else{if(m=l(),jn===null)throw Error(s(349));(xa&30)!==0||Ub(w,l,m)}C.memoizedState=m;var T={value:m,getSnapshot:l};return C.queue=T,Vb(Hb.bind(null,w,T,a),[a]),w.flags|=2048,ec(9,Wb.bind(null,w,T,m,l),void 0,null),m},useId:function(){var a=xr(),l=jn.identifierPrefix;if(Vt){var m=Fr,w=Dr;m=(w&~(1<<32-rs(w)-1)).toString(32)+m,l=":"+l+"R"+m,m=Xl++,0<m&&(l+="H"+m.toString(32)),l+=":"}else m=E_++,l=":"+l+"r"+m.toString(32)+":";return a.memoizedState=l},unstable_isNewReconciler:!1},A_={readContext:Ms,useCallback:Zb,useContext:Ms,useEffect:ap,useImperativeHandle:Xb,useInsertionEffect:Yb,useLayoutEffect:Qb,useMemo:ew,useReducer:rp,useRef:Kb,useState:function(){return rp(Zl)},useDebugValue:ip,useDeferredValue:function(a){var l=Ps();return tw(l,xn.memoizedState,a)},useTransition:function(){var a=rp(Zl)[0],l=Ps().memoizedState;return[a,l]},useMutableSource:Db,useSyncExternalStore:Fb,useId:nw,unstable_isNewReconciler:!1},O_={readContext:Ms,useCallback:Zb,useContext:Ms,useEffect:ap,useImperativeHandle:Xb,useInsertionEffect:Yb,useLayoutEffect:Qb,useMemo:ew,useReducer:op,useRef:Kb,useState:function(){return op(Zl)},useDebugValue:ip,useDeferredValue:function(a){var l=Ps();return xn===null?l.memoizedState=a:tw(l,xn.memoizedState,a)},useTransition:function(){var a=op(Zl)[0],l=Ps().memoizedState;return[a,l]},useMutableSource:Db,useSyncExternalStore:Fb,useId:nw,unstable_isNewReconciler:!1};function nr(a,l){if(a&&a.defaultProps){l=U({},l),a=a.defaultProps;for(var m in a)l[m]===void 0&&(l[m]=a[m]);return l}return l}function lp(a,l,m,w){l=a.memoizedState,m=m(w,l),m=m==null?l:U({},l,m),a.memoizedState=m,a.lanes===0&&(a.updateQueue.baseState=m)}var vu={isMounted:function(a){return(a=a._reactInternals)?Me(a)===a:!1},enqueueSetState:function(a,l,m){a=a._reactInternals;var w=Vn(),C=So(a),T=Wr(w,C);T.payload=l,m!=null&&(T.callback=m),l=wo(a,T,C),l!==null&&(or(l,a,C,w),du(l,a,C))},enqueueReplaceState:function(a,l,m){a=a._reactInternals;var w=Vn(),C=So(a),T=Wr(w,C);T.tag=1,T.payload=l,m!=null&&(T.callback=m),l=wo(a,T,C),l!==null&&(or(l,a,C,w),du(l,a,C))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var m=Vn(),w=So(a),C=Wr(m,w);C.tag=2,l!=null&&(C.callback=l),l=wo(a,C,w),l!==null&&(or(l,a,w,m),du(l,a,w))}};function aw(a,l,m,w,C,T,I){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(w,T,I):l.prototype&&l.prototype.isPureReactComponent?!Fl(m,w)||!Fl(C,T):!0}function iw(a,l,m){var w=!1,C=vo,T=l.contextType;return typeof T=="object"&&T!==null?T=Ms(T):(C=is(l)?fa:Mn.current,w=l.contextTypes,T=(w=w!=null)?yi(a,C):vo),l=new l(m,T),a.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=vu,a.stateNode=l,l._reactInternals=a,w&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=C,a.__reactInternalMemoizedMaskedChildContext=T),l}function lw(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&&vu.enqueueReplaceState(l,l.state,null)}function cp(a,l,m,w){var C=a.stateNode;C.props=m,C.state=a.memoizedState,C.refs={},Yh(a);var T=l.contextType;typeof T=="object"&&T!==null?C.context=Ms(T):(T=is(l)?fa:Mn.current,C.context=yi(a,T)),C.state=a.memoizedState,T=l.getDerivedStateFromProps,typeof T=="function"&&(lp(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&&vu.enqueueReplaceState(C,C.state,null),uu(a,m,C,w),C.state=a.memoizedState),typeof C.componentDidMount=="function"&&(a.flags|=4194308)}function Ei(a,l){try{var m="",w=l;do m+=le(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 dp(a,l,m){return{value:a,source:null,stack:m??null,digest:l??null}}function up(a,l){try{console.error(l.value)}catch(m){setTimeout(function(){throw m})}}var M_=typeof WeakMap=="function"?WeakMap:Map;function cw(a,l,m){m=Wr(-1,m),m.tag=3,m.payload={element:null};var w=l.value;return m.callback=function(){Su||(Su=!0,Cp=w),up(a,l)},m}function dw(a,l,m){m=Wr(-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(){up(a,l)}}var T=a.stateNode;return T!==null&&typeof T.componentDidCatch=="function"&&(m.callback=function(){up(a,l),typeof w!="function"&&(ko===null?ko=new Set([this]):ko.add(this));var I=l.stack;this.componentDidCatch(l.value,{componentStack:I!==null?I:""})}),m}function uw(a,l,m){var w=a.pingCache;if(w===null){w=a.pingCache=new M_;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=V_.bind(null,a,l,m),l.then(a,a))}function fw(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 mw(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=Wr(-1,1),l.tag=2,wo(m,l,1))),m.lanes|=1),a):(a.flags|=65536,a.lanes=C,a)}var P_=N.ReactCurrentOwner,ls=!1;function Kn(a,l,m,w){l.child=a===null?Ob(l,null,m,w):ki(l,a.child,m,w)}function hw(a,l,m,w,C){m=m.render;var T=l.ref;return Si(l,C),w=np(a,l,m,w,T,C),m=sp(),a!==null&&!ls?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~C,Hr(a,l,C)):(Vt&&m&&Dh(l),l.flags|=1,Kn(a,l,w,C),l.child)}function pw(a,l,m,w,C){if(a===null){var T=m.type;return typeof T=="function"&&!Op(T)&&T.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(l.tag=15,l.type=T,gw(a,l,T,w,C)):(a=Ru(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 I=T.memoizedProps;if(m=m.compare,m=m!==null?m:Fl,m(I,w)&&a.ref===l.ref)return Hr(a,l,C)}return l.flags|=1,a=Eo(T,w),a.ref=l.ref,a.return=l,l.child=a}function gw(a,l,m,w,C){if(a!==null){var T=a.memoizedProps;if(Fl(T,w)&&a.ref===l.ref)if(ls=!1,l.pendingProps=w=T,(a.lanes&C)!==0)(a.flags&131072)!==0&&(ls=!0);else return l.lanes=a.lanes,Hr(a,l,C)}return fp(a,l,m,w,C)}function xw(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},Ft(_i,js),js|=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,Ft(_i,js),js|=a,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=T!==null?T.baseLanes:m,Ft(_i,js),js|=w}else T!==null?(w=T.baseLanes|m,l.memoizedState=null):w=m,Ft(_i,js),js|=w;return Kn(a,l,C,m),l.child}function vw(a,l){var m=l.ref;(a===null&&m!==null||a!==null&&a.ref!==m)&&(l.flags|=512,l.flags|=2097152)}function fp(a,l,m,w,C){var T=is(m)?fa:Mn.current;return T=yi(l,T),Si(l,C),m=np(a,l,m,w,T,C),w=sp(),a!==null&&!ls?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~C,Hr(a,l,C)):(Vt&&w&&Dh(l),l.flags|=1,Kn(a,l,m,C),l.child)}function yw(a,l,m,w,C){if(is(m)){var T=!0;nu(l)}else T=!1;if(Si(l,C),l.stateNode===null)bu(a,l),iw(l,m,w),cp(l,m,w,C),w=!0;else if(a===null){var I=l.stateNode,V=l.memoizedProps;I.props=V;var Z=I.context,ue=m.contextType;typeof ue=="object"&&ue!==null?ue=Ms(ue):(ue=is(m)?fa:Mn.current,ue=yi(l,ue));var je=m.getDerivedStateFromProps,Ce=typeof je=="function"||typeof I.getSnapshotBeforeUpdate=="function";Ce||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==w||Z!==ue)&&lw(l,I,w,ue),bo=!1;var we=l.memoizedState;I.state=we,uu(l,w,I,C),Z=l.memoizedState,V!==w||we!==Z||as.current||bo?(typeof je=="function"&&(lp(l,m,je,w),Z=l.memoizedState),(V=bo||aw(l,m,V,w,we,Z,ue))?(Ce||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(l.flags|=4194308)):(typeof I.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=w,l.memoizedState=Z),I.props=w,I.state=Z,I.context=ue,w=V):(typeof I.componentDidMount=="function"&&(l.flags|=4194308),w=!1)}else{I=l.stateNode,Pb(a,l),V=l.memoizedProps,ue=l.type===l.elementType?V:nr(l.type,V),I.props=ue,Ce=l.pendingProps,we=I.context,Z=m.contextType,typeof Z=="object"&&Z!==null?Z=Ms(Z):(Z=is(m)?fa:Mn.current,Z=yi(l,Z));var Ge=m.getDerivedStateFromProps;(je=typeof Ge=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==Ce||we!==Z)&&lw(l,I,w,Z),bo=!1,we=l.memoizedState,I.state=we,uu(l,w,I,C);var Ye=l.memoizedState;V!==Ce||we!==Ye||as.current||bo?(typeof Ge=="function"&&(lp(l,m,Ge,w),Ye=l.memoizedState),(ue=bo||aw(l,m,ue,w,we,Ye,Z)||!1)?(je||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(w,Ye,Z),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(w,Ye,Z)),typeof I.componentDidUpdate=="function"&&(l.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof I.componentDidUpdate!="function"||V===a.memoizedProps&&we===a.memoizedState||(l.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===a.memoizedProps&&we===a.memoizedState||(l.flags|=1024),l.memoizedProps=w,l.memoizedState=Ye),I.props=w,I.state=Ye,I.context=Z,w=ue):(typeof I.componentDidUpdate!="function"||V===a.memoizedProps&&we===a.memoizedState||(l.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===a.memoizedProps&&we===a.memoizedState||(l.flags|=1024),w=!1)}return mp(a,l,m,w,T,C)}function mp(a,l,m,w,C,T){vw(a,l);var I=(l.flags&128)!==0;if(!w&&!I)return C&&Nb(l,m,!1),Hr(a,l,T);w=l.stateNode,P_.current=l;var V=I&&typeof m.getDerivedStateFromError!="function"?null:w.render();return l.flags|=1,a!==null&&I?(l.child=ki(l,a.child,null,T),l.child=ki(l,null,V,T)):Kn(a,l,V,T),l.memoizedState=w.state,C&&Nb(l,m,!0),l.child}function bw(a){var l=a.stateNode;l.pendingContext?jb(a,l.pendingContext,l.pendingContext!==l.context):l.context&&jb(a,l.context,!1),Qh(a,l.containerInfo)}function ww(a,l,m,w,C){return ji(),Hh(C),l.flags|=256,Kn(a,l,m,w),l.child}var hp={dehydrated:null,treeContext:null,retryLane:0};function pp(a){return{baseLanes:a,cachePool:null,transitions:null}}function jw(a,l,m){var w=l.pendingProps,C=Xt.current,T=!1,I=(l.flags&128)!==0,V;if((V=I)||(V=a!==null&&a.memoizedState===null?!1:(C&2)!==0),V?(T=!0,l.flags&=-129):(a===null||a.memoizedState!==null)&&(C|=1),Ft(Xt,C&1),a===null)return Wh(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):(I=w.children,a=w.fallback,T?(w=l.mode,T=l.child,I={mode:"hidden",children:I},(w&1)===0&&T!==null?(T.childLanes=0,T.pendingProps=I):T=Au(I,w,0,null),a=ja(a,w,m,null),T.return=l,a.return=l,T.sibling=a,l.child=T,l.child.memoizedState=pp(m),l.memoizedState=hp,a):gp(l,I));if(C=a.memoizedState,C!==null&&(V=C.dehydrated,V!==null))return L_(a,l,I,w,V,C,m);if(T){T=w.fallback,I=l.mode,C=a.child,V=C.sibling;var Z={mode:"hidden",children:w.children};return(I&1)===0&&l.child!==C?(w=l.child,w.childLanes=0,w.pendingProps=Z,l.deletions=null):(w=Eo(C,Z),w.subtreeFlags=C.subtreeFlags&14680064),V!==null?T=Eo(V,T):(T=ja(T,I,m,null),T.flags|=2),T.return=l,w.return=l,w.sibling=T,l.child=w,w=T,T=l.child,I=a.child.memoizedState,I=I===null?pp(m):{baseLanes:I.baseLanes|m,cachePool:null,transitions:I.transitions},T.memoizedState=I,T.childLanes=a.childLanes&~m,l.memoizedState=hp,w}return T=a.child,a=T.sibling,w=Eo(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 gp(a,l){return l=Au({mode:"visible",children:l},a.mode,0,null),l.return=a,a.child=l}function yu(a,l,m,w){return w!==null&&Hh(w),ki(l,a.child,null,m),a=gp(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function L_(a,l,m,w,C,T,I){if(m)return l.flags&256?(l.flags&=-257,w=dp(Error(s(422))),yu(a,l,I,w)):l.memoizedState!==null?(l.child=a.child,l.flags|=128,null):(T=w.fallback,C=l.mode,w=Au({mode:"visible",children:w.children},C,0,null),T=ja(T,C,I,null),T.flags|=2,w.return=l,T.return=l,w.sibling=T,l.child=w,(l.mode&1)!==0&&ki(l,a.child,null,I),l.child.memoizedState=pp(I),l.memoizedState=hp,T);if((l.mode&1)===0)return yu(a,l,I,null);if(C.data==="$!"){if(w=C.nextSibling&&C.nextSibling.dataset,w)var V=w.dgst;return w=V,T=Error(s(419)),w=dp(T,w,void 0),yu(a,l,I,w)}if(V=(I&a.childLanes)!==0,ls||V){if(w=jn,w!==null){switch(I&-I){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|I))!==0?0:C,C!==0&&C!==T.retryLane&&(T.retryLane=C,Ur(a,C),or(w,a,C,-1))}return Ap(),w=dp(Error(s(421))),yu(a,l,I,w)}return C.data==="$?"?(l.flags|=128,l.child=a.child,l=Y_.bind(null,a),C._reactRetry=l,null):(a=T.treeContext,ws=go(C.nextSibling),bs=l,Vt=!0,tr=null,a!==null&&(As[Os++]=Dr,As[Os++]=Fr,As[Os++]=ma,Dr=a.id,Fr=a.overflow,ma=l),l=gp(l,w.children),l.flags|=4096,l)}function kw(a,l,m){a.lanes|=l;var w=a.alternate;w!==null&&(w.lanes|=l),Kh(a.return,l,m)}function xp(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 Nw(a,l,m){var w=l.pendingProps,C=w.revealOrder,T=w.tail;if(Kn(a,l,w.children,m),w=Xt.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&&kw(a,m,l);else if(a.tag===19)kw(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(Ft(Xt,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&&fu(a)===null&&(C=m),m=m.sibling;m=C,m===null?(C=l.child,l.child=null):(C=m.sibling,m.sibling=null),xp(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&&fu(a)===null){l.child=C;break}a=C.sibling,C.sibling=m,m=C,C=a}xp(l,!0,m,null,T);break;case"together":xp(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function bu(a,l){(l.mode&1)===0&&a!==null&&(a.alternate=null,l.alternate=null,l.flags|=2)}function Hr(a,l,m){if(a!==null&&(l.dependencies=a.dependencies),va|=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=Eo(a,a.pendingProps),l.child=m,m.return=l;a.sibling!==null;)a=a.sibling,m=m.sibling=Eo(a,a.pendingProps),m.return=l;m.sibling=null}return l.child}function I_(a,l,m){switch(l.tag){case 3:bw(l),ji();break;case 5:zb(l);break;case 1:is(l.type)&&nu(l);break;case 4:Qh(l,l.stateNode.containerInfo);break;case 10:var w=l.type._context,C=l.memoizedProps.value;Ft(lu,w._currentValue),w._currentValue=C;break;case 13:if(w=l.memoizedState,w!==null)return w.dehydrated!==null?(Ft(Xt,Xt.current&1),l.flags|=128,null):(m&l.child.childLanes)!==0?jw(a,l,m):(Ft(Xt,Xt.current&1),a=Hr(a,l,m),a!==null?a.sibling:null);Ft(Xt,Xt.current&1);break;case 19:if(w=(m&l.childLanes)!==0,(a.flags&128)!==0){if(w)return Nw(a,l,m);l.flags|=128}if(C=l.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),Ft(Xt,Xt.current),w)break;return null;case 22:case 23:return l.lanes=0,xw(a,l,m)}return Hr(a,l,m)}var Sw,vp,Cw,Ew;Sw=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}},vp=function(){},Cw=function(a,l,m,w){var C=a.memoizedProps;if(C!==w){a=l.stateNode,ga(gr.current);var T=null;switch(m){case"input":C=De(a,C),w=De(a,w),T=[];break;case"select":C=U({},C,{value:void 0}),w=U({},w,{value:void 0}),T=[];break;case"textarea":C=pt(a,C),w=pt(a,w),T=[];break;default:typeof C.onClick!="function"&&typeof w.onClick=="function"&&(a.onclick=Zd)}Ze(m,w);var I;m=null;for(ue in C)if(!w.hasOwnProperty(ue)&&C.hasOwnProperty(ue)&&C[ue]!=null)if(ue==="style"){var V=C[ue];for(I in V)V.hasOwnProperty(I)&&(m||(m={}),m[I]="")}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(V=C!=null?C[ue]:void 0,w.hasOwnProperty(ue)&&Z!==V&&(Z!=null||V!=null))if(ue==="style")if(V){for(I in V)!V.hasOwnProperty(I)||Z&&Z.hasOwnProperty(I)||(m||(m={}),m[I]="");for(I in Z)Z.hasOwnProperty(I)&&V[I]!==Z[I]&&(m||(m={}),m[I]=Z[I])}else m||(T||(T=[]),T.push(ue,m)),m=Z;else ue==="dangerouslySetInnerHTML"?(Z=Z?Z.__html:void 0,V=V?V.__html:void 0,Z!=null&&V!==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"&&Bt("scroll",a),T||V===Z||(T=[])):(T=T||[]).push(ue,Z))}m&&(T=T||[]).push("style",m);var ue=T;(l.updateQueue=ue)&&(l.flags|=4)}},Ew=function(a,l,m,w){m!==w&&(l.flags|=4)};function tc(a,l){if(!Vt)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 Ln(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 z_(a,l,m){var w=l.pendingProps;switch(Fh(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ln(l),null;case 1:return is(l.type)&&tu(),Ln(l),null;case 3:return w=l.stateNode,Ci(),Gt(as),Gt(Mn),Zh(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(a===null||a.child===null)&&(au(l)?l.flags|=4:a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,tr!==null&&(_p(tr),tr=null))),vp(a,l),Ln(l),null;case 5:Jh(l);var C=ga(Ql.current);if(m=l.type,a!==null&&l.stateNode!=null)Cw(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 Ln(l),null}if(a=ga(gr.current),au(l)){w=l.stateNode,m=l.type;var T=l.memoizedProps;switch(w[pr]=l,w[Gl]=T,a=(l.mode&1)!==0,m){case"dialog":Bt("cancel",w),Bt("close",w);break;case"iframe":case"object":case"embed":Bt("load",w);break;case"video":case"audio":for(C=0;C<Wl.length;C++)Bt(Wl[C],w);break;case"source":Bt("error",w);break;case"img":case"image":case"link":Bt("error",w),Bt("load",w);break;case"details":Bt("toggle",w);break;case"input":Ee(w,T),Bt("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!T.multiple},Bt("invalid",w);break;case"textarea":oe(w,T),Bt("invalid",w)}Ze(m,T),C=null;for(var I in T)if(T.hasOwnProperty(I)){var V=T[I];I==="children"?typeof V=="string"?w.textContent!==V&&(T.suppressHydrationWarning!==!0&&Xd(w.textContent,V,a),C=["children",V]):typeof V=="number"&&w.textContent!==""+V&&(T.suppressHydrationWarning!==!0&&Xd(w.textContent,V,a),C=["children",""+V]):o.hasOwnProperty(I)&&V!=null&&I==="onScroll"&&Bt("scroll",w)}switch(m){case"input":me(w),Qe(w,T,!0);break;case"textarea":me(w),st(w);break;case"select":case"option":break;default:typeof T.onClick=="function"&&(w.onclick=Zd)}w=C,l.updateQueue=w,w!==null&&(l.flags|=4)}else{I=C.nodeType===9?C:C.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=Oe(m)),a==="http://www.w3.org/1999/xhtml"?m==="script"?(a=I.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof w.is=="string"?a=I.createElement(m,{is:w.is}):(a=I.createElement(m),m==="select"&&(I=a,w.multiple?I.multiple=!0:w.size&&(I.size=w.size))):a=I.createElementNS(a,m),a[pr]=l,a[Gl]=w,Sw(a,l,!1,!1),l.stateNode=a;e:{switch(I=at(m,w),m){case"dialog":Bt("cancel",a),Bt("close",a),C=w;break;case"iframe":case"object":case"embed":Bt("load",a),C=w;break;case"video":case"audio":for(C=0;C<Wl.length;C++)Bt(Wl[C],a);C=w;break;case"source":Bt("error",a),C=w;break;case"img":case"image":case"link":Bt("error",a),Bt("load",a),C=w;break;case"details":Bt("toggle",a),C=w;break;case"input":Ee(a,w),C=De(a,w),Bt("invalid",a);break;case"option":C=w;break;case"select":a._wrapperState={wasMultiple:!!w.multiple},C=U({},w,{value:void 0}),Bt("invalid",a);break;case"textarea":oe(a,w),C=pt(a,w),Bt("invalid",a);break;default:C=w}Ze(m,C),V=C;for(T in V)if(V.hasOwnProperty(T)){var Z=V[T];T==="style"?de(a,Z):T==="dangerouslySetInnerHTML"?(Z=Z?Z.__html:void 0,Z!=null&&nt(a,Z)):T==="children"?typeof Z=="string"?(m!=="textarea"||Z!=="")&&ft(a,Z):typeof Z=="number"&&ft(a,""+Z):T!=="suppressContentEditableWarning"&&T!=="suppressHydrationWarning"&&T!=="autoFocus"&&(o.hasOwnProperty(T)?Z!=null&&T==="onScroll"&&Bt("scroll",a):Z!=null&&S(a,T,Z,I))}switch(m){case"input":me(a),Qe(a,w,!1);break;case"textarea":me(a),st(a);break;case"option":w.value!=null&&a.setAttribute("value",""+xe(w.value));break;case"select":a.multiple=!!w.multiple,T=w.value,T!=null?et(a,!!w.multiple,T,!1):w.defaultValue!=null&&et(a,!!w.multiple,w.defaultValue,!0);break;default:typeof C.onClick=="function"&&(a.onclick=Zd)}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 Ln(l),null;case 6:if(a&&l.stateNode!=null)Ew(a,l,a.memoizedProps,w);else{if(typeof w!="string"&&l.stateNode===null)throw Error(s(166));if(m=ga(Ql.current),ga(gr.current),au(l)){if(w=l.stateNode,m=l.memoizedProps,w[pr]=l,(T=w.nodeValue!==m)&&(a=bs,a!==null))switch(a.tag){case 3:Xd(w.nodeValue,m,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Xd(w.nodeValue,m,(a.mode&1)!==0)}T&&(l.flags|=4)}else w=(m.nodeType===9?m:m.ownerDocument).createTextNode(w),w[pr]=l,l.stateNode=w}return Ln(l),null;case 13:if(Gt(Xt),w=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(Vt&&ws!==null&&(l.mode&1)!==0&&(l.flags&128)===0)Tb(),ji(),l.flags|=98560,T=!1;else if(T=au(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[pr]=l}else ji(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Ln(l),T=!1}else tr!==null&&(_p(tr),tr=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||(Xt.current&1)!==0?vn===0&&(vn=3):Ap())),l.updateQueue!==null&&(l.flags|=4),Ln(l),null);case 4:return Ci(),vp(a,l),a===null&&Hl(l.stateNode.containerInfo),Ln(l),null;case 10:return qh(l.type._context),Ln(l),null;case 17:return is(l.type)&&tu(),Ln(l),null;case 19:if(Gt(Xt),T=l.memoizedState,T===null)return Ln(l),null;if(w=(l.flags&128)!==0,I=T.rendering,I===null)if(w)tc(T,!1);else{if(vn!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(I=fu(a),I!==null){for(l.flags|=128,tc(T,!1),w=I.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,I=T.alternate,I===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=I.childLanes,T.lanes=I.lanes,T.child=I.child,T.subtreeFlags=0,T.deletions=null,T.memoizedProps=I.memoizedProps,T.memoizedState=I.memoizedState,T.updateQueue=I.updateQueue,T.type=I.type,a=I.dependencies,T.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),m=m.sibling;return Ft(Xt,Xt.current&1|2),l.child}a=a.sibling}T.tail!==null&<()>Ti&&(l.flags|=128,w=!0,tc(T,!1),l.lanes=4194304)}else{if(!w)if(a=fu(I),a!==null){if(l.flags|=128,w=!0,m=a.updateQueue,m!==null&&(l.updateQueue=m,l.flags|=4),tc(T,!0),T.tail===null&&T.tailMode==="hidden"&&!I.alternate&&!Vt)return Ln(l),null}else 2*lt()-T.renderingStartTime>Ti&&m!==1073741824&&(l.flags|=128,w=!0,tc(T,!1),l.lanes=4194304);T.isBackwards?(I.sibling=l.child,l.child=I):(m=T.last,m!==null?m.sibling=I:l.child=I,T.last=I)}return T.tail!==null?(l=T.tail,T.rendering=l,T.tail=l.sibling,T.renderingStartTime=lt(),l.sibling=null,m=Xt.current,Ft(Xt,w?m&1|2:m&1),l):(Ln(l),null);case 22:case 23:return Rp(),w=l.memoizedState!==null,a!==null&&a.memoizedState!==null!==w&&(l.flags|=8192),w&&(l.mode&1)!==0?(js&1073741824)!==0&&(Ln(l),l.subtreeFlags&6&&(l.flags|=8192)):Ln(l),null;case 24:return null;case 25:return null}throw Error(s(156,l.tag))}function D_(a,l){switch(Fh(l),l.tag){case 1:return is(l.type)&&tu(),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return Ci(),Gt(as),Gt(Mn),Zh(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 5:return Jh(l),null;case 13:if(Gt(Xt),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(s(340));ji()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return Gt(Xt),null;case 4:return Ci(),null;case 10:return qh(l.type._context),null;case 22:case 23:return Rp(),null;case 24:return null;default:return null}}var wu=!1,In=!1,F_=typeof WeakSet=="function"?WeakSet:Set,Ve=null;function $i(a,l){var m=a.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(w){sn(a,l,w)}else m.current=null}function yp(a,l,m){try{m()}catch(w){sn(a,l,w)}}var $w=!1;function U_(a,l){if(Rh=Lr,a=ab(),kh(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 I=0,V=-1,Z=-1,ue=0,je=0,Ce=a,we=null;t:for(;;){for(var Ge;Ce!==m||C!==0&&Ce.nodeType!==3||(V=I+C),Ce!==T||w!==0&&Ce.nodeType!==3||(Z=I+w),Ce.nodeType===3&&(I+=Ce.nodeValue.length),(Ge=Ce.firstChild)!==null;)we=Ce,Ce=Ge;for(;;){if(Ce===a)break t;if(we===m&&++ue===C&&(V=I),we===T&&++je===w&&(Z=I),(Ge=Ce.nextSibling)!==null)break;Ce=we,we=Ce.parentNode}Ce=Ge}m=V===-1||Z===-1?null:{start:V,end:Z}}else m=null}m=m||{start:0,end:0}}else m=null;for(Ah={focusedElem:a,selectionRange:m},Lr=!1,Ve=l;Ve!==null;)if(l=Ve,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,Ve=a;else for(;Ve!==null;){l=Ve;try{var Ye=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Ye!==null){var Xe=Ye.memoizedProps,on=Ye.memoizedState,ie=l.stateNode,ne=ie.getSnapshotBeforeUpdate(l.elementType===l.type?Xe:nr(l.type,Xe),on);ie.__reactInternalSnapshotBeforeUpdate=ne}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(Ae){sn(l,l.return,Ae)}if(a=l.sibling,a!==null){a.return=l.return,Ve=a;break}Ve=l.return}return Ye=$w,$w=!1,Ye}function nc(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&&yp(l,m,T)}C=C.next}while(C!==w)}}function ju(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 bp(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 _w(a){var l=a.alternate;l!==null&&(a.alternate=null,_w(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&(delete l[pr],delete l[Gl],delete l[Lh],delete l[k_],delete l[N_])),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 Tw(a){return a.tag===5||a.tag===3||a.tag===4}function Rw(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||Tw(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 wp(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=Zd));else if(w!==4&&(a=a.child,a!==null))for(wp(a,l,m),a=a.sibling;a!==null;)wp(a,l,m),a=a.sibling}function jp(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(jp(a,l,m),a=a.sibling;a!==null;)jp(a,l,m),a=a.sibling}var _n=null,sr=!1;function jo(a,l,m){for(m=m.child;m!==null;)Aw(a,l,m),m=m.sibling}function Aw(a,l,m){if(vs&&typeof vs.onCommitFiberUnmount=="function")try{vs.onCommitFiberUnmount(aa,m)}catch{}switch(m.tag){case 5:In||$i(m,l);case 6:var w=_n,C=sr;_n=null,jo(a,l,m),_n=w,sr=C,_n!==null&&(sr?(a=_n,m=m.stateNode,a.nodeType===8?a.parentNode.removeChild(m):a.removeChild(m)):_n.removeChild(m.stateNode));break;case 18:_n!==null&&(sr?(a=_n,m=m.stateNode,a.nodeType===8?Ph(a.parentNode,m):a.nodeType===1&&Ph(a,m),fo(a)):Ph(_n,m.stateNode));break;case 4:w=_n,C=sr,_n=m.stateNode.containerInfo,sr=!0,jo(a,l,m),_n=w,sr=C;break;case 0:case 11:case 14:case 15:if(!In&&(w=m.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){C=w=w.next;do{var T=C,I=T.destroy;T=T.tag,I!==void 0&&((T&2)!==0||(T&4)!==0)&&yp(m,l,I),C=C.next}while(C!==w)}jo(a,l,m);break;case 1:if(!In&&($i(m,l),w=m.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=m.memoizedProps,w.state=m.memoizedState,w.componentWillUnmount()}catch(V){sn(m,l,V)}jo(a,l,m);break;case 21:jo(a,l,m);break;case 22:m.mode&1?(In=(w=In)||m.memoizedState!==null,jo(a,l,m),In=w):jo(a,l,m);break;default:jo(a,l,m)}}function Ow(a){var l=a.updateQueue;if(l!==null){a.updateQueue=null;var m=a.stateNode;m===null&&(m=a.stateNode=new F_),l.forEach(function(w){var C=Q_.bind(null,a,w);m.has(w)||(m.add(w),w.then(C,C))})}}function rr(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,I=l,V=I;e:for(;V!==null;){switch(V.tag){case 5:_n=V.stateNode,sr=!1;break e;case 3:_n=V.stateNode.containerInfo,sr=!0;break e;case 4:_n=V.stateNode.containerInfo,sr=!0;break e}V=V.return}if(_n===null)throw Error(s(160));Aw(T,I,C),_n=null,sr=!1;var Z=C.alternate;Z!==null&&(Z.return=null),C.return=null}catch(ue){sn(C,l,ue)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)Mw(l,a),l=l.sibling}function Mw(a,l){var m=a.alternate,w=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(rr(l,a),vr(a),w&4){try{nc(3,a,a.return),ju(3,a)}catch(Xe){sn(a,a.return,Xe)}try{nc(5,a,a.return)}catch(Xe){sn(a,a.return,Xe)}}break;case 1:rr(l,a),vr(a),w&512&&m!==null&&$i(m,m.return);break;case 5:if(rr(l,a),vr(a),w&512&&m!==null&&$i(m,m.return),a.flags&32){var C=a.stateNode;try{ft(C,"")}catch(Xe){sn(a,a.return,Xe)}}if(w&4&&(C=a.stateNode,C!=null)){var T=a.memoizedProps,I=m!==null?m.memoizedProps:T,V=a.type,Z=a.updateQueue;if(a.updateQueue=null,Z!==null)try{V==="input"&&T.type==="radio"&&T.name!=null&&re(C,T),at(V,I);var ue=at(V,T);for(I=0;I<Z.length;I+=2){var je=Z[I],Ce=Z[I+1];je==="style"?de(C,Ce):je==="dangerouslySetInnerHTML"?nt(C,Ce):je==="children"?ft(C,Ce):S(C,je,Ce,ue)}switch(V){case"input":_e(C,T);break;case"textarea":$e(C,T);break;case"select":var we=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!T.multiple;var Ge=T.value;Ge!=null?et(C,!!T.multiple,Ge,!1):we!==!!T.multiple&&(T.defaultValue!=null?et(C,!!T.multiple,T.defaultValue,!0):et(C,!!T.multiple,T.multiple?[]:"",!1))}C[Gl]=T}catch(Xe){sn(a,a.return,Xe)}}break;case 6:if(rr(l,a),vr(a),w&4){if(a.stateNode===null)throw Error(s(162));C=a.stateNode,T=a.memoizedProps;try{C.nodeValue=T}catch(Xe){sn(a,a.return,Xe)}}break;case 3:if(rr(l,a),vr(a),w&4&&m!==null&&m.memoizedState.isDehydrated)try{fo(l.containerInfo)}catch(Xe){sn(a,a.return,Xe)}break;case 4:rr(l,a),vr(a);break;case 13:rr(l,a),vr(a),C=a.child,C.flags&8192&&(T=C.memoizedState!==null,C.stateNode.isHidden=T,!T||C.alternate!==null&&C.alternate.memoizedState!==null||(Sp=lt())),w&4&&Ow(a);break;case 22:if(je=m!==null&&m.memoizedState!==null,a.mode&1?(In=(ue=In)||je,rr(l,a),In=ue):rr(l,a),vr(a),w&8192){if(ue=a.memoizedState!==null,(a.stateNode.isHidden=ue)&&!je&&(a.mode&1)!==0)for(Ve=a,je=a.child;je!==null;){for(Ce=Ve=je;Ve!==null;){switch(we=Ve,Ge=we.child,we.tag){case 0:case 11:case 14:case 15:nc(4,we,we.return);break;case 1:$i(we,we.return);var Ye=we.stateNode;if(typeof Ye.componentWillUnmount=="function"){w=we,m=we.return;try{l=w,Ye.props=l.memoizedProps,Ye.state=l.memoizedState,Ye.componentWillUnmount()}catch(Xe){sn(w,m,Xe)}}break;case 5:$i(we,we.return);break;case 22:if(we.memoizedState!==null){Iw(Ce);continue}}Ge!==null?(Ge.return=we,Ve=Ge):Iw(Ce)}je=je.sibling}e:for(je=null,Ce=a;;){if(Ce.tag===5){if(je===null){je=Ce;try{C=Ce.stateNode,ue?(T=C.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none"):(V=Ce.stateNode,Z=Ce.memoizedProps.style,I=Z!=null&&Z.hasOwnProperty("display")?Z.display:null,V.style.display=ye("display",I))}catch(Xe){sn(a,a.return,Xe)}}}else if(Ce.tag===6){if(je===null)try{Ce.stateNode.nodeValue=ue?"":Ce.memoizedProps}catch(Xe){sn(a,a.return,Xe)}}else if((Ce.tag!==22&&Ce.tag!==23||Ce.memoizedState===null||Ce===a)&&Ce.child!==null){Ce.child.return=Ce,Ce=Ce.child;continue}if(Ce===a)break e;for(;Ce.sibling===null;){if(Ce.return===null||Ce.return===a)break e;je===Ce&&(je=null),Ce=Ce.return}je===Ce&&(je=null),Ce.sibling.return=Ce.return,Ce=Ce.sibling}}break;case 19:rr(l,a),vr(a),w&4&&Ow(a);break;case 21:break;default:rr(l,a),vr(a)}}function vr(a){var l=a.flags;if(l&2){try{e:{for(var m=a.return;m!==null;){if(Tw(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&&(ft(C,""),w.flags&=-33);var T=Rw(a);jp(a,T,C);break;case 3:case 4:var I=w.stateNode.containerInfo,V=Rw(a);wp(a,V,I);break;default:throw Error(s(161))}}catch(Z){sn(a,a.return,Z)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function W_(a,l,m){Ve=a,Pw(a)}function Pw(a,l,m){for(var w=(a.mode&1)!==0;Ve!==null;){var C=Ve,T=C.child;if(C.tag===22&&w){var I=C.memoizedState!==null||wu;if(!I){var V=C.alternate,Z=V!==null&&V.memoizedState!==null||In;V=wu;var ue=In;if(wu=I,(In=Z)&&!ue)for(Ve=C;Ve!==null;)I=Ve,Z=I.child,I.tag===22&&I.memoizedState!==null?zw(C):Z!==null?(Z.return=I,Ve=Z):zw(C);for(;T!==null;)Ve=T,Pw(T),T=T.sibling;Ve=C,wu=V,In=ue}Lw(a)}else(C.subtreeFlags&8772)!==0&&T!==null?(T.return=C,Ve=T):Lw(a)}}function Lw(a){for(;Ve!==null;){var l=Ve;if((l.flags&8772)!==0){var m=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:In||ju(5,l);break;case 1:var w=l.stateNode;if(l.flags&4&&!In)if(m===null)w.componentDidMount();else{var C=l.elementType===l.type?m.memoizedProps:nr(l.type,m.memoizedProps);w.componentDidUpdate(C,m.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var T=l.updateQueue;T!==null&&Ib(l,T,w);break;case 3:var I=l.updateQueue;if(I!==null){if(m=null,l.child!==null)switch(l.child.tag){case 5:m=l.child.stateNode;break;case 1:m=l.child.stateNode}Ib(l,I,m)}break;case 5:var V=l.stateNode;if(m===null&&l.flags&4){m=V;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 je=ue.memoizedState;if(je!==null){var Ce=je.dehydrated;Ce!==null&&fo(Ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}In||l.flags&512&&bp(l)}catch(we){sn(l,l.return,we)}}if(l===a){Ve=null;break}if(m=l.sibling,m!==null){m.return=l.return,Ve=m;break}Ve=l.return}}function Iw(a){for(;Ve!==null;){var l=Ve;if(l===a){Ve=null;break}var m=l.sibling;if(m!==null){m.return=l.return,Ve=m;break}Ve=l.return}}function zw(a){for(;Ve!==null;){var l=Ve;try{switch(l.tag){case 0:case 11:case 15:var m=l.return;try{ju(4,l)}catch(Z){sn(l,m,Z)}break;case 1:var w=l.stateNode;if(typeof w.componentDidMount=="function"){var C=l.return;try{w.componentDidMount()}catch(Z){sn(l,C,Z)}}var T=l.return;try{bp(l)}catch(Z){sn(l,T,Z)}break;case 5:var I=l.return;try{bp(l)}catch(Z){sn(l,I,Z)}}}catch(Z){sn(l,l.return,Z)}if(l===a){Ve=null;break}var V=l.sibling;if(V!==null){V.return=l.return,Ve=V;break}Ve=l.return}}var H_=Math.ceil,ku=N.ReactCurrentDispatcher,kp=N.ReactCurrentOwner,Ls=N.ReactCurrentBatchConfig,St=0,jn=null,mn=null,Tn=0,js=0,_i=xo(0),vn=0,sc=null,va=0,Nu=0,Np=0,rc=null,cs=null,Sp=0,Ti=1/0,Br=null,Su=!1,Cp=null,ko=null,Cu=!1,No=null,Eu=0,oc=0,Ep=null,$u=-1,_u=0;function Vn(){return(St&6)!==0?lt():$u!==-1?$u:$u=lt()}function So(a){return(a.mode&1)===0?1:(St&2)!==0&&Tn!==0?Tn&-Tn:C_.transition!==null?(_u===0&&(_u=_l()),_u):(a=Et,a!==0||(a=window.event,a=a===void 0?16:Fy(a.type)),a)}function or(a,l,m,w){if(50<oc)throw oc=0,Ep=null,Error(s(185));co(a,m,w),((St&2)===0||a!==jn)&&(a===jn&&((St&2)===0&&(Nu|=m),vn===4&&Co(a,Tn)),ds(a,w),m===1&&St===0&&(l.mode&1)===0&&(Ti=lt()+500,su&&yo()))}function ds(a,l){var m=a.callbackNode;Fd(a,l);var w=ca(a,a===jn?Tn: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?S_(Fw.bind(null,a)):Sb(Fw.bind(null,a)),w_(function(){(St&6)===0&&yo()}),m=null;else{switch(Tl(w)){case 1:m=$n;break;case 4:m=mr;break;case 16:m=Ht;break;case 536870912:m=io;break;default:m=Ht}m=Vw(m,Dw.bind(null,a))}a.callbackPriority=l,a.callbackNode=m}}function Dw(a,l){if($u=-1,_u=0,(St&6)!==0)throw Error(s(327));var m=a.callbackNode;if(Ri()&&a.callbackNode!==m)return null;var w=ca(a,a===jn?Tn:0);if(w===0)return null;if((w&30)!==0||(w&a.expiredLanes)!==0||l)l=Tu(a,w);else{l=w;var C=St;St|=2;var T=Ww();(jn!==a||Tn!==l)&&(Br=null,Ti=lt()+500,ba(a,l));do try{q_();break}catch(V){Uw(a,V)}while(!0);Gh(),ku.current=T,St=C,mn!==null?l=0:(jn=null,Tn=0,l=vn)}if(l!==0){if(l===2&&(C=oi(a),C!==0&&(w=C,l=$p(a,C))),l===1)throw m=sc,ba(a,0),Co(a,w),ds(a,lt()),m;if(l===6)Co(a,w);else{if(C=a.current.alternate,(w&30)===0&&!B_(C)&&(l=Tu(a,w),l===2&&(T=oi(a),T!==0&&(w=T,l=$p(a,T))),l===1))throw m=sc,ba(a,0),Co(a,w),ds(a,lt()),m;switch(a.finishedWork=C,a.finishedLanes=w,l){case 0:case 1:throw Error(s(345));case 2:wa(a,cs,Br);break;case 3:if(Co(a,w),(w&130023424)===w&&(l=Sp+500-lt(),10<l)){if(ca(a,0)!==0)break;if(C=a.suspendedLanes,(C&w)!==w){Vn(),a.pingedLanes|=a.suspendedLanes&C;break}a.timeoutHandle=Mh(wa.bind(null,a,cs,Br),l);break}wa(a,cs,Br);break;case 4:if(Co(a,w),(w&4194240)===w)break;for(l=a.eventTimes,C=-1;0<w;){var I=31-rs(w);T=1<<I,I=l[I],I>C&&(C=I),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*H_(w/1960))-w,10<w){a.timeoutHandle=Mh(wa.bind(null,a,cs,Br),w);break}wa(a,cs,Br);break;case 5:wa(a,cs,Br);break;default:throw Error(s(329))}}}return ds(a,lt()),a.callbackNode===m?Dw.bind(null,a):null}function $p(a,l){var m=rc;return a.current.memoizedState.isDehydrated&&(ba(a,l).flags|=256),a=Tu(a,l),a!==2&&(l=cs,cs=m,l!==null&&_p(l)),a}function _p(a){cs===null?cs=a:cs.push.apply(cs,a)}function B_(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(!er(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 Co(a,l){for(l&=~Np,l&=~Nu,a.suspendedLanes|=l,a.pingedLanes&=~l,a=a.expirationTimes;0<l;){var m=31-rs(l),w=1<<m;a[m]=-1,l&=~w}}function Fw(a){if((St&6)!==0)throw Error(s(327));Ri();var l=ca(a,0);if((l&1)===0)return ds(a,lt()),null;var m=Tu(a,l);if(a.tag!==0&&m===2){var w=oi(a);w!==0&&(l=w,m=$p(a,w))}if(m===1)throw m=sc,ba(a,0),Co(a,l),ds(a,lt()),m;if(m===6)throw Error(s(345));return a.finishedWork=a.current.alternate,a.finishedLanes=l,wa(a,cs,Br),ds(a,lt()),null}function Tp(a,l){var m=St;St|=1;try{return a(l)}finally{St=m,St===0&&(Ti=lt()+500,su&&yo())}}function ya(a){No!==null&&No.tag===0&&(St&6)===0&&Ri();var l=St;St|=1;var m=Ls.transition,w=Et;try{if(Ls.transition=null,Et=1,a)return a()}finally{Et=w,Ls.transition=m,St=l,(St&6)===0&&yo()}}function Rp(){js=_i.current,Gt(_i)}function ba(a,l){a.finishedWork=null,a.finishedLanes=0;var m=a.timeoutHandle;if(m!==-1&&(a.timeoutHandle=-1,b_(m)),mn!==null)for(m=mn.return;m!==null;){var w=m;switch(Fh(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&tu();break;case 3:Ci(),Gt(as),Gt(Mn),Zh();break;case 5:Jh(w);break;case 4:Ci();break;case 13:Gt(Xt);break;case 19:Gt(Xt);break;case 10:qh(w.type._context);break;case 22:case 23:Rp()}m=m.return}if(jn=a,mn=a=Eo(a.current,null),Tn=js=l,vn=0,sc=null,Np=Nu=va=0,cs=rc=null,pa!==null){for(l=0;l<pa.length;l++)if(m=pa[l],w=m.interleaved,w!==null){m.interleaved=null;var C=w.next,T=m.pending;if(T!==null){var I=T.next;T.next=C,w.next=I}m.pending=w}pa=null}return a}function Uw(a,l){do{var m=mn;try{if(Gh(),mu.current=xu,hu){for(var w=Zt.memoizedState;w!==null;){var C=w.queue;C!==null&&(C.pending=null),w=w.next}hu=!1}if(xa=0,wn=xn=Zt=null,Jl=!1,Xl=0,kp.current=null,m===null||m.return===null){vn=1,sc=l,mn=null;break}e:{var T=a,I=m.return,V=m,Z=l;if(l=Tn,V.flags|=32768,Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var ue=Z,je=V,Ce=je.tag;if((je.mode&1)===0&&(Ce===0||Ce===11||Ce===15)){var we=je.alternate;we?(je.updateQueue=we.updateQueue,je.memoizedState=we.memoizedState,je.lanes=we.lanes):(je.updateQueue=null,je.memoizedState=null)}var Ge=fw(I);if(Ge!==null){Ge.flags&=-257,mw(Ge,I,V,T,l),Ge.mode&1&&uw(T,ue,l),l=Ge,Z=ue;var Ye=l.updateQueue;if(Ye===null){var Xe=new Set;Xe.add(Z),l.updateQueue=Xe}else Ye.add(Z);break e}else{if((l&1)===0){uw(T,ue,l),Ap();break e}Z=Error(s(426))}}else if(Vt&&V.mode&1){var on=fw(I);if(on!==null){(on.flags&65536)===0&&(on.flags|=256),mw(on,I,V,T,l),Hh(Ei(Z,V));break e}}T=Z=Ei(Z,V),vn!==4&&(vn=2),rc===null?rc=[T]:rc.push(T),T=I;do{switch(T.tag){case 3:T.flags|=65536,l&=-l,T.lanes|=l;var ie=cw(T,Z,l);Lb(T,ie);break e;case 1:V=Z;var ne=T.type,ce=T.stateNode;if((T.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(ko===null||!ko.has(ce)))){T.flags|=65536,l&=-l,T.lanes|=l;var Ae=dw(T,V,l);Lb(T,Ae);break e}}T=T.return}while(T!==null)}Bw(m)}catch(tt){l=tt,mn===m&&m!==null&&(mn=m=m.return);continue}break}while(!0)}function Ww(){var a=ku.current;return ku.current=xu,a===null?xu:a}function Ap(){(vn===0||vn===3||vn===2)&&(vn=4),jn===null||(va&268435455)===0&&(Nu&268435455)===0||Co(jn,Tn)}function Tu(a,l){var m=St;St|=2;var w=Ww();(jn!==a||Tn!==l)&&(Br=null,ba(a,l));do try{G_();break}catch(C){Uw(a,C)}while(!0);if(Gh(),St=m,ku.current=w,mn!==null)throw Error(s(261));return jn=null,Tn=0,vn}function G_(){for(;mn!==null;)Hw(mn)}function q_(){for(;mn!==null&&!kt();)Hw(mn)}function Hw(a){var l=Kw(a.alternate,a,js);a.memoizedProps=a.pendingProps,l===null?Bw(a):mn=l,kp.current=null}function Bw(a){var l=a;do{var m=l.alternate;if(a=l.return,(l.flags&32768)===0){if(m=z_(m,l,js),m!==null){mn=m;return}}else{if(m=D_(m,l),m!==null){m.flags&=32767,mn=m;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{vn=6,mn=null;return}}if(l=l.sibling,l!==null){mn=l;return}mn=l=a}while(l!==null);vn===0&&(vn=5)}function wa(a,l,m){var w=Et,C=Ls.transition;try{Ls.transition=null,Et=1,K_(a,l,m,w)}finally{Ls.transition=C,Et=w}return null}function K_(a,l,m,w){do Ri();while(No!==null);if((St&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(Ud(a,T),a===jn&&(mn=jn=null,Tn=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||Cu||(Cu=!0,Vw(Ht,function(){return Ri(),null})),T=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||T){T=Ls.transition,Ls.transition=null;var I=Et;Et=1;var V=St;St|=4,kp.current=null,U_(a,m),Mw(m,a),m_(Ah),Lr=!!Rh,Ah=Rh=null,a.current=m,W_(m),Lt(),St=V,Et=I,Ls.transition=T}else a.current=m;if(Cu&&(Cu=!1,No=a,Eu=C),T=a.pendingLanes,T===0&&(ko=null),Pd(m.stateNode),ds(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(Su)throw Su=!1,a=Cp,Cp=null,a;return(Eu&1)!==0&&a.tag!==0&&Ri(),T=a.pendingLanes,(T&1)!==0?a===Ep?oc++:(oc=0,Ep=a):oc=0,yo(),null}function Ri(){if(No!==null){var a=Tl(Eu),l=Ls.transition,m=Et;try{if(Ls.transition=null,Et=16>a?16:a,No===null)var w=!1;else{if(a=No,No=null,Eu=0,(St&6)!==0)throw Error(s(331));var C=St;for(St|=4,Ve=a.current;Ve!==null;){var T=Ve,I=T.child;if((Ve.flags&16)!==0){var V=T.deletions;if(V!==null){for(var Z=0;Z<V.length;Z++){var ue=V[Z];for(Ve=ue;Ve!==null;){var je=Ve;switch(je.tag){case 0:case 11:case 15:nc(8,je,T)}var Ce=je.child;if(Ce!==null)Ce.return=je,Ve=Ce;else for(;Ve!==null;){je=Ve;var we=je.sibling,Ge=je.return;if(_w(je),je===ue){Ve=null;break}if(we!==null){we.return=Ge,Ve=we;break}Ve=Ge}}}var Ye=T.alternate;if(Ye!==null){var Xe=Ye.child;if(Xe!==null){Ye.child=null;do{var on=Xe.sibling;Xe.sibling=null,Xe=on}while(Xe!==null)}}Ve=T}}if((T.subtreeFlags&2064)!==0&&I!==null)I.return=T,Ve=I;else e:for(;Ve!==null;){if(T=Ve,(T.flags&2048)!==0)switch(T.tag){case 0:case 11:case 15:nc(9,T,T.return)}var ie=T.sibling;if(ie!==null){ie.return=T.return,Ve=ie;break e}Ve=T.return}}var ne=a.current;for(Ve=ne;Ve!==null;){I=Ve;var ce=I.child;if((I.subtreeFlags&2064)!==0&&ce!==null)ce.return=I,Ve=ce;else e:for(I=ne;Ve!==null;){if(V=Ve,(V.flags&2048)!==0)try{switch(V.tag){case 0:case 11:case 15:ju(9,V)}}catch(tt){sn(V,V.return,tt)}if(V===I){Ve=null;break e}var Ae=V.sibling;if(Ae!==null){Ae.return=V.return,Ve=Ae;break e}Ve=V.return}}if(St=C,yo(),vs&&typeof vs.onPostCommitFiberRoot=="function")try{vs.onPostCommitFiberRoot(aa,a)}catch{}w=!0}return w}finally{Et=m,Ls.transition=l}}return!1}function Gw(a,l,m){l=Ei(m,l),l=cw(a,l,1),a=wo(a,l,1),l=Vn(),a!==null&&(co(a,1,l),ds(a,l))}function sn(a,l,m){if(a.tag===3)Gw(a,a,m);else for(;l!==null;){if(l.tag===3){Gw(l,a,m);break}else if(l.tag===1){var w=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(ko===null||!ko.has(w))){a=Ei(m,a),a=dw(l,a,1),l=wo(l,a,1),a=Vn(),l!==null&&(co(l,1,a),ds(l,a));break}}l=l.return}}function V_(a,l,m){var w=a.pingCache;w!==null&&w.delete(l),l=Vn(),a.pingedLanes|=a.suspendedLanes&m,jn===a&&(Tn&m)===m&&(vn===4||vn===3&&(Tn&130023424)===Tn&&500>lt()-Sp?ba(a,0):Np|=m),ds(a,l)}function qw(a,l){l===0&&((a.mode&1)===0?l=1:(l=la,la<<=1,(la&130023424)===0&&(la=4194304)));var m=Vn();a=Ur(a,l),a!==null&&(co(a,l,m),ds(a,m))}function Y_(a){var l=a.memoizedState,m=0;l!==null&&(m=l.retryLane),qw(a,m)}function Q_(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),qw(a,m)}var Kw;Kw=function(a,l,m){if(a!==null)if(a.memoizedProps!==l.pendingProps||as.current)ls=!0;else{if((a.lanes&m)===0&&(l.flags&128)===0)return ls=!1,I_(a,l,m);ls=(a.flags&131072)!==0}else ls=!1,Vt&&(l.flags&1048576)!==0&&Cb(l,ou,l.index);switch(l.lanes=0,l.tag){case 2:var w=l.type;bu(a,l),a=l.pendingProps;var C=yi(l,Mn.current);Si(l,m),C=np(null,l,w,a,C,m);var T=sp();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,is(w)?(T=!0,nu(l)):T=!1,l.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,Yh(l),C.updater=vu,l.stateNode=C,C._reactInternals=l,cp(l,w,a,m),l=mp(null,l,w,!0,T,m)):(l.tag=0,Vt&&T&&Dh(l),Kn(null,l,C,m),l=l.child),l;case 16:w=l.elementType;e:{switch(bu(a,l),a=l.pendingProps,C=w._init,w=C(w._payload),l.type=w,C=l.tag=X_(w),a=nr(w,a),C){case 0:l=fp(null,l,w,a,m);break e;case 1:l=yw(null,l,w,a,m);break e;case 11:l=hw(null,l,w,a,m);break e;case 14:l=pw(null,l,w,nr(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:nr(w,C),fp(a,l,w,C,m);case 1:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:nr(w,C),yw(a,l,w,C,m);case 3:e:{if(bw(l),a===null)throw Error(s(387));w=l.pendingProps,T=l.memoizedState,C=T.element,Pb(a,l),uu(l,w,null,m);var I=l.memoizedState;if(w=I.element,T.isDehydrated)if(T={element:w,isDehydrated:!1,cache:I.cache,pendingSuspenseBoundaries:I.pendingSuspenseBoundaries,transitions:I.transitions},l.updateQueue.baseState=T,l.memoizedState=T,l.flags&256){C=Ei(Error(s(423)),l),l=ww(a,l,w,m,C);break e}else if(w!==C){C=Ei(Error(s(424)),l),l=ww(a,l,w,m,C);break e}else for(ws=go(l.stateNode.containerInfo.firstChild),bs=l,Vt=!0,tr=null,m=Ob(l,null,w,m),l.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(ji(),w===C){l=Hr(a,l,m);break e}Kn(a,l,w,m)}l=l.child}return l;case 5:return zb(l),a===null&&Wh(l),w=l.type,C=l.pendingProps,T=a!==null?a.memoizedProps:null,I=C.children,Oh(w,C)?I=null:T!==null&&Oh(w,T)&&(l.flags|=32),vw(a,l),Kn(a,l,I,m),l.child;case 6:return a===null&&Wh(l),null;case 13:return jw(a,l,m);case 4:return Qh(l,l.stateNode.containerInfo),w=l.pendingProps,a===null?l.child=ki(l,null,w,m):Kn(a,l,w,m),l.child;case 11:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:nr(w,C),hw(a,l,w,C,m);case 7:return Kn(a,l,l.pendingProps,m),l.child;case 8:return Kn(a,l,l.pendingProps.children,m),l.child;case 12:return Kn(a,l,l.pendingProps.children,m),l.child;case 10:e:{if(w=l.type._context,C=l.pendingProps,T=l.memoizedProps,I=C.value,Ft(lu,w._currentValue),w._currentValue=I,T!==null)if(er(T.value,I)){if(T.children===C.children&&!as.current){l=Hr(a,l,m);break e}}else for(T=l.child,T!==null&&(T.return=l);T!==null;){var V=T.dependencies;if(V!==null){I=T.child;for(var Z=V.firstContext;Z!==null;){if(Z.context===w){if(T.tag===1){Z=Wr(-1,m&-m),Z.tag=2;var ue=T.updateQueue;if(ue!==null){ue=ue.shared;var je=ue.pending;je===null?Z.next=Z:(Z.next=je.next,je.next=Z),ue.pending=Z}}T.lanes|=m,Z=T.alternate,Z!==null&&(Z.lanes|=m),Kh(T.return,m,l),V.lanes|=m;break}Z=Z.next}}else if(T.tag===10)I=T.type===l.type?null:T.child;else if(T.tag===18){if(I=T.return,I===null)throw Error(s(341));I.lanes|=m,V=I.alternate,V!==null&&(V.lanes|=m),Kh(I,m,l),I=T.sibling}else I=T.child;if(I!==null)I.return=T;else for(I=T;I!==null;){if(I===l){I=null;break}if(T=I.sibling,T!==null){T.return=I.return,I=T;break}I=I.return}T=I}Kn(a,l,C.children,m),l=l.child}return l;case 9:return C=l.type,w=l.pendingProps.children,Si(l,m),C=Ms(C),w=w(C),l.flags|=1,Kn(a,l,w,m),l.child;case 14:return w=l.type,C=nr(w,l.pendingProps),C=nr(w.type,C),pw(a,l,w,C,m);case 15:return gw(a,l,l.type,l.pendingProps,m);case 17:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:nr(w,C),bu(a,l),l.tag=1,is(w)?(a=!0,nu(l)):a=!1,Si(l,m),iw(l,w,C),cp(l,w,C,m),mp(null,l,w,!0,a,m);case 19:return Nw(a,l,m);case 22:return xw(a,l,m)}throw Error(s(156,l.tag))};function Vw(a,l){return be(a,l)}function J_(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 Is(a,l,m,w){return new J_(a,l,m,w)}function Op(a){return a=a.prototype,!(!a||!a.isReactComponent)}function X_(a){if(typeof a=="function")return Op(a)?1:0;if(a!=null){if(a=a.$$typeof,a===P)return 11;if(a===K)return 14}return 2}function Eo(a,l){var m=a.alternate;return m===null?(m=Is(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 Ru(a,l,m,w,C,T){var I=2;if(w=a,typeof a=="function")Op(a)&&(I=1);else if(typeof a=="string")I=5;else e:switch(a){case M:return ja(m.children,C,T,l);case O:I=8,C|=8;break;case L:return a=Is(12,m,l,C|2),a.elementType=L,a.lanes=T,a;case D:return a=Is(13,m,l,C),a.elementType=D,a.lanes=T,a;case W:return a=Is(19,m,l,C),a.elementType=W,a.lanes=T,a;case q:return Au(m,C,T,l);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case A:I=10;break e;case R:I=9;break e;case P:I=11;break e;case K:I=14;break e;case H:I=16,w=null;break e}throw Error(s(130,a==null?a:typeof a,""))}return l=Is(I,m,l,C),l.elementType=a,l.type=w,l.lanes=T,l}function ja(a,l,m,w){return a=Is(7,a,w,l),a.lanes=m,a}function Au(a,l,m,w){return a=Is(22,a,w,l),a.elementType=q,a.lanes=m,a.stateNode={isHidden:!1},a}function Mp(a,l,m){return a=Is(6,a,null,l),a.lanes=m,a}function Pp(a,l,m){return l=Is(4,a.children!==null?a.children:[],a.key,l),l.lanes=m,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}function Z_(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=ai(0),this.expirationTimes=ai(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ai(0),this.identifierPrefix=w,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function Lp(a,l,m,w,C,T,I,V,Z){return a=new Z_(a,l,m,V,Z),l===1?(l=1,T===!0&&(l|=8)):l=0,T=Is(3,null,null,l),a.current=T,T.stateNode=a,T.memoizedState={element:w,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},Yh(T),a}function eT(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 Yw(a){if(!a)return vo;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(is(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(is(m))return kb(a,m,l)}return l}function Qw(a,l,m,w,C,T,I,V,Z){return a=Lp(m,w,!0,a,C,T,I,V,Z),a.context=Yw(null),m=a.current,w=Vn(),C=So(m),T=Wr(w,C),T.callback=l??null,wo(m,T,C),a.current.lanes=C,co(a,C,w),ds(a,w),a}function Ou(a,l,m,w){var C=l.current,T=Vn(),I=So(C);return m=Yw(m),l.context===null?l.context=m:l.pendingContext=m,l=Wr(T,I),l.payload={element:a},w=w===void 0?null:w,w!==null&&(l.callback=w),a=wo(C,l,I),a!==null&&(or(a,C,I,T),du(a,C,I)),I}function Mu(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 Jw(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var m=a.retryLane;a.retryLane=m!==0&&m<l?m:l}}function Ip(a,l){Jw(a,l),(a=a.alternate)&&Jw(a,l)}function tT(){return null}var Xw=typeof reportError=="function"?reportError:function(a){console.error(a)};function zp(a){this._internalRoot=a}Pu.prototype.render=zp.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(s(409));Ou(a,l,null,null)},Pu.prototype.unmount=zp.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;ya(function(){Ou(null,a,null,null)}),l[Ir]=null}};function Pu(a){this._internalRoot=a}Pu.prototype.unstable_scheduleHydration=function(a){if(a){var l=Ol();a={blockedOn:null,target:a,priority:l};for(var m=0;m<ze.length&&l!==0&&l<ze[m].priority;m++);ze.splice(m,0,a),m===0&&qn(a)}};function Dp(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Lu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function Zw(){}function nT(a,l,m,w,C){if(C){if(typeof w=="function"){var T=w;w=function(){var ue=Mu(I);T.call(ue)}}var I=Qw(l,w,a,0,null,!1,!1,"",Zw);return a._reactRootContainer=I,a[Ir]=I.current,Hl(a.nodeType===8?a.parentNode:a),ya(),I}for(;C=a.lastChild;)a.removeChild(C);if(typeof w=="function"){var V=w;w=function(){var ue=Mu(Z);V.call(ue)}}var Z=Lp(a,0,!1,null,null,!1,!1,"",Zw);return a._reactRootContainer=Z,a[Ir]=Z.current,Hl(a.nodeType===8?a.parentNode:a),ya(function(){Ou(l,Z,m,w)}),Z}function Iu(a,l,m,w,C){var T=m._reactRootContainer;if(T){var I=T;if(typeof C=="function"){var V=C;C=function(){var Z=Mu(I);V.call(Z)}}Ou(l,I,a,C)}else I=nT(m,l,a,C,w);return Mu(I)}Rl=function(a){switch(a.tag){case 3:var l=a.stateNode;if(l.current.memoizedState.isDehydrated){var m=lo(l.pendingLanes);m!==0&&(ii(l,m|1),ds(l,lt()),(St&6)===0&&(Ti=lt()+500,yo()))}break;case 13:ya(function(){var w=Ur(a,1);if(w!==null){var C=Vn();or(w,a,1,C)}}),Ip(a,1)}},li=function(a){if(a.tag===13){var l=Ur(a,134217728);if(l!==null){var m=Vn();or(l,a,134217728,m)}Ip(a,134217728)}},Al=function(a){if(a.tag===13){var l=So(a),m=Ur(a,l);if(m!==null){var w=Vn();or(m,a,l,w)}Ip(a,l)}},Ol=function(){return Et},Ml=function(a,l){var m=Et;try{return Et=a,l()}finally{Et=m}},He=function(a,l,m){switch(l){case"input":if(_e(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=eu(w);if(!C)throw Error(s(90));Le(w),_e(w,C)}}}break;case"textarea":$e(a,m);break;case"select":l=m.value,l!=null&&et(a,!!m.multiple,l,!1)}},An=Tp,ps=ya;var sT={usingClientEntryPoint:!1,Events:[ql,xi,eu,zt,it,Tp]},ac={findFiberByHostInstance:ua,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},rT={bundleType:ac.bundleType,version:ac.version,rendererPackageName:ac.rendererPackageName,rendererConfig:ac.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:ac.findFiberByHostInstance||tT,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 zu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zu.isDisabled&&zu.supportsFiber)try{aa=zu.inject(rT),vs=zu}catch{}}return us.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=sT,us.createPortal=function(a,l){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Dp(l))throw Error(s(200));return eT(a,l,null,m)},us.createRoot=function(a,l){if(!Dp(a))throw Error(s(299));var m=!1,w="",C=Xw;return l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(w=l.identifierPrefix),l.onRecoverableError!==void 0&&(C=l.onRecoverableError)),l=Lp(a,1,!1,null,null,m,!1,w,C),a[Ir]=l.current,Hl(a.nodeType===8?a.parentNode:a),new zp(l)},us.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},us.flushSync=function(a){return ya(a)},us.hydrate=function(a,l,m){if(!Lu(l))throw Error(s(200));return Iu(null,a,l,!0,m)},us.hydrateRoot=function(a,l,m){if(!Dp(a))throw Error(s(405));var w=m!=null&&m.hydratedSources||null,C=!1,T="",I=Xw;if(m!=null&&(m.unstable_strictMode===!0&&(C=!0),m.identifierPrefix!==void 0&&(T=m.identifierPrefix),m.onRecoverableError!==void 0&&(I=m.onRecoverableError)),l=Qw(l,null,a,1,m??null,C,!1,T,I),a[Ir]=l.current,Hl(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 Pu(l)},us.render=function(a,l,m){if(!Lu(l))throw Error(s(200));return Iu(null,a,l,!1,m)},us.unmountComponentAtNode=function(a){if(!Lu(a))throw Error(s(40));return a._reactRootContainer?(ya(function(){Iu(null,null,a,!1,function(){a._reactRootContainer=null,a[Ir]=null})}),!0):!1},us.unstable_batchedUpdates=Tp,us.unstable_renderSubtreeIntoContainer=function(a,l,m,w){if(!Lu(m))throw Error(s(200));if(a==null||a._reactInternals===void 0)throw Error(s(38));return Iu(a,l,m,!1,w)},us.version="18.3.1-next-f1338f8080-20240426",us}var ij;function $N(){if(ij)return Wp.exports;ij=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(),Wp.exports=hT(),Wp.exports}var lj;function pT(){if(lj)return Du;lj=1;var e=$N();return Du.createRoot=e.createRoot,Du.hydrateRoot=e.hydrateRoot,Du}var gT=pT();function es(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 Yo=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 xT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_N=(...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 vT={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 yT=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,...vT,width:n,height:n,stroke:e,strokeWidth:r?Number(s)*24/Number(n):s,className:_N("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 Re=(e,n)=>{const s=p.forwardRef(({className:r,...o},i)=>p.createElement(yT,{ref:i,iconNode:n,className:_N(`lucide-${xT(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 bT=Re("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 TN=Re("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 nd=Re("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 Rn=Re("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 Wx=Re("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 fr=Re("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 RN=Re("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 um=Re("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 Sf=Re("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 Hx=Re("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 Cf=Re("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 fm=Re("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 pl=Re("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 Or=Re("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 wT=Re("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 Es=Re("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 nl=Re("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 jT=Re("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 AN=Re("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 Bx=Re("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 kT=Re("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 ON=Re("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 NT=Re("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 ST=Re("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 mm=Re("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 Va=Re("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 CT=Re("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 ET=Re("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 $T=Re("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 _T=Re("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 TT=Re("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 hm=Re("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 Ya=Re("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 MN=Re("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 RT=Re("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 pm=Re("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 cj=Re("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 PN=Re("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 AT=Re("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 OT=Re("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 sd=Re("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 Gx=Re("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 Pg=Re("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 Ia=Re("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 MT=Re("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 PT=Re("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 qx=Re("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 LT=Re("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 IT=Re("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 Gp=Re("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 zT=Re("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 DT=Re("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 FT=Re("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 UT=Re("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 Kx=Re("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 WT=Re("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 HT=Re("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 Qa=Re("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 BT=Re("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 GT=Re("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 qT=Re("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 sl=Re("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 Vx=Re("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 Qo=Re("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 KT=Re("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 gl=Re("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 VT=Re("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 Yx=Re("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 Jo=Re("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 LN=Re("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 Qx=Re("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 YT=Re("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 gm=Re("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 IN=Re("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 QT=Re("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 zN=Re("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 DN=Re("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 Jx=Re("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 JT=Re("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 XT=Re("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 ZT=Re("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 FN=Re("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 Gs=Re("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 Xx=Re("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 rl=Re("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 UN=Re("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 Ja=Re("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 Ef=Re("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 Xo=Re("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 eR=Re("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 WN(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=WN(e[n]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function HN(){for(var e,n,s=0,r="",o=arguments.length;s<o;s++)(e=arguments[s])&&(n=WN(e))&&(r&&(r+=" "),r+=n);return r}const Zx="-",tR=e=>{const n=sR(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const d=c.split(Zx);return d[0]===""&&d.length!==1&&d.shift(),BN(d,n)||nR(c)},getConflictingClassGroupIds:(c,d)=>{const u=s[c]||[];return d&&r[c]?[...u,...r[c]]:u}}},BN=(e,n)=>{var c;if(e.length===0)return n.classGroupId;const s=e[0],r=n.nextPart.get(s),o=r?BN(e.slice(1),r):void 0;if(o)return o;if(n.validators.length===0)return;const i=e.join(Zx);return(c=n.validators.find(({validator:d})=>d(i)))==null?void 0:c.classGroupId},dj=/^\[(.+)\]$/,nR=e=>{if(dj.test(e)){const n=dj.exec(e)[1],s=n==null?void 0:n.substring(0,n.indexOf(":"));if(s)return"arbitrary.."+s}},sR=e=>{const{theme:n,prefix:s}=e,r={nextPart:new Map,validators:[]};return oR(Object.entries(e.classGroups),s).forEach(([i,c])=>{Lg(c,r,i,n)}),r},Lg=(e,n,s,r)=>{e.forEach(o=>{if(typeof o=="string"){const i=o===""?n:uj(n,o);i.classGroupId=s;return}if(typeof o=="function"){if(rR(o)){Lg(o(r),n,s,r);return}n.validators.push({validator:o,classGroupId:s});return}Object.entries(o).forEach(([i,c])=>{Lg(c,uj(n,i),s,r)})})},uj=(e,n)=>{let s=e;return n.split(Zx).forEach(r=>{s.nextPart.has(r)||s.nextPart.set(r,{nextPart:new Map,validators:[]}),s=s.nextPart.get(r)}),s},rR=e=>e.isThemeGetter,oR=(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,aR=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)}}},GN="!",iR=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,b;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==="/"){b=j;continue}}k==="["?f++:k==="]"&&f--}const x=u.length===0?d:d.substring(g),h=x.startsWith(GN),v=h?x.substring(1):x,y=b&&b>g?b-g:void 0;return{modifiers:u,hasImportantModifier:h,baseClassName:v,maybePostfixModifierPosition:y}};return s?d=>s({className:d,parseClassName:c}):c},lR=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:aR(e.cacheSize),parseClassName:iR(e),...tR(e)}),dR=/\s+/,uR=(e,n)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:o}=n,i=[],c=e.trim().split(dR);let d="";for(let u=c.length-1;u>=0;u-=1){const f=c[u],{modifiers:g,hasImportantModifier:b,baseClassName:x,maybePostfixModifierPosition:h}=s(f);let v=!!h,y=r(v?x.substring(0,h):x);if(!y){if(!v){d=f+(d.length>0?" "+d:d);continue}if(y=r(x),!y){d=f+(d.length>0?" "+d:d);continue}v=!1}const j=lR(g).join(":"),k=b?j+GN:j,E=k+y;if(i.includes(E))continue;i.push(E);const S=o(y,v);for(let N=0;N<S.length;++N){const $=S[N];i.push(k+$)}d=f+(d.length>0?" "+d:d)}return d};function fR(){let e=0,n,s,r="";for(;e<arguments.length;)(n=arguments[e++])&&(s=qN(n))&&(r&&(r+=" "),r+=s);return r}const qN=e=>{if(typeof e=="string")return e;let n,s="";for(let r=0;r<e.length;r++)e[r]&&(n=qN(e[r]))&&(s&&(s+=" "),s+=n);return s};function fj(e,...n){let s,r,o,i=c;function c(u){const f=n.reduce((g,b)=>b(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=uR(u,s);return o(u,g),g}return function(){return i(fR.apply(null,arguments))}}const qt=e=>{const n=s=>s[e]||[];return n.isThemeGetter=!0,n},KN=/^\[(?:([a-z-]+):)?(.+)\]$/i,mR=/^\d+\/\d+$/,hR=new Set(["px","full","screen"]),pR=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,gR=/\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$/,xR=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,vR=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,yR=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Gr=e=>Gi(e)||hR.has(e)||mR.test(e),_o=e=>xl(e,"length",ER),Gi=e=>!!e&&!Number.isNaN(Number(e)),qp=e=>xl(e,"number",Gi),lc=e=>!!e&&Number.isInteger(Number(e)),bR=e=>e.endsWith("%")&&Gi(e.slice(0,-1)),gt=e=>KN.test(e),To=e=>pR.test(e),wR=new Set(["length","size","percentage"]),jR=e=>xl(e,wR,VN),kR=e=>xl(e,"position",VN),NR=new Set(["image","url"]),SR=e=>xl(e,NR,_R),CR=e=>xl(e,"",$R),cc=()=>!0,xl=(e,n,s)=>{const r=KN.exec(e);return r?r[1]?typeof n=="string"?r[1]===n:n.has(r[1]):s(r[2]):!1},ER=e=>gR.test(e)&&!xR.test(e),VN=()=>!1,$R=e=>vR.test(e),_R=e=>yR.test(e),mj=()=>{const e=qt("colors"),n=qt("spacing"),s=qt("blur"),r=qt("brightness"),o=qt("borderColor"),i=qt("borderRadius"),c=qt("borderSpacing"),d=qt("borderWidth"),u=qt("contrast"),f=qt("grayscale"),g=qt("hueRotate"),b=qt("invert"),x=qt("gap"),h=qt("gradientColorStops"),v=qt("gradientColorStopPositions"),y=qt("inset"),j=qt("margin"),k=qt("opacity"),E=qt("padding"),S=qt("saturate"),N=qt("scale"),$=qt("sepia"),_=qt("skew"),M=qt("space"),O=qt("translate"),L=()=>["auto","contain","none"],A=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto",gt,n],P=()=>[gt,n],D=()=>["",Gr,_o],W=()=>["auto",Gi,gt],K=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],H=()=>["solid","dashed","dotted","double","none"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F=()=>["start","end","center","between","around","evenly","stretch"],G=()=>["","0",gt],U=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[Gi,gt];return{cacheSize:500,separator:":",theme:{colors:[cc],spacing:[Gr,_o],blur:["none","",To,gt],brightness:z(),borderColor:[e],borderRadius:["none","","full",To,gt],borderSpacing:P(),borderWidth:D(),contrast:z(),grayscale:G(),hueRotate:z(),invert:G(),gap:P(),gradientColorStops:[e],gradientColorStopPositions:[bR,_o],inset:R(),margin:R(),opacity:z(),padding:P(),saturate:z(),scale:z(),sepia:G(),skew:z(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",gt]}],container:["container"],columns:[{columns:[To]}],"break-after":[{"break-after":U()}],"break-before":[{"break-before":U()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...K(),gt]}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:L()}],"overscroll-x":[{"overscroll-x":L()}],"overscroll-y":[{"overscroll-y":L()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",lc,gt]}],basis:[{basis:R()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",gt]}],grow:[{grow:G()}],shrink:[{shrink:G()}],order:[{order:["first","last","none",lc,gt]}],"grid-cols":[{"grid-cols":[cc]}],"col-start-end":[{col:["auto",{span:["full",lc,gt]},gt]}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":[cc]}],"row-start-end":[{row:["auto",{span:[lc,gt]},gt]}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",gt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",gt]}],gap:[{gap:[x]}],"gap-x":[{"gap-x":[x]}],"gap-y":[{"gap-y":[x]}],"justify-content":[{justify:["normal",...F()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...F(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...F(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[E]}],px:[{px:[E]}],py:[{py:[E]}],ps:[{ps:[E]}],pe:[{pe:[E]}],pt:[{pt:[E]}],pr:[{pr:[E]}],pb:[{pb:[E]}],pl:[{pl:[E]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[M]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[M]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",gt,n]}],"min-w":[{"min-w":[gt,n,"min","max","fit"]}],"max-w":[{"max-w":[gt,n,"none","full","min","max","fit","prose",{screen:[To]},To]}],h:[{h:[gt,n,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[gt,n,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[gt,n,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[gt,n,"auto","min","max","fit"]}],"font-size":[{text:["base",To,_o]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",qp]}],"font-family":[{font:[cc]}],"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",gt]}],"line-clamp":[{"line-clamp":["none",Gi,qp]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Gr,gt]}],"list-image":[{"list-image":["none",gt]}],"list-style-type":[{list:["none","disc","decimal",gt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Gr,_o]}],"underline-offset":[{"underline-offset":["auto",Gr,gt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",gt]}],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",gt]}],"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:[...K(),kR]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",jR]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},SR]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[d]}],"border-w-x":[{"border-x":[d]}],"border-w-y":[{"border-y":[d]}],"border-w-s":[{"border-s":[d]}],"border-w-e":[{"border-e":[d]}],"border-w-t":[{"border-t":[d]}],"border-w-r":[{"border-r":[d]}],"border-w-b":[{"border-b":[d]}],"border-w-l":[{"border-l":[d]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...H(),"hidden"]}],"divide-x":[{"divide-x":[d]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[d]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:H()}],"border-color":[{border:[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:["",...H()]}],"outline-offset":[{"outline-offset":[Gr,gt]}],"outline-w":[{outline:[Gr,_o]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Gr,_o]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",To,CR]}],"shadow-color":[{shadow:[cc]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...q(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":q()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",To,gt]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[g]}],invert:[{invert:[b]}],saturate:[{saturate:[S]}],sepia:[{sepia:[$]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[g]}],"backdrop-invert":[{"backdrop-invert":[b]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[S]}],"backdrop-sepia":[{"backdrop-sepia":[$]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",gt]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",gt]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",gt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[N]}],"scale-x":[{"scale-x":[N]}],"scale-y":[{"scale-y":[N]}],rotate:[{rotate:[lc,gt]}],"translate-x":[{"translate-x":[O]}],"translate-y":[{"translate-y":[O]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",gt]}],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",gt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",gt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Gr,_o,qp]}],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"]}}},TR=(e,{cacheSize:n,prefix:s,separator:r,experimentalParseClassName:o,extend:i={},override:c={}})=>{jc(e,"cacheSize",n),jc(e,"prefix",s),jc(e,"separator",r),jc(e,"experimentalParseClassName",o);for(const d in c)RR(e[d],c[d]);for(const d in i)AR(e[d],i[d]);return e},jc=(e,n,s)=>{s!==void 0&&(e[n]=s)},RR=(e,n)=>{if(n)for(const s in n)jc(e,s,n[s])},AR=(e,n)=>{if(n)for(const s in n){const r=n[s];r!==void 0&&(e[s]=(e[s]||[]).concat(r))}},OR=(e,...n)=>typeof e=="function"?fj(mj,e,...n):fj(()=>TR(mj(),e),...n),MR=OR({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)=>MR(HN(e)),PR={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:Pg},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:Pg},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:AN},warning:{box:"border-warning/50 bg-warning/5",text:"text-warning-text",Icon:Gs},error:{box:"border-destructive/50 bg-destructive/5",text:"text-destructive-text",Icon:nl}};function vt({tone:e="neutral",title:n,actions:s,bar:r,icon:o,role:i,className:c,children:d,...u}){const f=PR[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 hj=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,pj=HN,LR=(e,n)=>s=>{var r;if((n==null?void 0:n.variants)==null)return pj(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],b=i==null?void 0:i[f];if(g===null)return null;const x=hj(g)||hj(b);return o[f][x]}),d=s&&Object.entries(s).reduce((f,g)=>{let[b,x]=g;return x===void 0||(f[b]=x),f},{}),u=n==null||(r=n.compoundVariants)===null||r===void 0?void 0:r.reduce((f,g)=>{let{class:b,className:x,...h}=g;return Object.entries(h).every(v=>{let[y,j]=v;return Array.isArray(j)?j.includes({...i,...d}[y]):{...i,...d}[y]===j})?[...f,b,x]:f},[]);return pj(e,c,u,s==null?void 0:s.class,s==null?void 0:s.className)},Lc=LR("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(Lc({variant:n,size:s}),e),...r}));B.displayName="Button";const gj={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 ke({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",gj[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",gj[e],n),children:o})}const qs=e=>IR(e)?e.document:zR(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),xm=e=>{let n=qs(e);return(n==null?void 0:n.defaultView)??(typeof window<"u"?window:void 0)};function YN(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function IR(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function zR(e){return YN(e)&&e.nodeType===9}function DR(e){return YN(e)&&e.nodeType===11&&"host"in e}let FR=!1;function ev(){return FR}function Ra(e,n){var r;if(!ev())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:DR(s)?s=s.host:s=s.parentNode}return!1}const Ho=(e=document)=>{var s;if(!ev())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 Jn(e){if(ev()&&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 UR(e){e.focus({preventScroll:!0})}const WR=typeof document<"u"?Ke.useLayoutEffect:()=>{};function QN(e){let n=e;return n.nativeEvent=e,n.isDefaultPrevented=()=>n.defaultPrevented,n.isPropagationStopped=()=>n.cancelBubble,n.persist=()=>{},n}function HR(e,n){Object.defineProperty(e,"target",{value:n}),Object.defineProperty(e,"currentTarget",{value:n})}function JN(e){let n=p.useRef({isFocused:!1,observer:null});return WR(()=>{const s=n.current;return()=>{s.observer&&(s.observer.disconnect(),s.observer=null)}},[]),p.useCallback(s=>{let r=Jn(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=QN(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 tv(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 nv(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 Xa(e){let n=null;return()=>(n==null&&(n=e()),n)}const sv=Xa(function(){return nv(/^Mac/i)}),BR=Xa(function(){return nv(/^iPhone/i)}),XN=Xa(function(){return nv(/^iPad/i)||sv()&&navigator.maxTouchPoints>1}),GR=Xa(function(){return BR()||XN()}),qR=Xa(function(){return tv(/AppleWebKit/i)&&(GR()||!KR())}),KR=Xa(function(){return tv(/Chrome|CriOS|CrMo/i)}),VR=Xa(function(){return tv(/Android/i)});function YR(e){return e.pointerType===""&&e.isTrusted?!0:VR()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Ic(e,n,s=!0){let{metaKey:r,ctrlKey:o,altKey:i,shiftKey:c}=n,d=qR()&&sv()&&!XN()?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});Ic.isOpening=s,UR(e),e.dispatchEvent(d),Ic.isOpening=!1}Ic.isOpening=!1;let vl=null;const Ig=new Set;let $c=new Map,za=!1,mf=!1;const QR={Tab:!0,Escape:!0};function vm(e,n){for(let s of Ig)s(e,n)}function JR(e){return!(e.metaKey||!sv()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function $f(e){za=!0,!Ic.isOpening&&JR(e)&&(vl="keyboard",vm("keyboard",e))}function qi(e){vl="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(za=!0,vm("pointer",e))}function ZN(e){!Ic.isOpening&&YR(e)&&(za=!0,vl="virtual")}function e1(e){let n=Jn(e),s=xm(n),r=qs(n);if(n===s){mf=!0;return}n===r||!e.isTrusted||(!za&&!mf&&(vl="virtual",vm("virtual",e)),za=!1,mf=!1)}function t1(){za=!1,mf=!0}function n1(e){let n=Ho(qs(Jn(e)));queueMicrotask(()=>{Ho(qs(Jn(e)))!==n&&ZR("keyboard")})}function zg(e){if(typeof window>"u"||typeof document>"u")return;const n=xm(e),s=qs(e);if($c.get(n))return;let r=n.HTMLElement.prototype.focus;Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){za=!0,r.apply(this,arguments)}}),s.addEventListener("keydown",$f,!0),s.addEventListener("keyup",$f,!0),s.addEventListener("click",ZN,!0),s.addEventListener("invalid",n1,!0),n.addEventListener("focus",e1,!0),n.addEventListener("blur",t1,!1),typeof PointerEvent<"u"&&(s.addEventListener("pointerdown",qi,!0),s.addEventListener("pointermove",qi,!0),s.addEventListener("pointerup",qi,!0)),n.addEventListener("beforeunload",()=>{s1(e)},{once:!0}),$c.set(n,{focus:r})}const s1=(e,n)=>{const s=xm(e),r=qs(e);n&&r.removeEventListener("DOMContentLoaded",n),$c.has(s)&&(Reflect.defineProperty(s.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:$c.get(s).focus}),r.removeEventListener("keydown",$f,!0),r.removeEventListener("keyup",$f,!0),r.removeEventListener("click",ZN,!0),r.removeEventListener("invalid",n1,!0),s.removeEventListener("focus",e1,!0),s.removeEventListener("blur",t1,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",qi,!0),r.removeEventListener("pointermove",qi,!0),r.removeEventListener("pointerup",qi,!0)),$c.delete(s))};function XR(e){const n=qs(e);let s;return n.readyState!=="loading"?zg(e):(s=()=>{zg(e)},n.addEventListener("DOMContentLoaded",s)),()=>s1(e,s)}typeof document<"u"&&XR();function Dg(){return vl!=="pointer"}function ZR(e){vl=e,vm(e,null)}const eA=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function tA(e,n,s){let r=s?Jn(s):void 0,o=qs(r),i=xm(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&&!eA.has(g.type)||g instanceof d||g instanceof u&&g.isContentEditable,!(e&&n==="keyboard"&&s instanceof f&&!QR[s.key])}function nA(e,n,s){zg(),p.useEffect(()=>{if((s==null?void 0:s.enabled)===!1)return;let r=(o,i)=>{tA(!!(s!=null&&s.isTextInput),o,i)&&e(Dg())};return Ig.add(r),()=>{Ig.delete(r)}},n)}function sA(e){let{isDisabled:n,onFocus:s,onBlur:r,onFocusChange:o}=e;const i=p.useCallback(u=>{if(Jn(u)===u.currentTarget)return r&&r(u),o&&o(!1),!0},[r,o]),c=JN(i),d=p.useCallback(u=>{let f=Jn(u);const g=qs(f),b=g?Ho(g):Ho();f===u.currentTarget&&f===b&&(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 r1(){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 rA(e){let{isDisabled:n,onBlurWithin:s,onFocusWithin:r,onFocusWithinChange:o}=e,i=p.useRef({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:d}=r1(),u=p.useCallback(b=>{Ra(b.currentTarget,Jn(b))&&i.current.isFocusWithin&&!Ra(b.currentTarget,b.relatedTarget)&&(i.current.isFocusWithin=!1,d(),s&&s(b),o&&o(!1))},[s,o,i,d]),f=JN(u),g=p.useCallback(b=>{if(!Ra(b.currentTarget,Jn(b)))return;let x=Jn(b);const h=qs(x),v=Ho(h);if(!i.current.isFocusWithin&&v===x){r&&r(b),o&&o(!0),i.current.isFocusWithin=!0,f(b);let y=b.currentTarget;c(h,"focus",j=>{let k=Jn(j);if(i.current.isFocusWithin&&!Ra(y,k)){let E=new h.defaultView.FocusEvent("blur",{relatedTarget:k});HR(E,y);let S=QN(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 oA(e={}){let{autoFocus:n=!1,isTextInput:s,within:r}=e,o=p.useRef({isFocused:!1,isFocusVisible:n||Dg()}),[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=Dg(),c(h),f()},[f]);nA(h=>{o.current.isFocusVisible=h,f()},[s,i],{enabled:i,isTextInput:s});let{focusProps:b}=sA({isDisabled:r,onFocusChange:g}),{focusWithinProps:x}=rA({isDisabled:!r,onFocusWithinChange:g});return{isFocused:i,isFocusVisible:d,focusProps:r?x:b}}var Ns=$N();let Fg=!1,Fu=0;function aA(){Fg=!0,setTimeout(()=>{Fg=!1},500)}function xj(e){e.pointerType==="touch"&&aA()}function iA(){let e=qs(null);if(!(typeof e>"u"))return Fu===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",xj),Fu++,()=>{Fu--,!(Fu>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",xj)}}function lA(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(iA,[]);let{addGlobalListener:u,removeAllGlobalListeners:f}=r1(),{hoverProps:g,triggerHoverEnd:b}=p.useMemo(()=>{let x=(y,j)=>{if(d.pointerType=j,o||j==="touch"||d.isHovered||!Ra(y.currentTarget,Jn(y)))return;d.isHovered=!0;let k=y.currentTarget;d.target=k,u(qs(Jn(y)),"pointerover",E=>{d.isHovered&&d.target&&!Ra(d.target,Jn(E))&&h(E,E.pointerType)},{capture:!0}),n&&n({type:"hoverstart",target:k,pointerType:j}),s&&s(!0),c(!0)},h=(y,j)=>{let k=d.target;d.pointerType="",d.target=null,!(j==="touch"||!d.isHovered||!k)&&(d.isHovered=!1,f(),r&&r({type:"hoverend",target:k,pointerType:j}),s&&s(!1),c(!1))},v={};return typeof PointerEvent<"u"&&(v.onPointerEnter=y=>{Fg&&y.pointerType==="mouse"||x(y,y.pointerType)},v.onPointerLeave=y=>{!o&&Ra(y.currentTarget,Jn(y))&&h(y,y.pointerType)}),{hoverProps:v,triggerHoverEnd:h}},[n,s,r,o,d,u,f]);return p.useEffect(()=>{o&&b({currentTarget:d.target},d.pointerType)},[o]),{hoverProps:g,isHovered:i}}var cA=Object.defineProperty,dA=(e,n,s)=>n in e?cA(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Kp=(e,n,s)=>(dA(e,typeof n!="symbol"?n+"":n,s),s);let uA=class{constructor(){Kp(this,"current",this.detect()),Kp(this,"handoffState","pending"),Kp(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"}},Cr=new uA;function yl(e){var n;return Cr.isServer?null:e==null?document:(n=e==null?void 0:e.ownerDocument)!=null?n:document}function _f(e){var n,s;return Cr.isServer?null:e==null?document:(s=(n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))!=null?s:document}function o1(e){var n,s;return(s=(n=_f(e))==null?void 0:n.activeElement)!=null?s:null}function a1(e){return o1(e)===e}function ym(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(n=>setTimeout(()=>{throw n}))}function $s(){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 ym(()=>{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=$s();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 Zo(){let[e]=p.useState($s);return p.useEffect(()=>()=>e.dispose(),[e]),e}let en=(e,n)=>{Cr.isServer?p.useEffect(e,n):p.useLayoutEffect(e,n)};function ea(e){let n=p.useRef(e);return en(()=>{n.current=e},[e]),n}let ut=function(e){let n=ea(e);return Ke.useCallback((...s)=>n.current(...s),[n])};function fA(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 mA(e,n){return!(!e||!n||e.right<n.left||e.left>n.right||e.bottom<n.top||e.top>n.bottom)}function hA({disabled:e=!1}={}){let n=p.useRef(null),[s,r]=p.useState(!1),o=Zo(),i=ut(()=>{n.current=null,r(!1),o.dispose()}),c=ut(d=>{if(o.dispose(),n.current===null){n.current=d.currentTarget,r(!0);{let u=yl(d.currentTarget);o.addEventListener(u,"pointerup",i,!1),o.addEventListener(u,"pointermove",f=>{if(n.current){let g=fA(f);r(mA(g,n.current.getBoundingClientRect()))}},!1),o.addEventListener(u,"pointercancel",i,!1)}}});return{pressed:s,pressProps:e?{}:{onPointerDown:c,onPointerUp:i,onClick:i}}}function Ks(e){return p.useMemo(()=>e,Object.values(e))}let pA=p.createContext(void 0);function rv(){return p.useContext(pA)}function Ug(...e){return Array.from(new Set(e.flatMap(n=>typeof n=="string"?n.split(" "):[]))).filter(Boolean).join(" ")}function ts(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,ts),r}var ol=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(ol||{}),zo=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(zo||{});function Cn(){let e=xA();return p.useCallback(n=>gA({mergeRefs:e,...n}),[e])}function gA({ourProps:e,theirProps:n,slot:s,defaultTag:r,features:o,visible:i=!0,name:c,mergeRefs:d}){d=d??vA;let u=i1(n,e);if(i)return Uu(u,s,r,c,d);let f=o??0;if(f&2){let{static:g=!1,...b}=u;if(g)return Uu(b,s,r,c,d)}if(f&1){let{unmount:g=!0,...b}=u;return ts(g?0:1,{0(){return null},1(){return Uu({...b,hidden:!0,style:{display:"none"}},s,r,c,d)}})}return Uu(u,s,r,c,d)}function Uu(e,n={},s,r,o){let{as:i=s,children:c,refName:d="ref",...u}=Vp(e,["unmount","static"]),f=e.ref!==void 0?{[d]:e.ref}:{},g=typeof c=="function"?c(n):c;g=c1(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 b={};if(n){let x=!1,h=[];for(let[v,y]of Object.entries(n))typeof y=="boolean"&&(x=!0),y===!0&&h.push(v.replace(/([A-Z])/g,j=>`-${j.toLowerCase()}`));if(x){b["data-headlessui-state"]=h.join(" ");for(let v of h)b[`data-${v}`]=""}}if(_c(i)&&(Object.keys(Lo(u)).length>0||Object.keys(Lo(b)).length>0))if(!p.isValidElement(g)||Array.isArray(g)&&g.length>1||bA(g)){if(Object.keys(Lo(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(Lo(u)).concat(Object.keys(Lo(b))).map(x=>` - ${x}`).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(x=>` - ${x}`).join(`
|
|
512
|
+
`)].join(`
|
|
513
|
+
`))}else{let x=g.props,h=x==null?void 0:x.className,v=typeof h=="function"?(...k)=>Ug(h(...k),u.className):Ug(h,u.className),y=v?{className:v}:{},j=i1(g.props,Lo(Vp(u,["ref"])));for(let k in b)k in j&&delete b[k];return p.cloneElement(g,Object.assign({},j,b,f,{ref:o(yA(g),f.ref)},y))}return p.createElement(i,Object.assign({},Vp(u,["ref"]),!_c(i)&&f,!_c(i)&&b),g)}function xA(){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 vA(...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 i1(...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 l1(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},s={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(s[o]!=null||(s[o]=[]),s[o].push(r[o])):n[o]=r[o];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 gn(e){var n;return Object.assign(p.forwardRef(e),{displayName:(n=e.displayName)!=null?n:e.name})}function Lo(e){let n=Object.assign({},e);for(let s in n)n[s]===void 0&&delete n[s];return n}function Vp(e,n=[]){let s=Object.assign({},e);for(let r of n)r in s&&delete s[r];return s}function yA(e){return Ke.version.split(".")[0]>="19"?e.props.ref:e.ref}function c1(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let n=e._payload;if(n!=null&&n.status==="fulfilled")return c1(n.value)}return e}function _c(e){return e===p.Fragment||e===Symbol.for("react.fragment")}function bA(e){return _c(e.type)}function wA(e,n,s){let[r,o]=p.useState(s),i=e!==void 0,c=p.useRef(i),d=p.useRef(!1),u=p.useRef(!1);return i&&!c.current&&!d.current?(d.current=!0,c.current=i,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!i&&c.current&&!u.current&&(u.current=!0,c.current=i,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[i?e:r,ut(f=>(i||Ns.flushSync(()=>o(f)),n==null?void 0:n(f)))]}function jA(e){let[n]=p.useState(e);return n}function d1(e={},n=null,s=[]){for(let[r,o]of Object.entries(e))f1(s,u1(n,r),o);return s}function u1(e,n){return e?e+"["+n+"]":n}function f1(e,n,s){if(Array.isArray(s))for(let[r,o]of s.entries())f1(e,u1(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,""]):NA(s)&&!p.isValidElement(s)&&d1(s,n,e)}function kA(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 NA(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}let SA="span";var al=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(al||{});function CA(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 Cn()({ourProps:i,theirProps:o,slot:{},defaultTag:SA,name:"Hidden"})}let zc=gn(CA),EA=p.createContext(null);function $A({children:e}){let n=p.useContext(EA);if(!n)return Ke.createElement(Ke.Fragment,null,e);let{target:s}=n;return s?Ns.createPortal(Ke.createElement(Ke.Fragment,null,e),s):null}function _A({data:e,form:n,disabled:s,onReset:r,overrides:o}){let[i,c]=p.useState(null),d=Zo();return p.useEffect(()=>{if(r&&i)return d.addEventListener(i,"reset",r)},[i,n,r]),Ke.createElement($A,null,Ke.createElement(TA,{setForm:c,formId:n}),d1(e).map(([u,f])=>Ke.createElement(zc,{features:al.Hidden,...Lo({key:u,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:n,disabled:s,name:u,value:f,...o})})))}function TA({setForm:e,formId:n}){return p.useEffect(()=>{if(n){let s=document.getElementById(n);s&&e(s)}},[e,n]),n?null:Ke.createElement(zc,{features:al.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let r=s.closest("form");r&&e(r)}})}let RA=p.createContext(void 0);function m1(){return p.useContext(RA)}function h1(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function Xr(e){return h1(e)&&"tagName"in e}function Ss(e){return Xr(e)&&"accessKey"in e}function Yr(e){return Xr(e)&&"tabIndex"in e}function AA(e){return Xr(e)&&"style"in e}function OA(e){return Ss(e)&&e.nodeName==="IFRAME"}function p1(e){return Ss(e)&&e.nodeName==="INPUT"}function vj(e){return Ss(e)&&e.nodeName==="LABEL"}function MA(e){return Ss(e)&&e.nodeName==="FIELDSET"}function g1(e){return Ss(e)&&e.nodeName==="LEGEND"}function PA(e){return Xr(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function yj(e){let n=e.parentElement,s=null;for(;n&&!MA(n);)g1(n)&&(s=n),n=n.parentElement;let r=(n==null?void 0:n.getAttribute("disabled"))==="";return r&&LA(s)?!1:r}function LA(e){if(!e)return!1;let n=e.previousElementSibling;for(;n!==null;){if(g1(n))return!1;n=n.previousElementSibling}return!0}let x1=Symbol();function IA(e,n=!0){return Object.assign(e,{[x1]:n})}function Fn(...e){let n=p.useRef(e);p.useEffect(()=>{n.current=e},[e]);let s=ut(r=>{for(let o of n.current)o!=null&&(typeof o=="function"?o(r):o.current=r)});return e.every(r=>r==null||(r==null?void 0:r[x1]))?void 0:s}let bm=p.createContext(null);bm.displayName="DescriptionContext";function v1(){let e=p.useContext(bm);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,v1),n}return e}function zA(){var e,n;return(n=(e=p.useContext(bm))==null?void 0:e.value)!=null?n:void 0}function DA(){let[e,n]=p.useState([]);return[e.length>0?e.join(" "):void 0,p.useMemo(()=>function(s){let r=ut(i=>(n(c=>[...c,i]),()=>n(c=>{let d=c.slice(),u=d.indexOf(i);return u!==-1&&d.splice(u,1),d}))),o=p.useMemo(()=>({register:r,slot:s.slot,name:s.name,props:s.props,value:s.value}),[r,s.slot,s.name,s.props,s.value]);return Ke.createElement(bm.Provider,{value:o},s.children)},[n])]}let FA="p";function UA(e,n){let s=p.useId(),r=rv(),{id:o=`headlessui-description-${s}`,...i}=e,c=v1(),d=Fn(n);en(()=>c.register(o),[o,c.register]);let u=Ks({...c.slot,disabled:r||!1}),f={ref:d,...c.props,id:o};return Cn()({ourProps:f,theirProps:i,slot:u,defaultTag:FA,name:c.name||"Description"})}let WA=gn(UA),y1=Object.assign(WA,{});var yn=(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))(yn||{});let wm=p.createContext(null);wm.displayName="LabelContext";function b1(){let e=p.useContext(wm);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,b1),n}return e}function w1(e){var n,s,r;let o=(s=(n=p.useContext(wm))==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 HA({inherit:e=!1}={}){let n=w1(),[s,r]=p.useState([]),o=e?[n,...s].filter(Boolean):s;return[o.length>0?o.join(" "):void 0,p.useMemo(()=>function(i){let c=ut(u=>(r(f=>[...f,u]),()=>r(f=>{let g=f.slice(),b=g.indexOf(u);return b!==-1&&g.splice(b,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(wm.Provider,{value:d},i.children)},[r])]}let BA="label";function GA(e,n){var s;let r=p.useId(),o=b1(),i=m1(),c=rv(),{id:d=`headlessui-label-${r}`,htmlFor:u=i??((s=o.props)==null?void 0:s.htmlFor),passive:f=!1,...g}=e,b=Fn(n);en(()=>o.register(d),[d,o.register]);let x=ut(y=>{let j=y.currentTarget;if(!(y.target!==y.currentTarget&&PA(y.target))&&(vj(j)&&y.preventDefault(),o.props&&"onClick"in o.props&&typeof o.props.onClick=="function"&&o.props.onClick(y),vj(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;(p1(k)&&(k.type==="file"||k.type==="radio"||k.type==="checkbox")||k.role==="radio"||k.role==="checkbox"||k.role==="switch")&&k.click(),k.focus({preventScroll:!0})}}}),h=Ks({...o.slot,disabled:c||!1}),v={ref:b,...o.props,id:d,htmlFor:u,onClick:x};return f&&("onClick"in v&&(delete v.htmlFor,delete v.onClick),"onClick"in g&&delete g.onClick),Cn()({ourProps:v,theirProps:g,slot:h,defaultTag:u?BA:"div",name:o.name||"Label"})}let qA=gn(GA),KA=Object.assign(qA,{}),VA=p.createContext(()=>{});function YA({value:e,children:n}){return Ke.createElement(VA.Provider,{value:e},n)}function QA(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 JA(e=QA){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 bj(e){if(e===null)return{width:0,height:0};let{width:n,height:s}=e.getBoundingClientRect();return{width:n,height:s}}function XA(e,n,s=!1){let[r,o]=p.useState(()=>bj(n));return en(()=>{if(!n||!e)return;let i=$s();return i.requestAnimationFrame(function c(){i.requestAnimationFrame(c),o(d=>{let u=bj(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 j1=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(j1||{});function ZA(e){let n=p.useRef(null),s=ut(o=>{n.current=o.pointerType,!yj(o.currentTarget)&&o.pointerType==="mouse"&&o.button===j1.Left&&(o.preventDefault(),e(o))}),r=ut(o=>{n.current!=="mouse"&&(yj(o.currentTarget)||e(o))});return{onPointerDown:s,onClick:r}}let k1=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 e3=Object.defineProperty,t3=(e,n,s)=>n in e?e3(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,n3=(e,n,s)=>(t3(e,n+"",s),s),N1=(e,n,s)=>{if(!n.has(e))throw TypeError("Cannot "+s)},zs=(e,n,s)=>(N1(e,n,"read from private field"),s?s.call(e):n.get(e)),Yp=(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)},wj=(e,n,s,r)=>(N1(e,n,"write to private field"),n.set(e,s),s),jr,kc,Nc;let S1=class{constructor(n){Yp(this,jr,{}),Yp(this,kc,new k1(()=>new Set)),Yp(this,Nc,new Set),n3(this,"disposables",$s()),wj(this,jr,n),Cr.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return zs(this,jr)}subscribe(n,s){if(Cr.isServer)return()=>{};let r={selector:n,callback:s,current:n(zs(this,jr))};return zs(this,Nc).add(r),this.disposables.add(()=>{zs(this,Nc).delete(r)})}on(n,s){return Cr.isServer?()=>{}:(zs(this,kc).get(n).add(s),this.disposables.add(()=>{zs(this,kc).get(n).delete(s)}))}send(n){let s=this.reduce(zs(this,jr),n);if(s!==zs(this,jr)){wj(this,jr,s);for(let r of zs(this,Nc)){let o=r.selector(zs(this,jr));C1(r.current,o)||(r.current=o,r.callback(o))}for(let r of zs(this,kc).get(n.type))r(zs(this,jr),n)}}};jr=new WeakMap,kc=new WeakMap,Nc=new WeakMap;function C1(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:Qp(e[Symbol.iterator](),n[Symbol.iterator]()):e instanceof Map&&n instanceof Map||e instanceof Set&&n instanceof Set?e.size!==n.size?!1:Qp(e.entries(),n.entries()):jj(e)&&jj(n)?Qp(Object.entries(e)[Symbol.iterator](),Object.entries(n)[Symbol.iterator]()):!1}function Qp(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 jj(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}function Jp(e){let[n,s]=e(),r=$s();return(...o)=>{n(...o),r.dispose(),r.microTask(s)}}var s3=Object.defineProperty,r3=(e,n,s)=>n in e?s3(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,kj=(e,n,s)=>(r3(e,typeof n!="symbol"?n+"":n,s),s),E1=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(E1||{});let o3={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}}},a3=class $1 extends S1{constructor(){super(...arguments),kj(this,"actions",{push:n=>this.send({type:0,id:n}),pop:n=>this.send({type:1,id:n})}),kj(this,"selectors",{isTop:(n,s)=>n.stack[n.stack.length-1]===s,inStack:(n,s)=>n.stack.includes(s)})}static new(){return new $1({stack:[]})}reduce(n,s){return ts(s.type,o3,n,s)}};const jm=new k1(()=>a3.new());var Xp={exports:{}},Zp={};/**
|
|
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 Nj;function i3(){if(Nj)return Zp;Nj=1;var e=dm();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 Zp.useSyncExternalStoreWithSelector=function(u,f,g,b,x){var h=o(null);if(h.current===null){var v={hasValue:!1,value:null};h.current=v}else v=h.current;h=c(function(){function j($){if(!k){if(k=!0,E=$,$=b($),x!==void 0&&v.hasValue){var _=v.value;if(x(_,$))return S=_}return S=$}if(_=S,s(E,$))return _;var M=b($);return x!==void 0&&x(_,M)?(E=$,_):(E=$,S=M)}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,b,x]);var y=r(u,h[0],h[1]);return i(function(){v.hasValue=!0,v.value=y},[y]),d(y),y},Zp}var Sj;function l3(){return Sj||(Sj=1,Xp.exports=i3()),Xp.exports}var c3=l3();function Qn(e,n,s=C1){return c3.useSyncExternalStoreWithSelector(ut(r=>e.subscribe(d3,r)),ut(()=>e.state),ut(()=>e.state),ut(n),s)}function d3(e){return e}function rd(e,n){let s=p.useId(),r=jm.get(n),[o,i]=Qn(r,p.useCallback(c=>[r.selectors.isTop(c,s),r.selectors.inStack(c,s)],[r,s]));return en(()=>{if(e)return r.actions.push(s),()=>r.actions.pop(s)},[r,e,s]),e?i?o:!0:!1}let Wg=new Map,Tc=new Map;function Cj(e){var n;let s=(n=Tc.get(e))!=null?n:0;return Tc.set(e,s+1),s!==0?()=>Ej(e):(Wg.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Ej(e))}function Ej(e){var n;let s=(n=Tc.get(e))!=null?n:1;if(s===1?Tc.delete(e):Tc.set(e,s-1),s!==1)return;let r=Wg.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,Wg.delete(e))}function _1(e,{allowed:n,disallowed:s}={}){let r=rd(e,"inert-others");en(()=>{var o,i;if(!r)return;let c=$s();for(let u of(o=s==null?void 0:s())!=null?o:[])u&&c.add(Cj(u));let d=(i=n==null?void 0:n())!=null?i:[];for(let u of d){if(!u)continue;let f=yl(u);if(!f)continue;let g=u.parentElement;for(;g&&g!==f.body;){for(let b of g.children)d.some(x=>b.contains(x))||c.add(Cj(b));g=g.parentElement}}return c.dispose},[r,n,s])}function T1(e,n,s){let r=ea(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:Ss(n)?n:n.current;if(!o)return;let i=$s();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 Tf=["[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(","),u3=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var lr=(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))(lr||{}),Hg=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(Hg||{}),f3=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(f3||{});function R1(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(Tf)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}function m3(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(u3)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}var ov=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(ov||{});function A1(e,n=0){var s;return e===((s=yl(e))==null?void 0:s.body)?!1:ts(n,{0(){return e.matches(Tf)},1(){let r=e;for(;r!==null;){if(r.matches(Tf))return!0;r=r.parentElement}return!1}})}var h3=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(h3||{});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 Zr(e){e==null||e.focus({preventScroll:!0})}let p3=["textarea","input"].join(",");function g3(e){var n,s;return(s=(n=e==null?void 0:e.matches)==null?void 0:n.call(e,p3))!=null?s:!1}function O1(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 x3(e,n,s=e===null?document.body:_f(e)){return Ki(R1(s),n,{relativeTo:e})}function Ki(e,n,{sorted:s=!0,relativeTo:r=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?_f(e[0]):document:_f(e),c=Array.isArray(e)?s?O1(e):e:n&64?m3(e):R1(e);o.length>0&&c.length>1&&(c=c.filter(h=>!o.some(v=>v!=null&&"current"in v?(v==null?void 0:v.current)===h:v===h))),r=r??(i==null?void 0:i.activeElement);let d=(()=>{if(n&5)return 1;if(n&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),u=(()=>{if(n&1)return 0;if(n&2)return Math.max(0,c.indexOf(r))-1;if(n&4)return Math.max(0,c.indexOf(r))+1;if(n&8)return c.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),f=n&32?{preventScroll:!0}:{},g=0,b=c.length,x;do{if(g>=b||g+b<=0)return 0;let h=u+g;if(n&16)h=(h+b)%b;else{if(h<0)return 3;if(h>=b)return 1}x=c[h],x==null||x.focus(f),g+=d}while(x!==o1(x));return n&6&&g3(x)&&x.select(),2}function M1(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function v3(){return/Android/gi.test(window.navigator.userAgent)}function $j(){return M1()||v3()}function Fi(e,n,s,r){let o=ea(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 P1(e,n,s,r){let o=ea(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 _j=30;function L1(e,n,s){let r=ea(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 b(x){return typeof x=="function"?b(x()):Array.isArray(x)||x instanceof Set?x:[x]})(n);for(let b of g)if(b!==null&&(b.contains(f)||d.composed&&d.composedPath().includes(b)))return;return!A1(f,ov.Loose)&&f.tabIndex!==-1&&d.preventDefault(),r.current(d,f)},[r,n]),i=p.useRef(null);Fi(e,"pointerdown",d=>{var u,f;$j()||(i.current=((f=(u=d.composedPath)==null?void 0:u.call(d))==null?void 0:f[0])||d.target)},!0),Fi(e,"pointerup",d=>{if($j()||!i.current)return;let u=i.current;return i.current=null,o(d,()=>u)},!0);let c=p.useRef({x:0,y:0});Fi(e,"touchstart",d=>{c.current.x=d.touches[0].clientX,c.current.y=d.touches[0].clientY},!0),Fi(e,"touchend",d=>{let u={x:d.changedTouches[0].clientX,y:d.changedTouches[0].clientY};if(!(Math.abs(u.x-c.current.x)>=_j||Math.abs(u.y-c.current.y)>=_j))return o(d,()=>Yr(d.target)?d.target:null)},!0),P1(e,"blur",d=>o(d,()=>OA(window.document.activeElement)?window.document.activeElement:null),!0)}function Dc(...e){return p.useMemo(()=>yl(...e),[...e])}var y3=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(y3||{});const Wu={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},b3=200,Tj=5;function w3(e,{trigger:n,action:s,close:r,select:o}){let i=p.useRef(null),c=p.useRef(null),d=p.useRef(null);Fi(e&&n!==null,"pointerdown",u=>{h1(u==null?void 0:u.target)&&n!=null&&n.contains(u.target)&&(c.current=u.x,d.current=u.y,i.current=u.timeStamp)}),Fi(e&&n!==null,"pointerup",u=>{var f,g;let b=i.current;if(b===null||(i.current=null,!Yr(u.target))||Math.abs(u.x-((f=c.current)!=null?f:u.x))<Tj&&Math.abs(u.y-((g=d.current)!=null?g:u.y))<Tj)return;let x=s(u);switch(x.kind){case 0:return;case 1:{u.timeStamp-b>b3&&(o(x.target),r());break}case 2:{r();break}}},{capture:!0})}function I1(e,n,s,r){let o=ea(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 j3(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 k3(e){return p.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function N3(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 S3(){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 C3(){return M1()?{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=$s();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(Yr(d.target))try{let u=d.target.closest("a");if(!u)return;let{hash:f}=new URL(u.href),g=e.querySelector(f);Yr(g)&&!r(g)&&(c=g)}catch{}},!0),n.group(d=>{n.addEventListener(e,"touchstart",u=>{if(d.dispose(),Yr(u.target)&&AA(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(Yr(d.target)){if(p1(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 E3(){return{before({doc:e,d:n}){n.style(e.documentElement,"overflow","hidden")}}}function Rj(e){let n={};for(let s of e)Object.assign(n,s(n));return n}let Aa=N3(()=>new Map,{PUSH(e,n){var s;let r=(s=this.get(e))!=null?s:{doc:e,count:0,d:$s(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(n),r.computedMeta=Rj(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=Rj(s.meta)),this},SCROLL_PREVENT(e){let n={doc:e.doc,d:e.d,meta(){return e.computedMeta}},s=[C3(),S3(),E3()];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)}});Aa.subscribe(()=>{let e=Aa.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)&&Aa.dispatch(s.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",s),s.count===0&&Aa.dispatch("TEARDOWN",s)}});function $3(e,n,s=()=>({containers:[]})){let r=k3(Aa),o=n?r.get(n):void 0,i=o?o.count>0:!1;return en(()=>{if(!(!n||!e))return Aa.dispatch("PUSH",n,s),()=>Aa.dispatch("POP",n,s)},[e,n]),i}function z1(e,n,s=()=>[document.body]){let r=rd(e,"scroll-lock");$3(r,n,o=>{var i;return{containers:[...(i=o.containers)!=null?i:[],s]}})}function Aj(e){return[e.screenX,e.screenY]}function _3(){let e=p.useRef([-1,-1]);return{wasMoved(n){let s=Aj(n);return e.current[0]===s[0]&&e.current[1]===s[1]?!1:(e.current=s,!0)},update(n){e.current=Aj(n)}}}function T3(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 R3={},Oj,Mj;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Oj=process==null?void 0:R3)==null?void 0:Oj.NODE_ENV)==="test"&&typeof((Mj=Element==null?void 0:Element.prototype)==null?void 0:Mj.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 A3=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(A3||{});function D1(e){let n={};for(let s in e)e[s]===!0&&(n[`data-${s}`]="");return n}function F1(e,n,s,r){let[o,i]=p.useState(s),{hasFlag:c,addFlag:d,removeFlag:u}=T3(e&&o?3:0),f=p.useRef(!1),g=p.useRef(!1),b=Zo();return en(()=>{var x;if(e){if(s&&i(!0),!n){s&&d(3);return}return(x=r==null?void 0:r.start)==null||x.call(r,s),O3(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&&L3(n)||(f.current=!1,u(7),s||i(!1),(h=r==null?void 0:r.end)==null||h.call(r,s))}})}},[e,s,n,b]),e?[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 O3(e,{prepare:n,run:s,done:r,inFlight:o}){let i=$s();return P3(e,{prepare:n,inFlight:o}),i.nextFrame(()=>{s(),i.requestAnimationFrame(()=>{i.add(M3(e,r))})}),i.dispose}function M3(e,n){var s,r;let o=$s();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 P3(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 L3(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 av(e,n){let s=p.useRef([]),r=ut(e);p.useEffect(()=>{let o=[...s.current];for(let[i,c]of n.entries())if(s.current[i]!==c){let d=r(n,o);return s.current=n,d}},[r,...n])}function km(){return typeof window<"u"}function bl(e){return U1(e)?(e.nodeName||"").toLowerCase():"#document"}function ms(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function ao(e){var n;return(n=(U1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function U1(e){return km()?e instanceof Node||e instanceof ms(e).Node:!1}function fs(e){return km()?e instanceof Element||e instanceof ms(e).Element:!1}function ta(e){return km()?e instanceof HTMLElement||e instanceof ms(e).HTMLElement:!1}function Pj(e){return!km()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ms(e).ShadowRoot}function Nm(e){const{overflow:n,overflowX:s,overflowY:r,display:o}=_r(e);return/auto|scroll|overlay|hidden|clip/.test(n+r+s)&&o!=="inline"&&o!=="contents"}function I3(e){return/^(table|td|th)$/.test(bl(e))}function Sm(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const z3=/transform|translate|scale|rotate|perspective|filter/,D3=/paint|layout|strict|content/,ka=e=>!!e&&e!=="none";let eg;function iv(e){const n=fs(e)?_r(e):e;return ka(n.transform)||ka(n.translate)||ka(n.scale)||ka(n.rotate)||ka(n.perspective)||!lv()&&(ka(n.backdropFilter)||ka(n.filter))||z3.test(n.willChange||"")||D3.test(n.contain||"")}function F3(e){let n=Da(e);for(;ta(n)&&!Fc(n);){if(iv(n))return n;if(Sm(n))return null;n=Da(n)}return null}function lv(){return eg==null&&(eg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),eg}function Fc(e){return/^(html|body|#document)$/.test(bl(e))}function _r(e){return ms(e).getComputedStyle(e)}function Cm(e){return fs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Da(e){if(bl(e)==="html")return e;const n=e.assignedSlot||e.parentNode||Pj(e)&&e.host||ao(e);return Pj(n)?n.host:n}function W1(e){const n=Da(e);return Fc(n)?(e.ownerDocument||e).body:ta(n)&&Nm(n)?n:W1(n)}function Uc(e,n,s){var r;n===void 0&&(n=[]),s===void 0&&(s=!0);const o=W1(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),c=ms(o);if(i){const d=Bg(c);return n.concat(c,c.visualViewport||[],Nm(o)?o:[],d&&s?Uc(d):[])}else return n.concat(o,Uc(o,[],s))}function Bg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function U3(){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 Fa=Math.min,Hs=Math.max,Wc=Math.round,Hu=Math.floor,eo=e=>({x:e,y:e}),W3={left:"right",right:"left",bottom:"top",top:"bottom"};function H3(e,n,s){return Hs(e,Fa(n,s))}function wl(e,n){return typeof e=="function"?e(n):e}function Ua(e){return e.split("-")[0]}function od(e){return e.split("-")[1]}function H1(e){return e==="x"?"y":"x"}function B1(e){return e==="y"?"height":"width"}function Qr(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function G1(e){return H1(Qr(e))}function B3(e,n,s){s===void 0&&(s=!1);const r=od(e),o=G1(e),i=B1(o);let c=o==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[i]>n.floating[i]&&(c=Rf(c)),[c,Rf(c)]}function G3(e){const n=Rf(e);return[Gg(e),n,Gg(n)]}function Gg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Lj=["left","right"],Ij=["right","left"],q3=["top","bottom"],K3=["bottom","top"];function V3(e,n,s){switch(e){case"top":case"bottom":return s?n?Ij:Lj:n?Lj:Ij;case"left":case"right":return n?q3:K3;default:return[]}}function Y3(e,n,s,r){const o=od(e);let i=V3(Ua(e),s==="start",r);return o&&(i=i.map(c=>c+"-"+o),n&&(i=i.concat(i.map(Gg)))),i}function Rf(e){const n=Ua(e);return W3[n]+e.slice(n.length)}function Q3(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 J3(e){return typeof e!="number"?Q3(e):{top:e,right:e,bottom:e,left:e}}function Af(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 zj(e,n,s){let{reference:r,floating:o}=e;const i=Qr(n),c=G1(n),d=B1(c),u=Ua(n),f=i==="y",g=r.x+r.width/2-o.width/2,b=r.y+r.height/2-o.height/2,x=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:b};break;case"left":h={x:r.x-o.width,y:b};break;default:h={x:r.x,y:r.y}}const v=od(n);return v&&(h[c]+=x*(v==="end"?1:-1)*(s&&f?-1:1)),h}async function q1(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:b="floating",altBoundary:x=!1,padding:h=0}=wl(n,e),v=J3(h),j=d[x?b==="floating"?"reference":"floating":b],k=Af(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=b==="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},$=Af(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:E,offsetParent:S,strategy:u}):E);return{top:(k.top-$.top+v.top)/N.y,bottom:($.bottom-k.bottom+v.bottom)/N.y,left:(k.left-$.left+v.left)/N.x,right:($.right-k.right+v.right)/N.x}}const X3=50,Z3=async(e,n,s)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:c}=s,d=c.detectOverflow?c:{...c,detectOverflow:q1},u=await(c.isRTL==null?void 0:c.isRTL(n));let f=await c.getElementRects({reference:e,floating:n,strategy:o}),{x:g,y:b}=zj(f,r,u),x=r,h=0;const v={};for(let y=0;y<i.length;y++){const j=i[y];if(!j)continue;const{name:k,fn:E}=j,{x:S,y:N,data:$,reset:_}=await E({x:g,y:b,initialPlacement:r,placement:x,strategy:o,middlewareData:v,rects:f,platform:d,elements:{reference:e,floating:n}});g=S??g,b=N??b,v[k]={...v[k],...$},_&&h<X3&&(h++,typeof _=="object"&&(_.placement&&(x=_.placement),_.rects&&(f=_.rects===!0?await c.getElementRects({reference:e,floating:n,strategy:o}):_.rects),{x:g,y:b}=zj(f,x,u)),y=-1)}return{x:g,y:b,placement:x,strategy:o,middlewareData:v}},e4=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:b=!0,fallbackPlacements:x,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:y=!0,...j}=wl(e,n);if((s=i.arrow)!=null&&s.alignmentOffset)return{};const k=Ua(o),E=Qr(d),S=Ua(d)===d,N=await(u.isRTL==null?void 0:u.isRTL(f.floating)),$=x||(S||!y?[Rf(d)]:G3(d)),_=v!=="none";!x&&_&&$.push(...Y3(d,y,v,N));const M=[d,...$],O=await u.detectOverflow(n,j),L=[];let A=((r=i.flip)==null?void 0:r.overflows)||[];if(g&&L.push(O[k]),b){const W=B3(o,c,N);L.push(O[W[0]],O[W[1]])}if(A=[...A,{placement:o,overflows:L}],!L.every(W=>W<=0)){var R,P;const W=(((R=i.flip)==null?void 0:R.index)||0)+1,K=M[W];if(K&&(!(b==="alignment"?E!==Qr(K):!1)||A.every(F=>Qr(F.placement)===E?F.overflows[0]>0:!0)))return{data:{index:W,overflows:A},reset:{placement:K}};let H=(P=A.filter(q=>q.overflows[0]<=0).sort((q,F)=>q.overflows[1]-F.overflows[1])[0])==null?void 0:P.placement;if(!H)switch(h){case"bestFit":{var D;const q=(D=A.filter(F=>{if(_){const G=Qr(F.placement);return G===E||G==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(G=>G>0).reduce((G,U)=>G+U,0)]).sort((F,G)=>F[1]-G[1])[0])==null?void 0:D[0];q&&(H=q);break}case"initialPlacement":H=d;break}if(o!==H)return{reset:{placement:H}}}return{}}}},t4=new Set(["left","top"]);async function n4(e,n){const{placement:s,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),c=Ua(s),d=od(s),u=Qr(s)==="y",f=t4.has(c)?-1:1,g=i&&u?-1:1,b=wl(n,e);let{mainAxis:x,crossAxis:h,alignmentAxis:v}=typeof b=="number"?{mainAxis:b,crossAxis:0,alignmentAxis:null}:{mainAxis:b.mainAxis||0,crossAxis:b.crossAxis||0,alignmentAxis:b.alignmentAxis};return d&&typeof v=="number"&&(h=d==="end"?v*-1:v),u?{x:h*g,y:x*f}:{x:x*f,y:h*g}}const s4=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 n4(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}}}}},r4=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}=wl(e,n),g={x:s,y:r},b=await i.detectOverflow(n,f),x=Qr(o),h=H1(x);let v=g[h],y=g[x];const j=(E,S)=>H3(S+b[E==="y"?"top":"left"],S,S-b[E==="y"?"bottom":"right"]);c&&(v=j(h,v)),d&&(y=j(x,y));const k=u.fn({...n,[h]:v,[x]:y});return{...k,data:{x:k.x-s,y:k.y-r,enabled:{[h]:c,[x]:d}}}}}},o4=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}=wl(e,n),u=await o.detectOverflow(n,d),f=Ua(s),g=od(s),b=Qr(s)==="y",{width:x,height:h}=r.floating;let v,y;f==="top"||f==="bottom"?(v=f,y=g===(await(o.isRTL==null?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(y=f,v=g==="end"?"top":"bottom");const j=h-u.top-u.bottom,k=x-u.left-u.right,E=Fa(h-u[v],j),S=Fa(x-u[y],k),N=n.middlewareData.shift,$=!N;let _=E,M=S;N!=null&&N.enabled.x&&(M=k),N!=null&&N.enabled.y&&(_=j),$&&!g&&(b?M=x-2*Hs(u.left,u.right):_=h-2*Hs(u.top,u.bottom)),await c({...n,availableWidth:M,availableHeight:_});const O=await o.getDimensions(i.floating);return x!==O.width||h!==O.height?{reset:{rects:!0}}:{}}}};function K1(e){const n=_r(e);let s=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const o=ta(e),i=o?e.offsetWidth:s,c=o?e.offsetHeight:r,d=Wc(s)!==i||Wc(r)!==c;return d&&(s=i,r=c),{width:s,height:r,$:d}}function cv(e){return fs(e)?e:e.contextElement}function Vi(e){const n=cv(e);if(!ta(n))return eo(1);const s=n.getBoundingClientRect(),{width:r,height:o,$:i}=K1(n);let c=(i?Wc(s.width):s.width)/r,d=(i?Wc(s.height):s.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const a4=eo(0);function V1(e){const n=ms(e);return!lv()||!n.visualViewport?a4:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function i4(e,n,s){return n===void 0&&(n=!1),!!s&&n&&s===ms(e)}function Wa(e,n,s,r){n===void 0&&(n=!1),s===void 0&&(s=!1);const o=e.getBoundingClientRect(),i=cv(e);let c=eo(1);n&&(r?fs(r)&&(c=Vi(r)):c=Vi(e));const d=i4(i,s,r)?V1(i):eo(0);let u=(o.left+d.x)/c.x,f=(o.top+d.y)/c.y,g=o.width/c.x,b=o.height/c.y;if(i&&r){const x=ms(i),h=fs(r)?ms(r):r;let v=x,y=Bg(v);for(;y&&h!==v;){const j=Vi(y),k=y.getBoundingClientRect(),E=_r(y),S=k.left+(y.clientLeft+parseFloat(E.paddingLeft))*j.x,N=k.top+(y.clientTop+parseFloat(E.paddingTop))*j.y;u*=j.x,f*=j.y,g*=j.x,b*=j.y,u+=S,f+=N,v=ms(y),y=Bg(v)}}return Af({width:g,height:b,x:u,y:f})}function Em(e,n){const s=Cm(e).scrollLeft;return n?n.left+s:Wa(ao(e)).left+s}function Y1(e,n){const s=e.getBoundingClientRect(),r=s.left+n.scrollLeft-Em(e,s),o=s.top+n.scrollTop;return{x:r,y:o}}function l4(e){let{elements:n,rect:s,offsetParent:r,strategy:o}=e;const i=o==="fixed",c=ao(r),d=n?Sm(n.floating):!1;if(r===c||d&&i)return s;let u={scrollLeft:0,scrollTop:0},f=eo(1);const g=eo(0),b=ta(r);if((b||!i)&&((bl(r)!=="body"||Nm(c))&&(u=Cm(r)),b)){const h=Wa(r);f=Vi(r),g.x=h.x+r.clientLeft,g.y=h.y+r.clientTop}const x=c&&!b&&!i?Y1(c,u):eo(0);return{width:s.width*f.x,height:s.height*f.y,x:s.x*f.x-u.scrollLeft*f.x+g.x+x.x,y:s.y*f.y-u.scrollTop*f.y+g.y+x.y}}function c4(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function d4(e){const n=Cm(e),s=e.ownerDocument.body,r=Hs(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),o=Hs(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+Em(e);const c=-n.scrollTop;return _r(s).direction==="rtl"&&(i+=Hs(e.clientWidth,s.clientWidth)-r),{width:r,height:o,x:i,y:c}}const u4=25;function f4(e,n,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",o=ms(e),i=ao(e),c=o.visualViewport;let d=i.clientWidth,u=i.clientHeight,f=0,g=0;if(c){const x=!lv()||n==="fixed";r?x||(f=-c.offsetLeft,g=-c.offsetTop):(d=c.width,u=c.height,x&&(f=c.offsetLeft,g=c.offsetTop))}if(Em(i)<=0){const x=i.ownerDocument,h=x.body,v=getComputedStyle(h),y=x.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,j=Math.abs(i.clientWidth-h.clientWidth-y),k=getComputedStyle(i).scrollbarGutter==="stable both-edges"?j/2:j;k<=u4&&(d-=k)}return{width:d,height:u,x:f,y:g}}function m4(e,n){const s=Wa(e,!0,n==="fixed"),r=s.top+e.clientTop,o=s.left+e.clientLeft,i=Vi(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 Dj(e,n,s){let r;if(n==="viewport"||n==="layoutViewport")r=f4(e,s,n);else if(n==="document")r=d4(ao(e));else if(fs(n))r=m4(n,s);else{const o=V1(e);r={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return Af(r)}function h4(e,n){const s=n.get(e);if(s)return s;let r=Uc(e,[],!1).filter(d=>fs(d)&&bl(d)!=="body"),o=null;const i=_r(e).position==="fixed";let c=i?Da(e):e;for(;fs(c)&&!Fc(c);){const d=_r(c),u=iv(c),f=o?o.position:i?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&d.position==="static")?r=r.filter(b=>b!==c):o=d,c=Da(c)}return n.set(e,r),r}function p4(e){let{element:n,boundary:s,rootBoundary:r,strategy:o}=e;const c=[...s==="clippingAncestors"?Sm(n)?[]:h4(n,this._c):[].concat(s),r],d=Dj(n,c[0],o);let u=d.top,f=d.right,g=d.bottom,b=d.left;for(let x=1;x<c.length;x++){const h=Dj(n,c[x],o);u=Hs(h.top,u),f=Fa(h.right,f),g=Fa(h.bottom,g),b=Hs(h.left,b)}return{width:f-b,height:g-u,x:b,y:u}}function g4(e){const{width:n,height:s}=K1(e);return{width:n,height:s}}function x4(e,n,s){const r=ta(n),o=ao(n),i=s==="fixed",c=Wa(e,!0,i,n);let d={scrollLeft:0,scrollTop:0};const u=eo(0);if((r||!i)&&((bl(n)!=="body"||Nm(o))&&(d=Cm(n)),r)){const x=Wa(n,!0,i,n);u.x=x.x+n.clientLeft,u.y=x.y+n.clientTop}!r&&o&&(u.x=Em(o));const f=o&&!r&&!i?Y1(o,d):eo(0),g=c.left+d.scrollLeft-u.x-f.x,b=c.top+d.scrollTop-u.y-f.y;return{x:g,y:b,width:c.width,height:c.height}}function tg(e){return _r(e).position==="static"}function Fj(e,n){if(!ta(e)||_r(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return ao(e)===s&&(s=s.ownerDocument.body),s}function Q1(e,n){const s=ms(e);if(Sm(e))return s;if(!ta(e)){let o=Da(e);for(;o&&!Fc(o);){if(fs(o)&&!tg(o))return o;o=Da(o)}return s}let r=Fj(e,n);for(;r&&I3(r)&&tg(r);)r=Fj(r,n);return r&&Fc(r)&&tg(r)&&!iv(r)?s:r||F3(e)||s}const v4=async function(e){const n=this.getOffsetParent||Q1,s=this.getDimensions,r=await s(e.floating);return{reference:x4(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function y4(e){return _r(e).direction==="rtl"}const b4={convertOffsetParentRelativeRectToViewportRelativeRect:l4,getDocumentElement:ao,getClippingRect:p4,getOffsetParent:Q1,getElementRects:v4,getClientRects:c4,getDimensions:g4,getScale:Vi,isElement:fs,isRTL:y4};function J1(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function w4(e,n,s){let r=null,o;const i=ao(e);function c(){var g;clearTimeout(o),(g=r)==null||g.disconnect(),r=null}function d(g,b){g===void 0&&(g=!1),b===void 0&&(b=1),c();const x=e.getBoundingClientRect(),{left:h,top:v,width:y,height:j}=x;if(g||n(),!y||!j)return;const k=Hu(v),E=Hu(i.clientWidth-(h+y)),S=Hu(i.clientHeight-(v+j)),N=Hu(h),_={rootMargin:-k+"px "+-E+"px "+-S+"px "+-N+"px",threshold:Hs(0,Fa(1,b))||1};let M=!0;function O(L){const A=L[0].intersectionRatio;if(!J1(x,e.getBoundingClientRect()))return d();if(A!==b){if(!M)return d();A?d(!1,A):o=setTimeout(()=>{d(!1,1e-7)},1e3)}M=!1}try{r=new IntersectionObserver(O,{..._,root:i.ownerDocument})}catch{r=new IntersectionObserver(O,_)}r.observe(e)}const u=ms(e),f=()=>d(s);return u.addEventListener("resize",f),d(!0),()=>{u.removeEventListener("resize",f),c()}}function j4(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=cv(e),g=o||i?[...f?Uc(f):[],...n?Uc(n):[]]:[];g.forEach(k=>{o&&k.addEventListener("scroll",s),i&&k.addEventListener("resize",s)});const b=f&&d?w4(f,s,i):null;let x=-1,h=null;c&&(h=new ResizeObserver(k=>{let[E]=k;E&&E.target===f&&h&&n&&(h.unobserve(n),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var S;(S=h)==null||S.observe(n)})),s()}),f&&!u&&h.observe(f),n&&h.observe(n));let v,y=u?Wa(e):null;u&&j();function j(){const k=Wa(e);y&&!J1(y,k)&&s(),y=k,v=requestAnimationFrame(j)}return s(),()=>{var k;g.forEach(E=>{o&&E.removeEventListener("scroll",s),i&&E.removeEventListener("resize",s)}),b==null||b(),(k=h)==null||k.disconnect(),h=null,u&&cancelAnimationFrame(v)}}const ng=q1,k4=s4,N4=r4,S4=e4,C4=o4,E4=(e,n,s)=>{const r=new Map,o=s??{},i={...b4,...o.platform,_c:r};return Z3(e,n,{...o,platform:i})};var $4=typeof document<"u",_4=function(){},hf=$4?p.useLayoutEffect:_4;function Of(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(!Of(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)&&!Of(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}function X1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Uj(e,n){const s=X1(e);return Math.round(n*s)/s}function sg(e){const n=p.useRef(e);return hf(()=>{n.current=e}),n}function T4(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,b]=p.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[x,h]=p.useState(r);Of(x,r)||h(r);const[v,y]=p.useState(null),[j,k]=p.useState(null),E=p.useCallback(F=>{F!==_.current&&(_.current=F,y(F))},[]),S=p.useCallback(F=>{F!==M.current&&(M.current=F,k(F))},[]),N=i||v,$=c||j,_=p.useRef(null),M=p.useRef(null),O=p.useRef(g),L=u!=null,A=sg(u),R=sg(o),P=sg(f),D=p.useCallback(()=>{if(!_.current||!M.current)return;const F={placement:n,strategy:s,middleware:x};R.current&&(F.platform=R.current),E4(_.current,M.current,F).then(G=>{const U={...G,isPositioned:P.current!==!1};W.current&&!Of(O.current,U)&&(O.current=U,Ns.flushSync(()=>{b(U)}))})},[x,n,s,R,P]);hf(()=>{f===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,b(F=>({...F,isPositioned:!1})))},[f]);const W=p.useRef(!1);hf(()=>(W.current=!0,()=>{W.current=!1}),[]),hf(()=>{if(N&&(_.current=N),$&&(M.current=$),N&&$){if(A.current)return A.current(N,$,D);D()}},[N,$,D,A,L]);const K=p.useMemo(()=>({reference:_,floating:M,setReference:E,setFloating:S}),[E,S]),H=p.useMemo(()=>({reference:N,floating:$}),[N,$]),q=p.useMemo(()=>{const F={position:s,left:0,top:0};if(!H.floating)return F;const G=Uj(H.floating,g.x),U=Uj(H.floating,g.y);return d?{...F,transform:"translate("+G+"px, "+U+"px)",...X1(H.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:G,top:U}},[s,d,H.floating,g.x,g.y]);return p.useMemo(()=>({...g,update:D,refs:K,elements:H,floatingStyles:q}),[g,D,K,H,q])}const Z1=(e,n)=>{const s=k4(e);return{name:s.name,fn:s.fn,options:[e,n]}},R4=(e,n)=>{const s=N4(e);return{name:s.name,fn:s.fn,options:[e,n]}},A4=(e,n)=>{const s=S4(e);return{name:s.name,fn:s.fn,options:[e,n]}},O4=(e,n)=>{const s=C4(e);return{name:s.name,fn:s.fn,options:[e,n]}},eS={...Mg},M4=eS.useInsertionEffect,P4=M4||(e=>e());function tS(e){const n=p.useRef(()=>{});return P4(()=>{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 qg=typeof document<"u"?p.useLayoutEffect:p.useEffect;let Wj=!1,L4=0;const Hj=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+L4++;function I4(){const[e,n]=p.useState(()=>Wj?Hj():void 0);return qg(()=>{e==null&&n(Hj())},[]),p.useEffect(()=>{Wj=!0},[]),e}const z4=eS.useId,D4=z4||I4;function F4(){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 U4=p.createContext(null),W4=p.createContext(null),H4=()=>{var e;return((e=p.useContext(U4))==null?void 0:e.id)||null},B4=()=>p.useContext(W4),G4="data-floating-ui-focusable";function q4(e){const{open:n=!1,onOpenChange:s,elements:r}=e,o=D4(),i=p.useRef({}),[c]=p.useState(()=>F4()),d=H4()!=null,[u,f]=p.useState(r.reference),g=tS((h,v,y)=>{i.current.openEvent=h?v:void 0,c.emit("openchange",{open:h,event:v,reason:y,nested:d}),s==null||s(h,v,y)}),b=p.useMemo(()=>({setPositionReference:f}),[]),x=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:x,events:c,floatingId:o,refs:b}),[n,g,x,c,o,b])}function K4(e){e===void 0&&(e={});const{nodeId:n}=e,s=q4({...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,b=p.useRef(null),x=B4();qg(()=>{g&&(b.current=g)},[g]);const h=T4({...e,elements:{...o,...d&&{reference:d}}}),v=p.useCallback(S=>{const N=fs(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),contextElement:S}:S;u(N),h.refs.setReference(N)},[h.refs]),y=p.useCallback(S=>{(fs(S)||S===null)&&(b.current=S,c(S)),(fs(h.refs.reference.current)||h.refs.reference.current===null||S!==null&&!fs(S))&&h.refs.setReference(S)},[h.refs]),j=p.useMemo(()=>({...h.refs,setReference:y,setPositionReference:v,domReference:b}),[h.refs,y,v]),k=p.useMemo(()=>({...h.elements,domReference:g}),[h.elements,g]),E=p.useMemo(()=>({...h,...r,refs:j,elements:k,nodeId:n}),[h,j,k,n,r]);return qg(()=>{r.dataRef.current.floatingContext=E;const S=x==null?void 0:x.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 Bj="active",Gj="selected";function rg(e,n,s){const r=new Map,o=s==="item";let i=e;if(o&&e){const{[Bj]:c,[Gj]:d,...u}=e;i=u}return{...s==="floating"&&{tabIndex:-1,[G4]:""},...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&&[Bj,Gj].includes(f)))if(f.indexOf("on")===0){if(r.has(f)||r.set(f,[]),typeof g=="function"){var b;(b=r.get(f))==null||b.push(g),c[f]=function(){for(var x,h=arguments.length,v=new Array(h),y=0;y<h;y++)v[y]=arguments[y];return(x=r.get(f))==null?void 0:x.map(j=>j(...v)).find(j=>j!==void 0)}}}else c[f]=g}),c),{})}}function V4(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=>rg(d,e,"reference"),n),i=p.useCallback(d=>rg(d,e,"floating"),s),c=p.useCallback(d=>rg(d,e,"item"),r);return p.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:c}),[o,i,c])}function qj(e,n){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:n}}}}const Y4=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}=wl(e,n),{rects:b,elements:{floating:x}}=n,h=s.current[c],v=(f==null?void 0:f.current)||x,y=x.clientTop||v.clientTop,j=x.clientTop!==0,k=v.clientTop!==0,E=x===v;if(!h)return{};const S={...n,...await Z1(-h.offsetTop-x.clientTop-b.reference.height/2-h.offsetHeight/2-i).fn(n)},N=await ng(qj(S,v.scrollHeight+y+x.clientTop),g),$=await ng(S,{...g,elementContext:"reference"}),_=Hs(0,N.top),M=S.y+_,A=(v.scrollHeight>v.clientHeight?R=>R:Wc)(Hs(0,v.scrollHeight+(j&&E||k?y*2:0)-_-Hs(0,N.bottom)));if(v.style.maxHeight=A+"px",v.scrollTop=_,o){const R=v.offsetHeight<h.offsetHeight*Fa(d,s.current.length)-1||$.top>=-u||$.bottom>=-u;Ns.flushSync(()=>o(R))}return r&&(r.current=await ng(qj({...S,y:M},v.offsetHeight+y+x.clientTop),g)),{y:M}}});function Q4(e,n){const{open:s,elements:r}=e,{enabled:o=!0,overflowRef:i,scrollRef:c,onChange:d}=n,u=tS(d),f=p.useRef(!1),g=p.useRef(null),b=p.useRef(null);p.useEffect(()=>{if(!o)return;function h(y){if(y.ctrlKey||!v||i.current==null)return;const j=y.deltaY,k=i.current.top>=-.5,E=i.current.bottom>=-.5,S=v.scrollHeight-v.clientHeight,N=j<0?-1:1,$=j<0?"max":"min";v.scrollHeight<=v.clientHeight||(!k&&j>0||!E&&j<0?(y.preventDefault(),Ns.flushSync(()=>{u(_=>_+Math[$](j,S*N))})):/firefox/i.test(U3())&&(v.scrollTop+=j))}const v=(c==null?void 0:c.current)||r.floating;if(s&&v)return v.addEventListener("wheel",h),requestAnimationFrame(()=>{g.current=v.scrollTop,i.current!=null&&(b.current={...i.current})}),()=>{g.current=null,b.current=null,v.removeEventListener("wheel",h)}},[o,s,r.floating,i,c,u]);const x=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 v=h.scrollTop-g.current;(i.current.bottom<-.5&&v<-1||i.current.top<-.5&&v>1)&&Ns.flushSync(()=>u(y=>y+v))}requestAnimationFrame(()=>{g.current=h.scrollTop})}}}),[r.floating,u,i,c]);return p.useMemo(()=>o?{floating:x}:{},[o,x])}let jl=p.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});jl.displayName="FloatingContext";let dv=p.createContext(null);dv.displayName="PlacementContext";function J4(e){return p.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function X4(){return p.useContext(jl).setReference}function Z4(){return p.useContext(jl).getReferenceProps}function eO(){let{getFloatingProps:e,slot:n}=p.useContext(jl);return p.useCallback((...s)=>Object.assign({},e(...s),{"data-anchor":n.anchor}),[e,n])}function tO(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let n=p.useContext(dv),s=p.useMemo(()=>e,[JSON.stringify(e,(o,i)=>{var c;return(c=i==null?void 0:i.outerHTML)!=null?c:i})]);en(()=>{n==null||n(s??null)},[n,s]);let r=p.useContext(jl);return p.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let Kj=4;function nO({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);sO(d);let f=n&&s!==null&&d!==null,{to:g="bottom",gap:b=0,offset:x=0,padding:h=0,inner:v}=rO(s,d),[y,j="center"]=g.split(" ");en(()=>{f&&i(0)},[f]);let{refs:k,floatingStyles:E,context:S}=K4({open:f,placement:y==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${y}`:`${y}-${j}`,strategy:"absolute",transform:!1,middleware:[Z1({mainAxis:y==="selection"?0:b,crossAxis:x}),R4({padding:h}),y!=="selection"&&A4({padding:h}),y==="selection"&&v?Y4({...v,padding:h,overflowRef:c,offset:o,minItemsVisible:Kj,referenceOverflowThreshold:h,onFallbackChange(R){var P,D;if(!R)return;let W=S.elements.floating;if(!W)return;let K=parseFloat(getComputedStyle(W).scrollPaddingBottom)||0,H=Math.min(Kj,W.childElementCount),q=0,F=0;for(let G of(D=(P=S.elements.floating)==null?void 0:P.childNodes)!=null?D:[])if(Ss(G)){let U=G.offsetTop,z=U+G.clientHeight+K,Y=W.scrollTop,J=Y+W.clientHeight;if(U>=Y&&z<=J)H--;else{F=Math.max(0,Math.min(z,J)-Math.max(U,Y)),q=G.clientHeight;break}}H>=1&&i(G=>{let U=q*H-F+K;return G>=U?G:U})}}):null,O4({padding:h,apply({availableWidth:R,availableHeight:P,elements:D}){Object.assign(D.floating.style,{overflow:"auto",maxWidth:`${R}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${P}px)`})}})].filter(Boolean),whileElementsMounted:j4}),[N=y,$=j]=S.placement.split("-");y==="selection"&&(N="selection");let _=p.useMemo(()=>({anchor:[N,$].filter(Boolean).join(" ")}),[N,$]),M=Q4(S,{overflowRef:c,onChange:i}),{getReferenceProps:O,getFloatingProps:L}=V4([M]),A=ut(R=>{u(R),k.setFloating(R)});return p.createElement(dv.Provider,{value:r},p.createElement(jl.Provider,{value:{setFloating:A,setReference:k.setReference,styles:E,getReferenceProps:O,getFloatingProps:L,slot:_}},e))}function sO(e){en(()=>{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 rO(e,n){var s,r,o;let i=og((s=e==null?void 0:e.gap)!=null?s:"var(--anchor-gap, 0)",n),c=og((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",n),d=og((o=e==null?void 0:e.padding)!=null?o:"var(--anchor-padding, 0)",n);return{...e,gap:i,offset:c,padding:d}}function og(e,n,s=void 0){let r=Zo(),o=ut((u,f)=>{if(u==null)return[s,null];if(typeof u=="number")return[u,null];if(typeof u=="string"){if(!f)return[s,null];let g=Vj(u,f);return[g,b=>{let x=nS(u);{let h=x.map(v=>window.getComputedStyle(f).getPropertyValue(v));r.requestAnimationFrame(function v(){r.nextFrame(v);let y=!1;for(let[k,E]of x.entries()){let S=window.getComputedStyle(f).getPropertyValue(E);if(h[k]!==S){h[k]=S,y=!0;break}}if(!y)return;let j=Vj(u,f);g!==j&&(b(j),g=j)})}return r.dispose}]}return[s,null]}),i=p.useMemo(()=>o(e,n)[0],[e,n]),[c=i,d]=p.useState();return en(()=>{let[u,f]=o(e,n);if(d(u),!!f)return f(d)},[e,n]),c}function nS(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,...nS(o)]:[r]}return[]}function Vj(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 oO({children:e,freeze:n},s){let r=sS(n,e);return p.isValidElement(r)?p.cloneElement(r,{ref:s}):Ke.createElement(Ke.Fragment,null,r)}Ke.forwardRef(oO);function sS(e,n){let[s,r]=p.useState(n);return!e&&s!==n&&r(n),e?s:n}let $m=p.createContext(null);$m.displayName="OpenClosedContext";var Xn=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Xn||{});function ad(){return p.useContext($m)}function rS({value:e,children:n}){return Ke.createElement($m.Provider,{value:e},n)}function aO({children:e}){return Ke.createElement($m.Provider,{value:null},e)}function iO(e){function n(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",n))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",n),n())}let Io=[];iO(()=>{function e(n){if(!Yr(n.target)||n.target===document.body||Io[0]===n.target)return;let s=n.target;s=s.closest(Tf),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 lO(e){throw new Error("Unexpected object: "+e)}var rn=(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))(rn||{});function Bu(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:lO(e)}}function uv(e){let n=ut(e),s=p.useRef(!1);p.useEffect(()=>(s.current=!1,()=>{s.current=!0,ym(()=>{s.current&&n()})}),[n])}function cO(){let e=typeof document>"u";return"useSyncExternalStore"in Mg?(n=>n.useSyncExternalStore)(Mg)(()=>()=>{},()=>!1,()=>!e):!1}function id(){let e=cO(),[n,s]=p.useState(Cr.isHandoffComplete);return n&&Cr.isHandoffComplete===!1&&s(!1),p.useEffect(()=>{n!==!0&&s(!0)},[n]),p.useEffect(()=>Cr.handoff(),[]),e?!1:n}let oS=p.createContext(!1);function dO(){return p.useContext(oS)}function Yj(e){return Ke.createElement(oS.Provider,{value:e.force},e.children)}function uO(e){let n=dO(),s=p.useContext(iS),[r,o]=p.useState(()=>{var i;if(!n&&s!==null)return(i=s.current)!=null?i:null;if(Cr.isServer)return null;let c=e==null?void 0:e.getElementById("headlessui-portal-root");if(c)return c;if(e===null)return null;let 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 aS=p.Fragment,fO=gn(function(e,n){let{ownerDocument:s=null,...r}=e,o=p.useRef(null),i=Fn(IA(h=>{o.current=h}),n),c=Dc(o.current),d=s??c,u=uO(d),f=p.useContext(Kg),g=Zo(),b=id(),x=Cn();return uv(()=>{var h;u&&u.childNodes.length<=0&&((h=u.parentElement)==null||h.removeChild(u))}),!u||!b?null:Ns.createPortal(Ke.createElement("div",{"data-headlessui-portal":"",ref:h=>{g.dispose(),f&&h&&g.add(f.register(h))}},x({ourProps:{ref:i},theirProps:r,slot:{},defaultTag:aS,name:"Portal"})),u)});function mO(e,n){let s=Fn(n),{enabled:r=!0,ownerDocument:o,...i}=e,c=Cn();return r?Ke.createElement(fO,{...i,ownerDocument:o,ref:s}):c({ourProps:{ref:s},theirProps:i,slot:{},defaultTag:aS,name:"Portal"})}let hO=p.Fragment,iS=p.createContext(null);function pO(e,n){let{target:s,...r}=e,o={ref:Fn(n)},i=Cn();return Ke.createElement(iS.Provider,{value:s},i({ourProps:o,theirProps:r,defaultTag:hO,name:"Popover.Group"}))}let Kg=p.createContext(null);function gO(){let e=p.useContext(Kg),n=p.useRef([]),s=ut(i=>(n.current.push(i),e&&e.register(i),()=>r(i))),r=ut(i=>{let c=n.current.indexOf(i);c!==-1&&n.current.splice(c,1),e&&e.unregister(i)}),o=p.useMemo(()=>({register:s,unregister:r,portals:n}),[s,r,n]);return[n,p.useMemo(()=>function({children:i}){return Ke.createElement(Kg.Provider,{value:o},i)},[o])]}let xO=gn(mO),lS=gn(pO),cS=Object.assign(xO,{Group:lS});const pf={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function dS(e){let n=e.getBoundingClientRect();return`${n.x},${n.y}`}function vO(e,n,s){let r=$s();if(n.kind==="Tracked"){let o=function(){i!==dS(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 yO(e,n=typeof document<"u"?document.defaultView:null,s){let r=rd(e,"escape");I1(n,"keydown",o=>{r&&(o.defaultPrevented||o.key===yn.Escape&&s(o))})}function bO(){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 en(()=>{if(!n)return;function o(i){r(i.matches)}return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[n]),s}function wO({defaultContainers:e=[],portals:n,mainTreeNode:s}={}){let r=ut(()=>{var o,i;let c=yl(s),d=[];for(let u of e)u!==null&&(Xr(u)?d.push(u):"current"in u&&Xr(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&&Xr(u)&&u.id!=="headlessui-portal-root"&&(s&&(u.contains(s)||u.contains((i=s==null?void 0:s.getRootNode())==null?void 0:i.host))||d.some(f=>u.contains(f))||d.push(u));return d});return{resolveContainers:r,contains:ut(o=>r().some(i=>i.contains(o)))}}let uS=p.createContext(null);function Qj({children:e,node:n}){let[s,r]=p.useState(null),o=fS(n??s);return Ke.createElement(uS.Provider,{value:o},e,o===null&&Ke.createElement(zc,{features:al.Hidden,ref:i=>{var c,d;if(i){for(let u of(d=(c=yl(i))==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?d:[])if(u!==document.body&&u!==document.head&&Xr(u)&&u!=null&&u.contains(i)){r(u);break}}}}))}function fS(e=null){var n;return(n=p.useContext(uS))!=null?n:e}function fv(){let e=p.useRef(!1);return en(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Sc=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(Sc||{});function jO(){let e=p.useRef(0);return P1(!0,"keydown",n=>{n.key==="Tab"&&(e.current=n.shiftKey?1:0)},!0),e}function mS(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let n=new Set;for(let s of e.current)Xr(s.current)&&n.add(s.current);return n}let kO="div";var Ca=(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))(Ca||{});function NO(e,n){let s=p.useRef(null),r=Fn(s,n),{initialFocus:o,initialFocusFallback:i,containers:c,features:d=15,...u}=e;id()||(d=0);let f=Dc(s.current);$O(d,{ownerDocument:f});let g=_O(d,{ownerDocument:f,container:s,initialFocus:o,initialFocusFallback:i});TO(d,{ownerDocument:f,container:s,containers:c,previousActiveElement:g});let b=jO(),x=ut(E=>{if(!Ss(s.current))return;let S=s.current;(N=>N())(()=>{ts(b.current,{[Sc.Forwards]:()=>{Ki(S,lr.First,{skipElements:[E.relatedTarget,i]})},[Sc.Backwards]:()=>{Ki(S,lr.Last,{skipElements:[E.relatedTarget,i]})}})})}),h=rd(!!(d&2),"focus-trap#tab-lock"),v=Zo(),y=p.useRef(!1),j={ref:r,onKeyDown(E){E.key=="Tab"&&(y.current=!0,v.requestAnimationFrame(()=>{y.current=!1}))},onBlur(E){if(!(d&4))return;let S=mS(c);Ss(s.current)&&S.add(s.current);let N=E.relatedTarget;Yr(N)&&N.dataset.headlessuiFocusGuard!=="true"&&(hS(S,N)||(y.current?Ki(s.current,ts(b.current,{[Sc.Forwards]:()=>lr.Next,[Sc.Backwards]:()=>lr.Previous})|lr.WrapAround,{relativeTo:E.target}):Yr(E.target)&&Zr(E.target)))}},k=Cn();return Ke.createElement(Ke.Fragment,null,h&&Ke.createElement(zc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:x,features:al.Focusable}),k({ourProps:j,theirProps:u,defaultTag:kO,name:"FocusTrap"}),h&&Ke.createElement(zc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:x,features:al.Focusable}))}let SO=gn(NO),CO=Object.assign(SO,{features:Ca});function EO(e=!0){let n=p.useRef(Io.slice());return av(([s],[r])=>{r===!0&&s===!1&&ym(()=>{n.current.splice(0)}),r===!1&&s===!0&&(n.current=Io.slice())},[e,Io,n]),ut(()=>{var s;return(s=n.current.find(r=>r!=null&&r.isConnected))!=null?s:null})}function $O(e,{ownerDocument:n}){let s=!!(e&8),r=EO(s);av(()=>{s||a1(n==null?void 0:n.body)&&Zr(r())},[s]),uv(()=>{s&&Zr(r())})}function _O(e,{ownerDocument:n,container:s,initialFocus:r,initialFocusFallback:o}){let i=p.useRef(null),c=rd(!!(e&1),"focus-trap#initial-focus"),d=fv();return av(()=>{if(e===0)return;if(!c){o!=null&&o.current&&Zr(o.current);return}let u=s.current;u&&ym(()=>{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)Zr(r.current);else{if(e&16){if(Ki(u,lr.First|lr.AutoFocus)!==Hg.Error)return}else if(Ki(u,lr.First)!==Hg.Error)return;if(o!=null&&o.current&&(Zr(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 TO(e,{ownerDocument:n,container:s,containers:r,previousActiveElement:o}){let i=fv(),c=!!(e&4);I1(n==null?void 0:n.defaultView,"focus",d=>{if(!c||!i.current)return;let u=mS(r);Ss(s.current)&&u.add(s.current);let f=o.current;if(!f)return;let g=d.target;Ss(g)?hS(u,g)?(o.current=g,Zr(g)):(d.preventDefault(),d.stopPropagation(),Zr(f)):Zr(o.current)},!0)}function hS(e,n){for(let s of e)if(s.contains(n))return!0;return!1}function pS(e){var n;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!_c((n=e.as)!=null?n:xS)||Ke.Children.count(e.children)===1}let _m=p.createContext(null);_m.displayName="TransitionContext";var RO=(e=>(e.Visible="visible",e.Hidden="hidden",e))(RO||{});function AO(){let e=p.useContext(_m);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function OO(){let e=p.useContext(Tm);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let Tm=p.createContext(null);Tm.displayName="NestingContext";function Rm(e){return"children"in e?Rm(e.children):e.current.filter(({el:n})=>n.current!==null).filter(({state:n})=>n==="visible").length>0}function gS(e,n){let s=ea(e),r=p.useRef([]),o=fv(),i=Zo(),c=ut((h,v=zo.Hidden)=>{let y=r.current.findIndex(({el:j})=>j===h);y!==-1&&(ts(v,{[zo.Unmount](){r.current.splice(y,1)},[zo.Hidden](){r.current[y].state="hidden"}}),i.microTask(()=>{var j;!Rm(r)&&o.current&&((j=s.current)==null||j.call(s))}))}),d=ut(h=>{let v=r.current.find(({el:y})=>y===h);return v?v.state!=="visible"&&(v.state="visible"):r.current.push({el:h,state:"visible"}),()=>c(h,zo.Unmount)}),u=p.useRef([]),f=p.useRef(Promise.resolve()),g=p.useRef({enter:[],leave:[]}),b=ut((h,v,y)=>{u.current.splice(0),n&&(n.chains.current[v]=n.chains.current[v].filter(([j])=>j!==h)),n==null||n.chains.current[v].push([h,new Promise(j=>{u.current.push(j)})]),n==null||n.chains.current[v].push([h,new Promise(j=>{Promise.all(g.current[v].map(([k,E])=>E)).then(()=>j())})]),v==="enter"?f.current=f.current.then(()=>n==null?void 0:n.wait.current).then(()=>y(v)):y(v)}),x=ut((h,v,y)=>{Promise.all(g.current[v].splice(0).map(([j,k])=>k)).then(()=>{var j;(j=u.current.shift())==null||j()}).then(()=>y(v))});return p.useMemo(()=>({children:r,register:d,unregister:c,onStart:b,onStop:x,wait:f,chains:g}),[d,c,r,b,x,g,f])}let xS=p.Fragment,vS=ol.RenderStrategy;function MO(e,n){var s,r;let{transition:o=!0,beforeEnter:i,afterEnter:c,beforeLeave:d,afterLeave:u,enter:f,enterFrom:g,enterTo:b,entered:x,leave:h,leaveFrom:v,leaveTo:y,...j}=e,[k,E]=p.useState(null),S=p.useRef(null),N=pS(e),$=Fn(...N?[S,n,E]:n===null?[]:[n]),_=(s=j.unmount)==null||s?zo.Unmount:zo.Hidden,{show:M,appear:O,initial:L}=AO(),[A,R]=p.useState(M?"visible":"hidden"),P=OO(),{register:D,unregister:W}=P;en(()=>D(S),[D,S]),en(()=>{if(_===zo.Hidden&&S.current){if(M&&A!=="visible"){R("visible");return}return ts(A,{hidden:()=>W(S),visible:()=>D(S)})}},[A,S,D,W,M,_]);let K=id();en(()=>{if(N&&K&&A==="visible"&&S.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[S,A,K,N]);let H=L&&!O,q=O&&M&&L,F=p.useRef(!1),G=gS(()=>{F.current||(R("hidden"),W(S))},P),U=ut(fe=>{F.current=!0;let xe=fe?"enter":"leave";G.onStart(S,xe,Ne=>{Ne==="enter"?i==null||i():Ne==="leave"&&(d==null||d())})}),z=ut(fe=>{let xe=fe?"enter":"leave";F.current=!1,G.onStop(S,xe,Ne=>{Ne==="enter"?c==null||c():Ne==="leave"&&(u==null||u())}),xe==="leave"&&!Rm(G)&&(R("hidden"),W(S))});p.useEffect(()=>{N&&o||(U(M),z(M))},[M,N,o]);let Y=!(!o||!N||!K||H),[,J]=F1(Y,k,M,{start:U,end:z}),X=Lo({ref:$,className:((r=Ug(j.className,q&&f,q&&g,J.enter&&f,J.enter&&J.closed&&g,J.enter&&!J.closed&&b,J.leave&&h,J.leave&&!J.closed&&v,J.leave&&J.closed&&y,!J.transition&&M&&x))==null?void 0:r.trim())||void 0,...D1(J)}),le=0;A==="visible"&&(le|=Xn.Open),A==="hidden"&&(le|=Xn.Closed),M&&A==="hidden"&&(le|=Xn.Opening),!M&&A==="visible"&&(le|=Xn.Closing);let se=Cn();return Ke.createElement(Tm.Provider,{value:G},Ke.createElement(rS,{value:le},se({ourProps:X,theirProps:j,defaultTag:xS,features:vS,visible:A==="visible",name:"Transition.Child"})))}function PO(e,n){let{show:s,appear:r=!1,unmount:o=!0,...i}=e,c=p.useRef(null),d=pS(e),u=Fn(...d?[c,n]:n===null?[]:[n]);id();let f=ad();if(s===void 0&&f!==null&&(s=(f&Xn.Open)===Xn.Open),s===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[g,b]=p.useState(s?"visible":"hidden"),x=gS(()=>{s||b("hidden")}),[h,v]=p.useState(!0),y=p.useRef([s]);en(()=>{h!==!1&&y.current[y.current.length-1]!==s&&(y.current.push(s),v(!1))},[y,s]);let j=p.useMemo(()=>({show:s,appear:r,initial:h}),[s,r,h]);en(()=>{s?b("visible"):!Rm(x)&&c.current!==null&&b("hidden")},[s,x]);let k={unmount:o},E=ut(()=>{var $;h&&v(!1),($=e.beforeEnter)==null||$.call(e)}),S=ut(()=>{var $;h&&v(!1),($=e.beforeLeave)==null||$.call(e)}),N=Cn();return Ke.createElement(Tm.Provider,{value:x},Ke.createElement(_m.Provider,{value:j},N({ourProps:{...k,as:p.Fragment,children:Ke.createElement(yS,{ref:u,...k,...i,beforeEnter:E,beforeLeave:S})},theirProps:{},defaultTag:p.Fragment,features:vS,visible:g==="visible",name:"Transition"})))}function LO(e,n){let s=p.useContext(_m)!==null,r=ad()!==null;return Ke.createElement(Ke.Fragment,null,!s&&r?Ke.createElement(Vg,{ref:n,...e}):Ke.createElement(yS,{ref:n,...e}))}let Vg=gn(PO),yS=gn(MO),mv=gn(LO),IO=Object.assign(Vg,{Child:mv,Root:Vg});var zO=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(zO||{}),DO=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(DO||{});let FO={0(e,n){return e.titleId===n.id?e:{...e,titleId:n.id}}},hv=p.createContext(null);hv.displayName="DialogContext";function Am(e){let n=p.useContext(hv);if(n===null){let s=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Am),s}return n}function UO(e,n){return ts(n.type,FO,e,n)}let Jj=gn(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,...b}=e,x=p.useRef(!1);d=(function(){return d==="dialog"||d==="alertdialog"?d:(x.current||(x.current=!0,console.warn(`Invalid role [${d}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let h=ad();o===void 0&&h!==null&&(o=(h&Xn.Open)===Xn.Open);let v=p.useRef(null),y=Fn(v,n),j=Dc(v.current),k=o?0:1,[E,S]=p.useReducer(UO,{titleId:null,descriptionId:null,panelRef:p.createRef()}),N=ut(()=>i(!1)),$=ut(J=>S({type:0,id:J})),_=id()?k===0:!1,[M,O]=gO(),L={get current(){var J;return(J=E.panelRef.current)!=null?J:v.current}},A=fS(),{resolveContainers:R}=wO({mainTreeNode:A,portals:M,defaultContainers:[L]}),P=h!==null?(h&Xn.Closing)===Xn.Closing:!1;_1(f||P?!1:_,{allowed:ut(()=>{var J,X;return[(X=(J=v.current)==null?void 0:J.closest("[data-headlessui-portal]"))!=null?X:null]}),disallowed:ut(()=>{var J;return[(J=A==null?void 0:A.closest("body > *:not(#headlessui-portal-root)"))!=null?J:null]})});let D=jm.get(null);en(()=>{if(_)return D.actions.push(r),()=>D.actions.pop(r)},[D,r,_]);let W=Qn(D,p.useCallback(J=>D.selectors.isTop(J,r),[D,r]));L1(W,R,J=>{J.preventDefault(),N()}),yO(W,j==null?void 0:j.defaultView,J=>{J.preventDefault(),J.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),N()}),z1(f||P?!1:_,j,R),T1(_,v,N);let[K,H]=DA(),q=p.useMemo(()=>[{dialogState:k,close:N,setTitleId:$,unmount:g},E],[k,N,$,g,E]),F=Ks({open:k===0}),G={ref:y,id:r,role:d,tabIndex:-1,"aria-modal":f?void 0:k===0?!0:void 0,"aria-labelledby":E.titleId,"aria-describedby":K,unmount:g},U=!bO(),z=Ca.None;_&&!f&&(z|=Ca.RestoreFocus,z|=Ca.TabLock,u&&(z|=Ca.AutoFocus),U&&(z|=Ca.InitialFocus));let Y=Cn();return Ke.createElement(aO,null,Ke.createElement(Yj,{force:!0},Ke.createElement(cS,null,Ke.createElement(hv.Provider,{value:q},Ke.createElement(lS,{target:v},Ke.createElement(Yj,{force:!1},Ke.createElement(H,{slot:F},Ke.createElement(O,null,Ke.createElement(CO,{initialFocus:c,initialFocusFallback:v,containers:R,features:z},Ke.createElement(YA,{value:N},Y({ourProps:G,theirProps:b,slot:F,defaultTag:WO,features:HO,visible:k===0,name:"Dialog"})))))))))))}),WO="div",HO=ol.RenderStrategy|ol.Static;function BO(e,n){let{transition:s=!1,open:r,...o}=e,i=ad(),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(Qj,null,Ke.createElement(IO,{show:r,transition:s,unmount:o.unmount},Ke.createElement(Jj,{ref:n,...o}))):Ke.createElement(Qj,null,Ke.createElement(Jj,{ref:n,open:r,...o}))}let GO="div";function qO(e,n){let s=p.useId(),{id:r=`headlessui-dialog-panel-${s}`,transition:o=!1,...i}=e,[{dialogState:c,unmount:d},u]=Am("Dialog.Panel"),f=Fn(n,u.panelRef),g=Ks({open:c===0}),b=ut(j=>{j.stopPropagation()}),x={ref:f,id:r,onClick:b},h=o?mv:p.Fragment,v=o?{unmount:d}:{},y=Cn();return Ke.createElement(h,{...v},y({ourProps:x,theirProps:i,slot:g,defaultTag:GO,name:"Dialog.Panel"}))}let KO="div";function VO(e,n){let{transition:s=!1,...r}=e,[{dialogState:o,unmount:i}]=Am("Dialog.Backdrop"),c=Ks({open:o===0}),d={ref:n,"aria-hidden":!0},u=s?mv:p.Fragment,f=s?{unmount:i}:{},g=Cn();return Ke.createElement(u,{...f},g({ourProps:d,theirProps:r,slot:c,defaultTag:KO,name:"Dialog.Backdrop"}))}let YO="h2";function QO(e,n){let s=p.useId(),{id:r=`headlessui-dialog-title-${s}`,...o}=e,[{dialogState:i,setTitleId:c}]=Am("Dialog.Title"),d=Fn(n);p.useEffect(()=>(c(r),()=>c(null)),[r,c]);let u=Ks({open:i===0}),f={ref:d,id:r};return Cn()({ourProps:f,theirProps:o,slot:u,defaultTag:YO,name:"Dialog.Title"})}let JO=gn(BO),bS=gn(qO),XO=gn(VO),wS=gn(QO),ZO=Object.assign(JO,{Panel:bS,Title:wS,Description:y1}),Xj=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function Zj(e){var n,s;let r=(n=e.innerText)!=null?n:"",o=e.cloneNode(!0);if(!Ss(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 Xj.test(c)&&(c=c.replace(Xj,"")),c}function e5(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():Zj(i).trim()}return null}).filter(Boolean);if(r.length>0)return r.join(", ")}return Zj(e).trim()}function t5(e){let n=p.useRef(""),s=p.useRef("");return ut(()=>{let r=e.current;if(!r)return"";let o=r.innerText;if(n.current===o)return s.current;let i=e5(r).trim().toLowerCase();return n.current=o,s.current=i,i})}var n5=Object.defineProperty,s5=(e,n,s)=>n in e?n5(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,ek=(e,n,s)=>(s5(e,typeof n!="symbol"?n+"":n,s),s),zn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(zn||{}),Do=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Do||{}),gf=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(gf||{}),jS=(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))(jS||{});function tk(e,n=s=>s){let s=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=O1(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 r5={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=e.buttonElement?pf.Tracked(dS(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:rn.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:pf.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===rn.Nothing)return{...d,activeOptionIndex:null};if(n.focus===rn.Specific)return{...d,activeOptionIndex:e.options.findIndex(g=>g.id===n.id)};if(n.focus===rn.Previous){let g=e.activeOptionIndex;if(g!==null){let b=e.options[g].dataRef.current.domRef,x=Bu(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(x!==null){let h=e.options[x].dataRef.current.domRef;if(((r=b.current)==null?void 0:r.previousElementSibling)===h.current||((o=h.current)==null?void 0:o.previousElementSibling)===null)return{...d,activeOptionIndex:x}}}}else if(n.focus===rn.Next){let g=e.activeOptionIndex;if(g!==null){let b=e.options[g].dataRef.current.domRef,x=Bu(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(x!==null){let h=e.options[x].dataRef.current.domRef;if(((i=b.current)==null?void 0:i.nextElementSibling)===h.current||((c=h.current)==null?void 0:c.nextElementSibling)===null)return{...d,activeOptionIndex:x}}}}let u=tk(e),f=Bu(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!==rn.Nothing&&(r=Bu(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:rn.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,...tk(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:pf.Moved}}};class pv extends S1{constructor(n){super(n),ek(this,"actions",{onChange:s=>{let{onChange:r,compare:o,mode:i,value:c}=this.state.dataRef.current;return ts(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:Jp(()=>{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:Jp(()=>{let s=[];return[r=>s.push(r),()=>{this.send({type:7,options:s.splice(0)})}]}),goToOption:Jp(()=>{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})}}),ek(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=jm.get(null);this.disposables.add(r.on(E1.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(vO(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 pv({id:n,dataRef:{current:{}},listboxState:s?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:rn.Nothing},frozenValue:!1,__demoMode:s,buttonPositionState:pf.Idle})}reduce(n,s){return ts(s.type,r5,n,s)}}const kS=p.createContext(null);function gv(e){let n=p.useContext(kS);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,NS),s}return n}function NS({id:e,__demoMode:n=!1}){let s=p.useMemo(()=>pv.new({id:e,__demoMode:n}),[]);return uv(()=>s.dispose()),s}let Om=p.createContext(null);Om.displayName="ListboxDataContext";function ld(e){let n=p.useContext(Om);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,ld),s}return n}let o5=p.Fragment;function a5(e,n){let s=p.useId(),r=rv(),{value:o,defaultValue:i,form:c,name:d,onChange:u,by:f,invalid:g=!1,disabled:b=r||!1,horizontal:x=!1,multiple:h=!1,__demoMode:v=!1,...y}=e;const j=x?"horizontal":"vertical";let k=Fn(n),E=jA(i),[S=h?[]:void 0,N]=wA(o,u,E),$=NS({id:s,__demoMode:v}),_=p.useRef({static:!1,hold:!1}),M=p.useRef(new Map),O=JA(f),L=p.useCallback(Y=>ts(A.mode,{[Do.Multi]:()=>S.some(J=>O(J,Y)),[Do.Single]:()=>O(S,Y)}),[S]),A=Ks({value:S,disabled:b,invalid:g,mode:h?Do.Multi:Do.Single,orientation:j,onChange:N,compare:O,isSelected:L,optionsPropsRef:_,listRef:M});en(()=>{$.state.dataRef.current=A},[A]);let R=Qn($,Y=>Y.listboxState),P=jm.get(null),D=Qn(P,p.useCallback(Y=>P.selectors.isTop(Y,s),[P,s])),[W,K]=Qn($,Y=>[Y.buttonElement,Y.optionsElement]);L1(D,[W,K],(Y,J)=>{$.send({type:jS.CloseListbox}),A1(J,ov.Loose)||(Y.preventDefault(),W==null||W.focus())});let H=Ks({open:R===zn.Open,disabled:b,invalid:g,value:S}),[q,F]=HA({inherit:!0}),G={ref:k},U=p.useCallback(()=>{if(E!==void 0)return N==null?void 0:N(E)},[N,E]),z=Cn();return Ke.createElement(F,{value:q,props:{htmlFor:W==null?void 0:W.id},slot:{open:R===zn.Open,disabled:b}},Ke.createElement(nO,null,Ke.createElement(kS.Provider,{value:$},Ke.createElement(Om.Provider,{value:A},Ke.createElement(rS,{value:ts(R,{[zn.Open]:Xn.Open,[zn.Closed]:Xn.Closed})},d!=null&&S!=null&&Ke.createElement(_A,{disabled:b,data:{[d]:S},form:c,onReset:U}),z({ourProps:G,theirProps:y,slot:H,defaultTag:o5,name:"Listbox"}))))))}let i5="button";function l5(e,n){let s=p.useId(),r=m1(),o=ld("Listbox.Button"),i=gv("Listbox.Button"),{id:c=r||`headlessui-listbox-button-${s}`,disabled:d=o.disabled||!1,autoFocus:u=!1,...f}=e,g=Fn(n,X4(),i.actions.setButtonElement),b=Z4(),[x,h,v]=Qn(i,K=>[K.listboxState,K.buttonElement,K.optionsElement]),y=x===zn.Open;w3(y,{trigger:h,action:p.useCallback(K=>{if(h!=null&&h.contains(K.target))return Wu.Ignore;let H=K.target.closest('[role="option"]:not([data-disabled])');return Ss(H)?Wu.Select(H):v!=null&&v.contains(K.target)?Wu.Ignore:Wu.Close},[h,v]),close:i.actions.closeListbox,select:i.actions.selectActiveOption});let j=ut(K=>{switch(K.key){case yn.Enter:kA(K.currentTarget);break;case yn.Space:case yn.ArrowDown:K.preventDefault(),i.actions.openListbox({focus:o.value?rn.Nothing:rn.First});break;case yn.ArrowUp:K.preventDefault(),i.actions.openListbox({focus:o.value?rn.Nothing:rn.Last});break}}),k=ut(K=>{switch(K.key){case yn.Space:K.preventDefault();break}}),E=ZA(K=>{var H;i.state.listboxState===zn.Open?(Ns.flushSync(()=>i.actions.closeListbox()),(H=i.state.buttonElement)==null||H.focus({preventScroll:!0})):(K.preventDefault(),i.actions.openListbox({focus:rn.Nothing}))}),S=ut(K=>K.preventDefault()),N=w1([c]),$=zA(),{isFocusVisible:_,focusProps:M}=oA({autoFocus:u}),{isHovered:O,hoverProps:L}=lA({isDisabled:d}),{pressed:A,pressProps:R}=hA({disabled:d}),P=Ks({open:x===zn.Open,active:A||x===zn.Open,disabled:d,invalid:o.invalid,value:o.value,hover:O,focus:_,autofocus:u}),D=Qn(i,K=>K.listboxState===zn.Open),W=l1(b(),{ref:g,id:c,type:j3(e,h),"aria-haspopup":"listbox","aria-controls":v==null?void 0:v.id,"aria-expanded":D,"aria-labelledby":N,"aria-describedby":$,disabled:d||void 0,autoFocus:u,onKeyDown:j,onKeyUp:k,onKeyPress:S},E,M,L,R);return Cn()({ourProps:W,theirProps:f,slot:P,defaultTag:i5,name:"Listbox.Button"})}let SS=p.createContext(!1),c5="div",d5=ol.RenderStrategy|ol.Static;function u5(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=J4(o),[g,b]=p.useState(null);f&&(i=!0);let x=ld("Listbox.Options"),h=gv("Listbox.Options"),[v,y,j,k]=Qn(h,se=>[se.listboxState,se.buttonElement,se.optionsElement,se.__demoMode]),E=Dc(y),S=Dc(j),N=ad(),[$,_]=F1(d,g,N!==null?(N&Xn.Open)===Xn.Open:v===zn.Open);T1($,y,h.actions.closeListbox);let M=k?!1:c&&v===zn.Open;z1(M,S);let O=k?!1:c&&v===zn.Open;_1(O,{allowed:p.useCallback(()=>[y,j],[y,j])});let L=Qn(h,h.selectors.didButtonMove)?!1:$,A=Qn(h,h.selectors.hasFrozenValue)&&!e.static,R=sS(A,x.value),P=p.useCallback(se=>x.compare(R,se),[x.compare,R]),D=Qn(h,se=>{var fe;if(f==null||!((fe=f==null?void 0:f.to)!=null&&fe.includes("selection")))return null;let xe=se.options.findIndex(Ne=>P(Ne.dataRef.current.value));return xe===-1&&(xe=0),xe}),W=(()=>{if(f==null)return;if(D===null)return{...f,inner:void 0};let se=Array.from(x.listRef.current.values());return{...f,inner:{listRef:{current:se},index:D}}})(),[K,H]=tO(W),q=eO(),F=Fn(n,f?K:null,h.actions.setOptionsElement,b),G=Zo();p.useEffect(()=>{let se=j;se&&v===zn.Open&&(a1(se)||se==null||se.focus({preventScroll:!0}))},[v,j]);let U=ut(se=>{var fe;switch(G.dispose(),se.key){case yn.Space:if(h.state.searchQuery!=="")return se.preventDefault(),se.stopPropagation(),h.actions.search(se.key);case yn.Enter:se.preventDefault(),se.stopPropagation(),h.actions.selectActiveOption();break;case ts(x.orientation,{vertical:yn.ArrowDown,horizontal:yn.ArrowRight}):return se.preventDefault(),se.stopPropagation(),h.actions.goToOption({focus:rn.Next});case ts(x.orientation,{vertical:yn.ArrowUp,horizontal:yn.ArrowLeft}):return se.preventDefault(),se.stopPropagation(),h.actions.goToOption({focus:rn.Previous});case yn.Home:case yn.PageUp:return se.preventDefault(),se.stopPropagation(),h.actions.goToOption({focus:rn.First});case yn.End:case yn.PageDown:return se.preventDefault(),se.stopPropagation(),h.actions.goToOption({focus:rn.Last});case yn.Escape:se.preventDefault(),se.stopPropagation(),Ns.flushSync(()=>h.actions.closeListbox()),(fe=h.state.buttonElement)==null||fe.focus({preventScroll:!0});return;case yn.Tab:se.preventDefault(),se.stopPropagation(),Ns.flushSync(()=>h.actions.closeListbox()),x3(h.state.buttonElement,se.shiftKey?lr.Previous:lr.Next);break;default:se.key.length===1&&(h.actions.search(se.key),G.setTimeout(()=>h.actions.clearSearch(),350));break}}),z=Qn(h,se=>{var fe;return(fe=se.buttonElement)==null?void 0:fe.id}),Y=Ks({open:v===zn.Open}),J=l1(f?q():{},{id:r,ref:F,"aria-activedescendant":Qn(h,h.selectors.activeDescendantId),"aria-multiselectable":x.mode===Do.Multi?!0:void 0,"aria-labelledby":z,"aria-orientation":x.orientation,onKeyDown:U,role:"listbox",tabIndex:v===zn.Open?0:void 0,style:{...u.style,...H,"--button-width":XA($,y,!0).width},...D1(_)}),X=Cn(),le=p.useMemo(()=>x.mode===Do.Multi?x:{...x,isSelected:P},[x,P]);return Ke.createElement(cS,{enabled:i?e.static||$:!1,ownerDocument:E},Ke.createElement(Om.Provider,{value:le},X({ourProps:J,theirProps:u,slot:Y,defaultTag:c5,features:d5,visible:L,name:"Listbox.Options"})))}let f5="div";function m5(e,n){let s=p.useId(),{id:r=`headlessui-listbox-option-${s}`,disabled:o=!1,value:i,...c}=e,d=p.useContext(SS)===!0,u=ld("Listbox.Option"),f=gv("Listbox.Option"),g=Qn(f,A=>f.selectors.isActive(A,r)),b=u.isSelected(i),x=p.useRef(null),h=t5(x),v=ea({disabled:o,value:i,domRef:x,get textValue(){return h()}}),y=Fn(n,x,A=>{A?u.listRef.current.set(r,A):u.listRef.current.delete(r)}),j=Qn(f,A=>f.selectors.shouldScrollIntoView(A,r));en(()=>{if(j)return $s().requestAnimationFrame(()=>{var A,R;(R=(A=x.current)==null?void 0:A.scrollIntoView)==null||R.call(A,{block:"nearest"})})},[j,x]),en(()=>{if(!d)return f.actions.registerOption(r,v),()=>f.actions.unregisterOption(r)},[v,r,d]);let k=ut(A=>{if(o)return A.preventDefault();f.actions.selectOption(i)}),E=ut(()=>{if(o)return f.actions.goToOption({focus:rn.Nothing});f.actions.goToOption({focus:rn.Specific,id:r})}),S=_3(),N=ut(A=>S.update(A)),$=ut(A=>{S.wasMoved(A)&&(o||g&&f.state.activationTrigger===gf.Pointer||f.actions.goToOption({focus:rn.Specific,id:r},gf.Pointer))}),_=ut(A=>{S.wasMoved(A)&&(o||g&&f.state.activationTrigger===gf.Pointer&&f.actions.goToOption({focus:rn.Nothing}))}),M=Ks({active:g,focus:g,selected:b,disabled:o,selectedOption:b&&d}),O=d?{}:{id:r,ref:y,role:"option",tabIndex:o===!0?void 0:-1,"aria-disabled":o===!0?!0:void 0,"aria-selected":b,disabled:void 0,onClick:k,onFocus:E,onPointerEnter:N,onMouseEnter:N,onPointerMove:$,onMouseMove:$,onPointerLeave:_,onMouseLeave:_},L=Cn();return!b&&d?null:L({ourProps:O,theirProps:c,slot:M,defaultTag:f5,name:"Listbox.Option"})}let h5=p.Fragment;function p5(e,n){let{options:s,placeholder:r,...o}=e,i={ref:Fn(n)},c=ld("ListboxSelectedOption"),d=Ks({}),u=c.value===void 0||c.value===null||c.mode===Do.Multi&&Array.isArray(c.value)&&c.value.length===0,f=Cn();return Ke.createElement(SS.Provider,{value:!0},f({ourProps:i,theirProps:{...o,children:Ke.createElement(Ke.Fragment,null,r&&u?r:s)},slot:d,defaultTag:h5,name:"ListboxSelectedOption"}))}let g5=gn(a5),CS=gn(l5),x5=KA,ES=gn(u5),$S=gn(m5),v5=gn(p5),y5=Object.assign(g5,{Button:CS,Label:x5,Options:ES,Option:$S,SelectedOption:v5});const b5={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function Mm({open:e,onClose:n,title:s,description:r,footer:o,size:i="md",initialFocus:c,hideClose:d,className:u,children:f}){return t.jsxs(ZO,{open:e,onClose:n,initialFocus:c,className:"relative z-dialog",children:[t.jsx(XO,{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(bS,{className:ae("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",b5[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(wS,{className:"text-lg font-semibold",children:s}),r&&t.jsx(y1,{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(Xo,{"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 xv({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(Mm,{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 vv=p.createContext(null),w5=()=>p.useContext(vv);function yv(e){const n=p.useContext(vv);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 bt({label:e,id:n,required:s,optional:r,note:o,hint:i,error:c,warning:d,aside:u,group:f,className:g,children:b}){const x=p.useId(),h=n??`${x}-control`,[v,y,j,k,E]=[`${x}-label`,`${x}-note`,`${x}-hint`,`${x}-error`,`${x}-warning`],S=[o&&y,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":v,"aria-describedby":S}:{},children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[f?t.jsx("span",{id:v,className:"caps text-small font-semibold",children:N}):t.jsx("label",{id:v,htmlFor:h,className:"caps text-small font-semibold",children:N}),u]}),o&&t.jsx("p",{id:y,className:"-mt-1 mb-2 text-small text-muted-foreground",children:o}),t.jsx(vv.Provider,{value:f?null:{id:h,describedBy:S,invalid:!!c,required:!!s},children:b}),i&&t.jsx("p",{id:j,className:"mt-1.5 text-small text-muted-foreground",children:i}),c&&t.jsx("p",{id:k,className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{id:E,className:"mt-2 font-mono text-small text-warning-text",children:d})]})}const _S="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",TS="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",cd="xl:columns-2 xl:gap-x-10 2xl:columns-3 [&>*]:mb-5 [&>*]:mt-0 [&>*]:break-inside-avoid",Hc="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,...yv(r),className:ae(s?TS:ae(_S,n==="sm"?"h-control-sm":"h-control-md"),e)}));Pe.displayName="Input";const tn=p.forwardRef(({className:e,bare:n,...s},r)=>t.jsx("textarea",{ref:r,...s,...yv(s),className:ae(n?TS:ae(_S,"py-2.5"),e)}));tn.displayName="Textarea";const RS=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,...yv(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},j5=RS("checkbox");RS("radio");function yr({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 Ct({value:e,onChange:n,options:s,label:r,id:o,className:i,disabled:c=!1,name:d,small:u=!1,placeholder:f,autoFocus:g}){const b=s.find(h=>h.value===e),x=w5();return t.jsxs(y5,{value:e,onChange:n,disabled:c,name:d,children:[t.jsxs(CS,{id:o??(x==null?void 0:x.id),autoFocus:g,"aria-label":r,"aria-describedby":x==null?void 0:x.describedBy,"aria-invalid":(x==null?void 0:x.invalid)||void 0,"data-value":e,className:ae("flex min-w-0 items-center justify-between gap-2 border border-input bg-background text-left font-mono hover:border-foreground/60 focus-visible:outline-offset-0 disabled:opacity-60 data-[open]:border-foreground",u?"h-control-sm px-2 text-small":"h-control-md px-3 text-body",i),children:[t.jsx("span",{className:ae("min-w-0 truncate",!b&&"text-muted-foreground"),children:(b==null?void 0:b.label)??f??""}),t.jsx(Or,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsx(ES,{anchor:"bottom start","data-picker-list":"",className:"z-popover max-h-72 w-[var(--button-width)] min-w-[12rem] overflow-auto border border-border-strong bg-background py-1 font-mono text-body shadow-float outline-none [--anchor-gap:2px] [--anchor-padding:8px]",children:s.map(h=>t.jsxs($S,{value:h.value,disabled:h.disabled,title:h.title,"data-value":h.value,className:"group flex min-h-10 cursor-pointer items-center gap-2 px-3 py-2 data-[disabled]:cursor-not-allowed data-[focus]:bg-accent data-[disabled]:opacity-50 data-[selected]:text-foreground",children:[t.jsx(pl,{className:"invisible size-3.5 shrink-0 text-primary-text group-data-[selected]:visible","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 break-words",children:h.label}),h.tag&&t.jsx(ke,{tone:"success",className:"ml-auto",children:h.tag})]},h.value))})]})}function dd({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 k5=["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 N5({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(k5,"h-control-sm cursor-pointer disabled:cursor-not-allowed disabled:opacity-45",c)})}function S5({label:e,className:n}){return t.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[t.jsx(IT,{className:ae("size-4 animate-spin text-run-active",n),"aria-hidden":!0}),e&&t.jsx("span",{className:"sr-only",children:e})]})}function ud({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 AS="flex shrink-0 gap-x-4 overflow-x-auto border-b px-5 md:px-8",OS=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 MS({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,v;const b=e.findIndex(y=>y.id===n),x=g.key==="ArrowRight"?(b+1)%e.length:g.key==="ArrowLeft"?(b-1+e.length)%e.length:g.key==="Home"?0:g.key==="End"?e.length-1:-1;x<0||x===b||(g.preventDefault(),s(e[x].id),(v=(h=d.current)==null?void 0:h.querySelectorAll('[role="tab"]')[x])==null||v.focus())};return t.jsx("div",{ref:d,role:"tablist","aria-label":r,onKeyDown:u,className:ae(AS,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:OS(n===g.id),children:g.label},g.id))})}const C5=(e,n)=>({role:"tabpanel",id:`${e}-panel-${n}`,"aria-labelledby":`${e}-tab-${n}`});function E5({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 PS=p.createContext(null),$5={neutral:[Pg,"text-muted-foreground"],success:[AN,"text-success-text"],warning:[Gs,"text-warning-text"],error:[nl,"text-destructive-text"]},_5=5e3;function T5(){return p.useContext(PS)??R5}const R5=()=>{};function A5({toast:e,done:n}){const s=p.useCallback(()=>n(e.id),[n,e.id]),r=e.tone??"neutral",o=e.duration??(r==="error"?0:_5),[i,c]=p.useState(!1),[d,u]=p.useState(!1),f=i||d;p.useEffect(()=>{if(!o||f)return;const x=setTimeout(s,o);return()=>clearTimeout(x)},[o,f,s]);const[g,b]=$5[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",b),"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"font-semibold",children:e.title}),e.description&&t.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:e.description})]}),t.jsx("button",{type:"button",onClick:s,"aria-label":"Dismiss",className:"-m-1 shrink-0 p-1 text-muted-foreground hover:text-foreground",children:t.jsx(Xo,{className:"size-3.5","aria-hidden":!0})})]})}function O5({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(PS.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(A5,{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:LS,setPrototypeOf:nk,isFrozen:M5,getPrototypeOf:P5,getOwnPropertyDescriptor:L5}=Object;let{freeze:ns,seal:Vs,create:IS}=Object,{apply:Yg,construct:Qg}=typeof Reflect<"u"&&Reflect;ns||(ns=function(n){return n});Vs||(Vs=function(n){return n});Yg||(Yg=function(n,s,r){return n.apply(s,r)});Qg||(Qg=function(n,s){return new n(...s)});const Gu=Cs(Array.prototype.forEach),sk=Cs(Array.prototype.pop),dc=Cs(Array.prototype.push),xf=Cs(String.prototype.toLowerCase),ag=Cs(String.prototype.toString),rk=Cs(String.prototype.match),uc=Cs(String.prototype.replace),I5=Cs(String.prototype.indexOf),z5=Cs(String.prototype.trim),ar=Cs(Object.prototype.hasOwnProperty),Yn=Cs(RegExp.prototype.test),fc=D5(TypeError);function Cs(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 Yg(e,n,r)}}function D5(e){return function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return Qg(e,s)}}function yt(e,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xf;nk&&nk(e,null);let r=n.length;for(;r--;){let o=n[r];if(typeof o=="string"){const i=s(o);i!==o&&(M5(n)||(n[r]=i),o=i)}e[o]=!0}return e}function F5(e){for(let n=0;n<e.length;n++)ar(e,n)||(e[n]=null);return e}function Sa(e){const n=IS(null);for(const[s,r]of LS(e))ar(e,s)&&(Array.isArray(r)?n[s]=F5(r):r&&typeof r=="object"&&r.constructor===Object?n[s]=Sa(r):n[s]=r);return n}function mc(e,n){for(;e!==null;){const r=L5(e,n);if(r){if(r.get)return Cs(r.get);if(typeof r.value=="function")return Cs(r.value)}e=P5(e)}function s(){return null}return s}const ok=ns(["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"]),ig=ns(["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"]),lg=ns(["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"]),U5=ns(["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"]),cg=ns(["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"]),W5=ns(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ak=ns(["#text"]),ik=ns(["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"]),dg=ns(["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"]),lk=ns(["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"]),qu=ns(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),H5=Vs(/\{\{[\w\W]*|[\w\W]*\}\}/gm),B5=Vs(/<%[\w\W]*|[\w\W]*%>/gm),G5=Vs(/\$\{[\w\W]*}/gm),q5=Vs(/^data-[\-\w.\u00B7-\uFFFF]+$/),K5=Vs(/^aria-[\-\w]+$/),zS=Vs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),V5=Vs(/^(?:\w+script|data):/i),Y5=Vs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),DS=Vs(/^html$/i),Q5=Vs(/^[a-z][.\w]*(-[.\w]+)+$/i);var ck=Object.freeze({__proto__:null,ARIA_ATTR:K5,ATTR_WHITESPACE:Y5,CUSTOM_ELEMENT:Q5,DATA_ATTR:q5,DOCTYPE_NAME:DS,ERB_EXPR:B5,IS_ALLOWED_URI:zS,IS_SCRIPT_OR_DATA:V5,MUSTACHE_EXPR:H5,TMPLIT_EXPR:G5});const hc={element:1,text:3,progressingInstruction:7,comment:8,document:9},J5=function(){return typeof window>"u"?null:window},X5=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}},dk=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function FS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:J5();const n=Be=>FS(Be);if(n.version="3.2.3",n.removed=[],!e||!e.document||e.document.nodeType!==hc.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:b,DOMParser:x,trustedTypes:h}=e,v=u.prototype,y=mc(v,"cloneNode"),j=mc(v,"remove"),k=mc(v,"nextSibling"),E=mc(v,"childNodes"),S=mc(v,"parentNode");if(typeof c=="function"){const Be=s.createElement("template");Be.content&&Be.content.ownerDocument&&(s=Be.content.ownerDocument)}let N,$="";const{implementation:_,createNodeIterator:M,createDocumentFragment:O,getElementsByTagName:L}=s,{importNode:A}=r;let R=dk();n.isSupported=typeof LS=="function"&&typeof S=="function"&&_&&_.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:P,ERB_EXPR:D,TMPLIT_EXPR:W,DATA_ATTR:K,ARIA_ATTR:H,IS_SCRIPT_OR_DATA:q,ATTR_WHITESPACE:F,CUSTOM_ELEMENT:G}=ck;let{IS_ALLOWED_URI:U}=ck,z=null;const Y=yt({},[...ok,...ig,...lg,...cg,...ak]);let J=null;const X=yt({},[...ik,...dg,...lk,...qu]);let le=Object.seal(IS(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}})),se=null,fe=null,xe=!0,Ne=!0,ge=!1,me=!0,Le=!1,Ue=!0,De=!1,Ee=!1,re=!1,_e=!1,Qe=!1,he=!1,Ie=!0,et=!1;const pt="user-content-";let oe=!0,$e=!1,st={},Oe=null;const dt=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 Tt=null;const nt=yt({},["audio","video","img","source","image","track"]);let ft=null;const Kt=yt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Dt="http://www.w3.org/1998/Math/MathML",ye="http://www.w3.org/2000/svg",de="http://www.w3.org/1999/xhtml";let We=de,Ze=!1,at=null;const Q=yt({},[Dt,ye,de],ag);let ve=yt({},["mi","mo","mn","ms","mtext"]),He=yt({},["annotation-xml"]);const Se=yt({},["title","style","font","a","script"]);let Je=null;const Nt=["application/xhtml+xml","text/html"],zt="text/html";let it=null,An=null;const ps=s.createElement("form"),Qs=function(te){return te instanceof RegExp||te instanceof Function},En=function(){let te=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(An&&An===te)){if((!te||typeof te!="object")&&(te={}),te=Sa(te),Je=Nt.indexOf(te.PARSER_MEDIA_TYPE)===-1?zt:te.PARSER_MEDIA_TYPE,it=Je==="application/xhtml+xml"?ag:xf,z=ar(te,"ALLOWED_TAGS")?yt({},te.ALLOWED_TAGS,it):Y,J=ar(te,"ALLOWED_ATTR")?yt({},te.ALLOWED_ATTR,it):X,at=ar(te,"ALLOWED_NAMESPACES")?yt({},te.ALLOWED_NAMESPACES,ag):Q,ft=ar(te,"ADD_URI_SAFE_ATTR")?yt(Sa(Kt),te.ADD_URI_SAFE_ATTR,it):Kt,Tt=ar(te,"ADD_DATA_URI_TAGS")?yt(Sa(nt),te.ADD_DATA_URI_TAGS,it):nt,Oe=ar(te,"FORBID_CONTENTS")?yt({},te.FORBID_CONTENTS,it):dt,se=ar(te,"FORBID_TAGS")?yt({},te.FORBID_TAGS,it):{},fe=ar(te,"FORBID_ATTR")?yt({},te.FORBID_ATTR,it):{},st=ar(te,"USE_PROFILES")?te.USE_PROFILES:!1,xe=te.ALLOW_ARIA_ATTR!==!1,Ne=te.ALLOW_DATA_ATTR!==!1,ge=te.ALLOW_UNKNOWN_PROTOCOLS||!1,me=te.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Le=te.SAFE_FOR_TEMPLATES||!1,Ue=te.SAFE_FOR_XML!==!1,De=te.WHOLE_DOCUMENT||!1,_e=te.RETURN_DOM||!1,Qe=te.RETURN_DOM_FRAGMENT||!1,he=te.RETURN_TRUSTED_TYPE||!1,re=te.FORCE_BODY||!1,Ie=te.SANITIZE_DOM!==!1,et=te.SANITIZE_NAMED_PROPS||!1,oe=te.KEEP_CONTENT!==!1,$e=te.IN_PLACE||!1,U=te.ALLOWED_URI_REGEXP||zS,We=te.NAMESPACE||de,ve=te.MATHML_TEXT_INTEGRATION_POINTS||ve,He=te.HTML_INTEGRATION_POINTS||He,le=te.CUSTOM_ELEMENT_HANDLING||{},te.CUSTOM_ELEMENT_HANDLING&&Qs(te.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(le.tagNameCheck=te.CUSTOM_ELEMENT_HANDLING.tagNameCheck),te.CUSTOM_ELEMENT_HANDLING&&Qs(te.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(le.attributeNameCheck=te.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),te.CUSTOM_ELEMENT_HANDLING&&typeof te.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(le.allowCustomizedBuiltInElements=te.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Le&&(Ne=!1),Qe&&(_e=!0),st&&(z=yt({},ak),J=[],st.html===!0&&(yt(z,ok),yt(J,ik)),st.svg===!0&&(yt(z,ig),yt(J,dg),yt(J,qu)),st.svgFilters===!0&&(yt(z,lg),yt(J,dg),yt(J,qu)),st.mathMl===!0&&(yt(z,cg),yt(J,lk),yt(J,qu))),te.ADD_TAGS&&(z===Y&&(z=Sa(z)),yt(z,te.ADD_TAGS,it)),te.ADD_ATTR&&(J===X&&(J=Sa(J)),yt(J,te.ADD_ATTR,it)),te.ADD_URI_SAFE_ATTR&&yt(ft,te.ADD_URI_SAFE_ATTR,it),te.FORBID_CONTENTS&&(Oe===dt&&(Oe=Sa(Oe)),yt(Oe,te.FORBID_CONTENTS,it)),oe&&(z["#text"]=!0),De&&yt(z,["html","head","body"]),z.table&&(yt(z,["tbody"]),delete se.tbody),te.TRUSTED_TYPES_POLICY){if(typeof te.TRUSTED_TYPES_POLICY.createHTML!="function")throw fc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof te.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw fc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=te.TRUSTED_TYPES_POLICY,$=N.createHTML("")}else N===void 0&&(N=X5(h,o)),N!==null&&typeof $=="string"&&($=N.createHTML(""));ns&&ns(te),An=te}},Wn=yt({},[...ig,...lg,...U5]),gs=yt({},[...cg,...W5]),xs=function(te){let be=S(te);(!be||!be.tagName)&&(be={namespaceURI:We,tagName:"template"});const qe=xf(te.tagName),kt=xf(be.tagName);return at[te.namespaceURI]?te.namespaceURI===ye?be.namespaceURI===de?qe==="svg":be.namespaceURI===Dt?qe==="svg"&&(kt==="annotation-xml"||ve[kt]):!!Wn[qe]:te.namespaceURI===Dt?be.namespaceURI===de?qe==="math":be.namespaceURI===ye?qe==="math"&&He[kt]:!!gs[qe]:te.namespaceURI===de?be.namespaceURI===ye&&!He[kt]||be.namespaceURI===Dt&&!ve[kt]?!1:!gs[qe]&&(Se[qe]||!Wn[qe]):!!(Je==="application/xhtml+xml"&&at[te.namespaceURI]):!1},fn=function(te){dc(n.removed,{element:te});try{S(te).removeChild(te)}catch{j(te)}},Hn=function(te,be){try{dc(n.removed,{attribute:be.getAttributeNode(te),from:be})}catch{dc(n.removed,{attribute:null,from:be})}if(be.removeAttribute(te),te==="is")if(_e||Qe)try{fn(be)}catch{}else try{be.setAttribute(te,"")}catch{}},_s=function(te){let be=null,qe=null;if(re)te="<remove></remove>"+te;else{const lt=rk(te,/^[\r\n\t ]+/);qe=lt&<[0]}Je==="application/xhtml+xml"&&We===de&&(te='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+te+"</body></html>");const kt=N?N.createHTML(te):te;if(We===de)try{be=new x().parseFromString(kt,Je)}catch{}if(!be||!be.documentElement){be=_.createDocument(We,"template",null);try{be.documentElement.innerHTML=Ze?$:kt}catch{}}const Lt=be.body||be.documentElement;return te&&qe&&Lt.insertBefore(s.createTextNode(qe),Lt.childNodes[0]||null),We===de?L.call(be,De?"html":"body")[0]:De?be.documentElement:Lt},Bn=function(te){return M.call(te.ownerDocument||te,te,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},Ts=function(te){return te instanceof b&&(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")},Rs=function(te){return typeof d=="function"&&te instanceof d};function On(Be,te,be){Gu(Be,qe=>{qe.call(n,te,be,An)})}const ee=function(te){let be=null;if(On(R.beforeSanitizeElements,te,null),Ts(te))return fn(te),!0;const qe=it(te.nodeName);if(On(R.uponSanitizeElement,te,{tagName:qe,allowedTags:z}),te.hasChildNodes()&&!Rs(te.firstElementChild)&&Yn(/<[/\w]/g,te.innerHTML)&&Yn(/<[/\w]/g,te.textContent)||te.nodeType===hc.progressingInstruction||Ue&&te.nodeType===hc.comment&&Yn(/<[/\w]/g,te.data))return fn(te),!0;if(!z[qe]||se[qe]){if(!se[qe]&&mt(qe)&&(le.tagNameCheck instanceof RegExp&&Yn(le.tagNameCheck,qe)||le.tagNameCheck instanceof Function&&le.tagNameCheck(qe)))return!1;if(oe&&!Oe[qe]){const kt=S(te)||te.parentNode,Lt=E(te)||te.childNodes;if(Lt&&kt){const lt=Lt.length;for(let bn=lt-1;bn>=0;--bn){const $n=y(Lt[bn],!0);$n.__removalCount=(te.__removalCount||0)+1,kt.insertBefore($n,k(te))}}}return fn(te),!0}return te instanceof u&&!xs(te)||(qe==="noscript"||qe==="noembed"||qe==="noframes")&&Yn(/<\/no(script|embed|frames)/i,te.innerHTML)?(fn(te),!0):(Le&&te.nodeType===hc.text&&(be=te.textContent,Gu([P,D,W],kt=>{be=uc(be,kt," ")}),te.textContent!==be&&(dc(n.removed,{element:te.cloneNode()}),te.textContent=be)),On(R.afterSanitizeElements,te,null),!1)},Me=function(te,be,qe){if(Ie&&(be==="id"||be==="name")&&(qe in s||qe in ps))return!1;if(!(Ne&&!fe[be]&&Yn(K,be))){if(!(xe&&Yn(H,be))){if(!J[be]||fe[be]){if(!(mt(te)&&(le.tagNameCheck instanceof RegExp&&Yn(le.tagNameCheck,te)||le.tagNameCheck instanceof Function&&le.tagNameCheck(te))&&(le.attributeNameCheck instanceof RegExp&&Yn(le.attributeNameCheck,be)||le.attributeNameCheck instanceof Function&&le.attributeNameCheck(be))||be==="is"&&le.allowCustomizedBuiltInElements&&(le.tagNameCheck instanceof RegExp&&Yn(le.tagNameCheck,qe)||le.tagNameCheck instanceof Function&&le.tagNameCheck(qe))))return!1}else if(!ft[be]){if(!Yn(U,uc(qe,F,""))){if(!((be==="src"||be==="xlink:href"||be==="href")&&te!=="script"&&I5(qe,"data:")===0&&Tt[te])){if(!(ge&&!Yn(q,uc(qe,F,"")))){if(qe)return!1}}}}}}return!0},mt=function(te){return te!=="annotation-xml"&&rk(te,G)},At=function(te){On(R.beforeSanitizeAttributes,te,null);const{attributes:be}=te;if(!be||Ts(te))return;const qe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J,forceKeepAttr:void 0};let kt=be.length;for(;kt--;){const Lt=be[kt],{name:lt,namespaceURI:bn,value:$n}=Lt,mr=it(lt);let Ht=lt==="value"?$n:z5($n);if(qe.attrName=mr,qe.attrValue=Ht,qe.keepAttr=!0,qe.forceKeepAttr=void 0,On(R.uponSanitizeAttribute,te,qe),Ht=qe.attrValue,et&&(mr==="id"||mr==="name")&&(Hn(lt,te),Ht=pt+Ht),Ue&&Yn(/((--!?|])>)|<\/(style|title)/i,Ht)){Hn(lt,te);continue}if(qe.forceKeepAttr||(Hn(lt,te),!qe.keepAttr))continue;if(!me&&Yn(/\/>/i,Ht)){Hn(lt,te);continue}Le&&Gu([P,D,W],io=>{Ht=uc(Ht,io," ")});const ri=it(te.nodeName);if(Me(ri,mr,Ht)){if(N&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!bn)switch(h.getAttributeType(ri,mr)){case"TrustedHTML":{Ht=N.createHTML(Ht);break}case"TrustedScriptURL":{Ht=N.createScriptURL(Ht);break}}try{bn?te.setAttributeNS(bn,lt,Ht):te.setAttribute(lt,Ht),Ts(te)?fn(te):sk(n.removed)}catch{}}}On(R.afterSanitizeAttributes,te,null)},Jt=function Be(te){let be=null;const qe=Bn(te);for(On(R.beforeSanitizeShadowDOM,te,null);be=qe.nextNode();)On(R.uponSanitizeShadowNode,be,null),ee(be),At(be),be.content instanceof i&&Be(be.content);On(R.afterSanitizeShadowDOM,te,null)};return n.sanitize=function(Be){let te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},be=null,qe=null,kt=null,Lt=null;if(Ze=!Be,Ze&&(Be="<!-->"),typeof Be!="string"&&!Rs(Be))if(typeof Be.toString=="function"){if(Be=Be.toString(),typeof Be!="string")throw fc("dirty is not a string, aborting")}else throw fc("toString is not a function");if(!n.isSupported)return Be;if(Ee||En(te),n.removed=[],typeof Be=="string"&&($e=!1),$e){if(Be.nodeName){const $n=it(Be.nodeName);if(!z[$n]||se[$n])throw fc("root node is forbidden and cannot be sanitized in-place")}}else if(Be instanceof d)be=_s("<!---->"),qe=be.ownerDocument.importNode(Be,!0),qe.nodeType===hc.element&&qe.nodeName==="BODY"||qe.nodeName==="HTML"?be=qe:be.appendChild(qe);else{if(!_e&&!Le&&!De&&Be.indexOf("<")===-1)return N&&he?N.createHTML(Be):Be;if(be=_s(Be),!be)return _e?null:he?$:""}be&&re&&fn(be.firstChild);const lt=Bn($e?Be:be);for(;kt=lt.nextNode();)ee(kt),At(kt),kt.content instanceof i&&Jt(kt.content);if($e)return Be;if(_e){if(Qe)for(Lt=O.call(be.ownerDocument);be.firstChild;)Lt.appendChild(be.firstChild);else Lt=be;return(J.shadowroot||J.shadowrootmode)&&(Lt=A.call(r,Lt,!0)),Lt}let bn=De?be.outerHTML:be.innerHTML;return De&&z["!doctype"]&&be.ownerDocument&&be.ownerDocument.doctype&&be.ownerDocument.doctype.name&&Yn(DS,be.ownerDocument.doctype.name)&&(bn="<!DOCTYPE "+be.ownerDocument.doctype.name+`>
|
|
523
|
+
`+bn),Le&&Gu([P,D,W],$n=>{bn=uc(bn,$n," ")}),N&&he?N.createHTML(bn):bn},n.setConfig=function(){let Be=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};En(Be),Ee=!0},n.clearConfig=function(){An=null,Ee=!1},n.isValidAttribute=function(Be,te,be){An||En({});const qe=it(Be),kt=it(te);return Me(qe,kt,be)},n.addHook=function(Be,te){typeof te=="function"&&dc(R[Be],te)},n.removeHook=function(Be){return sk(R[Be])},n.removeHooks=function(Be){R[Be]=[]},n.removeAllHooks=function(){R=dk()},n}var vf=FS();function bv(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Za=bv();function US(e){Za=e}const Rc={exec:()=>null};function It(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(Zn.caret,"$1"),s=s.replace(o,c),r},getRegex:()=>new RegExp(s,n)};return r}const Zn={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")},Z5=/^(?:[ \t]*(?:\n|$))+/,eM=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,tM=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,fd=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nM=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,WS=/(?:[*+-]|\d{1,9}[.)])/,HS=It(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,WS).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(),wv=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,sM=/^[^\n]+/,jv=/(?!\s*\])(?:\\.|[^\[\]\\])+/,rM=It(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",jv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),oM=It(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,WS).getRegex(),Pm="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",kv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,aM=It("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",kv).replace("tag",Pm).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),BS=It(wv).replace("hr",fd).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",Pm).getRegex(),iM=It(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",BS).getRegex(),Nv={blockquote:iM,code:eM,def:rM,fences:tM,heading:nM,hr:fd,html:aM,lheading:HS,list:oM,newline:Z5,paragraph:BS,table:Rc,text:sM},uk=It("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",fd).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",Pm).getRegex(),lM={...Nv,table:uk,paragraph:It(wv).replace("hr",fd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",uk).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",Pm).getRegex()},cM={...Nv,html:It(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",kv).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:Rc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:It(wv).replace("hr",fd).replace("heading",` *#{1,6} *[^
|
|
524
|
+
]`).replace("lheading",HS).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},dM=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,uM=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,GS=/^( {2,}|\\)\n(?!\s*$)/,fM=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Lm=/[\p{P}\p{S}]/u,Sv=/[\s\p{P}\p{S}]/u,qS=/[^\s\p{P}\p{S}]/u,mM=It(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Sv).getRegex(),KS=/(?!~)[\p{P}\p{S}]/u,hM=/(?!~)[\s\p{P}\p{S}]/u,pM=/(?:[^\s\p{P}\p{S}]|~)/u,gM=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,VS=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,xM=It(VS,"u").replace(/punct/g,Lm).getRegex(),vM=It(VS,"u").replace(/punct/g,KS).getRegex(),YS="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",yM=It(YS,"gu").replace(/notPunctSpace/g,qS).replace(/punctSpace/g,Sv).replace(/punct/g,Lm).getRegex(),bM=It(YS,"gu").replace(/notPunctSpace/g,pM).replace(/punctSpace/g,hM).replace(/punct/g,KS).getRegex(),wM=It("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,qS).replace(/punctSpace/g,Sv).replace(/punct/g,Lm).getRegex(),jM=It(/\\(punct)/,"gu").replace(/punct/g,Lm).getRegex(),kM=It(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),NM=It(kv).replace("(?:-->|$)","-->").getRegex(),SM=It("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",NM).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Mf=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,CM=It(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Mf).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),QS=It(/^!?\[(label)\]\[(ref)\]/).replace("label",Mf).replace("ref",jv).getRegex(),JS=It(/^!?\[(ref)\](?:\[\])?/).replace("ref",jv).getRegex(),EM=It("reflink|nolink(?!\\()","g").replace("reflink",QS).replace("nolink",JS).getRegex(),Cv={_backpedal:Rc,anyPunctuation:jM,autolink:kM,blockSkip:gM,br:GS,code:uM,del:Rc,emStrongLDelim:xM,emStrongRDelimAst:yM,emStrongRDelimUnd:wM,escape:dM,link:CM,nolink:JS,punctuation:mM,reflink:QS,reflinkSearch:EM,tag:SM,text:fM,url:Rc},$M={...Cv,link:It(/^!?\[(label)\]\((.*?)\)/).replace("label",Mf).getRegex(),reflink:It(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Mf).getRegex()},Jg={...Cv,emStrongRDelimAst:bM,emStrongLDelim:vM,url:It(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},_M={...Jg,br:It(GS).replace("{2,}","*").getRegex(),text:It(Jg.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ku={normal:Nv,gfm:lM,pedantic:cM},pc={normal:Cv,gfm:Jg,breaks:_M,pedantic:$M},TM={"&":"&","<":"<",">":">",'"':""","'":"'"},fk=e=>TM[e];function kr(e,n){if(n){if(Zn.escapeTest.test(e))return e.replace(Zn.escapeReplace,fk)}else if(Zn.escapeTestNoEncode.test(e))return e.replace(Zn.escapeReplaceNoEncode,fk);return e}function mk(e){try{e=encodeURI(e).replace(Zn.percentDecode,"%")}catch{return null}return e}function hk(e,n){var i;const s=e.replace(Zn.findPipe,(c,d,u)=>{let f=!1,g=d;for(;--g>=0&&u[g]==="\\";)f=!f;return f?"|":" |"}),r=s.split(Zn.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(Zn.slashPipe,"|");return r}function gc(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 RM(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 pk(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 AM(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 Pf{constructor(n){Rt(this,"options");Rt(this,"rules");Rt(this,"lexer");this.options=n||Za}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:gc(r,`
|
|
527
|
+
`)}}}fences(n){const s=this.rules.block.fences.exec(n);if(s){const r=s[0],o=AM(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=gc(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:gc(s[0],`
|
|
528
|
+
`)}}blockquote(n){const s=this.rules.block.blockquote.exec(n);if(s){let r=gc(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
|
+
`),b=g.replace(this.rules.other.blockquoteSetextReplace,`
|
|
532
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
|
|
533
|
+
${g}`:g,i=i?`${i}
|
|
534
|
+
${b}`:b;const x=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(b,c,!0),this.lexer.state.top=x,r.length===0)break;const h=c.at(-1);if((h==null?void 0:h.type)==="code")break;if((h==null?void 0:h.type)==="blockquote"){const v=h,y=v.raw+`
|
|
535
|
+
`+r.join(`
|
|
536
|
+
`),j=this.blockquote(y);c[c.length-1]=j,o=o.substring(0,o.length-v.raw.length)+j.raw,i=i.substring(0,i.length-v.text.length)+j.text;break}else if((h==null?void 0:h.type)==="list"){const v=h,y=v.raw+`
|
|
537
|
+
`+r.join(`
|
|
538
|
+
`),j=this.list(y);c[c.length-1]=j,o=o.substring(0,o.length-h.raw.length)+j.raw,i=i.substring(0,i.length-v.raw.length)+j.raw,r=y.substring(c.at(-1).raw.length).split(`
|
|
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="",b="";if(!(s=c.exec(n))||this.rules.block.hr.test(n))break;g=s[0],n=n.substring(g.length);let x=s[2].split(`
|
|
540
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,E=>" ".repeat(3*E.length)),h=n.split(`
|
|
541
|
+
`,1)[0],v=!x.trim(),y=0;if(this.options.pedantic?(y=2,b=x.trimStart()):v?y=s[1].length+1:(y=s[2].search(this.rules.other.nonSpaceChar),y=y>4?1:y,b=x.slice(y),y+=s[1].length),v&&this.rules.other.blankLine.test(h)&&(g+=h+`
|
|
542
|
+
`,n=n.substring(h.length+1),f=!0),!f){const E=this.rules.other.nextBulletRegex(y),S=this.rules.other.hrRegex(y),N=this.rules.other.fencesBeginRegex(y),$=this.rules.other.headingBeginRegex(y),_=this.rules.other.htmlBeginRegex(y);for(;n;){const M=n.split(`
|
|
543
|
+
`,1)[0];let O;if(h=M,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),O=h):O=h.replace(this.rules.other.tabCharGlobal," "),N.test(h)||$.test(h)||_.test(h)||E.test(h)||S.test(h))break;if(O.search(this.rules.other.nonSpaceChar)>=y||!h.trim())b+=`
|
|
544
|
+
`+O.slice(y);else{if(v||x.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(x)||$.test(x)||S.test(x))break;b+=`
|
|
545
|
+
`+h}!v&&!h.trim()&&(v=!0),g+=M+`
|
|
546
|
+
`,n=n.substring(M.length+1),x=O.slice(y)}}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(b),j&&(k=j[0]!=="[ ] ",b=b.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:g,task:!!j,checked:k,loose:!1,text:b,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(x=>x.type==="space"),b=g.length>0&&g.some(x=>this.rules.other.anyLine.test(x.raw));i.loose=b}if(i.loose)for(let f=0;f<i.items.length;f++)i.items[f].loose=!0;return i}}html(n){const s=this.rules.block.html.exec(n);if(s)return{type:"html",block:!0,raw:s[0],pre:s[1]==="pre"||s[1]==="script"||s[1]==="style",text:s[0]}}def(n){const s=this.rules.block.def.exec(n);if(s){const r=s[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),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=hk(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(hk(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=gc(r.slice(0,-1),"\\");if((r.length-c.length)%2===0)return}else{const c=RM(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)),pk(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 pk(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 b=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(b.lastIndex=0,s=s.slice(-1*n.length+c);(o=b.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 x=[...o[0]][0].length,h=n.slice(0,c+o.index+x+u);if(Math.min(c,u)%2){const y=h.slice(1,-1);return{type:"em",raw:h,text:y,tokens:this.lexer.inlineTokens(y)}}const v=h.slice(2,-2);return{type:"strong",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){const s=this.rules.inline.code.exec(n);if(s){let r=s[2].replace(this.rules.other.newLineCharGlobal," ");const 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 Fs{constructor(n){Rt(this,"tokens");Rt(this,"options");Rt(this,"state");Rt(this,"tokenizer");Rt(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||Za,this.options.tokenizer=this.options.tokenizer||new Pf,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:Zn,block:Ku.normal,inline:pc.normal};this.options.pedantic?(s.block=Ku.pedantic,s.inline=pc.pedantic):this.options.gfm&&(s.block=Ku.gfm,this.options.breaks?s.inline=pc.breaks:s.inline=pc.gfm),this.tokenizer.rules=s}static get rules(){return{block:Ku,inline:pc}}static lex(n,s){return new Fs(s).lex(n)}static lexInline(n,s){return new Fs(s).inlineTokens(n)}lex(n){n=n.replace(Zn.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(Zn.tabCharGlobal," ").replace(Zn.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 b;this.options.extensions.startBlock.forEach(x=>{b=x.call({lexer:this},g),typeof b=="number"&&b>=0&&(f=Math.min(f,b))}),f<1/0&&f>=0&&(u=n.substring(0,f+1))}if(this.state.top&&(d=this.tokenizer.paragraph(u))){const f=s.at(-1);r&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=`
|
|
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(x=>(g=x.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 x=s.at(-1);g.type==="text"&&(x==null?void 0:x.type)==="text"?(x.raw+=g.raw,x.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 b=n;if((f=this.options.extensions)!=null&&f.startInline){let x=1/0;const h=n.slice(1);let v;this.options.extensions.startInline.forEach(y=>{v=y.call({lexer:this},h),typeof v=="number"&&v>=0&&(x=Math.min(x,v))}),x<1/0&&x>=0&&(b=n.substring(0,x+1))}if(g=this.tokenizer.inlineText(b)){n=n.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(c=g.raw.slice(-1)),i=!0;const x=s.at(-1);(x==null?void 0:x.type)==="text"?(x.raw+=g.raw,x.text+=g.text):s.push(g);continue}if(n){const x="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(x);break}else throw new Error(x)}}return s}}class Lf{constructor(n){Rt(this,"options");Rt(this,"parser");this.options=n||Za}space(n){return""}code({text:n,lang:s,escaped:r}){var c;const o=(c=(s||"").match(Zn.notSpaceStart))==null?void 0:c[0],i=n.replace(Zn.endingNewline,"")+`
|
|
559
|
+
`;return o?'<pre><code class="language-'+kr(o)+'">'+(r?i:kr(i,!0))+`</code></pre>
|
|
560
|
+
`:"<pre><code>"+(r?i:kr(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+" "+kr(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>${kr(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=mk(n);if(i===null)return o;n=i;let c='<a href="'+n+'"';return s&&(c+=' title="'+kr(s)+'"'),c+=">"+o+"</a>",c}image({href:n,title:s,text:r}){const o=mk(n);if(o===null)return kr(r);n=o;let i=`<img src="${n}" alt="${r}"`;return s&&(i+=` title="${kr(s)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:kr(n.text)}}class Ev{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 Us{constructor(n){Rt(this,"options");Rt(this,"renderer");Rt(this,"textRenderer");this.options=n||Za,this.options.renderer=this.options.renderer||new Lf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ev}static parse(n,s){return new Us(s).parse(n)}static parseInline(n,s){return new Us(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 Ac{constructor(n){Rt(this,"options");Rt(this,"block");this.options=n||Za}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Fs.lex:Fs.lexInline}provideParser(){return this.block?Us.parse:Us.parseInline}}Rt(Ac,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class OM{constructor(...n){Rt(this,"defaults",bv());Rt(this,"options",this.setOptions);Rt(this,"parse",this.parseMarkdown(!0));Rt(this,"parseInline",this.parseMarkdown(!1));Rt(this,"Parser",Us);Rt(this,"Renderer",Lf);Rt(this,"TextRenderer",Ev);Rt(this,"Lexer",Fs);Rt(this,"Tokenizer",Pf);Rt(this,"Hooks",Ac);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 Lf(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 b=u.apply(i,g);return b===!1&&(b=f.apply(i,g)),b||""}}o.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new Pf(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 b=u.apply(i,g);return b===!1&&(b=f.apply(i,g)),b}}o.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new Ac;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];Ac.passThroughHooks.has(c)?i[d]=g=>{if(this.defaults.async)return Promise.resolve(u.call(i,g)).then(x=>f.call(i,x));const b=u.call(i,g);return f.call(i,b)}:i[d]=(...g)=>{let b=u.apply(i,g);return b===!1&&(b=f.apply(i,g)),b}}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 Fs.lex(n,s??this.defaults)}parser(n,s){return Us.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?Fs.lex:Fs.lexInline,f=c.hooks?c.hooks.provideParser():n?Us.parse:Us.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 b=f(g,c);return c.hooks&&(b=c.hooks.postprocess(b)),b}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>"+kr(r.message+"",!0)+"</pre>";return s?Promise.resolve(o):o}if(s)return Promise.reject(r);throw r}}}const Ha=new OM;function Pt(e,n){return Ha.parse(e,n)}Pt.options=Pt.setOptions=function(e){return Ha.setOptions(e),Pt.defaults=Ha.defaults,US(Pt.defaults),Pt};Pt.getDefaults=bv;Pt.defaults=Za;Pt.use=function(...e){return Ha.use(...e),Pt.defaults=Ha.defaults,US(Pt.defaults),Pt};Pt.walkTokens=function(e,n){return Ha.walkTokens(e,n)};Pt.parseInline=Ha.parseInline;Pt.Parser=Us;Pt.parser=Us.parse;Pt.Renderer=Lf;Pt.TextRenderer=Ev;Pt.Lexer=Fs;Pt.lexer=Fs.lex;Pt.Tokenizer=Pf;Pt.Hooks=Ac;Pt.parse=Pt;Pt.options;Pt.setOptions;Pt.use;Pt.walkTokens;Pt.parseInline;Us.parse;Fs.lex;let xc;const MM=e=>(xc||(vf.addHook("uponSanitizeElement",(n,s)=>{xc??(xc=s.allowedTags)}),vf.sanitize("<b></b>"),vf.removeHook("uponSanitizeElement")),(xc==null?void 0:xc[e.toLowerCase()])===!0),PM=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)=>MM(i)?(s++,o):PM(o));return n&&!s&&r!==e?`<p>${r.trim().replace(/\n/g,`<br>
|
|
579
|
+
`)}</p>
|
|
580
|
+
`:r}}});const na=e=>e.slice(-8),md=e=>new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),ht=e=>new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function il(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const XS=e=>e.basis==="estimate",to=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,If=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")}`},kl=e=>e&&e.usd===null&&typeof e.so_far_usd=="number"&&typeof e.unpriced=="number"?e:void 0,gk=(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.`,LM=new Set(["completed","failed","cancelled"]),Ba=e=>typeof e=="string"&&LM.has(e),IM="$0 · free model",ZS=e=>e.usd===0&&e.free===!0,e2=e=>e.upper_bound===!0?"at most ":"",zM=(e,{ended:n=!1}={})=>e.usd!==null?`${e2(e)}${to(e.usd)}`:typeof e.so_far_usd=="number"?n?`${If(e.so_far_usd)} known, ${e.unpriced??0} not priced`:`so far ${If(e.so_far_usd)}, ${e.unpriced??0} not priced`:"not priced";function no(e,{ended:n=!1}={}){const s=hd(e);if(s&&(e==null?void 0:e.usd)===0)return`${t2(s.tokens)} tokens · Using ChatGPT plan`;const r=DM(e,n);return s?`${r} + ChatGPT plan`:r}function DM(e,n){const s=kl(e),r=o=>XS(o)?" est.":"";return s?n?`${If(s.so_far_usd)}${r(s)} known · ${s.unpriced} not priced`:`so far ${If(s.so_far_usd)}${r(s)} · ${s.unpriced} not priced`:!e||e.usd===null?"Unknown":ZS(e)?IM:`${e2(e)}${to(e.usd)}${r(e)}`}const hd=e=>e!=null&&e.plan&&e.plan.requests>0?e.plan:void 0;function t2(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 xk(e,n,{ended:s=!1,text:r}={}){const o=r??no(e,{ended:s});return typeof n!="number"?o:(r!==void 0?FM.test(r):!kl(e)&&!hd(e)&&!!e&&e.usd!==null&&!ZS(e))?`${o} of ${vk(n)}`:`${o} · cap ${vk(n)}`}const FM=/^<?\$[\d.,]+( est\.)?$/;function vk(e){for(let n=2;n<8;n++)if(Number(e.toFixed(n))===e)return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}function UM(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 so(e,n){const s=vf.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&&UM(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 $v=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))},WM=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 Sn(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()||WM(n.slice(s))}function HM(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 n2=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,s2=e=>e.refused===!0,r2=e=>e.tool_status==="failed"&&!s2(e)||e.kind==="error",BM=e=>e.paused===!0;function GM(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 b;const x=f.kind==="tool_use"&&f.tool_use_id?n.get(f.tool_use_id):void 0;if(x){const h=x.tool_status!=="failed",v=[f.tool_input_preview,x.tool_result_preview].filter(Boolean),y=x.tool_status!==null;b={row:{...x,id:f.id,seq:f.seq,timestamp:f.timestamp,summary:h?(x.summary??"").replace(/:\s*ok$/i,""):x.summary,...f.usage?{usage:f.usage}:{}},...y?{ms:Math.max(0,Date.parse(x.timestamp)-Date.parse(f.timestamp))}:{},detail:v.length===2?`${v[0]}
|
|
581
|
+
|
|
582
|
+
→ ${v[1]}`:v[0]??null}}else b={row:f};c.push(b),f.kind==="tool_use"&&f.tool_use_id&&d.set(f.tool_use_id,b),u=b}return i&&c.push({row:i}),c}class Fe extends Error{constructor(s,r,o,i=!1,c){super(o);Rt(this,"fields");Rt(this,"retryAfterMs");Rt(this,"details");Rt(this,"problems");this.status=s,this.code=r,this.retryable=i,this.requestId=c,this.name="ClientError"}toApiError(){return{code:this.code,message:this.message,retryable:this.retryable,request_id:this.requestId,...this.details?{details:this.details}:{}}}}const Ut=e=>e instanceof Fe?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),yk=(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}`},qM=new Set(["/auth/sign-in","/setup"]);function KM({fetch:e=globalThis.fetch.bind(globalThis),base:n="/v2",onSignedOut:s}={}){async function r(v,y,j={}){return(await o(v,y,j)).body}async function o(v,y,{body:j,headers:k={},signal:E,text:S=!1}={}){var M;const N=j!==void 0||v!=="GET"&&v!=="HEAD",$=await e(`${n}${y}`,{method:v,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&&!qM.has(y)&&(s==null||s());const O=(M=await $.json().catch(()=>null))==null?void 0:M.error,L=new Fe($.status,(O==null?void 0:O.code)??"http_error",(O==null?void 0:O.message)??`${v} ${y}: ${$.status}`,(O==null?void 0:O.retryable)??!1,O==null?void 0:O.request_id);throw O!=null&&O.fields&&(L.fields=O.fields),typeof(O==null?void 0:O.retry_after_ms)=="number"&&(L.retryAfterMs=O.retry_after_ms),O!=null&&O.details&&typeof O.details=="object"&&!Array.isArray(O.details)&&(L.details=O.details),Array.isArray(O==null?void 0:O.problems)&&(L.problems=O.problems),L}return{body:!S&&($.headers.get("content-type")??"").includes("json")?await $.json():await $.text(),etag:$.headers.get("etag"),status:$.status}}const i=v=>`/agents/${encodeURIComponent(v)}`,c=v=>`/runs/${encodeURIComponent(v)}`,d=(v,y,j)=>`${i(v)}/learning/workflows/${encodeURIComponent(y)}/revisions/${encodeURIComponent(j)}/replays`,u=v=>`/settings/mcp-servers/${encodeURIComponent(v)}`,f=v=>`/triggers/${encodeURIComponent(v)}`,g=new Map,b=(v,y)=>`${i(v)}/learning/files/${encodeURIComponent(y)}`,x=v=>({note:v.body,etag:v.etag}),h={accept:"text/markdown, application/json"};return{capabilities:()=>r("GET","/capabilities"),session:()=>o("GET","/auth/session").then(v=>({status:v.status,body:v.body})),signIn:v=>r("POST","/auth/sign-in",{body:{password:v}}),setup:(v,y,j=!1)=>r("POST","/setup",{body:{password:v,...y?{code:y}:{},...j?{import:!0}:{}}}),setupImport:()=>r("GET","/setup/import").then(v=>(v==null?void 0:v.offer)===!1?null:v,v=>{if(v instanceof Fe&&(v.status===404||v.status===403))return null;throw v}),signOut:()=>r("POST","/auth/sign-out",{body:{}}),signOutEverywhere:()=>r("POST","/auth/sign-out-everywhere",{body:{}}),stats:()=>r("GET","/stats"),listRuns:(v=50,y,j)=>r("GET",`/runs${yk(v,y,j)}`),listAgentRuns:(v,y=50,j,k={})=>r("GET",`${i(v)}/runs${yk(y,j,typeof k=="boolean"?{archived:k}:k)}`),discoverNative:(v,y)=>r("POST","/native/discover",{body:{project:v,...y?{runtime:y}:{}}}),connectNative:v=>r("POST","/native/connect",{body:v}),getNative:v=>r("GET",`${i(v)}/native`),verifyNative:v=>r("POST",`${i(v)}/native/verify`,{body:{}}),disconnectNative:v=>r("POST",`${i(v)}/native/disconnect`,{body:{}}),observations:({days:v=30,sessionId:y}={},j)=>{const k=new URLSearchParams({days:String(v)});return y&&k.set("session_id",y),r("GET",`/observations?${k}`,{signal:j})},listConnectors:()=>r("GET","/connectors"),enrollConnector:(v,y)=>r("POST","/connectors/enrollment",{body:{...v!=null&&v.trim()?{label:v.trim()}:{},...y?{capabilities:y}:{}}}),revokeConnector:v=>r("DELETE",`/connectors/${encodeURIComponent(v)}`),listAgents:({archived:v=!1,cursor:y}={})=>{const j=new URLSearchParams;return v&&j.set("archived","true"),y&&j.set("cursor",y),r("GET",`/agents${j.size?`?${j}`:""}`)},getAgent:async v=>{const y=await o("GET",i(v)),j=g.get(v);return{agent:j&&j.revision===y.body.revision&&!y.body.warnings?{...y.body,warnings:j.warnings}:y.body,etag:y.etag}},createAgent:async v=>{var j;const y=await r("POST","/agents",{body:v});return(j=y.warnings)!=null&&j.length&&g.set(y.agent_id,{revision:y.revision,warnings:y.warnings}),y},updateDefinition:async(v,y,j)=>{const k=await o("PUT",`${i(v)}/definition`,{body:y,headers:j?{"if-match":j}:{}});return g.delete(v),{agent:k.body,etag:k.etag}},listRevisions:(v,y)=>r("GET",`${i(v)}/revisions${y?`?cursor=${encodeURIComponent(y)}`:""}`),setCurrent:async(v,y)=>{const j=await r("POST",`${i(v)}/current`,{body:{revision:y}});return g.delete(v),j},archiveAgent:v=>r("POST",`${i(v)}/archive`,{body:{}}),unarchiveAgent:v=>r("POST",`${i(v)}/unarchive`,{body:{}}),agentLearning:v=>r("GET",`${i(v)}/learning`),learningCost:(v,y)=>r("GET",`${i(v)}/learning/cost${y?`?limit=${y}`:""}`),learningBatches:v=>r("GET",`${i(v)}/learning/batches`),learningBatch:(v,y)=>r("GET",`${i(v)}/learning/batches/${encodeURIComponent(y)}`),startLearningBatch:(v,y)=>r("POST",`${i(v)}/learning/batches`,{body:y}),cancelLearningBatch:(v,y)=>r("POST",`${i(v)}/learning/batches/${encodeURIComponent(y)}/cancel`,{body:{}}),learningEvals:v=>r("GET",`${i(v)}/learning/evals`),learningPromotions:v=>r("GET",`${i(v)}/learning/promotions`),learningLoop:v=>r("GET",`${i(v)}/learning/loop`),learnedWorkflowRevisions:(v,y,j)=>r("GET",`${i(v)}/learning/workflows/${encodeURIComponent(y)}/revisions${j?`?limit=${j}`:""}`),startLearnedWorkflowReplay:(v,y,j)=>r("POST",`${d(v,y,j)}`,{body:{}}),learnedWorkflowReplay:(v,y,j,k)=>r("GET",`${d(v,y,j)}/${encodeURIComponent(k)}`),learningNotes:(v,y)=>r("GET",`${i(v)}/learning/notes?cursor=${encodeURIComponent(y)}`),learningLog:(v,y)=>r("GET",`${i(v)}/learning/log?cursor=${encodeURIComponent(y)}`),readNote:async(v,y)=>x(await o("GET",b(v,y),{headers:h,text:!0})),writeNote:async(v,y,j,k)=>x(await o("PUT",b(v,y),{body:{text:j},headers:{...h,..."etag"in k?{"if-match":k.etag}:{"if-none-match":"*"}},text:!0})),retireNote:async(v,y,j)=>x(await o("POST",`${b(v,y)}/retire`,{body:{},headers:{...h,"if-match":j},text:!0})),approveNote:async(v,y,j)=>x(await o("POST",`${b(v,y)}/approve`,{body:{},headers:{...h,"if-match":j},text:!0})),restoreNote:async(v,y,j)=>x(await o("POST",`${b(v,y)}/restore`,{body:{},headers:{...h,"if-match":j},text:!0})),forgetSignIn:(v,y)=>r("DELETE",`${i(v)}/sign-ins/${encodeURIComponent(y)}`),promoteWorkflow:async(v,y,j)=>{var E;const k=await r("POST",`${i(v)}/learning/workflows/${encodeURIComponent(y)}/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:v=>r("GET",c(v)),runLearningResult:v=>r("GET",`${c(v)}/learning`),runLearningDiff:v=>r("GET",`${c(v)}/learning/diff`),runLearning:v=>r("GET",`${c(v)}/learning`),runComputer:v=>r("GET",`${c(v)}/computer`),takeOverComputer:v=>r("POST",`${c(v)}/computer/take-over`,{body:{}}),handBackComputer:(v,y)=>r("POST",`${c(v)}/computer/hand-back`,{body:y?{outcome:y}:{}}),archiveRun:v=>r("POST",`${c(v)}/archive`,{body:{}}),unarchiveRun:v=>r("POST",`${c(v)}/unarchive`,{body:{}}),raiseCap:(v,y)=>r("PATCH",c(v),{body:{max_cost_usd:y}}),gradeRun:(v,y)=>r("PUT",`${c(v)}/grade`,{body:y}),startRun:async(v,y,j)=>{const k=await o("POST",`${i(v)}/runs`,{body:y,headers:{"idempotency-key":j}});return{run:k.body,status:k.status}},getTimeline:(v,{after:y,waitMs:j,signal:k}={})=>{const E=new URLSearchParams;return y!==void 0&&E.set("after",String(y)),j!==void 0&&E.set("wait_ms",String(j)),r("GET",`${c(v)}/timeline${E.size?`?${E}`:""}`,{signal:k})},listFiles:v=>r("GET",`${c(v)}/files`),deleteUpload:v=>r("DELETE",`/files/${encodeURIComponent(v)}`),readFile:(v,y)=>r("GET",`${c(v)}/files/${y.split("/").map(encodeURIComponent).join("/")}`,{text:!0}),sendMessage:(v,y,j)=>r("POST",`${c(v)}/messages`,{body:{content:y},headers:{"idempotency-key":j}}),getRunGraph:(v,y)=>r("GET",`${c(v)}/graph`,{signal:y}),pauseRun:v=>r("POST",`${c(v)}/pause`,{body:{}}),resumeRun:v=>r("POST",`${c(v)}/resume`,{body:{}}),validateWorkflow:(v,y)=>r("POST","/workflows/validate",{body:v,signal:y}),statsOver:({from:v,agent:y})=>{const j=new URLSearchParams;return v&&j.set("from",v),y&&j.set("agent",y),r("GET",`/stats${j.size?`?${j}`:""}`)},fileUrl:(v,y)=>`${n}${c(v)}/files/${y.split("/").map(encodeURIComponent).join("/")}`,listToolKeys:()=>r("GET","/settings/tool-keys"),saveToolKey:(v,y)=>r("PUT",`/settings/tool-keys/${encodeURIComponent(v)}`,{body:{values:y}}),removeToolKey:v=>r("DELETE",`/settings/tool-keys/${encodeURIComponent(v)}`),chatGPT:()=>r("GET","/settings/chatgpt"),startChatGPT:()=>r("POST","/settings/chatgpt/sign-in"),finishChatGPT:v=>r("POST","/settings/chatgpt/sign-in/finish",{body:{redirect_url:v}}),signOutChatGPT:()=>r("DELETE","/settings/chatgpt"),computers:()=>r("GET","/computers"),saveComputerKeys:(v,y)=>r("PUT",`/computers/${encodeURIComponent(v)}/keys`,{body:y}),testComputer:v=>r("POST",`/computers/${encodeURIComponent(v)}/test`),computerChoices:v=>r("GET",`/computers/${encodeURIComponent(v)}/choices`),createPairing:()=>r("POST","/computers/pairings"),removeComputer:v=>r("DELETE",`/computers/${encodeURIComponent(v)}`),archil:()=>r("GET","/workspace/archil"),saveArchil:v=>r("PUT","/workspace/archil",{body:v}),archilOff:()=>r("DELETE","/workspace/archil"),testArchil:()=>r("POST","/workspace/archil/test"),webhook:()=>r("GET","/settings/webhook"),saveWebhook:v=>r("PUT","/settings/webhook",{body:{url:v}}),removeWebhook:()=>r("DELETE","/settings/webhook"),testWebhook:()=>r("POST","/settings/webhook/test",{body:{}}),emailAccount:()=>r("GET","/settings/email"),saveEmailAccount:v=>r("PUT","/settings/email",{body:v}),removeEmailAccount:()=>r("DELETE","/settings/email"),testEmailAccount:(v={})=>r("POST","/settings/email/test",{body:v}),listTriggers:()=>r("GET","/triggers"),getTrigger:v=>r("GET",f(v)),createTrigger:(v,y)=>r("POST","/triggers",{body:v,headers:{"idempotency-key":y}}),rotateTriggerSecret:v=>r("POST",`${f(v)}/secret`),updateTrigger:(v,y)=>r("PATCH",f(v),{body:y}),deleteTrigger:v=>r("DELETE",f(v)),fireTrigger:(v,y)=>r("POST",`${f(v)}/fire`,{body:{},headers:{"idempotency-key":y}}),triggerFirings:v=>r("GET",`${f(v)}/firings`),webhookDeliveries:()=>r("GET","/settings/webhook/deliveries"),redeliverWebhook:v=>r("POST",`/settings/webhook/deliveries/${encodeURIComponent(v)}/redeliver`,{body:{}}),listTemplates:()=>r("GET","/templates"),applyTemplate:(v,y,j)=>r("POST",`/templates/${encodeURIComponent(v)}/apply`,{body:y,headers:{"idempotency-key":j}}),importTemplate:(v,y={})=>r("POST","/templates/import",{body:{source:v,...y.dryRun?{dry_run:!0}:{},...y.trustPublisher?{trust_publisher:!0}:{}}}),deleteTemplate:v=>r("DELETE",`/templates/${encodeURIComponent(v)}`),listMcpServers:()=>r("GET","/settings/mcp-servers"),previewMcpServer:(v,y,j)=>r("POST","/settings/mcp-servers/preview",{body:{url:v,auth:y,...j?{name:j}:{}}}),saveMcpServer:(v,y,j,k={})=>r("PUT",u(v),{body:{url:y,auth:j,...k}}),composioTools:(v,y)=>r("POST","/settings/mcp-servers/composio/tools",{body:{api_key:v,toolkit:y}}),saveComposioServer:(v,y,j,k)=>r("PUT",`${u(v)}/composio`,{body:{api_key:y,toolkit:j,tools:k}}),refreshMcpServer:v=>r("POST",`${u(v)}/refresh`,{body:{}}),deleteMcpServer:v=>r("DELETE",u(v)),composioEvents:v=>r("GET",`${u(v)}/composio/events`),composioTriggers:v=>r("GET",`${u(v)}/composio/triggers`),rotateComposioSecret:v=>r("POST",`${u(v)}/composio/rotate-secret`,{body:{}}),deleteComposioSubscription:v=>r("DELETE",`${u(v)}/composio/subscription`),startMcpSignIn:(v,y)=>r("POST",`${u(v)}/oauth/start`,{body:y}),mcpPrivateHosts:()=>r("GET","/settings/mcp-servers/oauth/private-hosts"),saveMcpPrivateHosts:v=>r("PUT","/settings/mcp-servers/oauth/private-hosts",{body:{hosts:v}}),githubConnection:()=>r("GET","/integrations/github"),connectGitHub:v=>r("POST","/integrations/github/connect",{body:v?{org:v}:{}}),disconnectGitHub:()=>r("DELETE","/integrations/github"),toolSettings:()=>r("GET","/settings/tools"),saveToolSettings:v=>r("PUT","/settings/tools",{body:v}),stop:v=>r("POST",`${c(v)}/stop`,{body:{}}),answerApproval:(v,y,j,k,E)=>r("POST",`${c(v)}/approvals/${encodeURIComponent(y)}`,{body:{decision:j,...k?{note:k}:{},...E?{confirm_destructive:!0}:{}}}),cancel:v=>r("POST",`${c(v)}/cancel`,{body:{}})}}async function Vr(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 o2(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(x=>{if(o!=null&&o.aborted)return null;throw x});if(!g||o!=null&&o.aborted||(f=g,s&&(d=HM(d,g)),r==null||r(g),s==null||s(d),g.final&&!g.has_more))break;u=g.next_after;const b=Math.max(c,g.unchanged?g.poll_after_ms??0:0);b&&await new Promise(x=>setTimeout(x,b))}return f}const bk=e=>`#/observations/${encodeURIComponent(e)}`,zf=e=>e==="claude"?"Claude Code":e==="codex"?"Codex":e;function Ea(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 Xg=e=>{const n=Ea(e);return n==="Running"?"success":["Needs input","Disconnected","Failed"].includes(n)?"warning":"muted"},$a=e=>e==null?"—":e.toLocaleString("en-US");function _v(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,b]=p.useState(!1);return p.useEffect(()=>{i(null),d(null)},[e,n,s,r]),p.useEffect(()=>{let x=!0;if(!n||typeof e.observations!="function"){b(!1);return}let h=null,v,y;const j=async()=>{if(!x||h)return;clearTimeout(v);const E=h=new AbortController,S=()=>x&&h===E;b(!0);const N=()=>{clearTimeout($),S()&&(h=null,y=void 0,b(!1),clearTimeout(v),v=setTimeout(k,15e3))},$=y=setTimeout(()=>{S()&&(d("The observation read timed out. Try refreshing again."),E.abort(),N())},3e4);try{const _=await e.observations({days:s,sessionId:r},E.signal);S()&&(i(_),d(null))}catch(_){S()&&(_ instanceof Fe&&_.status===404?(i(null),d(null)):d(Ut(_)))}finally{N()}},k=()=>{!x||h||(document.hidden?(clearTimeout(v),v=setTimeout(k,15e3)):j())};return j(),window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{x=!1,clearTimeout(v),clearTimeout(y),h==null||h.abort(),h=null,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[e,n,s,r,u]),{data:o,error:c,loading:g,refresh:()=>f(x=>x+1)}}function Tv({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(Yx,{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(Jo,{className:"size-4","aria-hidden":!0})})]}),d&&t.jsx(vt,{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(vt,{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=>Ea(f)==="Running").length],["Needs input",u.filter(f=>Ea(f)==="Needs input").length],["Disconnected",u.filter(f=>Ea(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(a2,{usage:o.usage}),t.jsx(VM,{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:bk(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(fr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(ke,{children:zf(f.harness)}),t.jsx(ke,{tone:Xg(f),children:Ea(f)}),t.jsx(ke,{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 ",ht(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(ke,{tone:Xg(f),children:Ea(f)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("a",{href:bk(f.id),className:"inline-flex items-center gap-1 underline underline-offset-2",children:[f.display_name,t.jsx(fr,{className:"size-3 shrink-0","aria-hidden":!0})]})}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:zf(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"?"—":$a(f.usage.total_tokens)}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:ht(f.received_at)})]},f.id))})]})}):t.jsx("p",{className:"text-body text-muted-foreground",children:"No observed session matches."})]})}function a2({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",$a(e.input_tokens)],["Output",$a(e.output_tokens)],["Cache writes",$a(e.cache_write_tokens)],["Cache reads",$a(e.cache_read_tokens)],["Total tokens",$a(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 VM({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:$a(s)},r))]},n.model))})]})}):null}function YM({v2:e,sessionId:n,go:s}){var i;const r=_v(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:"flex min-h-12 flex-wrap items-center gap-2 border-b px-5 py-2",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>s("#/agents"),children:t.jsx(Rn,{"aria-hidden":!0})}),t.jsx(Yx,{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(Jo,{"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(vt,{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(ke,{tone:"muted",children:"Observed"}),t.jsx(ke,{tone:Xg(o),children:Ea(o)}),t.jsx(ke,{children:zf(o.harness)})]})]}),t.jsx(vt,{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",zf(o.harness)],["Model",o.models.join(", ")||"Not reported"],["Connection",o.connection_state],["Last reported activity",o.reported_activity],["First seen",ht(o.created_at)],["Last received",ht(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(a2,{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 Rv(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 Yt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),QM=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),Zg=128,JM=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},ex=(e,n=0)=>n>Zg?'"…"':Array.isArray(e)?`[${e.map(s=>ex(s,n+1)).join(",")}]`:Yt(e)?`{${Object.keys(e).filter(s=>e[s]!==void 0).sort().map(s=>`${JSON.stringify(s)}:${ex(e[s],n+1)}`).join(",")}}`:JM(e),XM=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")},vc=(e,n)=>Object.fromEntries(Object.entries(e).filter(([s])=>s!==n)),ZM=e=>{switch(e.node){case"chain":return vc(e,"steps");case"parallel":return vc(e,"branches");case"map":case"loop":return vc(e,"body");case"route":return Yt(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([n,s])=>[n,Yt(s)?vc(s,"body"):s]))}:e;case"workflow":return Yt(e.workflow)?{...e,workflow:vc(e.workflow,"root")}:e;default:return e}};function ll(e){const n=[],s=[],r=(o,i,c,d)=>{if(!Yt(o)||typeof o.node!="string"||c>Zg)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:XM(ex(ZM(o))),...tP(o,d)});const u=(f,g,b,x=i,h=d)=>{!Yt(f)||typeof f.node!="string"||c+1>Zg||(s.push({from:x,to:g,kind:b}),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(Yt(o.branches))for(const[f,g]of Object.entries(o.branches))Yt(g)&&u(g.body,`${i}/branches/${QM(f)}/body`,"route");break;case"workflow":Yt(o.workflow)&&u(o.workflow.root,`${i}/workflow/root`,"child",i,Yt(o.workflow.schemas)?o.workflow.schemas:{});break}};return r(Yt(e)?e.root:void 0,"/root",0,Yt(e)&&Yt(e.schemas)?e.schemas:{}),{nodes:n,edges:s}}const eP=(e,n)=>{const s=typeof e=="string"&&Object.hasOwn(n,e)?n[e]:void 0,r=i=>{var c;for(let d=0;Yt(i)&&typeof i.$ref=="string"&&d<8;d+=1){const u=(c=/^#\/definitions\/(.+)$/.exec(i.$ref))==null?void 0:c[1],f=Yt(s)&&Yt(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!Yt(o)||!Yt(o.properties)?[]:Object.entries(o.properties).map(([i,c])=>{const d=r(c),u=Yt(d)&&typeof d.description=="string"?d.description:"",f=Yt(d)?(Array.isArray(d.type)?d.type:[d.type]).filter(g=>g!=="null"):[];return Yt(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}})},tP=(e,n)=>{let s=e,r;const o=i=>typeof i=="string"?i:"";switch(e.node){case"judge":case"sift":r=eP(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:Yt(e.branches)?Object.keys(e.branches):[]}];break;case"loop":case"escalate":{const i=e.node==="loop"?e.until:e.when;if(!Yt(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,...Yt(s.images)&&Object.keys(s.images).length?{images:Object.keys(s.images)}:{}}};function i2(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 b=new Map(e.nodes.map(S=>[S.path,S])),x=[];for(const S of n.nodes){const N=b.get(S.path);d.has(S.path)||N===void 0||u.has(N.path)||(f(N.path,S.path),(N.kind!==S.kind||N.label!==S.label)&&x.push({prev:N.path,next:S.path,was:{kind:N.kind,label:N.label},now:{kind:S.kind,label:S.label}}))}const h=[];for(const S of n.nodes){const N=d.get(S.path),$=N===void 0?void 0:b.get(N);$===void 0||$.kind!==S.kind||$.label!==S.label||$.changeCheck!==void 0&&S.changeCheck!==void 0&&$.changeCheck!==S.changeCheck&&h.push({prev:$.path,next:S.path,kind:S.kind,label:S.label})}const v=({path:S,kind:N,label:$})=>({path:S,kind:N,label:$}),y=(S,N,$)=>JSON.stringify([S,N,$]),j=new Set(e.edges.map(S=>y(S.from,S.to,S.kind))),k=new Set(n.edges.map(S=>y(S.from,S.to,S.kind))),E=(S,N,$)=>{const[_,M]=[N.get(S.from),N.get(S.to)];return _!==void 0&&M!==void 0&&$.has(y(_,M,S.kind))};return{added:n.nodes.filter(S=>!d.has(S.path)).map(v),removed:e.nodes.filter(S=>!u.has(S.path)).map(v),changed:x,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 pn({className:e}){return t.jsx("span",{"aria-hidden":!0,className:ae("block bg-muted motion-safe:animate-pulse",e)})}function Im({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 nP(){return t.jsxs(Im,{label:"Loading Mission Control",className:"space-y-8 p-5 md:p-8",children:[t.jsx(pn,{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(pn,{className:"h-3 w-16"}),t.jsx(pn,{className:"mt-3 h-6 w-12"})]},n))}),t.jsx(pn,{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(Df,{n:4}),t.jsx(Df,{n:6})]})]})}function Df({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(pn,{className:"h-4 w-20"}),t.jsx(pn,{className:"h-4 flex-1"}),t.jsx(pn,{className:"hidden h-4 w-24 sm:block"})]},s))})}function Un({label:e,rows:n=8}){return t.jsx(Im,{label:e,children:t.jsx(Df,{n})})}function sP(){return t.jsxs(Im,{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(pn,{className:"h-4 w-24"}),t.jsx(pn,{className:"h-7 w-2/3"}),t.jsx(pn,{className:"h-3 w-1/3"})]}),t.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,n)=>t.jsx(pn,{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(pn,{className:"size-4 shrink-0"}),t.jsx(pn,{className:ae("h-4",n%2?"w-1/2":"w-3/4")})]},n))})]})}function rP(){return t.jsxs(Im,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(pn,{className:"h-7 w-64"}),t.jsx(pn,{className:"h-3 w-80 max-w-full"})]}),t.jsx(pn,{className:"h-12 w-full"}),t.jsx(Df,{n:5})]})}function Qt({problem:e,onRetry:n,link:s,className:r="m-8"}){return t.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${r}`,role:"alert",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-prose font-semibold",children:e.title}),t.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&t.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),(n||s)&&t.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[n&&t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"}),s&&t.jsx("a",{href:s.href,className:"caps border px-3 py-2 text-small hover:bg-accent",children:s.label})]})]})]})}function l2({what:e,id:n,list:s}){return t.jsx(Qt,{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 tx extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const nx=e=>Math.min(1e4,1e3*2**e),wk=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),oP=e=>(e==null?void 0:e.name)==="AbortError",jk=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function aP({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 b=N=>{o=N;for(const $ of[...i])$()},x=N=>{const $=nx(N);clearTimeout(u),b({state:"offline",attempt:N,retryAt:Date.now()+$}),u=setTimeout(()=>void j(),$)},h=()=>{o.state!=="offline"&&x(0)},v=()=>{if(o.state!=="offline")return;clearTimeout(u),b({state:"resumed"});const N=d;d=[];for(const $ of N)$();for(const $ of[...c])$();u=setTimeout(()=>{o.state==="resumed"&&b({state:"online"})},s)};async function y(N){const $=setTimeout(()=>N.abort(),r);try{return!wk(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 y(N);f===N&&(f=null,o.state==="offline"&&($?v():x(o.attempt+1)))}const k=()=>g??(g=y(new AbortController).finally(()=>{g=null})),E=N=>new Promise(($,_)=>{if(N!=null&&N.aborted)return _(jk(N));const M=()=>{d=d.filter(L=>L!==O),_(jk(N))},O=()=>{N==null||N.removeEventListener("abort",M),$()};d.push(O),N==null||N.addEventListener("abort",M,{once:!0})});return{fetch:async(N,$)=>{var O;const _=(($==null?void 0:$.method)??"GET").toUpperCase(),M=_==="GET"||_==="HEAD";for(let L=0;;L++){let A,R;try{A=await e(N,$)}catch(P){if((O=$==null?void 0:$.signal)!=null&&O.aborted||oP(P))throw P;R=P}if(A&&!wk(A))return v(),A;if(o.state!=="offline"&&await k()){if(A)return A;if(!M)throw new tx;if(L>=2)throw R;await new Promise(P=>setTimeout(P,nx(L)));continue}if(h(),!M)throw new tx;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 iP=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),c2=e=>e instanceof tx||e instanceof TypeError&&/fetch|network/i.test(e.message);function Wt(e,n){const s=`${iP(n)} could not be read.`;if(c2(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof Fe))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 lP(e){return c2(e)?"Can't reach agentrun-serve":e instanceof Fe?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}function cP({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,b]=p.useState(null),x=p.useRef(0),h=p.useRef(!1),v=async y=>{if(h.current)return;h.current=!0;const j=++x.current;f(!0);try{const k=await n.listRevisions(e.agent_id,y);if(j!==x.current)return;r(E=>{const S=new Map((y?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===x.current&&d(Wt(k,y?"more versions":"the versions"))}finally{j===x.current&&(h.current=!1,f(!1))}};return p.useEffect(()=>(h.current=!1,r(null),i(null),d(null),b(null),v(null),()=>{x.current++,h.current=!1}),[n,e.agent_id,e.revision,e.revisions]),c&&!s?t.jsx(Qt,{problem:c,onRetry:()=>void v(null),className:""}):s?t.jsxs("section",{className:"overflow-hidden border","aria-label":"Agent versions",children:[t.jsxs("div",{className:"border-b px-4 py-3 text-body text-muted-foreground",children:[e.revisions," ",e.revisions===1?"version":"versions"," · Current version ",e.definition.version]}),s.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Versions",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Version","Created","Note","Configuration"].map(y=>t.jsx("th",{className:"px-4 py-3 font-semibold",children:y},y))})}),t.jsx("tbody",{children:s.map(y=>t.jsxs(p.Fragment,{children:[t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsxs("td",{className:"whitespace-nowrap px-4 py-3",children:[t.jsxs("span",{className:"font-semibold",children:["v",y.version]}),y.revision===e.revision&&t.jsx("span",{className:"ml-2 bg-primary/10 px-2 py-1 text-micro text-primary-text",children:"Current"})]}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:ht(y.created_at)}),t.jsx("td",{className:"min-w-40 px-4 py-3 text-muted-foreground",children:y.note||"—"}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(B,{size:"sm","aria-expanded":g===y.revision,"aria-label":`View configuration for version ${y.version}`,onClick:()=>b(j=>j===y.revision?null:y.revision),children:g===y.revision?"Hide":"View"})})]}),g===y.revision&&t.jsx("tr",{className:"border-b bg-card",children:t.jsxs("td",{colSpan:4,className:"p-4",children:[t.jsx("p",{className:"mb-3 break-all font-mono text-label text-muted-foreground",children:y.revision}),t.jsx("pre",{"aria-label":`Version ${y.version} configuration`,className:"max-h-[520px] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:JSON.stringify(y.definition,null,2)})]})})]},y.revision))})]})}):t.jsx("p",{className:"p-10 text-center text-body text-muted-foreground",children:"No versions were returned for this agent."}),c&&t.jsx(Qt,{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 v(o),children:u?"Loading":"Load more versions"})})]}):t.jsx(Un,{label:"Loading versions",rows:4})}const d2=(e,n)=>e.name.localeCompare(n.name,void 0,{sensitivity:"base",numeric:!0})||(e.id<n.id?-1:e.id>n.id?1:0),Nl=e=>[...e].sort((n,s)=>d2({name:n.definition.name||n.agent_id,id:n.agent_id},{name:s.definition.name||s.agent_id,id:s.agent_id}));function dP(e){return e.usd===null?{total:"Unknown"}:{total:no({usd:e.usd,basis:"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}const Av=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],Yi=864e5,sx=e=>Math.floor(e/Yi)*Yi;function Ov(e,n=Date.now()){var r;const s=(r=Av.find(o=>o.id===e))==null?void 0:r.days;return s?new Date(sx(n)-(s-1)*Yi).toISOString():void 0}const u2=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function uP(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 fP(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 f2=(e,n)=>dP({usd:e.cost_usd,unknownRuns:e.unknown_cost_runs}),Mv=e=>e.runs_with_metrics<e.runs?`tokens from ${e.runs_with_metrics} of ${e.runs} runs`:void 0;function Ga(e){return e===null?"Unknown":t2(e)}const Ff=e=>e===null?"—":`${Math.round(e*100)}%`;function kk(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function mP(e,n,s=Date.now()){if(!e.length)return[];const r=sx(s),o=Math.max(r-29*Yi,n?sx(Date.parse(n)):r-29*Yi),i=new Map(e.map(d=>[d.day,d])),c=[];for(let d=o;d<=r;d+=Yi){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 hP(e,n){return{agents:e.agents,runs:{total:e.runs.total,active:e.runs.active,needsInput:e.runs.needs_input,failed:e.runs.failed,statusUnknown:e.runs.status_unknown,needsReview:e.runs.needs_review},perAgent:e.per_agent.map(s=>({agentId:s.agent_id,name:s.name,runs:s.runs})).sort((s,r)=>d2({name:s.name,id:s.agentId},{name:r.name,id:r.agentId})),cost:{usd:e.cost.usd,basis:e.cost.basis,unknownRuns:e.cost.unknown_runs},recent:n,analytics:e.analytics}}function m2({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(dd,{label:"Range",name:"mission-range",value:e,onChange:n,size:"sm",options:Av.map(i=>({value:i.id,label:i.label}))}),o&&r.length>0&&t.jsx(Ct,{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 yf=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function h2({a:e,basis:n,now:s=Date.now(),refreshing:r=!1}){const o=e.totals,i=fP(o),c=u2(o),d=f2(o),u=[{label:"Tokens",value:Ga(o.tokens),notes:[`${i===null?"":`${Ff(i)} of input cached · `}${Ga(o.output)} output`,Mv(o),o.requests===null||o.unmetered===null?"Model request counts unavailable":o.unmetered?`${yf(o.unmetered,"request")} with no token count`:void 0]},{label:"Run time",value:kk(e.time.wall_ms),notes:[`wall time of ${yf(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${kk(e.time.active_ms)} active, over ${yf(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:Ff(c),notes:[o.completed+o.failed?uP(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(vP,{days:mP(e.by_day,e.filter.from,s)}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[t.jsx(pP,{rows:e.by_harness_effort,basis:n}),t.jsx(gP,{tools:e.tools})]}),t.jsx(xP,{groups:e.by_source})]})}function Ui({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 p2="px-4 py-2 text-left font-normal",Nr="px-4 py-2.5 align-top";function pP({rows:e,basis:n}){return t.jsx(Ui,{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:p2,children:s},s))})}),t.jsx("tbody",{children:e.map(s=>{const r=f2(s),o=Mv(s);return t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:Nr,children:s.harness}),t.jsx("td",{className:ae(Nr,!s.effort&&"text-muted-foreground"),children:s.effort??"unset"}),t.jsx("td",{className:Nr,children:s.runs}),t.jsx("td",{className:Nr,children:Ff(u2(s))}),t.jsxs("td",{className:Nr,children:[t.jsx("span",{className:"whitespace-nowrap",children:Ga(s.tokens)}),o&&t.jsx("span",{className:"block text-label text-muted-foreground",children:o})]}),t.jsxs("td",{className:Nr,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 gP({tools:e}){return t.jsx(Ui,{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:p2,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:Nr,title:n.tool,children:n.label}),t.jsx("td",{className:Nr,children:Ga(n.calls)}),t.jsx("td",{className:ae(Nr,n.errors>0&&"text-destructive-text"),children:Ga(n.errors)}),t.jsx("td",{className:Nr,children:Ff(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 xP({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}`}: ${yf(n.runs,"run")}`).join(" · ")}):null}const ug=e=>Math.max(0,e.runs-e.completed-e.failed);function Nk(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 fg=e=>e.slice(5);function vP({days:e}){const n=e.some(d=>d.runs>0),s=t.jsxs(t.Fragment,{children:[t.jsx(bT,{className:"size-4","aria-hidden":!0}),"Run activity"]}),r=t.jsxs(t.Fragment,{children:[t.jsx(ET,{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(Ui,{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(Ui,{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=Nk(Math.max(...e.map(d=>d.runs))),i=Nk(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:ug}];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(Ui,{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(Sk,{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 · ${ug(d)} other`]})]})}),t.jsx(Ui,{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(Sk,{days:e,top:i,label:"Tokens per day",format:Ga,stack:d=>[{className:"bg-primary",value:d.tokens}],readout:d=>[`${Ga(d.tokens)} tokens`,Mv(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:ug(d)}),t.jsx("td",{className:"pr-4",children:d.tokens===null?"Unknown":d.tokens.toLocaleString("en-US")})]},d.day))})]})})]})]})}function Sk({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())},[b,x]=p.useState(null),[h,v]=p.useState(null),y=e.find(j=>j.day===(b??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:()=>x(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:()=>x(j.day),onFocus:()=>{v(j.day),u(k)},onBlur:()=>v(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:fg(e[0].day)}),e.length>2&&t.jsx("span",{children:fg(e[Math.floor(e.length/2)].day)}),t.jsx("span",{children:fg(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:y?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block font-semibold text-foreground",children:o(y)[0]}),o(y).slice(1).map(j=>t.jsx("span",{className:"block",children:j},j)),t.jsx("span",{className:"block",children:y.day})]}):"Hover or focus a day for its figures."})]})]})}const an=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),bf=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function yP(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 b={};if(o(),e[s]==="}")s++;else for(;;){o(),e[s]!=='"'&&r(e[s]==="}"?"a trailing comma before }":"expected a key in double quotes");const x=i();if(o(),e[s]!==":"&&r("expected : after the key"),s++,b[x]=c(`${d}/${bf(x)}`),o(),e[s]===","){s++;continue}if(e[s]==="}"){s++;break}r("expected , or } after the value")}f=b}else if(g==="["){s++;const b=[];if(o(),e[s]==="]")s++;else for(;;){if(b.push(c(`${d}/${b.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=b}else if(g==='"')f=i();else{const b=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(e.slice(s,s+400));b||r(s>=e.length?"the text ends before the value":"expected a value"),s+=b[0].length,f=JSON.parse(b[0])}return n.set(d,{start:u,end:s}),f};try{const d=c("");return 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 bP(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 g2(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(an(s))s=Object.prototype.hasOwnProperty.call(s,o)?s[o]:void 0;else return}return s}const x2=new Set(["judge","pick","sift","route"]),Ck=["jev","parallel","openrouter"];function wP(e){return!an(e)||!an(e.properties)?[]:Object.entries(e.properties).flatMap(([n,s])=>{if(!an(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 Pv(e,n,s){const r=g2(e,n);if(!an(r))return{decision:!1};const o=r.node,i=s??{},c=o==="route"&&typeof r.valuePath=="string",d=typeof o=="string"&&x2.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=an(e)&&an(e.schemas)?e.schemas:{};let b=[];Array.isArray(i.questions)?b=i.questions.map(v=>({id:v.id,type:v.type==="choice"||v.type==="score"?v.type:"noul",text:v.instructions||v.id,...v.options?{options:v.options}:{}})):o==="judge"||o==="sift"?b=typeof r.out=="string"?wP(g[r.out]):[]:o==="pick"?b=[{id:"pick",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Pick one"}]:o==="route"&&(b=[{id:"branch",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Which branch?",options:an(r.branches)?Object.keys(r.branches):[]}]);const x=Array.isArray(i.images)?i.images.map(String):an(r.images)?Object.keys(r.images):[],h=an(r.unsure)&&typeof r.unsure.branch=="string"&&typeof r.unsure.gte=="number"?{branch:r.unsure.branch,gte:r.unsure.gte}:void 0;return{decision:d,provider:u,model:f,questions:b,...x.length?{images:x}:{},web:u==="parallel",...h?{unsure:h}:{}}}const jP=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function kP(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(!an(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=an(e.schemas)?e.schemas:{};an(e.input)&&typeof e.input.schemaId=="string"&&!o[e.input.schemaId]&&s("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),an(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(!an(d)){s(u,'expected a node (an object with a "node" kind)');return}const f=d.node;if(typeof f!="string"||!jP.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=(x,h)=>{d[x]===void 0&&s(u,`a ${f} node needs ${x} (${h})`)},b=x=>{typeof d[x]=="string"&&!o[d[x]]&&s(`${u}/${x}`,`no schema "${d[x]}" in schemas`)};switch(f){case"chain":!Array.isArray(d.steps)||!d.steps.length?s(u,"a chain needs steps"):d.steps.forEach((x,h)=>c(x,`${u}/steps/${h}`));break;case"parallel":!Array.isArray(d.branches)||!d.branches.length?s(u,"a parallel node needs branches"):d.branches.forEach((x,h)=>c(x,`${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":an(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"),b("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":b("out");break}if(f==="route"){if(!an(d.branches)||!Object.keys(d.branches).length)s(u,"a route needs branches");else for(const[x,h]of Object.entries(d.branches))an(h)?c(h.body,`${u}/branches/${bf(x)}/body`):s(`${u}/branches/${bf(x)}`,`branch "${x}" 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"),an(d.unsure)&&an(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(x2.has(f)&&!(f==="route"&&typeof d.valuePath=="string")&&(d.provider!==void 0&&!Ck.includes(d.provider)&&r(`${u}/provider`,`provider "${String(d.provider)}" is not one of ${Ck.join(", ")}`),d.provider==="openrouter"&&typeof d.model!="string"&&s(u,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),an(d.images))){const x=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))x.includes(h)||s(`${u}/images/${bf(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 Ek(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 NP(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 SP(e){const n=ll(e),r=n.nodes.map(i=>Pv(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 Uf=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,$k=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),pd=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function gd(e,n){return Object.fromEntries(n.nodes.map(s=>[s.path,Pv(e,s.path,s)]))}const Vu=e=>e>=.995?"1.00":e.toFixed(2);function cl(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?` ${Vu(f)}`:""}`}const r=Object.keys(n);if(!r.length)return;const o=u=>{const f=n[u];return f.type==="choice"?`${v2(e,u,f.choice)} ${Vu(f.probabilities[f.choice]??f.confidence)}`:f.type==="noul"?`${f.noul>=.5?"yes":"no"} ${Vu(f.noul>=.5?f.noul:1-f.noul)}`:f.type==="score"?`${f.score} ${Vu(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 v2(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 y2=(e,n)=>e.nodes.filter(s=>s.path.startsWith(`${n}/body`)).map(s=>s.path);function CP(e,n,s){var b,x;const r=(x=(b=e.nodes[n])==null?void 0:b.items)==null?void 0:x.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=y2(e.graph,n).filter(h=>!i.has(c.get(h)??""));let u=-1;d.forEach((h,v)=>{const y=e.decisions.filter(k=>k.node===h&&k.item===s),j=e.effects.filter(k=>k.node===h&&k.item===s);!y.length&&!j.length||(u=v,y.some(k=>k.status==="failed")||j.some(k=>k.status==="failed")?o[h]="failed":y.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=Uf(r.status)??"pending";let g=!Object.values(o).includes("working");return d.forEach((h,v)=>{o[h]||(v<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 EP(e,n){var g,b,x;const s={},r=[],o={};let i=null;const c=new Map(e.graph.nodes.map(h=>[h.path,h.kind]));for(const[h,v]of Object.entries(e.nodes)){const y=Uf(v.status);y&&(s[h]=y),v.branch&&r.push(`${h}/branches/${$k(v.branch)}/body`),v.items&&(o[h]=v.items.map(j=>({index:j.index,status:Uf(j.status)??"pending",label:Bc(e,h,j.index),...Lv(e,h,j)}))),v.status==="escalated"&&c.get(h)==="escalate"&&(i=h)}const d={},u=h=>/\/body(\/|$)/.test(h)&&e.graph.nodes.some(v=>v.kind==="map"&&h.startsWith(`${v.path}/body`));for(const h of e.decisions){if(!h.node||h.item!==null||u(h.node))continue;const v=cl(h);v&&(d[h.node]=v)}if(n&&n.item!=null&&c.get(n.path)==="map"){Object.assign(s,CP(e,n.path,n.item));const h=((x=(b=(g=e.nodes[n.path])==null?void 0:g.items)==null?void 0:b.find(v=>v.index===n.item))==null?void 0:x.branches)??{};for(const[v,y]of Object.entries(h)){const j=`${v}/branches/`,k=`${j}${$k(y)}/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 v of e.decisions)if(v.node&&v.item===n.item&&v.node.startsWith(`${n.path}/body`)){const y=cl(v);y&&(d[v.node]=y)}}if(e.run.paused){for(const[h,v]of Object.entries(s))v==="working"&&(s[h]="held");for(const h of Object.values(o))for(const v of h)v.status==="working"&&(v.status="held")}const f={};for(const[h,v]of Object.entries(e.nodes))v.model&&(f[h]={model:v.model,...v.tier?{tier:v.tier}:{}});return{status:s,taken:r,items:o,fired:i,verdict:d,meta:gd(e.workflow,e.graph),selected:n,...Object.keys(f).length?{ran:f}:{}}}const mg={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"},$P=e=>{if(!e)return;const n=e.toLowerCase();return mg[n]??mg[n.split(/[_\s-]/)[0]]??mg[n.split(/[_\s-]/).at(-1)??""]};function _P(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 Lv(e,n,s){const r=y2(e.graph,n),o=x=>x?r.indexOf(x):-1,i=e.decisions.filter(x=>{var h;return x.item===s.index&&!!((h=x.node)!=null&&h.startsWith(`${n}/body`))}).sort((x,h)=>o(x.node)-o(h.node));let c,d;const u=Object.entries(s.branches??{}).sort(([x],[h])=>o(x)-o(h));if(u.length)[d,c]=u[u.length-1];else{const x=i.filter(h=>{var v;return h.status==="answered"&&((v=h.action)==null?void 0:v.taken)}).at(-1);x&&(c=x.action.taken,d=x.node??void 0)}const f=d&&i.filter(x=>x.node===d).at(-1)||i.filter(x=>x.status==="answered").at(-1),g=f?_P(f):void 0,b=s.status==="failed"?"bad":s.status==="needs_review"||s.status==="escalated"?"warn":$P(c);return{...c?{outcome:c}:{},...g?{p:g.p,pNote:g.note}:{},...b?{tone:b}:{}}}function Bc(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 b2(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 w2(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 Sl=e=>e==null?"Unknown":e>0&&e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Qi=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function dl(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 TP=(e,n,s)=>{const r=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||n)-Date.parse(e.run.startedAt);return pd(e.run.status)||e.run.paused?r:r+Math.max(0,s-n)};function RP(e,n,s){return e!=="input_required"||n!=="waiting"?null:s.findLast(r=>r.kind==="waiting")??null}function AP(e){const n=e.content_type??"";return n.startsWith("text/markdown")||e.path.toLowerCase().endsWith(".md")?"markdown":n.startsWith("text/")||n.includes("json")?"text":"download"}function j2(e){return e.split("/").slice(0,-1).some(n=>n.startsWith(".")||n==="__pycache__"||n==="node_modules")}const k2="The agent finished without writing an answer.",_k=[0,250,1e3],OP=e=>new Promise(n=>setTimeout(n,e));function rx(){let e=0;return{begin:()=>++e,current:n=>n===e,cancel:()=>{e++}}}const N2="30d",Tk=10,MP=["queued","working","input_required","paused"];function PP({agent:e,v2:n,now:s=Date.now,stats:r}){const[o,i]=p.useState(N2),[c,d]=p.useState(r??null),[u,f]=p.useState(null),[g,b]=p.useState(!0),[x,h]=p.useState(0),v=p.useRef(0),y=p.useRef(!0);p.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);const j=p.useRef(null),k=p.useRef(null);p.useEffect(()=>{const S=`${o}/${x}`;if(k.current===S)return;const N=++v.current;if(j.current===S){k.current=null,f(null),b(!1);return}k.current=S,b(!0),f(null),(async()=>{for(const[$,_]of _k.entries()){if(_&&await OP(_),N!==v.current||!y.current)return;try{const M=await n.statsOver({from:Ov(o,s()),agent:e.agent_id});if(N!==v.current||!y.current)return;const O=!(M.runs.status_unknown>0);if(d(M),j.current=O||$===_k.length-1?S:null,O)break}catch(M){N===v.current&&f(Ut(M));break}}N===v.current&&(k.current=null,b(!1))})()},[n,e.agent_id,o,x]),p.useEffect(()=>{const S=new AbortController,N=$=>({status:$,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(MP.map($=>n.listAgentRuns(e.agent_id,Tk,null,N($)))).then($=>{if(S.signal.aborted)return;const _=$.flatMap(M=>M.status==="fulfilled"?M.value.runs:[]).filter(M=>!pd(M.status));for(const M of _.slice(0,Tk)){let O=`${M.status}/${M.state}`;o2(n,M.run_id,{signal:S.signal,onPage:L=>{const A=`${L.status}/${L.state}`;A!==O&&(O=A,h(R=>R+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(m2,{range:o,onRange:i,agent:null,agents:[]}),u?t.jsxs("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:["The analytics could not be read: ",u]}):!c||!E?t.jsx("p",{className:"py-12 text-center font-mono text-body text-muted-foreground",children:"Loading analytics..."}):E.totals.runs?t.jsx(h2,{a:E,basis:c.cost.basis,now:s(),refreshing:g}):t.jsx("div",{className:"border px-4 py-12 text-center",children:t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent in this range."})})]})}const Iv=["codex","codex-cli","claude","claude-cli","cursor","other"],S2="agentrun.coding-agent.v1",hg="agentrun:coding-agent",pg={codex:"Codex app","codex-cli":"Codex CLI",claude:"Claude Code app","claude-cli":"Claude Code CLI",cursor:"Cursor",other:"Other / terminal"};function Rk(){try{const e=localStorage.getItem(S2);return Iv.includes(e)?e:""}catch{return""}}function LP(e){try{localStorage.setItem(S2,e)}catch{}}function IP(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 zP="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=",DP="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=",FP="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",UP="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 Ak({agent:e}){const n=e==="codex"?zP:e==="claude"?DP:e==="codex-cli"?FP:e==="claude-cli"?UP: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(GT,{className:"size-4 shrink-0","aria-hidden":!0}):t.jsx(Va,{className:"size-4 shrink-0","aria-hidden":!0})}function WP(){const[e,n]=p.useState(Rk);return p.useEffect(()=>{const r=o=>{const i=o instanceof CustomEvent?o.detail:void 0;n(Iv.includes(i)?i:Rk())};return window.addEventListener(hg,r),window.addEventListener("storage",r),()=>{window.removeEventListener(hg,r),window.removeEventListener("storage",r)}},[]),{agent:e,choose:r=>{LP(r),n(r),window.dispatchEvent(new CustomEvent(hg,{detail:r}))}}}function nn({label:e,prompt:n,playgroundHref:s,playgroundLabel:r="API playground",disabled:o,compact:i=!1,compactIcon:c,variant:d="outline"}){const{agent:u,choose:f}=WP(),[g,b]=p.useState(!1),[x,h]=p.useState(!1),[v,y]=p.useState(!1),[j,k]=p.useState(null),E=p.useRef(null),S=p.useRef(null),N=p.useRef(null),$=p.useRef(null),_=p.useRef(null),M=p.useRef(0),O=p.useId(),L=IP(u,n),A=u?L?`Open in ${pg[u]}`:`Copy prompt for ${pg[u]}`:"Choose your coding agent",R=()=>{var U;b(!1),(U=E.current)==null||U.focus()},P=async()=>{const U=++M.current;b(!1);try{if(await navigator.clipboard.writeText(n),U!==M.current)return;h(!0),y(!1)}catch{U===M.current&&y(!0)}};p.useEffect(()=>(h(!1),y(!1),()=>{M.current++}),[u,n]),p.useEffect(()=>{if(!x)return;const U=setTimeout(()=>h(!1),2e3);return()=>clearTimeout(U)},[x]),p.useEffect(()=>{o&&b(!1)},[o]),p.useEffect(()=>{if(!g){k(null);return}const U=()=>{var Ne;const Y=E.current.getBoundingClientRect(),J=Math.min(240,window.innerWidth-16),X=Math.min(((Ne=N.current)==null?void 0:Ne.scrollHeight)||340,window.innerHeight-16),le=window.innerHeight-Y.bottom-12,se=Y.top-12,fe=le>=X||le>=se,xe=Math.max(80,fe?le:se);k({width:J,left:Math.max(8,Math.min(Y.right-J,window.innerWidth-J-8)),top:fe?Y.bottom+4:Math.max(8,Y.top-Math.min(X,xe)-4),maxHeight:xe})};U();const z=Y=>{var J,X;!((J=S.current)!=null&&J.contains(Y.target))&&!((X=N.current)!=null&&X.contains(Y.target))&&b(!1)};return document.addEventListener("pointerdown",z),window.addEventListener("resize",U),window.addEventListener("scroll",U,!0),()=>{document.removeEventListener("pointerdown",z),window.removeEventListener("resize",U),window.removeEventListener("scroll",U,!0)}},[g]);const D=j!==null;p.useEffect(()=>{var U,z,Y;g&&D&&((Y=((U=N.current)==null?void 0:U.querySelector('[aria-checked="true"]'))??((z=N.current)==null?void 0:z.querySelector('[role="menuitemradio"]')))==null||Y.focus())},[g,D]),p.useEffect(()=>{var U,z;v&&((U=$.current)==null||U.focus(),(z=$.current)==null||z.select())},[v]);const W=U=>{var X;if(U.key==="Escape"){U.preventDefault(),R();return}if(U.key==="Tab"){R();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(U.key))return;U.preventDefault();const z=[...N.current.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')],Y=z.indexOf(document.activeElement),J=U.key==="Home"?0:U.key==="End"?z.length-1:(Y+(U.key==="ArrowDown"?1:-1)+z.length)%z.length;(X=z[J])==null||X.focus()},K="flex w-full items-center gap-2 px-3 py-2 text-left text-body hover:bg-accent focus:bg-accent focus:outline-none",H=t.jsxs(t.Fragment,{children:[i&&c?c:t.jsx(Ak,{agent:u}),i?t.jsx("span",{className:"sr-only",children:x?"Copied":e}):x?"Copied":e]}),q=i?`${e} · ${A}`:A,F=`h-full !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none ${i?"px-2":"pl-3 pr-1"}`,G=d==="primary"?"data-[state=open]:bg-primary/20 has-[:focus-visible]:bg-primary/20":"data-[state=open]:bg-accent has-[:focus-visible]:bg-accent";return t.jsxs("div",{ref:S,role:"group","aria-label":`${e} options`,"data-state":g?"open":"closed",className:ae(Lc({variant:d,size:"sm"}),"shrink-0 items-stretch gap-0 overflow-hidden px-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring",G),children:[L&&!o?t.jsx("a",{href:L,title:q,"aria-label":i?e:void 0,className:ae(Lc({variant:"ghost",size:"sm"}),F),children:H}):t.jsx(B,{variant:"ghost",size:"sm",className:F,disabled:o,title:q,"aria-label":i?e:void 0,onClick:()=>u?void P():b(!0),children:H}),t.jsx(B,{ref:E,variant:"ghost",size:"icon",className:"h-full w-7 !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none",disabled:o,"aria-label":`Choose coding agent for ${e}`,"aria-haspopup":"menu","aria-expanded":g,"aria-controls":g?O:void 0,onClick:()=>b(U=>!U),onKeyDown:U=>{(U.key==="ArrowDown"||U.key==="ArrowUp")&&(U.preventDefault(),b(!0))},children:t.jsx(Or,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:x?"Prompt copied":""}),g&&Ns.createPortal(t.jsxs("div",{ref:N,id:O,role:"menu","aria-label":"Coding agent",onKeyDown:W,className:`fixed z-popover overflow-y-auto border bg-card p-1 shadow-float${D?"":" invisible"}`,style:j??{width:240},children:[Iv.map(U=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":u===U,tabIndex:-1,className:K,onClick:()=>{f(U),R()},children:[t.jsx(Ak,{agent:U}),pg[U],u===U&&t.jsx(pl,{className:"ml-auto size-3.5","aria-hidden":!0})]},U)),t.jsx("div",{role:"separator",className:"my-1 border-t"}),s&&t.jsxs("a",{role:"menuitem",tabIndex:-1,href:s,className:K,onClick:()=>b(!1),children:[t.jsx(mm,{className:"size-4","aria-hidden":!0}),r]}),t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,className:K,onClick:()=>{var U;(U=E.current)==null||U.focus(),P()},children:[t.jsx(Va,{className:"size-4","aria-hidden":!0}),"Copy prompt"]})]}),document.body),v&&Ns.createPortal(t.jsx("div",{className:"fixed inset-0 z-popover grid place-items-center bg-overlay/70 p-4",onClick:U=>{var z;U.target===U.currentTarget&&(y(!1),(z=E.current)==null||z.focus())},children:t.jsxs("div",{ref:_,role:"dialog","aria-modal":"true","aria-label":"Copy prompt",className:"w-full max-w-xl border bg-background p-5 shadow-float",onKeyDown:U=>{var z,Y,J;if(U.key==="Escape"&&(U.preventDefault(),y(!1),(z=E.current)==null||z.focus()),U.key==="Tab"){const X=[..._.current.querySelectorAll("button, textarea")];U.shiftKey&&document.activeElement===X[0]?(U.preventDefault(),(Y=X.at(-1))==null||Y.focus()):!U.shiftKey&&document.activeElement===X.at(-1)&&(U.preventDefault(),(J=X[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 U;y(!1),(U=E.current)==null||U.focus()},children:t.jsx(Xo,{"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(tn,{ref:$,readOnly:!0,"aria-label":"Prompt to copy",value:n,rows:9,className:"w-full resize-y border bg-card p-3 font-mono text-small",onFocus:U=>U.currentTarget.select()})]})}),document.body)]})}function sa(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 ro(e){const n=sa(e).origin;return`First read this server's matching agentrun-serve skill from ${n}/skills/agentrun-serve/SKILL.md. Target this existing instance only: ${n}/v2; do not start a replacement server. Check its /capabilities and /openapi.json. Prefer configured MCP at ${n}/v2/mcp, verifying with whoami; otherwise use the documented API. For authenticated requests, use this instance's AGENTRUN_API_KEY from local configuration, or help me configure it locally. Never print credentials.`}function zm(e,n="",s){return`${ro(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 HP(e,n,s=""){return C2(e,n,s)}function ox(e,n,s){return C2(e,n,"",!0,s)}function C2(e,n,s="",r=!1,o){const i=sa(e).origin;return`${ro(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 Bo(e,n,s=!1,r){const o=sa(e).origin;return r?`${ro(e)}
|
|
606
|
+
|
|
607
|
+
Help me edit the existing backend agent ${JSON.stringify(n)}, using ${Yo(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?`${ro(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.`:`${ro(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 Dm(e,n){const s=sa(e).origin,r=n===void 0?"/runs":`/agents/${encodeURIComponent(n)}/runs`;return`${ro(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 zv(e,n,s){const r=sa(e).origin;return s?`${ro(e)}
|
|
614
|
+
|
|
615
|
+
Help me run the existing backend agent ${JSON.stringify(n)}, using ${Yo(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.`:`${ro(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 BP(e,n,s){const r=sa(e).origin;return`${ro(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 E2(e){const n=sa(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 GP(e,n){const s=sa(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 qP(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 Fm={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},KP=new Set(["completed","failed","cancelled"]);function VP(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 $2=(e,n)=>e==="failed"&&(n==null?void 0:n.code)==="escalated",YP=(e,n)=>e==="completed"&&!!n;function Um(e,n,s,r,o,i,c,d){const u=KP.has(e),f=s==="agentic",g=$2(e,i),b=YP(e,c),x=e==="queued"&&(d==null?void 0:d.state)==="starting"&&(d.kind==="desktop"||d.kind==="phone"),h=g?"Escalated":b?"Needs review":x?"Starting":e==="input_required"?n==="waiting"?"Input required":"Stopped":{queued:"Queued",working:"Working",completed:"Completed",failed:"Failed",cancelled:"Cancelled",paused:"Paused"}[e],v=g||b?"warning":e==="completed"?"success":e==="failed"?"error":e==="cancelled"?"muted":e==="input_required"||e==="paused"?"warning":"active",y=VP(e,n,s,r,o);return{label:h,tone:v,live:e==="queued"||e==="working",needsYou:e==="input_required",final:u,canStop:f&&e==="working"&&n==="working",canCancel:!u,canMessage:y!==null,messageMode:y}}const QP={Queued:Gp,Starting:Gp,Working:Gp,Completed:pl,Failed:nl,Escalated:jT,"Needs review":hm,Cancelled:RN,"Input required":Kx,Stopped:sl,Paused:ON};function Cl({run:e}){const n=Um(e.status,e.state,e.kind,Fm,!0,e.error,e.review,e.computer),s=QP[n.label];return t.jsxs(ke,{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 JP=["ready","unavailable"],wf=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ax=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function xd(e){if(wf(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function Ok(e){const n=wf(e)?e.places:void 0;if(!wf(n)||!Array.isArray(n.modes)||!Array.isArray(n.boxes))return null;const s=n.boxes.filter(wf).filter(o=>typeof o.id=="string").map(o=>({id:o.id,available:o.available===!0,...typeof o.reason=="string"?{reason:o.reason}:{},...JP.includes(o.state)?{state:o.state}:{}})),r=xd(n.default_place);return r?{modes:n.modes.filter(o=>typeof o=="string"),boxes:s,defaultPlace:r}:null}const gg=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,XP=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",ZP=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",eL={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."}]}},tL=["jev","parallel"];function nL(e="jev"){const n=structuredClone(eL);return e!=="jev"&&Object.assign(n.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),n}const sL={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`."}]}},rL=()=>structuredClone(sL);function vd(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 b={...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},x=xd(g.place),h=g.computer===void 0&&x?ax(x):g.computer;return h!==void 0&&(b.computer=h,delete b.place),b},f=Ji(u(c),u(d));return c.version=f?e.definition.version:e.revisions+1,{definition:c,...s.trim()?{note:s.trim()}:{},unchanged:f}}function Ji(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=>Ji(e[o],n[o]))}const Dv="decision",_2="workflow",T2={[Dv]:nL,[_2]:rL},R2=e=>e!==void 0&&Object.hasOwn(T2,e);function oL(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?tL.find(o=>n.some(i=>i.id===o&&i.available)):"jev"}const aL="You are a helpful agent. Do the task you're given and report what you found.";function iL(e){var n;return R2(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:T2[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 Mk(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 lL(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:b}=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 b=="boolean"?{nodes:b}:{}}]})}function Wm(e,n){return n.filter(s=>!s.call_only&&s.harnesses.includes(e))}function ix(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:Wm(e,s).some(c=>c.name===n):!0}const Wf=e=>O2[e]??e,Pk=e=>e.map(Wf).join(" and ");function Lk(e,n,s,r){var i;if(n.startsWith("mcp:"))return`${Wf(e)} doesn't run MCP tools here${r!=null&&r.length?`: ${Pk(r)} do`:""}`;const o=((i=s.find(c=>c.name===n))==null?void 0:i.harnesses)??[];return o.length?`Runs on ${Pk(o)} here, not on ${Wf(e)}`:"No harness runs it here"}function cL(e,n,s,r,o={}){const i=[...n,...s.filter(c=>!n.includes(c))];return{tools:i.filter(c=>ix(e,c,r,o)),held:i.filter(c=>!ix(e,c,r,o))}}const dL=(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,Fv=new Set(["browser"]),Uv=(e,n,s)=>e||n.some(r=>Fv.has(r))||!s?{mode:"runner"}:s.defaultPlace;function A2(e,n){const s=xd(e.definition.place);if(s)return{place:s,byDefault:!1};const r=e.kind==="workflow",o=e.definition.tools??[];if(!(!r&&!o.some(i=>Fv.has(i))&&!n))return{place:Uv(r,o,n),byDefault:!0}}const xg=(e,n,s)=>Wm(e,n).filter(r=>r.available&&((s==null?void 0:s.mode)==="sandbox"?!Fv.has(r.name):!r.sandbox_only)).map(r=>r.name),uL=["web_fetch","web_search"],Ik=e=>e.some(n=>uL.includes(n)),O2={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},fL=["pi","claude-agent","codex","opencode"];function mL(e,n){const s=fL.flatMap(r=>{const o=e.find(i=>i.id===r);return o?[{id:r,label:O2[r],available:o.available,reason:o.reason}]:[]});return n&&(s.push({id:Dv,label:"Decision",available:n.available,reason:n.available?void 0:"This server runs no decision workflows: it has no decision provider's key."}),s.push({id:_2,label:"Workflow",available:!0,reason:void 0})),s}function hL(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 Hm(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 pL(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 yd=e=>e==="claude-code"?"Claude Code":e==="codex"?"Codex":e,Wv=e=>e.kind==="project"?"Project default":`${e.kind==="profile"?"Profile":"Named agent"}: ${e.name}`;function Hv(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 Bv(e){const n=e==null?void 0:e.definition.native;return!n||!Hv(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 bd(e){return"connected"in e&&!e.connected?"Disconnected":e.state==="ready"?"Ready to run":e.state==="needs_attention"?"Needs attention":"Needs verification"}const Gv=p.createContext(null),qv=p.createContext(void 0);function gL(e,n){const s=e==null?void 0:e.definition.native,r=Hv(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(b=>b+1);return p.useEffect(()=>{if(!e||!s||!r)return;let b=!0,x=!1;const h=async()=>{if(!x){x=!0;try{const{native:j}=await n.getNative(e.agent_id);if(!j)throw new Error("The remote binding is no longer available.");b&&c({key:o,native:j})}catch(j){b&&c({key:o,native:{...s,state:"needs_attention",capabilities:{...s.capabilities,launch:!1},issues:[`Connection status could not be read: ${Ut(j)}`]}})}finally{x=!1}}};h();const v=()=>{document.hidden||h()},y=setInterval(v,15e3);return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{b=!1,clearInterval(y),window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[n,o,d]),{native:!r||!s?s:(i==null?void 0:i.key)===o?i.native:Bv(e??void 0),refresh:f}}function Kv(){const e=p.useContext(Gv),[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 xL({children:e,native:n}){const s=Kv();return t.jsx(qv.Provider,{value:n,children:t.jsx(Gv.Provider,{value:s,children:e})})}function M2({agent:e,v2:n,learning:s,onAgent:r}){const o=p.useContext(qv)??e.definition.native,i=Kv(),c=e.definition.learning===!0||e.definition.learning==="notes",[d,u]=p.useState(!1),[f,g]=p.useState(!1),[b,x]=p.useState(null),h=o.connected&&o.state==="ready"&&o.capabilities.notes&&o.capabilities.skills&&o.capabilities.launch,v=async y=>{if(i.begin()){g(!0),x(null);try{if(y){const{native:N}=await n.verifyNative(e.agent_id);if(!N.connected||N.state!=="ready"||!N.capabilities.notes||!N.capabilities.skills)throw new Error(`Native learning is not ready: ${N.issues.join("; ")||bd(N)}. Verify the connection and try again.`)}const{agent:j,etag:k}=await n.getAgent(e.agent_id),{unchanged:E,...S}=vd(j,{learning:y?"notes":!1},y?"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){x(Ut(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(ud,{labelledBy:`native-learning-${e.agent_id}`,checked:c,busy:f,disabled:i.busy||!!e.archived_at||!c&&(!h||s!=="on"),onChange:y=>y?u(!0):void v(!1)})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:c?"On supplies approved notes and skills, then checks proposals after each job. Learned workflows are unavailable.":"Off neither supplies nor creates AgentRun learning. Saved learning stays available. Native memory behavior is unchanged."}),s!=="on"&&t.jsx(vt,{tone:"warning",children:s==="off"?"This server has learning turned off.":s===null?"This server does not expose learning.":"Checking this server's learning support."}),!h&&t.jsx("p",{className:"text-small text-warning-text",children:"Verify a connected native launch with notes and skills support before enabling self-improvement."}),b&&!d&&t.jsx(vt,{tone:"error",children:b}),t.jsxs(Mm,{open:d,onClose:()=>{f||(u(!1),x(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),x(null)},children:"Cancel"}),t.jsx(B,{size:"sm",variant:"solid",disabled:f||i.busy,"aria-busy":f,onClick:()=>void v(!0),children:f?"Enabling…":"Enable self-improvement"})]}),children:[t.jsx("p",{className:"text-body",children:"Reflection and grading incur additional native model usage after jobs. Task usage and learning usage are recorded separately; dollar cost may be unknown. Native spend caps are unavailable, so AgentRun cannot promise a dollar limit. Verification checks native authentication and compatibility before the policy is saved; it starts no paid task."}),t.jsx("p",{className:"mt-3 text-body",children:"Accepted notes and skills become active automatically. Risky proposals wait for owner review in Dojo. Existing tests, a rubric or task feedback can help measure outcomes; passing a grader alone does not prove an improvement."}),b&&t.jsx(vt,{tone:"error",className:"mt-3",children:b})]})]})}function vL({agent:e,v2:n,learning:s,onAgent:r,onChanged:o}){const i=p.useContext(qv)??e.definition.native,c=Hv(i),d=Kv(),u=d.busy,[f,g]=p.useState(null),b=async x=>{if(d.begin()){g(null);try{const{native:h}=await(x==="verify"?n.verifyNative(e.agent_id):n.disconnectNative(e.agent_id));c||r({...e,definition:{...e.definition,native:h}}),await o()}catch(h){g(Ut(h))}finally{d.end()}}};return t.jsx(Gv.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(ke,{tone:i.connected&&i.state==="ready"?"success":"warning",children:bd(i)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"sm",disabled:u||!i.connected,"aria-busy":u,onClick:()=>void b("verify"),children:"Verify connection"}),t.jsx(B,{size:"sm",disabled:u||!i.connected,onClick:()=>void b("disconnect"),children:"Disconnect"})]}),f&&t.jsx(vt,{tone:"error",children:f}),t.jsx("div",{className:"border-y py-4",children:t.jsx(M2,{agent:e,v2:n,learning:s,onAgent:r})}),i.issues.length>0&&t.jsxs(vt,{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(x=>t.jsx("li",{children:x},x))})]})]}),t.jsx("dl",{className:"space-y-3 text-small",children:[["Runtime",`${yd(i.runtime)} · ${i.version??"Version unknown"}`],["Project",i.project],["Selector",Wv(i.selector)],["Model",i.model??"Native default · unknown until launch"],["Machine",i.machine_id]].map(([x,h])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:x}),t.jsx("dd",{className:"break-all font-mono",children:h})]},x))}),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(x=>t.jsx("li",{className:"break-all font-mono",children:x},x))}):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(x=>t.jsx("li",{className:"break-all font-mono",children:x},x))}):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(x=>t.jsxs("li",{className:"break-all font-mono",children:[x.path,t.jsxs("span",{className:"block text-muted-foreground",children:["SHA-256 ",x.sha256]})]},x.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 yL={browserbase:"Browserbase",kernel:"Kernel"},Ai=e=>yL[e]??e,zk=e=>t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"font-mono underline underline-offset-2",children:e.slice(-8)}),bL=5e3,Dk=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function wL({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),b=p.useRef(e);b.current=e;const x=p.useRef(r);x.current=r;const h=e.sign_ins??[],v=h.some($=>$.state==="held");p.useEffect(()=>{if(!v||d)return;const $=setInterval(()=>x.current(),bL);return()=>clearInterval($)},[v,d]);const y=(N=(S=e.tools)==null?void 0:S.find($=>$.name==="browser"))==null?void 0:N.resolved;if(!h.length&&y!=="browserbase"&&y!=="kernel"&&!f)return null;const j=[...new Set(h.map($=>$.key))].map($=>({key:$,items:h.filter(_=>_.key===$)})),k=async $=>{var _,M;u(!0),g(null);try{const L=(await n.forgetSignIn(e.agent_id,$)).removed.filter(R=>R.at_vendor==="not_deleted"),A=L.length?{tone:"warn",text:L.map(R=>`Forgotten here, but ${Ai(R.provider)} didn't confirm the delete. ${R.message??""}`.trim()).join(" ")}:null;if(g(A),c(null),!await o()){const R=b.current;s({...R,sign_ins:(R.sign_ins??[]).filter(P=>P.key!==$)}),g({tone:"warn",text:`${A?`${A.text} `:"Forgotten. "}The agent couldn't be read again.`})}}catch(O){const L=O instanceof Fe&&O.code==="sign_in_held"?((_=O.details)==null?void 0:_.held_by)??((M=O.details)==null?void 0:M.handed_to):void 0;g(O instanceof Fe&&O.code==="sign_in_held"?{tone:"warn",text:"A run is using this sign-in; you can forget it when that run ends.",...L?{run:L}:{}}:{tone:"error",text:`Not forgotten: ${Ut(O)}`}),c(null)}finally{u(!1)}},E=({key:$,items:_})=>{const M=_.length===1?`Forget the ${Ai(_[0].provider)} sign-in`:`Forget the saved sign-ins for ${Dk(_.map(L=>Ai(L.provider)))}`,O=_.some(L=>L.state==="held");return t.jsx(B,{size:"sm",variant:"ghost",disabled:d||O,"aria-label":M,title:O?"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(Ia,{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:Ai(_.provider)}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:_.verified_at?`last verified ${ht(_.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 ",zk(_.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 ${Ai($.items[0].provider)} sign-in?`:`Forget the saved sign-ins for ${Dk($.items.map(_=>Ai(_.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: ",zk(f.run)]})]})]})}const jL=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),kL=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function Tr(e,n){var c,d;const s=`${jL(n)} could not be read.`;if(kL(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof Fe))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 ss({problem:e,onRetry:n,className:s="m-8"}){return t.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${s}`,role:"alert",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-prose font-semibold",children:e.title}),t.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&t.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),n&&t.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})})]})]})}const Oa=[{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"}],Yu=e=>Oa.find(n=>n.path===e),NL=e=>e.filter(n=>n.total_usd!==null),SL=e=>Math.min(25,Math.max(3,Math.round(e/15)));function CL(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 EL(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 $L(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 _L(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=EL(Math.max(o,...n,s??0)*1.08);return{top:i,above:e.filter(c=>c.total_usd>i).length}}function TL(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 RL(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 Ro(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 ir(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`}const AL=e=>e<=20?1:Math.max(5,Math.ceil(e/20));function OL(e,n){const s=[];for(let r=0;r<e.length;r+=n){const o=e.slice(r,r+n),i=Object.fromEntries(Oa.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 lx(e){const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`}const jf=(e,n)=>`${n?Math.round(e/n*100):0}%`,Qu=3,yc=5,ML=20,Oc={revision:"New revision",promote:"Promoted",hold:"Held",refit:"Refit",queued:"Queued",skipped:"Skipped"},Vv={revision:"R",promote:"P",hold:"H",refit:"F",queued:"Q",skipped:"S"},P2=e=>e.source==="refit"?"refit":e.decided==="replaying"?"revision":e.decided;function PL(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=P2(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 LL=e=>e.path!=="replay",L2=e=>{var n;return(n=e==null?void 0:e.summary.hand_backs)!=null&&n.ran?e.summary.hand_backs:null},Yv=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>r.workflow===n&&r.digest===s);function IL(e,{serving:n=null,refit:s,stopped:r=null}={}){if(s)return{word:"Refit",tone:"muted"};if(!e)return{word:"Not decided",tone:"muted"};const o=zL(e),i=o?{proof:o}:{};return e.decided==="promote"?e.digest!==n?{word:"Served",tone:"muted",...i}:e.digest===r?{word:"Stopped",tone:"warning",...i}:{word:"Serving",tone:DL(e)?"success":"plain",...i}:e.decided==="hold"?{word:"Held",tone:"warning",...i}:e.decided==="queued"?{word:"Queued",tone:"plain"}:e.decided==="skipped"?{word:"Skipped",tone:"muted"}:{word:"Replaying",tone:"active"}}function Gc(...e){const n=IL(...e);return{...n,text:n.proof?`${n.word} · ${n.proof}`:n.word}}const Qv=(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},I2=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>{var o;return r.workflow===n&&r.source==="refit"&&r.decided==="promote"&&((o=r.refit)==null?void 0:o.from)===s});function zL(e){var r;const n=e.replay,s=n?` · ${n.n-n.handed_back} alone`:"";return e.source==="dry_run"?"not replayed":e.source==="refit"?n?`refit on ${n.n} ${n.n===1?"row":"rows"}${s}`:null:e.source!=="replay"||!n||e.decided!=="promote"&&e.decided!=="hold"?null:n.n?`replayed ${n.n}${(r=n.of)!=null&&r.length?`/${n.of.length}`:""}${s}`:"0 replays answered"}const DL=e=>{var n;return(e.source==="replay"||e.source==="refit")&&(((n=e.replay)==null?void 0:n.n)??0)>0},Fk=e=>`${Math.round(e*100)}%`,FL=e=>`${e>=0?"+":""}${Math.round(e*1e3)/10} pts`;function Ma(e){var r;const n=e.replay;return!n||!n.n?e.reason:`${e.source==="refit"?"Refit on":e.source==="graded"?"Checked on":"Replay on"} ${n.n} graded ${n.n===1?"input":"inputs"}: workflow ${Fk(n.wf_acc)} vs agent ${Fk(n.agent_acc)} (${FL(n.delta)}), ${n.handed_back} handed back${(r=n.outcomes)!=null&&r.skipped_write?`, ${n.outcomes.skipped_write} skipped`:""}`}function UL(e){const n=[];let s;try{s=e===null?null:JSON.parse(e)}catch{return n}const r=(o,i,c)=>{if(Array.isArray(o)){o.forEach((f,g)=>r(f,`${i}/${g}`,c));return}if(!o||typeof o!="object")return;const d=o,u=d.guard;typeof d.label=="string"&&u&&typeof u=="object"&&!Array.isArray(u)&&(u.signal==="self"||u.signal==="jev"||u.signal==="both")&&typeof u.threshold=="number"&&n.push({label:d.label,node:`${c}${d.label}`,path:i,signal:u.signal,threshold:u.threshold,fitted:!!u.fit});for(const[f,g]of Object.entries(d)){if(f==="guard")continue;const b=f==="workflow"&&d.node==="workflow"&&typeof d.label=="string";r(g,`${i}/${f.replace(/~/g,"~0").replace(/\//g,"~1")}`,b?`${c}${d.label}/`:c)}};return r(s,"",""),n}const WL={self:"its own confidence",jev:"Jev",both:"its own confidence and Jev"};function HL(e,n=.1){const s=Math.round(1/n),r=Array.from({length:s},(o,i)=>({from:i*n,to:(i+1)*n,right:0,wrong:0,ungraded:0}));for(const o of e){const i=o.p===null?0:Math.min(s-1,Math.max(0,Math.floor(o.p/n+1e-9))),c=r[i];o.correct===!0?c.right+=1:o.correct===!1?c.wrong+=1:c.ungraded+=1}return r}const BL=(e,n,s,r)=>e&&s?e.guards.find(o=>o.workflow===n&&o.digest===s&&o.node===r):void 0;function z2(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 GL(e){var A,R;const{notes:n,compiledNotes:s,runs:r,workflows:o,cost:i,promotions:c,serving:d,loop:u,mode:f="full",execution:g="hosted"}=e,b=f==="notes",x=o.filter(P=>P.status==="active"),h=u==null?void 0:u.compiles.find(P=>P.digest===null&&(P.draft_errors.length>0||P.attempts.length>0)),v=u==null?void 0:u.compiles.find(P=>P.digest!==null),y=i==null?void 0:i.summary,j=L2(i),k=c.at(-1),E=k?d.find(P=>P.workflow===k.workflow):void 0,S=(E==null?void 0:E.digest)??null,N=E!=null&&E.replaying?`revision ${E.replaying.slice(0,7)} replays on graded inputs before it serves`:(k==null?void 0:k.decided)==="hold"&&k.digest!==S?`revision ${k.digest.slice(0,7)} was held: ${Ma(k)}`:null,$=S!==null&&k?Qv(i,k.workflow)===S:!1,_=$?`revision ${S.slice(0,7)} no longer runs first: it cost as much as the agent by hand; its next run asks the agent for a new version`:null,M=_?N?`${_}; ${N}`:_:S&&N?`revision ${S.slice(0,7)} serves; ${N}`:null,O=[];if(O.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 O.push({key:"compiled",title:"Learning",value:"Notes and skills",detail:"Native runs receive accepted notes and skills; learned workflows are unavailable.",state:"later"}),O;if(x.length||v&&v.digest){const P=((A=x[0])==null?void 0:A.name)??(v==null?void 0:v.workflow)??"a workflow";O.push({key:"compiled",title:"Compiled",value:P,detail:v?`from ${v.from_notes.length} ${v.from_notes.length===1?"note":"notes"}, ${v.attempts.length} ${v.attempts.length===1?"attempt":"attempts"}`:"a learned workflow",state:"done"})}else h?O.push({key:"compiled",title:"Compile",value:"Draft failed",detail:`${h.attempts.length} ${h.attempts.length===1?"attempt":"attempts"}, the checks refused it: it tries again on a later run`,state:"warn"}):b?O.push({key:"compiled",title:"Compile",value:"Notes only",detail:`this agent learns notes only: no workflow compiles from them. Full learning compiles one at ${Qu} notes or ${yc} runs`,state:"later"}):O.push({key:"compiled",title:"Compile",value:"Not yet",detail:g==="sdk"?`With workflow learning and backend tool bindings, compilation starts at ${Qu} notes or ${yc} runs`:`${n} of ${Qu} notes, ${Math.min(r,yc)} of ${yc} runs: a workflow compiles at ${Qu} notes or ${yc} runs`,state:n||r?"now":"later"});if(g==="sdk")return b||O.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:x.length?"now":"later"}),O;if(y!=null&&y.takeover)O.push({key:"took_over",title:"Took over",value:`Run ${y.takeover.n}`,detail:M??((R=k==null?void 0:k.replay)!=null&&R.n?Ma(k):k?k.reason:"the first run a learned workflow finished alone"),state:$||(k==null?void 0:k.decided)==="hold"&&!S?"warn":"done"});else if(k)if(M)O.push({key:"took_over",title:"Take over",value:Gc(Yv(c,k.workflow,S)??k,{serving:S,stopped:$?S:null}).word,detail:M,state:$?"warn":"done"});else{const P=Gc(k,{serving:S});O.push({key:"took_over",title:"Take over",value:P.word,detail:k.decided==="replaying"?"replaying on graded inputs before it serves; the agent takes the runs meanwhile":Ma(k),state:k.decided==="hold"?"warn":"now"})}else b||O.push({key:"took_over",title:"Take over",value:"Not yet",detail:"a compiled workflow replays on graded runs, then serves first when it does as well as the agent",state:"later"});if(y!=null&&y.takeover&&y.withheld)O.push({key:"cheaper",title:"Cheaper",value:"No ratio yet",detail:`${D2(y.withheld)}: ${F2}`,state:"now"});else if(y!=null&&y.after&&y.before){const P=`${vg(y.before.mean_usd)} a run by the agent, ${vg(y.after.mean_usd)} all-in over the ${y.after.runs===1?"1 run":`${y.after.runs} runs`} it served since`,D=y.times_cheaper;D!==null&&D>1?O.push({key:"cheaper",title:"Cheaper",...qL(y,D),state:"done"}):D!==null?O.push({key:"cheaper",title:"Cheaper",value:D<1?y.before.mean_usd>0?`Not cheaper yet: ${KL(y.after.mean_usd/y.before.mean_usd)} the cost`:"Not cheaper yet":"Same cost",detail:P,state:"now"}):O.push({key:"cheaper",title:"Cheaper",value:`${y.after.runs} served ${y.after.runs===1?"run":"runs"} so far`,detail:`${P}; how many times cheaper shows after ${ML} runs`,state:"now"})}else y!=null&&y.takeover&&y.after_state==="cost_unknown"?O.push({key:"cheaper",title:"Cheaper",value:"No cost yet",detail:"no served run's cost is known yet",state:"now"}):y!=null&&y.after?O.push({key:"cheaper",title:"Cheaper",value:`${y.after.runs} served ${y.after.runs===1?"run":"runs"} so far`,detail:`${vg(y.after.mean_usd)} all-in over the ${y.after.runs===1?"1 run":`${y.after.runs} runs`} it served; no priced agent runs before takeover to compare with`,state:"now"}):b||O.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"});const L=((u==null?void 0:u.guards)??[]).filter(P=>P.runs>0&&P.threshold!==null).sort((P,D)=>D.escalated/D.runs-P.escalated/P.runs)[0];if(j||L){const P=j?`${Math.round(j.back/j.ran*100)}% handed back`:"no run since";O.push({key:"unsure",title:"Unsure",value:P,detail:L?`most at "${L.node}": ${L.escalated} of ${L.runs} under ${L.threshold.toFixed(2)}`:`of ${j.ran} runs it ran first`,state:j&&j.back/j.ran>.25?"warn":"watch"})}return O}function D2(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 F2="how many times cheaper shows once every run's cost is known";function qL(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 at the same accuracy`,detail:`Replay: ${o}${i}`}}return{value:`${s} cheaper`,detail:`accuracy not claimed: ${r?`its replay was below the bar (${o})`:"no replay yet"}`}}const vg=e=>e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`,KL=e=>{const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`},VL=1e3,U2="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.",W2=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.":U2,cx=e=>`${e} served ${e===1?"run":"runs"}`;function Uk({v2:e,agentId:n,on:s,quiet:r=!1,promotions:o,onCost:i,execution:c="hosted"}){const[d,u]=p.useState(null),[f,g]=p.useState([]),b=o??f,x=p.useRef(i);x.current=i;const[h,v]=p.useState(null),[y,j]=p.useState(0);return p.useEffect(()=>{let k=!0;return v(null),Promise.resolve().then(()=>e.learningCost(n,VL)).then(E=>{var S;k&&(u(E),(S=x.current)==null||S.call(x,E))},E=>{k&&v(E??new Error("unknown"))}),o||Promise.resolve().then(()=>e.learningPromotions(n)).then(E=>{k&&g(E.promotions)},()=>{}),()=>{k=!1}},[e,n,y,!o]),r&&(!d||d.runs.filter(k=>k.total_usd!==null).length<2)?null:h&&!d?t.jsx(ss,{problem:Tr(h,"the cost per run"),onRetry:()=>j(k=>k+1),className:""}):d?t.jsx(QL,{data:d,on:s,promotions:b,execution:c}):t.jsx(pn,{className:"h-[320px] w-full"})}const Ot={top:30,right:16,bottom:30,left:60},Ju=17,YL=16,qr=260;function QL({data:e,on:n,width:s,promotions:r=[],execution:o="hosted"}){var Ee;const i=p.useMemo(()=>NL(e.runs),[e.runs]),c=p.useMemo(()=>i.filter(LL),[i]),d=SL(c.length),u=p.useMemo(()=>CL(c,d),[c,d]),f=p.useMemo(()=>PL(e.runs,r),[e.runs,r]),{summary:g}=e,b=L2(e),x=p.useRef(null),[h,v]=p.useState(s??720);p.useEffect(()=>{const re=x.current;if(s||!re||typeof ResizeObserver>"u")return;const _e=new ResizeObserver(([Qe])=>{Qe&&Qe.contentRect.width>0&&v(Qe.contentRect.width)});return _e.observe(re),()=>_e.disconnect()},[s]);const[y,j]=p.useState(null),[k,E]=p.useState(null),S=Oa.map(re=>({...re,runs:e.runs.filter(_e=>_e.path===re.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(re=>re.state==="needs_revision"&&re.served&&re.by_hand).map(re=>`${re.workflow} no longer runs first: ${ir(re.served.mean_usd)} a run all-in over its newest ${re.served.runs} priced runs, at or over ${ir(re.by_hand.mean_usd)} a run by hand.${re.unknown_cost_runs?` ${re.unknown_cost_runs===1?"1 run":`${re.unknown_cost_runs} runs`} of unknown cost left out.`:""} Its next run asks the agent for a new version, which runs first again.`)].filter(re=>!!re);if(i.length<2)return t.jsxs(Bk,{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:W2(o)}),N.map(re=>t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-small text-muted-foreground",children:re},re))]}),e.runs.length>0&&(()=>{var Qe;const re=Math.max(300,h),_e=(re-Ot.left-Ot.right)/(e.runs.at(-1).n-e.runs[0].n+1);return t.jsx("figure",{ref:x,className:"px-4 pb-3",children:t.jsx(Hk,{runs:e.runs,width:re,x:he=>Ot.left+(he-e.runs[0].n+.5)*_e,step:_e,plot:[Ot.left,re-Ot.right],takeover:((Qe=g.takeover)==null?void 0:Qe.n)??null})})})()]});const $=Math.max(300,h),_=$-Ot.left-Ot.right,M=e.runs[0].n,O=e.runs.at(-1).n,L=_/(O-M+1),A=re=>Ot.left+(re-M+.5)*L,R=g.before,{top:P,above:D}=_L(i,u,(R==null?void 0:R.mean_usd)??null),W=[],K=[];for(const re of f){const _e=A(re.n)-L/2;let Qe=K.findIndex(he=>_e-he>=YL);Qe<0?(Qe=K.length,K.push(_e)):K[Qe]=_e,W.push(Qe)}const H=K.length?K.length*Ju+8:0,q=Ot.top+H,F=re=>q+qr-Math.min(re,P)/P*qr,G=$L(P),U=TL(M,O,$<520?5:7),z=g.takeover&&g.takeover.n>=M?g.takeover:null,Y=g.takeover?Math.max(g.takeover.n,M):null,J=c.map((re,_e)=>`${_e?"L":"M"}${A(re.n).toFixed(1)},${F(u[_e]).toFixed(1)}`).join(""),X=y===null?null:i[y],le=g.times_cheaper!==null?`${lx(g.times_cheaper)} cheaper`:null,se=b?`${jf(b.back,b.ran)} handed back since`:null,fe=g.after?`${ir(g.after.mean_usd)} all-in over ${cx(g.after.runs)} after`:g.takeover&&g.after_state==="cost_unknown"?"no served run's cost known yet":null,xe=g.before&&fe?`${ir(g.before.mean_usd)} a run before takeover, ${fe}${le?`: ${le}`:""}${se?` · ${se}`:""}`:null,Ne=e.unknown_cost_runs+e.unknown_path_runs,ge=re=>{const _e=re.currentTarget.getBoundingClientRect(),Qe=(re.clientX-_e.left)/_e.width*$,he=(re.clientY-_e.top)/_e.height*(q+qr+Ot.bottom);if(f.length&&he<q-2){j(null);const Ie=f.map((et,pt)=>({i:pt,d:Math.abs(A(et.n)-L/2-Qe)+Math.abs(Ot.top+W[pt]*Ju+8-he)})).sort((et,pt)=>et.d-pt.d)[0];E(Ie&&Ie.d<=12?Ie.i:null);return}E(null),j(RL(i,M+(Qe-Ot.left)/L-.5))},me=re=>{const Qe={ArrowRight:he=>he+1,ArrowLeft:he=>he-1,Home:()=>0,End:()=>i.length-1,PageUp:he=>he+10,PageDown:he=>he-10}[re.key];if(!Qe){re.key==="Escape"&&j(null);return}re.preventDefault(),j(he=>Math.min(i.length-1,Math.max(0,Qe(he??(re.key==="ArrowLeft"?i.length:-1)))))},Le=re=>[`Run ${re.n}`,`${Ro(re.total_usd)} all-in${re.learning_usd?` (${Ro(re.cost_usd??0)} the run, ${Ro(re.learning_usd)} learning)`:""}`,`${Yu(re.path).label}${re.workflow?`: ${re.workflow}`:""}`,re.learned_revision?`Learned revision ${re.learned_revision.slice(0,7)}`:"Nothing learned yet",...re.path==="replay"?["A replay: learning's spend, out of the line"]:[]],Ue=k===null?null:f[k]??null,De=z?A(z.n)>Ot.left+_*.62:!1;return t.jsxs(Bk,{title:"Cost per run",headline:xe,unknown:Ne,children:[t.jsxs("figure",{ref:x,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(re=>re.runs>0).map(re=>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:re.fill})}),re.label," ",t.jsx("span",{className:"text-foreground",children:re.runs})]},re.path)),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-foreground",strokeWidth:2})}),"Rolling mean of ",d," runs"]}),R&&t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"4 3"})}),"Before takeover, the agent alone"]}),Object.keys(Oc).filter(re=>f.some(_e=>_e.kind===re)).map(re=>t.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":`marker-key-${re}`,children:[t.jsx("svg",{width:"14",height:"14","aria-hidden":!0,children:t.jsx(Gk,{x:0,y:0,kind:re})}),Oc[re]," ",t.jsx("span",{className:"text-foreground",children:f.filter(_e=>_e.kind===re).length})]},re))]}),t.jsxs("div",{className:"relative shrink-0",tabIndex:0,onKeyDown:me,onBlur:()=>j(null),"aria-label":`Cost per run, runs ${M} to ${O}. ${xe??""} Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:$,height:q+qr+Ot.bottom,className:"block select-none font-mono",onPointerMove:ge,onPointerLeave:()=>{j(null),E(null)},"aria-hidden":!0,children:[G.map(re=>t.jsxs("g",{children:[t.jsx("path",{d:`M${Ot.left},${F(re)}H${Ot.left+_}`,className:re===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:Ot.left-8,y:F(re),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:Ro(re)})]},re)),U.map(re=>t.jsx("text",{x:A(re),y:q+qr+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:re},re)),t.jsx("text",{x:Ot.left,y:H?Ot.top-10:q-16,className:"caps fill-muted-foreground text-label",children:"$ a run, all-in"}),t.jsx("text",{x:Ot.left-8,y:q+qr+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),f.map((re,_e)=>t.jsxs("g",{"data-testid":`marker-${re.kind}`,opacity:k===null||k===_e?1:.55,children:[t.jsx("path",{d:`M${A(re.n)-L/2},${Ot.top+W[_e]*Ju+15}V${q+qr}`,className:H2[re.kind],strokeWidth:1,strokeDasharray:"2 3"}),t.jsx(Gk,{x:A(re.n)-L/2-7,y:Ot.top+W[_e]*Ju+1,kind:re.kind})]},`${re.kind}:${re.n}:${re.workflow}:${re.digest}:${re.at}`)),i.map((re,_e)=>re.path==="replay"?t.jsx("circle",{cx:A(re.n),cy:F(re.total_usd),r:_e===y?0:2.5,className:"fill-none stroke-muted-foreground",strokeWidth:1.25},re.run_id):t.jsx("circle",{cx:A(re.n),cy:F(re.total_usd),r:_e===y?0:3,className:ae(Yu(re.path).fill),fillOpacity:.65},re.run_id)),R&&t.jsxs("g",{children:[t.jsx("path",{d:`M${Ot.left},${F(R.mean_usd)}H${Ot.left+_}`,className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"6 4"}),t.jsxs(yg,{x:Ot.left+_-4,y:F(R.mean_usd)-6,anchor:"end",children:["Before takeover ",ir(R.mean_usd)]})]}),z&&t.jsxs("g",{children:[t.jsx("path",{d:`M${A(z.n)},${q-4}V${q+qr}`,className:"stroke-chart-workflow",strokeWidth:1.5}),t.jsxs(yg,{x:A(z.n)+(De?-6:6),y:q+6,anchor:De?"end":"start",children:["Workflow took over, run ",z.n]})]}),Y!==null&&g.after&&t.jsxs("g",{children:[t.jsx("path",{d:`M${A(Y)},${F(g.after.mean_usd)}H${Ot.left+_}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsxs(yg,{x:Ot.left+_-4,y:F(g.after.mean_usd)-8,anchor:"end",strong:!0,children:[$<520?"Served":`Served after takeover (${cx(g.after.runs)})`," ",ir(g.after.mean_usd),le?` · ${le}`:""]})]}),t.jsx("path",{d:J,fill:"none",className:"stroke-foreground",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),X&&t.jsxs("g",{children:[t.jsx("path",{d:`M${A(X.n)},${q}V${q+qr}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("circle",{cx:A(X.n),cy:F(X.total_usd),r:5,className:ae(Yu(X.path).fill,"stroke-card"),strokeWidth:2})]})]}),Ue&&!X&&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",A(Ue.n)>$*.6&&"-translate-x-full"),"data-testid":"marker-tip",style:{left:A(Ue.n)>$*.6?A(Ue.n)-L/2-12:A(Ue.n)-L/2+12,top:Ot.top},children:qk(Ue).map((re,_e)=>t.jsx("span",{className:ae("block",_e===0?"font-semibold":"text-muted-foreground"),children:re},_e))}),X&&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",A(X.n)>$*.6&&"-translate-x-full"),style:{left:A(X.n)>$*.6?A(X.n)-10:A(X.n)+10,top:q},children:[Le(X).map((re,_e)=>t.jsx("span",{className:ae("block",_e===0?"font-semibold":"text-muted-foreground"),children:re},re)),t.jsx("span",{className:"block text-muted-foreground",children:ht(X.started_at)})]}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:X?Le(X).join(", "):""}),f.length>0&&t.jsx("p",{className:"sr-only",children:`Markers: ${f.map(re=>qk(re).join(", ")).join(". ")}.`})]}),t.jsx(Hk,{runs:e.runs,width:$,x:A,step:L,plot:[Ot.left,Ot.left+_],takeover:((Ee=g.takeover)==null?void 0:Ee.n)??null}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Each dot is a run: its own cost plus what learning spent for it (the look-back and the grade). The line is the mean of the last ",d," runs",i.some(re=>re.path==="replay")?", replay runs (hollow) left out":"",".",D?` ${D===1?"1 run costs":`${D} runs cost`} more than ${Ro(P)} and ${D===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,...ZL(e,n,o)].map(re=>t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:re},re))]}),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(re=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:re},re))})}),t.jsx("tbody",{children:e.runs.map(re=>{var _e;return t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:re.n}),t.jsx("td",{className:"pr-4",children:ht(re.started_at)}),t.jsxs("td",{className:"pr-4",children:[Yu(re.path).label,re.workflow?`: ${re.workflow}`:""]}),t.jsx("td",{className:"pr-4",children:((_e=re.learned_revision)==null?void 0:_e.slice(0,7))??"-"}),t.jsx("td",{className:"pr-4",children:re.cost_usd===null?"unknown":Ro(re.cost_usd)}),t.jsx("td",{className:"pr-4",children:re.learning_usd===null?"unknown":Ro(re.learning_usd)}),t.jsx("td",{className:"pr-4",children:re.total_usd===null?"unknown":Ro(re.total_usd)})]},re.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(re=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:re},re))})}),t.jsx("tbody",{children:f.map(re=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:re.n}),t.jsxs("td",{className:"pr-4",children:[Vv[re.kind]," ",Oc[re.kind]]}),t.jsx("td",{className:"pr-4",children:re.workflow}),t.jsx("td",{className:"pr-4",children:re.digest.slice(0,7)}),t.jsx("td",{className:"pr-4 font-sans",children:Ma(re.record)})]},`${re.kind}:${re.n}:${re.workflow}:${re.digest}:${re.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 JL=64,Ao={top:4,bottom:6},XL=[...Oa].reverse(),Wk=e=>e.from===e.to?`Run ${e.from}`:`Runs ${e.from} to ${e.to}`;function Hk({runs:e,width:n,x:s,step:r,plot:o,takeover:i}){const c=JL,d=AL(e.length),u=p.useMemo(()=>OL(e,d),[e,d]),[f,g]=p.useState(null);if(!u.length)return null;const[b,x]=o,h=O=>Math.min(x,Math.max(b,O)),v=O=>({from:h(s(O.from)-r/2),to:h(s(O.to)+r/2)}),y=O=>Ao.top+c*(1-O),j=u.at(-1),k=O=>{const{from:L,to:A}=v(O),R=A-L>4?1:0;return{x0:L+R,w:Math.max(1,A-L-2*R)}},E=O=>`${Wk(O)}: ${Oa.filter(L=>O.counts[L.path]).map(L=>`${L.label.toLowerCase()} ${O.counts[L.path]}`).join(", ")}`,S=u.some(O=>O.counts.workflow)?`${jf(j.counts.workflow,j.runs)} by the learned workflow`:Oa.filter(O=>j.counts[O.path]).map(O=>`${jf(j.counts[O.path],j.runs)} ${O.label.toLowerCase()}`).join(", "),N=`Last ${j.runs===1?"run":`${j.runs} runs`}: ${S}`,$=f===null?null:u[f],_=$?k($).x0>n/2:!1,M=i!==null&&s(i)>=b&&s(i)<=x;return t.jsxs("div",{className:"relative min-w-0",style:{width:n},"data-testid":"execution-mix",children:[t.jsxs("div",{className:"font-mono text-label",style:{paddingLeft:b},children:[t.jsxs("span",{className:"caps block text-muted-foreground",children:["Who finished each run",d>1?`, by ${d}`:""]}),t.jsx("span",{className:"block text-foreground",children:N})]}),t.jsxs("svg",{width:n,height:Ao.top+c+Ao.bottom,className:"mt-2 block select-none font-mono","aria-hidden":!0,onPointerLeave:()=>g(null),children:[[0,.5,1].map(O=>t.jsxs("text",{x:b-6,y:y(O),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:[O*100,"%"]},O)),u.map((O,L)=>{const{x0:A,w:R}=k(O);let P=Ao.top+c;return t.jsxs("g",{onPointerEnter:()=>g(L),opacity:f===null||f===L?1:.55,children:[t.jsx("rect",{x:v(O).from,y:Ao.top,width:Math.max(1,v(O).to-v(O).from),height:c,className:"fill-card",fillOpacity:0}),XL.map(D=>{const W=O.counts[D.path]/O.runs*c;if(!W)return null;P-=W;const K=P>Ao.top+.5?Math.min(2,W):0;return t.jsx("rect",{x:A,y:P+K,width:R,height:W-K,className:D.fill,fillOpacity:.8},D.path)})]},O.from)}),M&&t.jsx("g",{"data-testid":"mix-takeover",children:t.jsx("path",{d:`M${s(i)-r/2},${Ao.top}V${Ao.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:Wk($)}),Oa.filter(O=>$.counts[O.path]).map(O=>t.jsxs("span",{className:"block text-muted-foreground",children:[O.label," ",$.counts[O.path]," (",jf($.counts[O.path],$.runs),")"]},O.path))]}),t.jsx("p",{className:"sr-only",children:`Execution mix in blocks of ${d} runs. ${u.map(E).join(". ")}. ${N}.`})]})}function ZL(e,n,s){const r=e.summary;return!r.takeover&&s!=="hosted"?[W2(s)]:r.takeover?r.withheld?[`${D2(r.withheld)}: ${F2}.`]: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?[`${cx(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.":U2]}function Bk({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(ke,{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 H2={promote:"stroke-chart-workflow",hold:"stroke-warning",refit:"stroke-foreground",revision:"stroke-muted-foreground",queued:"stroke-muted-foreground",skipped:"stroke-muted-foreground"},eI={promote:"fill-foreground",hold:"fill-warning-text",refit:"fill-foreground",revision:"fill-muted-foreground",queued:"fill-muted-foreground",skipped:"fill-muted-foreground"};function Gk({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",H2[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",eI[s]),children:Vv[s]})]})}const qk=e=>[`${Oc[e.kind]} · run ${e.n}`,`${e.workflow} ${e.digest.slice(0,7)}`,Ma(e.record),ht(e.at)];function yg({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 tI(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 nI(e){var i;const n=tI(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 Kk=500,sI=5,dx=e=>e.status==="running";function rI(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 oI={agent:"by hand",handed_back:"handed back",workflow:"workflow"},aI=2e3;function iI({v2:e,agentId:n,onFinished:s,pollMs:r=aI}){const[o,i]=p.useState(void 0),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,b]=p.useState(0),x=p.useRef(!1),h=p.useRef(s);if(h.current=s,p.useEffect(()=>{let y=!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(!y)return;i(_),d(null),_&&dx(_)?(x.current=!0,j=setTimeout(()=>void k(_.id),r)):_&&x.current&&(x.current=!1,(N=h.current)==null||N.call(h))}catch($){if(!y)return;d($??new Error("unknown")),j=setTimeout(()=>void k(E),r*2)}};return k(),()=>{y=!1,clearTimeout(j)}},[e,n,r,g]),o===void 0&&!c)return t.jsx(pn,{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),b(y=>y+1)},children:"Read again"})]});const v=o&&dx(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"}),!v&&!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&&!v&&t.jsx(lI,{v2:e,agentId:n,onStarted:y=>{x.current=!0,i(y),f(!1),b(j=>j+1)},onCancel:()=>f(!1)}),o&&!u&&t.jsx(uI,{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 lI({v2:e,agentId:n,onStarted:s,onCancel:r}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[g,b]=p.useState(""),[x,h]=p.useState(String(sI)),[v,y]=p.useState(!1),[j,k]=p.useState(null),E=async _=>{var A;const M=(A=_.target.files)==null?void 0:A[0];if(!M)return;k(null);const O=nI(await M.text());if("error"in O){i(null),d(O.error);return}d(O.rows.length>Kk?`A batch takes at most ${Kk} rows: this file has ${O.rows.length}.`:null),i({name:M.name,columns:O.columns,rows:O.rows});const L=O.columns.at(-1);b(L),f(O.columns.filter(R=>R!==L))},S=Number(x),N=!!o&&!c&&u.length>0&&!!g&&!u.includes(g)&&Number.isFinite(S)&&S>0,$=async()=>{var _,M;if(!(!o||!N)){y(!0),k(null);try{s(await e.startLearningBatch(n,{inputs:u,answer:g,rows:o.rows,max_cost_usd:S}))}catch(O){k(O instanceof Fe?((M=(_=O.fields)==null?void 0:_[0])==null?void 0:M.message)??O.message:O instanceof Error?O.message:String(O)),y(!1)}}};return t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsx(bt,{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(bt,{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(j5,{label:_,checked:u.includes(_),disabled:_===g,onChange:M=>f(O=>M.target.checked?o.columns.filter(L=>O.includes(L)||L===_):O.filter(L=>L!==_))},_))})}),t.jsx(bt,{label:"The answer column",note:"What the agent is told after each answer: the reference it should have given.",children:t.jsx(Ct,{label:"The answer column",value:g,onChange:_=>{b(_),f(M=>M.filter(O=>O!==_))},options:o.columns.map(_=>({value:_,label:_}))})}),t.jsx(bt,{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 ${to(S)} for ${o.rows.length} rows.`:void 0,children:t.jsx(Pe,{inputMode:"decimal",value:x,onChange:_=>h(_.target.value),className:"max-w-40","aria-label":"Cap, in dollars"})}),t.jsx(cI,{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||v,onClick:()=>void $(),children:v?"Starting":"Learn"}),t.jsx(B,{variant:"ghost",onClick:r,disabled:v,children:"Cancel"})]})]})}function cI({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 dI={running:"active",completed:"success",cancelled:"muted",stopped:"warning"};function uI({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(b){d(b instanceof Error?b.message:String(b))}i(!1)},f=rI(s),g=s.cost_usd===null?"unknown":to(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(ke,{tone:dI[s.status],children:s.status}),t.jsxs("span",{className:"font-mono text-body",children:[s.finished," of ",s.total," rows"]})]}),dx(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(vt,{tone:"warning",children:f}),s.status==="completed"&&t.jsx(vt,{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(Oo,{label:"Right",value:`${s.right}`}),t.jsx(Oo,{label:"Wrong",value:`${s.wrong}`}),t.jsx(Oo,{label:"Failed",value:`${s.failed}`}),t.jsx(Oo,{label:"Cost so far",value:`${g} of ${to(s.max_cost_usd)}`}),t.jsx(Oo,{label:"Notes learned",value:`${s.lessons.notes.length}`}),t.jsx(Oo,{label:"Skills learned",value:`${s.lessons.skills.length}`}),t.jsx(Oo,{label:"Workflow revisions",value:`${s.revisions.length}`}),t.jsx(Oo,{label:"Paths",value:`${s.paths.agent} by hand, ${s.paths.handed_back} handed back, ${s.paths.workflow} workflow`})]}),s.lessons.notes.length+s.lessons.skills.length+s.lessons.workflows.length>0&&t.jsxs("p",{className:"text-body text-muted-foreground",children:["Learned: ",[...s.lessons.notes,...s.lessons.skills.map(b=>`${b} (skill)`),...s.lessons.workflows.map(b=>`${b} (workflow)`)].join(", "),"."]}),t.jsx("div",{className:"max-h-96 overflow-auto",children:t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{children:["Row","Result","Path","Cost","Answer","Reference"].map(b=>t.jsx("th",{className:"caps sticky top-0 border-b bg-card px-2 py-1 text-left font-semibold",children:b},b))})}),t.jsx("tbody",{children:s.rows.map(b=>t.jsxs("tr",{"aria-current":s.current===b.n?"step":void 0,children:[t.jsx("td",{className:"border-b px-2 py-1",children:b.n}),t.jsx("td",{className:"border-b px-2 py-1",children:b.state==="done"?t.jsx(ke,{tone:b.right?"success":"error",children:b.right?"right":"wrong"}):b.state==="failed"?t.jsx(ke,{tone:"error",title:b.error,children:"failed"}):t.jsx(ke,{tone:b.state==="running"?"active":"muted",children:b.state==="running"?"running":"waiting"})}),t.jsx("td",{className:"border-b px-2 py-1",children:b.path?oI[b.path]:""}),t.jsx("td",{className:"border-b px-2 py-1",children:b.total_usd==null?"":to(b.total_usd)}),t.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:b.answer??void 0,children:b.answer??""}),t.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:b.reference,children:b.reference})]},b.n))})]})})]})}const Oo=({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})]}),fI="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).",bg=e=>`${Math.round(e*1e3)/10}%`;function mI(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:bg(e.accuracy),accuracyVs:`95% interval ${bg(i)} to ${bg(c)}, n=${e.n.toLocaleString("en-US")}`,cost:r?o===null||s===0?ir(n):o>=1?`${lx(o)} cheaper`:`${lx(n/s)} the cost`:n!==null?ir(n):"Not counted",costVs:r?`${ir(n)} a task vs ${ir(s)} by hand`:n!==null?`${ir(n)} a task; by hand not counted`:"The test did not count the cost a task."}}function Vk({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(ss,{problem:Tr(i,"the held-out test"),onRetry:()=>u(f=>f+1),className:""}):r?t.jsx(hI,{result:r.latest}):t.jsx(pn,{className:"h-[116px] w-full"})}function hI({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," · ",ht(e.recorded_at),e.learned_revision?` · revision ${e.learned_revision.slice(0,7)}`:""]})]}),e?t.jsx(pI,{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:fI})]})]})}function pI({result:e}){const n=mI(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 Hf="https://api.githubcopilot.com/mcp/",wd={composio:"Composio",github:"GitHub",url:"URL"},Yk=/^[a-z][a-z0-9-]{0,31}$/,Jv=[{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:Hf,readOnly:`${Hf}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."}],B2=e=>Jv.find(n=>n.id===e);function gI(e){const n=new URLSearchParams(e??""),s=n.get("add");if(!s||!Yk.test(s))return;const r=n.get("toolkit")??"",o=n.get("preset")??void 0;if(o==="composio"&&Yk.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=B2(o);return i?{name:s,preset:i.id}:{name:s,...n.get("auth")==="github_app"?{auth:"github_app"}:{}}}const xI="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.",G2=(e,n)=>`mcp:${e}/${n}`;function Go(e){const n=/^mcp:([^/]+)\/(.+)$/.exec(e);return n?{server:n[1],tool:n[2]}:null}function vI(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 yI(e,n){return e.flatMap(s=>{const r=Go(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 Qk=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 oo(e){var i,c,d,u,f,g,b,x;if(!(e instanceof Fe))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:Qk(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:Qk(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.`}:{}}:(b=e.fields)!=null&&b.length?{text:e.fields.map(h=>h.message).join(" "),...typeof((x=e.details)==null?void 0:x.composio)=="string"?{detail:e.details.composio}:{}}:{text:`${e.code}: ${e.message}`}}const Jk={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"},bI="the sign-in didn't finish: try again",wI=e=>e&&Object.hasOwn(Jk,e)?Jk[e]:bI;function jI(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 jd=Go;function kI(e){const n=Go(e);return n?`${n.server} · ${n.tool}`:null}const NI="https://chatgpt.com/#settings",ux="chatgpt",qc=e=>!!e&&e.startsWith(`${ux}/`)&&e.length>ux.length+1,q2="Codex and pi agents run on your ChatGPT plan. Claude Agent, OpenCode, Jev decisions and paid tools need their own keys.",SI="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.",CI="This sign-in is yours: don't let other people run agents on this server with it.",EI="Signed out. If ChatGPT still lists AgentRun under connected apps, disconnect it there.",$I="Signed out here. OpenAI didn't confirm the revocation: remove AgentRun in your ChatGPT settings.",_I="Your ChatGPT sign-in expired. Sign in again.",K2="Requests on your ChatGPT plan cost no dollars here; your plan's own limits apply.",TI=`Counts dollars. ${K2}`,RI=new Set(["signed_out","pending","signed_in","expired"]),Bf=e=>e&&typeof e=="object"&&RI.has(String(e.state))?e:null,AI=e=>e.charAt(0).toUpperCase()+e.slice(1),OI=e=>`Signed in as ${e.email??"your ChatGPT account"}${e.plan?` (${AI(e.plan)})`:""}`;function ul(e,n){return qc(e)?{text:`${e.slice(ux.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 V2(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 MI(e,n,s,r){return!e||typeof r!="number"||qc(e)?null:V2(n,s).has(e)?`free model: up to ${r} requests`:null}function PI(e){return e>=1e6?`${Math.round(e/1e6*10)/10}M`.replace(/\.0M$/,"M"):`${Math.round(e/1e3)}K`}function LI(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.models)??[]}function Y2(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 II="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",zI="none yet: add a model key in Settings → Model keys",Q2=e=>ul(e,null).text,Xv=(e,n)=>[e,n!=null&&n.model?n.tier:void 0,n!=null&&n.model?Q2(n.model):void 0].filter(Boolean).join(" · "),J2=e=>e!=null&&e.model?`ran on ${Q2(e.model)}${e.tier?` (the ${e.tier} tier)`:""}`:"",DI="http://www.w3.org/2000/svg",Oi=16,ln=240,FI=40,UI=58,wg=16,jg=26,Xu=18,Mi=14,Xk=16,WI=26,HI=14,BI=22,Ds=14,Zk=16,Zu=16,GI=4,qI=10,KI=18,VI=30,YI=5,Cc=124,fx=34,QI=4,kg=10*.6,JI=12.5*.6,Kc=10.5*.6,e0=11*.6,Zv=9*.66,t0=10.5*.6,XI={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"},ey=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),Gf={review:"needs review","not-run":"",pending:""};function wt(e,n,...s){const r=document.createElementNS(DI,e);if(n)for(const[o,i]of Object.entries(n))r.setAttribute(o,String(i));for(const o of s)ks(r,o);return r}function ks(e,n){if(n!=null){if(Array.isArray(n)){for(const s of n)ks(e,s);return}e.appendChild(typeof n=="string"?document.createTextNode(n):n)}}const Er=(e,n)=>e.length>n?`${e.slice(0,n-1)}…`:e,ZI=(e,n)=>{const s=/^(.*) (\d\.\d\d)$/.exec(e);return!s||e.length<=n?Er(e,n):`${Er(s[1],Math.max(2,n-s[2].length-1))} ${s[2]}`},Fo=(e,n)=>Math.max(2,Math.floor(e/n)),qo=(e,n)=>Math.ceil(e.length*n),Ws=(e,n,s,r,o)=>wt("line",{x1:e,y1:n,x2:s,y2:r,class:o?`wire ${o}`:"wire"});function X2(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 ty(e,n){var u,f,g,b;const{diff:s={},status:r={},fired:o}=e.marks,i=n===o?"escalated":r[n],c=i&&ey.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:((b=e.marks.selected)==null?void 0:b.path)===n&&e.marks.selected.item==null}}function kd(e,n,s){var x,h,v;const r=ty(e,n.path),o=(x=e.marks.meta)==null?void 0:x[n.path],i=o!=null&&o.tool?jd(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)?`, ${J2(c)}`:""})`;r.state&&(u+=`: ${r.state.replace("-"," ")}`),r.tag&&(u+=`${r.state?", ":": "}${r.tag.toLowerCase()}`),(v=o==null?void 0:o.questions)!=null&&v.length&&(u+=`
|
|
632
|
+
${o.questions.map(y=>`• ${y.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-${XI[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 b=wt("g",{class:g,"data-path":n.path},wt("title",null,u));return e.svg.appendChild(b),b}const Xi=e=>qo(e,Zv)+10;function kf(e,n,s,r,o="tag"){const i=Xi(r);return ks(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 ez=(e,n)=>{var s,r;return!!((r=(s=e.marks.meta)==null?void 0:s[n.path])!=null&&r.decision)},Bm=(e,n)=>ez(e,n)?UI:FI;function ny(e,n,s,r,o){var k,E,S,N,$;const i=ty(e,s.path),c=(k=e.marks.meta)==null?void 0:k[s.path],d=Bm(e,s),u=(E=e.marks.verdict)==null?void 0:E[s.path],f=i.state in Gf?Gf[i.state]:i.state,g=((S=c==null?void 0:c.questions)==null?void 0:S.length)??0,b=c!=null&&c.tool?jd(c.tool):null,x=(N=e.marks.ran)==null?void 0:N[s.path],h=(x&&!(c!=null&&c.decision)?Xv(s.kind,x):s.kind)+(b?` · ${b.tool} on ${b.server}`:c!=null&&c.tool?` · ${c.tool}`:s.via?` · ${s.via}`:"")+(c!=null&&c.decision&&g?` · ${g} ${g===1?"question":"questions"}`:""),v=[($=c==null?void 0:c.images)!=null&&$.length?"IMG":"",c!=null&&c.web?"WEB":"",b?"MCP":""].filter(Boolean),y=v.reduce((_,M)=>_+Xi(M)+4,0);i.selected&&n.appendChild(wt("rect",{x:r-4,y:o-4,width:ln+8,height:d+8,class:"sel"})),ks(n,[wt("rect",{x:r,y:o,width:ln,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"},Er(s.label,Fo(ln-34-y,JI))),wt("text",{x:r+24,y:o+31,class:"kind"},Er(h,Fo(ln-34-(f?qo(f,Zv)+8:0),Kc))),f?wt("text",{x:r+ln-10,y:o+31,class:"state","text-anchor":"end"},f):null]);let j=r+ln-8;for(const _ of v.reverse())j-=Xi(_),kf(n,j,o+7,_,"badge"),j-=4;if(c!=null&&c.decision&&c.provider){const _=kf(n,r+24,o+38,c.provider,"chip"),M=u?ZI(u,Fo(ln-44-_-20,t0)):"",O=ln-40-_-(M?qo(M,t0)+10:0),L=(x==null?void 0:x.model)??c.model;L&&O>24&&n.appendChild(wt("text",{x:r+24+_+6,y:o+47.5,class:"model"},Er(L,Fo(O,Kc)))),M&&n.appendChild(wt("text",{x:r+ln-10,y:o+47.5,class:"verdict","text-anchor":"end"},M))}else u&&n.appendChild(wt("text",{x:r+ln-10,y:o+17,class:"verdict","text-anchor":"end"},u));i.tag&&kf(n,r+ln-Xi(i.tag),o-7,i.tag)}function tz(e,n){return{w:ln,h:Bm(e,n),cx:ln/2,place:(s,r)=>ny(e,kd(e,n,"card"),n,s,r)}}function Z2(e,n,s){const r=ty(e,n.path),o=r.state==="done"?"passed":r.state in Gf?Gf[r.state]:r.state,i=Er(n.label===n.kind?"exit":`exit: ${n.label}`,40),c=qo(i,Kc)+16;return{w:Mi+c+(r.tag?6+Xi(r.tag):0)+(o?6+qo(o,Zv):0),h:jg,cx:0,exit:!0,place:(d,u)=>{const f=kd(e,n,"exit"),g=u+jg/2;let b=d+Mi+c;s&&f.appendChild(Ws(d,u,d,u+jg,"spine")),r.selected&&f.appendChild(wt("rect",{x:d+Mi-3,y:g-Xu/2-3,width:c+6,height:Xu+6,class:"sel"})),ks(f,[Ws(d,g,d+Mi,g,"exit-wire"),wt("rect",{x:d+Mi,y:g-Xu/2,width:c,height:Xu,class:"exit-box"}),wt("text",{x:d+Mi+8,y:g+3.5,class:"exit-text"},i)]),r.tag&&(kf(f,b+6,g-6.5,r.tag),b+=6+Xi(r.tag)),o&&f.appendChild(wt("text",{x:b+6,y:g+3.5,class:"state"},o))}}}function nz(e,n,s){const r=s.map(d=>d.node.kind==="escalate"?Z2(e,d.node,!1):Gm(e,d.node));let o=ln/2,i=ln/2,c=-wg;for(const d of r)o=Math.max(o,d.cx),i=Math.max(i,d.w-d.cx),c+=d.h+wg;return{w:o+i,h:c,cx:o,place:(d,u)=>{const f=kd(e,n,"chain"),g=d+o;let b=u,x=null;r.forEach((h,v)=>{v&&(b+=wg),h.exit?x===null&&(x=b):x!==null&&f.appendChild(Ws(g,x,g,b,"spine")),h.place(h.exit?g:g-h.cx,b),b+=h.h,h.exit||(x=b)}),r[r.length-1].exit&&x!==null&&f.appendChild(Ws(g,x,g,b,"spine"))}}}function sz(e,n,s){const r=Bm(e,n),o=s.map(h=>({kid:h,box:Gm(e,h.node),x:0,c:0}));let i=0,c=0;o.forEach((h,v)=>{v&&(i+=BI),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-ln/2),g=Math.max(i,u+ln/2),b=r+Xk+WI,x=b+c+HI;return{w:g-f,h:x,cx:u-f,place:(h,v)=>{const y=kd(e,n,"card"),j=h-f,k=v+r+Xk,E=v+x;ny(e,y,n,j+u-ln/2,v),y.appendChild(Ws(j+u,v+r,j+u,k)),d&&ks(y,[Ws(j+o[0].c,k,j+o[d].c,k),Ws(j+o[0].c,E,j+o[d].c,E)]),o.forEach((S,N)=>{const $=j+S.c,_=S.kid.node.path,M=e.taken.has(_);if(y.appendChild(wt("line",{x1:$,y1:k,x2:$,y2:v+b,class:M?"wire branch taken":"wire branch","data-to":_})),S.kid.name!==null){const O=(N<d?o[N+1].c-6:S.x+S.box.w)-S.c-12,L=Er(S.kid.name,Fo(O,Kc)),A=wt("text",{x:$+6,y:k+15,class:M?"branch-name taken":"branch-name"},L);y.appendChild(L===S.kid.name?A:wt("g",null,wt("title",null,S.kid.name),A))}y.appendChild(Ws($,v+b+S.box.h,$,E,M?"taken":void 0)),S.box.place(j+S.x,v+b)})}}}const rz=e=>e.replace(/^.*\//,"").replace(/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,"");function oz(e,n,s,r,o,i){const c=ey.has(s.status)?s.status:"pending",d=s.label?rz(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})`:""}`,b=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:Cc,height:fx,class:"cell"}),wt("rect",{x:r,y:o,width:3,height:fx,class:"cell-edge"}),wt("text",{x:r+9,y:o+14,class:"cell-name"},Er(d,Fo(Cc-14,kg))),wt("text",{x:r+9,y:o+27,class:"cell-out"},Er(u,Fo(Cc-18-(f?qo(f,kg)+6:0),kg))),f?wt("text",{x:r+Cc-6,y:o+27,class:"cell-p","text-anchor":"end"},f):null);e.appendChild(b)}function az(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<=VI,[o,i,c]=r?[Cc,fx,QI]:[Zu,Zu,GI],d=Math.min(s.length,r?YI:qI),u=Math.ceil(s.length/d),f=d*(o+c)-c,g=u*(i+c)-c+KI+(r?4:0),b={};for(const k of s)b[k.status]=(b[k.status]??0)+1;const x={};for(const k of s)k.outcome&&(x[k.outcome]=(x[k.outcome]??0)+1);const h=Object.entries(x).map(([k,E])=>`${E} ${k}`),y=[`${b.done??0}/${s.length} done`,b.working?`${b.working} working`:"",b.held?`${b.held} held`:"",b.failed?`${b.failed} failed`:"",b.review?`${b.review} review`:"",...h].filter(Boolean).join(" · ");return{w:Math.max(f,qo(y,Kc)),h:g,place:(k,E,S)=>{const N=E-f/2,$=e.marks.selected;s.forEach((_,M)=>{const O=N+M%d*(o+c),L=S+Math.floor(M/d)*(i+c),A=ey.has(_.status)?_.status:"pending",R=($==null?void 0:$.path)===n.path&&$.item===_.index;if(r){oz(k,n,_,O,L,R);return}ks(k,wt("rect",{x:O,y:L,width:Zu,height:Zu,class:`cell ${A}${R?" picked":""}`,"data-path":n.path,"data-item":_.index},wt("title",null,`#${_.index+1}${_.label?` ${_.label}`:""}: ${A==="review"?"needs review":A.replace("-"," ")}`)))}),ks(k,wt("text",{x:E,y:S+g-4,class:"caption","text-anchor":"middle"},y))}}}function iz(e,n,s){const r=Gm(e,s),o=Bm(e,n),i=n.kind==="map"?az(e,n):null,c=i?i.h+Ds:0,d=Math.max(ln/2,r.cx,i?i.w/2:0)+Ds,u=Math.max(ln/2,r.w-r.cx,i?i.w/2:0)+Ds,f=o+Ds+c+r.h+Ds;return{w:d+u,h:f,cx:d,place:(g,b)=>{const x=kd(e,n,"card"),h=g+d;if(ks(x,wt("rect",{x:g,y:b+o/2,width:d+u,height:f-o/2,class:"frame"})),i?(ks(x,Ws(h,b+o,h,b+o+Ds)),ks(x,Ws(h,b+o+Ds+i.h,h,b+o+Ds+c))):ks(x,Ws(h,b+o,h,b+o+Ds)),ks(x,Ws(h,b+o+Ds+c+r.h,h,b+f)),ny(e,x,n,h-ln/2,b),i){const v=wt("g",{class:"items"});i.place(v,h,b+o+Ds),x.appendChild(v)}r.place(h-r.cx,b+o+Ds+c)}}}function eC(e,n){return e.kind==="escalate"?"exit":n.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function Gm(e,n){const s=e.kids[n.path]??[],r=eC(n,s);return r==="exit"?Z2(e,n,!0):r==="leaf"?tz(e,n):r==="chain"?nz(e,n,s):r==="fan"?sz(e,n,s):iz(e,n,s[0].node)}function sy(e){const{byPath:n,kids:s}=X2(tC(e)),r=o=>{const i=s[o.path]??[],c=eC(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 qm=e=>`${e} ${e===1?"node":"nodes"}`,tC=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 lz(e,n,s={}){var g;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const r=X2(tC(n)),o=(b,x)=>(e.setAttribute("viewBox",`0 0 ${b} ${x}`),e.setAttribute("width",String(b)),e.setAttribute("height",String(x)),e.style.setProperty("min-width",`${Math.min(b,480)}px`),{w:b,h:x});if(!r.byPath["/root"])return o(0,0);const i={svg:e,kids:r.kids,marks:s,taken:new Set(s.taken??[])},c=Gm(i,r.byPath["/root"]);c.place(Oi,Oi);let d=c.w,u=c.h;const f=(((g=s.diff)==null?void 0:g.removed)??[]).map(b=>`${b.label} (${b.kind})`);if(f.length){const b=["Removed:",...f.map(h=>Er(h,Fo(Math.max(d,300),e0)))],x=wt("g",{class:"removed-list"},wt("title",null,`Removed: ${f.join(", ")}`));b.forEach((h,v)=>{x.appendChild(wt("text",{x:Oi,y:Oi+u+33+v*Zk,class:"removed"},h)),d=Math.max(d,qo(h,e0))}),e.appendChild(x),u+=22+b.length*Zk}return o(d+2*Oi,u+2*Oi)}function cz(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 dz=1600;function Nd({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,b]=p.useState(0),x=p.useMemo(()=>JSON.stringify([(e==null?void 0:e.nodes)??null,n??null]),[e,n]);p.useEffect(()=>{if(!d.current)return;const v=lz(d.current,e,n);f(y=>y.w===v.w&&y.h===v.h?y:v),d.current.style.setProperty("--wf-phase",`-${Date.now()%dz}ms`)},[x]),p.useEffect(()=>{var j;const v=(j=d.current)==null?void 0:j.parentElement;if(!v||typeof ResizeObserver>"u")return;const y=new ResizeObserver(([k])=>b(k.contentRect.width));return y.observe(v),()=>y.disconnect()},[]);const h=u.w&&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:v=>{const y=cz(v.target);y&&s&&s(y)}})}function Sd({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 nC={self:"self",jev:"jev",both:"self+jev"},uz=e=>`${nC[e.signal]} ≥${e.threshold.toFixed(2)}`,fz=(e,n)=>n?`${Math.round(e/n*100)}%`:"0%";function mz({guards:e,workflow:n,digest:s,loop:r}){return e.length?t.jsxs("section",{className:"border","aria-label":"Where it is unsure","data-testid":"step-guards",children:[t.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-3 py-2",children:[t.jsx("h3",{className:"caps text-label font-semibold",children:"Where it is unsure"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Each guarded step hands the run back to the agent when its p is under the threshold."})]}),t.jsx("ul",{className:"divide-y",children:e.map(o=>t.jsx(hz,{guard:o,stats:BL(r,n,s,o.node)},o.node))}),t.jsx(gz,{})]}):null}function hz({guard:e,stats:n}){const s=(n==null?void 0:n.right)??0,r=(n==null?void 0:n.wrong)??0,o=(n==null?void 0:n.replays)??0,i=(n==null?void 0:n.grades_past)??0,c=s+r?` · graded ${s} right, ${r} wrong`:i?"":" · none graded",d=i?` · ${i} older ${i===1?"run's grade is":"runs' grades are"} past the newest grades kept`:"";return t.jsxs("li",{className:"grid grid-cols-1 gap-x-4 gap-y-2 px-3 py-2.5 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center","data-testid":"guard-row",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"min-w-0 break-words font-mono text-body font-semibold",children:e.node}),t.jsx(ke,{tone:"plain",title:`Reads ${WL[e.signal]}`,children:nC[e.signal]}),t.jsxs(ke,{tone:"muted",children:[e.fitted?"fitted":"threshold"," ",e.threshold.toFixed(2)]})]}),t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:n&&n.runs?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:ae("font-semibold",n.escalated/n.runs>.25?"text-warning-text":"text-foreground"),children:[fz(n.escalated,n.runs)," handed back"]})," (",n.escalated," of ",n.runs," runs)",c,d,o?` · ${o} replay ${o===1?"run":"runs"} apart`:""]}):o?`Replayed on ${o} graded ${o===1?"input":"inputs"}; no run served yet.`:"No run of this revision yet."})]}),n&&n.points.length>0&&t.jsx(pz,{guard:e,stats:n})]})}const Mo=168,br=36,n0=2;function pz({guard:e,stats:n}){const s=HL(n.points),r=Math.max(1,...s.map(d=>d.right+d.wrong+d.ungraded)),o=Mo/s.length,i=d=>Math.min(Mo-1,Math.max(1,d*Mo)),c=s.filter(d=>d.right+d.wrong+d.ungraded).map(d=>`p ${d.from.toFixed(1)} to ${d.to.toFixed(1)}: ${[d.right&&`${d.right} right`,d.wrong&&`${d.wrong} wrong`,d.ungraded&&`${d.ungraded} not graded`].filter(Boolean).join(", ")}`);return t.jsxs("figure",{className:"m-0 shrink-0","data-testid":"guard-histogram",children:[t.jsxs("svg",{width:Mo,height:br+14,className:"block font-mono","aria-hidden":!0,children:[s.map(d=>{let u=br;const f=[[d.right,"fill-success"],[d.wrong,"fill-destructive"],[d.ungraded,"fill-muted-foreground"]];return t.jsxs("g",{children:[t.jsx("title",{children:`p ${d.from.toFixed(1)}–${d.to.toFixed(1)}: ${d.right} right, ${d.wrong} wrong, ${d.ungraded} not graded`}),t.jsx("rect",{x:d.from*Mo,y:0,width:o,height:br,className:"fill-card",fillOpacity:0}),f.map(([g,b])=>{if(!g)return null;const x=g/r*(br-2);u-=x;const h=u>.5&&u+x<br-.5?1:0;return t.jsx("rect",{x:d.from*Mo+n0/2,y:u+h,width:o-n0,height:Math.max(1,x-h),className:b,fillOpacity:b==="fill-muted-foreground"?.45:.85},b)})]},d.from)}),t.jsx("path",{d:`M0,${br+.5}H${Mo}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("path",{d:`M${i(e.threshold)},0V${br+3}`,className:"stroke-foreground",strokeWidth:1.5,strokeDasharray:"3 2"}),t.jsx("text",{x:0,y:br+12,className:"fill-muted-foreground text-micro",children:"0"}),t.jsx("text",{x:Mo,y:br+12,textAnchor:"end",className:"fill-muted-foreground text-micro",children:"1"}),t.jsx("text",{x:i(e.threshold),y:br+12,textAnchor:"middle",className:"fill-foreground text-micro font-semibold",children:e.threshold.toFixed(2)})]}),n.points.length<n.runs&&t.jsxs("p",{className:"m-0 font-mono text-micro text-muted-foreground",children:["p of the newest ",n.points.length," runs"]}),t.jsx("figcaption",{className:"sr-only",children:`${e.node}: p by run${n.points.length<n.runs?`, the newest ${n.points.length} of ${n.runs}`:""}. ${c.join(". ")}.`})]})}function gz(){const e=[["Right","fill-success",.85],["Wrong","fill-destructive",.85],["Not graded","fill-muted-foreground",.45]];return t.jsxs("p",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"caps",children:"p by run"}),e.map(([n,s,r])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"10",height:"10","aria-hidden":!0,children:t.jsx("rect",{width:"10",height:"10",className:s,fillOpacity:r})}),n]},n)),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M6,0V10",className:"stroke-foreground",strokeWidth:1.5,strokeDasharray:"3 2"})}),"Threshold"]}),t.jsx("span",{children:"A missing signal counts as 0 and hands back."})]})}const xz=3e3,vz=e=>e.word==="Held"||e.word==="Not decided"||e.word==="Skipped",s0=e=>`${Math.round(e*100)}%`,yz=e=>`${e>=0?"+":""}${Math.round(e*1e3)/10} pts`,sC=e=>`${e} graded ${e===1?"input":"inputs"}`;function bz(e){if(!e)return"Replay started: its runs are queued.";const n=e.outcomes,s=n.answered+n.handed_back+n.failed+n.skipped_write;return`Replaying on ${sC(e.inputs)}: ${s} of ${e.inputs} ended (${n.answered} answered alone, ${n.handed_back} handed back${n.failed?`, ${n.failed} failed`:""}${n.skipped_write?`, ${n.skipped_write} skipped`:""}).`}function wz(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 ${s0(r.wf_acc)} vs agent ${s0(r.agent_acc)} on ${sC(r.n)} (${yz(r.delta)}), ${r.handed_back} handed back`:null}}function jz({v2:e,agentId:n,workflow:s,digest:r,offered:o,resume:i=null,onStarted:c,onDecided:d,pollMs:u=xz}){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 b=p.useRef(d);b.current=d;const x=f.at==="running"?f.replay:null,h=f.at==="running"?f.unread:void 0;p.useEffect(()=>{if(x===null||h!==void 0)return;let j=!0,k;const E=()=>{Promise.resolve().then(()=>e.learnedWorkflowReplay(n,s,r,x)).then(S=>{var N;if(j){if(S.status==="running"){g({at:"running",replay:x,read:S}),k=setTimeout(E,u);return}g({at:"decided",read:S}),(N=b.current)==null||N.call(b)}},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,x,h,u]);const v=()=>{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})})},y=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:v,disabled:y,"aria-label":`Replay revision ${r.slice(0,7)} on graded inputs`,children:f.at==="starting"?"Starting…":f.at==="idle"?"Replay":"Replay again"}),f.at==="running"&&t.jsxs("p",{className:"break-words text-body",role:"status","data-testid":"replay-progress",children:[f.unread!==void 0?`Couldn't read the replay: ${f.unread} `:bz(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=wz(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 Ng=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},r0=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function kz(e,n,s,r,o){const i=[e.length&&`added ${r0(e.length,"node")} (${Ng(e)})`,n.length&&`edited ${Ng(n)}`,s.length&&`removed ${r0(s.length,"node")} (${Ng(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 Nz(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:ll(i)}catch{c=null}if(!(c!=null&&c.nodes.length)){r+=1;continue}const d=s?i2(s,c):null,u=d?d.added.map(k=>k.path):c.nodes.map(k=>k.path),f=k=>{var E;return((E=c.nodes.find(S=>S.path===k))==null?void 0:E.kind)!=="chain"},g=d?[...d.changed.map(k=>k.next),...d.rewritten.map(k=>k.next)]:[],b=d?d.moved.map(k=>k.next):[],x=new Map(c.nodes.map(k=>[k.path,k.label])),h=d?d.removed.filter(k=>k.kind!=="chain").map(k=>k.label):[],v=d?d.edges.added.length+d.edges.removed.length:0,y=UL(o.text),j=Object.fromEntries(y.flatMap(k=>c.nodes.some(E=>E.path===k.path)?[[k.node,k.path]]:[]));n.push({digest:o.digest??null,guards:y,guardPaths:j,commit:o.commit,at:o.at,run:"run"in o.by?o.by.run:null,reason:o.reason,graph:c,marks:{meta:gd(i,c),diff:{added:u,edited:g,moved:b,removed:d?d.removed.map(({label:k,kind:E})=>({label:k,kind:E})):[]}},added:u,edited:g,removed:h,line:d?kz(u.filter(f).map(k=>x.get(k)??k),g.filter(f).map(k=>x.get(k)??k),h,b.length,v):`First version: ${qm(sy(c))}`}),s=c}return{steps:n,unreadable:r}}const Sz=50,Cz=1800;function Ez({v2:e,agentId:n,workflows:s,promotions:r=[],serving:o=[],loop:i=null,cost:c=null,onReplayed:d}){const u=s.filter(x=>x.status==="active").map(x=>x.name),[f,g]=p.useState(null),b=f!==null&&u.includes(f)?f:u[0]??null;return b===null?null:t.jsx($z,{v2:e,agentId:n,name:b,choices:u,onPick:g,promotions:r,serving:o,loop:i,stopped:Qv(c,b),onReplayed:d},b)}const ef="Learned workflow";function $z({v2:e,agentId:n,name:s,choices:r,onPick:o,promotions:i,serving:c,loop:d,stopped:u,onReplayed:f}){var k;const[g,b]=p.useState(null),[x,h]=p.useState(null),[v,y]=p.useState(0);p.useEffect(()=>{let E=!0;return h(null),Promise.resolve().then(()=>e.learnedWorkflowRevisions(n,s,Sz)).then(S=>{E&&b(S)},S=>{E&&h(S??new Error("unknown"))}),()=>{E=!1}},[e,n,s,v]);const j=t.jsxs("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-4 py-3",children:[t.jsxs("h2",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"caps text-small font-semibold",children:ef})," ",t.jsx("span",{className:"ml-1 break-all font-mono text-body font-semibold",children:s})]}),r.length>1&&t.jsx(Ct,{small:!0,className:"w-56 max-w-full",label:"Learned workflow",value:s,onChange:o,options:r.map(E=>({value:E,label:E}))})]});return x&&!g?t.jsxs("section",{className:"border","aria-label":ef,children:[j,t.jsx("div",{className:"p-4",children:t.jsx(ss,{problem:Tr(x,"the learned workflow"),onRetry:()=>y(E=>E+1),className:""})})]}):g?t.jsxs("section",{className:"border","aria-label":ef,children:[j,t.jsx(_z,{data:g,promotions:i,serving:((k=c.find(E=>E.workflow===g.name))==null?void 0:k.digest)??null,loop:d,stopped:u,replay:{v2:e,agentId:n,onStarted:f,onDecided:()=>{y(E=>E+1),f==null||f()}}})]}):t.jsxs("section",{className:"border","aria-label":ef,"aria-busy":!0,children:[j,t.jsx("div",{className:"p-4",children:t.jsx(pn,{className:"h-48 w-full"})})]})}function _z({data:e,stepMs:n=Cz,promotions:s=[],serving:r=null,loop:o=null,stopped:i=null,replay:c}){const{steps:d,unreadable:u}=p.useMemo(()=>Nz(e.revisions),[e.revisions]),[f,g]=p.useState(Math.max(0,d.length-1)),[b,x]=p.useState(!1),h=p.useRef(f);h.current=f;const v=p.useRef(d);if(p.useEffect(()=>{var P;const L=v.current;v.current=d;const A=((P=L[h.current])==null?void 0:P.digest)??null,R=L===d||h.current>=L.length-1||A===null?-1:d.findIndex(D=>D.digest===A);g(R>=0?R:Math.max(0,d.length-1)),x(!1)},[d]),p.useEffect(()=>{if(!b)return;const L=setInterval(()=>g(A=>Math.min(A+1,d.length-1)),n);return()=>clearInterval(L)},[b,d.length,n]),p.useEffect(()=>{b&&f>=d.length-1&&x(!1)},[b,f,d.length]),!e.revisions.length)return null;if(!d.length)return t.jsxs("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:["This workflow's revisions can't be read as a workflow",u?`: ${u} ${u===1?"revision":"revisions"} did not read`:"","."]});const y=d[Math.min(f,d.length-1)],j=d.length,k=L=>{x(!1),g(Math.max(0,Math.min(j-1,L)))},E=()=>{if(b)return x(!1);f>=j-1&&g(0),x(!0)},S=`Revision ${Math.min(f,j-1)+1} of ${j}, ${ht(y.at)}`,N=Yv(s,e.name,y.digest),$=I2(s,e.name,y.digest),_=Gc(N,{serving:r,refit:$,stopped:i}),M=y.guards.length?{...y.marks,verdict:Object.fromEntries(y.guards.flatMap(L=>y.guardPaths[L.node]?[[y.guardPaths[L.node],uz(L)]]:[]))}:y.marks,O=(N==null?void 0:N.source)==="refit"&&N.refit?N.refit:null;return t.jsxs("div",{className:"space-y-3 p-4",children:[j>1&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsxs(B,{size:"sm",onClick:E,"aria-label":b?"Pause the replay":"Play the replay","aria-pressed":b,children:[b?t.jsx(sl,{"aria-hidden":!0}):t.jsx(Qo,{"aria-hidden":!0}),b?"Pause":"Play"]}),t.jsx(B,{size:"icon",onClick:()=>k(f-1),disabled:f<=0,"aria-label":"Previous revision",children:t.jsx(wT,{"aria-hidden":!0})}),t.jsx(B,{size:"icon",onClick:()=>k(f+1),disabled:f>=j-1,"aria-label":"Next revision",children:t.jsx(Es,{"aria-hidden":!0})}),t.jsx(N5,{min:1,max:j,value:f+1,onChange:L=>k(L-1),label:"Revision",valueText:S,className:"basis-full sm:min-w-[10rem] sm:flex-1 sm:basis-0"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{children:j>1?`Revision ${f+1} of ${j}`:"One revision"})," · ",t.jsx("time",{dateTime:y.at,children:ht(y.at)})," · ",y.run?t.jsxs("a",{href:`#/runs/${encodeURIComponent(y.run)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",na(y.run)]}):"a person"]}),t.jsx("p",{className:"mt-1 break-words text-lead",role:"status","data-testid":"replay-line",children:y.line}),y.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-body text-muted-foreground",children:y.reason}),t.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-body","data-testid":"standing",children:[t.jsx(ke,{tone:_.tone,children:_.text}),t.jsx("span",{className:"min-w-0 break-words text-muted-foreground",children:$?`Its thresholds were refit: revision ${$.digest.slice(0,7)} serves in its place.`:N?Ma(N):y.digest?"No replay yet: a new revision replays on the last graded inputs before it serves.":"Its file did not read: no standing."})]}),O&&t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground","data-testid":"refit",children:N==null?void 0:N.reason}),c&&y.digest&&t.jsx(jz,{v2:c.v2,agentId:c.agentId,workflow:e.name,digest:y.digest,offered:!$&&vz(_),resume:(N==null?void 0:N.decided)==="replaying"?N.replay_id??null:null,onStarted:c.onStarted,onDecided:c.onDecided},y.digest)]}),t.jsx("div",{className:"flex min-h-[280px] overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] p-4",children:t.jsx(Nd,{graph:y.graph,marks:M,label:`The workflow at revision ${f+1} of ${j}, as a graph`,minScale:.5,maxScale:1.6,className:"m-auto"})}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Sd,{}),t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:"NEW"})," first appears in this revision · ",t.jsx("span",{className:"font-semibold text-foreground",children:"EDITED"})," its prompt, code, inputs or tier changed",y.guards.length?t.jsxs(t.Fragment,{children:[" · ",t.jsx("span",{className:"font-semibold text-foreground",children:"jev ≥0.70"})," the step's guard: its signal and threshold"]}):null]})]}),t.jsx(mz,{guards:y.guards,workflow:e.name,digest:y.digest,loop:o}),(e.total>e.revisions.length||e.truncated||u>0)&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[e.total>e.revisions.length&&`The latest ${e.revisions.length} of ${e.total} revisions. `,e.truncated&&"Older changes are past the log this server keeps. ",u>0&&`${u} ${u===1?"revision":"revisions"} could not be read as a workflow and ${u===1?"is":"are"} left out.`]})]})}const o0=8,Tz={promote:"success",hold:"warning",refit:"plain",revision:"active",queued:"plain",skipped:"muted"};function a0({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,o0);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(Az,{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?Qv(r,u.compile.workflow):null}):t.jsx(Oz,{record:u.record})},u.key)})}),c.length>o0&&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 Rz=({id:e})=>t.jsxs("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",na(e)]}),rC=({at:e,run:n})=>t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[t.jsx("time",{dateTime:e,children:ht(e)}),n?t.jsxs(t.Fragment,{children:[" · ",t.jsx(Rz,{id:n})]}):null]});function Az({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:Gc(Yv(n,e.workflow,e.digest),{serving:s,refit:I2(n,e.workflow,e.digest),stopped:r});return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?t.jsx(ke,{tone:"error",children:"Draft failed"}):t.jsx(ke,{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(ke,{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(rC,{at:e.at,run:e.run_id})]})}function Oz({record:e}){var o;const n=P2(e),s=Gc(e,{serving:e.digest}),r=n==="promote"?s.tone:Tz[n];return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(ke,{tone:r,children:[Vv[n]," · ",Oc[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:Ma(e)}),(o=e.replay)!=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(rC,{at:e.at})]})}const Mz={done:{icon:pl,word:"Done",ink:"text-success-text",edge:"border-t-success"},now:{icon:kT,word:"Next",ink:"text-run-active",edge:"border-t-run-active"},later:{icon:ST,word:"Later",ink:"text-muted-foreground",edge:"border-t-border"},warn:{icon:Gs,word:"Look",ink:"text-warning-text",edge:"border-t-warning"},watch:{icon:hm,word:"Watch",ink:"text-foreground",edge:"border-t-border-strong"}};function i0({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=Mz[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 oC({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(ud,{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 Pz({fields:e,onFields:n,saved:s,server:r,error:o,warning:i}){const c=e.learning??s,d=c===!0||c==="notes",u=f=>n({learning:f===!1&&s===void 0?void 0:f});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Learning"})}),t.jsx(oC,{id:"learning-switch",className:"border px-4 py-3",checked:d,server:r,onChange:f=>u(f?s==="notes"?"notes":!0:!1)}),d&&t.jsx("fieldset",{"aria-label":"What it learns",className:"mt-2 space-y-2",children:[[!0,"Notes, skills and workflows","Once a job repeats, it can learn it as a workflow and run it as one step."],["notes","Notes and skills only","It never runs a learned workflow, and is never asked to draft one."]].map(([f,g,b])=>t.jsxs("label",{className:ae("flex items-start gap-3 border px-3 py-2.5",c===f&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"learning-kind",className:"mt-1 accent-primary",checked:c===f,onChange:()=>u(f)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:g}),t.jsx("span",{className:"block text-small text-muted-foreground",children:b})]})]},String(f)))}),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 Lz="Not read: its front matter can't be read; fix the file to use it",Iz={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned",superseded:"Replaced"},aC=(e,n)=>`${Iz[e]} by ${n==="person"?"you":"a run"}`,mx=e=>e.readme??e.file,Sg="Can't tell which version this is: reload.",Km="It changed since you opened it.",zz=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.",Dz=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.`,Fz="Making an agent from it takes your password sign-in in the console.",Uz="Restoring takes your password sign-in in the console.",iC=["feedback","project","reference","user"],Wz={user:"About you",feedback:"How to work",project:"About the work",reference:"Where to look"},lC=e=>Wz[e]??e,Hz={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"},Bz=["seeded","reflecting","proposed"],Vm=e=>!!e&&Bz.includes(e.state),Cd=e=>Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&typeof n.file=="string"&&typeof n.name=="string"):[],cC=e=>Cd(e==null?void 0:e.given),dC=e=>Cd(e==null?void 0:e.read),Vc=e=>(e==null?void 0:e.state)==="merged"?Cd(e.learned):[],ry=e=>Cd(e==null?void 0:e.pending),uC=e=>Cd(e),l0=e=>(e==null?void 0:e.state)==="merged"?uC(e.skills):[],c0=e=>(e==null?void 0:e.state)==="merged"?uC(e.workflows):[],Gz=e=>ry(e).length>0,qf=(e,n)=>`${e} ${n}${e===1?"":"s"}`,fC=e=>e.status==="pending",Kf=e=>{var n;return((n=e==null?void 0:e.learning)==null?void 0:n.pending)??0},oy=e=>`${e} learned ${e===1?"item waits":"items wait"} for your OK`;function qz(e){const n=e&&typeof e=="object"?e.learning:void 0;return n&&typeof n=="object"&&n.approve===!0?"yes":"password"}const mC="Approving needs your password sign-in. Until then it stays out of every run.",Kz="It changes what this agent trusts or skips, so it waits for you.",Vz="Runs that use bash on the host run as you. For untrusted tasks, use the sandbox.",hC="[redacted]",pC=e=>e===1?"1 note waits for your OK":e>1?`${e} notes wait for your OK`:"A note waits for your OK",Zi=e=>`${e} ${e===1?"note":"notes"}`,qa=e=>`${e} ${e===1?"run":"runs"}`,Yz={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"},Vf=e=>Yz[e??""]??"stopped",Qz={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 ay(e){return e.detail&&e.detail.trim()?e.detail.trim():Qz[e.reason??""]??"Not kept: learning stopped."}const Jz=e=>e==="seeded"?"Learns after the run":"Looking back",Yf=e=>dl(Math.round(e)*1e3),Pa=e=>no({usd:e,basis:"estimate",charge_state:null,cap_usd:null}),d0=(e,n)=>e>0?Math.round((n-e)/e*100):null,gC=e=>typeof e.before.median_cost_usd=="number"&&typeof e.after.median_cost_usd=="number",xC=e=>e.after.median_learning_usd;function Xz(e){const n=[`answers in ${Yf(e.after.median_duration_s)} instead of ${Yf(e.before.median_duration_s)}`];gC(e)&&n.push(`${Pa(e.after.median_cost_usd)} instead of ${Pa(e.before.median_cost_usd)} a run`);const s=xC(e);return s!==null&&n.push(`learning itself ${Pa(s)} a run`),`Since it learned (${vC(e)}): ${n.join(" · ")}`}function vC(e){return`medians of ${qa(e.after.runs)} started from what it learned`}const Zz=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)},eD=/^---\n([\s\S]*?)\n?^---$\n?/m,hx=e=>/^"[^"]*"$|^'[^']*'$/.test(e)?e.slice(1,-1):e;function Qf(e){const n=e.replace(/\r\n/g,`
|
|
634
|
+
`),s=n.startsWith(`---
|
|
635
|
+
`)?eD.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]]=hx((d[2]??"").trim()):c.trim()&&o.push(c)}const i=iC.includes(r.type??"")?r.type:"project";return{name:r.name??"",description:r.description??"",type:i,body:n.slice(s[0].length),rest:o}}const u0=e=>{const n=e.replace(/\s*\n\s*/g," ").trim();return/^["'].*["']$/.test(n)?n.includes('"')?`'${n}'`:`"${n}"`:n},tD=e=>`---
|
|
637
|
+
name: ${u0(e.name)}
|
|
638
|
+
description: ${u0(e.description)}
|
|
639
|
+
type: ${e.type}
|
|
640
|
+
${e.rest.map(n=>`${n}
|
|
641
|
+
`).join("")}---
|
|
642
|
+
${e.body.replace(/^\n*/,`
|
|
643
|
+
`)}`;function nD(e){const n=Qf(e).rest.find(r=>/^supersedes:/.test(r)),s=n?hx(n.replace(/^supersedes:\s*/,"").trim()).trim():"";return s?(/^\[.*\]$/.test(s)?s.slice(1,-1).split(","):[s]).map(r=>hx(r.trim())).filter(Boolean):[]}const Yc=e=>Qf(e).body.replace(/^\n+/,"");function f0(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 Ym=(e,n=[])=>{const s=n.filter(o=>o!==hC),r=new URLSearchParams(s.map(o=>["note",o]));return`#/agents/${encodeURIComponent(e)}/learning${s.length?`?${r}`:""}`};function yC(e){return e.kind===Kr?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===Kr?{...e,kind:Kr,agent_label:null}:e}const Kr="learning",sD={seeded:0,reflecting:1,proposed:2,merged:3,dropped:3},px=e=>e?sD[e.state]??0:-1,rD=e=>{const n=e==null?void 0:e.learning;return n&&typeof n=="object"&&typeof n.state=="string"?n:void 0},m0=e=>e.charAt(0).toLowerCase()+e.slice(1);function oD(e){var s,r;if(!e||px(e)<2)return"Looking back on this run…";if(e.state==="proposed")return`Looking back: ${m0(((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=Vc(e),i=ry(e),c=[...o.length?[`kept ${Zi(o.length)} (${n(o)})`]:[],...i.length?[`${m0(pC(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 Vf(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${ay(e)}`}function aD(e){var i;const n=yC(e),s=n.summary??"",r=r2(n)?`${s} (failed)`:s,o=(i=n2(n))==null?void 0:i.trimEnd();return o&&o.trim()!==s.trim()?`${r}
|
|
644
|
+
${o.replace(/^(?=.)/gm," ")}`:r}function iD(e,n){const s=e.filter(u=>u.agent_label===Kr&&u.kind!==Kr);if(!s.length)return e.map(yC);const r=e.findLast(u=>u.kind===Kr),o=rD(r),i=px(o)>px(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:Kr,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:oD(i??void 0),text:[...s,...r?[r]:[]].map(aD).join(`
|
|
645
|
+
`)};return e.flatMap(u=>u===c?[d]:u.agent_label===Kr||u.kind===Kr?[]:[u])}const lD={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},h0=["Added","Replaced","Retired","Removed","Changed"];function cD(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 dD(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:cD(d.patch)])),o=new Map([...cC(n),...dC(n),...Vc(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,v;const u=r.get(d.path),f=i(d.path),g=((u==null?void 0:u.after)??[]).filter(y=>y.mark==="added").map(y=>y.text.trim()),b=((h=g.find(y=>y.startsWith("superseded_by:")))==null?void 0:h.replace(/^superseded_by:\s*/,""))??((v=Vc(n).find(y=>{var j;return(j=y.supersedes)==null?void 0:j.includes(d.path)}))==null?void 0:v.file),x=d.status==="added"?`Added: ${f}`:d.status==="deleted"?`Removed: ${f}`:g.includes("status: superseded")||!u&&b?`Replaced: ${f}${b?` → ${i(b)}`:""}`:g.includes("status: retired")?`Retired: ${f}`:`Changed: ${f}`;return u?{file:d.path,said:x,before:d.status==="added"?null:u.before,after:d.status==="deleted"?null:u.after}:{file:d.path,said:x,before:null,after:null,withheld:lD[d.withheld??""]??"Not shown."}}).sort((d,u)=>h0.indexOf(d.said.split(":")[0])-h0.indexOf(u.said.split(":")[0]))}function uD(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 Ed(){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 Ys(e=Ed){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 bC(e,n,s,r){const o=await r(n,s,e.keyFor(n,{content:s}));return e.done(),o}function fD(e=Ed){const n=new Map;return s=>{let r=n.get(s);return r||(r=Ys(e),n.set(s,r)),r}}function gx(e,n){const s=new Set(e.map(r=>r.run_id));return[...e,...n.filter(r=>!s.has(r.run_id))]}const ei=(e,n,s)=>({...Tr(e,n),title:s}),mD=(e,n)=>{const s=e.get(n);return s!=null&&s.title?Sn(s):`run ${na(n)}`},wC="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",hD=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),p0=20,pD=15e3;function Sr(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 gD(e){return t.jsx(xD,{...e},e.agent.agent_id)}function xD({agent:e,v2:n,focus:s=[],server:r,onAgent:o,places:i,onChanged:c}){var Dt;const[d,u]=p.useState(null),[f,g]=p.useState(null),[b,x]=p.useState([]),[h,v]=p.useState([]),[y,j]=p.useState([]),[k,E]=p.useState(null),[S,N]=p.useState(null),[$,_]=p.useState({items:[],cursor:null,pages:0}),[M,O]=p.useState({items:[],cursor:null,pages:0}),[L,A]=p.useState(!1),R=p.useMemo(()=>({items:new Set,changed:A}),[]),[P,D]=Sr(R),[W,K]=p.useState(0),H=p.useRef(0),q=p.useRef(!1),F=p.useRef(!0),G=p.useRef(!1),[U,z]=p.useState(!1),Y=p.useRef(()=>!1);Y.current=()=>!P&&!R.items.size&&!q.current&&$.pages===0;const J=ye=>{const de=ye==="background";if(!F.current||de&&(G.current||!Y.current()))return Promise.resolve();const We=++H.current;G.current=!0,z(!0),q.current=!1,g(null);const Ze=()=>F.current&&We===H.current&&(ye==="write"||!R.items.size)&&(!de||Y.current()),at=n.agentLearning(e.agent_id).then(Q=>{Ze()&&(u(Q),_({items:[],cursor:Q.notes.next_cursor,pages:0}),O({items:[],cursor:Q.log.next_cursor,pages:0}))},Q=>{Ze()&&g(Q??new Error("unknown"))});return n.listAgentRuns(e.agent_id,50,null,!!e.archived_at).then(Q=>{Ze()&&x(Q.runs)},()=>{}),Promise.resolve().then(()=>n.learningPromotions(e.agent_id)).then(Q=>{Ze()&&(v(Q.promotions),j(Q.serving))},()=>{}),Promise.resolve().then(()=>n.learningLoop(e.agent_id)).then(Q=>{Ze()&&E(Q)},()=>{}),at.finally(()=>{We===H.current&&(G.current=!1,z(!1))})},X=()=>J("manual"),le=p.useRef(()=>{});le.current=()=>{document.hidden||J("background")},p.useEffect(()=>{F.current=!0,X();const ye=()=>le.current();window.addEventListener("focus",ye),document.addEventListener("visibilitychange",ye);const de=window.setInterval(ye,pD);return()=>{F.current=!1,H.current++,window.removeEventListener("focus",ye),document.removeEventListener("visibilitychange",ye),window.clearInterval(de)}},[n,e.agent_id,e.archived_at]);const se=()=>(c==null||c(),J("write")),fe=()=>{if(!$.cursor||q.current)return;const ye=H.current;q.current=!0,n.learningNotes(e.agent_id,$.cursor).then(de=>{ye===H.current&&(q.current=!1,_(We=>({items:[...We.items,...de.items.filter(Ze=>!We.items.some(at=>at.file===Ze.file))],cursor:de.next_cursor,pages:We.pages+1})))},de=>{ye===H.current&&(q.current=!1,_(We=>({...We,error:de??new Error("unknown")})))})},xe=e.definition.learning===!0||e.definition.learning==="notes",Ne=!!e.archived_at,ge=p.useMemo(()=>[...(d==null?void 0:d.notes.items)??[],...$.items],[d,$.items]),me=ge.filter(ye=>ye.status==="active"),Le=ge.filter(fC),Ue=(d==null?void 0:d.skills)??[],De=(d==null?void 0:d.workflows)??[],[Ee,re]=p.useState(void 0),Qe=Le.length>0||[...Ue,...De].some(ye=>ye.status==="pending")||De.some(ye=>ye.status==="active");p.useEffect(()=>{if(!Qe||Ee!==void 0)return;let ye=!0;return Promise.resolve().then(()=>n.capabilities()).then(de=>{ye&&re(qz(de))},()=>{ye&&re("password")}),()=>{ye=!1}},[Qe]);const he=ge.filter(ye=>ye.status==="superseded"||ye.status==="retired"),Ie=p.useMemo(()=>{const ye=new Map(ge.map(We=>[We.file,We])),de=new Map;for(const We of ge){if(We.status==="superseded")continue;const at=[...new Set([...nD(We.text),...ge.filter(Q=>Q.status==="superseded"&&Q.superseded_by===We.file).map(Q=>Q.file)])].flatMap(Q=>{const ve=ye.get(Q);return ve?ve.status==="superseded"&&ve.superseded_by===We.file?[{file:Q,name:ve.name}]:[]:[{file:Q,name:null}]});at.length&&de.set(We.file,at)}return de},[ge]),et=p.useMemo(()=>new Map(b.map(ye=>[ye.run_id,ye])),[b]),pt=p.useMemo(()=>uD([...(d==null?void 0:d.log.items)??[],...M.items]),[d,M.items]),oe=s.filter(ye=>!ge.some(de=>de.file===ye)).length>0;p.useEffect(()=>{d&&oe&&$.cursor&&$.error===void 0&&$.pages<p0&&fe()},[d,oe,$.cursor,$.pages]);const $e=ge.some(ye=>!pt.has(ye.file));p.useEffect(()=>{if(!d||!$e||!M.cursor||M.pages>=p0)return;const ye=H.current;n.learningLog(e.agent_id,M.cursor).then(de=>{ye===H.current&&O(We=>({items:[...We.items,...de.items],cursor:de.next_cursor,pages:We.pages+1}))},()=>{ye===H.current&&O(de=>({...de,cursor:null}))})},[d,$e,M.cursor]);const st=b.filter(ye=>ye.learning&&(ye.learning.state==="merged"||ye.learning.state==="dropped")).length,Oe=e.definition.native?"native":es(e.definition)?"sdk":"hosted",dt=GL({notes:me.length,compiledNotes:ge.filter(ye=>ye.status!=="retired"&&z2(ye.text)!==null).length,runs:b.filter(ye=>ye.status==="completed").length,workflows:De,cost:S,promotions:h,serving:y,loop:k,mode:e.definition.learning==="notes"?"notes":"full",execution:Oe}),Tt=ye=>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:L||U,onClick:()=>{!R.items.size&&!G.current&&X()},children:t.jsx(Jo,{className:ae(U&&"animate-spin"),"aria-hidden":!0})})}),ye]});if(f&&!d)return Tt(t.jsx(ss,{problem:Tr(f,"what this agent learned"),onRetry:X,className:""}));if(!d)return Tt(t.jsx(yD,{}));const nt=f?t.jsx(vD,{error:f,onRetry:X}):null,ft=ye=>t.jsx(wD,{agent:e,v2:n,onAgent:o,server:r,disabled:Ne,quiet:ye}),Kt=xe&&!Ne&&(Oe==="hosted"?t.jsx(iI,{v2:n,agentId:e.agent_id,onFinished:()=>{K(ye=>ye+1),X()}}):t.jsxs(vt,{tone:"info",children:[Oe==="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:cn(e.agent_id,"runs"),className:"underline underline-offset-2",children:"Open the agent’s Run controls"}),"."]}));return!ge.length&&!Ue.length&&!De.length&&!P?Tt(t.jsxs("div",{className:"space-y-6",children:[nt,t.jsx(ND,{on:xe,lookedBack:st,switchRow:ft(!0),onAdd:Ne?void 0:()=>D(!0)}),xe&&t.jsx(i0,{stages:dt}),t.jsx(Vk,{v2:n,agentId:e.agent_id,quiet:!0}),Kt,t.jsx(Uk,{v2:n,agentId:e.agent_id,on:xe,quiet:!0,promotions:h,onCost:N,execution:Oe},W),t.jsx(a0,{loop:k,promotions:h,serving:y,cost:S}),t.jsx(x0,{runs:b})]})):Tt(t.jsxs("div",{className:"space-y-6",children:[Le.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:Le.length})]}),t.jsx("p",{className:"px-4 pt-3 text-body text-muted-foreground",children:Kz}),((Dt=A2(e,i))==null?void 0:Dt.place.mode)==="runner"&&(e.definition.tools??[]).includes("bash")&&t.jsx("p",{className:"px-4 pt-1 text-body text-muted-foreground",children:Vz}),t.jsx("ul",{className:"space-y-3 p-4",children:Le.map(ye=>t.jsx("li",{children:t.jsx(g0,{note:ye,v2:n,agentId:e.agent_id,readOnly:Ne,focused:s.includes(ye.file),from:pt.get(ye.file),runs:et,onChanged:se,refreshHolds:R,approves:Ee,replaces:Ie.get(ye.file)})},ye.file))})]}),t.jsx(i0,{stages:dt}),t.jsx(Vk,{v2:n,agentId:e.agent_id}),Zz(d.impact)&&t.jsx(bD,{impact:d.impact}),Kt,t.jsx(Uk,{v2:n,agentId:e.agent_id,on:xe,promotions:h,onCost:N,execution:Oe},W),t.jsx(Ez,{v2:n,agentId:e.agent_id,workflows:De,promotions:h,serving:y,loop:k,cost:S,onReplayed:()=>{X()}}),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:me.length?`${Zi(me.length)} in use. Every later run reads ${me.length===1?"it":"them"} before it starts.`:[...Ue,...De].some(ye=>ye.status==="active")?"No note is in use.":"No note is in use: the next run starts with nothing learned."})]}),!Ne&&!P&&t.jsxs(B,{size:"sm",onClick:()=>D(!0),children:[t.jsx(gl,{"aria-hidden":!0})," Add a note"]})]}),nt,!xe&&t.jsx(kD,{server:r}),P&&t.jsx(CC,{title:"New note",v2:n,agentId:e.agent_id,taken:ge.map(ye=>ye.file),onDone:ye=>{D(!1),ye&&se()}},"new"),t.jsx("ul",{className:"space-y-3",children:me.map(ye=>t.jsx("li",{children:t.jsx(g0,{note:ye,v2:n,agentId:e.agent_id,readOnly:Ne,focused:s.includes(ye.file),from:pt.get(ye.file),runs:et,onChanged:se,refreshHolds:R,replaces:Ie.get(ye.file)})},ye.file))}),$.error!==void 0&&t.jsx(ss,{problem:Tr($.error,"more notes"),onRetry:fe,className:""}),$.cursor&&t.jsx("div",{className:"flex justify-center",children:t.jsx(B,{size:"sm",onClick:fe,children:"Load more notes"})}),he.length>0&&t.jsx(_D,{notes:he,all:ge,from:pt,focus:s,runs:et,v2:n,agentId:e.agent_id,readOnly:Ne,onChanged:se,refreshHolds:R})]}),["skill","workflow"].map(ye=>{const de=ye==="skill"?Ue:De;if(!de.length)return null;const We=ye==="skill"?"Skills it learned":"Workflows it learned",Ze=de.filter(Q=>Q.status!=="retired"),at=de.filter(Q=>Q.status==="retired");return t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":We,children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:We}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:Ze.length?ye==="skill"?`${qf(Ze.length,"skill")}: how to do a job it does again, given to every later run once active.`:`${qf(Ze.length,"workflow")}: a job it does again, as steps a later run can call.`:`No ${ye} is in use: the next run gets none.`})]}),Ze.length>0&&t.jsx("ul",{className:"space-y-3",children:Ze.map(Q=>t.jsx("li",{children:t.jsx(SD,{item:Q,kind:ye,v2:n,agentId:e.agent_id,readOnly:Ne,runs:et,approves:Ee,onChanged:se,refreshHolds:R})},Q.file))}),at.length>0&&t.jsx(TD,{kind:ye,items:at,v2:n,agentId:e.agent_id,runs:et,readOnly:Ne,onChanged:se,refreshHolds:R})]},ye)})]}),t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[t.jsx(jC,{title:"Learning",children:ft(!1)}),t.jsx(a0,{loop:k,promotions:h,serving:y,cost:S}),t.jsx(x0,{runs:b}),t.jsx(AD,{index:d.index,skills:Ue.filter(ye=>ye.status==="active").map(ye=>ye.name),off:!xe||r==="off"})]})]})]}))}function vD({error:e,onRetry:n}){const s=Tr(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 jC({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 yD(){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 bD({impact:e}){const{before:n,after:s}=e,r=[{label:"Answers in",now:Yf(s.median_duration_s),was:Yf(n.median_duration_s),delta:d0(n.median_duration_s,s.median_duration_s)},...gC(e)?[{label:"A run costs",now:Pa(s.median_cost_usd),was:Pa(n.median_cost_usd),delta:d0(n.median_cost_usd,s.median_cost_usd)}]:[]],o=xC(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":Xz(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:vC(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:[Pa(o)," a run"]})]})]})]})})}function wD(e){return e.agent.definition.native?t.jsx("div",{className:"p-4",children:t.jsx(M2,{agent:e.agent,v2:e.v2,learning:e.server,onAgent:e.onAgent})}):t.jsx(jD,{...e})}function jD({agent:e,v2:n,onAgent:s,server:r,disabled:o,quiet:i}){const[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,b]=p.useState(null),x=async h=>{d(!0),f(null),b(h);try{const{agent:v,etag:y}=await n.getAgent(e.agent_id),j=vd(v,{learning:h},h?"Learning on":"Learning off");if(j.unchanged)s==null||s(v);else{const{unchanged:k,...E}=j;s==null||s((await n.updateDefinition(e.agent_id,E,y)).agent)}}catch(v){f(v??new Error("unknown"))}b(null),d(!1)};return t.jsx(oC,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:i,checked:g??(e.definition.learning===!0||e.definition.learning==="notes"),onChange:h=>void x(h),busy:c,disabled:o,server:r,problem:u?t.jsx(ss,{problem:ei(u,"the agent","Learning was not changed."),className:"mt-2"}):null})}function kD({server:e}){return t.jsxs(vt,{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 ND({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(Jx,{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(gl,{"aria-hidden":!0})," Or write a note yourself"]})})]})}function g0({note:e,v2:n,agentId:s,readOnly:r,focused:o,from:i,runs:c,onChanged:d,approves:u,refreshHolds:f,replaces:g=[]}){const[b,x]=p.useState(!1),[h,v]=Sr(f),[y,j]=Sr(f),[k,E]=p.useState(o),[S,N]=p.useState(null),[$,_]=Sr(f),[M,O]=p.useState(null),L=p.useRef(null),A=fC(e),R=async()=>{const K=H=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:H});_(!0),O(null);try{await n.approveNote(s,e.file,e.etag)}catch(H){_(!1),O(H instanceof Fe&&Hm(H).kind==="conflict"?K(`${Km} Reload the tab to see the newest version.`):t.jsx(ss,{problem:ei(H,"the note","The note was not approved."),className:""}));return}await d(),_(!1)};if(p.useEffect(()=>{var H,q;if(!o)return;E(!0),(q=(H=L.current)==null?void 0:H.scrollIntoView)==null||q.call(H,{block:"center",behavior:"smooth"});const K=setTimeout(()=>E(!1),2600);return()=>clearTimeout(K)},[o]),p.useEffect(()=>{if(!S)return;const K=setTimeout(()=>N(null),2400);return()=>clearTimeout(K)},[S]),h)return t.jsx(CC,{title:"Edit note",v2:n,agentId:s,file:e.file,seen:e,onDone:K=>{v(!1),K&&(N("Saved"),d())}});const P=Yc(e.text),D=xx(e.last_change),W=z2(e.text);return t.jsxs("article",{ref:L,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(ke,{children:lC(e.type)}),e.origin==="you"&&t.jsx(ke,{tone:"muted",children:"From you"}),W&&t.jsxs(ke,{tone:"success",label:!0,title:`This note went into the learned workflow ${W}`,children:["Compiled into ",W]}),S&&t.jsx("span",{className:"caps text-micro text-success-text",role:"status",children:S})]}),t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),A&&u==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:mC})]}),!r&&!y&&t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[A?u==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void R(),disabled:$,"aria-label":`Approve ${e.name}`,children:$?"Approving":"Approve"}):t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>v(!0),"aria-label":`Edit ${e.name}`,children:[t.jsx(Vx,{"aria-hidden":!0})," Edit"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>j(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]})]}),M&&t.jsx("div",{className:"px-5 pt-3",children:M}),P.trim()&&t.jsx(Jm,{text:P}),t.jsxs("footer",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5 border-t px-5 py-2.5 font-mono text-label text-muted-foreground",children:[(i==null?void 0:i.run)&&t.jsx(Qm,{run:i.run.id,runs:c,at:i.run.at,reason:i.run.reason}),D&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Xx,{className:"size-3","aria-hidden":!0}),D]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Sf,{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(Sf,{className:"size-3","aria-hidden":!0}),"Read in ",qa(e.runs.read)]}),g.length>0&&t.jsxs("button",{type:"button",onClick:()=>x(K=>!K),"aria-expanded":b,className:"flex items-center gap-1.5 hover:text-foreground",children:[t.jsx(MT,{className:"size-3","aria-hidden":!0}),"Replaces ",g.length," older ",g.length===1?"note":"notes",t.jsx(Or,{className:ae("size-3 transition-transform",b&&"rotate-180"),"aria-hidden":!0})]})]}),b&&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(K=>t.jsx("li",{className:ae("break-words",K.name===null&&"font-mono text-small"),children:K.name??K.file},K.file))}),y&&t.jsx(NC,{name:e.name,kind:"note",retire:()=>n.retireNote(s,e.file,e.etag),onDone:async K=>{K&&await d(),j(!1)}})]})}function SD({item:e,kind:n,v2:s,agentId:r,readOnly:o,runs:i,approves:c,onChanged:d,refreshHolds:u}){const[f,g]=Sr(u),[b,x]=p.useState(null),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=Sr(u),[S,N]=Sr(u),[$,_]=p.useState(null),M=e.status==="pending",[O,L]=Sr(u),A=p.useRef(Ys()).current,[R,P]=p.useState(null),D=n==="workflow"&&e.status==="active"&&c==="yes",W=async()=>{j(null),x(null),v(null);try{const G=await s.readNote(r,e.file);x(G.note),v(G.etag)}catch(G){j(G??new Error("unknown"))}},K=async()=>{if(f)return g(!1);g(!0),b===null&&await W()};p.useEffect(()=>{b===null&&h===null||(f?W():(x(null),v(null)))},[e.etag]);const H=n==="skill"&&f&&h?h:e.etag,q=async()=>{E(!0),_(null);try{await s.approveNote(r,mx(e),H)}catch(G){E(!1),_(G instanceof Fe&&Hm(G).kind==="conflict"?t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${Km} Reload the tab to see the newest version.`}):t.jsx(ss,{problem:ei(G,`the ${n}`,`The ${n} was not approved.`),className:""}));return}await d(),E(!1)},F=`the ${n} ${e.name}`;return t.jsxs("article",{"aria-label":e.name,className:"border bg-card/40",children:[t.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words font-mono text-lead font-semibold leading-snug",children:e.name}),M&&t.jsxs(ke,{tone:"warning",children:[t.jsx(Gx,{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}),M&&c==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:mC})]}),t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[!o&&!S&&!O&&t.jsxs(t.Fragment,{children:[M&&c==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void q(),disabled:k,"aria-label":`Approve ${e.name}`,children:k?"Approving":"Approve"}),D&&t.jsx(B,{size:"sm",onClick:()=>{P(null),L(!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 K(),"aria-expanded":f,"aria-label":`${f?"Hide":"Show"} ${F}`,children:[t.jsx(Or,{className:ae("transition-transform",f&&"rotate-180"),"aria-hidden":!0}),f?"Hide":"Show"]})]})]}),$&&t.jsx("div",{className:"px-5 pt-3",children:$}),R&&t.jsxs("p",{className:"px-5 pt-3 text-body",role:"status",children:["Made the agent ",t.jsx("a",{href:cn(R.agent_id),className:"font-mono underline underline-offset-2",children:R.definition.name}),". Open it to run it."]}),f&&(y!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(ss,{problem:Tr(y,F),onRetry:()=>void W(),className:""})}):b===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${F}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):n==="skill"?t.jsx(Jm,{text:Yc(b)}):t.jsx(CD,{name:e.name,text:b})),t.jsxs("footer",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 border-t px-5 py-2.5 font-mono text-label text-muted-foreground",children:[e.run&&t.jsx(Qm,{run:e.run,runs:i}),xx(e.last_change)&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Xx,{className:"size-3","aria-hidden":!0}),xx(e.last_change)]}),t.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),S&&t.jsx(NC,{name:e.name,kind:n,retire:()=>s.retireNote(r,mx(e),H),onDone:async G=>{G&&await d(),N(!1)}}),O&&t.jsx($D,{name:e.name,keys:A,promote:G=>s.promoteWorkflow(r,e.name,G),onDone:G=>{L(!1),G&&P(G)}})]})}function CD({name:e,text:n}){const{doc:s,graph:r}=p.useMemo(()=>{try{const c=JSON.parse(n);return{doc:c,graph:ll(c)}}catch{return{doc:null,graph:null}}},[n]),o=p.useMemo(()=>r?{meta:gd(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(Nd,{graph:r,marks:o,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),t.jsx(Sd,{}),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 xx(e){return e&&e.kind!=="learned"?`${aC(e.kind,e.by)} · ${ht(e.at)}`:null}function kC(e){return(e==null?void 0:e.by)==="host"?Lz:e?`${aC("retired",e.by)} · ${ht(e.at)}`:"Retired"}function Qm({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(Jx,{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:mD(n,e),children:na(e)}),s&&t.jsxs("span",{className:"shrink-0",children:["· ",ht(s)]})]})}function Jm({text:e}){const[n,s]=p.useState(!1),r=e.split(`
|
|
647
|
+
`).length>8||e.length>520,o=p.useMemo(()=>so(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:wC,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(Or,{className:ae("size-3.5 transition-transform",n&&"rotate-180"),"aria-hidden":!0}),n?"Show less":"Show all"]})]})}const ED={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 NC({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 b;(b=u.current)==null||b.focus()},[]);const f=b=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:b}),g=async()=>{i(!0),d(null);try{await s()}catch(b){i(!1),d(b instanceof Fe&&Hm(b).kind==="conflict"?f(`${Km} Reload the tab to see the newest version.`):t.jsx(ss,{problem:ei(b,`the ${n}`,`The ${n} was not retired.`),className:""}));return}await r(!0)};return t.jsxs("div",{role:"alertdialog","aria-label":`Retire ${e}?`,onKeyDown:b=>{b.key==="Escape"&&(b.stopPropagation(),r(!1))},className:"flex flex-wrap items-center gap-3 border-t border-destructive/40 bg-destructive/5 px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Retire it?"})," ",ED[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 $D({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 b;i(!0),d(null);let g;try{g=await s(n.keyFor("promote",e))}catch(x){return i(!1),x instanceof Fe&&x.status<500&&n.done(),x instanceof Fe&&x.status===403?void d(t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:Fz})):x instanceof Fe&&((b=x.problems)!=null&&b.length)?void d(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["No agent was made: ",x.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:x.problems.map((h,v)=>t.jsx("li",{children:h.detail},v))})]})):void d(t.jsx(ss,{problem:ei(x,"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?"})," ",Dz(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 SC({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 b=h=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:h}),x=async()=>{var h;d(!0),f(null);try{await r()}catch(v){if(d(!1),v instanceof Fe&&(v.status===412||v.code==="precondition_failed")){f(b(Km)),await o();return}if(v instanceof Fe&&v.status===403)return void f(b(Uz));if(v instanceof Fe&&((h=v.problems)!=null&&h.length))return void f(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["Not restored: ",v.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:v.problems.map((y,j)=>t.jsx("li",{children:y.detail},j))})]}));if(v instanceof Fe&&v.status===400){await o(),i();return}return void f(t.jsx(ss,{problem:ei(v,`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?"})," ",zz(s)]}),u&&t.jsx("div",{className:"w-full",children:u}),t.jsx(B,{ref:g,size:"sm",variant:"solid",onClick:()=>void x(),disabled:c,children:c?"Restoring":"Yes, restore"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:i,disabled:c,children:"Keep"})]})}function CC({title:e,v2:n,agentId:s,file:r,seen:o,taken:i=[],onDone:c}){const[d,u]=p.useState(o?Qf(o.text):{name:"",description:"",type:"feedback",body:`
|
|
648
|
+
`,rest:[]}),[f,g]=p.useState((o==null?void 0:o.etag)??null),[b,x]=p.useState(null),[h,v]=p.useState(!1),[y,j]=p.useState([]),[k,E]=p.useState(null),[S,N]=p.useState(!1),[$,_]=p.useState(null),M=p.useRef(null),O=async()=>{if(r)try{const D=await n.readNote(s,r);u(Qf(D.note)),g(D.etag),x(null)}catch(D){x(D??new Error("unknown"))}};p.useEffect(()=>{var D;(D=M.current)==null||D.focus()},[]);const L=D=>u(W=>({...W,...D})),A=d.name.trim()!==""&&d.description.trim()!==""&&!h,R=async()=>{if(!A)return;if(E(null),j([]),N(!1),r&&!f){E(Sg);return}v(!0);const D=tD(d);try{await n.writeNote(s,r??f0(d.name,i),D,r?{etag:f??""}:{create:!0}),c(!0)}catch(W){v(!1);const K=W instanceof Fe?Hm(W,!r):null;(K==null?void 0:K.kind)==="conflict"?(_(D),await O()):(K==null?void 0:K.kind)==="refused"?j(K.problems):(K==null?void 0:K.kind)==="taken"?N(!0):E(W??new Error("unknown"))}},P=D=>{D.key==="Escape"?(D.preventDefault(),D.stopPropagation(),c(!1)):D.key==="Enter"&&(D.metaKey||D.ctrlKey||D.target.tagName==="INPUT")&&(D.preventDefault(),R())};return t.jsxs("section",{className:"border border-border-strong bg-card","aria-label":e,onKeyDown:P,children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-2.5",children:[t.jsx("h3",{className:"caps text-label font-semibold",children:e}),t.jsxs("span",{className:"ml-auto hidden font-mono text-label text-muted-foreground sm:inline",children:[t.jsxs("kbd",{children:[hD?"⌘":"Ctrl","+Enter"]})," save · ",t.jsx("kbd",{children:"Esc"})," cancel"]})]}),b!==null&&t.jsx(ss,{problem:Tr(b,"the note"),onRetry:()=>{x(null),O()},className:"m-5"}),t.jsxs("div",{className:"space-y-4 px-5 py-4",children:[$&&t.jsxs("div",{className:"border border-warning/50 bg-warning/10 px-4 py-3 text-body",role:"alert",children:[t.jsxs("p",{className:"flex items-center gap-2 font-semibold",children:[t.jsx(Gs,{className:"size-4 text-warning-text","aria-hidden":!0}),"Changed since you opened it"]}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"This is the newest version. Your edit wasn't saved; it's below to copy."}),t.jsxs("details",{className:"mt-2",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"Your edit"}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words border bg-background p-3 font-mono text-small",children:$})]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Name"}),t.jsx(Pe,{ref:M,value:d.name,onChange:D=>L({name:D.target.value}),placeholder:"e.g., Try /policies/refund-policy first"})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Description"}),t.jsx("span",{className:"-mt-0.5 mb-1.5 block text-small text-muted-foreground",children:"One line: what the next run sees before it opens the note."}),t.jsx(Pe,{value:d.description,onChange:D=>L({description:D.target.value}),placeholder:"When it applies, and what to do"})]}),t.jsxs("fieldset",{children:[t.jsx("legend",{className:"caps mb-1.5 text-label font-semibold",children:"Type"}),t.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Type",children:iC.map(D=>t.jsxs("label",{className:ae("caps cursor-pointer border px-3 py-1.5 text-label",d.type===D?"border-foreground":"text-muted-foreground hover:text-foreground"),title:D,children:[t.jsx("input",{type:"radio",name:`type-${r??"new"}`,className:"sr-only",checked:d.type===D,onChange:()=>L({type:D})}),lC(D)]},D))}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:Hz[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(tn,{value:d.body.replace(/^\n/,""),onChange:D=>L({body:`
|
|
649
|
+
${D.target.value}`}),rows:7,placeholder:"What to do, and why. Markdown.",className:"resize-y leading-[1.65]"})]}),y.length>0&&t.jsxs("div",{className:"border border-destructive/50 bg-destructive/5 px-4 py-3 text-body",role:"alert",children:[t.jsx("p",{className:"font-semibold text-destructive-text",children:"Not saved: the note doesn't pass the checks."}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:y.map((D,W)=>t.jsx("li",{children:D.detail},W))})]}),S&&t.jsx("p",{className:"text-body text-destructive-text",role:"alert",children:"Not saved: a note by this name exists already. Change its name."}),k===Sg?t.jsxs("p",{className:"text-body text-destructive-text",role:"alert",children:["Not saved: ",Sg]}):k!==null&&t.jsx(ss,{problem:ei(k,"the note","The note was not saved."),className:""}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void R(),disabled:!A,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:f0(d.name,i)})]})]})]})}function _D({notes:e,all:n,from:s,focus:r,runs:o,v2:i,agentId:c,readOnly:d,onChanged:u,refreshHolds:f}){const[g,b]=Sr(f,null),[x,h]=p.useState(e.some(N=>r.includes(N.file))),[v,y]=p.useState(new Set),j=N=>y($=>{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(EC,{title:"Earlier notes",count:`${e.length} no longer read`,open:x,onToggle:()=>h(N=>!N),children:e.map(N=>{var O,L;const $=N.status==="retired",_=$&&v.has(N.file),M=(O=s.get(N.file))==null?void 0:O.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(ke,{tone:"muted",children:$?"Retired":"Replaced"}),$&&t.jsx($C,{open:_,label:`the note ${N.name}`,onClick:()=>j(N.file)}),$&&!d&&N.etag&&g!==N.file&&t.jsxs(B,{size:"sm",onClick:()=>b(N.file),"aria-label":`Restore ${N.name}`,children:[t.jsx(LN,{"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)})]}):$?kC(N.retired):null}),g===N.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(SC,{name:N.name,kind:"note",from:(L=N.retired)==null?void 0:L.from,restore:()=>i.restoreNote(c,N.file,N.etag),onChanged:u,onDone:()=>b(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}),Yc(N.text).trim()&&t.jsx(Jm,{text:Yc(N.text)}),M&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(Qm,{run:M.id,runs:o,at:M.at,reason:M.reason})})]})]},N.file)})})}function EC({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(Or,{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 TD({kind:e,items:n,v2:s,agentId:r,runs:o,readOnly:i,onChanged:c,refreshHolds:d}){const[u,f]=p.useState(!1),[g,b]=Sr(d,null),[x,h]=p.useState(new Set),v=y=>h(j=>{const k=new Set(j);return k.has(y)?k.delete(y):k.add(y),k});return t.jsx(EC,{title:e==="skill"?"Earlier skills":"Earlier workflows",count:`${n.length} no longer given`,open:u,onToggle:()=>f(y=>!y),children:n.map(y=>{var j;return t.jsxs("li",{className:"border-b px-4 py-3 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-body text-muted-foreground line-through decoration-muted-foreground/40",children:y.name}),t.jsx(ke,{tone:"muted",children:"Retired"}),t.jsx($C,{open:x.has(y.file),label:`the ${e} ${y.name}`,onClick:()=>v(y.file)}),!i&&g!==y.file&&t.jsxs(B,{size:"sm",onClick:()=>b(y.file),"aria-label":`Restore ${y.name}`,children:[t.jsx(LN,{"aria-hidden":!0})," Restore"]})]}),y.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:y.description}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:kC(y.retired)}),g===y.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(SC,{name:y.name,kind:e,from:(j=y.retired)==null?void 0:j.from,restore:()=>s.restoreNote(r,mx(y),y.etag),onChanged:c,onDone:()=>b(null)})}),x.has(y.file)&&t.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[t.jsx(RD,{v2:s,agentId:r,file:y.file,etag:y.etag,kind:e,label:`the ${e} ${y.name}`}),y.run&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(Qm,{run:y.run,runs:o})})]})]},y.file)})})}function $C({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(Or,{className:ae("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function RD({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),b=async()=>{const x=++g.current;f(null),d(null);try{const h=await e.readNote(n,s);x===g.current&&d(h.note)}catch(h){x===g.current&&f(h??new Error("unknown"))}};return p.useEffect(()=>{b()},[s,r]),u!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(ss,{problem:Tr(u,i),onRetry:()=>void b(),className:""})}):c===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${i}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):o==="skill"?t.jsx(Jm,{text:Yc(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 x0({runs:e}){const n=e.filter(o=>{var i;return((i=o.learning)==null?void 0:i.state)==="dropped"}),s=n.filter(o=>Vf(o.learning.reason)!=="nothing").slice(0,6),r=n.length-n.filter(o=>Vf(o.learning.reason)!=="nothing").length;return n.length?t.jsxs(jC,{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:ay(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:Sn(o),children:Sn(o)}),t.jsxs("span",{className:"shrink-0",children:["· ",ht(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 AD({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(()=>so(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(Or,{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?Zi(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(wC,"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 iy({run:e,link:n=!1,className:s}){var b;const r=cC(e.learning),o=dC(e.learning),i=Vc(e.learning),c=Vm(e.learning)&&e.learning.state!=="seeded",d=ry(e.learning),u=Gz(e.learning),f=[...l0(e.learning),...c0(e.learning)],g=((b=e.learning)==null?void 0:b.state)==="dropped"&&Vf(e.learning.reason)!=="nothing"?ay(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(tf,{agentId:e.agent_id,refs:r,link:n,kind:"given"}),o.length>0&&t.jsx(tf,{agentId:e.agent_id,refs:o,link:n,kind:"read"}),i.length>0&&t.jsx(tf,{agentId:e.agent_id,refs:i,link:n,kind:"learned",replaces:i.reduce((x,h)=>{var v;return x+(((v=h.supersedes)==null?void 0:v.length)??0)},0)}),u&&t.jsx(tf,{agentId:e.agent_id,refs:d,link:n,kind:"pending"}),g&&t.jsx(OD,{agentId:e.agent_id,said:g,link:n}),["skill","workflow"].flatMap(x=>{const h=(x==="skill"?l0:c0)(e.learning);return[!1,!0].map(v=>{const y=h.filter(j=>j.pending===!0===v);return y.length?t.jsx(MD,{agentId:e.agent_id,refs:y,link:n,kind:x,pending:v},`${x}-${v}`):null})}),c&&t.jsxs(ke,{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"})]}),Jz(e.learning.state)]})]})}function OD({agentId:e,said:n,link:s}){const r=t.jsxs(ke,{tone:"muted",className:ae(s&&"cursor-pointer"),children:[t.jsx(NT,{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:Ym(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 MD({agentId:e,refs:n,link:s,kind:r,pending:o}){const i=o?`${qf(n.length,r)} ${n.length===1?"waits":"wait"} for your OK`:`Learned ${qf(n.length,r)}`,c=`${i}: ${n.map(f=>f.name).join(", ")}`,d=o?Gx:r==="skill"?Ef:Ja,u=t.jsxs(ke,{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:Ym(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 tf({agentId:e,refs:n,link:s,kind:r,replaces:o=0}){const i=r==="pending"?pC(n.length):r==="given"?`Started with: ${Zi(n.length)}`:r==="read"?`Read: ${Zi(n.length)}`:`Learned ${Zi(n.length)}`,c=n.map(h=>h.name).join(", "),d=r==="given"||r==="read",u=d?Sf:r==="pending"?Gx:Jx,f=t.jsxs(ke,{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!==hC),b=`${i}${c?`: ${c}`:""}${o?` (replaces ${o===1?"1 older note":`${o} older notes`})`:""}`;if(!s||!g.length&&r!=="pending")return t.jsx("span",{title:b,"aria-label":b,className:"inline-flex",children:f});const x=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(E5,{tip:x,children:t.jsx("a",{href:Ym(e,g.map(h=>h.file)),"aria-label":b,className:"inline-flex",children:f})})}function PD({n:e,className:n}){return e<=0?null:t.jsx("span",{"aria-label":oy(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 LD=["pi","claude-agent","codex","opencode"];function ID(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 zD(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 DD(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 ly="Refused on this server for every agent, whatever the agent's own setting or Never ask.",FD="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.",_C=(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=Go(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 UD(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 WD={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},TC={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."}}},Jf=(e,n)=>{var s;return(n&&((s=TC[n])==null?void 0:s.label[e]))??WD[e]??e},HD={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."},v0=(e,n)=>{var s;return(n&&((s=TC[n])==null?void 0:s.help[e]))??HD[e]};function RC(e,n){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:Jf(e,n),unavailable:!1}:{text:"not known",unavailable:!1}}function AC(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 BD=(e,n,s,r)=>AC(e,n,"provider",s,r),GD=(e,n,s,r)=>AC(e,n,"permission",s,r);function vx(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 OC(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 qD=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),KD=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))]},VD=e=>typeof e=="string"?e:JSON.stringify(e);function YD(e){return Object.keys(e).sort().map(n=>{const s=e[n];if(qD(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=KD(s),o=r[0]===null,i=(o?r.slice(1):r).map(d=>VD(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 QD="Calls outside it are refused before they run or ask.",JD="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.",XD=[{id:"runs",label:"Runs",shows:()=>!0,Body:sF},{id:"versions",label:"Versions",shows:()=>!0,Body:cP},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:rF},{id:"learning",label:"Learning",shows:(e,n)=>e.kind==="agentic"&&n.learning!==!1,Body:e=>t.jsx(gD,{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:PP}],cn=(e,n)=>`#/agents/${encodeURIComponent(e)}${n?`/${n}`:e==="new"||e==="connect"?"/runs":""}`;function ZD({v2:e,agentId:n,routePrefix:s,harnesses:r,go:o,tab:i,learning:c,notes:d,places:u}){const[f,g]=p.useState(null),[b,x]=p.useState(null),[h,v]=p.useState(0),[y,j]=p.useState(void 0);p.useEffect(()=>{let P=!0;return g(null),x(null),j(void 0),$(!1),S.current=++k.current,e.getAgent(n).then(D=>{P&&g(D.agent)},D=>{P&&x({cause:D})}),e.statsOver({from:Ov(N2),agent:n}).then(D=>{P&&j(D)},()=>{P&&j(null)}),()=>{P=!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),_=(P=!1,D=!P)=>{const W=++k.current;return D&&(S.current=W),e.getAgent(n).then(K=>(W>E.current&&W>=S.current&&(E.current=W,g(H=>H&&H.agent_id===K.agent.agent_id?K.agent:H),$(!1)),E.current>=W),()=>(W===k.current&&!P&&$(!0),E.current>=W))},M=P=>{g(D=>({...P,tools:(D==null?void 0:D.tools)??P.tools})),_()},O=()=>void _(),L=()=>void _(!0,!1),A=()=>_(!0,!0),R=y===void 0?void 0:y!==null;return b?b.cause instanceof Fe&&b.cause.status===404?t.jsx(l2,{what:"agent",id:n,list:{href:"#/agents",label:"Open the agents list"}}):t.jsx(Qt,{problem:Wt(b.cause,"the agent"),onRetry:()=>v(P=>P+1)}):f?t.jsx(eF,{agent:f,onAgent:M,onSignInsAgent:g,reread:_,onChanged:O,poll:L,afterForget:A,stale:N,v2:e,go:o,stats:y,analytics:R,places:u,routePrefix:s,harnesses:r,tab:i,learning:c,notes:d},f.agent_id):t.jsx(rP,{})}function eF({agent:e,onAgent:n,onSignInsAgent:s,reread:r,onChanged:o,poll:i,afterForget:c,stale:d,v2:u,go:f,stats:g,analytics:b,routePrefix:x,harnesses:h,tab:v,learning:y,notes:j,places:k}){var se,fe,xe,Ne;const E=nF(e,u,r,()=>r(!1,!1)),[S,N]=p.useState(!1),$=Kf(e),_=e.definition,M=es(_),{native:O,refresh:L}=gL(e,u),A=e.kind==="workflow",R=A?Ja:Hx,P=Y2(_.harness??"pi",h),D=_.model?ul(_.model,x):P?(({text:ge,title:me})=>({text:`${ge} (default)`,title:me}))(ul(P,x)):{text:zI},W=A||O||M||h==null?void 0:h.find(ge=>ge.id===(_.harness??"pi")&&ge.available===!1),K=W?`${W.id} doesn't run on this server${W.reason?`: ${W.reason}`:"."}`:void 0,H=A2(e,k),q=`${XP(H==null?void 0:H.place)}${H!=null&&H.byDefault?" (server default)":""}`,F=!M&&!O&&!A&&!W&&!_.model&&!P&&(h==null?void 0:h.some(ge=>ge.id===(_.harness??"pi")&&ge.default_model===null)),G=[...M?[["Runtime",Yo(M.runtime)],["Model","Reported per run"],["Execution","Your backend"]]:O?[["Runtime",O.runtime],["Model",O.model??"Native default"],["Selector",O.selector.kind==="project"?"Project default":O.selector.name??O.selector.kind],["Machine",O.machine_id]]:A?[]:[["Harness",_.harness??"pi"],["Model",D.text,D.title],["Thinking",_.thinking??"default"],["Runs",q]],["Revision",`rev ${_.version} of ${e.revisions}`]],U=XD.filter(ge=>ge.shows(e,{analytics:b===!0,learning:y===void 0?v==="learning"?void 0:!1:!!y})),z=U.find(ge=>ge.id===v)??U[0],Y=v==="analytics"&&b===void 0,J=((se=E.runs)==null?void 0:se.filter(tF))??[],X=((fe=e.runs)==null?void 0:fe.live)??(E.runs?`${J.length}${E.cursor?"+":""}`:"—"),le=[["Status",e.archived_at?"Archived":O?bd(O):"Active"],["Live jobs",String(X)],...G];return t.jsx(xL,{native:O,children:t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":"Agent detail",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-5 py-2 lg:flex-nowrap lg:py-0","aria-label":"Agent toolbar",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>f(e.archived_at?"#/agents?archived=true":"#/agents"),children:t.jsx(Rn,{"aria-hidden":!0})}),t.jsx(R,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 truncate text-body font-semibold",children:_.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(),L()},disabled:E.reading,children:t.jsx(Jo,{className:ae(E.reading&&"animate-spin"),"aria-hidden":!0})}),!O&&!M&&t.jsx(B,{size:"sm",onClick:()=>f(cn(e.agent_id,"edit")),children:"Detailed editor"}),t.jsx(nn,{label:"Edit agent",prompt:Bo(location.origin,e.agent_id,!!O,M==null?void 0:M.runtime),playgroundHref:O||M?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),!e.archived_at&&t.jsx(nn,{variant:"primary",label:"Run agent",disabled:!!O&&(!O.connected||O.state!=="ready"||!O.capabilities.launch),prompt:zv(location.origin,e.agent_id,M==null?void 0:M.runtime),playgroundHref:M?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`})]})]}),t.jsxs("main",{className:"grid min-h-0 flex-1 grid-cols-1 items-start gap-6 overflow-auto p-5 lg:grid-cols-[minmax(260px,320px)_minmax(0,1fr)] md:p-8",children:[t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"Agent overview",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold",children:_.name}),_.approvals==="never"&&t.jsx(ke,{tone:"warning",className:"mt-2",title:"Never ask: a call of this agent never waits for you. A tool set to deny, and a template’s pins, still hold.",children:"Unattended"}),_.description&&t.jsx("p",{id:"agent-description",className:ae("mt-2 text-body leading-relaxed text-muted-foreground",!S&&"max-sm:line-clamp-2"),children:_.description}),t.jsx("p",{className:"mt-3 break-all font-mono text-label text-muted-foreground",children:e.agent_id})]}),t.jsxs("button",{type:"button","aria-expanded":S,"aria-controls":_.description?"agent-description agent-facts":"agent-facts",onClick:()=>N(ge=>!ge),className:"flex w-full min-w-0 items-center gap-2 text-left font-mono text-small text-muted-foreground sm:hidden",children:[t.jsx(Es,{className:ae("size-3.5 shrink-0 transition-transform",S&&"rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:le.map(([,ge])=>ge).join(" · ")})]}),t.jsxs("dl",{id:"agent-facts",className:ae("grid grid-cols-2 gap-3",!S&&"max-sm:hidden"),"aria-label":"Current revision",children:[le.map(([ge,me,Le])=>t.jsxs("div",{className:"min-w-0 border bg-card p-4",children:[t.jsx("dt",{className:"mb-2 text-label text-muted-foreground",children:ge}),t.jsx("dd",{className:"break-words text-body font-semibold",title:Le,children:me})]},ge)),!A&&!O&&!M&&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:!A&&e.tools?e.tools.length?t.jsx("ul",{className:"space-y-2","aria-label":"Tools",children:e.tools.map(ge=>t.jsxs("li",{children:[t.jsx("span",{title:ge.blurb,children:ge.name}),ge.provider?` · ${Jf(ge.provider,ge.name)}`:"",ge.permission?` · ${ge.permission}`:"",RC(ge.resolved,ge.name).unavailable&&t.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:ge.resolved,children:" · unavailable"})]},ge.name))}):"none":_.tools.join(", ")||"None configured"})]})]}),K&&t.jsx(vt,{tone:"warning","aria-label":"Harness not available",children:K}),!e.archived_at&&F&&t.jsxs(vt,{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(vt,{tone:"error",children:["Couldn't refresh this agent. ",t.jsx(B,{size:"sm",onClick:()=>void r(),children:"Retry"})]}),(xe=e.warnings)!=null&&xe.length?t.jsxs("div",{className:"font-mono text-small",role:"status","aria-label":"Save warnings",children:[t.jsx("p",{className:"text-warning-text",children:"Created. What the server said of this revision (Edit shows each at its step):"}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:e.warnings.map((ge,me)=>t.jsxs("li",{children:[t.jsx("span",{className:"text-muted-foreground",children:ge.field})," ",ge.message]},`${ge.field}:${me}`))})]}):null,t.jsx(wL,{agent:e,v2:u,onAgent:s,poll:i,refresh:c}),O&&t.jsx(vL,{agent:e,v2:u,learning:y,onAgent:n,onChanged:async()=>{L(),await r()}}),!O&&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:M?"Managed by your backend":_.skills.join(", ")||"None configured"})]})]}),_.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:_.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"}),J.length?t.jsx("ul",{className:"space-y-3",children:J.map(ge=>t.jsx("li",{children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(ge.run_id)}`,className:"flex items-center gap-2 text-small hover:text-primary-text",children:[t.jsx(Cl,{run:ge}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:Sn(ge)}),t.jsx(fr,{className:"size-3 shrink-0","aria-hidden":!0})]})},ge.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",{className:"min-w-0","aria-label":"Agent workspace",children:[t.jsx(MS,{id:"agent-views",label:"Agent views",value:z.id,onChange:ge=>f(cn(e.agent_id,ge)),tabs:U.map(ge=>({id:ge.id,label:t.jsxs(t.Fragment,{children:[ge.label,ge.id==="learning"&&t.jsx(PD,{n:$,className:"ml-1.5"})]})})),className:"mb-5 overflow-x-auto px-0 md:px-0"}),t.jsx("div",{...C5("agent-views",z.id),"aria-label":Y?void 0:z.label,children:Y?t.jsx(Un,{label:"Loading the tab",rows:4}):t.jsx(z.Body,{agent:e,v2:u,go:f,stats:g,history:E,focus:j,learning:y,onAgent:n,onChanged:o,places:k})})]})]})]})})}const tF=e=>!e.imported_from&&["queued","working","paused","input_required"].includes(e.status);function nF(e,n,s,r){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,b]=p.useState(!1),[x,h]=p.useState(null),[v,y]=p.useState(!1),j=p.useRef(0),k=p.useRef([]),E=p.useRef(0),S=p.useRef(!1),N=async($,_=!1,M=!1,O=!1)=>{if(S.current)return;S.current=!0;const L=++j.current;f(!0),b(!!$);const A=_?O?r():s():Promise.resolve();try{let R=$,P=[];const D=$||M?void 0:k.current.at(-1),W=D?Date.parse(D.created_at):NaN,K=E.current+1;let H=!1;const q=new Set;do{if(q.size>=K){y(!0),h({title:"Run history could not be refreshed.",why:"Previous runs are still shown. The run list changed too much to refresh them safely.",next:"Try again, or reload the latest runs to reset the loaded history."});return}if(q.has(R))throw new Error("The runs list repeated a page. Refresh to try again.");q.add(R);const F=await n.listAgentRuns(e.agent_id,50,R,!!e.archived_at);if(L!==j.current)return;P=gx(P,F.runs),R=F.next_cursor,H||(H=F.runs.some(G=>G.run_id===(D==null?void 0:D.run_id)||Date.parse(G.created_at)<W))}while(!$&&R&&D&&!H);L===j.current&&(k.current=$?gx(k.current,P):P,E.current=$?E.current+1:q.size,i(k.current),d(R),h(null),y(!1))}catch(R){L===j.current&&h(Wt(R,$?"more runs":"the runs"))}finally{await A,L===j.current&&(S.current=!1,f(!1),b(!1))}};return p.useEffect(()=>{S.current=!1,k.current=[],E.current=0,i(null),d(null),h(null),y(!1),N(null);const $=()=>{document.hidden||N(null,!0,!1,!0)};window.addEventListener("focus",$),document.addEventListener("visibilitychange",$);const _=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:x,refresh:()=>{N(null,!0)},loadMore:()=>{c&&N(c)},reloadLatest:v?()=>{N(null,!0,!0)}:null}}function sF({agent:e,history:n}){const[s,r]=p.useState(""),{runs:o,cursor:i,reading:c,more:d,error:u,refresh:f,loadMore:g,reloadLatest:b}=n;if(u&&!o)return t.jsx(Qt,{problem:u,onRetry:f,className:""});if(!o)return t.jsx(Un,{label:"Loading the runs",rows:5});const x=o.filter(h=>`${Sn(h)} ${h.run_id} ${h.status}`.toLowerCase().includes(s.toLowerCase()));return t.jsxs("section",{className:"min-h-[380px] overflow-hidden border","aria-label":"Agent run history",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b p-3",children:[t.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(gm,{className:"size-3.5 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{"aria-label":"Search this agent's runs",value:s,onChange:h=>r(h.target.value),placeholder:"Search runs…",className:"w-40 min-w-0"})]}),t.jsxs("span",{className:"text-small text-muted-foreground",children:[o.length,i?"+":""," ",o.length===1&&!i?"run":"runs"]}),t.jsx("div",{className:"ml-auto",children:t.jsx(nn,{label:"Query",prompt:`${Dm(location.origin,e.agent_id)}
|
|
651
|
+
Current view: all statuses; ${e.archived_at?"archived runs":"non-archived runs"}.`,playgroundHref:Rv(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:x.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(Cl,{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:Sn(h)}),t.jsx(fr,{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(iy,{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:ht(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:dl(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||kl(h.cost))?no(h.cost,{ended:Ba(h.status)}):"—"})]},h.run_id))})]}),!x.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(Qt,{problem:u,onRetry:f,className:""}),b&&t.jsx(B,{size:"sm",onClick:b,disabled:c,children:"Reload latest runs"})]}),i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",onClick:g,disabled:c,children:d?"Loading":"Load more"})})]})}function rF({agent:e}){const n=e.definition.workflow,s=p.useMemo(()=>ll(n),[n]),r=p.useMemo(()=>({meta:gd(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:[qm(sy(s))," · rev ",e.definition.version]}),t.jsx("span",{className:"flex-1"}),t.jsx(nn,{label:"Edit workflow",prompt:Bo(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(Nd,{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(Sd,{})})]})}function MC({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 oF=20,aF=100,iF=4,Pi=(e,n)=>(e==null?void 0:e.filter(s=>s.status===n).length)??0,PC=e=>`#/agents/${encodeURIComponent(e.agent_id)}/learning`,yx=e=>e.toLocaleString("en-US"),LC=[{label:"Active notes",of:e=>e.view?{value:Pi(e.notes,"active"),exact:!!e.complete}:null},{label:"Learned skills",of:e=>{var n;return(n=e.view)!=null&&n.skills?{value:Pi(e.view.skills,"active"),exact:!0}:null}},{label:"Workflow drafts",of:e=>{var n;return(n=e.view)!=null&&n.workflows?{value:Pi(e.view.workflows,"active"),exact:!0}:null}},{label:"Pending review",of:e=>e.view?{value:Pi(e.notes,"pending")+Pi(e.view.skills,"pending")+Pi(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 IC(e,n){if(!e.length)return"0";const s=e.map(n);return s.every(r=>r===null)?"—":`${yx(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 lF({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),b=p.useRef(!1),x=p.useCallback(async()=>{if(n!=="on"&&n!=="off"||b.current)return;b.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 Vr(async A=>{if(!E())throw new Error("Read superseded");if(A&&N.has(A))throw new Error("The agent list repeated a page. Refresh to try again.");A&&N.add(A);const R=await e.listAgents({cursor:A});return S=R.next_cursor,R},A=>A.agents,aF);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(A=>[A.agent_id,A])).values()].map(A=>({agent:A}));r(A=>{const R=new Map(A==null?void 0:A.map(P=>[P.agent.agent_id,P]));return _.map(({agent:P})=>{const D=R.get(P.agent_id);return P.kind==="agentic"&&(D==null?void 0:D.agent.kind)==="agentic"&&D.view?{...D,agent:P,stale:!0,error:void 0,unavailable:void 0}:{agent:P}})});const M=_.filter(A=>A.agent.kind==="agentic");let O=0;const L=async()=>{for(;E()&&O<M.length;){const{agent:A}=M[O++];let R;try{const P=await e.agentLearning(A.agent_id);if(!E())return;const D=new Map(P.notes.items.map(q=>[q.file,q]));let W=P.notes.next_cursor,K;const H=new Set;for(let q=0;W&&q<oF&&E();q++){if(H.has(W)){K="The note list repeated a page.";break}H.add(W);try{const F=await e.learningNotes(A.agent_id,W);F.items.forEach(G=>D.set(G.file,G)),W=F.next_cursor}catch(F){K=Wt(F,"more notes").why;break}}R={agent:A,view:P,notes:[...D.values()],complete:!W,...W?{noteIssue:K??"More note pages are available in the agent's Learning tab."}:{}}}catch(P){R={agent:A,error:Wt(P,"Learning"),unavailable:P instanceof Fe&&P.status===404}}if(!E())return;r(P=>(P==null?void 0:P.map(D=>D.agent.agent_id!==A.agent_id?D:R.error&&!R.unavailable&&D.view?{...D,...R,stale:!0}:R))??null)}};await Promise.all(Array.from({length:Math.min(iF,M.length)},L)),E()&&f(new Date().toISOString())}catch(S){E()&&i(Wt(S,"Learning Dojo"))}finally{E()&&(b.current=!1,d(!1))}},[e,n]);p.useEffect(()=>{r(null),f(null),i(null),x();const k=()=>{document.hidden||x()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{g.current++,b.current=!1,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[x]),p.useEffect(()=>{if(n!=="on"&&n!=="off")return;const k=window.setInterval(()=>{document.hidden||x()},15e3);return()=>window.clearInterval(k)},[n,x]);const h=(s==null?void 0:s.filter(k=>k.agent.kind==="agentic"))??[],v=h.filter(k=>k.view).length,y=h.some(k=>k.stale),j=h.flatMap(k=>{var 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:"flex min-h-12 shrink-0 items-center gap-2 border-b px-5",children:[t.jsx(MC,{className:"shrink-0"}),t.jsx("h1",{className:"caps text-body font-semibold",children:"Learning Dojo"}),t.jsx(B,{className:"ml-auto",size:"icon","aria-label":"Refresh Learning Dojo",disabled:c||!n,onClick:()=>void x(),children:t.jsx(Jo,{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(Qt,{problem:o,onRetry:()=>void x(),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(Un,{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:LC.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:IC(h,E)})]},k))}),t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:[v," of ",h.length," agent histories read. Counts show active items; pending notes, skills and drafts are counted under review. + means a minimum from incomplete data; — means not reported.",y?" Last-read totals include saved histories that may have changed; they are not current minimums.":u&&!c?` Updated ${ht(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(cF,{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)}`:PC(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"," · ",ht(E.at)]})]}),t.jsx(fr,{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…":v<h.length?"No changes in the histories available so far.":"No saved learning changes yet."})]})]})]})]})]})}function cF({row:e,server:n}){const{agent:s,view:r,error:o}=e,i=s.kind==="agentic",c=s.definition.learning===!0||s.definition.learning==="notes";return t.jsxs("article",{className:"flex min-w-0 flex-col border bg-card p-5",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words text-lead font-semibold",children:s.definition.name||s.agent_id}),t.jsx(ke,{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:LC.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:IC([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:[yx(r.counts.merged)," runs kept learning · ",yx(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?PC(s):cn(s.agent_id),children:[i?"Open learning":"View agent",t.jsx(fr,{className:"size-3.5","aria-hidden":!0})]})]})}const dF=140,uF=32,fF=40,mF=60;function cy({value:e,name:n,note:s,blurb:r,description:o,tag:i,why:c,alert:d,on:u,disabled:f,warn:g,onToggle:b}){const[x,h]=p.useState(!1),v=p.useRef(null),y=p.useRef(null),j=p.useRef(null),k=p.useRef(null),E=nf(v,"width",x,n),S=nf(y,"height",x,o),N=nf(j,"width",x,i),$=nf(k,"width",x,d),_=E??n.length>uF,M=!!o&&(S??o.length>dF),O=!!i&&(N??i.length>fF),L=!!d&&($??d.length>mF),A=!!c&&(c!==i||O),R=!!o&&(!!r||M)||A||L||_,P=(W,K)=>!x&&W&&K?W:void 0,D=W=>{W.preventDefault(),W.stopPropagation(),h(K=>!K)};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",x?"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:b,className:"shrink-0 accent-primary"}),t.jsx("span",{ref:v,title:P(n,_),className:ae("min-w-0",x?"[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&&!x?t.jsx("span",{ref:y,"data-line":!0,className:"mt-1 line-clamp-3 font-sans text-label text-muted-foreground [overflow-wrap:anywhere]",title:P(o,M),children:o}):null,i&&t.jsx("span",{ref:j,"data-tag":!0,title:P(c,A),className:"mt-1 max-w-full self-start truncate border px-1.5 text-micro text-muted-foreground",children:i}),d&&!x&&t.jsx("span",{ref:k,className:"mt-1 truncate font-sans text-label text-warning-text",role:"alert",title:P(d,L),children:d}),x&&t.jsxs("span",{"data-more":!0,className:"mt-2 min-w-0 space-y-1 font-sans text-label text-muted-foreground",children:[o&&t.jsx("span",{className:"block whitespace-pre-wrap [overflow-wrap:anywhere]",children:o}),c&&c!==o&&t.jsx("span",{className:"block [overflow-wrap:anywhere]",children:c}),d&&t.jsx("span",{className:"block text-warning-text [overflow-wrap:anywhere]",role:"alert",children:d})]}),R&&t.jsx("button",{type:"button",onClick:D,"aria-expanded":x,className:"mt-auto self-start pt-1 font-sans text-label underline underline-offset-2 hover:text-foreground",children:x?"Less":"More"})]})}function nf(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 hF({servers:e,tools:n,harness:s,harnesses:r,onChange:o,onRetry:i}){const c=h=>o(n.includes(h)?n.filter(v=>v!==h):[...n,h]),d=n.filter(h=>Go(h)),u=!r||r.includes(s),f=(h,v,y,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(cy,{value:h,name:v,note:E,description:y,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}),b=!u&&t.jsxs("p",{className:"text-small text-warning-text",children:[s," doesn't run MCP tools on this server",r!=null&&r.length?`: ${r.join(" and ")} do`:"","."]});if(e==="failed")return t.jsxs("div",{className:"mt-4 space-y-2",children:[t.jsxs("p",{className:"font-mono text-small text-warning-text",role:"alert",children:["The MCP servers could not be read."," ",i&&t.jsx(B,{type:"button",onClick:i,size:"xs",className:"ml-1",children:"Retry"})]}),d.length>0&&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 x=yI(n,e);return!e.length&&!x.length?t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"No MCP server is saved: add one in Settings → MCP servers to grant its tools."}):t.jsxs("div",{className:"mt-4 space-y-4",children:[b,e.map(h=>t.jsxs("section",{"aria-label":`MCP server ${h.name}`,children:[t.jsxs("p",{className:"caps mb-2 text-label font-semibold text-muted-foreground",children:[h.name," · MCP server"]}),g(h.tools.map(v=>{var y;return f(G2(h.name,v.name),v.name,[v.title,v.description].filter(Boolean).join(": ")||void 0,void 0,vI(v,s)??(v.permission==="deny"?ly:void 0),(y=h.not_metered)!=null&&y.includes(v.name)?"not metered":void 0)}))]},h.name)),x.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(x.map(h=>f(h.grant,h.grant,void 0,h.why)))]})]})}const pF="[a-z][a-z0-9-]{0,31}",zC="[A-Za-z0-9_-]{1,64}",gF="[a-z0-9][a-z0-9.-]{0,63}",xF="[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}",vF=`[a-z][a-z0-9_-]{0,63}(?:\\.${zC})?`,yF="mcp:",bF="monid:",y0="*",wF=new RegExp(`^mcp:(${pF})/(\\*|${zC})$`),jF=new RegExp(`^monid:(${gF})/(\\*|${xF})$`),kF=new RegExp(`^${vF}$`);function NF(e){if(fl(e)){const s=jF.exec(e);return s?s[2]===y0?{kind:"monid-provider",provider:s[1]}:{kind:"monid",provider:s[1],endpoint:s[2]}:void 0}if(!CF(e))return kF.test(e)?{kind:"plain",name:e}:void 0;const n=wF.exec(e);if(n)return n[2]===y0?{kind:"mcp-server",server:n[1]}:{kind:"mcp",server:n[1],tool:n[2]}}const fl=e=>e.startsWith(bF),SF=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.`,CF=e=>e.startsWith(yF);function DC(e){const n=NF(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 EF=e=>DC(e)?void 0:SF(e);function $F(e){const n=e.trim();return!n||fl(n)?n:`monid:${n}`}function FC(e){return new Map(e.flatMap((n,s)=>fl(n)?[[`definition.tools[${s}]`,n]]:[]))}function _F(e,n){const s=FC(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 TF=e=>{const n=DC(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 RF({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(fl))],g=x=>o(e.includes(x)?e.filter(h=>h!==x):[...e,x]),b=()=>{const x=$F(i);if(!x)return;const h=EF(x);u(h),!h&&(c(""),e.includes(x)||o([...e,x]))};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(x=>{const h=r.filter(v=>v.grant===x);return t.jsx("li",{className:"min-w-0",children:t.jsx(cy,{value:x,name:x,description:TF(x),alert:h.length?"The save was refused here: see below.":void 0,warn:h.length>0,on:e.includes(x),disabled:!1,onToggle:()=>g(x)})},x)})}),t.jsxs("form",{className:"flex flex-wrap items-start gap-2",onSubmit:x=>{x.preventDefault(),b()},children:[t.jsx(Pe,{"aria-label":"monid grant",value:i,onChange:x=>{c(x.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(gl,{"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((x,h)=>t.jsx("li",{children:x.message},`${x.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((x,h)=>t.jsx("li",{children:x.message},`${x.grant}:${h}`))})]})}const AF=e=>e.offered&&(e.kind==="none"||e.providers.some(n=>n.ready)),OF=e=>{var n;return e.why??((n=e.providers.find(s=>!s.ready))==null?void 0:n.why)};function MF(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 PF=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},dy="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",uy=new Set(["sandbox","desktop","phone"]),LF=e=>e.charAt(0).toUpperCase()+e.slice(1);function IF({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=AF(c),u=d?void 0:OF(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(MF(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:LF(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&&uy.has(i.kind)&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:dy}),!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 zF({value:e,saved:n,places:s,tools:r,picked:o,onChange:i,error:c,warning:d}){var N;const u=e??xd(n),f=(u??Uv(!1,o,s)).mode,g=(N=s.boxes.find($=>$.available))==null?void 0:N.id,b=(u==null?void 0:u.mode)==="sandbox"?u.box:g,x=!g&&f!=="sandbox",h=new Set(r.filter($=>$.sandbox_only).map($=>$.name)),[v,y]=p.useState([]),j=()=>{const $=o.filter(_=>h.has(_));y($),i({place:{mode:"runner"},...$.length?{tools:o.filter(_=>!h.has(_))}:{}})},k=$=>{y([]),$&&i({place:{mode:"sandbox",box:$}})},E=$=>$.map(_=>_.charAt(0).toUpperCase()+_.slice(1)).join(" and "),S=($,_,M,O,L=!1)=>t.jsxs("label",{className:ae("flex items-start gap-3 border px-4 py-3",f===$?"border-foreground":"border-border",L?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsx("input",{type:"radio",name:"place",value:$,checked:f===$,disabled:L,onChange:O,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:M})]})]});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Where it runs"}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"radiogroup","aria-label":"Where it runs",children:[S("runner","On the server","No box and no shell: its files stay in the run's folder on the server.",j),S("sandbox","In a sandbox","Its file and shell tools run in a box; its keys stay on the server.",()=>k(b),x)]}),x&&t.jsxs("div",{className:"mt-3 border px-4 py-3 text-small text-muted-foreground",role:"status",children:[t.jsx("p",{children:"No box is set up on this server, so this agent runs on the server."}),t.jsx("ul",{className:"mt-1",children:s.boxes.map($=>t.jsxs("li",{children:[t.jsx("span",{className:"font-mono",children:$.id}),$.reason?`: ${$.reason}`:""]},$.id))})]}),f==="sandbox"&&t.jsx("ul",{className:"mt-3 border","aria-label":"Box",children:s.boxes.map($=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("label",{className:ae("flex items-start gap-3 px-4 py-2.5",$.available?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"box",value:$.id,checked:b===$.id,disabled:!$.available&&b!==$.id,onChange:()=>k($.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-mono text-body",children:$.id}),!$.available&&$.reason&&t.jsx("span",{className:"mt-0.5 block text-small",children:$.reason})]})]})},$.id))}),f==="runner"&&v.length>0&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:[E(v)," ",v.length===1?"runs":"run"," only in a sandbox, so ",v.length===1?"it's":"they're"," turned off for this agent."]}),c&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:d})]})}function UC(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 bx({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:JD}):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,":"]})," ",YD(e.pin),". ",QD,s?" This server pins it too; both hold.":""]}):null}const b0={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."]},DF=({effect:e})=>t.jsx("span",{"data-effect":e,children:t.jsx(ke,{tone:b0[e][0],title:b0[e][1],children:e})}),FF="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function fy({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:b,labelOf:x,detailOf:h,effectOf:v,confirmAllowOf:y=()=>!1,fallbackWordOf:j,onEdit:k}){const[E,S]=p.useState(null),N=p.useRef(null),$=p.useRef(null);p.useEffect(()=>{var D,W;if(E!==null||d||N.current===null)return;const P=`${N.current} permission`;N.current=null,(W=[...((D=$.current)==null?void 0:D.querySelectorAll("button[aria-label]"))??[]].find(K=>K.getAttribute("aria-label")===P))==null||W.focus()},[E,d]);const _=P=>{N.current=P,S(null)},M=n.some(P=>P.choice),O=n.some(P=>P.gate),L=n.some(P=>{var D;return((D=P.gate)==null?void 0:D.ask_needs)==="password"}),A=["Tool",...O?["Permission"]:[],...M?["Provider","Resolves to"]:[]],R=t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"—"});return t.jsxs(t.Fragment,{children:[L&&t.jsx("p",{className:"mb-2 text-small text-warning-text",children:FF}),t.jsx("div",{ref:$,className:"relative overflow-x-auto",children:t.jsxs("table",{"aria-label":e,className:"w-full border text-left",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b",children:[A.map(P=>t.jsx("th",{className:"caps px-3 py-2 text-label font-semibold text-muted-foreground",children:P},P)),t.jsx("th",{children:t.jsx("span",{className:"sr-only",children:"Reset"})})]})}),t.jsx("tbody",{children:n.map(({name:P,choice:D,gate:W})=>{var me,Le,Ue;const K=D?r(D):"",H=(me=s[P])==null?void 0:me.provider,q=D!==void 0&&H!==void 0&&H!==K,F=q?H:K,G=De=>k(Ee=>BD(Ee,P,De,K)),U=W?o(W):"allow",z=(Le=s[P])==null?void 0:Le.permission,Y=W!==void 0&&z!==void 0&&z!==U,J=Y?z:U,X=W!==void 0&&u(P,J),le=X&&f,se=le?"deny":J,fe=De=>k(Ee=>GD(Ee,P,De,U)),xe=v==null?void 0:v(P),Ne=(j==null?void 0:j(P))??"default",ge=h==null?void 0:h(P);return t.jsxs(p.Fragment,{children:[t.jsxs("tr",{"data-tool":P,"data-set":q||Y?"":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:[(x==null?void 0:x(P))??P,xe&&t.jsx(DF,{effect:xe})]}),ge?t.jsx("span",{"data-tool-detail":!0,className:"mt-0.5 block text-small text-muted-foreground",children:ge}):null]}),O&&t.jsx("td",{className:"px-3 py-2",children:W?t.jsxs(t.Fragment,{children:[t.jsx(Ct,{small:!0,label:`${P} permission`,value:se,disabled:d||le,onChange:De=>{const Ee=De;Ee==="allow"&&Ee!==se&&y(P)?S(P):fe(Ee)},className:ae("w-48",Y&&"border-primary text-primary"),options:W.permissions.map(De=>({value:De,label:`${De}${De===U?` (${Ne})`:""}`,...De==="ask"&&W.ask_needs==="password"&&!g?{disabled:!0,title:"No one can approve a call here: it takes the owner's password sign-in."}:{}}))}),Y&&!le&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",U,Ne==="default"?"":` (${Ne})`]}),X&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:ly}),se==="deny"&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:FD}),se==="ask"&&g&&!X&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),se==="ask"&&W.ask_needs==="password"&&!g&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Each call is refused: no one can approve it here."})]}):R}),M&&t.jsx("td",{className:"px-3 py-2",children:D?t.jsxs(t.Fragment,{children:[t.jsx(Ct,{small:!0,label:`${P} provider`,value:F,disabled:d,onChange:De=>G(De),className:ae("w-96 max-w-full",q&&"border-primary text-primary"),options:D.providers.map(De=>({value:De,label:`${Jf(De,P)}${De===K?" (default)":""}`}))}),v0(F,P)&&t.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:v0(F,P)}),q&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",Jf(K,P)]})]}):R}),M&&t.jsx("td",{className:"px-3 py-2.5",children:D?i(D,F):R}),t.jsx("td",{className:"px-2 py-2 text-right",children:q&&t.jsx(B,{size:"sm",variant:"ghost",disabled:d,"aria-label":`Reset ${P} to its default`,onClick:()=>G(void 0),children:"Reset"})})]}),E===P&&t.jsx("tr",{children:t.jsx("td",{colSpan:A.length+1,className:"px-3 pb-2.5",children:t.jsx(UF,{name:P,keep:se==="ask"?"Keep asking":"Cancel",busy:d,onAllow:()=>{d||(_(P),fe("allow"))},onKeep:()=>_(P)})})}),b!=null&&b(P)?t.jsx("tr",{"data-note":P,children:t.jsx("td",{colSpan:A.length+1,className:"px-3 pb-2.5",children:b(P)})}):null,(Ue=c[P])!=null&&Ue.length?t.jsx("tr",{children:t.jsx("td",{colSpan:A.length+1,className:"px-3 pb-2.5",children:c[P].map(De=>t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:De},De))})}):null]},P)})})]})})]})}function UF({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 wx({value:e,prefix:n,tool:s}){const r=RC(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 WF=({choice:e,harnesses:n=[]})=>t.jsx(t.Fragment,{children:LD.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(wx,{value:e.resolves[s],prefix:`${s}: `,tool:e.name},s)})});function HF({agent:e,harness:n,model:s,tools:r,choices:o,gates:i=[],mcpServers:c,serverSettings:d,focus:u,callTools:f,value:g,issues:b,unattended:x=!1,onChange:h}){const v=new Set(r),y=o.filter(R=>v.has(R.name)||!R.available),j=i.some(R=>R.ask_needs==="password"),k=R=>{var P;return(P=e==null?void 0:e.tools)==null?void 0:P.find(D=>D.name===R)},E=R=>{var D;const P=Go(R);return P?(D=c==null?void 0:c.find(W=>W.name===P.server))==null?void 0:D.tools.find(W=>W.name===P.tool):void 0},S=R=>{var D;const P=Go(R);return P?(D=g[`mcp:${P.server}/*`])==null?void 0:D.permission:void 0},N=f?f.flatMap(R=>i.filter(P=>P.name===R)):[...new Set(r)].flatMap(R=>{var W;const P=i.find(K=>K.name===R);if(P)return[P];const D=k(R)??E(R);return!((W=D==null?void 0:D.permissions)!=null&&W.length)||!D.default_permission?[]:[{name:R,permission:D.permission??D.default_permission,default_permission:D.default_permission,permissions:D.permissions,...j&&D.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),$=UC(y,N,[...i.map(R=>R.name),...o.map(R=>R.name)]),_=p.useRef(null);if(p.useEffect(()=>{var D,W;if(!u)return;const R=`${u} permission`,P=[...((D=_.current)==null?void 0:D.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(K=>K.getAttribute("aria-label")===R);(W=P==null?void 0:P.scrollIntoView)==null||W.call(P,{block:"center"}),P==null||P.focus()},[]),!$.length)return null;const M=(e==null?void 0:e.definition.tool_settings)??{},O=x!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:L,rest:A}=OC(b,"definition.tool_settings",$.map(R=>R.name));return t.jsxs("section",{"aria-label":"Tool settings",ref:_,children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Tool settings"})}),t.jsxs("p",{className:"-mt-1 mb-2 text-small text-muted-foreground",children:["Each of these tools takes this server's setting (its default here) unless it is changed here. ",f?"A call node can't wait for an approval: a tool set to ask stops the run from starting. Set it to allow.":x?"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(fy,{label:"This agent's tool settings",unattended:x,rows:$,settings:g,fallbackOf:R=>R.provider,issues:L,onEdit:R=>h(R(g)),effectOf:R=>{var P;return(P=E(R))==null?void 0:P.effect},confirmAllowOf:R=>{var P;return((P=E(R))==null?void 0:P.effect)==="destructive"},noteOf:R=>{const P=g[R],D=d==null?void 0:d[R],W=!!(P!=null&&P.pin||P!=null&&P.pin_broken);return!W&&!(D!=null&&D.pin)&&!(D!=null&&D.pin_broken)?null:t.jsxs(t.Fragment,{children:[W&&t.jsx(bx,{setting:P,label:"Pinned for this agent",also:!!(D!=null&&D.pin)}),(!W||(D==null?void 0:D.pin_broken))&&t.jsx(bx,{setting:D,label:"Pinned on this server"})]})},refused:R=>_C(R,i,e==null?void 0:e.tools,c),locked:!0,permissionFallbackOf:R=>{var P;return S(R.name)??((P=k(R.name))==null?void 0:P.default_permission)??R.permission},resolvesOf:R=>{var H,q,F,G,U,z;const P=(((H=g[R.name])==null?void 0:H.provider)??null)!==(((q=M[R.name])==null?void 0:q.provider)??null)||(((F=g[R.name])==null?void 0:F.permission)??null)!==(((G=M[R.name])==null?void 0:G.permission)??null)||O,D=(U=e==null?void 0:e.tools)==null?void 0:U.find(Y=>Y.name===R.name),W=D&&D.provider===(((z=g[R.name])==null?void 0:z.provider)??R.provider)?D.resolved:void 0,K=(s??"")===((e==null?void 0:e.definition.model)??"");return!P&&n===((e==null?void 0:e.definition.harness)??"pi")&&K&&W?t.jsx(wx,{value:W,prefix:`${n}: `,tool:R.name}):!P&&!M[R.name]&&!s?t.jsx(wx,{value:R.resolves[n],prefix:`${n}: `,tool:R.name}):t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),A.map(R=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:R},R))]})}const sf=20,BF=400;function GF(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 b=new AbortController,x=setTimeout(()=>{o({workflow:n,...r?{tools:r}:{}},b.signal).then(h=>{b.signal.aborted||c({text:e,check:h})},h=>{b.signal.aborted||((h==null?void 0:h.status)===404||(h==null?void 0:h.status)===405?c("unsupported"):c({text:e,failed:(h==null?void 0:h.message)||`the server answered ${(h==null?void 0:h.status)??"nothing"}`}))})},BF);return()=>{clearTimeout(x),b.abort()}},[e,s,f,o,d]);const g=()=>{c(null),u(b=>b+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 w0({text:e,onText:n,base:s,baseLabel:r,serverIssues:o,readOnly:i=!1,validate:c,tools:d}){var K;const u=p.useRef(null),f=p.useRef(null),[g,b]=p.useState(0),x=p.useMemo(()=>yP(e),[e]),h=p.useRef(null);x.ok&&(h.current={value:x.value,spans:x.spans});const v=(K=h.current)==null?void 0:K.value,y=p.useMemo(()=>ll(v),[v]),j=p.useMemo(()=>s===void 0?null:ll(s),[s]),k=p.useMemo(()=>j?i2(j,y):null,[j,y]),E=GF(e,x.ok?x.value:void 0,x.ok,d,i?void 0:c),S=p.useMemo(()=>x.ok&&!i?kP(x.value):[],[x,i]),N=p.useMemo(()=>E.mode!=="server"?S:[...E.check.issues.map(H=>({path:H.path,message:H.message,severity:"error"})),...E.check.warnings.map(H=>typeof H=="string"?{path:"",message:H,severity:"warning"}:{path:H.path??"",message:H.message,severity:"warning"})],[E.mode,E.mode==="server"?E.check:null,S]),$=x.ok?NP(x.spans,y.nodes.map(H=>H.path),g):null,_=p.useMemo(()=>({meta:gd(v,y),diff:k?{added:k.added.map(H=>H.path),edited:[...k.changed,...k.rewritten].map(H=>H.next),moved:k.moved.map(H=>H.next),removed:k.removed.map(({label:H,kind:q})=>({label:H,kind:q}))}:void 0,selected:$?{path:$}:null}),[v,y,k,$]),M=e.split(`
|
|
652
|
+
`).length,O=H=>bP(e,H),L=[];x.ok||L.push({...O(x.error.offset),message:`JSON: ${x.error.message}`,severity:"error",offset:x.error.offset});for(const H of N){const q=x.ok?Ek(x.spans,H.path):void 0,F=(q==null?void 0:q.start)??0;L.push({...O(F),message:H.message,severity:H.severity,offset:F,path:H.path})}for(const H of[...o??[]].reverse()){const q=H.path&&x.ok?Ek(x.spans,H.path):void 0;L.unshift({...q?O(q.start):{line:0,col:0},message:`Server: ${H.message}`,severity:"error",offset:(q==null?void 0:q.start)??-1})}const A=new Map;for(const H of L)H.line&&A.get(H.line)!=="error"&&A.set(H.line,H.severity);const R=(H,q=H)=>{const F=u.current;!F||H<0||(F.focus(),F.setSelectionRange(H,q),F.scrollTop=Math.max(0,(O(H).line-4)*sf),b(H))};p.useEffect(()=>{const H=x.ok?x.spans.get("/root"):void 0;H&&u.current&&(u.current.scrollTop=Math.max(0,(O(H.start).line-2)*sf))},[]);const P=k?k.edges.added.length+k.edges.removed.length:0,D=k?k.added.length+k.changed.length+k.rewritten.length+k.removed.length+k.moved.length+P:0,W=L.filter(H=>H.severity==="error").length;return t.jsxs("div",{className:"grid min-h-0 grid-cols-1 border xl:grid-cols-[minmax(420px,5fr)_7fr]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col border-b xl:border-b-0 xl:border-r",children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"workflow.json"}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[M," 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"&&x.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"&&x.ok&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:E.mode==="pending"?"checking...":"checked by the server"}),W?t.jsxs("span",{className:"caps inline-flex items-center gap-1 text-label text-destructive-text",children:[t.jsx(nl,{className:"size-3.5","aria-hidden":!0})," ",W," ",W===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:`${sf}px`},children:Array.from({length:M},(H,q)=>t.jsx("div",{className:ae("pr-2",A.get(q+1)==="error"&&"bg-destructive/15 text-destructive-text",A.get(q+1)==="warning"&&"bg-warning/15 text-warning-text"),children:q+1},q))}),t.jsx(tn,{bare:!0,ref:u,value:e,readOnly:i,spellCheck:!1,wrap:"off","aria-label":"Workflow JSON",onChange:H=>{i||n(H.target.value),b(H.target.selectionStart)},onSelect:H=>b(H.target.selectionStart),onScroll:H=>{f.current&&(f.current.scrollTop=H.target.scrollTop)},onKeyDown:H=>{if(H.key!=="Tab"||i)return;H.preventDefault();const q=H.currentTarget,F=q.selectionStart,G=q.selectionEnd;n(`${e.slice(0,F)} ${e.slice(G)}`),requestAnimationFrame(()=>q.setSelectionRange(F+2,F+2))},className:"flex-1 resize-none overflow-auto bg-background px-3 py-3 text-small selection:bg-primary/[0.28] selection:text-foreground focus-visible:outline focus-visible:outline-focus focus-visible:-outline-offset-2 focus-visible:outline-ring",style:{lineHeight:`${sf}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:[L.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."}),L.map((H,q)=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>R(H.offset),className:"flex w-full items-start gap-2.5 border-b px-4 py-2 text-left hover:bg-accent",children:[H.severity==="error"?t.jsx(nl,{className:"mt-0.5 size-3.5 shrink-0 text-destructive-text","aria-hidden":!0}):t.jsx(Gs,{className:"mt-0.5 size-3.5 shrink-0 text-warning-text","aria-hidden":!0}),t.jsx("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",children:H.line?`L${H.line}:${H.col}`:"—"}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:H.message})]})},q))]})]}),t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:qm(sy(y))}),k&&(D?t.jsxs("span",{className:"font-mono text-label",children:[[k.added.length&&`${k.added.length} new`,k.changed.length+k.rewritten.length&&`${k.changed.length+k.rewritten.length} edited`,k.removed.length&&`${k.removed.length} removed`,k.moved.length&&`${k.moved.length} moved`,!k.moved.length&&P&&`${P} ${P===1?"connection":"connections"} changed`].filter(Boolean).join(" · ")," ",t.jsxs("span",{className:"text-muted-foreground",children:["against ",r??"the current revision"]})]}):t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Same as ",r??"the current revision"]})),t.jsx("span",{className:"flex-1"}),!x.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]",!x.ok&&"opacity-60"),children:y.nodes.length?t.jsx(Nd,{graph:y,marks:_,label:"The workflow's graph",minScale:.55,onSelect:H=>{const q=x.ok?x.spans.get(`${H.path}/label`)??x.spans.get(H.path):void 0;q&&R(q.start,q.end)}}):t.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"No root node to draw yet."})}),t.jsx("div",{className:"border-t px-4 py-2",children:t.jsx(Sd,{})})]})]})}const qF="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function WC(){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:qF,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let Wi=null;function rf(e,n){return Wi?Wi({to:e,replay:n}):!1}function HC(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);Wi=o;const i=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",i),()=>{Wi===o&&(Wi=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(Wi=null,!n.replay){location.hash=n.to;return}location.hash!==r.current?window.addEventListener("hashchange",n.replay,{once:!0}):n.replay()}}}}const BC="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",Cg="custom",j0=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function KF(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 VF(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 YF=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:Ya},{id:"workflow",label:"Workflow",note:"Its graph and its JSON",Icon:Ja},{id:"computer",label:"Computer",note:"Where it runs and what it drives",Icon:Qa},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:Ef},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:IN},{id:"history",label:"History",note:"Revisions and the current one",Icon:sd}];function QF({agent:e,revisions:n=[],caps:s,onSave:r,onMakeCurrent:o,onArchive:i,onReload:c,onBack:d,step:u,problem:f=null,notice:g,draft:b,validate:x,providerChoices:h=[],permissionGates:v=[],focusTool:y,mcpServers:j=null,serverToolSettings:k,onRetryMcp:E}){var fn,Hn,_s,Bn,Ts,Rs,On;const S=!e,N=e==null?void 0:e.definition,$=es(N),_=!!(N!=null&&N.native)||!!$,[M,O]=p.useState(u??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),L=S?gg(s.places):void 0,[A,R]=p.useState({name:(N==null?void 0:N.name)??"",description:(N==null?void 0:N.description)??"",instructions:(N==null?void 0:N.instructions)??(S?aL:""),harness:(N==null?void 0:N.harness)??"pi",thinking:N==null?void 0:N.thinking,model:N==null?void 0:N.model,tools:S?xg("pi",s.tools,L):(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):"",...L?{place:L}:{},...(e==null?void 0:e.kind)==="workflow"?{workflowText:b??JSON.stringify(N.workflow,null,2)}:{}}),[P,D]=p.useState(!1),[W,K]=p.useState(!1),H=p.useRef(A);H.current=A;const[q,F]=p.useState(A),G=ee=>{const{maxCostText:Me,workflowText:mt,...At}=ee,Jt=Mk(Me),Be=j0(mt),te={...At,maxCost:Jt.ok?Jt.value??0:Me,...mt!==void 0?{workflowSent:Be!==void 0?Be:mt}:{}},be=e?{...vd(e,te,"").definition}:{...te};return delete be.version,be.tool_settings&&!Object.keys(be.tool_settings).length&&delete be.tool_settings,{...be,tools:[...be.tools??[]].sort(),approvals:ee.approvals??(N==null?void 0:N.approvals)??"ask"}},U=!Ji(G(A),G(q)),[z,Y]=p.useState([]),[J,X]=p.useState(!1),le=s.tools.map(ee=>`${ee.name}:${ee.available}:${(ee.harnesses??[]).join("+")}`).join(","),se=JSON.stringify(gg(s.places)??null);p.useEffect(()=>{if(!S)return;const ee=Me=>{const mt=Me.place??gg(s.places);return{...Me,...mt?{place:mt}:{},...J?{}:{tools:xg(Me.harness??"pi",s.tools,mt)}}};R(ee),F(ee)},[le,se]);const[fe,xe]=p.useState(""),[Ne,ge]=p.useState(()=>((N==null?void 0:N.tools)??[]).filter(fl)),[me,Le]=p.useState(!1),[Ue,De]=p.useState(!1),[Ee,re]=p.useState(f),[_e,Qe]=p.useState(null),he=ee=>{Qe(null),O(ee)},Ie=p.useRef(null),et=FC(Ie.current??A.tools??[]),pt=(Ee==null?void 0:Ee.kind)==="invalid"?Object.entries(Ee.fields).flatMap(([ee,Me])=>{const mt=et.get(ee);return mt?[{grant:mt,message:Me}]:[]}):[],oe=ee=>(Ee==null?void 0:Ee.kind)==="invalid"&&Object.entries(Ee.fields).filter(([Me])=>!et.has(Me)&&(Me===`definition.${ee}`||Me.startsWith(`definition.${ee}[`)||Me.startsWith(`definition.${ee}.`))).map(([,Me])=>Me).join(" ")||void 0,{monid:$e,rest:st}=_F((e==null?void 0:e.warnings)??[],(N==null?void 0:N.tools)??[]),Oe=ee=>pL(st,ee).map(Me=>Me.message).join(" ")||void 0,dt=ee=>{S&&Ue||R(Me=>({...Me,...ee}))},Tt=p.useRef(null);p.useEffect(()=>{var ee;((Ee==null?void 0:Ee.kind)==="invalid"||(Ee==null?void 0:Ee.kind)==="other")&&((ee=Tt.current)==null||ee.focus())},[Ee]);const nt=(e==null?void 0:e.kind)==="workflow",ft=S&&R2(A.harness),Kt=[...(fn=A.name)!=null&&fn.trim()?[]:["Give the agent a name to create it."],...!nt&&!ft&&!((Hn=A.instructions)!=null&&Hn.trim())?["Write its instructions to create it."]:[]],Dt=A.approvals??(N==null?void 0:N.approvals)??"ask",ye=mL(s.harnesses,S?{available:!!s.decisionProvider}:void 0),de={mcpHarnesses:s.mcpHarnesses,workflow:nt},We=ee=>{if(ee.mode==="sandbox")return;const Me=new Set(s.tools.filter(mt=>mt.sandbox_only).map(mt=>mt.name));Y(mt=>mt.filter(At=>!Me.has(At)))},Ze=ee=>{if(S&&!J){dt({harness:ee,tools:xg(ee,s.tools,A.place)}),Y([]);return}const Me=cL(ee,A.tools??[],z,s.tools,de);dt({harness:ee,tools:Me.tools}),Y(Me.held)},at=n.find(ee=>ee.revision===(e==null?void 0:e.revision))??n.find(ee=>ee.current),Q=YF.filter(ee=>!(S&&ee.id==="history")&&(ee.id!=="workflow"||nt)&&!(ft&&ee.id==="tools")&&(ee.id!=="computer"||!nt&&!ft&&!!(s.computers||s.places))),ve=Q.some(ee=>ee.id===M)?M:Q[0].id,He=Q.findIndex(ee=>ee.id===ve),Se=async()=>{if(!r)return;const ee=A;Ie.current=A.tools??[],De(!0);let Me={...A,workflowText:void 0,maxCostText:void 0};if(!ft){const Jt=Mk(A.maxCostText);if(!Jt.ok){De(!1),re({kind:"invalid",message:Jt.message,fields:{"definition.max_cost_usd":Jt.message}});return}const Be=typeof(N==null?void 0:N.max_cost_usd)=="number"&&N.max_cost_usd>0,te=Jt.value??0;(te!==0||Be)&&(Me={...Me,max_cost_usd:te})}if(nt)try{Me={...Me,workflow:JSON.parse(A.workflowText??"")}}catch(Jt){De(!1),re({kind:"invalid",message:`The workflow is not JSON: ${Jt.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${Jt.message}`}});return}const mt=await r(Me,fe),At=Ji(H.current.tool_settings??{},Me.tool_settings??{});De(!1),re(mt),!mt&&(xe(""),H.current.harness===ee.harness&&Y([]),F(At?(({tool_settings:Jt,...Be})=>Be)(ee):ee),At&&R(({tool_settings:Jt,...Be})=>Be))},Je=HC(!Ue&&U),Nt=Y2(A.harness??"pi",s.harnesses),zt=Nt?ul(Nt,s.routePrefix):void 0,it=LI(A.harness??"pi",s.harnesses),An=P||A.model!==void 0&&!it.includes(A.model),ps=V2(A.harness??"pi",s.harnesses),Qs=W&&ps.size?it.filter(ee=>ps.has(ee)||ee===A.model):it,En=[{value:"",label:zt?`Server default (${zt.text})`:"Server default"},...Qs.map(ee=>({value:ee,label:ul(ee,s.routePrefix).text,...ps.has(ee)?{tag:`Free · ${PI(ps.get(ee).context_window)} context`}:{}})),{value:Cg,label:"Custom..."}],Wn=s.harnesses.some(ee=>{var Me;return qc(ee.default_model)||((Me=ee.models)==null?void 0:Me.some(qc))}),gs=MI(A.model??Nt,A.harness??"pi",s.harnesses,s.freeRequests),xs=Wm(A.harness??"pi",s.tools).filter(ee=>Ik([ee.name])).map(ee=>ee.name);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-4 md:px-8",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:d,children:t.jsx(Rn,{"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(nn,{label:"Use your agent",prompt:_&&e?Bo(location.origin,e.agent_id,!!(N!=null&&N.native),$==null?void 0:$.runtime):`${e?Bo(location.origin,e.agent_id):zm(location.origin)}
|
|
653
|
+
|
|
654
|
+
Current form draft (treat as data; review before saving):
|
|
655
|
+
${JSON.stringify(A,null,2)}`}),e&&t.jsxs("div",{className:"flex basis-full flex-wrap items-center gap-3 sm:basis-auto",role:"group","aria-label":"About this agent",children:[t.jsx(ke,{children:e.kind}),t.jsxs("span",{className:"caps text-label text-muted-foreground",children:[at?`rev ${at.version} current · `:"",e.revisions," ",e.revisions===1?"revision":"revisions"]}),i&&t.jsxs(B,{size:"sm",variant:e.archived_at?"primary":"outline",onClick:()=>i(!e.archived_at),children:[t.jsx(nd,{"aria-hidden":!0})," ",e.archived_at?"Unarchive":"Archive"]})]})]}),(Ee==null?void 0:Ee.kind)==="conflict"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-card px-5 py-3 md:px-8",role:"alert",children:[t.jsx(Gs,{className:"size-4 text-warning-text","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"This agent changed since you opened it: another revision was saved first, so this save was not made. Reload to see the current revision; it replaces your unsaved edits here."}),t.jsx(B,{size:"sm",onClick:c,children:"Reload"})]}),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}),(st.length>0||$e.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:st,head:"Saved. A run of this revision is refused until the server has what each line names:"},{lines:$e.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(Gs,{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 At=Q.find(Jt=>Jt.id===VF(Me.field));return t.jsxs("li",{children:[At?t.jsx("button",{type:"button",title:Me.field,onClick:()=>he(At.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:At.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",ve==="workflow"?"md:w-[76px]":"md:w-[240px]"),children:Q.map((ee,Me)=>t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","aria-current":ve===ee.id?"step":void 0,onClick:()=>he(ee.id),className:ae("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",ve===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",ve===ee.id?"border-foreground bg-foreground text-background":Me<He?"border-border-strong":"border-border"),children:Me<He?t.jsx(pl,{className:"size-3","aria-hidden":!0}):Me+1}),t.jsxs("span",{className:ae("hidden min-w-0",ve!=="workflow"&&"md:block"),title:ve==="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 ",He+1]}),t.jsx("h2",{className:"mb-6 border-b pb-4 text-lg font-semibold",children:Q[He].label}),t.jsxs("fieldset",{disabled:S&&Ue,className:"m-0 min-w-0 border-0 p-0",children:[ve==="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(bt,{label:"Name",id:"agent-name",required:S,note:S?void 0:"Set when the agent was created; an edit keeps it.",error:oe("name"),warning:Oe("name"),children:t.jsx(Pe,{id:"agent-name",value:A.name,readOnly:!S,onChange:ee=>dt({name:ee.target.value}),placeholder:"e.g., Invoice checker"})}),t.jsx(bt,{label:"Description",id:"agent-description",optional:!0,note:S?void 0:"Set when the agent was created; an edit keeps it.",error:oe("description"),warning:Oe("description"),children:t.jsx(Pe,{id:"agent-description",value:A.description,readOnly:!S,onChange:ee=>dt({description:ee.target.value}),placeholder:S?"Short summary for the agent list":"No description"})})]}),ft?t.jsx(bt,{group:!0,label:"Workflow",children:t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:A.harness===Dv?"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."})}):nt?t.jsx(bt,{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:Oe("workflow"),children:t.jsxs(B,{size:"sm",onClick:()=>O("workflow"),children:[t.jsx(Ja,{"aria-hidden":!0})," Open the workflow"]})}):t.jsxs(bt,{group:me?"heading":void 0,label:"Instructions",id:me?void 0:"agent-instructions",required:!0,error:oe("instructions"),warning:Oe("instructions"),aside:t.jsx("span",{className:"flex",children:["Preview","Edit"].map(ee=>t.jsx(B,{size:"xs",type:"button",onClick:()=>Le(ee==="Preview"),className:ae("caps border px-2.5 py-1 text-label",ee==="Preview"===me?"border-foreground bg-foreground text-background":"text-muted-foreground"),children:ee},ee))}),children:[me?t.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:so(A.instructions||"")}}):t.jsx(tn,{id:"agent-instructions",value:A.instructions,onChange:ee=>dt({instructions:ee.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:ae(JF,"resize-y leading-[1.7]")}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(A.instructions??"").length," characters"]})]})]}),ve==="workflow"&&t.jsx(w0,{text:A.workflowText??"",onText:ee=>dt({workflowText:ee}),base:nt?N.workflow:void 0,baseLabel:at?`rev ${at.version}`:void 0,validate:x,tools:A.tools,serverIssues:KF(Ee,nt)}),ve==="computer"&&!nt&&!ft&&s.computers&&t.jsx("div",{className:"space-y-8",children:t.jsx(IF,{kinds:s.computers,value:A.computer??(N==null?void 0:N.computer)??ax(A.place??{mode:"runner"}),onChange:ee=>{const Me=PF(ee),mt=new Set(s.tools.filter(At=>At.sandbox_only).map(At=>At.name));dt({computer:ee,place:Me,...Me.mode==="runner"?{tools:(A.tools??[]).filter(At=>!mt.has(At))}:{}}),We(Me)},error:oe("computer")??oe("place"),warning:Oe("computer")??Oe("place")})}),ve==="computer"&&!nt&&!ft&&!s.computers&&s.places&&t.jsx("div",{className:"space-y-8",children:t.jsx(zF,{value:A.place,saved:N==null?void 0:N.place,places:s.places,tools:s.tools,picked:A.tools??[],onChange:ee=>{dt({...ee,...ee.place?{computer:ax(ee.place)}:{}}),ee.place&&We(ee.place)},error:oe("computer")??oe("place"),warning:Oe("computer")??Oe("place")})}),ve==="tools"&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs(bt,{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:oe("tools"),warning:Oe("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 nt||!ee.call_only||((Me=A.tools)==null?void 0:Me.includes(ee.name))}).map(ee=>{var kt,Lt;const Me=ix(A.harness??"pi",ee.name,s.tools,de),mt=((kt=A.tools)==null?void 0:kt.includes(ee.name))??!1,At=h.find(lt=>lt.name===ee.name),Jt=(Lt=(A.tool_settings??(N==null?void 0:N.tool_settings)??{})[ee.name])==null?void 0:Lt.provider,Be=!!At&&Jt!==void 0&&Jt!==At.provider,te=dL(ee,A.place??xd(N==null?void 0:N.place)??Uv(nt,A.tools??[],s.places)),be=_C(ee.name,v,e==null?void 0:e.tools)?ly:ee.call_only&&!nt?"Workflow-only: a workflow's call node runs it, not an agent":Me?te??(!ee.available&&!Be?(At==null?void 0:At.reason)??ee.reason??`Needs ${(ee.missing??[]).join(", ")}`:void 0):Lk(A.harness??"pi",ee.name,s.tools),qe=be?ee.call_only&&!nt?"Workflow only":te&&Me&&be===te?"Sandbox-only":be:void 0;return t.jsx("li",{className:"min-w-0",children:t.jsx(cy,{value:ee.name,name:ee.name,blurb:ee.blurb,description:ee.summary,why:be,tag:qe,on:mt,disabled:!!be&&!mt,onToggle:()=>{X(!0),dt({tools:mt?A.tools.filter(lt=>lt!==ee.name):[...A.tools??[],ee.name]})}})},ee.name)}),s.mcp&&!nt&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(hF,{servers:j,tools:A.tools??[],harness:A.harness??"pi",harnesses:s.mcpHarnesses,onRetry:E,onChange:ee=>{X(!0),dt({tools:ee})}})}),!nt&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(RF,{tools:A.tools??[],listed:Ne,notes:$e.map(({grant:ee,warning:Me})=>({grant:ee,message:Me.message})),refused:pt,onChange:ee=>{ge(Me=>[...new Set([...Me,...ee.filter(fl)])]),X(!0),dt({tools:ee})}})})]}),!nt&&!Ik(A.tools??[])&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["This agent can't reach the web: ",xs.length?`tick ${xs.join(" or ")} in Tools.`:`${A.harness??"pi"} runs no web tool on this server.`]})]}),t.jsx(HF,{agent:e,unattended:!nt&&Dt==="never",harness:A.harness??"pi",model:A.model,tools:A.tools??[],choices:nt?[]:h,gates:v,mcpServers:Array.isArray(j)?j:void 0,serverSettings:k,focus:y,callTools:nt?ID(j0(A.workflowText)??(N==null?void 0:N.workflow)):void 0,value:A.tool_settings??(N==null?void 0:N.tool_settings)??{},issues:(Ee==null?void 0:Ee.kind)==="invalid"?Ee.fields:{},onChange:ee=>!Ue&&Ji(ee,(N==null?void 0:N.tool_settings)??{})?R(({tool_settings:Me,...mt})=>mt):dt({tool_settings:ee})}),!nt&&!ft&&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",Dt===ee&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"approvals",value:ee,className:"mt-1 accent-primary",checked:Dt===ee,disabled:Ue,onChange:()=>dt({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)),Dt==="never"&&t.jsx("p",{className:"text-small text-warning-text",children:BC})]}),t.jsx(bt,{group:!0,label:"Skills",note:"Skill files are saved with each revision and kept as they are by an edit.",children:(_s=N==null?void 0:N.skills)!=null&&_s.length?t.jsx("ul",{className:"border",children:N.skills.map(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."})})]}),ve==="settings"&&t.jsxs("div",{className:"2xl:columns-2 2xl:gap-x-10 [&>*]:mb-8 [&>*]:mt-0 [&>*]:break-inside-avoid",children:[!nt&&t.jsxs(bt,{group:"heading",label:"Harness",note:"What runtime runs this agent.",error:oe("harness"),warning:Oe("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:ye.map(ee=>{const Me=t.jsxs(t.Fragment,{children:[t.jsx("input",{type:"radio",name:"harness",value:ee.id,checked:A.harness===ee.id,disabled:!ee.available&&A.harness!==ee.id,onChange:()=>Ze(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?ee.id:"Not available here"})]})]}),mt=ae("min-w-0 border px-4 py-3",A.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:[((Bn=ye.find(ee=>ee.id===A.harness))==null?void 0:Bn.label)??A.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:Lk(A.harness??"pi",ee,s.tools,s.mcpHarnesses)})]},ee))})]})]}),!nt&&!ft&&t.jsx(bt,{group:"heading",label:"Thinking",note:"How hard the model thinks before it answers.",error:oe("thinking"),warning:Oe("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",A.thinking===ee?"border-foreground":"text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:A.thinking===ee,onChange:()=>dt({thinking:ee})}),ee]},ee))})}),!ft&&t.jsxs(bt,{label:"Model",id:"agent-model",optional:!0,note:zt?t.jsxs(t.Fragment,{children:["Empty uses the server's default (",t.jsx("span",{title:zt.title,children:zt.text}),")."]}):II,error:oe("model"),warning:Oe("model"),children:[t.jsx(Ct,{id:"agent-model",label:"Model",className:"w-full",value:An?Cg:A.model??"",options:En,onChange:ee=>{if(ee===Cg){D(!0);return}D(!1),dt({model:ee||void 0})}}),An&&t.jsx(Pe,{id:"agent-model-custom","aria-label":"Custom model",className:"mt-2",value:A.model??"",onChange:ee=>{D(!0),dt({model:ee.target.value||void 0})},placeholder:"provider/model"}),ps.size>0&&t.jsxs("label",{className:"mt-2 flex items-center gap-2 text-small text-muted-foreground",children:[t.jsx(ud,{checked:W,onChange:K,label:"Free models only"})," Free models only (",ps.size,"): $0 a request; the provider limits requests per day."]})]}),!ft&&t.jsx(bt,{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.",Wn&&t.jsx("span",{className:"mt-1 block",children:TI}),gs&&t.jsx("span",{className:"mt-1 block","data-note":"free-requests",children:gs})]}),hint:t.jsx(WC,{}),error:oe("max_cost_usd"),warning:Oe("max_cost_usd"),children:t.jsx(Pe,{id:"agent-max-cost",inputMode:"decimal",value:A.maxCostText??"",onChange:ee=>dt({maxCostText:ee.target.value}),placeholder:"e.g., 2.50"})}),!nt&&!ft&&s.learning&&t.jsx(Pz,{fields:A,onFields:dt,saved:N==null?void 0:N.learning,server:s.learning,error:oe("learning"),warning:Oe("learning")})]}),ve==="history"&&_e&&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:()=>Qe(null),children:[t.jsx(Rn,{"aria-hidden":!0})," Back to History"]}),t.jsxs("span",{className:"caps text-small",children:["rev ",_e.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:_e.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(_e.created_at)}),t.jsx(B,{size:"sm",onClick:()=>o==null?void 0:o(_e.revision),disabled:!o,children:"Make current"})]}),t.jsx(w0,{readOnly:!0,text:JSON.stringify((Ts=_e.definition)==null?void 0:Ts.workflow,null,2),onText:()=>{},base:N.workflow,baseLabel:at?`rev ${at.version}, the current one`:"the current revision"})]}),ve==="history"&&!_e&&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:ht(ee.created_at)}),nt&&!ee.current&&((Me=ee.definition)==null?void 0:Me.workflow)!==void 0&&t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>Qe(ee),"aria-label":`View rev ${ee.version}`,children:[t.jsx(hm,{"aria-hidden":!0})," View"]}),ee.current?t.jsx(ke,{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:He===0,onClick:()=>he(Q[He-1].id),children:[t.jsx(Rn,{"aria-hidden":!0})," Previous"]}),ve!=="history"&&t.jsx(Pe,{value:fe,onChange:ee=>xe(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")}),ve==="history"&&t.jsx("span",{className:"flex-1"}),He<Q.length-1&&t.jsxs(B,{size:"sm",onClick:()=>he(Q[He+1].id),children:["Next ",t.jsx(Wx,{"aria-hidden":!0})]}),!_e&&t.jsx(B,{ref:Tt,size:"sm",variant:"solid",onClick:Se,disabled:!r||Ue||!S&&!U||!((Rs=A.name)!=null&&Rs.trim())||!nt&&!ft&&!((On=A.instructions)!=null&&On.trim()),children:S?Ue?"Creating…":"Create":Ue?"Saving…":U?"Save revision":at?`Saved · rev ${at.version}`:"Saved"}),S&&!Ue&&!_e&&Kt.map(ee=>t.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:ee},ee)),(Ee==null?void 0:Ee.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: ",Ee.message]}),(Ee==null?void 0:Ee.kind)==="other"&&t.jsx("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:Ee.message})]}),t.jsxs(xv,{open:Je.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:Je.leave,onCancel:Je.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 JF="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 XF({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(b=>`${b.definition.name} ${b.definition.description??""}`.toLowerCase().includes(d.toLowerCase()));return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-3 border-b px-5 py-2",children:[t.jsxs("h1",{className:"caps flex items-center gap-2 text-body font-semibold",children:[t.jsx(Hx,{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(nn,{variant:"primary",label:"Build an agent",prompt:zm(location.origin),playgroundHref:"#/playground?operation=create-agent"})]})]}),t.jsxs("div",{className:"p-5 md:p-6",children:[t.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[t.jsxs("label",{className:ae(Hc,"flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3"),children:[t.jsx(gm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,value:d,onChange:b=>u(b.target.value),placeholder:"Search agents by name or description...","aria-label":"Search agents",className:"h-full flex-1 max-sm:portrait:placeholder:text-transparent"})]}),t.jsxs(B,{size:"lg",variant:n?"primary":"outline","aria-pressed":n,onClick:()=>s==null?void 0:s(!n),children:[t.jsx(nd,{"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(b=>t.jsx(ZF,{agent:b,actions:r},b.agent_id))})]}):t.jsx(Un,{label:"Loading the agents",rows:6}),c&&t.jsx("div",{className:"mt-6",children:t.jsx(Tv,{read:c,view:"cards",query:d})})]})]})}function ZF({agent:e,actions:n}){var d;const s=e.kind==="workflow"?Ja:Hx,r=!!e.archived_at,o=Bv(e),i=es(e.definition),c=Kf(e);return t.jsxs("li",{className:ae("flex flex-col border p-5 transition-colors hover:border-border-strong",r&&"opacity-70"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-start gap-2.5 text-left",onClick:()=>{var u;return(u=n.onOpen)==null?void 0:u.call(n,e.agent_id)},children:[t.jsx(s,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-base font-semibold",children:e.definition.name}),t.jsx(ke,{children:e.kind}),e.kind==="agentic"&&t.jsx(ke,{children:i?Yo(i.runtime):o?yd(o.runtime):e.definition.harness??"pi"}),o&&t.jsx(ke,{tone:o.connected&&o.state==="ready"?"success":"warning",children:bd(o)}),r&&t.jsx(ke,{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"?SP(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(ke,{className:"shrink-0 whitespace-nowrap",children:[e.revisions," ",e.revisions===1?"revision":"revisions"]}),e.runs&&t.jsxs(ke,{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":oy(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(nn,{compact:!0,compactIcon:t.jsx(Qo,{className:"size-3.5","aria-hidden":!0}),label:`Run ${e.definition.name}`,disabled:!!o&&(!o.connected||o.state!=="ready"||!o.capabilities.launch),prompt:zv(location.origin,e.agent_id,i==null?void 0:i.runtime),playgroundHref:i?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`}),t.jsx(nn,{compact:!0,compactIcon:t.jsx(Vx,{className:"size-3.5","aria-hidden":!0}),label:`Edit ${e.definition.name}`,prompt:Bo(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(sd,{"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(TN,{"aria-hidden":!0}):t.jsx(nd,{"aria-hidden":!0})})]})]})]})}function e6({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(""),[b,x]=p.useState("live"),[h,v]=p.useState(null),[y,j]=p.useState(!1),[k,E]=p.useState(!1),[S,N]=p.useState(null),$=p.useRef(!1),_=p.useRef(!1),M=p.useRef(0),O=p.useRef(!0),L=T5(),A=p.useCallback(async()=>{if(_.current)return;_.current=!0,o(!0);const W=M.current;try{const K=await e.listConnectors();O.current&&W===M.current&&(s(K.connectors),c(null))}catch(K){O.current&&W===M.current&&c(Ut(K))}finally{_.current=!1,O.current&&o(!1)}},[e]);p.useEffect(()=>{O.current=!0,queueMicrotask(()=>{O.current&&A()});const W=()=>{!document.hidden&&!$.current&&A()},K=setInterval(W,15e3);return window.addEventListener("focus",W),document.addEventListener("visibilitychange",W),()=>{O.current=!1,M.current++,clearInterval(K),window.removeEventListener("focus",W),document.removeEventListener("visibilitychange",W)}},[A]),p.useEffect(()=>{if(!h)return;const W=new Date(h.expires_at).getTime()-Date.now();if(W<=0){v(null),j(!0);return}const K=setTimeout(()=>{v(null),j(!0)},W);return()=>clearTimeout(K)},[h]);const R=async()=>{if(!$.current){$.current=!0,E(!0),u(null),j(!1);try{const W=await e.enrollConnector(f,{native_execution:b!=="history",history_import:b!=="live"});O.current&&v(W)}catch(W){O.current&&u(Ut(W))}finally{$.current=!1,O.current&&E(!1)}}},P=async()=>{if(!($.current||!S)){$.current=!0,E(!0),u(null),M.current++;try{const{connector:W}=await e.revokeConnector(S.connector_id);O.current&&(s(K=>(K==null?void 0:K.map(H=>H.connector_id===W.connector_id?W:H))??null),N(null))}catch(W){O.current&&u(Ut(W))}finally{$.current=!1,O.current&&E(!1)}}},D=async()=>{if(h)try{await navigator.clipboard.writeText(h.enrollment_token),L({title:"Connection code copied"})}catch{L({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(nn,{label:"Connect agent",prompt:GP(location.origin,b)})]}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect a Claude Code or Codex setup on your laptop, VM or container. Its files and native sign-in stay there."}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label",children:"Allow this connection to"}),t.jsx(dd,{name:"remote-connection-intent",label:"Connection scope",size:"sm",value:b,onChange:x,options:[{value:"live",label:"Live agent",disabled:k},{value:"history",label:"History only",disabled:k},{value:"both",label:"Both",disabled:k}]}),t.jsxs("p",{className:"max-w-prose text-small text-muted-foreground",children:[b==="live"?"Run future jobs with your existing setup. Past conversations are not shared.":b==="history"?"Upload completed conversations from one selected project and runtime. No executing worker or self-improvement is enabled.":"Connect for future jobs and upload completed conversations from the selected project and runtime."," ",b!=="live"&&" Preview and approve the history on the source machine before upload. History is not used as learning."]})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(bt,{label:"Machine label",hint:"Optional. A name you recognize in this console.",children:t.jsx(Pe,{value:f,onChange:W=>g(W.target.value),placeholder:"My development machine",disabled:k,maxLength:120})})}),t.jsx(B,{size:"md",className:"self-start sm:mt-6",disabled:k,"aria-busy":k,onClick:()=>void R(),children:k&&!S?"Creating code…":"Create connection code"})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Use the code only in the connector's secure terminal prompt. It expires after ten minutes and can pair one machine. The coding-agent prompt contains no credentials."}),y&&t.jsx(vt,{tone:"warning",children:"The connection code expired. Create a new one if you have not connected the machine."}),d&&!S&&t.jsx(vt,{tone:"error",title:"Connection action failed",children:d})]}),t.jsxs("section",{className:"space-y-4","aria-label":"Connected remote machines",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-lg font-semibold",children:"Remote machines"}),t.jsx(B,{size:"sm",disabled:r||k,onClick:()=>void A(),"aria-busy":r,children:r?"Refreshing…":"Refresh"})]}),i&&t.jsx(vt,{tone:"error",title:"Remote machines could not be read",actions:t.jsx(B,{size:"xs",disabled:r,onClick:()=>void A(),children:"Try again"}),children:i}),n===null&&!i&&t.jsx("p",{className:"text-body text-muted-foreground",role:"status",children:"Loading remote machines…"}),(n==null?void 0:n.length)===0&&t.jsxs("div",{className:"border p-6",children:[t.jsx("h3",{className:"text-body font-semibold",children:"No remote machines connected"}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Use your coding agent to connect a source machine. It appears here once the connector has paired."})]}),n==null?void 0:n.map(W=>t.jsxs("article",{className:"space-y-4 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h3",{className:"mr-auto break-words text-body font-semibold",children:W.label||W.connector_id}),t.jsx(ke,{tone:W.status==="revoked"||!W.capabilities.native_execution?"plain":W.status==="online"?"success":"warning",children:W.status==="revoked"?"Revoked":!W.capabilities.native_execution&&W.capabilities.history_import?"History only":W.status==="online"?"Online":"Offline"}),t.jsx(B,{size:"sm",disabled:k||W.status==="revoked",onClick:()=>{u(null),N(W)},children:"Revoke access"})]}),t.jsxs("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Last seen"}),t.jsx("dd",{children:W.last_seen_at?ht(W.last_seen_at):"Not yet seen"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Access"}),t.jsx("dd",{children:W.capabilities.native_execution?W.capabilities.history_import?"Live agents and history import":"Selected native agents and remote jobs":W.capabilities.history_import?"History import only":"Observation only"})]})]}),W.status==="offline"&&W.capabilities.native_execution&&t.jsx(vt,{tone:"warning",children:"The source worker is offline. Start it on the original machine to verify or run its agents. Saved agents and learning are preserved."}),W.targets.length>0?t.jsx("ul",{className:"divide-y border-t",children:W.targets.map(K=>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:K.name}),K.agent_id?t.jsx("a",{href:cn(K.agent_id),className:"text-small underline underline-offset-2",children:"Open agent"}):t.jsx(ke,{children:"Not imported"})]}),t.jsxs("p",{className:"break-words text-small text-muted-foreground",children:[yd(K.runtime)," · ",K.machine_id," · ",K.history_only?"Imported history":W.status==="online"?K.state==="ready"&&K.capabilities.launch?"Ready to run":K.state==="needs_attention"?"Needs attention":"Needs verification":"Worker unavailable"]}),K.issues.length>0&&t.jsx("p",{className:"text-small text-warning-text",children:K.issues.join("; ")})]},K.target_id))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No native targets imported. Choose a project or agent with the source connector."})]},W.connector_id)),t.jsx("p",{className:"text-small text-muted-foreground",children:"Refreshes every 15 seconds while this page is visible. Open an agent to see its runs. Live connections also support Learning Dojo."})]}),t.jsx(Mm,{open:h!==null,onClose:()=>v(null),title:"Connect this machine",description:"Enter this code directly in the source connector's secure prompt.",footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",onClick:()=>v(null),children:"Done"}),t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void D(),children:"Copy connection code"})]}),children:h&&t.jsxs(t.Fragment,{children:[t.jsx(bt,{label:"One-use connection code",hint:`Expires ${ht(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:W=>W.currentTarget.select()})}),t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"This grants a scoped connector credential. Keep it out of coding-agent prompts, URLs and source control. After pairing, the connector retains its own credential in its private state directory."})]})}),t.jsxs(xv,{open:S!==null,title:"Revoke this machine's access?",confirm:k?"Revoking…":"Revoke access",busy:k,onCancel:()=>{N(null),u(null)},onConfirm:()=>void P(),children:[t.jsxs("p",{children:[(S==null?void 0:S.label)||"This machine"," will no longer receive work or report activity. Agent definitions, past runs and saved learning stay available. Pair the machine again to restore access."]}),d&&t.jsx(vt,{tone:"error",className:"mt-3",children:d})]})]})}function Xm({variant:e}){return t.jsx(nn,{variant:e,label:"Connect agent",prompt:E2(location.origin),playgroundHref:"#/agents/connect",playgroundLabel:"Connection setup"})}function t6({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([]),[b,x]=p.useState({}),[h,v]=p.useState(!1),[y,j]=p.useState(null),k=async()=>{v(!0),j(null),u(null),g([]),x({});try{u((await e.discoverNative(i.trim())).targets)}catch(S){j(Ut(S))}finally{v(!1)}},E=async()=>{v(!0),j(null);try{for(const S of f){if(b[S])continue;const{project:N,runtime:$,selector:_}=d[S],M=await e.connectNative({project:N,runtime:$,selector:_});x(O=>({...O,[S]:M.agent.agent_id}))}}catch(S){j(Ut(S))}finally{v(!1)}};return t.jsxs("section",{className:"mx-auto max-w-page space-y-6 p-5 md:p-8","aria-label":"Connect agent",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h1",{className:"mr-auto text-2xl font-semibold",children:"Connect agent"}),t.jsx(B,{size:"sm",onClick:()=>n("#/agents"),children:"Back to agents"})]}),t.jsx("p",{className:"max-w-prose text-lead text-muted-foreground",children:"Connect a native setup for new jobs, or observe an agent already running in its original application. Keep its instructions, tools, permissions and sign-in."}),t.jsx(vt,{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(dd,{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(nn,{variant:"primary",label:"Connect agent",prompt:`${E2(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(e6,{v2:e}):t.jsxs(t.Fragment,{children:[t.jsx(Xm,{}),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(bt,{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"})]}),y&&t.jsx(vt,{tone:"error",title:"Connection request failed",children:y}),d&&t.jsxs("section",{className:"space-y-4","aria-label":"Native targets",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Choose what to connect"}),!d.length&&t.jsx(vt,{children:"No supported native setup was found. Install Claude Code or Codex on this host and check the project path."}),d.map((S,N)=>t.jsxs("article",{className:"space-y-3 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsxs("label",{className:"flex min-w-0 flex-1 items-start gap-3",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",disabled:h||!!b[N],checked:f.includes(N),onChange:$=>g(_=>$.target.checked?[..._,N]:_.filter(M=>M!==N))}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("strong",{className:"break-words text-body",children:Wv(S.selector)}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:[yd(S.runtime)," · ",S.version??"Version unknown"]})]})]}),t.jsx(ke,{tone:S.state==="ready"?"success":"warning",children:bd(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(vt,{tone:"warning",children:t.jsx("ul",{children:S.issues.map($=>t.jsx("li",{children:$},$))})}),b[N]&&t.jsxs("p",{role:"status",className:"text-body",children:["Connected. ",t.jsx("a",{href:cn(b[N]),className:"underline underline-offset-2",children:"Open connected agent"})]})]},`${S.runtime}:${S.selector.kind}:${S.selector.name??""}`)),!!d.length&&t.jsx(B,{variant:"solid",size:"sm",onClick:()=>void E(),disabled:h||!f.some(S=>!b[S]),"aria-busy":h,children:h?"Connecting…":"Connect selected"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Connecting saves a reference and starts no run. Authentication and approval compatibility are checked separately on the connected agent's page."})]})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Your coding agent can also help import selected history. Past conversations stay historical; they do not become live jobs or AgentRun learning."})]})}const _a=e=>e instanceof Fe?hL(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function n6({v2:e,archived:n,go:s}){const r=_v(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),Vr(b=>e.listAgents({archived:n,cursor:b}),b=>b.agents).then(b=>{g===u.current&&i(b)}).catch(b=>{g===u.current&&d(_a(b).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(XF,{observations:r,agents:o,archived:n,onArchivedChange:g=>s(g?"#/agents?archived=true":"#/agents"),error:c,handoff:t.jsx(Xm,{}),actions:{onOpen:g=>s(cn(g)),onEdit:g=>s(cn(g,"edit")),onNew:()=>s("#/agents/new"),onRuns:g=>s(cn(g,"runs")),onLearning:g=>s(cn(g,"learning")),onArchive:async(g,b)=>{try{await(b?e.archiveAgent(g):e.unarchiveAgent(g)),f()}catch(x){d(_a(x).message)}}}})}function s6({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),[b,x]=p.useState([]),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=p.useState(0),[S,N]=p.useState(null),$=p.useRef(!0);p.useEffect(()=>($.current=!0,()=>{$.current=!1}),[]);const _=F=>Vr(G=>e.listRevisions(F,G),G=>G.revisions),M=async()=>{if(i)try{const[{agent:F,etag:G},U]=await Promise.all([e.getAgent(i),_(i)]);u(F),g(G),x(U),N(F.revision),E(z=>z+1),j(null),v(null)}catch(F){d?j(`The agent could not be reloaded: ${_a(F).message}`):v(_a(F).message)}};p.useEffect(()=>{M()},[i]);const[O,L]=p.useState(null),A=p.useRef(0);p.useEffect(()=>{const F=++A.current;e.computers().then(G=>{F===A.current&&L(G.kinds)},()=>{F===A.current&&L(null)})},[e]);const[R,P]=p.useState(void 0);p.useEffect(()=>{let F=!0;return Promise.resolve().then(()=>e.toolSettings()).then(G=>{F&&P(G)},()=>{}),()=>{F=!1}},[e]);const[D,W]=p.useState(null),K=p.useRef(0),H=()=>{if(!n.mcp)return;const F=++K.current;W(null),e.listMcpServers().then(G=>{F===K.current&&W(G.servers)},()=>{F===K.current&&W("failed")})};p.useEffect(H,[e,n.mcp]);const q=async(F,G)=>{let U;try{U=await G()}catch(z){j(`${F} did not finish: ${_a(z).message}`);return}u(U);try{const{agent:z,etag:Y}=await e.getAgent(U.agent_id),J=await _(U.agent_id).catch(()=>b);u(z),g(Y),x(J),z.revision!==S?(N(z.revision),E(X=>X+1),j(F==="Make current"?null:`${F} done. This agent changed since you opened it: the form now shows its current revision.`)):j(null)}catch(z){j(`${F} done. The page could not be refreshed: ${_a(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&&es(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(vt,{children:"This agent runs in your backend. Edit its application code with your coding agent; manage self-improving in its Learning tab."}),t.jsx(nn,{label:"Edit agent",prompt:Bo(location.origin,d.agent_id,!1,es(d.definition).runtime)}),t.jsx("a",{href:cn(d.agent_id),className:"block text-body underline underline-offset-2",children:"Back to agent"})]}):t.jsx(QF,{agent:d,revisions:b,caps:{...n,computers:O},providerChoices:s,permissionGates:r,mcpServers:D,serverToolSettings:R,onRetryMcp:H,...o?{focusTool:o,step:"tools"}:{},notice:y,validate:e.validateWorkflow,onBack:()=>c("#/agents"),onReload:()=>{M(),H()},onSave:async(F,G)=>{let U;try{if(!d){const X=await e.createAgent(iL({name:F.name??"",description:F.description??"",instructions:F.instructions??"",harness:F.harness??"pi",tools:F.tools??[],approvals:F.approvals,tool_settings:F.tool_settings,thinking:F.thinking,model:F.model,computer:F.computer,learning:F.learning,max_cost_usd:F.max_cost_usd,decisionProvider:n.decisionProvider}));return $.current&&c(cn(X.agent_id,X.kind==="workflow"?"workflow":void 0)),null}const z=vd(d,F,G);if(z.unchanged)return{kind:"other",message:"Nothing to save: the definition is the current revision's, and a note alone makes no new revision."};const{unchanged:Y,...J}=z;U=await e.updateDefinition(d.agent_id,J,f)}catch(z){return _a(z)}return u(U.agent),g(U.etag),N(U.agent.revision),e.getAgent(U.agent.agent_id).then(z=>u(Y=>Y&&Y.revision===z.agent.revision?{...Y,tools:z.agent.tools}:Y)).catch(()=>{}),_(U.agent.agent_id).then(x).catch(()=>j("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:F=>{d&&q("Make current",()=>e.setCurrent(d.agent_id,F))},onArchive:F=>{d&&q(F?"Archive":"Unarchive",()=>F?e.archiveAgent(d.agent_id):e.unarchiveAgent(d.agent_id))}},`${(d==null?void 0:d.agent_id)??"new"}:${k}`)}function dr(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 r6={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},o6={tool:1,model:1,mcp:2,computer:2,source:2};function Xf(e,n){const s=e.split(":"),r=o6[s[0]];return(r===void 0?"":s.slice(r).join(":"))||n||s.slice(1).join(":")}const a6="Sign in with your password to change secrets.",i6="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",l6="Open the console from the server's link to change secrets.",ti={sign_in:a6,no_accounts:i6,token:l6},GC=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,c6=e=>{var n;return((n=GC(e))==null?void 0:n.secrets_writable)===!0};function d6(e){const n=GC(e);return n!=null&&n.secrets_reason?n.secrets_reason:(n==null?void 0:n.accounts)===!1?"no_accounts":"sign_in"}function u6(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:c6(o),whyNot:d6(o)})},()=>{}),()=>{r=!1}},[e]),n}const f6=2e3,jx=e=>e instanceof Fe||e instanceof Error?e.message:String(e),my=({children:e="Manage usage"})=>t.jsx("a",{href:NI,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:e});function m6(){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(my,{})," in your ChatGPT settings."]}),t.jsx("p",{children:CI})]})}function kx({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,b]=p.useState(!1),[x,h]=p.useState(!1),[v,y]=p.useState(!1),j=p.useRef(null),k=p.useRef(0);p.useEffect(()=>{d(n)},[n]);const E=L=>{d(L),s==null||s(L)},S=c.state==="pending";p.useEffect(()=>{if(!S)return;let L=!1;const A=()=>{if(L||document.visibilityState!=="visible")return;L=!0;const D=++k.current;e.chatGPT().then(W=>{const K=Bf(W);D===k.current&&K&&K.state!=="pending"&&E(K)},()=>{}).finally(()=>{L=!1})},R=setInterval(A,f6),P=()=>{document.visibilityState==="visible"&&A()};return document.addEventListener("visibilitychange",P),()=>{clearInterval(R),document.removeEventListener("visibilitychange",P)}},[e,S]);const N=async()=>{f(null),b(!0);const L=window.open("","_blank");k.current++;try{const A=await e.startChatGPT();L&&(L.opener=null,L.location.href=A.authorize_url),E({state:"pending",authorize_url:A.authorize_url,expires_at:A.expires_at})}catch(A){L==null||L.close(),f(jx(A))}finally{b(!1)}},$=async L=>{var P;L.preventDefault();const A=(P=j.current)==null?void 0:P.value.trim();if(!A)return;f(null),b(!0),h(!0),k.current++;const R=D=>{j.current&&(j.current.value=""),y(!1),E(D)};try{R(await e.finishChatGPT(A))}catch(D){const W=await e.chatGPT().then(Bf,()=>null);(W==null?void 0:W.state)==="signed_in"?R(W):f(jx(D))}finally{b(!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:OI(c)}),t.jsx(m6,{})]});if(!r)return t.jsx("p",{className:"text-body",role:"status",children:ti[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 M=dr(c.authorize_url),O=c.expires_at;return t.jsxs("form",{onSubmit:L=>void $(L),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:SI}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[M&&t.jsxs(t.Fragment,{children:[t.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Open the sign-in page"})," (a new tab)"]}),M&&O&&" · ",O&&`Waits until ${md(O)}`]}),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 L;return y(!!((L=j.current)!=null&&L.value.trim()))}})]}),_,t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!v||g,children:x?"Finishing…":"Finish sign-in"}),t.jsx(B,{type:"button",size:"sm",disabled:g,onClick:()=>void N(),children:"Start again"})]})]})}const h6={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 p6({v2:e,writable:n,whyNot:s,onChange:r}){var y;const[o,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,b]=p.useState(null);if(p.useEffect(()=>{let j=!0;return e.chatGPT().then(k=>{j&&i(Bf(k))},()=>{j&&i(null)}),()=>{j=!1}},[e]),!o)return null;const x=async()=>{b(null);let j;try{j=await e.signOutChatGPT()}catch(k){b(jx(k));return}d(!1),i({state:"signed_out"}),f(typeof j=="object"&&(j==null?void 0:j.revoked)===!1?{words:j.message||$I,settings:!0}:{words:EI}),r==null||r()},h=j=>{i(j),j.state!=="pending"&&f(null),j.state==="signed_in"&&(r==null||r())},v=h6[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(ke,{tone:v.tone,children:v.words})]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:q2}),t.jsxs("div",{className:"mt-3 space-y-3",children:[o.state==="expired"&&t.jsx("p",{className:"text-body text-warning-text",children:_I}),o.state==="signed_in"&&((y=o.models)!=null&&y.length)?t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Models: ",o.models.join(" · ")]}):null,t.jsx(kx,{v2:e,view:o,onView:h,writable:n,whyNot:s}),o.state==="signed_in"&&n&&!c&&t.jsx(B,{size:"sm",onClick:()=>{d(!0),b(null)},children:"Sign out"}),c&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Sign out of ChatGPT on this server? Codex and pi agents then need a key to run here."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void x(),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(my,{children:"ChatGPT settings"})]})]})]})]})}function g6(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 qC({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=g6(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:Wf(s.id)}),t.jsx(ke,{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:ul(s.default_model,n).text}):s.reason&&t.jsx("span",{className:"text-small text-muted-foreground",children:s.reason})]},s.id)})})]}):null}const of=(e,n,s)=>{if(!/^\d{1,2}$/.test(e))return null;const r=Number(e);return r>=n&&r<=s?r:null};function x6(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const[s,r,o,i,c]=n,d=of(s,0,59);if(d===null||i!=="*")return null;if(r==="*")return o==="*"&&c==="*"?{kind:"hourly",minute:d}:null;const u=of(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=of(c,0,6);return g===null?null:{kind:"weekly",day:g,at:f}}if(c==="*"){const g=of(o,1,31);return g===null?null:{kind:"monthly",date:g,at:f}}return null}function v6(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 y6(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 k0=e=>String(e).padStart(2,"0"),b6=e=>`${k0(e.hour)}:${k0(e.minute)}`;function w6(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 Eg={exports:{}},N0;function j6(){return N0||(N0=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 b(x,h,v){h===void 0&&(h=!0),v===void 0&&(v=!1),this.expression=x,this.dayOfWeekStartIndexZero=h,this.monthStartIndexZero=v}return b.prototype.parse=function(){var x,h,v=(x=this.expression)!==null&&x!==void 0?x:"";if(v==="@reboot")return h=["@reboot","","","","","",""],h;if(v.startsWith("@")){var y=this.parseSpecial(this.expression);h=this.extractParts(y)}else h=this.extractParts(this.expression);return this.normalize(h),this.validate(h),h},b.prototype.parseSpecial=function(x){var h={"@yearly":"0 0 1 JAN *","@annually":"0 0 1 JAN *","@monthly":"0 0 1 * *","@weekly":"0 0 * * SUN","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},v=h[x];if(!v)throw new Error("Unknown special expression.");return v},b.prototype.extractParts=function(x){if(!this.expression)throw new Error("cron expression is empty");for(var h=x.trim().split(/[ ]+/),v=0;v<h.length;v++)if(h[v].includes(",")){var y=h[v].split(",").map(function(k){return k.trim()}).filter(function(k){return k!==""}).map(function(k){return isNaN(Number(k))?k:Number(k)}).filter(function(k){return k!==null&&k!==""});y.length===0&&y.push("*"),y.sort(function(k,E){return k!==null&&E!==null?k-E:0}),h[v]=y.map(function(k){return k!==null?k.toString():""}).join(",")}if(h.length<5)throw new Error("Expression has only ".concat(h.length," part").concat(h.length==1?"":"s",". At least 5 parts are required."));if(h.length==5)h.unshift(""),h.push("");else if(h.length==6){var j=/\d{4}$/.test(h[5])||h[4]=="?"||h[2]=="?";j?h.unshift(""):h.push("")}else if(h.length>7)throw new Error("Expression has ".concat(h.length," parts; too many!"));return h},b.prototype.normalize=function(x){var h=this;x[3]=x[3].replace("?","*"),x[5]=x[5].replace("?","*"),x[2]=x[2].replace("?","*"),x[0].indexOf("0/")==0&&(x[0]=x[0].replace("0/","*/")),x[1].indexOf("0/")==0&&(x[1]=x[1].replace("0/","*/")),x[2].indexOf("0/")==0&&(x[2]=x[2].replace("0/","*/")),x[3].indexOf("1/")==0&&(x[3]=x[3].replace("1/","*/")),!this.monthStartIndexZero&&x[4].indexOf("1/")==0&&(x[4]=x[4].replace("1/","*/")),x[6].indexOf("1/")==0&&(x[6]=x[6].replace("1/","*/")),x[5]=x[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,function(_){var M=_.replace(/\D/,""),O=M;return h.dayOfWeekStartIndexZero?M=="7"&&(O="0"):O=(parseInt(M)-1).toString(),_.replace(M,O)}),x[5]=="L"&&(x[5]="6"),x[3]=="?"&&(x[3]="*");var v=/^\d{1,2}W[+-]\d{1,2}$/;if(x[3].indexOf("W")>-1&&(x[3].indexOf(",")>-1||/[-+]/.test(x[3]))&&!v.test(x[3]))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var y={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var j in y)x[5]=x[5].replace(new RegExp(j,"gi"),y[j].toString());x[4]=x[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,function(_){var M=_.replace(/\D/,""),O=M;return h.monthStartIndexZero&&(O=(parseInt(M)+1).toString()),_.replace(M,O)});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)x[4]=x[4].replace(new RegExp(E,"gi"),k[E].toString());x[0]=="0"&&(x[0]=""),!/\*|\-|\,|\//.test(x[2])&&(/\*|\//.test(x[1])||/\*|\//.test(x[0]))&&(x[2]+="-".concat(x[2]));for(var S=0;S<x.length;S++)if(x[S].indexOf(",")!=-1&&(x[S]=x[S].split(",").filter(function(_){return _!==""}).join(",")||"*"),x[S]=="*/1"&&(x[S]="*"),x[S].indexOf("/")>-1&&!/^\*|\-|\,/.test(x[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 $=x[S].split("/");x[S]="".concat($[0],"-").concat(N,"/").concat($[1])}}},b.prototype.validate=function(x){var h="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(x[0],h),this.validateOnlyExpectedCharactersFound(x[1],h),this.validateOnlyExpectedCharactersFound(x[2],h),this.validateOnlyExpectedCharactersFound(x[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(x[4],h),this.validateOnlyExpectedCharactersFound(x[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(x[6],h),this.validateAnyRanges(x)},b.prototype.validateAnyRanges=function(x){x.forEach(function(h){return f.default.stepRange(h)}),f.default.secondRange(x[0]),f.default.minuteRange(x[1]),f.default.hourRange(x[2]),f.default.dayOfMonthRange(x[3]),f.default.monthRange(x[4],this.monthStartIndexZero),f.default.dayOfWeekRange(x[5],this.dayOfWeekStartIndexZero)},b.prototype.validateOnlyExpectedCharactersFound=function(x,h){var v=x.match(new RegExp("[^".concat(h,"]+"),"gi"));if(v&&v.length)throw new Error("Expression contains invalid values: '".concat(v.toString(),"'"))},b})();d.CronParser=g},8333(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.ExpressionDescriptor=void 0;var f=u(1823),g=u(6949),b=(function(){function x(h,v){if(this.expression=h,this.options=v,this.expressionParts=new Array(5),!this.options.locale&&x.defaultLocale&&(this.options.locale=x.defaultLocale),!x.locales[this.options.locale]){var y=Object.keys(x.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(y,"'.")),this.options.locale=y}this.i18n=x.locales[this.options.locale],v.use24HourTimeFormat===void 0&&(v.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return x.toString=function(h,v){var y=v===void 0?{}:v,j=y.throwExceptionOnParseError,k=j===void 0?!0:j,E=y.verbose,S=E===void 0?!1:E,N=y.dayOfWeekStartIndexZero,$=N===void 0?!0:N,_=y.monthStartIndexZero,M=_===void 0?!1:_,O=y.use24HourTimeFormat,L=y.trimHoursLeadingZero,A=L===void 0?!1:L,R=y.locale,P=R===void 0?null:R,D=y.logicalAndDayFields,W=D===void 0?!1:D,K={throwExceptionOnParseError:k,verbose:S,dayOfWeekStartIndexZero:$,monthStartIndexZero:M,use24HourTimeFormat:O,trimHoursLeadingZero:A,locale:P,logicalAndDayFields:W};K.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var H=new x(h,K);return H.getFullDescription()},x.initialize=function(h,v){v===void 0&&(v="en"),x.specialCharacters=["/","-",",","*"],x.defaultLocale=v,h.load(x.locales)},x.prototype.getFullDescription=function(){var h,v,y="";try{var j=new g.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=j.parse(),this.expressionParts[0]==="@reboot")return((v=(h=this.i18n).atReboot)===null||v===void 0?void 0:v.call(h))||"Run once, at startup";var k=this.getTimeOfDayDescription(),E=this.getDayOfMonthDescription(),S=this.getMonthDescription(),N=this.getDayOfWeekDescription(),$=this.getYearDescription();y+=k+E+N+S+$,y=this.transformVerbosity(y,!!this.options.verbose),y=y.charAt(0).toLocaleUpperCase()+y.substr(1)}catch(_){if(!this.options.throwExceptionOnParseError)y=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(_)}return y},x.prototype.getTimeOfDayDescription=function(){var h=this.expressionParts[0],v=this.expressionParts[1],y=this.expressionParts[2],j="";if(!f.StringUtilities.containsAny(v,x.specialCharacters)&&!f.StringUtilities.containsAny(y,x.specialCharacters)&&!f.StringUtilities.containsAny(h,x.specialCharacters))j+=this.i18n.atSpace()+this.formatTime(y,v,h);else if(!h&&v.indexOf("-")>-1&&!(v.indexOf(",")>-1)&&!(v.indexOf("/")>-1)&&!f.StringUtilities.containsAny(y,x.specialCharacters)){var k=v.split("-");j+=f.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(y,k[0],""),this.formatTime(y,k[1],""))}else if(!h&&y.indexOf(",")>-1&&y.indexOf("-")==-1&&y.indexOf("/")==-1&&!f.StringUtilities.containsAny(v,x.specialCharacters)){var E=y.split(",");j+=this.i18n.at();for(var S=0;S<E.length;S++)j&&(j+=" "),j+=this.formatTime(E[S],v,""),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},x.prototype.getSecondsDescription=function(){var h=this,v=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(y){return y},function(y){return f.StringUtilities.format(h.i18n.everyX0Seconds(y),y)},function(y){return h.i18n.secondsX0ThroughX1PastTheMinute()},function(y){return y=="0"?"":parseInt(y)<20?h.i18n.atX0SecondsPastTheMinute(y):h.i18n.atX0SecondsPastTheMinuteGt20()||h.i18n.atX0SecondsPastTheMinute(y)},{min:0,max:59});return v},x.prototype.getMinutesDescription=function(){var h=this,v=this.expressionParts[0],y=this.expressionParts[2],j=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(k){return k},function(k){return f.StringUtilities.format(h.i18n.everyX0Minutes(k),k)},function(k){return h.i18n.minutesX0ThroughX1PastTheHour()},function(k){var E,S;try{return k=="0"&&y.indexOf("/")==-1&&v==""?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},x.prototype.getHoursDescription=function(){var h=this,v=this.expressionParts[2],y=0,j=[];v.split("/")[0].split(",").forEach(function(S){var N=S.split("-");N.length===2&&j.push({value:N[1],index:y+1}),y+=N.length});var k=0,E=this.getSegmentDescription(v,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},x.prototype.getDayOfWeekDescription=function(){var h=this,v=this.i18n.daysOfTheWeek(),y=null;return this.expressionParts[5]=="*"?y="":y=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(j,k){var 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]:v[S];if(j.indexOf("#")>-1){var $=null,_=j.substring(j.indexOf("#")+1),M=j.substring(0,j.indexOf("#"));switch(_){case"1":$=h.i18n.first(M);break;case"2":$=h.i18n.second(M);break;case"3":$=h.i18n.third(M);break;case"4":$=h.i18n.fourth(M);break;case"5":$=h.i18n.fifth(M);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}),y},x.prototype.getMonthDescription=function(){var h=this,v=this.i18n.monthsOfTheYear(),y=this.getSegmentDescription(this.expressionParts[4],"",function(j,k){return k&&h.i18n.monthsOfTheYearInCase?h.i18n.monthsOfTheYearInCase(k)[parseInt(j)-1]:v[parseInt(j)-1]},function(j){return parseInt(j)==1?"":f.StringUtilities.format(h.i18n.commaEveryX0Months(j),j)},function(j){return h.i18n.commaMonthX0ThroughMonthX1()||h.i18n.commaX0ThroughX1()},function(j){return h.i18n.commaOnlyInMonthX0?h.i18n.commaOnlyInMonthX0():h.i18n.commaOnlyInX0()});return y},x.prototype.getDayOfMonthDescription=function(){var h=this,v,y,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()),M=N[4];M?N[3]=="-"?E=f.StringUtilities.format(((y=(v=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||y===void 0?void 0:y.call(v,M))||", %s days before the %s of the month",M,_):E=f.StringUtilities.format(((k=(j=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||k===void 0?void 0:k.call(j,M))||", %s days after the %s of the month",M,_):E=f.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),_);break}else{var O=S.match(/L-(\d{1,2})/);if(O){var L=O[1];E=f.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(L),L);break}else{if(S=="*"&&this.expressionParts[5]!="*")return"";E=this.getSegmentDescription(S,this.i18n.commaEveryDay(),function(A){return A=="L"?h.i18n.lastDay():h.i18n.dayX0?f.StringUtilities.format(h.i18n.dayX0(),A):A},function(A){return A=="1"?h.i18n.commaEveryDay():h.i18n.commaEveryX0Days(A)},function(A){return h.i18n.commaBetweenDayX0AndX1OfTheMonth(A)},function(A){return h.i18n.commaOnDayX0OfTheMonth(A)})}break}}return E},x.prototype.getYearDescription=function(){var h=this,v=this.getSegmentDescription(this.expressionParts[6],"",function(y){return/^\d+$/.test(y)?new Date(parseInt(y),1).getFullYear().toString():y},function(y){return f.StringUtilities.format(h.i18n.commaEveryX0Years(y),y)},function(y){return h.i18n.commaYearX0ThroughYearX1()||h.i18n.commaX0ThroughX1()},function(y){return h.i18n.commaOnlyInYearX0?h.i18n.commaOnlyInYearX0():h.i18n.commaOnlyInX0()});return v},x.prototype.getSegmentDescription=function(h,v,y,j,k,E,S){var N=null,$=h.indexOf("/")>-1,_=h.indexOf("-")>-1,M=h.indexOf(",")>-1;if(!h)N="";else if(h==="*")N=v;else if(!$&&!_&&!M)N=f.StringUtilities.format(E(h),y(h));else if(M){for(var O=h.split(","),L="",A=this.i18n.spaceAnd(),R=0;R<O.length;R++)if(R>0&&O.length>2&&(L+=",",R<O.length-1&&(L+=" ")),R>0&&O.length>1&&(R==O.length-1||O.length==2)&&(L+=A==","&&O.length>2?" ":"".concat(A," ")),O[R].indexOf("/")>-1||O[R].indexOf("-")>-1){var P=O[R].indexOf("-")>-1&&O[R].indexOf("/")==-1,D=this.getSegmentDescription(O[R],v,y,j,P?this.i18n.commaX0ThroughX1:k,E);P?D=D.replace(", ",""):R>0&&D.startsWith(", ")&&(D=D.substring(2)),L+=D}else if(!$)L+=y(O[R]);else{var W=this.getSegmentDescription(O[R],v,y,j,k,E);R>0&&W&&W.startsWith(", ")&&(W=W.substring(2)),L+=W}$?N=L:N=f.StringUtilities.format(E(h),L)}else if($){var O=h.split("/");if(N=f.StringUtilities.format(j(O[1]),O[1]),O[0].indexOf("-")>-1){var K=this.generateRangeSegmentDescription(O[0],k,y);K.indexOf(", ")!=0&&(N+=", "),N+=K}else if(O[0].indexOf("*")==-1){var H=f.StringUtilities.format(E(O[0]),y(O[0]));H=H.replace(", ",""),N+=f.StringUtilities.format(this.i18n.commaStartingX0(),H)}N+=this.getWrappingIncrementDescription(h,S,v,y,j,k,E)}else _&&(N=this.generateRangeSegmentDescription(h,k,y));return N},x.prototype.getWrappingIncrementDescription=function(h,v,y,j,k,E,S){if(!this.options.verbose||!v)return"";var N=h.split("/"),$=N[0],_=N[1],M=parseInt(_),O=v.max-v.min+1,L=$==="*",A=Number.isInteger(M)&&M>1,R=A&&O%M===0;if(!L||!A||R)return"";for(var P=[],D=v.min;D<=v.max;D+=M)P.push(D);if(P.length<2)return"";var W=this.getSegmentDescription(P.join(","),y,j,k,E,S);return W?", ".concat(W):""},x.prototype.generateRangeSegmentDescription=function(h,v,y){var j="",k=h.split("-"),E=y(k[0],1),S=y(k[1],2),N=v(h);return j+=f.StringUtilities.format(N,E,S),j},x.prototype.formatTime=function(h,v,y){var j=0,k=0,E=parseInt(h)+j,S=parseInt(v)+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 _="";y&&(_=":".concat(("00"+y).substring(y.length)));var M=E.toString(),O=("00"+M).substring(M.length),L=S.toString(),A=("00"+L).substring(L.length),R=this.options.trimHoursLeadingZero?M:O;return"".concat($?N:"").concat(R,":").concat(A).concat(_).concat($?"":N)},x.prototype.transformVerbosity=function(h,v){if(!v&&(h=h.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),h=h.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),h=h.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),h=h.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var y=0,j=Object.entries(this.i18n.conciseVerbosityReplacements());y<j.length;y++){var k=j[y],E=k[0],S=k[1];h=h.replace(new RegExp(E,"g"),S)}return h},x.prototype.getPeriod=function(h){return h>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},x.locales={},x})();d.ExpressionDescriptor=b},3747(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.enLocaleLoader=void 0;var f=u(9486),g=(function(){function b(){}return b.prototype.load=function(x){x.en=new f.en},b})();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(b){return u(b)?"every %s second":"every %s seconds"},g.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},g.prototype.atX0SecondsPastTheMinute=function(b){return u(b)?"at %s second past the minute":"at %s seconds past the minute"},g.prototype.everyX0Minutes=function(b){return u(b)?"every %s minute":"every %s minutes"},g.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},g.prototype.atX0MinutesPastTheHour=function(b){return u(b)?"at %s minute past the hour":"at %s minutes past the hour"},g.prototype.everyX0Hours=function(b){return u(b)?"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(b){return u(b)?", %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(b){return u(b)?", %s day before the %s of the month":", %s days before the %s of the month"},g.prototype.commaDaysAfterTheX0OfTheMonth=function(b){return u(b)?", %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(b){return u(b)?", 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(b,x){if(!b)throw new Error(x)}function f(b){var x=[];if(!isNaN(parseInt(b,10))){x.push(parseInt(b,10));var h=b.match(/^\d+-(-?\d+)/);h&&x.push(parseInt(h[1],10))}return x}var g=(function(){function b(){}return b.stepRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++){var y=h[v].split("/")[1];u(y===void 0||!/^0+$/.test(y),"step value must be greater than 0")}},b.secondRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=0&&k<=59,"seconds part must be >= 0 and <= 59")}},b.minuteRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=0&&k<=59,"minutes part must be >= 0 and <= 59")}},b.hourRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=0&&k<=23,"hours part must be >= 0 and <= 23")}},b.dayOfMonthRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=1&&k<=31,"DOM part must be >= 1 and <= 31")}},b.monthRange=function(x,h){for(var v=x.split(","),y=0;y<v.length;y++)for(var j=0,k=f(v[y]);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")}},b.dayOfWeekRange=function(x,h){for(var v=x.split(","),y=0;y<v.length;y++){if(v[y].indexOf("#")>-1){var j=v[y].substring(v[y].indexOf("#")+1);u(/^[1-5]$/.test(j),"DOW nth weekday must be >= 1 and <= 5")}for(var k=0,E=f(v[y]);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")}}},b})();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 b=[],x=1;x<arguments.length;x++)b[x-1]=arguments[x];return g.replace(/%s/g,function(h){return b.shift()})},f.containsAny=function(g,b){return b.some(function(x){return g.indexOf(x)>-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})())})(Eg)),Eg.exports}var k6=j6();const N6=EN(k6),$d={rules:20,conditions:20,list:20,pointer:512,text:200,value:1024},Nn=$d,KC={in:"is one of",prefix:"starts with",exists:"exists",missing:"is missing"},S6=Object.keys(KC);let C6=0;const Zm=()=>`r${++C6}`,E6=()=>({key:Zm(),pointer:"",op:"in",value:""}),VC=()=>({key:Zm(),event:"",actions:"",where:[]});function YC(e){const n=e.trim();try{return JSON.parse(n)}catch{return n}}function QC(e){return typeof e!="string"?JSON.stringify(e):e!==""&&e===e.trim()&&!/[,\r\n]/.test(e)&&YC(e)===e?e:JSON.stringify(e)}const $6=e=>"in"in e?`${e.pointer} is one of ${e.in.map(QC).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($6).join(" and ")}`:""}`};function JC(e){return"in"in e?{pointer:e.pointer,op:"in",value:e.in.map(QC).join(`
|
|
658
|
+
`)}:"exists"in e?{pointer:e.pointer,op:e.exists?"exists":"missing",value:""}:{pointer:e.pointer,op:"prefix",value:e.prefix}}const XC=e=>({key:Zm(),...JC(e),was:e}),ZC=e=>{if(!e.was)return!1;const n=JC(e.was);return n.pointer===e.pointer&&n.op===e.op&&n.value===e.value},eE=e=>(e??[]).join(", "),Zf=e=>({key:Zm(),event:e.event,actions:eE(e.actions),where:(e.where??[]).map(XC),was:e}),_6=(e,n)=>e.length===n.length&&e.every((s,r)=>s===n[r]),T6=e=>e.split(/[\s,]+/).filter(Boolean),S0=/^[!-~]+$/,Mc=e=>[...e].length,R6=/^(\/([^~]|~[01])*)?$/;function A6(e,n,s){return e.length>Nn.conditions&&(s[`${n}.where`]=`At most ${Nn.conditions} conditions a rule.`),e.map((r,o)=>{if(ZC(r))return r.was;const i=`${n}.where[${o}]`,c=r.pointer;if(c?c.startsWith("/")?R6.test(c)?Mc(c)>Nn.pointer&&(s[`${i}.pointer`]=`At most ${Nn.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?Mc(u)>Nn.text&&(s[`${i}.prefix`]=`At most ${Nn.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(YC);return d.length?d.length>Nn.list?s[`${i}.in`]=`At most ${Nn.list} values.`:d.some(u=>Mc(JSON.stringify(u))>Nn.value)&&(s[`${i}.in`]=`Each value is at most ${Nn.value} characters.`):s[`${i}.in`]="Give at least one value, one a line.",{pointer:c,in:d}})}function O6(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)&&(!S0.test(i)||Mc(i)>Nn.text)&&(s[`${r}.event`]=`An event's name has no spaces: printable characters only, at most ${Nn.text}.`):s[`${r}.event`]="Name the event.";const c=o&&(typeof e.actions=="string"?e.actions===eE(o.actions):_6(e.actions,o.actions??[])),d=c?[...o.actions??[]]:typeof e.actions=="string"?T6(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((b,x)=>ZC(b)&&b.was===o.where[x]))return o;d.length>Nn.list?s[`${r}.actions`]=`At most ${Nn.list} actions.`:d.some(b=>!S0.test(b)||Mc(b)>Nn.text)&&(s[`${r}.actions`]=`An action's name is printable characters, at most ${Nn.text}.`);const f=A6(e.where,r,s);return{event:i,...d.length?{actions:d}:{},...f.length?{where:f}:{}}}function hy(e){const n={};return e.length>Nn.rules&&(n["source.accept"]=`At most ${Nn.rules} rules.`),{accept:e.map((s,r)=>O6(s,r,n)),issues:n}}function _d(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 Hi=(e,n)=>n&&e===Sx(n)?n:B6(e),El=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",tE=(e="")=>({name:"",kind:"cron",cron:"",timezone:El(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),eh={seconds:1,minutes:60,hours:3600};function py(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 nE(e){try{return N6.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const Ta=e=>String(e).padStart(2,"0"),em=(e,n)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:n});function sE(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 C0=(e,n)=>{const s=new Date(e);return`${s.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:n}).replace(",","")}, ${em(s,n)} ${sE(s,n)}`};function E0(e,{zone:n=El(),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))?`${em(r,n)} today`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:n})}, ${em(r,n)} ${sE(r,n)}`} has already passed.`}function tm(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 M6(e,n,s,r){const o=new Date(tm(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-tm(new Date(c),n);return new Date(c)}const P6=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 L6(e,n,s,r,o){const i=nE(e),c=n!==s,d=P6(e),u=d&&`At ${Ta(d.hour)}:${Ta(d.minute)}`;if(d&&u&&i.startsWith(u))try{const f=r??M6(o,n,d.hour,d.minute),g=d.days?Math.floor(tm(f,s)/864e5)-Math.floor(tm(f,n)/864e5):0,b=g>0?" the next day":g<0?" the day before":"";return`At ${em(f,s)} your time${b}${c?` (${u.slice(3)} ${n})`:""}${i.slice(u.length)}`}catch{}return`${i}${c?` (${n})`:""}`}function gy(e,n,{zone:s=El(),instead:r,now:o=Date.now()}={}){const i=r?` · ${r}`:n?` · next ${C0(n,s)}`:" · no next time";return"cron"in e?`${L6(e.cron,e.timezone,s,n?new Date(n):null,new Date(o))}${i}`:"at"in e?`Once, ${C0(e.at,s)}${!r&&n&&Date.parse(n)===Date.parse(e.at)?"":i}`:`Every ${py(e.every_s)}${i}`}const ra=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,I6=e=>`${ra(e)} a run`,z6=(e,n)=>typeof e=="number"?I6(e):typeof n=="number"&&n>0?`Agent's default (${ra(n)})`:"Agent's default";function xy(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 vy=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",yy=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",rE=e=>e.source.kind==="github"&&e.target.kind==="start_run",th=[{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"}],Qc=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,by="This server's address as this page sees it: behind a proxy, use its public address.",Nx={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)"},oE=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"},D6={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"},aE=e=>`On ${e.event} from ${e.server}`,F6=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}`},iE=e=>{var s;const n=e.urls.length===1?U6(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}`},U6=e=>{try{return new URL(e).host}catch{return e}},lE=e=>`On GitHub ${e.accept.map(n=>Uo(n,!1)).join(" or ")}`;function nm(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 ${md(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const W6={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},H6=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function B6(e){if(!H6.test(e))return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toISOString().replace(/\.\d{3}Z$/,"Z")}function Sx(e){const n=new Date(e);return`${n.getFullYear()}-${Ta(n.getMonth()+1)}-${Ta(n.getDate())}T${Ta(n.getHours())}:${Ta(n.getMinutes())}${n.getSeconds()?`:${Ta(n.getSeconds())}`:""}`}const $0=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function wy(e){const n=py(e);return/^\d/.test(n)?`At least ${n}.`:`At least ${n==="hour"?"an":"a"} ${n}.`}const Jc="A number is needed.",Xc=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function _0(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()||El()};else if(e.kind==="at"){const d=Hi(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=Xc(e.every);e.every.trim()?d===void 0&&(s["source.every_s"]=Jc):s["source.every_s"]="A number is needed.";const u=e.startAt?Hi(e.startAt,(c=e.read)==null?void 0:c.startAt):null;r={kind:"schedule",every_s:Math.round((d??0)*eh[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=Xc(e.maxCost);return e.maxCost.trim()?o===void 0&&(s["target.max_cost_usd"]=Jc):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 G6=()=>({name:"",signature:"standard",accept:[],agentId:"",content:"",maxCost:""});function dE(e,n){const{accept:s,issues:r}=hy(n);return{source:{kind:"webhook",...e.signature!==void 0?{signature:e.signature}:{},...s.length?{accept:s}:{}},issues:r}}function q6(e,n=!1){const{source:s,issues:r}=dE({signature:e.signature},e.accept);return sh(e,s,r,n,"a webhook")}const K6=()=>({name:"",events:["pull_request:opened"],where:{},other:[],agentId:"",content:"",maxCost:""}),uE=[...new Set(th.map(e=>e.event))],V6=(e,n)=>e.length===n.length&&e.every(s=>n.includes(s));function nh(e){var i;const s=[...uE.flatMap(c=>{var f;const d=th.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&&V6(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 fE(e){const{accept:n,issues:s}=hy(nh(e));return n.length||(s["source.accept"]="Pick at least one event."),{source:{kind:"github",accept:n},issues:s}}function Y6(e){var s;const n={events:[],where:{},other:[],read:{order:[],rules:{}}};for(const r of e){const o=th.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=Zf(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(XC),n.read.order.push(`event:${r.event}`),n.read.rules[r.event]=r}return n}const jy=e=>e.source.kind==="composio"&&e.target.kind==="start_run";function Q6(e){const n=(e==null?void 0:e.properties)??{},s=new Set(Array.isArray(e==null?void 0:e.required)?e.required.filter(r=>typeof r=="string"):[]);return Object.entries(n).filter(([,r])=>r&&typeof r=="object"&&r.deprecated!==!0).map(([r,o])=>{const i=(Array.isArray(o.type)?o.type:[o.type]).filter(f=>f!=="null"),c=i.length===1&&["string","number","integer","boolean"].includes(String(i[0]))?i[0]:"json",d=c==="string"&&Array.isArray(o.enum)&&o.enum.every(f=>typeof f=="string")?o.enum:void 0,u=o.default===void 0?c==="boolean"?"false":"":c==="json"?JSON.stringify(o.default):String(o.default);return{name:r,title:typeof o.title=="string"&&o.title.trim()?o.title:r,...typeof o.description=="string"&&o.description.trim()?{description:o.description}:{},required:s.has(r),type:c,...d?{options:d}:{},initial:u}})}function J6(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=Xc(i);d===void 0||o.type==="integer"&&!Number.isInteger(d)?s[c]=o.type==="integer"?"A whole number is needed.":Jc: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 X6=()=>({name:"",server:"",event:"",config:{},where:[],agentId:"",content:"",maxCost:""});function ky(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 hy([...o,...s])}function Z6(e,n,s=[],r){const{accept:o,...i}=e,{accept:c,issues:d}=ky(e.event,n,s,r);return{source:{...i,...c.length?{accept:c}:{}},issues:d}}function e8(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?J6(n,e.config,r):{},{accept:i,issues:c}=ky(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 sh(e,d,r,s,"a trigger")}const mE=e=>e.source.kind==="feed"&&e.target.kind==="start_run",Cx=20,hE=900,t8="item",pE=()=>({name:"",urls:"",every:"15",everyUnit:"minutes",items:"",id:"",where:[],others:[],agentId:"",content:"",maxCost:""});function n8(e){const n=e.source,s=n.every_s??hE,r=s%3600===0?"hours":s%60===0?"minutes":"seconds",o=(n.accept??[]).map(Zf),i=o[0]&&!o[0].actions.trim()?o[0]:null;return{...pE(),urls:n.urls.join(`
|
|
659
|
+
`),every:String(s/eh[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 s8=e=>{try{return new URL(e)}catch{return null}};function gE(e){const n=e.split(/\r\n|\r|\n/).map(r=>r.trim()).filter(Boolean),s={};return n.length?n.length>Cx?s["source.urls"]=`${Cx} feeds at most: this has ${n.length}.`:n.forEach((r,o)=>{const i=s8(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 xE(e,n){var f,g,b;const{urls:s,issues:r}=gE(e.urls),o=Xc(e.every),i=Math.round((o??0)*eh[e.everyUnit]);o===void 0?r["source.every_s"]=Jc:n&&i<n&&(r["source.every_s"]=wy(n));const c=x=>{var v;const h=e[x];return h||((v=e.read)==null?void 0:v[x])===""?{[x]:h}:{}},{accept:d,issues:u}=ky(t8,e.where,e.others,(g=(f=e.read)==null?void 0:f.accept)!=null&&g[0]&&!((b=e.read.accept[0].actions)!=null&&b.length)?e.read.accept[0]:void 0);return Object.assign(r,u),{source:{kind:"feed",urls:s,every_s:i,...c("items"),...c("id"),...d.length?{accept:d}:{}},issues:r}}function r8(e,n,s=!1){const{source:r,issues:o}=xE(e,n);return sh(e,r,o,s,"a feed trigger")}function o8(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",..._d(n)])}function a8(e,n=!1){const{source:s,issues:r}=fE(e);return sh(e,s,r,n,"a GitHub trigger")}function sh(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=Xc(e.maxCost);return e.maxCost.trim()?i===void 0&&(s["target.max_cost_usd"]=Jc):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 i8(e){const n=e.source,s="cron"in n?n.timezone:El(),r={...tE(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:Sx(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/eh[o]),everyUnit:o,startAt:Sx(n.start_at),read:{startAt:n.start_at}}}const Zc=(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=>Zc(e[o],n[o]))};function T0(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&&!Zc(s,e.source)?{source:s}:{},...r&&!Zc(r,e.target)?{target:r}:{}}}const l8=["name","enabled","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd"];function $l(e){var r;if(!(e instanceof Fe))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;(l8.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 c8=[{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"}],d8=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),u8=Array.from({length:31},(e,n)=>({value:String(n+1),label:String(n+1)})),f8=Array.from({length:60},(e,n)=>({value:String(n),label:`:${String(n).padStart(2,"0")}`}));function vE({value:e,onChange:n,label:s,name:r}){const o=x6(e),[i,c]=p.useState(()=>e.trim()!==""&&!o),d=p.useId(),u=i||e.trim()!==""&&!o,f=x=>n(v6(x)),g=x=>{if(x==="custom"){c(!0);return}c(!1),f(y6(x,o))},b=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(Ct,{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:c8}),!u&&(o==null?void 0:o.kind)==="weekly"&&t.jsx(Ct,{id:`${d}-day`,label:"Day of the week",className:"w-40",value:String(o.day),onChange:x=>f({...o,day:Number(x)}),options:d8}),!u&&(o==null?void 0:o.kind)==="monthly"&&t.jsx(Ct,{id:`${d}-date`,label:"Day of the month",className:"w-24",value:String(o.date),onChange:x=>f({...o,date:Number(x)}),options:u8}),!u&&(o==null?void 0:o.kind)==="hourly"&&t.jsx(Ct,{id:`${d}-minute`,label:"Minutes past the hour",className:"w-24",value:String(o.minute),onChange:x=>f({...o,minute:Number(x)}),options:f8}),!u&&o&&b&&t.jsx(Pe,{id:`${d}-at`,type:"time","aria-label":"At",className:"w-32",value:b6(b),onChange:x=>{const h=w6(x.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:x=>n(x.target.value),placeholder:"30 1 * * *",spellCheck:!1}),t.jsx("p",{className:"text-small text-muted-foreground","aria-live":"polite",children:e.trim()?nE(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const R0=Intl.supportedValuesOf,af=typeof R0=="function"?R0("timeZone"):[],lf=af.length&&!af.includes("UTC")?["UTC",...af]:af;function yE({value:e,onChange:n,label:s,name:r,id:o,className:i}){if(!lf.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&&!lf.includes(e)?[e,...lf]:lf;return t.jsx(Ct,{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 m8(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 h8(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 p8(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 g8(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?bE(s,(n==null?void 0:n.schemas)??{}):null}function bE(e,n={}){var u;const s=h8(e,n),r=s(e),o=Object.entries(r.properties??{}).map(([f,g])=>{const b=s(g);return{name:f,...b!=null&&b.description?{note:b.description}:{}}}),i=((u=r.examples)==null?void 0:u[0])??r.default;if(i!==void 0)return{text:JSON.stringify(i,null,2),from:"example",fields:o,optional:[]};const c=(f,g=0)=>{var h,v;const b=s(f);if(!b||g>4)return null;if((h=b.examples)!=null&&h.length)return b.examples[0];if(b.default!==void 0)return b.default;if((v=b.enum)!=null&&v.length)return b.enum[0];const x=Array.isArray(b.type)?b.type[0]:b.type;return x==="object"||b.properties?Object.fromEntries(Object.entries(b.properties??{}).filter(([y])=>(b.required??[]).includes(y)).map(([y,j])=>[y,c(j,g+1)])):x==="array"?[]:x==="string"?"":x==="number"||x==="integer"?0:x==="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 $g=e=>`'${e.replace(/'/g,"'\\''")}'`;function x8(e,n,s,r){return[`curl -X POST ${$g(`${e}/v2/agents/${n?encodeURIComponent(n):"{agent_id}"}/runs`)} \\`,' -H "Authorization: Bearer $AGENTRUN_API_KEY" \\'," -H 'Content-Type: application/json' \\",` -H ${$g(`Idempotency-Key: ${r}`)} \\`,` -d ${$g(JSON.stringify(s))}`].join(`
|
|
660
|
+
`)}const v8=e=>e>=200&&e<300;async function y8(e,n,s,r){const o=await r(n,s,e.keyFor(n,s));return v8(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)?Sy(n[r]).join(", "):"")||"…"),wE=e=>`#/templates/${encodeURIComponent(e)}`;function el(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 b8(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=x=>x!==null&&typeof x=="object"&&!Array.isArray(x);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=(x,h)=>x==="boolean"?typeof h=="boolean":x==="string"?typeof h=="string":(x==="number"||x==="integer")&&typeof h=="number"&&Number.isFinite(h);if(!c(d)||Object.keys(d).some(x=>!["parameters","grants","servers","overrides"].includes(x))||!c(d.parameters)||d.grants!==void 0&&(!Array.isArray(d.grants)||d.grants.some(x=>typeof x!="string"||!n.mcp.some(h=>h.tools.some(v=>v.tool===x))))||d.servers!==void 0&&(!c(d.servers)||Object.entries(d.servers).some(([x,h])=>!n.mcp.some(v=>v.toolkit===x)||typeof h!="string"||!/^[a-z][a-z0-9-]{0,31}$/.test(h)))||!c(d.overrides)||Object.keys(d.overrides).some(x=>x!=="approvals"&&x!=="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(x=>x.id).includes(d.overrides.choice))))return s;const f=rh(n.parameters);if(!f)return s;const g=new Map(f),b=[];for(const[x,h]of Object.entries(d.parameters)){const v=g.get(x);if(!v)return s;if(h==="")continue;if(v.array?!Array.isArray(h)||!h.every(k=>u(v.type,k)):!u(v.type,h))return s;const y=Array.isArray(h)?h.map(String).join(`
|
|
661
|
+
`):String(h),j=ah({fields:[[x,v]],contentRequired:!1},{[x]:y})[x];if(JSON.stringify(j)!==JSON.stringify(h))return s;b.push([x,h])}return{body:{...d,parameters:Object.fromEntries(b)}}}catch{return s}}const w8=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function Ny(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} (${wd[c.source]}${c.required?"":", optional"})`).join(", ")]),e.triggers.length&&r.push(["Triggers",w8(e.triggers.length,"trigger")]),(o=e.budget)!=null&&o.per_run_usd&&r.push(["Budget",`${to(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 Td(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 j8(e){return Object.fromEntries(Object.entries(e).flatMap(([n,s])=>s.array?[]:s.type==="boolean"?typeof s.default=="boolean"?[[n,String(s.default)]]:[]:Td(s)?[]:s.format==="timezone"?[[n,El()]]:s.format==="cron"?typeof s.default=="string"?[[n,s.default]]:[]:[]))}const k8=(e,n)=>n.filter(s=>s.source===e.source&&s.toolkit===e.toolkit).map(s=>s.name).sort();function N8(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=Jv.find(r=>r.name===e.toolkit);return`#/settings/mcp?add=${n}${s?`&preset=${s.id}`:""}`}const sm=e=>e.mcp.length===0&&e.secrets.length===0,S8=e=>{const n=e.source;return typeof n=="object"&&n!==null&&"kind"in n?n.kind:void 0},A0=[{id:"email",what:"the email account",needs:e=>(e.tools??[]).some(n=>n.startsWith("email_"))||e.triggers.some(n=>S8(n)==="email"),met:async e=>(await e.emailAccount()).configured,unmet:{before:"Connect your mailbox under ",link:"Settings → Email",href:"#/settings/email",after:" first."}}],C8=(e,n)=>e.mcp.flatMap(s=>s.tools.map(r=>r.tool)).filter(s=>n.has(s)),E8=(e,n)=>e.filter(s=>s.field===n);function rm(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 $8(e){const n=Td(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 _8(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: ${jE(s).join(", ")}.`;case"bad_format":return`${r} isn't in the form its description asks for.`;default:return e.message}}const jE=e=>{var n;return(n=e.enum)!=null&&n.length?e.enum.map(String):Td(e)??[]};function kE(e,n){var c;if(e.array){const d=Sy(n);return d.length?d.every(u=>kE({...e,array:!1,required:!0},u)):!e.required}if(n==="")return!e.required;const s=Td(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)||jE(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 Sy=e=>(e??"").split(`
|
|
662
|
+
`).map(n=>n.trim()).filter(n=>n!==""),NE=kE,La=e=>!!e&&typeof e=="object"&&!Array.isArray(e),T8=new Set(["string","number","integer","boolean"]),R8=["oneOf","anyOf","allOf","not","if","$ref","const"],Ex=e=>R8.some(n=>n in e),cf=e=>typeof e=="string"?e:void 0,df=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,A8=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0));function O8(e,n){if(!La(e)||Ex(e))return null;const s=e.type==="array",r=s?e.items:e;if(!La(r)||Ex(r)||typeof r.type!="string"||!T8.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 A8({type:r.type,...s?{array:!0}:{},required:n,title:cf(e.title),description:cf(e.description),examples:Array.isArray(e.examples)?e.examples:void 0,default:e.default,enum:o,pattern:cf(r.pattern),format:cf(r.format),minimum:df(r.minimum),maximum:df(r.maximum),minLength:df(r.minLength),maxLength:df(r.maxLength)})}function rh(e,n){const s=La(e)&&La(e.properties)?e.properties:{},r=La(e)&&Array.isArray(e.required)?e.required:[],o=[];for(const[i,c]of Object.entries(s)){if(i===n)continue;const d=O8(c,r.includes(i));if(!d)return null;o.push([i,d])}return o}function M8(e){if(!La(e))return{kind:"message"};const n=()=>({kind:"json",example:bE(e)});if(Ex(e))return n();const s=La(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=rh(e,"content");return o?o.length?{kind:"fields",form:{fields:o,contentRequired:r.includes("content")||!r.some(i=>i!=="content")}}:{kind:"message"}:n()}const oh=(e,n)=>n.title||e;function P8(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 L8(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=Sy(n);return r.length?r.map(s):e.required?[]:void 0}return e.type==="boolean"?n==="true"||n==="false"?n==="true":e.required?!1:void 0:n===void 0||n===""?e.required&&e.type==="string"?"":void 0:s(n)}function SE(e){const n=j8(Object.fromEntries(e.fields));for(const[s,r]of e.fields){const o=r.array?null:Td(r);o&&r.default!==void 0&&o.includes(String(r.default))&&(n[s]=String(r.default))}return n}function ah(e,n){const s={};for(const[r,o]of e.fields){const i=L8(o,n[r]);i!==void 0&&(s[r]=i)}return s}const I8=(e,n,s)=>({...n.trim()?{content:n}:{},...ah(e,s)}),$x=(e,n="input")=>e.startsWith(`${n}.`)?e.slice(n.length+1).split(".")[0]:null,CE=e=>e.type==="integer"?"a whole number":e.type==="number"?"a number":e.type==="boolean"?"true or false":"text",z8={string:"text",integer:"whole numbers",number:"numbers",boolean:"true or false"},D8=e=>e.array?`a list of ${z8[e.type]}`:CE(e);function EE(e,n,s){var o;const r=oh(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 ${CE(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(", ")}.`:_8(e,n,s,r)}const F8={date:"date",email:"email",uri:"url"};function $E({field:e,label:n,help:s,value:r,onChange:o}){const i=P8(e),c=$8(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(Ct,{label:n,className:"w-full",value:r,onChange:o,options:c}):e.array?t.jsx(tn,{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(vE,{label:n,value:r,onChange:o}):e.format==="timezone"&&e.type==="string"?t.jsx(yE,{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"?F8[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 Po({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 _E={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."},U8='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.',Pc=(e,n)=>e[n]?t.jsx("span",{"data-issue":n,children:e[n]}):void 0,ur=({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 ih({name:e,at:n,where:s,onChange:r,issues:o,label:i}){const c=(f,g)=>r(s.map((b,x)=>x===f?{...b,...g}:b)),d=(f,g)=>c(f,g==="prefix"?{op:g,value:s[f].value.split(/\r\n|\r|\n/).find(b=>b.trim())??""}:{op:g}),u=s.length>=$d.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(ur,{issues:o,field:`${n}.where`}),s.map((f,g)=>{const b=`${n}.where[${g}]`,x=`${e}-where-${g}`;return t.jsxs("div",{"data-condition":x,className:"space-y-3 border p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t.jsx(bt,{label:"Field",className:"min-w-40 flex-1",error:Pc(o,`${b}.pointer`),children:t.jsx(Pe,{name:`${x}-pointer`,value:f.pointer,onChange:h=>c(g,{pointer:h.target.value}),placeholder:"/title",autoComplete:"off",spellCheck:!1})}),t.jsx(dd,{name:`${x}-op`,label:`Condition ${g+1}'s test`,value:f.op,onChange:h=>d(g,h),options:S6.map(h=>({value:h,label:KC[h]}))}),t.jsx(B,{type:"button",size:"icon",variant:"ghost","aria-label":`Remove condition ${g+1}`,onClick:()=>r(s.filter((h,v)=>v!==g)),children:t.jsx(Xo,{"aria-hidden":!0})})]}),f.op==="in"&&t.jsx(bt,{label:"Values",hint:U8,error:Pc(o,`${b}.in`),children:t.jsx(tn,{name:`${x}-value`,rows:3,value:f.value,onChange:h=>c(g,{value:h.target.value}),spellCheck:!1})}),f.op==="prefix"&&t.jsx(bt,{label:"Text",hint:"Its first line, trimmed, starts with this, in any case.",error:Pc(o,`${b}.prefix`),children:t.jsx(Pe,{name:`${x}-value`,value:f.value,onChange:h=>c(g,{value:h.target.value}),autoComplete:"off",spellCheck:!1})}),t.jsx(ur,{issues:o,field:b}),t.jsx(ur,{issues:o,field:`${b}.exists`})]},f.key)}),t.jsxs(B,{type:"button",size:"sm",onClick:()=>r([...s,E6()]),disabled:u,children:[t.jsx(gl,{"aria-hidden":!0})," Add a condition"]})]})}function TE({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=(b,x)=>s(n.map((h,v)=>v===b?{...h,...x}:h));return t.jsxs("div",{className:"min-w-0 space-y-3",children:[!n.length&&f,n.map((b,x)=>{const h=`source.accept[${o(x)}]`,v=`${e}-${x}`;return t.jsxs("section",{"data-rule":v,"aria-label":`Rule ${x+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 ",x+1]}),t.jsxs(B,{type:"button",size:"xs",variant:"ghost","aria-label":`Remove rule ${x+1}`,onClick:()=>s(n.filter((y,j)=>j!==x)),children:[t.jsx(FN,{"aria-hidden":!0})," Remove"]})]}),t.jsx(ur,{issues:r,field:h}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(bt,{label:"Event",hint:c,error:Pc(r,`${h}.event`),children:t.jsx(Pe,{name:`${v}-event`,value:b.event,onChange:y=>g(x,{event:y.target.value}),placeholder:d,autoComplete:"off",spellCheck:!1})}),t.jsx(bt,{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:Pc(r,`${h}.actions`),children:t.jsx(Pe,{name:`${v}-actions`,value:b.actions,onChange:y=>g(x,{actions:y.target.value}),placeholder:"opened, edited",autoComplete:"off",spellCheck:!1})})]}),t.jsx(ih,{name:v,at:h,where:b.where,onChange:y=>g(x,{where:y}),issues:r,label:"Only when"})]},b.key)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>s([...n,VC()]),disabled:i<=0,children:[t.jsx(gl,{"aria-hidden":!0})," ",u]}),i<=0&&t.jsxs("span",{className:"text-small text-muted-foreground",children:[$d.rules," rules, the most a trigger takes."]})]})]})}const Dn=e=>`#/triggers/${encodeURIComponent(e)}`,ml=e=>ht(e),W8={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function H8({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(K8,{v2:e,go:s,agentName:r,every:d*2,now:u,failuresToPause:i,noAddress:f}):n.trigger===null?n.kind==="webhook"?t.jsx(tU,{v2:e,go:s}):n.kind==="github"?t.jsx(nU,{v2:e,go:s}):n.kind==="composio"?t.jsx(sU,{v2:e,go:s,noAddress:f}):n.kind==="feed"?t.jsx(UE,{v2:e,go:s,minEvery:o}):t.jsx(LE,{v2:e,go:s,minEvery:o,now:u}):n.edit?t.jsx(Z8,{v2:e,go:s,id:n.trigger,minEvery:o,now:u},n.trigger):t.jsx(X8,{v2:e,go:s,agentName:r,id:n.trigger,every:d,now:u,failuresToPause:i},n.trigger)}function RE(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 AE=e=>e?"ran"in e?`Done · ran ${ml(e.ran.nominal_at)}`:`Its time passed · ${ml(e.passed)}`:null,B8=/has already passed\.?$/;function OE({trigger:e}){return e.disabled?t.jsx(ke,{tone:"warning",children:"Turned off"}):t.jsx(ke,{tone:"muted",children:"Paused"})}const G8=e=>e.last_firing?`${cE(e.last_firing)}${e.last_firing.catch_up?" · caught up late":""} · ${ml(e.last_firing.nominal_at)}`:"Not fired yet",q8=e=>`${e.ok?"Checked":"Check failed"} ${ml(e.at)}: ${e.message}`,Cy="App triggers need this server's public address: set AGENTRUN_PUBLIC_URL and restart.";function K8({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),[b,x]=p.useState(0),h=p.useRef(!1),v=p.useRef(!0);p.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const y=()=>{h.current||(h.current=!0,e.listTriggers().then(j=>{v.current&&(u(j.triggers),g(null))},j=>{v.current&&g(Wt(j,"the triggers"))}).finally(()=>{h.current=!1}))};return p.useEffect(y,[e,b]),RE(y,r,[e]),t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[t.jsx("h1",{className:"mr-auto text-2xl font-semibold",children:"Triggers"}),!(d&&!d.length)&&t.jsxs(t.Fragment,{children:[t.jsxs(B,{size:"lg",disabled:c,onClick:()=>n("#/triggers/new-composio"),children:[t.jsx(um,{"aria-hidden":!0})," New app trigger"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-github"),children:[t.jsx(pm,{"aria-hidden":!0})," New GitHub trigger"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-webhook"),children:[t.jsx(rl,{"aria-hidden":!0})," New webhook"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-feed"),children:[t.jsx(Qx,{"aria-hidden":!0})," New feed trigger"]}),t.jsxs(B,{size:"lg",variant:"solid",onClick:()=>n("#/triggers/new"),children:[t.jsx(gl,{"aria-hidden":!0})," New schedule"]})]})]}),c&&d&&d.length>0&&t.jsx("p",{className:"-mt-2 mb-4 text-small text-muted-foreground",children:Cy}),f&&!d?t.jsx(Qt,{problem:f,onRetry:()=>x(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:Dn(j.id),className:"min-w-0 break-words text-prose font-semibold hover:underline",children:j.name}),t.jsx(ke,{children:Y8[j.source.kind]}),!j.enabled&&!xy(j,o())&&t.jsx(OE,{trigger:j})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:ME(j),children:Q8(j,s,o())}),nm(j,i)&&t.jsx("p",{className:"mt-1 break-words text-small text-warning-text",children:nm(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:G8(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:q8(j.last_check)})]})]},j.id))}):t.jsx(V8,{go:n,noAddress:c}):t.jsx(Un,{label:"Loading the triggers",rows:4}),d&&f&&t.jsx(Qt,{problem:f,className:"mt-4"})]})}function V8({go:e,noAddress:n}){const s=[{Icon:fm,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:rl,name:"Webhook",what:"On each signed request another system sends to its URL.",action:"New webhook",to:"#/triggers/new-webhook"},{Icon:pm,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:um,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:Qx,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",className:"border border-primary/50 bg-primary/5 p-5",children:[t.jsx("p",{className:"caps text-label text-primary-text",children:"No triggers yet"}),t.jsx("h2",{id:"first-trigger",className:"mt-2 text-xl font-semibold",children:"Start runs without being here"}),t.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A trigger starts a run of an agent for you, and each run it starts stops at a spend cap. Pick what should start it."}),t.jsx("ul",{className:"mt-5 grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-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-primary-text","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:Cy}),t.jsx(B,{size:"sm",variant:d==="#/triggers/new"?"solid":"outline",className:"mt-4 self-start",disabled:n&&d==="#/triggers/new-composio",onClick:()=>e(d),children:c})]},o))})]})}const Y8={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"},ME=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function Q8(e,n,s){return`${e.source.kind==="schedule"?gy(e.source,e.next_at,{instead:AE(xy(e,s)),now:s}):e.source.kind==="github"?lE(e.source):e.source.kind==="composio"?aE(e.source):e.source.kind==="email"?F6(e.source):e.source.kind==="feed"?iE(e.source):oE(e.source)} · ${e.target.kind==="start_run"?n(e.target.agent_id)||e.target.agent_id:`messages run ${na(e.target.run_id)}`}`}const J8={on:"On",off:"Off",missing:"Composio no longer has it: delete this trigger and make it again.",unknown:"Composio didn't say"};function PE(){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(Rn,{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 X8({v2:e,go:n,agentName:s,id:r,every:o,now:i,failuresToPause:c}){var Qe,he,Ie,et,pt;const[d,u]=p.useState(null),[f,g]=p.useState([]),[b,x]=p.useState(null),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),[$,_]=p.useState(null),M=p.useRef(!1),[O,L]=p.useState(!1),[A,R]=p.useState(null),[P,D]=p.useState(null),[W,K]=p.useState(null),[H,q]=p.useState(0),F=p.useRef(!1),G=p.useRef(!1),U=p.useRef(0),z=()=>{G.current=!0;const oe=U.current;return Promise.all([e.getTrigger(r),e.triggerFirings(r)]).then(([$e,st])=>{oe===U.current&&(u($e),g(st.firings),x(null))}).finally(()=>{G.current=!1})};p.useEffect(()=>{z().catch(oe=>x(Wt(oe,"the trigger")))},[e,r,H]),RE(()=>{!G.current&&!F.current&&W===null&&z().catch(()=>{})},o,[e,r]);const[Y,J]=p.useState(void 0),X=d&&d.target.kind==="start_run"&&typeof d.target.max_cost_usd!="number"?d.target.agent_id:null;p.useEffect(()=>{if(!X)return;let oe=!0;return e.getAgent(X).then($e=>{oe&&J(typeof $e.agent.definition.max_cost_usd=="number"?$e.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{oe=!1}},[e,X]);const le=(d==null?void 0:d.source.kind)==="composio"?d.source.server:null;if(p.useEffect(()=>{if(!le)return;let oe=!0;return e.composioTriggers(le).then($e=>{var st;oe&&R(((st=$e.triggers.find(Oe=>Oe.id===r))==null?void 0:st.on_composio)??"unknown")},()=>{oe&&R(null)}),()=>{oe=!1}},[e,le,r,d==null?void 0:d.enabled]),W!==null)return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Rn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsx("h1",{className:"mt-3 break-words text-2xl font-semibold leading-tight",children:(d==null?void 0:d.name)??r}),t.jsx("p",{className:"mt-2 text-body",children:"Deleted here. Its runs stay."}),t.jsx("p",{role:"status","data-composio-note":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:W}),t.jsx("a",{href:"#/triggers",className:"mt-4 inline-block text-body underline underline-offset-2",children:"All triggers"})]});if(!d)return b?t.jsx(Qt,{problem:b,onRetry:()=>q(oe=>oe+1),link:{href:"#/triggers",label:"All triggers"}}):t.jsx(Un,{label:"Loading the trigger",rows:4});const se=yy(d)?d:null,fe=rE(d)?d:null,xe=jy(d)?d:null,Ne=mE(d)?d:null;if(!se&&!fe&&!xe&&!Ne&&!vy(d))return t.jsx(PE,{});const ge=d,me=xy(d,i(),f),Le=async(oe,$e,st)=>{j(oe),v(null);try{await $e()}catch(Oe){v(Wt(Oe,st))}finally{j(null)}},Ue=()=>Le("pause",async()=>{U.current++,D(null);const{composio:oe,...$e}=await e.updateTrigger(r,{enabled:!d.enabled});U.current++,u($e),D((oe==null?void 0:oe.note)??null)},d.enabled?"the pause":"the resume"),De=()=>Le("delete",async()=>{const oe=await e.deleteTrigger(r);oe!=null&&oe.composio?K(oe.composio.note):n("#/triggers")},"the delete"),Ee=async()=>{if(!M.current){M.current=!0,L(!0),v(null),_(null);try{_((await e.rotateTriggerSecret(r)).signing_secret??null)}catch(oe){v(Wt(oe,"the new secret"))}finally{M.current=!1,L(!1)}}},re=async()=>{if(!F.current){F.current=!0,j("fire"),v(null),U.current++;try{const oe=await e.fireTrigger(r,Ed());U.current++,g($e=>[oe,...$e.filter(st=>st.key!==oe.key)]),await z().catch(()=>{})}catch(oe){v(Wt(oe,"the run now"))}finally{F.current=!1,j(null)}}},_e=typeof ge.target.input.content=="string"?ge.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(Rn,{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&&!me&&t.jsx(OE,{trigger:d})]}),t.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:se?`Webhook · ${oE(se.source)}`:fe?`GitHub · ${lE(fe.source)}`:xe?`App · ${aE(xe.source)}`:Ne?`Feed · ${iE(Ne.source)}`:t.jsx("span",{title:ME(d),children:gy(ge.source,d.next_at,{instead:AE(me),now:i()})})})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 self-stretch sm:self-auto",children:[!(me&&"ran"in me)&&t.jsx(B,{size:"sm",onClick:()=>void Ue(),disabled:y!==null,children:d.enabled?t.jsxs(t.Fragment,{children:[t.jsx(sl,{"aria-hidden":!0})," Pause"]}):t.jsxs(t.Fragment,{children:[t.jsx(Qo,{"aria-hidden":!0})," Resume"]})}),t.jsxs(B,{size:"sm",onClick:()=>n(`${Dn(r)}/edit`),children:[t.jsx(Vx,{"aria-hidden":!0})," ",se||fe||xe?"Edit filter":Ne?"Edit feed":"Edit"]}),se&&(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),Ee()},children:"Yes, make a new one"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>N(!1),children:"Keep"})]}):t.jsxs(B,{size:"sm",onClick:()=>N(!0),disabled:y!==null||O,children:[t.jsx(Ia,{"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:y!==null,children:[t.jsx(FN,{"aria-hidden":!0})," Delete"]}),t.jsxs(B,{size:"sm",variant:"solid",onClick:()=>void re(),disabled:y==="fire",children:[t.jsx(eR,{"aria-hidden":!0})," ",y==="fire"?"Starting":"Run now"]})]})]}),nm(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:[nm(d,c)," ",((Qe=d.disabled)==null?void 0:Qe.reason)==="source_unreadable"?Ne?"Edit its feeds, then Resume.":"Edit its when, then Resume.":((he=d.disabled)==null?void 0:he.reason)==="auto_paused"?me&&"passed"in me?"Its time has passed: edit its time first, then Resume.":me?"":"Resume turns it on again.":""]}),h&&t.jsx(Qt,{problem:h,className:"mt-4"}),P&&t.jsx("p",{role:"status","data-composio-note":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:P}),se&&$&&t.jsx(Ey,{label:"The webhook's new secret",secret:$}),Ne&&t.jsx(iU,{check:Ne.last_check??null,newest:f[0]}),t.jsxs("dl",{className:"mt-5 grid grid-cols-1 gap-x-6 gap-y-3 border p-4 text-body sm:grid-cols-[max-content_minmax(0,1fr)]",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Agent"}),t.jsx("dd",{className:"min-w-0 break-words",children:t.jsx("a",{href:cn(ge.target.agent_id),className:"hover:underline",children:s(ge.target.agent_id)||ge.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:_e??JSON.stringify(ge.target.input)}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),t.jsx("dd",{className:"font-mono",children:z6(ge.target.max_cost_usd,Y)}),se?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:Qc(se)}),t.jsx(IE,{text:Qc(se),label:"Copy URL"}),t.jsx("span",{className:"basis-full text-small text-muted-foreground",children:by})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("dd",{children:Nx[se.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:(Ie=se.source.accept)!=null&&Ie.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:se.source.accept.map((oe,$e)=>t.jsx("li",{children:Uo(oe)},$e))}):"Every signed request"})]}):xe?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:xe.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:xe.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(xe.source.config).length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:Object.entries(xe.source.config).map(([oe,$e])=>t.jsxs("li",{children:[oe,": ",typeof $e=="string"?$e:JSON.stringify($e)]},oe))}):"None"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(et=xe.source.accept)!=null&&et.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:xe.source.accept.map((oe,$e)=>t.jsx("li",{children:Uo(oe)},$e))}):"Every event of its instance"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"At Composio"}),t.jsx("dd",{className:"min-w-0 break-words",children:A?t.jsx("span",{"data-on-composio":A,className:A==="missing"?"text-warning-text":void 0,children:J8[A]}):t.jsx("span",{className:"text-muted-foreground",children:"Not read"})})]}):fe?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsxs("dd",{className:"min-w-0 break-words",children:[t.jsx("ul",{className:"space-y-1 font-mono text-small",children:fe.source.accept.map((oe,$e)=>t.jsx("li",{children:Uo(oe)},$e))}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):Ne?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:Ne.source.urls.map(oe=>t.jsx("li",{className:"break-all",children:dr(oe)?t.jsx("a",{href:dr(oe),target:"_blank",rel:"noreferrer",className:"hover:underline",children:oe}):oe},oe))})}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Read"}),t.jsxs("dd",{children:["Every ",py(Ne.source.every_s??hE)]}),(Ne.source.items!==void 0||Ne.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 ",Ne.source.items?Ne.source.items:"the whole document"," · Id at ",Ne.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:(pt=Ne.source.accept)!=null&&pt.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:Ne.source.accept.map((oe,$e)=>t.jsx("li",{children:Uo(oe)},$e))}):"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(oe=>t.jsxs("li",{"data-firing":oe.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(ke,{tone:W8[oe.status],children:W6[oe.status]}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:ml(oe.nominal_at)})]}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:oe.status==="started"?`${D6[oe.by]}${oe.catch_up?", caught up late":""}`:`${cE(oe)}${oe.catch_up?" · caught up late":""}${oe.by==="manual"?" · Run now":""}`}),oe.run_id&&t.jsxs("a",{href:`#/runs/${encodeURIComponent(oe.run_id)}`,className:"shrink-0 font-mono text-small underline-offset-2 hover:underline",children:["Run ",na(oe.run_id)]})]},oe.key))}):t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function Z8({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,b=>u(Wt(b,"the trigger")))},[e,s,f]),i?yy(i)||rE(i)||jy(i)?t.jsx(aU,{v2:e,go:n,trigger:i}):mE(i)?t.jsx(UE,{v2:e,go:n,trigger:i,minEvery:r}):vy(i)?t.jsx(LE,{v2:e,go:n,trigger:i,minEvery:r,now:o}):t.jsx(PE,{}):d?t.jsx(Qt,{problem:d,onRetry:()=>g(b=>b+1)}):t.jsx(Un,{label:"Loading the trigger",rows:4})}function Mt({label:e,field:n,issue:s,hint:r,children:o}){return t.jsx(bt,{className:"min-w-0",label:e,hint:r,error:s?t.jsx("span",{"data-issue":n,children:s}):void 0,children:o})}const Rd=e=>e!==void 0?`${ra(e)}, the agent's default`:void 0;async function Ad(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 LE({v2:e,go:n,trigger:s,minEvery:r,now:o=Date.now}){var D,W,K;const[i,c]=p.useState(()=>s?i8(s):tE()),[d,u]=p.useState(null),[f,g]=p.useState({}),[b,x]=p.useState([]),[h,v]=p.useState(!1),y=p.useRef(Ys()).current;p.useEffect(()=>{Ad(e).then(u,()=>u([]))},[e]);const j=H=>q=>c(F=>({...F,[H]:q})),k=H=>{var F;j("at")(H);const q=Hi(H,(F=i.read)==null?void 0:F.at);q!==null&&Date.parse(q)>o()?g(({"source.at":G,...U})=>U):q!==null&&g(G=>G["source.at"]?{...G,"source.at":E0(q,{now:o()})}:G)},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=(D=(d??[]).find(H=>H.agent_id===i.agentId))==null?void 0:D.definition.max_cost_usd,N=typeof S=="number"&&S>0?S:void 0,$=N!==void 0||!!s&&typeof s.target.max_cost_usd!="number"&&i.agentId===s.target.agent_id,_=async H=>{var G;H.preventDefault();const{body:q,issues:F}=_0(i,$);if(x([]),!q){g(F??{});return}g({}),v(!0);try{if(s){const U=T0(s,q);Object.keys(U).length&&await e.updateTrigger(s.id,U),n(Dn(s.id))}else{const U=await e.createTrigger(q,y.keyFor("createTrigger",q));n(Dn(U.id))}}catch(U){const z=$l(U),Y=i.kind==="at"?Hi(i.at,(G=i.read)==null?void 0:G.at):null,J=z.fields["source.at"];J&&Y!==null&&(Date.parse(Y)<=o()||B8.test(J))&&(z.fields["source.at"]=E0(Y,{now:o()})),g(Object.fromEntries(Object.entries(z.fields).filter(([X])=>E.has(X)))),x([...z.rest,...Object.entries(z.fields).filter(([X])=>!E.has(X)).map(([,X])=>X)]),v(!1)}},M=s?_0(i,$).body:void 0,O=!!(s&&M&&T0(s,M).source),L=i.kind==="at"?Hi(i.at,(W=i.read)==null?void 0:W.at):null,A=i.startAt?Hi(i.startAt,(K=i.read)==null?void 0:K.startAt):null,R=Nl((d??[]).filter(H=>!H.archived_at||H.agent_id===i.agentId)),P=[{kind:"cron",label:"Repeats"},{kind:"at",label:"Once"},{kind:"every",label:"Every"}];return t.jsxs("form",{onSubmit:H=>void _(H),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Dn(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(Rn,{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(fm,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit schedule":"New schedule"]}),b.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:b.map((H,q)=>t.jsx("p",{children:H},q))}),t.jsxs("div",{className:`mt-5 ${cd}`,children:[t.jsx(Mt,{label:"Name",field:"name",issue:f.name,children:t.jsx(Pe,{name:"name",value:i.name,onChange:H=>j("name")(H.target.value),placeholder:"nightly triage"})}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"When"}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:P.map(({kind:H,label:q})=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${i.kind===H?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"kind",value:H,checked:i.kind===H,onChange:()=>j("kind")(H),className:"accent-primary"}),q]},H))}),t.jsxs("div",{className:"mt-3 grid grid-cols-[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(vE,{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:L?`= ${$0(L)}`:void 0,children:t.jsx(Pe,{name:"at",type:"datetime-local",step:60,value:i.at,onChange:H=>k(H.target.value)})}),i.kind==="every"&&t.jsx(Mt,{label:"Every",field:"source.every_s",issue:f["source.every_s"],hint:r?wy(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Pe,{name:"every",inputMode:"decimal",value:i.every,onChange:H=>j("every")(H.target.value),placeholder:"5"}),t.jsx(Ct,{id:"schedule-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:i.everyUnit,onChange:H=>j("everyUnit")(H),options:["seconds","minutes","hours"].map(H=>({value:H,label:H}))})]})}),i.kind==="cron"&&t.jsx(Mt,{label:"Time zone",field:"source.timezone",issue:f["source.timezone"],hint:"The time zone this schedule runs in.",children:t.jsx(yE,{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:A?`= ${$0(A)}`:void 0,children:t.jsx(Pe,{name:"startAt",type:"datetime-local",step:60,value:i.startAt,onChange:H=>j("startAt")(H.target.value)})})]}),O&&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(Ct,{name:"agent",label:"Agent",className:"w-full",value:i.agentId,onChange:H=>j("agentId")(H),options:[{value:"",label:d?"Pick an agent":"Loading the agents"},...R.map(H=>({value:H.agent_id,label:`${H.definition.name||H.agent_id}${H.kind==="workflow"?" (workflow)":""}`})),...i.agentId&&d&&!R.some(H=>H.agent_id===i.agentId)?[{value:i.agentId,label:i.agentId}]:[]]})}),t.jsx(Mt,{label:"Each run is asked",field:"target.input",issue:f["target.input"],children:t.jsx(tn,{name:"content",rows:4,className:"p-3 font-sans",value:i.content,onChange:H=>j("content")(H.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 (${ra(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:H=>j("maxCost")(H.target.value),placeholder:Rd(N)})}),!s&&t.jsxs("div",{children:[t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"enabled",checked:i.enabled,onChange:H=>j("enabled")(H.target.checked),className:"accent-primary"})," On from now (off: made paused)"]}),f.enabled&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"enabled",children:f.enabled})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:h,children:h?"Saving":s?"Save changes":"Create schedule"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(s?Dn(s.id):"#/triggers"),children:"Cancel"})]})]})}function IE({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(Va,{"aria-hidden":!0})," ",n]}),s&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:s})]})}function Ey({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(_x,{title:"URL",text:s,label:"Copy URL",hint:by}),t.jsx(_x,{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 _x({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(IE,{text:n,label:s})]}),r&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:r})]})}const eU=["standard","github"];function tU({v2:e,go:n}){var $;const[s,r]=p.useState(G6),[o,i]=p.useState(null),[c,d]=p.useState({}),[u,f]=p.useState([]),[g,b]=p.useState(!1),[x,h]=p.useState(null),v=p.useRef(Ys()).current;p.useEffect(()=>{Ad(e).then(i,()=>i([]))},[e]);const y=_=>M=>r(O=>({...O,[_]:M})),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 M=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd",..._d(s.accept.map(A=>A.where.length))]),{body:O,issues:L}=q6(s,k!==void 0);if(f([]),!O){d(L??{});return}d({}),b(!0);try{h(await e.createTrigger(O,v.keyFor("createTrigger",O)))}catch(A){const R=$l(A);d(Object.fromEntries(Object.entries(R.fields).filter(([P])=>M.has(P)))),f([...R.rest,...Object.entries(R.fields).filter(([P])=>!M.has(P)).map(([,P])=>P)])}finally{b(!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(Rn,{className:"size-3.5","aria-hidden":!0})," Triggers"]});if(x)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(rl,{className:"size-5 text-primary-text","aria-hidden":!0}),x.name]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:`Send each request to this URL, signed with this secret (${Nx[x.source.kind==="webhook"?x.source.signature??"standard":"standard"]}). Each one starts a run.`}),x.signing_secret?t.jsx(Ey,{label:"The webhook's URL and secret",url:Qc(x),secret:x.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(_x,{title:"URL",text:Qc(x),label:"Copy URL",hint:by}),x.note&&t.jsx("p",{role:"note",children:x.note})]}),t.jsx("div",{className:"mt-6",children:t.jsx(B,{type:"button",size:"lg",variant:"solid",onClick:()=>n(Dn(x.id)),children:"Done"})})]});const N=Nl((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(rl,{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((_,M)=>t.jsx("p",{children:_},M))}),t.jsxs("div",{className:`mt-5 ${cd}`,children:[t.jsx(Mt,{label:"Name",field:"name",issue:c.name,children:t.jsx(Pe,{name:"name",value:s.name,onChange:_=>y("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:eU.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:()=>y("signature")(_),className:"accent-primary"}),Nx[_]]},_))}),c["source.signature"]&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.signature",children:c["source.signature"]})]}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Events from an app Composio connects start runs through an app trigger instead: ",t.jsx("a",{href:"#/triggers/new-composio",className:"underline underline-offset-2",children:"New app trigger"})]}),t.jsx(zE,{signature:s.signature,rules:s.accept,onChange:y("accept"),issues:c,cap:null}),t.jsx(Mt,{label:"Agent",field:"target.agent_id",issue:c["target.agent_id"],children:t.jsx(Ct,{name:"agent",label:"Agent",className:"w-full",value:s.agentId,onChange:_=>y("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(tn,{name:"content",rows:4,className:"p-3 font-sans",value:s.content,onChange:_=>y("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 (${ra(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:_=>y("maxCost")(_.target.value),placeholder:Rd(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 nU({v2:e,go:n}){var R;const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(0),[u,f]=p.useState(K6),[g,b]=p.useState(null),[x,h]=p.useState({}),[v,y]=p.useState([]),[j,k]=p.useState(!1),E=p.useRef(Ys()).current,S=p.useRef(!0);p.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]),p.useEffect(()=>{let P=!0;return i(null),e.githubConnection().then(D=>{P&&r(!!D&&"app_id"in D&&!!D.app_id)},D=>{P&&(D instanceof Fe&&D.status===404?r(!1):i(Wt(D,"GitHub's connection")))}),()=>{P=!1}},[e,c]),p.useEffect(()=>{Ad(e).then(b,()=>b([]))},[e]);const N=P=>D=>f(W=>({...W,[P]:D})),$=(R=(g??[]).find(P=>P.agent_id===u.agentId))==null?void 0:R.definition.max_cost_usd,_=typeof $=="number"&&$>0?$:void 0,M=async P=>{P.preventDefault();const D=new Set(["name","target.agent_id","target.input","target.max_cost_usd",..._d(nh(u).map(H=>H.where.length))]),{body:W,issues:K}=a8(u,_!==void 0);if(y([]),!W){h(K??{});return}h({}),k(!0);try{const H=await e.createTrigger(W,E.keyFor("createTrigger",W));S.current&&n(Dn(H.id))}catch(H){const q=$l(H);h(Object.fromEntries(Object.entries(q.fields).filter(([F])=>D.has(F)))),y([...q.rest,...Object.entries(q.fields).filter(([F])=>!D.has(F)).map(([,F])=>F)]),k(!1)}},O=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(Rn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),L=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(pm,{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:[O,L,t.jsx(Qt,{problem:o,onRetry:()=>d(P=>P+1),className:"mt-4"})]});if(s===null)return t.jsx(Un,{label:"Reading GitHub's connection",rows:3});if(!s)return t.jsxs("div",{className:"p-5 md:p-8",children:[O,L,t.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Connect GitHub first: ",t.jsx("a",{href:"#/settings/github",className:"underline underline-offset-2",children:"Settings → GitHub"}),". A GitHub trigger takes events from this server's GitHub App."]})]});const A=Nl((g??[]).filter(P=>!P.archived_at));return t.jsxs("form",{onSubmit:P=>void M(P),className:"p-5 md:p-8",noValidate:!0,children:[O,L,t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event it takes from this server's GitHub App starts a capped run of the agent."}),v.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:v.map((P,D)=>t.jsx("p",{children:P},D))}),t.jsxs("div",{className:`mt-5 ${cd}`,children:[t.jsx(Mt,{label:"Name",field:"name",issue:x.name,children:t.jsx(Pe,{name:"name",value:u.name,onChange:P=>N("name")(P.target.value),placeholder:"review PRs"})}),t.jsx(DE,{picks:u,onChange:P=>f(D=>({...D,...P})),issues:x}),t.jsx(Mt,{label:"Agent",field:"target.agent_id",issue:x["target.agent_id"],children:t.jsx(Ct,{name:"agent",label:"Agent",className:"w-full",value:u.agentId,onChange:P=>N("agentId")(P),options:[{value:"",label:g?"Pick an agent":"Loading the agents"},...A.map(P=>({value:P.agent_id,label:`${P.definition.name||P.agent_id}${P.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Mt,{label:"Each run is asked",field:"target.input",issue:x["target.input"],hint:"The event's payload comes with it.",children:t.jsx(tn,{name:"content",rows:4,className:"p-3 font-sans",value:u.content,onChange:P=>N("content")(P.target.value)})}),t.jsx(Mt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:x["target.max_cost_usd"],hint:_!==void 0?`Uses the agent's default (${ra(_)}) 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:P=>N("maxCost")(P.target.value),placeholder:Rd(_)})})]}),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 sU({v2:e,go:n,noAddress:s}){var ge;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(0),[f,g]=p.useState(null),[b,x]=p.useState(null),[h,v]=p.useState(0),[y,j]=p.useState(X6),[k,E]=p.useState(null),[S,N]=p.useState({}),[$,_]=p.useState([]),[M,O]=p.useState(null),[L,A]=p.useState(null),[R,P]=p.useState(!1),D=p.useRef(Ys()).current,W=p.useRef(!0);p.useEffect(()=>(W.current=!0,()=>{W.current=!1}),[]),p.useEffect(()=>{let me=!0;return c(null),e.listMcpServers().then(Le=>{if(!me)return;const Ue=Le.servers.filter(De=>De.source==="composio");o(Ue),Ue.length===1&&j(De=>De.server?De:{...De,server:Ue[0].name})},Le=>{me&&c(Wt(Le,"the saved MCP servers"))}),()=>{me=!1}},[e,d]),p.useEffect(()=>{if(!y.server)return;let me=!0;const Le=y.server;return g(null),x(null),e.composioEvents(Le).then(Ue=>{me&&g({server:Le,events:Ue.events})},Ue=>{me&&x(Wt(Ue,`${Le}'s events`))}),()=>{me=!1}},[e,y.server,h]),p.useEffect(()=>{Ad(e).then(E,()=>E([]))},[e]);const K=me=>{A(null),j(me)},H=me=>Le=>K(Ue=>({...Ue,[me]:Le})),q=me=>K(Le=>Le.server===me?Le:{...Le,server:me,event:"",config:{},where:[]}),F=me=>{K(Le=>Le.event===me?Le:{...Le,event:me,config:{},where:[]}),N({})},G=(f==null?void 0:f.server)===y.server?f.events.find(me=>me.slug===y.event):void 0,U=Q6(G==null?void 0:G.config),z=(ge=(k??[]).find(me=>me.agent_id===y.agentId))==null?void 0:ge.definition.max_cost_usd,Y=typeof z=="number"&&z>0?z:void 0,J=async me=>{var Ue,De;const Le=new Set(["name","source.server","source.event","source.config",...U.map(Ee=>`source.config.${Ee.name}`),"target.agent_id","target.input","target.max_cost_usd",...y.where.length?_d([y.where.length]):[]]);N({}),_([]),O(null),A(null),P(!0);try{const Ee=await e.createTrigger(me,D.keyFor("createTrigger",me));W.current&&n(Dn(Ee.id));return}catch(Ee){if(Ee instanceof Fe&&Ee.code==="composio_subscription_elsewhere")A({url:typeof((Ue=Ee.details)==null?void 0:Ue.webhook_url)=="string"?Ee.details.webhook_url:"another address",body:me});else if(Ee instanceof Fe&&Ee.code.startsWith("composio_"))_([Ee.message]),Ee.code==="composio_not_connected"&&O(dr(typeof((De=Ee.details)==null?void 0:De.connect_url)=="string"?Ee.details.connect_url:null)??null);else{const re=$l(Ee);N(Object.fromEntries(Object.entries(re.fields).filter(([_e])=>Le.has(_e)))),_([...re.rest,...Object.entries(re.fields).filter(([_e])=>!Le.has(_e)).map(([,_e])=>_e)])}}P(!1)},X=()=>e8(y,U,Y!==void 0),le=me=>{me.preventDefault();const{body:Le,issues:Ue}=X();if(_([]),O(null),!Le){N(Ue??{});return}J(Le)},se=()=>{const me=L;A(null),me&&J({...me.body,source:{...me.body.source,move_subscription:!0}})},fe=t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Rn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),xe=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(um,{className:"size-5 text-primary-text","aria-hidden":!0}),"New app trigger"]});if(i)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[fe,xe,t.jsx(Qt,{problem:i,onRetry:()=>u(me=>me+1),className:"mt-4"})]});if(r===null)return t.jsx(Un,{label:"Reading the saved Composio servers",rows:3});if(!r.length)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[fe,xe,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 Ne=Nl((k??[]).filter(me=>!me.archived_at));return t.jsxs("form",{onSubmit:le,className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[fe,xe,t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event Composio delivers for it starts a capped run of the agent. This server makes the trigger on Composio for the account the server is connected as."}),s&&t.jsx("p",{className:"mt-4 border border-warning/50 p-3 text-body",role:"status",children:Cy}),$.length>0&&t.jsxs("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:[$.map((me,Le)=>t.jsx("p",{className:"break-words",children:me},Le)),M&&t.jsx("a",{href:M,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:y.name,onChange:me=>H("name")(me.target.value),placeholder:"new issues"})}),t.jsx(Mt,{label:"Composio server",field:"source.server",issue:S["source.server"],children:t.jsx(Ct,{name:"server",label:"Composio server",className:"w-full",value:y.server,onChange:q,options:[{value:"",label:"Pick a server"},...r.map(me=>({value:me.name,label:me.toolkit?`${me.name} (${me.toolkit})`:me.name}))]})}),y.server&&(b?t.jsx(Qt,{problem:b,onRetry:()=>v(me=>me+1),className:""}):t.jsx(Mt,{label:"Event",field:"source.event",issue:S["source.event"],hint:G==null?void 0:G.description,children:t.jsx(Ct,{name:"event",label:"Event",className:"w-full",value:y.event,onChange:F,disabled:!f,options:[{value:"",label:f?f.events.length?"Pick an event":"Composio offers no event for this toolkit":"Loading the events"},...((f==null?void 0:f.events)??[]).map(me=>({value:me.slug,label:me.name||me.slug}))]})})),G&&t.jsxs(t.Fragment,{children:[G.polled&&t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:"Composio checks for it every few minutes, so a run starts some minutes after the event."}),G.instructions&&t.jsx("p",{className:"whitespace-pre-wrap text-small text-muted-foreground",children:G.instructions}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Config"}),t.jsxs("p",{className:"mb-2 mt-1 text-small text-muted-foreground",children:["What Composio watches for ",t.jsx("span",{className:"font-mono",children:G.slug}),"."]}),t.jsx(ur,{issues:S,field:"source.config"}),U.length?t.jsx("div",{className:"space-y-4",children:U.map(me=>t.jsx(rU,{field:me,value:y.config[me.name]??me.initial,issue:S[`source.config.${me.name}`],onChange:Le=>K(Ue=>({...Ue,config:{...Ue.config,[me.name]:Le}}))},`${G.slug}:${me.name}`))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"This event takes no config."})]}),t.jsx(FE,{where:y.where,onChange:H("where"),issues:S})]}),t.jsx(Mt,{label:"Agent",field:"target.agent_id",issue:S["target.agent_id"],children:t.jsx(Ct,{name:"agent",label:"Agent",className:"w-full",value:y.agentId,onChange:me=>H("agentId")(me),options:[{value:"",label:k?"Pick an agent":"Loading the agents"},...Ne.map(me=>({value:me.agent_id,label:`${me.definition.name||me.agent_id}${me.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(tn,{name:"content",rows:4,className:"p-3 font-sans",value:y.content,onChange:me=>H("content")(me.target.value)})}),t.jsx(Mt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:S["target.max_cost_usd"],hint:Y!==void 0?`Uses the agent's default (${ra(Y)}) 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:y.maxCost,onChange:me=>H("maxCost")(me.target.value),placeholder:Rd(Y)})})]}),L&&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:L.url})," now. Moving them here stops them arriving there: anything listening at ",t.jsx("code",{className:"break-all font-mono text-small",children:L.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:se,children:"Move it here"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>A(null),children:"Keep it there"})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:R||!!L||s,children:R?"Creating":"Create app trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function rU({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(bt,{className:"min-w-0",label:e.title,required:e.required,optional:!e.required,hint:e.description,error:i,children:e.options?t.jsx(Ct,{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(tn,{name:o,rows:3,className:"p-3 font-mono",value:n,onChange:c=>r(c.target.value),spellCheck:!1}):t.jsx(Pe,{name:o,inputMode:e.type==="string"?void 0:"decimal",value:n,onChange:c=>r(c.target.value),autoComplete:"off",spellCheck:!1})})})}function oU(e,n){const s=n!==null?`, up to ${n} at once; past that, a request waits for one of them to end`:"";return e?`With a filter, each request it takes starts its own run${n!==null?s:", even while an earlier run is still going"}. Any other request is answered and starts nothing.`:n!==null?`Every signed request starts a run${s}.`:"Every signed request starts a run. One that comes while its last run is still going is skipped."}function zE({signature:e,rules:n,onChange:s,issues:r,cap:o}){return t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(ur,{issues:r,field:"source.accept"}),t.jsx(TE,{name:"accept",rules:n,onChange:s,issues:r,room:$d.rules-n.length,eventHint:_E[e],eventPlaceholder:e==="github"?"issues":"issue.opened"}),t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:oU(n.length>0,o)})]})]})}function DE({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=nh(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:uE.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:[th.filter(u=>u.event===i).map(({event:u,action:f,label:g})=>{const b=`${u}:${f}`;return t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"event",value:b,checked:e.events.includes(b),onChange:()=>r(b),className:"accent-primary"}),g," ",t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[u," ",f]})]},b)}),c>=0&&t.jsxs("div",{className:"ml-6 space-y-1 pt-1",children:[[d,`${d}.event`,`${d}.actions`].map(u=>t.jsx(ur,{issues:s,field:u},u)),t.jsx(ih,{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(TE,{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:$d.rules-o.length,eventHint:_E.github,eventPlaceholder:"issues",addLabel:"Add another event"})]})]})}function aU({v2:e,go:n,trigger:s}){const r=yy(s)?s:null,o=jy(s)?s:null,[i,c]=p.useState(()=>r?(r.source.accept??[]).map(Zf):o?(o.source.accept??[]).map(Zf):[]),[d,u]=p.useState(()=>r||o?{events:[],where:{},other:[]}:Y6(s.source.accept)),f=o&&i[0]&&!i[0].actions.trim()?i[0]:null,g=o?i.slice(f?1:0):[],[b,x]=p.useState({}),[h,v]=p.useState([]),[y,j]=p.useState(!1),k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const E=async $=>{$.preventDefault();const{source:_,issues:M}=r?dE(r.source,i):o?Z6(o.source,(f==null?void 0:f.where)??[],g,f==null?void 0:f.was):fE(d);if(v([]),Object.keys(M).length){x(M);return}x({}),j(!0);try{Zc(_,s.source)||await e.updateTrigger(s.id,{source:_}),k.current&&n(Dn(s.id))}catch(O){if(!k.current)return;const L=$l(O),A=_d(r||o?i.map(R=>R.where.length):nh(d).map(R=>R.where.length));x(Object.fromEntries(Object.entries(L.fields).filter(([R])=>A.has(R)))),v([...L.rest,...Object.entries(L.fields).filter(([R])=>!A.has(R)).map(([,R])=>R)]),j(!1)}},S=r?rl:o?um:pm,N=$=>c(f?$.length?[{...f,where:$},...g]:g:$.length?[{...VC(),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:Dn(s.id),className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Rn,{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(zE,{signature:r.source.signature??"standard",rules:i,onChange:c,issues:b,cap:s.max_active_runs??null}):o?t.jsx(FE,{where:(f==null?void 0:f.where)??[],onChange:N,issues:b,others:g.map($=>$.event+($.actions.trim()?` (${$.actions.trim()})`:""))}):t.jsx(DE,{picks:d,onChange:u,issues:b})}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:y,children:y?"Saving":"Save filter"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(Dn(s.id)),children:"Cancel"})]})]})}function FE({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(ur,{issues:s,field:"source.accept"}),t.jsx(ur,{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(ih,{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 iU({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"} · ${ml(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 UE({v2:e,go:n,trigger:s,minEvery:r}){var L;const[o,i]=p.useState(()=>s?n8(s):pE()),[c,d]=p.useState(null),[u,f]=p.useState({}),[g,b]=p.useState([]),[x,h]=p.useState(!1),[v,y]=p.useState(()=>!!s&&(s.source.items!==void 0||s.source.id!==void 0));p.useEffect(()=>{(u["source.items"]||u["source.id"])&&y(!0)},[u]);const j=p.useRef(Ys()).current,k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]),p.useEffect(()=>{s||Ad(e).then(d,()=>d([]))},[e,s]);const E=A=>R=>i(P=>({...P,[A]:R})),S=(L=(c??[]).find(A=>A.agent_id===o.agentId))==null?void 0:L.definition.max_cost_usd,N=typeof S=="number"&&S>0?S:void 0,$=async A=>{A.preventDefault();const R=o8(gE(o.urls).urls.length,[o.where.length,...o.others.map(K=>K.where.length)]);b([]);const P=K=>{if(!k.current)return;const H=$l(K);f(Object.fromEntries(Object.entries(H.fields).filter(([q])=>R.has(q)))),b([...H.rest,...Object.entries(H.fields).filter(([q])=>!R.has(q)).map(([,q])=>q)]),h(!1)};if(s){const{source:K,issues:H}=xE(o,r);if(Object.keys(H).length){f(H);return}f({}),h(!0);try{Zc(K,s.source)||await e.updateTrigger(s.id,{source:K}),k.current&&n(Dn(s.id))}catch(q){P(q)}return}const{body:D,issues:W}=r8(o,r,N!==void 0);if(!D){f(W??{});return}f({}),h(!0);try{const K=await e.createTrigger(D,j.keyFor("createTrigger",D));k.current&&n(Dn(K.id))}catch(K){P(K)}},_=Object.entries(u).filter(([A])=>/^source\.urls(\[\d+\])?$/.test(A)),M=Nl((c??[]).filter(A=>!A.archived_at)),O=o.others.map(A=>A.event+(A.actions.trim()?` (${A.actions.trim()})`:""));return t.jsxs("form",{onSubmit:A=>void $(A),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Dn(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(Rn,{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(Qx,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit feed":"New feed trigger"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:s?"The feeds it reads, how often, and which items start a run. Its name, its agent and what each run is asked stay as they are.":"Each new or updated item in its feeds starts a capped run of the agent. The items already there when it is made start none: its first check, on its page once it is made, says how many."}),g.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:g.map((A,R)=>t.jsx("p",{children:A},R))}),t.jsxs("div",{className:`mt-5 ${cd}`,children:[!s&&t.jsx(Mt,{label:"Name",field:"name",issue:u.name,children:t.jsx(Pe,{name:"name",value:o.name,onChange:A=>E("name")(A.target.value),placeholder:"vendor outages"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(bt,{className:"min-w-0",label:"Feed URLs",hint:`One a line, 1 to ${Cx}: RSS, Atom, JSON Feed, or an API's JSON list. Plain http is read on a public address alone.`,error:_.length?t.jsx(t.Fragment,{children:_.map(([A,R])=>t.jsx("span",{"data-issue":A,className:"block",children:R},A))}):void 0,children:t.jsx(tn,{name:"urls",rows:4,className:"p-3 font-mono text-small",value:o.urls,onChange:A=>E("urls")(A.target.value),placeholder:"https://www.githubstatus.com/history.atom",spellCheck:!1})}),s&&t.jsx("p",{className:"mt-2 text-small text-warning-text",role:"note",children:"A feed you add starts from now: what's in it already won't start runs."})]}),t.jsx(Mt,{label:"Every",field:"source.every_s",issue:u["source.every_s"],hint:r?wy(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Pe,{name:"every",inputMode:"decimal",value:o.every,onChange:A=>E("every")(A.target.value),placeholder:"15"}),t.jsx(Ct,{id:"feed-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:o.everyUnit,onChange:A=>E("everyUnit")(A),options:["seconds","minutes","hours"].map(A=>({value:A,label:A}))})]})}),t.jsxs("details",{"data-json-list":!0,open:v,onToggle:A=>y(A.currentTarget.open),className:"min-w-0 border p-3",children:[t.jsxs("summary",{className:"cursor-pointer text-body font-semibold",children:["JSON list ",t.jsx("span",{className:"font-normal text-small text-muted-foreground",children:"(optional: a feed that is an API's JSON, such as GitHub's pull requests)"})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(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:A=>E("items")(A.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:A=>E("id")(A.target.value),placeholder:"/id",autoComplete:"off",spellCheck:!1})})]})]}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(ur,{issues:u,field:"source.accept"}),t.jsx(ur,{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(ih,{name:"feed",at:"source.accept[0]",where:o.where,onChange:E("where"),issues:u,label:"Only when"}),O.length>0&&t.jsxs("p",{className:"text-small text-muted-foreground",role:"note",children:[O.length===1?"One more rule, made through the API, is kept as it is":`${O.length} more rules, made through the API, are kept as they are`,": ",O.join(", "),"."]})]})]}),!s&&t.jsxs(t.Fragment,{children:[t.jsx(Mt,{label:"Agent",field:"target.agent_id",issue:u["target.agent_id"],children:t.jsx(Ct,{name:"agent",label:"Agent",className:"w-full",value:o.agentId,onChange:A=>E("agentId")(A),options:[{value:"",label:c?"Pick an agent":"Loading the agents"},...M.map(A=>({value:A.agent_id,label:`${A.definition.name||A.agent_id}${A.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(tn,{name:"content",rows:4,className:"p-3 font-sans",value:o.content,onChange:A=>E("content")(A.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 (${ra(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:A=>E("maxCost")(A.target.value),placeholder:Rd(N)})})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:x,children:x?s?"Saving":"Creating":s?"Save feed":"Create feed trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(s?Dn(s.id):"#/triggers"),children:"Cancel"})]})]})}const WE=e=>e?"#/playground?operation=apply-template":"#/templates";function O0({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,b]=p.useState(0);if(p.useEffect(()=>{if(s!==void 0)return;let h=!0;return f(null),e.listTemplates().then(v=>{h&&d(v.templates)},v=>{h&&f(Wt(v,"the templates"))}),()=>{h=!1}},[e,g,s]),s!==void 0)return t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(cU,{v2:e,source:s,go:r})});const x=n===void 0||c==null?void 0:c.find(h=>h.id===n);return t.jsx("div",{className:"p-5 md:p-8",children:u&&!c?t.jsx(Qt,{problem:u,onRetry:()=>b(h=>h+1),className:""}):c?n===void 0?t.jsx(lU,{v2:e,templates:c,go:r,playground:o,onRemoved:()=>b(h=>h+1)}):x?t.jsx(mU,{v2:e,template:x,go:r,playground:o,draft:i},`${x.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:WE(o),className:"underline",children:"See its templates"}),"."]}):t.jsx(Un,{label:"Loading the templates",rows:3})})}function $y({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 lU({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),[b,x]=p.useState(null),h=async v=>{g(v.id),x(null);try{await e.deleteTemplate(v.id),o()}catch(y){x(y instanceof Error?y.message:String(y))}finally{g(null)}};return t.jsxs(t.Fragment,{children:[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:v=>{v.preventDefault(),d.trim()&&s(dU(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:v=>u(v.target.value)})]}),t.jsx(B,{size:"sm",variant:"solid",type:"submit",disabled:!d.trim(),children:"Read it"})]}),b&&t.jsx("p",{className:"mb-3 text-body text-destructive-text",role:"alert",children:b}),n.length?t.jsx("ul",{className:"grid gap-3 md:grid-cols-2",children:n.map(v=>t.jsx("li",{children:t.jsxs("article",{"aria-label":Wo(v),className:"flex h-full flex-col border bg-card px-5 py-4",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx(qx,{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(v)}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:v.version}),v.category&&t.jsx(ke,{tone:"muted",children:v.category}),!v.bundled&&t.jsx(ke,{tone:"muted",children:"Imported"})]}),t.jsx($y,{t:v}),t.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:v.description}),v.tags.length>0&&t.jsx("p",{"aria-label":"Tags",className:"mt-1.5 break-words font-mono text-small text-muted-foreground",children:v.tags.join(" · ")}),t.jsx("dl",{className:"mt-3 space-y-1 font-mono text-small text-muted-foreground",children:Ny(v).map(([y,j])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0",children:y}),t.jsx("dd",{className:"min-w-0 break-words text-foreground/80",children:j})]},y))}),t.jsxs("div",{className:"mt-auto flex flex-wrap items-center justify-end gap-2 pt-4",children:[!v.bundled&&t.jsx(B,{size:"sm",onClick:()=>void h(v),disabled:f===v.id,children:f===v.id?"Removing…":"Remove"}),r?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>s(el(v)),children:"Configure"}):t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:sm(v)?"primary":"outline",onClick:()=>s(wE(v.id)),children:"Configure"}),t.jsx(nn,{variant:sm(v)?"outline":"primary",label:"Run",prompt:ox(location.origin,v),playgroundHref:el(v)})]})]})]})},v.id))}):t.jsx("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",children:"This server offers no templates yet."})]})}function cU({v2:e,source:n,go:s}){var E;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[b,x]=p.useState(null);p.useEffect(()=>{let S=!0;if(!n){c("Give a package's source: github:owner/repo/path@ref.");return}return e.importTemplate(n,{dryRun:!0}).then(N=>{S&&o(N)},N=>{S&&c(M0(N))}),()=>{S=!1}},[e,n]);const h=async()=>{g(!0),x(null);try{if(!r)return;const S=await e.importTemplate(`${r.template.id}@${r.template.sha}`,{trustPublisher:d});s(wE(S.template.id))}catch(S){x(M0(S))}finally{g(!1)}},v=t.jsxs("a",{href:"#/templates",className:"caps mb-4 inline-flex items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[t.jsx(Rn,{className:"size-3.5","aria-hidden":!0})," Templates"]});if(i)return t.jsxs("div",{className:"max-w-3xl",children:[v,t.jsx("p",{className:"border px-4 py-6 font-mono text-body text-destructive-text",role:"alert",children:i})]});if(!r)return t.jsx(Un,{label:"Reading the package from GitHub",rows:3});const y=r.template,j=y.publisher??"",k=Object.entries(r.skill_files);return t.jsxs("section",{"aria-label":"Install from GitHub",className:"max-w-3xl",children:[v,t.jsxs("h1",{className:"font-mono text-2xl font-semibold",children:[Wo(y)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:y.version})]}),t.jsxs("dl",{className:"mt-3 space-y-1 border bg-card px-4 py-3 font-mono text-small",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Publisher"}),t.jsxs("dd",{"data-publisher":!0,children:[j,r.publisher_trusted?" (trusted here)":" (new here)"]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Commit"}),t.jsx("dd",{className:"break-all","data-sha":!0,children:y.sha})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Source"}),t.jsx("dd",{className:"break-all",children:y.source})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Installs as"}),t.jsxs("dd",{className:"break-all",children:[y.id,r.replaced?`, replacing the one read at ${r.replaced.slice(0,12)}`:""]})]})]}),t.jsx("p",{className:"mt-3 text-lead leading-[1.6]",children:y.description}),t.jsx(cr,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:Ny(y,{mcp:!1}).map(([S,N])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:S}),t.jsx("dd",{className:"min-w-0 break-words",children:N})]},S))})}),y.mcp.length>0&&t.jsx(cr,{title:"MCP tools it asks for",note:"None is granted by installing: the Apply screen asks you to tick each one.",children:y.mcp.map(S=>t.jsxs("div",{"data-mcp":S.toolkit,className:"px-4 py-3",children:[t.jsx(HE,{m:S}),t.jsx("p",{className:"mt-1 break-words font-mono text-small",children:S.tools.map(N=>N.name).join(", ")})]},S.toolkit))}),t.jsx(BE,{t:y}),t.jsx(GE,{t:y}),t.jsx(cr,{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})}),((E=y.output)==null?void 0:E.json_schema)&&t.jsx(cr,{title:"Output schema",note:`What the agent is told to answer in (${y.output.schema}), in full: its descriptions are instructions too.`,children:t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-output-schema":!0,children:JSON.stringify(y.output.json_schema,null,2)})}),k.length>0&&t.jsx(cr,{title:"Skill files",note:"Every file the agent is given, in full.",children:k.map(([S,N])=>t.jsxs("details",{className:"px-4 py-2","data-skill-file":S,children:[t.jsx("summary",{className:"cursor-pointer font-mono text-body",children:S}),t.jsx("pre",{className:"mt-2 max-h-[32rem] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:N})]},S))}),!r.publisher_trusted&&t.jsxs("label",{className:"mt-6 flex items-start gap-2.5 border border-warning/50 px-4 py-3",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:d,onChange:S=>u(S.target.checked)}),t.jsxs("span",{children:[t.jsxs("span",{className:"font-mono text-body",children:["I trust ",j]}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:["This server has no package from ",j," yet. Ticked, it remembers that you trust them."]})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void h(),disabled:f||!r.publisher_trusted&&!d,children:f?"Installing…":"Install"}),t.jsx("span",{className:"text-small text-muted-foreground",children:"Installing stores it; nothing runs and nothing is granted until you apply it."}),b&&t.jsx("p",{className:"w-full text-body text-destructive-text",role:"alert",children:b})]})]})}function M0(e){var n;return e instanceof Fe&&((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 dU=e=>`#/templates/install?src=${encodeURIComponent(e)}`,uU=3e3;function fU(e,n){let s;const r=new Promise(o=>s=setTimeout(()=>o(void 0),n));return Promise.race([e,r]).finally(()=>clearTimeout(s))}function mU({v2:e,template:n,go:s,playground:r=!1,draft:o}){var Tt,nt,ft,Kt,Dt,ye,de,We,Ze,at;const i=r?"h2":"h1",c={fields:rh(n.parameters)??[]},d=b8(o,n),[u,f]=p.useState(()=>{var Q;return{...Object.fromEntries(c.fields.filter(([,ve])=>ve.type==="boolean"&&!ve.array).map(([ve])=>[ve,"false"])),...SE(c),...Object.fromEntries(Object.entries(((Q=d.body)==null?void 0:Q.parameters)??{}).map(([ve,He])=>[ve,Array.isArray(He)?He.map(String).join(`
|
|
664
|
+
`):String(He)]))}}),[g,b]=p.useState(()=>{var Q;return new Set(((Q=d.body)==null?void 0:Q.grants)??[])}),[x,h]=p.useState(((nt=(Tt=d.body)==null?void 0:Tt.overrides)==null?void 0:nt.approvals)??n.approvals_default??"ask"),[v,y]=p.useState(((Kt=(ft=d.body)==null?void 0:ft.overrides)==null?void 0:Kt.choice)??""),[j,k]=p.useState(null),[E,S]=p.useState(null),[N,$]=p.useState(0),[_,M]=p.useState(()=>{var Q;return((Q=d.body)==null?void 0:Q.servers)??{}}),[O,L]=p.useState(!1),[A,R]=p.useState([]),[P,D]=p.useState(null),[W,K]=p.useState(null),[H,q]=p.useState([]),[F,G]=p.useState({}),U=p.useRef(Ys()).current,z=p.useRef(!0);p.useEffect(()=>(z.current=!0,()=>{z.current=!1}),[]),p.useEffect(()=>{let Q=!0;return S(null),e.listMcpServers().then(ve=>{Q&&k(ve.servers)},ve=>{Q&&S(Wt(ve,"the saved MCP servers"))}),()=>{Q=!1}},[e,N]);const Y=C8(n,g),J=n.mcp.map(Q=>{const ve=j?k8(Q,j):[];return{m:Q,matches:ve,uses:ve.length===1?ve[0]:ve.includes(_[Q.toolkit]??"")?_[Q.toolkit]:void 0}}),X=Object.fromEntries(J.flatMap(({m:Q,uses:ve})=>ve?[[Q.toolkit,ve]]:[])),le=J.filter(({matches:Q,uses:ve})=>Q.length>1&&!ve).map(({m:Q})=>Q.toolkit),se=n.mcp.length>0&&j===null,fe=j&&J.some(({m:Q,matches:ve})=>{var He,Se;return((Se=(He=d.body)==null?void 0:He.servers)==null?void 0:Se[Q.toolkit])!==void 0&&!ve.includes(d.body.servers[Q.toolkit])}),xe=d.error??(fe?"This prepared server choice no longer matches the saved MCP servers. Open a fresh request to review the current accounts.":void 0),Ne=!!xe||se||le.length>0,ge=r||sm(n),me=!r&&sm(n)?A0.filter(Q=>Q.needs(n)):[],[Le,Ue]=p.useState({}),[De,Ee]=p.useState(0),re=me.map(Q=>Q.id).join(" ");p.useEffect(()=>{let Q=!0;for(const ve of A0.filter(He=>re.split(" ").includes(He.id)))ve.met(e).then(He=>{Q&&Ue(Se=>({...Se,[ve.id]:He?"met":"unmet"}))},()=>{Q&&Ue(He=>({...He,[ve.id]:"unread"}))});return()=>{Q=!1}},[e,re,De]);const _e=me.filter(Q=>Le[Q.id]!=="met"),Qe=_e.find(Q=>Le[Q.id]===void 0),he=_e.length>0;p.useEffect(()=>{if(!he)return;const Q=()=>Ee(ve=>ve+1);return window.addEventListener("focus",Q),()=>window.removeEventListener("focus",Q)},[he]);const Ie={parameters:ah(c,u),...Y.length?{grants:Y}:{},...Object.keys(X).length?{servers:X}:{},overrides:{approvals:x,...v?{choice:v}:{}}},et=Q=>E8(A,Q),pt=(Q,ve,He)=>{f(Se=>({...Se,[Q]:He})),NE(ve,He)&&R(Se=>Se.filter(Je=>$x(Je.field,"parameters")!==Q))},oe=async()=>{var ve,He;if(!ge||Ne||_e.length)return;L(!0),R([]),D(null);const Q=u;try{const Se=await e.applyTemplate(n.id,Ie,U.keyFor(n.id,Ie));U.done();const Je=async()=>(await Promise.all(Se.trigger_ids.map(it=>fU(e.getTrigger(it),uU).catch(()=>null)))).filter(it=>it!=null&&vy(it));if(Se.warnings.length||(ve=Se.webhook_secrets)!=null&&ve.length){G(Q),K(Se),Je().then(q,()=>{});return}const Nt=Se.trigger_ids.length?await Je():[];if(!z.current)return;if(!Nt.length){s(cn(Se.agent_id));return}G(Q),q(Nt),K(Se)}catch(Se){Se instanceof Fe&&((He=Se.fields)!=null&&He.length)?(R(Se.fields),D({text:Se.message,withIssues:!0}),Se.fields.some(Je=>Je.field.startsWith("servers.")||Je.field.startsWith("mcp."))&&$(Je=>Je+1)):D({text:Se instanceof Error?Se.message:String(Se),withIssues:!1})}finally{L(!1)}},$e=c.fields,st=Q=>Q.filter(ve=>!n.secrets.includes(ve)),Oe=(ye=(Dt=n.model)==null?void 0:Dt.choices)==null?void 0:ye.find(Q=>Q.id===v),dt=Q=>{var ve,He;return/^(parameters|mcp|servers)\./.test(Q.field)||/^grants\.\d+$/.test(Q.field)||Q.field==="overrides.choice"&&!!((He=(ve=n.model)==null?void 0:ve.choices)!=null&&He.length)||Q.field.startsWith("secrets.")&&[...n.secrets,...st((Oe==null?void 0:Oe.secrets)??[])].includes(Q.field.slice(8))};return W?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(pl,{className:"size-5 text-success-text","aria-hidden":!0})," ",Wo(n,F)," applied"]}),W.warnings.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mb-3 text-lead",children:"The agent is made. The server says:"}),t.jsx("ul",{className:"mb-5 space-y-2 border bg-card px-4 py-3 text-body",role:"status","aria-label":"Warnings",children:W.warnings.map((Q,ve)=>{var Nt,zt;const He=/^triggers\.(\d+)\.secret$/.exec(Q.field),Se=He?W.trigger_ids[Number(He[1])]:void 0,Je=He?(Nt=n.triggers[Number(He[1])])==null?void 0:Nt.name:void 0;return Se&&((zt=W.webhook_secrets)!=null&&zt.some(it=>it.trigger_id===Se))?t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:Q.field})," ",Q.message]},`${Q.field}:${ve}`):t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:Q.field})," ",Q.message,Q.fix?t.jsx("span",{className:"block text-muted-foreground",children:Q.fix}):null,Se&&t.jsxs("a",{href:`#/triggers/${encodeURIComponent(Se)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",typeof Je=="string"&&Je?Je:Se," to get its signing secret (Rotate)"]})]},`${Q.field}:${ve}`)})})]}),(de=W.webhook_secrets)==null?void 0:de.map(Q=>{var Je;const ve=W.trigger_ids.indexOf(Q.trigger_id),He=ve>=0?(Je=n.triggers[ve])==null?void 0:Je.name:void 0,Se=typeof He=="string"&&He?He:Q.trigger_id;return Q.signing_secret?t.jsx(Ey,{label:`The webhook's URL and secret (${Se})`,url:Qc({id:Q.trigger_id}),secret:Q.signing_secret},Q.trigger_id):t.jsxs("div",{className:"mt-4 border px-4 py-3 text-body",children:[Q.note&&t.jsx("p",{className:"text-muted-foreground",role:"note",children:Q.note}),t.jsxs("a",{href:`#/triggers/${encodeURIComponent(Q.trigger_id)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",Se," to get its signing secret (Rotate)"]})]},Q.trigger_id)}),H.length>0&&t.jsx("ul",{className:"mt-4 divide-y border","aria-label":"Schedules",children:H.map(Q=>t.jsxs("li",{"data-trigger":Q.id,className:"px-4 py-3",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(Q.id)}`,className:"break-words text-prose font-semibold hover:underline",children:Q.name}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",children:gy(Q.source,Q.next_at)})]},Q.id))}),t.jsx("div",{className:"mt-5"}),t.jsx("a",{href:cn(W.agent_id),className:"inline-flex border px-3 py-2 font-mono text-body font-semibold hover:bg-accent",children:"Open the agent"})]}):t.jsxs("div",{children:[t.jsxs("a",{href:WE(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(Rn,{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($y,{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.":ge?"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."}),xe&&t.jsxs("p",{className:"mt-3 text-body text-destructive-text",role:"alert",children:[xe," ",t.jsx("a",{href:el(n),className:"underline",children:"Open a fresh request"}),"."]}),t.jsxs("div",{className:`mt-6 ${cd}`,children:[$e.length>0&&t.jsx(cr,{title:"Parameters",children:$e.map(([Q,ve])=>t.jsxs("div",{"data-field":`parameters.${Q}`,className:"px-4 py-3",children:[t.jsx($E,{field:ve,label:oh(Q,ve),help:rm(ve),value:u[Q]??"",onChange:He=>pt(Q,ve,He)}),t.jsx(Po,{issues:A.filter(He=>$x(He.field,"parameters")===Q),words:He=>EE(He,Q,ve)})]},Q))}),n.mcp.length>0&&t.jsxs(cr,{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(Qt,{problem:E,onRetry:()=>$(Q=>Q+1),className:""})}),J.map(({m:Q,matches:ve,uses:He})=>t.jsxs("div",{"data-mcp":Q.toolkit,className:"px-4 py-3",children:[t.jsx(HE,{m:Q,children:j&&ve.length<2&&t.jsx("span",{className:"text-small text-muted-foreground",children:He?`Uses ${He}`:"Not set up here"})}),j&&ve.length>1&&t.jsxs("label",{className:"mt-2 flex flex-wrap items-center gap-2 text-small text-muted-foreground",children:["Uses",t.jsx(Ct,{small:!0,label:`Server for ${Q.toolkit}`,value:He??"",placeholder:"Pick one",onChange:Se=>M(Je=>({...Je,[Q.toolkit]:Se})),options:ve.map(Se=>({value:Se,label:Se}))}),!He&&t.jsxs("span",{"data-unpicked":Q.toolkit,children:[ve.length," saved servers are ",wd[Q.source]," ",Q.toolkit,": pick the one the agent uses."]})]}),j&&ve.length===0&&t.jsxs("p",{role:"status","data-missing-mcp":Q.toolkit,className:"mt-2 border border-warning/50 px-3 py-2 text-small text-warning-text",children:[Q.required?`${Q.toolkit} is required and not set up here: Apply is refused until it is.`:`${Q.toolkit} is not set up here: Apply makes the agent without its tools (${Q.tools.map(Se=>Se.name).join(", ")}).`," ",t.jsx("a",{href:N8(Q),className:"font-mono text-primary-text underline-offset-2 hover:underline",children:Q.source==="github"?"Set up GitHub App access":Q.source==="composio"?`Add ${Q.toolkit} from Composio`:`Set up ${Q.toolkit}`})]}),t.jsx(Po,{issues:[...et(`mcp.${Q.toolkit}`),...et(`servers.${Q.toolkit}`)]}),t.jsx("ul",{className:"mt-2 space-y-2",children:Q.tools.map(Se=>{const Je=Y.indexOf(Se.tool);return t.jsxs("li",{"data-tool":Se.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(Se.tool),onChange:()=>b(Nt=>{const zt=new Set(Nt);return zt.has(Se.tool)?zt.delete(Se.tool):zt.add(Se.tool),zt})}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body",children:Se.name})," ",t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Se.tool}),t.jsx("span",{className:"block text-small text-muted-foreground",children:Se.asks==="allow"?"The template asks you to grant this.":"The template does not ask for this; unticked, the agent doesn't get it."})]})]}),Je>=0&&t.jsx(Po,{issues:et(`grants.${Je}`)})]},Se.tool)})})]},Q.toolkit))]}),n.secrets.length>0&&t.jsx(cr,{title:"Keys it uses",note:"Saved on this server by name; a run is given them.",children:n.secrets.map(Q=>t.jsxs("div",{"data-secret":Q,className:"px-4 py-3 font-mono text-body",children:[Q,t.jsx(Po,{issues:et(`secrets.${Q}`)})]},Q))}),(Ze=(We=n.model)==null?void 0:We.choices)!=null&&Ze.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 ${(at=n.harness)!=null&&at.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(Q=>t.jsxs("label",{"data-choice":Q.id||"(default)",className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"model-choice",value:Q.id,className:"mt-1 accent-primary",checked:v===Q.id,onChange:()=>{y(Q.id),R(ve=>ve.filter(He=>He.field!=="overrides.choice"&&!(He.field.startsWith("secrets.")&&!n.secrets.includes(He.field.slice(8)))))}}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body","data-choice-label":!0,children:Q.label}),"model"in Q&&t.jsxs("span",{className:"block font-mono text-label text-muted-foreground",children:[Q.model," on ",Q.harness]}),Q.warning&&t.jsx("span",{className:"mt-1 block text-small text-warning-text","data-choice-warning":Q.id,children:Q.warning}),Q.note&&t.jsx("span",{className:"mt-1 block text-small text-muted-foreground","data-choice-note":Q.id,children:Q.note}),"secrets"in Q&&v===Q.id&&t.jsx("span",{"data-choice-keys":Q.id,children:t.jsx(Po,{issues:st(Q.secrets).flatMap(ve=>et(`secrets.${ve}`))})})]})]},Q.id||"(default)"))}),t.jsx(Po,{issues:et("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(([Q,ve,He])=>t.jsxs("label",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"approvals",value:Q,className:"mt-1 accent-primary",checked:x===Q,onChange:()=>h(Q)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:ve}),t.jsx("span",{className:"block text-small text-muted-foreground",children:He})]})]},Q))}),x==="never"&&t.jsx("p",{className:"mt-2 text-small text-warning-text",children:BC})]}),t.jsx(BE,{t:n}),t.jsx(GE,{t:n}),t.jsx(cr,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:Ny(n,{secrets:!1,mcp:!1}).map(([Q,ve])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:Q}),t.jsx("dd",{className:"min-w-0 break-words",children:ve})]},Q))})})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[ge?t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void oe(),disabled:O||Ne||_e.length>0,title:se?E?"The saved MCP servers couldn't be read: try again first":"Reading the saved MCP servers…":le.length?`Pick the server for ${le.join(", ")} first`:Qe?`Reading ${Qe.what}…`:void 0,children:O?"Applying…":"Apply"}),!r&&t.jsx(nn,{variant:"outline",label:"Set it up with an agent",disabled:Ne,prompt:ox(location.origin,n,Ie),playgroundHref:el(n,Ie)}),_e.map(Q=>Le[Q.id]==="unmet"?t.jsxs("p",{role:"status","data-requirement":Q.id,className:"min-w-0 text-body text-warning-text",children:[Q.unmet.before,t.jsx("a",{href:Q.unmet.href,className:"font-mono text-primary-text underline-offset-2 hover:underline",children:Q.unmet.link}),Q.unmet.after]},Q.id):Le[Q.id]==="unread"?t.jsxs("p",{role:"alert","data-requirement-unread":Q.id,className:"flex min-w-0 flex-wrap items-center gap-2 text-body text-destructive-text",children:[`${Q.what[0].toUpperCase()}${Q.what.slice(1)} couldn't be read.`,t.jsx(B,{size:"sm",onClick:()=>Ee(ve=>ve+1),children:"Try again"})]},Q.id):null)]}):t.jsx(nn,{variant:"primary",label:"Run",disabled:Ne,prompt:ox(location.origin,n,Ie),playgroundHref:el(n,Ie)}),P&&(!P.withIssues||A.length>0)&&t.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:P.text})]}),A.filter(Q=>!dt(Q)).length>0&&t.jsx("div",{className:"mt-2",children:t.jsx(Po,{issues:A.filter(Q=>!dt(Q)),named:!0})})]})}function HE({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(ke,{tone:"muted",children:wd[e.source]}),t.jsx(ke,{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 BE({t:e}){if(!e.input_schema)return null;const n=rh(e.input_schema,"content");return n&&!n.length?null:t.jsx(cr,{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:oh(s,r)}),r.title&&t.jsx("span",{className:"text-small text-muted-foreground",children:s}),t.jsx(ke,{tone:"muted",children:D8(r)}),t.jsx(ke,{tone:r.required?"plain":"muted",children:r.required?"Required":"Optional"})]}),rm(r)&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:rm(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 GE({t:e}){const n=e.evals.length;return t.jsx(cr,{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 cr({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 om(e){return{definition:{version:1,name:"New agent",instructions:e.trim(),harness:"pi",tools:[],skills:[]}}}function P0(e){return`#/playground?${new URLSearchParams({operation:"create-agent",draft:JSON.stringify(e)})}`}function hU(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 pU={"code-review":mm,"inbound-lead":gm,kyb:QT,"market-monitor":VT,"release-notes":Ya};function gU({origin:e,v2:n}){const[s,r]=p.useState(""),[o,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(null),[g,b]=p.useState(null),[x,h]=p.useState(0),v=p.useId(),y=zm(e,s),j=om(s);p.useEffect(()=>{let S=!0;return b(null),n.listTemplates().then(N=>{S&&f(N.templates)},N=>{S&&b(Wt(N,"the template catalog"))}),()=>{S=!1}},[n,x]);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":`${v}-heading`,children:[t.jsxs("header",{className:"text-center",children:[t.jsx("h1",{id:`${v}-heading`,className:"text-2xl font-semibold leading-tight tracking-tight md:text-display",children:"What do you want to build?"}),t.jsx("p",{className:"mt-3 text-base text-muted-foreground",children:"Describe your agent, or pick a template to start from."})]}),t.jsxs("div",{className:"mx-auto mt-8 max-w-page",children:[t.jsxs("div",{className:ae(Hc,"!rounded-composer overflow-hidden bg-card transition-colors"),"data-agent-composer":!0,children:[t.jsx("label",{htmlFor:`${v}-brief`,className:"sr-only",children:"Describe your agent"}),t.jsx(tn,{bare:!0,id:`${v}-brief`,value:s,onChange:S=>r(S.target.value),rows:3,placeholder:"A support agent that answers questions from our docs and escalates to Slack when it’s stuck…",className:"block min-h-28 w-full resize-none px-5 pb-3 pt-5 font-sans text-base leading-relaxed text-foreground md:px-6 md:pt-6"}),t.jsx("div",{className:"flex justify-end px-4 pb-4 pt-1 md:px-5 md:pb-5",children:t.jsx(nn,{variant:"primary",label:"Build an agent",prompt:y,playgroundHref:P0(j)})})]}),t.jsxs("details",{className:"mt-3 text-small text-muted-foreground",children:[t.jsx("summary",{className:"ml-auto w-fit cursor-pointer hover:text-foreground",children:"View coding-agent prompt"}),t.jsx("label",{htmlFor:`${v}-prompt`,className:"sr-only",children:"Coding-agent prompt"}),t.jsx(tn,{id:`${v}-prompt`,value:y,readOnly:!0,rows:8,spellCheck:!1,className:"mt-3 w-full border bg-card p-4 font-mono text-small leading-relaxed text-foreground"})]})]}),t.jsxs("section",{className:"mt-10 md:mt-12","aria-labelledby":`${v}-templates`,children:[t.jsxs("div",{className:"mb-5 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("h2",{id:`${v}-templates`,className:"text-lead font-semibold",children:"Start from a template"}),t.jsx("span",{role:"status",className:"text-small text-muted-foreground",children:u===null&&!g?"Loading templates…":u?`${E.length} of ${u.length}`:""})]}),t.jsxs("div",{className:ae(Hc,"flex w-full items-center gap-2 px-3 sm:w-72"),children:[t.jsx(gm,{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(Qt,{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,$=pU[S.name]??qx,_=`${v}-${encodeURIComponent(S.id)}-actions`,M=[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($y,{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}),M,t.jsx(Wx,{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(nn,{variant:"primary",label:"Use this template",prompt:HP(e,S,s),playgroundHref:el(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:P0(om("")),children:"start from a blank agent"}),"."]})]})}const qE=p.createContext(new Map),xU={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"};function KE({run:e}){const n=p.useContext(qE);if(!e.trigger)return null;const{id:s}=e.trigger,r=n.get(s),o=r?`${xU[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(ke,{className:"max-w-full",children:[t.jsx(fm,{className:"size-3 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"truncate",children:o})]})})}const am=["queued","working","paused","input_required","completed","failed","cancelled"],vU={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function yU({runs:e,agentName:n,onOpen:s,error:r,onRetry:o,onMore:i,loadingMore:c,filter:d={},onFilter:u,agentId:f,observations:g}){var x,h;const b=!!d.archived;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-5 py-2 md:px-6",children:[t.jsxs("h1",{className:"caps mr-auto flex items-center gap-2.5 text-small font-semibold",children:[t.jsx(sd,{className:"size-4","aria-hidden":!0}),b?"Archived runs":"Runs"]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Ct,{label:"Runs in one state",value:d.status??"",onChange:v=>u({...d,status:v||void 0}),className:"h-control-sm w-48",options:[{value:"",label:"Any state"},...am.map(v=>({value:v,label:vU[v]}))]}),t.jsxs(B,{size:"sm",variant:b?"primary":"outline","aria-pressed":b,onClick:()=>u({...d,archived:!b}),children:[t.jsx(nd,{"aria-hidden":!0})," Archived"]})]}),t.jsx(nn,{label:"Query",prompt:`${Dm(location.origin,f)}
|
|
665
|
+
Current view: ${d.status?`status ${d.status}`:"all statuses"}; ${b?"archived runs":"non-archived runs"}.`,playgroundHref:Rv(f,d)})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[r&&!e?t.jsx(Qt,{problem:r,onRetry:o,className:""}):e?!e.length&&!((x=g==null?void 0:g.data)!=null&&x.sessions.length)&&!d.status&&!b?t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(bU,{})}):!e.length&&((h=g==null?void 0:g.data)!=null&&h.sessions.length)?null:e.length?t.jsx(wU,{runs:e,agentName:n,onOpen:s}):t.jsx("p",{className:"px-4 py-16 text-center text-body text-muted-foreground",children:d.status?"No run matches.":b?"No archived runs.":"No runs yet."}):t.jsx(Un,{label:"Loading the runs"}),g&&t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Tv,{read:g})}),e&&r&&t.jsx(Qt,{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 bU(){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:Lc({variant:"solid",size:"lg"}),children:[t.jsx(Qo,{"aria-hidden":!0})," Start a run"]}),t.jsx("a",{href:"#/templates",className:Lc({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function wU({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(Cl,{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:Sn(r)}),t.jsx(fr,{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(KE,{run:r})}),t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground md:hidden",children:[n(r.agent_id)," · ",ht(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:ht(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:no(r.cost,{ended:Ba(r.status)})})]},r.run_id))})]})}function jU({agentId:e,details:n}){const{denied:s,asks:r}=zD(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 kU(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 Fe(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 b=u==null?void 0:u.file;return b!=null&&b.file_id?(s==null||s(1),i(b)):c(new Fe(d.status,"bad_answer","The server's answer named no file."))}const f=u==null?void 0:u.error,g=new Fe(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 Fe(0,"network","The upload did not reach the server.")),d.onabort=()=>c(new Fe(0,"aborted","The upload was stopped.")),r==null||r.addEventListener("abort",()=>d.abort(),{once:!0}),d.send(e)})}const NU=(e,n,s)=>kU(e,{onProgress:n,signal:s});function _g(e){if(!(e instanceof Fe))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 SU({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 b=p.useRef({items:o,frozen:r,remove:n});b.current={items:o,frozen:r,remove:n};const x=p.useRef(!0);p.useEffect(()=>{x.current=!0;const k=u.current;return()=>{var $;x.current=!1;for(const _ of k.values())_.abort();const{items:E,frozen:S,remove:N}=b.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(b.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 M of k)N!==null&&M.size>N?E.push({text:`${M.name} is ${il(M.size)}: this server takes files up to ${il(N)}.`}):$.length>=S?E.push({text:`${M.name} is not added: a run names at most ${s==null?void 0:s.max_files_per_run} files here.`}):$.push(M);d(E);const _=$.map(M=>({key:`f${f.current++}`,name:M.name,size:M.size,progress:0}));g.current+=_.length,i(M=>[...M,..._]),_.forEach((M,O)=>{const L=new AbortController;u.current.set(M.key,L);const A=R=>{x.current&&i(P=>P.map(D=>D.key===M.key?{...D,...R}:D))};e($[O],R=>A({progress:R}),L.signal).then(R=>{var P,D,W;if(u.current.delete(M.key),L.signal.aborted){(W=(D=(P=b.current).remove)==null?void 0:D.call(P,R.file_id))==null||W.catch(K=>{x.current&&d(H=>[...H,{text:`${M.name} was sent before it was stopped, and was not removed: ${_g(K)}`}])});return}A({file:R,progress:1})},R=>{u.current.delete(M.key),!(L.signal.aborted||!x.current)&&(i(P=>P.filter(D=>D.key!==M.key)),d(P=>[...P,{text:`${M.name}: ${_g(R)}`}]))})})},[s==null?void 0:s.max_files_per_run,s==null?void 0:s.max_upload_bytes,e]),v=p.useCallback(k=>{var _;const{items:E,frozen:S,remove:N}=b.current,$=E.find(M=>M.key===k);if(!(S||!$||$.removing)){if(!$.file||!N){(_=u.current.get(k))==null||_.abort(),u.current.delete(k),i(M=>M.filter(O=>O.key!==k));return}i(M=>M.map(O=>O.key===k?{...O,removing:!0}:O)),d(M=>M.filter(O=>O.about!==k)),N($.file.file_id).then(()=>{x.current&&i(M=>M.filter(O=>O.key!==k))},M=>{x.current&&(i(O=>O.map(L=>L.key===k?{...L,removing:!1}:L)),d(O=>[...O,{about:k,text:`${$.name} was not removed: ${_g(M)}`}]))})}},[]),y=p.useCallback(()=>{b.current={...b.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:v,clear:y,fileIds:j,frozen:r,busy:o.some(k=>!k.file||k.removing)}}function L0({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,b=s||e.frozen,x=n?[`up to ${n.max_files_per_run} files`,...n.max_upload_bytes!==null?[`${il(n.max_upload_bytes)} each`]:[]].join(", "):"";return t.jsxs("div",{className:ae("border border-dashed px-3 py-2.5",i?"border-primary bg-primary/5":"border-border",r&&"max-sm:border-0 max-sm:p-0"),onDragOver:h=>{b||(h.preventDefault(),c(!0))},onDragLeave:()=>c(!1),onDrop:h=>{h.preventDefault(),c(!1),b||f([...h.dataTransfer.files])},role:"group","aria-label":"Files for the run",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>{var h;return(h=o.current)==null?void 0:h.click()},disabled:b,title:r?`Attach files${x?` (${x})`:""}`:void 0,className:ae(r&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[t.jsx(qT,{"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",x?` (${x})`:"",". 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:il(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:b||h.removing,"aria-label":`Remove ${h.name}`,className:"text-muted-foreground hover:text-foreground disabled:opacity-45",children:t.jsx(Xo,{className:"size-3.5","aria-hidden":!0})})]},h.key))}),d.some(h=>!h.file)&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:"The run can start once every file is sent."}),u.length>0&&t.jsx("ul",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:u.map((h,v)=>t.jsx("li",{children:h},`${v}:${h}`))})]})}const uf={"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."},_y=(e,n)=>e instanceof Fe?{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 CU({agents:e,revisions:n=[],efforts:s,origin:r,agentId:o,onAgent:i,onSend:c,onOpenRun:d,result:u=null,live:f,limits:g,upload:b=NU,removeUpload:x}){var Kt,Dt,ye;const[h,v]=p.useState(o??((Kt=e[0])==null?void 0:Kt.agent_id)??"");p.useEffect(()=>{var de;o&&o!==h&&e.some(We=>We.agent_id===o)?v(o):e.some(We=>We.agent_id===h)||v(((de=e[0])==null?void 0:de.agent_id)??"")},[e,o]);const y=e.find(de=>de.agent_id===h),j=Bv(y),k=es(y==null?void 0:y.definition),E=(y==null?void 0:y.kind)??"agentic",[S,N]=p.useState(""),[$,_]=p.useState(""),M=$?(Dt=n.find(de=>de.revision===$))==null?void 0:Dt.definition:void 0,O=E==="agentic"?JSON.stringify(((ye=M??(y==null?void 0:y.definition))==null?void 0:ye.input_schema)??null):"null",L=p.useMemo(()=>E==="agentic"?M8(JSON.parse(O)):null,[E,O]),A=(L==null?void 0:L.kind)==="fields"?L.form:null,R=E==="workflow"||(L==null?void 0:L.kind)==="json",[P,D]=p.useState({});p.useEffect(()=>{D(A?SE(A):{})},[h,O]);const W=E==="workflow"?g8(y==null?void 0:y.definition.workflow):(L==null?void 0:L.kind)==="json"?L.example:null,K=p.useRef("");p.useEffect(()=>{if(S.trim()&&S!==K.current)return;const de=(W==null?void 0:W.text)??"";K.current=de,N(de)},[h,W==null?void 0:W.text]);const[H,q]=p.useState(""),[F,G]=p.useState(""),[U,z]=p.useState(""),[Y,J]=p.useState("form"),[X,le]=p.useState(u?"response":"code"),[se,fe]=p.useState("curl"),[xe,Ne]=p.useState(()=>!(typeof window<"u"&&typeof window.matchMedia=="function")||window.matchMedia("(min-width: 1024px) and (min-height: 501px)").matches),ge=p.useId(),[me,Le]=p.useState(u),Ue=new Set((A==null?void 0:A.fields.map(([de])=>de))??[]),De=de=>{const We=$x(de);return We!==null&&Ue.has(We)?We:null},Ee=p.useMemo(()=>{var at,Q;const de=me&&me.status>=400?(at=me.body)==null?void 0:at.error:void 0;if(!de||typeof de.message!="string")return;const We=Array.isArray(de.fields)?de.fields.filter(ve=>!!ve&&typeof ve.field=="string"&&typeof ve.message=="string"):[],Ze=We.filter(ve=>ve.message!==de.message&&De(ve.field)===null);return{message:de.message,more:Ze,issues:We,box:typeof((Q=de.details)==null?void 0:Q.box)=="string"?de.details.box:void 0,details:de.code==="agent_not_runnable"?de.details:void 0}},[me,O]),[re,_e]=p.useState(new Set);p.useEffect(()=>{_e(new Set)},[me]);const Qe=(de,We,Ze)=>{D(at=>({...at,[de]:Ze})),_e(at=>{const Q=new Set(at);return NE(We,Ze)?Q.add(de):Q.delete(de),Q})},he=de=>re.has(de)?[]:((Ee==null?void 0:Ee.issues)??[]).filter(We=>De(We.field)===de),[Ie,et]=p.useState(!1),pt=p.useMemo(()=>Ys(),[]),oe=SU({upload:b,remove:x,limits:g,frozen:Ie}),$e=m8(E,{text:S,revision:$,effort:H,maxCostUsd:F,fileIds:oe.fileIds,repo:U,...A?{typed:{fields:ah(A,P),contentRequired:A.contentRequired}}:{},...(L==null?void 0:L.kind)==="json"?{json:!0}:{}}),st=$e.ok?$e.body:{input:R?S:A?I8(A,S,P):{content:S},...oe.fileIds.length?{file_ids:oe.fileIds}:{}},Oe=h?pt.keyFor(h,st):"",dt=se==="curl"?x8(r,h,st,Oe):`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(Oe)},
|
|
671
|
+
},
|
|
672
|
+
body: JSON.stringify(${JSON.stringify(st,null,2).replace(/\n/g,`
|
|
673
|
+
`)}),
|
|
674
|
+
});
|
|
675
|
+
console.log(res.status, await res.json());`,Tt=!!j&&(!j.connected||j.state!=="ready"||!j.capabilities.launch||!!F.trim()||!!H||!!U.trim()||oe.fileIds.length>0||oe.busy),nt=async()=>{if(k||Tt||!$e.ok||!c||oe.busy)return;et(!0);const de=await y8(pt,h,$e.body,c);et(!1),Le(de),le("response"),Ne(!0),de.status>=200&&de.status<300&&oe.clear()},ft=R?E==="workflow"?'{ "subject": "...", "body": "..." }':"The agent's input, as JSON":`The run's ${A?"message":"first message"}, e.g. Summarize the standup: we ship Friday.`;return e.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-hidden",children:[t.jsxs("div",{"aria-label":"Playground agent",className:"flex shrink-0 flex-wrap items-center gap-3 border-b px-5 py-3 md:px-6",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-small",children:[t.jsx("label",{htmlFor:"playground-agent",className:"caps text-muted-foreground",children:"Agent"}),t.jsx(Ct,{id:"playground-agent",label:"Agent",value:h,onChange:de=>{v(de),_(""),i==null||i(de)},options:Nl(e).map(de=>({value:de.agent_id,label:de.definition.name})),className:"w-56 max-w-[60vw]"})]}),k?t.jsxs("span",{className:"font-mono text-small",children:[Yo(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(nn,{variant:"primary",label:"Run agent",prompt:zv(r,h,k.runtime)})]}):t.jsxs("div",{className:ae("relative grid min-h-0 flex-1 grid-cols-1",xe?"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",xe?"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",!xe&&"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(de=>t.jsx("button",{type:"button","aria-pressed":Y===de,onClick:()=>J(de),className:ae("min-h-6 border-b pb-1 capitalize",Y===de?"border-primary":"border-transparent text-muted-foreground"),children:de==="json"?"JSON":"Form"},de))})]}),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."]}),Tt&&t.jsx("p",{className:"text-warning-text",children:U.trim()?"This request selects a repository. Native execution uses its source project.":F.trim()?"This request has a spend cap. Native execution cannot enforce it.":H||oe.fileIds.length?"This request has managed effort or attachments. Native execution uses its source configuration and project files.":"Verify a connected native launch before sending a run."}),!!U.trim()&&t.jsx(B,{size:"sm",onClick:()=>z(""),children:"Use native source repository"}),!!H&&t.jsx(B,{size:"sm",onClick:()=>q(""),children:"Use native configured effort"}),oe.fileIds.length>0&&t.jsx(B,{size:"sm",onClick:()=>oe.clear(),children:"Remove uploaded attachments"}),!!F.trim()&&t.jsx(B,{size:"sm",onClick:()=>G(""),children:"Remove cap for native execution"}),t.jsx("a",{href:cn(h),className:"underline underline-offset-2",children:"Open native connection"})]}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Start a run"}),t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:[y?`${y.definition.name}: ${E==="agentic"?"an":"a"} ${E} agent.`:"Pick an agent."," The server answers 202 with the run; follow it on its page."]})]}),Y==="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(st,null,2)}),!j&&t.jsx(Na,{name:"file_ids",note:uf.file_ids,children:t.jsx(L0,{attachments:oe,limits:g})})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Na,{htmlFor:"playground-input",name:R?"input":"input.content",required:!A||A.contentRequired,optional:!!A&&!A.contentRequired,error:!$e.ok&&$e.field==="input"&&S?$e.message:void 0,children:[t.jsx(tn,{id:"playground-input",value:S,onChange:de=>N(de.target.value),rows:R?7:4,placeholder:ft,className:I0}),W&&t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[p8(W,"start",E==="workflow"?"workflow":"agent"),W.fields.length>0&&t.jsxs(t.Fragment,{children:[" Fields: ",W.fields.map((de,We)=>t.jsxs("span",{title:de.note,children:[We?", ":"",t.jsx("span",{className:"text-foreground",children:de.name})]},de.name)),"."]})]})]}),A==null?void 0:A.fields.map(([de,We])=>t.jsxs("div",{"data-field":`input.${de}`,children:[t.jsx($E,{field:We,label:oh(de,We),help:rm(We),value:P[de]??"",onChange:Ze=>Qe(de,We,Ze)}),t.jsx(Po,{issues:he(de),words:Ze=>EE(Ze,de,We)})]},de)),!j&&t.jsx(Na,{name:"file_ids",note:uf.file_ids,children:t.jsx(L0,{attachments:oe,limits:g})}),t.jsx(Na,{name:"revision",note:"Empty runs the current revision.",children:t.jsx(Ct,{label:"Revision",value:$,onChange:_,className:"w-full",options:[{value:"",label:"The current revision"},...n.map(de=>({value:de.revision,label:`rev ${de.version}${de.current?" (current)":""}${de.note?`: ${de.note}`:""}`}))]})}),!j&&t.jsx(Na,{name:"effort",note:"How hard the model thinks. Empty uses the agent's own.",children:t.jsx(Ct,{label:"Effort",value:H,onChange:q,className:"w-full",options:["",...s].map(de=>({value:de,label:de||"Agent default"}))})}),E==="agentic"&&!j&&t.jsx(Na,{htmlFor:"playground-repo",name:"repo",note:uf.repo,error:!$e.ok&&$e.field==="repo"?$e.message:void 0,children:t.jsx(Pe,{id:"playground-repo",value:U,onChange:de=>z(de.target.value),placeholder:"owner/name"})}),E==="agentic"&&!j&&t.jsxs(Na,{htmlFor:"playground-cap",name:"max_cost_usd",note:"A spend cap in dollars; empty means none.",error:!$e.ok&&$e.field==="max_cost_usd"?$e.message:void 0,children:[t.jsx(Pe,{id:"playground-cap",value:F,onChange:de=>G(de.target.value),inputMode:"decimal",placeholder:"e.g. 0.50",className:I0}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:t.jsx(WC,{})})]})]})]}),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(nn,{label:"Use your agent",prompt:BP(r,h,st),disabled:Tt||!$e.ok||!h||oe.busy}),t.jsxs(B,{variant:"primary",size:"lg",onClick:nt,disabled:Tt||!$e.ok||!c||Ie||!h||oe.busy,title:oe.busy?"Waiting for the files to be sent":void 0,children:[t.jsx(Qo,{"aria-hidden":!0})," ",Ie?"Sending":"Send request"]})]})]})]}),t.jsxs("section",{"aria-label":"Code and response",className:ae("flex min-h-0 flex-col",!xe&&"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",xe?"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",!xe&&"hidden"),children:[t.jsx("button",{type:"button","aria-pressed":X==="code",onClick:()=>le("code"),className:ae("border-b pb-1",X==="code"?"border-primary":"border-transparent text-muted-foreground"),children:"Code"}),t.jsxs("button",{type:"button","aria-pressed":X==="response",onClick:()=>le("response"),disabled:!me,className:ae("border-b pb-1 disabled:opacity-45",X==="response"?"border-primary":"border-transparent text-muted-foreground"),children:["Response",me&&t.jsx("span",{className:ae("ml-2 font-mono max-sm:hidden",me.status<300?"text-success-text":"text-destructive-text"),children:me.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":xe,"aria-controls":ge,onClick:()=>Ne(de=>!de),children:[xe?t.jsx(TT,{"aria-hidden":!0}):t.jsx(hm,{"aria-hidden":!0})," ",xe?"Hide code and response":"Show code and response"]})})]}),t.jsx("div",{id:ge,className:ae("flex min-h-0 flex-1 flex-col",!xe&&"hidden"),children:X==="code"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b px-5 md:px-6",children:[t.jsx("div",{role:"group","aria-label":"Code in",className:"flex gap-5 text-small",children:["curl","fetch"].map(de=>t.jsx("button",{type:"button","aria-pressed":se===de,onClick:()=>fe(de),className:ae("-mb-px border-b-2 py-2.5",se===de?"border-primary":"border-transparent text-muted-foreground"),children:de==="curl"?"cURL":"JavaScript"},de))}),t.jsx(B,{size:"icon",variant:"outline","aria-label":"Copy code",onClick:()=>{var de;return void((de=navigator.clipboard)==null?void 0:de.writeText(dt))},children:t.jsx(Va,{"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:dt}),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."})]}):me&&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:me.status<300?"text-success-text":"text-destructive-text",children:me.status})," ",t.jsxs("span",{className:"text-muted-foreground",children:[me.ms," ms"]})]}),Ee&&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: ",Ee.message,Ee.box?t.jsxs("span",{className:"text-muted-foreground",children:[" (box: ",Ee.box,")"]}):null,t.jsx(jU,{agentId:h,details:Ee.details}),Ee.more.length>0&&t.jsx("span",{className:"mt-1 block",children:Ee.more.map(de=>t.jsxs("span",{className:"block",children:[de.field,": ",de.message]},`${de.field}:${de.message}`))})]}),me.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(me.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(me.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(me.body,null,2)}),me.runId&&t.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(me.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(Wx,{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(uf).map(([de,We])=>t.jsxs("div",{children:[t.jsx("dt",{className:"font-mono text-body",children:de}),t.jsx("dd",{className:"text-small text-muted-foreground",children:We})]},de))}),t.jsxs("code",{className:"text-small",children:["/v2/agents/","{agent_id}","/runs"]})]})}const I0="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 Na({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 z0="h-11 w-full border bg-card px-3 text-lead outline-none focus:border-primary",EU=e=>`'${e.replaceAll("'","'\\''")}'`;function $U({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,b]=p.useState(""),[x,h]=p.useState("code"),[v,y]=p.useState("curl"),[j,k]=p.useState(null),[E,S]=p.useState(null),[N,$]=p.useState(!1),[_,M]=p.useState(!1),O=p.useRef(0);p.useEffect(()=>(O.current++,i(r.status??""),d(!!r.archived),b(""),S(null),k(null),$(!1),()=>{O.current++}),[s,r.status,r.archived]);const L={...o?{status:o}:{},...c?{archived:!0}:{}},A=s?`/v2/agents/${encodeURIComponent(s)}/runs`:"/v2/runs",R=new URLSearchParams({limit:String(u)});g&&R.set("cursor",g),o&&R.set("status",o),c&&R.set("archived","true");const P=`${n}${A}?${R}`,D=v==="curl"?`curl -X GET ${EU(P)} \\
|
|
676
|
+
-H "Authorization: Bearer $AGENTRUN_API_KEY"`:`const response = await fetch(${JSON.stringify(P)}, {
|
|
677
|
+
method: "GET",
|
|
678
|
+
headers: { Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\` },
|
|
679
|
+
});
|
|
680
|
+
console.log(response.status, await response.json());`,W=`${Dm(n,s)}
|
|
681
|
+
|
|
682
|
+
Prepared read-only request: GET ${P}
|
|
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.`,K=()=>{O.current++,b(""),S(null),k(null),M(!1)},H=async(q=g)=>{if(N)return;const F=++O.current;$(!0),S(null),k(null),b(q),M(!1);const G=performance.now();try{const U=s?await e.listAgentRuns(s,u,q||void 0,L):await e.listRuns(u,q||void 0,L);if(O.current!==F)return;S(U),k({status:200,ms:performance.now()-G,body:U})}catch(U){if(O.current!==F)return;k(_y(U,performance.now()-G))}finally{O.current===F&&($(!1),h("response"))}};return t.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-2",children:[t.jsxs("section",{className:"flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",children:[t.jsx("header",{className:"flex h-12 shrink-0 items-center border-b px-6",children:t.jsx("span",{className:"text-lead font-semibold",children:"Request"})}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto p-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"List runs"}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:"Inspect server-run sessions and imported history. This request only reads data."})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Agent"}),t.jsx(Pe,{className:z0,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(Ct,{label:"Run status",value:o,disabled:N,onChange:q=>{i(q),K()},options:[{value:"",label:"All statuses"},...am.map(q=>({value:q,label:q.replaceAll("_"," ")}))]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Archive"}),t.jsx(Ct,{label:"Archived runs",value:String(c),disabled:N,onChange:q=>{d(q==="true"),K()},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(Ct,{label:"Page size",value:String(u),disabled:N,onChange:q=>{f(Number(q)),K()},options:[10,25,50,100].map(q=>({value:String(q),label:String(q)}))})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Cursor"}),t.jsx(Pe,{"aria-label":"Cursor",className:`${z0} font-mono text-small`,value:g,disabled:N,placeholder:"First page",onChange:q=>{O.current++,b(q.target.value),S(null),k(null)}})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t p-4",children:[t.jsx(nn,{label:"Use your agent",prompt:W}),t.jsxs(B,{variant:"primary",disabled:N,onClick:()=>void H(),children:[t.jsx(Qo,{"aria-hidden":!0}),N?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(q=>t.jsx("button",{onClick:()=>h(q),className:ae("h-12 border-b text-small capitalize",x===q?"border-primary":"border-transparent text-muted-foreground"),children:q},q)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{var q;(q=navigator.clipboard)==null||q.writeText(D).then(()=>M(!0),()=>M(!1))},children:t.jsx(Va,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:_?"Code copied":""})]}),x==="code"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-12 shrink-0 gap-5 border-b px-6",children:["curl","fetch"].map(q=>t.jsx("button",{onClick:()=>y(q),className:ae("border-b text-small",v===q?"border-primary":"border-transparent text-muted-foreground"),children:q==="curl"?"cURL":"JavaScript"},q))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:D})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:j?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[j.status||"Network error"," · ",Math.round(j.ms)," ms"]}),E&&t.jsxs(t.Fragment,{children:[E.runs.length?t.jsx("ul",{className:"divide-y border",children:E.runs.map(q=>t.jsx("li",{children:t.jsxs("a",{className:"flex items-center gap-3 p-3 text-lead hover:bg-accent",href:`#/runs/${encodeURIComponent(q.run_id)}`,children:[t.jsx(Cl,{run:q}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:q.title||q.run_id}),t.jsx(fr,{className:"size-3.5 shrink-0","aria-hidden":!0})]})},q.run_id))}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"No runs match this request."}),E.next_cursor&&t.jsx(B,{size:"sm",disabled:N,onClick:()=>void H(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 bc=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Li="w-full border bg-card px-3 py-3 text-lead outline-none focus:border-primary";function _U({v2:e,origin:n,operation:s,agentId:r,draft:o,harnesses:i=[]}){const c=s==="edit-agent",d=hU(o??null),[u,f]=p.useState(null),[g,b]=p.useState(null),[x,h]=p.useState(void 0),[v,y]=p.useState(d??om("")),[j,k]=p.useState(JSON.stringify(d??om(""),null,2)),[E,S]=p.useState(j),N=HC(j!==E),[$,_]=p.useState("form"),[M,O]=p.useState("code"),[L,A]=p.useState("curl"),[R,P]=p.useState(null),[D,W]=p.useState(null),[K,H]=p.useState(null),[q,F]=p.useState(!1),[G,U]=p.useState(!1),[z,Y]=p.useState(0),[J,X]=p.useState(!1);p.useEffect(()=>{if(!c)return;if(!r){P("Choose an agent from Connected agents to edit its definition.");return}let oe=!0;return f(null),h(void 0),P(null),e.getAgent(r).then(({agent:$e,etag:st})=>{if(!oe)return;f($e),b(st);const Oe={definition:{...$e.definition,version:$e.revisions+1}},dt=JSON.stringify(Oe,null,2);y(Oe),k(dt),S(dt),W(null),U(!1)}).catch($e=>{oe&&P(String($e instanceof Error?$e.message:$e))}),()=>{oe=!1}},[e,c,r,z]);const le=(oe,$e)=>{const st={...v.definition,[oe]:oe==="model"?$e.trim():$e};oe==="model"&&!$e.trim()&&!c&&delete st.model;const Oe={...v,definition:st};y(Oe),k(JSON.stringify(Oe,null,2))};let se=v,fe=null;if($==="json")try{const oe=JSON.parse(j);!bc(oe)||!bc(oe.definition)?fe="Include a definition object in the request.":se=oe}catch{fe="Enter valid JSON before sending the request."}!fe&&se.note!==void 0&&typeof se.note!="string"&&(fe="note must be a string.");for(const oe of["description","instructions","harness","model"])!fe&&se.definition[oe]!==void 0&&typeof se.definition[oe]!="string"&&(fe=`definition.${oe} must be a string.`);!fe&&typeof se.definition.name!="string"&&(fe="Give this agent a name.");const xe=!fe;!fe&&!se.definition.name.trim()&&(fe="Give this agent a name."),!fe&&!se.definition.workflow&&(typeof se.definition.instructions!="string"||!se.definition.instructions.trim())&&(fe="Add instructions for this agent.");const Ne=se;if(!fe&&c&&u){const oe=bc(se.definition.workflow),$e=Object.keys(u.definition).filter(Oe=>!Object.hasOwn(se.definition,Oe));for(const Oe of["id","name","description"])!fe&&se.definition[Oe]!==u.definition[Oe]&&(fe=`definition.${Oe} is fixed when the agent is created. Restore its current value.`);for(const Oe of["native","sdk"])!fe&&u.definition[Oe]!==void 0&&$e.includes(Oe)&&(fe=`Cannot remove definition.${Oe} here. Edit the original source configuration with your agent.`);if(!fe&&!oe)for(const Oe of["input_schema","output_schema"])$e.includes(Oe)&&(fe=`Cannot remove definition.${Oe}: the API keeps an omitted schema. Restore it or supply a replacement schema.`);!fe&&$e.includes("harness")&&(fe='Cannot remove definition.harness: the API keeps it. Select an explicit harness, such as "pi" for the default.'),!fe&&(u.definition.computer!==void 0||u.definition.place!==void 0)&&!Object.hasOwn(se.definition,"computer")&&!Object.hasOwn(se.definition,"place")&&(fe='Cannot remove definition.computer and definition.place together: the API keeps the setting. Set computer to {"kind":"none"} or place to {"mode":"runner"} explicitly.');const st=bc(se.skills)&&Object.keys(se.skills).length===0;if(!fe&&!Object.hasOwn(se.definition,"skills")&&!st&&(u.definition.skills.length>0||bc(se.skills)&&Object.keys(se.skills).length>0)&&(fe="Cannot remove definition.skills while skill files are retained or supplied. Give their skill names, or use definition.skills: [] with skills: {} to clear them."),!fe){const Oe=Object.fromEntries($e.map(ft=>[ft,ft==="learning"?oe?void 0:!1:ft==="max_cost_usd"?0:ft==="checkout"?oe?void 0:"none":ft==="tools"||ft==="skills"?[]:void 0])),{unchanged:dt,...Tt}=vd(u,{...Oe,...se.definition},se.note??""),nt=se.skills!==void 0&&!Ji(se.skills,x);dt&&!nt&&(fe="Change the definition before saving a revision."),nt&&(Tt.definition.version=u.revisions+1),se={...se,...Tt}}}c&&u&&!g&&(fe="This server did not provide a revision ETag. Reload the current revision before editing.");const ge=c?"PUT":"POST",me=c?`/v2/agents/${encodeURIComponent(r??"")}/definition`:"/v2/agents",Le=`${n}${me}`,Ue=JSON.stringify(se,null,2),De=oe=>`'${oe.replaceAll("'","'\\''")}'`,Ee={"Content-Type":"application/json",...c&&g?{"If-Match":g}:{}},re=L==="curl"?`curl -X ${ge} ${De(Le)} \\
|
|
684
|
+
-H "Authorization: Bearer $AGENTRUN_API_KEY" \\
|
|
685
|
+
${Object.entries(Ee).map(([oe,$e])=>` -H ${De(`${oe}: ${$e}`)} \\
|
|
686
|
+
`).join("")} -d ${De(Ue)}`:`const response = await fetch(${JSON.stringify(Le)}, {
|
|
687
|
+
method: ${JSON.stringify(ge)},
|
|
688
|
+
headers: {
|
|
689
|
+
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
690
|
+
${Object.entries(Ee).map(([oe,$e])=>` ${JSON.stringify(oe)}: ${JSON.stringify($e)},`).join(`
|
|
691
|
+
`)}
|
|
692
|
+
},
|
|
693
|
+
body: JSON.stringify(${Ue}),
|
|
694
|
+
});
|
|
695
|
+
console.log(response.status, await response.json());`,_e=es(u==null?void 0:u.definition),Qe=c&&(!!(u!=null&&u.definition.native)||!!_e),he=Qe&&u?Bo(n,u.agent_id,!!u.definition.native,_e==null?void 0:_e.runtime):`${c?Bo(n,r??""):zm(n)}
|
|
696
|
+
|
|
697
|
+
Prepared request: ${ge} ${Le}${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
|
+
${Ue}`,Ie=!fe&&!R&&(!c||!!u)&&!q&&!G,et=async()=>{if(!Ie)return;F(!0),H(null);const oe=performance.now();try{const $e=c?await e.updateDefinition(r,se,g):{agent:await e.createAgent(se),etag:null};H($e.agent.agent_id),S(j),W({status:c?200:201,ms:performance.now()-oe,body:$e.agent}),c?(f($e.agent),b($e.etag),se.skills!==void 0&&h(se.skills)):U(!0)}catch($e){const st=_y($e,performance.now()-oe);W(st),!c&&(st.status===0||st.status>=500)&&U(!0)}finally{F(!1),O("response")}},pt=t.jsxs(xv,{open:N.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:N.leave,onCancel:N.stay,children:[c?"Your changes to this agent are not saved.":"This new agent is not saved yet."," Leave drops them; Stay keeps them here."]});return R?t.jsxs(t.Fragment,{children:[pt,t.jsxs("div",{className:"m-6 border p-5",role:"alert",children:[t.jsx("p",{children:R}),r&&t.jsx(B,{className:"mt-3",onClick:()=>Y(oe=>oe+1),children:"Reload agent"})]})]}):c&&!u?t.jsxs(t.Fragment,{children:[pt,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(oe=>t.jsx("button",{onClick:()=>{if(oe==="form"&&$==="json"){if(!xe)return;y(Ne)}_(oe)},className:ae("h-12 border-b text-small",$===oe?"border-primary":"border-transparent text-muted-foreground"),children:oe==="json"?"JSON":"Form"},oe))})]}),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(tn,{value:j,onChange:oe=>k(oe.target.value),className:`${Li} min-h-[360px] font-mono text-small`,spellCheck:!1})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ii,{name:"Name",children:t.jsx(Pe,{value:v.definition.name,readOnly:c,onChange:oe=>le("name",oe.target.value),className:Li})}),t.jsx(Ii,{name:"Description",children:t.jsx(Pe,{value:v.definition.description??"",readOnly:c,onChange:oe=>le("description",oe.target.value),className:Li})}),v.definition.workflow?t.jsx(Ii,{name:"Workflow",children:t.jsx("pre",{className:`${Li} overflow-auto font-mono text-small`,children:JSON.stringify(v.definition.workflow,null,2)})}):t.jsxs(t.Fragment,{children:[t.jsx(Ii,{name:"Instructions",children:t.jsx(tn,{value:v.definition.instructions??"",rows:5,onChange:oe=>le("instructions",oe.target.value),className:Li})}),t.jsx(Ii,{name:"Harness",children:t.jsx(Ct,{label:"Harness",value:v.definition.harness??"pi",onChange:oe=>le("harness",oe),options:[...new Set([v.definition.harness??"pi",...i.map(oe=>oe.id)])].map(oe=>{var $e;return{value:oe,label:`${oe}${(($e=i.find(st=>st.id===oe))==null?void 0:$e.available)===!1?" (not set up)":""}`}})})}),t.jsx(Ii,{name:"Model",children:t.jsx(Pe,{value:v.definition.model??"",onChange:oe=>le("model",oe.target.value),placeholder:"Server default",className:Li})})]}),t.jsx("button",{className:"text-lead text-primary-text",onClick:()=>_("json"),children:"Edit all fields in JSON →"})]}),fe&&t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:fe}),c&&u&&!g&&t.jsx(B,{size:"sm",onClick:()=>Y(oe=>oe+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(nn,{label:"Use your agent",prompt:he,disabled:!Qe&&!!fe}),t.jsxs(B,{variant:"primary",onClick:()=>void et(),disabled:!Ie,children:[t.jsx(Qo,{"aria-hidden":!0}),q?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(oe=>t.jsx("button",{onClick:()=>O(oe),className:ae("h-12 border-b text-small capitalize",M===oe?"border-primary":"border-transparent text-muted-foreground"),children:oe},oe)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{navigator.clipboard.writeText(re).then(()=>X(!0),()=>X(!1))},children:t.jsx(Va,{"aria-hidden":!0})}),t.jsx("span",{role:"status",className:"sr-only",children:J?"Code copied":""})]}),M==="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(oe=>t.jsx("button",{onClick:()=>A(oe),className:ae("border-b text-small",L===oe?"border-primary":"border-transparent text-muted-foreground"),children:oe==="curl"?"cURL":"JavaScript"},oe))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:re})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:D?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[D.status||"Network error"," · ",Math.round(D.ms)," ms"]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(D.body,null,2)}),K&&t.jsxs("a",{className:"inline-flex items-center gap-2 text-lead text-primary-text",href:cn(K),children:["Open agent",t.jsx(fr,{className:"size-4"})]}),D.status===412&&t.jsx(B,{onClick:()=>Y(oe=>oe+1),children:"Reload current revision"}),G&&!K&&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."})})]}),pt]})}function Ii({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 TU=[{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"}],Ko="p-5 md:p-8",ni="mb-6 max-w-prose",si="[&>:not(section)]:mb-6";function Rr({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 RU({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:AS,children:TU.filter(r=>n.includes(r.id)).map(r=>t.jsx("a",{href:`#/settings/${r.id}`,"aria-current":e===r.id?"page":void 0,className:OS(e===r.id),children:r.label},r.id))}),t.jsx("div",{className:"min-h-0 flex-1",children:s})]})}async function lh(e,n){var d;let s;try{s=((d=navigator.clipboard)==null?void 0:d.readText().catch(()=>""))??Promise.resolve("")}catch{s=Promise.resolve("")}Ns.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 oa({error:e,title:n="The run failed"}){return t.jsxs("section",{className:"flex gap-3 bg-card px-4 py-4 md:px-5",role:"alert",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"caps text-small font-semibold",children:n}),t.jsx("p",{className:"mt-2 break-words font-mono text-body leading-relaxed",children:e.message}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[e.code,e.retryable?" · retryable":"",e.request_id?` · ${e.request_id}`:""]})]})]})}const AU={anthropic:"claude.ai",openai:"chatgpt.com",openrouter:"openrouter.ai",parallel:"parallel.ai",monid:"monid.ai",browserbase:"browserbase.com",kernel:"kernel.sh",typesafe:"typesafe.ai"},OU={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"},MU=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function PU({id:e,className:n}){const[s,r]=p.useState(!1),o=AU[e],i=OU[e];return o&&!s?t.jsx("img",{"data-provider-icon":e,src:MU(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(Ia,{className:ae("size-4 shrink-0 text-muted-foreground",n),"aria-hidden":!0})}const LU=/^(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,IU=40;function zU(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&&LU.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>IU)?[]:i.map(c=>/\s/.test(c)?c[0].toUpperCase()+c.slice(1):c)}function DU(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 VE=e=>e.filter(n=>!n.imported_from).length,FU=864e5;function UU(e,n){return e.some(s=>!s.imported_from)||n.some(s=>s.source==="live"&&s.runs>0)}function Od(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 WU(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 HU(e,n){let s=!1,r;const o=()=>{s||e().catch(()=>{}).finally(()=>{s||(r=setTimeout(o,n))})};return o(),()=>{s=!0,clearTimeout(r)}}const YE=e=>e.pending!=null&&e.pending.kind!=="stopped",BU=e=>e.status==="input_required"&&e.state!=="waiting"&&!YE(e),GU=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function D0(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 GU.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 ch({field:e,label:n,writable:s,required:r=!0,stateSaid:o=!1,now:i=Date.now,note:c,onPaste:d,onRemove:u}){const f=e.source==="env",g=s&&!f;return t.jsxs("li",{"data-secret":e.name,"data-source":e.source??"none",className:ae("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",f&&"opacity-60"),children:[t.jsxs("span",{children:[Xf(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":c?"text-warning-text":e.set?"text-success-text":"text-muted-foreground",children:e.set?"Set":"Missing"}),e.source&&t.jsx("span",{className:"text-muted-foreground",children:r6[e.source]}),e.changed_at&&t.jsxs("span",{className:"text-muted-foreground",children:["Changed ",Od(e.changed_at,i())," ago"]}),c&&t.jsx("span",{className:"text-warning-text",children:c}),g&&t.jsxs("span",{className:"ml-auto flex gap-2 font-sans",children:[d&&t.jsx(B,{type:"button",size:"sm",variant:e.set?"outline":"primary",onClick:d,children:e.set?"Replace":"Paste"}),u&&e.set&&t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:u,children:"Remove"})]})]})}const F0={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-…"}},qU=e=>Object.prototype.hasOwnProperty.call(F0,e)?F0[e]:void 0,KU={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."},U0=e=>e instanceof Fe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function W0(e,n){return n?n.state==="accepted"?`${e} accepted this key · ${ht(n.at)}`:`Not checked: ${n.reason}${n.at?` · ${ht(n.at)}`:""}`:null}const VU="can't be opened: paste it again",YU=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],Tx="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function QU({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,b]=p.useState(null),[x,h]=p.useState(null),v=p.useRef(0),y=()=>{const _=++v.current;e.listToolKeys().then(M=>{_===v.current&&(d(M),f(null))}).catch(M=>{_===v.current&&f(U0(M))})};p.useEffect(y,[e]);const j=_=>b(M=>M===_?null:M),k=_=>{j(_),y(),n==null||n()},E=(_,M,O,L)=>{h({id:_,title:M,error:U0(O)}),O instanceof Fe&&O.code==="key_set_by_server"&&(j(L),y())};if(!c)return u?t.jsx(H0,{error:u,onRetry:y}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Un,{label:"Loading the tool keys",rows:3})});const S=c.reenter,N=YU.map(_=>({..._,keys:c.keys.filter(M=>M.kind==="model"==(_.kind==="model"))})).filter(_=>_.keys.length),$=_=>t.jsx(JU,{tool:_,writable:s,again:!!S&&_.fields.some(M=>M.stored_unreadable||S.fields.includes(M.name)),open:(g==null?void 0:g.id)===_.id?g.mode:null,problem:(x==null?void 0:x.id)===_.id?x:null,onOpen:M=>{b(M?{id:_.id,mode:M}:null),h(null)},onSave:async M=>{const O=g;try{await e.saveToolKey(_.id,M)}catch(L){return L instanceof Fe&&L.status===422?L:(E(_.id,"The key was not saved",L,O),null)}return k(O),null},onRemove:async()=>{const M=g;try{await e.removeToolKey(_.id)}catch(O){E(_.id,"The key was not removed",O,M);return}k(M)}},_.id);return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:ni,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:si,children:[!s&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:ti[r]}),u&&t.jsx(H0,{inline:!0,error:u,onRetry:y}),S&&t.jsxs(vt,{tone:"warning",role:"alert","aria-label":"Keys to enter again",title:"Enter these keys again",children:[t.jsx("p",{children:KU[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(Rr,{label:_.label,title:_.label,note:_.kind==="model"?t.jsx("p",{children:Tx}):void 0,children:t.jsxs("ul",{className:"border",children:[_.kind==="model"&&o,_.keys.map($)]})},_.label)),i&&t.jsx(qC,{harnesses:i})]})]})})}function H0({error:e,onRetry:n,inline:s=!1}){return t.jsx(vt,{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 JU({tool:e,writable:n,again:s,open:r,problem:o,onOpen:i,onSave:c,onRemove:d}){var h;const u=p.useRef(null),f=v=>e.secrets.find(y=>Xf(y.name)===v.name),g=v=>e.fields.find(y=>y.name===Xf(v.name)),b=e.fields.filter(v=>{var y;return((y=f(v))==null?void 0:y.source)!=="env"}),x=e.secrets.filter(v=>v.set).length;return t.jsxs("li",{ref:u,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(PU,{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(ke,{tone:x===e.secrets.length?"success":"plain",children:x===e.secrets.length?"set":x?`${x} of ${e.secrets.length} set`:"not set"}),s&&t.jsx(ke,{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(", ")}`]}),W0(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:W0(e.label,e.check)}),t.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(v=>{var y;return t.jsx(ch,{field:v,stateSaid:e.secrets.length===1,writable:n&&r===null,note:(y=g(v))!=null&&y.stored_unreadable?VU:void 0,onPaste:()=>void lh(()=>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(v))==null?void 0:k.name)??"")}),onRemove:v.source==="console"?()=>i("remove"):void 0},v.name)})}),!b.length&&t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"Set when the server starts, and that one wins: change it where the server is started."})]})]}),r==="edit"&&t.jsx(QE,{tool:e,fields:b,onSave:c,onCancel:()=>i(null)}),r==="remove"&&t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove the ",e.label," key saved here?",e.secrets.some(v=>v.source==="env")?" The one set in the environment stays.":""]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void d(),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>i(null),children:"Keep"})]}),o&&t.jsx("div",{className:"mt-4 border",children:t.jsx(oa,{error:o.error,title:o.title})})]})}function QE({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),b=()=>n.some(y=>{var j,k;return(k=(j=o.current)==null?void 0:j.elements.namedItem(y.name))==null?void 0:k.value}),x=()=>{var y;(y=o.current)==null||y.reset(),c(!1)},h=async y=>{var N,$;y.preventDefault();const j={};for(const _ of n){const M=($=(N=o.current)==null?void 0:N.elements.namedItem(_.name))==null?void 0:$.value;M&&(j[_.name]=M)}if(!Object.keys(j).length)return;u(!0),g(null);const k=await s(j);if(u(!1),!k){x();return}const E={},S=[];for(const _ of k.fields??[]){const M=_.field.startsWith("values.")?_.field.slice(7):null;M&&n.some(O=>O.name===M)?E[M]=_.message:S.push(_.message)}g({fields:E,message:S.length?S.join(" "):Object.keys(E).length?null:k.message})},v=qU(e.id);return t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:y=>void h(y),onInput:()=>c(!!b()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e.label} key`,children:[v&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:e.label})," · No key yet?"," ",t.jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Get a key"})," (opens in a new tab)"]}),n.map(y=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:y.name}),y.set&&t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"Saved already. A new value replaces it; leave it empty to keep it."}),t.jsx(Pe,{type:"password",name:y.name,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:v&&n.length===1?v.placeholder:void 0}),(f==null?void 0:f.fields[y.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[y.name]})]},y.name)),(f==null?void 0:f.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f.message}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!i||d,children:d?"Saving":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{x(),r()},children:"Cancel"})]})]})}const Md=p.createContext(null);function B0({connection:e,children:n}){return t.jsx(Md.Provider,{value:e,children:n})}const XU={state:"online"},ZU=()=>()=>{},G0=()=>XU;function Ty(){const e=p.useContext(Md);return p.useSyncExternalStore(e?e.subscribe:ZU,e?e.link:G0,G0)}function JE(e){const n=p.useContext(Md),s=p.useRef(e);s.current=e,p.useEffect(()=>n==null?void 0:n.onResume(()=>s.current()),[n])}function XE(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 eW(){const e=p.useContext(Md),n=Ty(),s=XE(n.state==="offline"?n.retryAt:null);return!e||n.state==="online"?null:n.state==="resumed"?t.jsxs(vt,{bar:!0,tone:"success",icon:Jo,"data-connection":"resumed",children:[t.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):t.jsxs(vt,{bar:!0,tone:"warning",icon:UN,"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 tW(){const e=p.useContext(Md),n=Ty(),s=XE(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(UN,{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 nW=(e,n)=>e.flatMap(s=>s.tools.flatMap(r=>{var o;return(o=r.permissions)!=null&&o.length&&r.default_permission?[{name:G2(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"}:{}}]:[]})),q0=e=>e instanceof Fe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function sW({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),b=()=>{o&&(g(null),e.listMcpServers().then(G=>g(G.servers),()=>g("failed")))};p.useEffect(b,[e,o]);const[x,h]=p.useState(null),[v,y]=p.useState(null),[j,k]=p.useState(!1),[E,S]=p.useState(null),N=p.useRef(0),$=()=>{const G=++N.current;e.toolSettings().then(U=>{G===N.current&&(u(U),h(null))},U=>{G===N.current&&h(q0(U))})};p.useEffect($,[e]);const[_,M]=p.useState("reading"),O=()=>{M("reading"),Promise.resolve(c==null?void 0:c()).then(G=>M(G===!1?"failed":"landed"))},L=()=>{$(),O()};if(p.useEffect(O,[]),!d)return x?t.jsx(vt,{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: ",x.code,": ",x.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const A=vx(d,n),R=E?E(A):A,P=UC(n,[...s,...Array.isArray(f)?nW(f,s.some(G=>G.ask_needs==="password")):[]]),D=G=>{var z;const U=Go(G);return U?(z=R[`mcp:${U.server}/*`])==null?void 0:z.permission:void 0},W=Object.entries(R).filter(([,G])=>(G==null?void 0:G.pin)||(G==null?void 0:G.pin_broken)),K=G=>{var z;const U=s.find(Y=>Y.name===G);return!U||(((z=R[G])==null?void 0:z.permission)??U.default_permission)===U.permission},{byTool:H,rest:q}=OC((v==null?void 0:v.fields)??{},"",P.map(G=>G.name)),F=async G=>{var J;const U=E?X=>G(E(X)):G;k(!0),y(null);const z=++N.current;let Y;try{Y=await e.toolSettings()}catch{S(()=>U),y({fields:{},error:null,unread:!0}),k(!1);return}try{const X=await e.saveToolSettings(U(vx(Y,n)));S(null),z===N.current&&(u(X),h(null)),i()}catch(X){y(X instanceof Fe&&X.status===422&&((J=X.fields)!=null&&J.length)?{fields:Object.fromEntries(X.fields.map(le=>[le.field,le.message])),error:null}:{fields:{},error:q0(X)})}k(!1)};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Tools"}),t.jsxs("div",{className:"mt-2 grid gap-x-10 gap-y-2 xl:grid-cols-2",children:[t.jsx("p",{className:"text-lead text-muted-foreground",children:"This server's provider for each tool that has a choice, and what it resolves to on each harness. A change is saved at once and applies to every run launched from then on. An agent with a provider of its own keeps it."}),s.length>0&&t.jsxs("p",{className:"text-lead text-muted-foreground",children:["Each tool's permission: ",t.jsx("span",{className:"font-mono text-body",children:"allow"})," runs it, ",t.jsx("span",{className:"font-mono text-body",children:"ask"})," makes the run wait for your approval at each call, ",t.jsx("span",{className:"font-mono text-body",children:"deny"})," refuses it and tells the agent why. A permission applies at the next call, in runs already going too. An agent's own allow or ask takes the place of this server's; deny here refuses it for every agent."]})]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("section",{"aria-label":"This server's providers",children:[P.length?t.jsx(fy,{label:"This server's tool settings",rows:P,settings:R,fallbackOf:G=>G.default_provider,issues:H,busy:j,onEdit:G=>void F(G),permissionFallbackOf:G=>D(G.name)??G.default_permission,refused:(G,U)=>U==="deny",resolvesOf:(G,U)=>U===G.provider&&K(G.name)?t.jsx(WF,{choice:G,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:L,disabled:j,size:"xs",className:"ml-1",children:"Retry"})]})}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"This server offers no tool with a choice of provider."}),f==="failed"&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"alert",children:["The MCP servers' tools could not be read, so they are not listed. ",t.jsx(B,{type:"button",size:"xs",className:"ml-1",onClick:b,disabled:j,children:"Retry"})]}),q.map(G=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:G},G)),(v==null?void 0:v.error)&&t.jsx("div",{className:"mt-3 border",children:t.jsx(oa,{error:v.error,title:"The change was not saved"})}),(v==null?void 0:v.unread)&&t.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[t.jsx("p",{className:"font-mono text-small text-destructive-text",children:"Couldn't read the current settings, so nothing was saved. Try again."}),t.jsx(B,{type:"button",size:"xs",className:"mt-2",onClick:()=>void F(G=>G),disabled:j,children:"Try again"})]}),x&&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: ",x.code,": ",x.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:L,disabled:j,size:"xs",className:"mt-2",children:"Try again"})]})]}),W.length>0&&t.jsxs("section",{"aria-label":"Pinned tools",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Pinned tools"}),t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:"A pin bounds a tool's calls for every agent on this server, its own pin beside it."}),t.jsx("ul",{className:"mt-2 border",children:W.map(([G,U])=>t.jsxs("li",{"data-pin":G,className:"border-b px-3 py-2.5 last:border-b-0",children:[t.jsx("p",{className:"font-mono text-body",children:G}),t.jsx(bx,{setting:U})]},G))})]})]})]})})}function rW(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 K0={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."},oW=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(K0,e.reason)?K0[e.reason]:"The connection didn't finish. Try again.";function aW(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 iW({note:e}){const n=e.lastIndexOf(": "),s=n>=0?e.slice(n+2).trim():"",r=s?dr(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 lW({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,b]=p.useState(null),[x,h]=p.useState(null),[v,y]=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 A=await e.githubConnection();r(A.connected?A:null),i(null)}catch(A){i(A instanceof Error?A.message:String(A))}},[e]);p.useEffect(()=>{_()},[_]),p.useEffect(()=>{n&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),p.useEffect(()=>{var A;g&&((A=$.current)==null||A.submit())},[g]);const M=async()=>{var A;if(!N.current){N.current=!0,f(!0),h(null),y(null),S(null);try{const R=await e.connectGitHub(c.trim()||void 0),P=aW(R.action,dr);if(!P){h("GitHub's address didn't look right, so nothing was sent."),N.current=!1,f(!1);return}b({action:P,manifest:JSON.stringify(R.manifest)})}catch(R){if(N.current=!1,f(!1),h(R instanceof Error?R.message:String(R)),R instanceof Fe&&R.code==="github_wrong_origin"){const P=(A=R.details)==null?void 0:A.public_url;y(typeof P=="string"&&dr(P)||null)}R instanceof Fe&&R.code==="github_already_connected"&&_()}}},O=async()=>{k(!1),f(!0),h(null),y(null);try{S(await e.disconnectGitHub()),r(null)}catch(A){A instanceof Fe&&(A.status===404||A.code==="github_not_connected")?await _():h(A instanceof Error?A.message:String(A))}finally{f(!1)}},L=s?dr(`https://github.com/apps/${encodeURIComponent(s.slug)}`):void 0;return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:ni,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:si,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:oW(n)}),(x||v)&&t.jsx("div",{role:"alert",className:"border border-destructive/50 px-4 py-3 text-lead text-destructive-text",children:v?t.jsxs("p",{children:["Open this server at ",t.jsx("a",{href:v,className:"break-all underline underline-offset-2",children:v})," to connect GitHub."]}):t.jsx("p",{children:x})}),E&&t.jsxs("section",{"aria-label":"Disconnected",className:"border p-4 text-lead",children:[t.jsx("p",{children:t.jsx(iW,{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(vt,{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(Rr,{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:A=>d(A.target.value),disabled:u,placeholder:"your-org",className:"h-9 w-auto"})]}),t.jsxs(B,{type:"button",variant:"solid",onClick:()=>void M(),disabled:u,children:[t.jsx(cj,{"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(cj,{className:"size-4 text-muted-foreground","aria-hidden":!0}),L?t.jsx("a",{href:L,target:"_blank",rel:"noopener noreferrer",className:"font-mono underline underline-offset-2",children:s.slug}):t.jsx("span",{className:"font-mono",children:s.slug}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["App ",s.app_id]})]}),s.installations.length?t.jsx("ul",{"aria-label":"Installations",className:"mt-3 space-y-1 font-mono text-body",children:s.installations.map(A=>t.jsx("li",{children:A.account},A.id))}):t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"Not installed on any account yet."}),j?t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2 text-body",role:"alertdialog","aria-label":"Disconnect GitHub?",children:[t.jsx("span",{children:"Disconnect GitHub? Every GitHub trigger turns off."}),t.jsx(B,{type:"button",variant:"destructive",disabled:u,onClick:()=>void O(),children:"Disconnect GitHub"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>k(!1),children:"Cancel"})]}):t.jsx(B,{type:"button",variant:"outline",className:"mt-4",disabled:u,onClick:()=>k(!0),children:"Disconnect"})]})]}),g&&t.jsx("form",{"data-github-manifest":!0,ref:$,method:"post",action:g.action,hidden:!0,children:t.jsx("input",{type:"hidden",name:"manifest",defaultValue:g.manifest})})]})]})})}const cW=8,dW={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function uW({v2:e,signIn:n,add:s,writable:r,whyNot:o="sign_in",open:i=d=>location.assign(d),choices:c=[]}){var G,U,z,Y,J;const[d,u]=p.useState(null),[f,g]=p.useState(null),[b,x]=p.useState(!1),[h,v]=p.useState(null),[y,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),[_,M]=p.useState(null),O=s?JSON.stringify(s):"",L=p.useRef(O);p.useEffect(()=>{if(O===L.current)return;L.current=O;const X=O?JSON.parse(O):void 0;S(X&&X.preset!=="composio"?{add:X}:null),$((X==null?void 0:X.preset)==="composio"&&r?X:!1)},[O]);const A=p.useRef(0),R=p.useRef(null),P=()=>{const X=++A.current;e.listMcpServers().then(le=>{X===A.current&&(u(le.servers),j(null))},le=>{X===A.current&&j(oo(le))})};p.useEffect(P,[e]),p.useEffect(()=>{e.toolSettings().then(g,()=>g(null))},[e]);const D=p.useRef(!1),W=async(X,le)=>{if(!D.current){D.current=!0,x(!0),v(null);try{const se=await e.toolSettings();g(await e.saveToolSettings(le(vx(se,c)))),P()}catch(se){v({server:X,problem:oo(se)})}D.current=!1,x(!1)}},K=p.useRef(null);s&&d&&((G=K.current)==null?void 0:G.key)!==O&&(K.current={key:O,name:ZE(s.name,d)});const H=X=>{var le;return((le=K.current)==null?void 0:le.key)===JSON.stringify(X)&&K.current.name!==X.name?{...X,toolkit:X.toolkit??X.name,name:K.current.name}:X},q=d!==null||y!==null;p.useEffect(()=>{n&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[n]);const F=async(X,le)=>i((await e.startMcpSignIn(X,le)).authorization_url);return t.jsx("div",{ref:R,className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:ni,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:si,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: ${wI(n.error)}.`}),!r&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:ti[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}),y&&t.jsx(vt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:P,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The MCP servers could not be read. ",y.text]})}),t.jsxs(Rr,{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||q)&&t.jsx(NW,{v2:e,saved:E.saved,add:E.add&&H(E.add),given:E.problem,writable:r,taken:d,signIn:F,onCancel:()=>S(null),onSaved:(X=>le=>{le&&M(le),S(se=>se===X?null:se),P()})(E)},`${((U=E.saved)==null?void 0:U.name)??"new"}|${((z=E.add)==null?void 0:z.name)??""}|${((Y=E.add)==null?void 0:Y.auth)??""}|${((J=E.add)==null?void 0:J.preset)??""}`),N&&(typeof N!="object"||q)&&t.jsx(bW,{v2:e,add:typeof N=="object"?H(N):void 0,onClose:()=>$(!1),onSaved:P},typeof N=="object"?O:"new"),d&&(d.length?t.jsx("ul",{className:"border",children:d.map(X=>t.jsx(mW,{v2:e,server:X,settings:f,settingsBusy:b,settingsProblem:(h==null?void 0:h.server)===X.name?h.problem:null,onSettings:le=>void W(X.name,le),writable:r&&!E,signIn:F,onChange:le=>S({saved:X,...le?{problem:le}:{}}),onPaste:()=>void lh(()=>S({saved:X}),()=>{var le;return((le=R.current)==null?void 0:le.querySelector('input[name="mcp-token"], input[name="mcp-header-value-0"]'))??null}),onChanged:P,onDeleted:le=>{M(le??null),P()}},X.name))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No MCP server is saved here yet."}))]}),t.jsx(vW,{v2:e})]})]})})}const hl=({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})]}),Ec=(e,n)=>`mcp:${e}/${n}`,fW=["allow","ask","deny"];function mW({v2:e,server:n,settings:s,settingsBusy:r,settingsProblem:o,onSettings:i,writable:c,signIn:d,onChange:u,onPaste:f,onChanged:g,onDeleted:b}){var L,A;const[x,h]=p.useState(!1),[v,y]=p.useState(!1),[j,k]=p.useState(null),[E,S]=p.useState(null),N=async R=>{h(!0),S(null);try{await R()}catch(P){S(oo(P))}h(!1)},[$,_]=n.credential?dW[n.credential]??[n.credential,"plain"]:["no credential","plain"],M=n.auth.type==="oauth",O=j&&[["Added",j.added],["Removed",j.removed],["Changed",j.changed]].filter(([,R])=>R.length).map(([R,P])=>`${R} ${P.join(", ")}`);return t.jsxs("li",{"data-server":n.name,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(KT,{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(ke,{tone:_,children:$}),!!((L=n.not_metered)!=null&&L.length)&&t.jsx(ke,{tone:"plain",children:"not metered"}),n.source&&t.jsxs(t.Fragment,{children:[t.jsx(ke,{tone:"muted",children:wd[n.source]}),t.jsx("span",{"data-toolkit":!0,className:"font-mono text-small text-muted-foreground",children:n.toolkit?`toolkit ${n.toolkit}`:"no toolkit"})]})]}),t.jsx("p",{className:"mt-1.5 break-all font-mono text-small text-muted-foreground",children:n.url}),n.auth.type==="github_app"&&t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed with this server's GitHub App: a token narrowed to the run's repository is made for each run",(A=n.auth.headers)!=null&&A.length?` · headers ${n.auth.headers.join(", ")}`:""]}),M&&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 ${ht(n.oauth.expires_at)}`:""]}),s&&t.jsx(gW,{server:n,settings:s,busy:r,onSettings:i}),o&&t.jsx("div",{className:"mt-2",children:t.jsx(hl,{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(xW,{server:n,settings:s,busy:r,onSettings:i})})]}),n.secret&&t.jsx("ul",{className:"mt-2",children:t.jsx(ch,{field:n.secret,label:kW[n.auth.type],writable:c,onPaste:M?void 0:f})}),n.source==="composio"&&t.jsx(pW,{v2:e,server:n.name,writable:c}),O&&t.jsx("p",{className:"mt-2 font-mono text-small",role:"status",children:O.length?O.join(" · "):"No change: it lists the same tools."})]}),!v&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[M&&n.credential!=="sealed"&&c&&t.jsx(B,{size:"sm",variant:"primary",disabled:x,onClick:()=>void N(()=>{var R;return d(n.name,{url:n.url,...(R=n.oauth)!=null&&R.scopes.length?{scopes:n.oauth.scopes}:{}})}),children:"Sign in again"}),t.jsx(B,{size:"sm",disabled:x,onClick:()=>void N(async()=>{try{k(await e.refreshMcpServer(n.name))}finally{g()}}),children:"Refresh"}),t.jsx(B,{size:"sm",disabled:x,onClick:()=>u(),children:"Change"}),t.jsx(B,{size:"sm",variant:"destructive",disabled:x,onClick:()=>y(!0),children:"Delete"})]})]}),v&&t.jsxs("div",{role:"alertdialog","aria-label":`Delete ${n.name}`,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Delete ",n.name,"? Its credential goes with it, and an agent that grants its tools can't call them."]}),t.jsx(B,{size:"sm",variant:"destructive",disabled:x,onClick:()=>void N(async()=>{var R;b((R=await e.deleteMcpServer(n.name))==null?void 0:R.composio)}),children:"Delete"}),t.jsx(B,{size:"sm",onClick:()=>y(!1),children:"Keep"})]}),E&&t.jsxs("div",{className:"mt-3",children:[t.jsx(hl,{problem:E}),E.needsClient&&c&&t.jsx(B,{className:"mt-2",size:"sm",variant:"primary",onClick:()=>u(E),children:"Enter a Client ID"})]})]})}const hW={on:"on at Composio",off:"off at Composio",missing:"Composio no longer has it",unknown:"Composio didn't say"};function pW({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),[b,x]=p.useState(!1),[h,v]=p.useState(!1);if(p.useEffect(()=>{let k=!0;return e.composioTriggers(n).then(E=>{k&&o(E)},E=>{k&&(E instanceof Fe&&E.status===404?u(!0):c(oo(E)))}),()=>{k=!1}},[e,n]),d)return null;const y=async()=>{g(!1),x(!0),c(null),v(!1);try{await e.rotateComposioSecret(n),v(!0)}catch(k){c(oo(k))}x(!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:["· ",hW[k.on_composio],k.enabled?"":" · paused here"]})]},k.id))}):t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["No trigger uses it yet. ",t.jsx("a",{href:"#/triggers/new-composio",className:"underline underline-offset-2",children:"New app trigger"})]}),r.composio_error&&t.jsxs("p",{className:"mt-2 text-small text-warning-text",children:["Composio didn't answer: ",r.composio_error]}),j&&(j.ours?t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"The project's webhook subscription sends its events here."}):t.jsxs("p",{className:"mt-2 break-all text-small text-muted-foreground",children:["The project's webhook subscription sends its events to ",t.jsx("span",{className:"font-mono",children:j.webhook_url}),", not here: a new trigger asks before it moves it."]})),(j==null?void 0:j.ours)&&s&&!f&&t.jsx(B,{className:"mt-2",size:"sm",disabled:b,onClick:()=>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 y(),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(hl,{problem:i})})]})}function gW({server:e,settings:n,busy:s,onSettings:r}){var g;const o=Ec(e.name,"*"),i=((g=n[o])==null?void 0:g.allow_reads)===!0,c=e.tools.filter(b=>b.effect==="read").length,d=`allow-reads-${e.name}`,u=`${d}-words`,f=b=>r(x=>{const{[o]:h,...v}=x,{allow_reads:y,...j}=h??{},k=b?{...j,allow_reads:!0}:j;return Object.keys(k).length?{...v,[o]:k}:v});return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ud,{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 xW({server:e,settings:n,busy:s,onSettings:r}){const o=n==null?void 0:n[Ec(e.name,"*")],i=new Map(e.tools.map(u=>[Ec(e.name,u.name),u])),c=e.tools.map(u=>{var f;return{name:Ec(e.name,u.name),...n?{gate:{name:Ec(e.name,u.name),permission:u.permission??"ask",default_permission:u.default_permission??"ask",permissions:(f=u.permissions)!=null&&f.length?u.permissions:fW}}:{}}}),d=u=>{var g,b;const f=(g=e.prices)==null?void 0:g[u];return f!==void 0?`$${f} a call`:(b=e.not_metered)!=null&&b.includes(u)?"not metered":null};return t.jsx(fy,{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 vW({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(""),b=()=>void e.mcpPrivateHosts().then(v=>{s(v.hosts),o(null)},v=>o(oo(v)));p.useEffect(b,[e]);const x=async v=>{u(!0),c(null);try{return s((await e.saveMcpPrivateHosts(v)).hosts),!0}catch(y){return c(oo(y)),!1}finally{u(!1)}},h=async v=>{v.preventDefault(),n&&f.trim()&&await x([...n,f.trim()])&&g("")};return t.jsxs(Rr,{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:b,className:"mt-3",children:"Try again"})]}),n&&(n.length?t.jsx("ul",{"aria-label":"Allowed private network hosts",className:"border",children:n.map(v=>t.jsxs("li",{"data-host":v,className:"flex items-center justify-between gap-3 border-b px-3 py-2 last:border-b-0",children:[t.jsx("span",{className:"break-all font-mono text-body",children:v}),t.jsx(B,{size:"sm",disabled:d,onClick:()=>void x(n.filter(y=>y!==v)),children:"Remove"})]},v))}):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:v=>void h(v),"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:v=>g(v.target.value),placeholder:"auth.corp.example",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:d||!f.trim(),children:"Allow"})]}),i&&t.jsx(hl,{problem:i})]})}const yW=32;function ZE(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,yW-o.length).replace(/-+$/,"")}${o}`;if(!s.has(i))return i}}function bW({v2:e,add:n,onClose:s,onSaved:r}){var A;const o=p.useRef(null),[i,c]=p.useState((n==null?void 0:n.toolkit)??""),[d,u]=p.useState((n==null?void 0:n.name)??""),[f,g]=p.useState(null),[b,x]=p.useState([]),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=p.useState(!1),S=()=>{var R,P;return(((P=(R=o.current)==null?void 0:R.elements.namedItem("composio-key"))==null?void 0:P.value)??"").trim()},N=async R=>{E(!0),j(null);try{await R()}catch(P){j(oo(P))}E(!1)},$=p.useRef(0),_=()=>{$.current++,g(null)},M=()=>N(async()=>{const R=++$.current;g(null),x([]);const P=await e.composioTools(S(),i.trim().toLowerCase());R===$.current&&(g(P),n!=null&&n.tools&&P.toolkit===n.toolkit&&x(P.tools.map(D=>D.slug).filter(D=>n.tools.includes(D))))}),O=()=>N(async()=>{var P,D;const R=await e.saveComposioServer(d.trim(),S(),f.toolkit,b);(P=o.current)==null||P.reset(),r(),R.connect_url||(D=R.not_served)!=null&&D.length||R.composio?v({connect:R.connect_url,notServed:R.not_served,composio:R.composio}):s()}),L=R=>x(P=>P.includes(R)?P.filter(D=>D!==R):[...P,R]);return h?t.jsxs("section",{"aria-label":"Composio server saved",className:"space-y-3 border bg-card p-4",children:[t.jsxs("p",{className:"text-body",children:["Saved.",h.connect?` Its tools need your ${f==null?void 0:f.toolkit} account: connect it on Composio, then refresh the server.`:""]}),h.connect&&t.jsx("p",{children:t.jsxs("a",{href:h.connect,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-body underline",children:["Connect your ",f==null?void 0:f.toolkit," account"]})}),(A=h.notServed)!=null&&A.length?t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:["Composio's server doesn't list ",h.notServed.join(", "),": a run can't call ",h.notServed.length===1?"it":"them","."]}):null,h.composio&&t.jsx("p",{className:`border p-4 text-body ${h.composio.removed?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:h.composio.note}),t.jsx(B,{size:"sm",onClick:s,children:"Done"})]}):t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:R=>{R.preventDefault(),f&&b.length&&d.trim()&&O()},"aria-label":"Add from Composio",className:"space-y-4 border bg-card p-4",onInput:R=>{R.target.name==="composio-key"&&_()},children:[t.jsx("p",{className:"text-small text-muted-foreground",children:"Composio runs the toolkit's actions for you. This saves an MCP server that grants only the actions you tick, with your Composio key sealed like any credential."}),(n==null?void 0:n.tools)&&t.jsxs("p",{role:"note",className:"text-small text-muted-foreground",children:["A template uses ",n.tools.join(", "),": enter your key and load the actions, and those are ticked."]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Composio API key"}),t.jsx(Pe,{name:"composio-key",...Nf})]}),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:R=>{c(R.target.value),_()},placeholder:"github",spellCheck:!1})]}),y&&t.jsx(hl,{problem:y}),f&&t.jsxs("fieldset",{className:"space-y-2",children:[t.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Actions to grant"}),f.tools.length?t.jsx("ul",{className:"divide-y border",children:f.tools.map(R=>t.jsx("li",{className:"px-3 py-2",children:t.jsxs("label",{className:"flex items-start gap-2 text-body",children:[t.jsx("input",{type:"checkbox",value:R.slug,checked:b.includes(R.slug),onChange:()=>L(R.slug),className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono",children:R.name}),t.jsx("span",{className:"ml-2 font-mono text-small text-muted-foreground",children:R.slug}),R.description&&t.jsx("span",{className:"block text-small text-muted-foreground",children:R.description})]})]})},R.slug))}):t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This toolkit lists no actions."}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",d.trim()||"<name>","/<tool>."]}),t.jsx(Pe,{name:"composio-name",value:d,onChange:R=>u(R.target.value),spellCheck:!1})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:k||!i.trim(),onClick:()=>void M(),children:"Load actions"}),f&&t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:k||!b.length||!d.trim(),children:k?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",disabled:k,onClick:()=>{var R;(R=o.current)==null||R.reset(),s()},children:"Cancel"})]})]})}const wW=/^mcp-(token|scopes|client-id|client-secret|header-(name|value)-\d+)$/,Nf={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},jW=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"],["github_app","GitHub App"]],kW={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in",github_app:"Headers"};function NW({v2:e,saved:n,add:s,given:r,writable:o,taken:i,signIn:c,onCancel:d,onSaved:u}){var De,Ee,re,_e,Qe;const f=p.useRef(null),g=n?void 0:B2(s==null?void 0:s.preset),[b,x]=p.useState(g),[h,v]=p.useState((n==null?void 0:n.name)??(s==null?void 0:s.name)??""),[y,j]=p.useState((n==null?void 0:n.url)??((s==null?void 0:s.auth)==="github_app"?Hf:(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",[_,M]=p.useState((n==null?void 0:n.toolkit)??(g?g.name:s&&!s.auth?s.toolkit??s.name:"")),O=$==="github"?"github":_.trim(),L=()=>{if(k==="github_app")return{};const he=O||null;return n?he!==n.toolkit?{toolkit:he}:{}:he?{toolkit:he}:{}},A=!n&&!!(i!=null&&i.some(he=>he.name===h.trim())),R=!!n||!!i&&!A,[P,D]=p.useState(null),[W,K]=p.useState(r??null),[H,q]=p.useState(!1),F=p.useRef(0),G=()=>{F.current++,D(null)},U=he=>{var Ie,et;return(((et=(Ie=f.current)==null?void 0:Ie.elements.namedItem(he))==null?void 0:et.value)??"").trim()},[z,Y]=p.useState(!1),J=he=>{try{return new URL(he).origin}catch{return he}},X=(he=k)=>{var Ie;return Y(!!n&&he==="oauth"&&(n.auth.type!=="oauth"||U("mcp-scopes")!==(((Ie=n.oauth)==null?void 0:Ie.scopes.join(" "))??"")||!!U("mcp-client-id")||!!U("mcp-client-secret")||J(U("mcp-url"))!==J(n.url)))};p.useEffect(()=>X(),[k]);const le=()=>{if(k==="bearer")return U("mcp-token")?{type:k,token:U("mcp-token")}:{type:k};if(k!=="headers"&&k!=="github_app")return{type:k};const he=Object.fromEntries(Array.from({length:S},(Ie,et)=>[U(`mcp-header-name-${et}`),U(`mcp-header-value-${et}`)]).filter(([Ie,et])=>Ie&&et));return Object.keys(he).length?{type:k,headers:he}:{type:k}},se=async he=>{q(!0),K(null);try{await he()}catch(Ie){K(oo(Ie))}q(!1)},fe=!!(W!=null&&W.needsClient);p.useEffect(()=>{fe&&E("oauth")},[fe]),p.useEffect(()=>{var he,Ie;fe&&k==="oauth"&&((Ie=(he=f.current)==null?void 0:he.elements.namedItem("mcp-client-id"))==null||Ie.focus())},[fe,k]);const xe=()=>R&&se(()=>{const he=U("mcp-scopes").split(/\s+/).filter(Boolean),Ie=U("mcp-client-id");return c(h.trim(),{url:y.trim(),...he.length?{scopes:he}:{},...Ie?{client_id:Ie,...U("mcp-client-secret")?{client_secret:U("mcp-client-secret")}:{}}:{},...L()})}),Ne=()=>{const he=F.current;se(async()=>{try{const Ie=await e.previewMcpServer(y.trim(),le(),n==null?void 0:n.name);he===F.current&&D(Ie)}catch(Ie){if(he===F.current)throw Ie}})},ge=he=>{if(he.preventDefault(),!!R){if(k==="oauth"&&(!n||z))return void xe();se(async()=>{var et;const Ie=await e.saveMcpServer(h.trim(),y.trim(),le(),L());(et=f.current)==null||et.reset(),u(Ie.composio)})}},me=!H&&R&&!!h.trim()&&!!y.trim()&&(!!n||!!P),Le=he=>{var Ie;if(i){for(const et of Array.from(((Ie=f.current)==null?void 0:Ie.elements)??[]))et instanceof HTMLInputElement&&wW.test(et.name)&&(et.value="");N(1),x(he),v(ZE(he.name,i)),j(he.url),E(he.auth),M(he.name),K(null),G()}},Ue=he=>(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. ",he]});return t.jsxs("form",{ref:f,autoComplete:"off",onSubmit:ge,"aria-label":n?`Change ${n.name}`:"Add an MCP server",className:"space-y-4 border bg-card p-4",onInput:he=>{["mcp-name","mcp-toolkit"].includes(he.target.name)||G(),X()},children:[!n&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("span",{className:"caps block text-small font-semibold",children:"Presets"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Jv.map(he=>t.jsx(B,{type:"button",size:"sm",variant:(b==null?void 0:b.id)===he.id?"solid":"outline","aria-pressed":(b==null?void 0:b.id)===he.id,disabled:H||!i||!o&&he.auth!=="none",onClick:()=>Le(he),children:he.label},he.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."}),b&&t.jsx("p",{role:"note","data-mcp-preset":b.id,className:"text-small text-muted-foreground",children:b.note}),(b==null?void 0:b.readOnly)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ud,{checked:y===b.readOnly,label:"Read-only",disabled:H,onChange:he=>{j(he?b.readOnly:b.url),G()}}),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:he=>v(he.target.value),spellCheck:!1}),A&&t.jsxs("span",{role:"alert",className:"mt-1 block text-small text-destructive-text",children:[h.trim()," is saved already: saving would replace it. Change it from its row, or choose another name."]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Address"}),t.jsx(Pe,{name:"mcp-url",value:y,onChange:he=>{j(he.target.value),W!=null&&W.needsClient&&K(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:wd[$]})]}),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:",O||"<toolkit>","/<tool>): applying one uses this server for them."]}),t.jsx(Pe,{name:"mcp-toolkit",value:$==="github"?"github":_,readOnly:$==="github",onChange:he=>M(he.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:jW.map(([he,Ie])=>t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"radio",name:"mcp-auth",value:he,checked:k===he,disabled:!o&&he!=="none",onChange:()=>{E(he),he==="github_app"&&!y.trim()&&j(Hf),G()},className:"accent-primary"}),Ie]},he))})]}),k==="bearer"&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),Ue("A new token replaces it; leave this empty to keep it."),t.jsx(Pe,{name:"mcp-token",...Nf})]}),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:[Ue(`Its headers: ${(Ee=n==null?void 0:n.auth.headers)==null?void 0:Ee.join(", ")}. New ones replace them all; leave the values empty to keep them.`),Array.from({length:S},(he,Ie)=>{var et;return t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Pe,{name:`mcp-header-name-${Ie}`,"aria-label":`Header ${Ie+1} name`,placeholder:"X-Api-Key",defaultValue:(et=n==null?void 0:n.auth.headers)==null?void 0:et[Ie],spellCheck:!1}),t.jsx(Pe,{name:`mcp-header-value-${Ie}`,"aria-label":`Header ${Ie+1} value`,...Nf})]},Ie)}),S<cW&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>N(he=>he+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."}),((re=n==null?void 0:n.oauth)==null?void 0:re.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:(_e=n==null?void 0:n.oauth)==null?void 0:_e.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:fe?"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:fe?"Client secret (if its app has one)":"Client secret (optional)"}),t.jsx(Pe,{name:"mcp-client-secret",...Nf})]})]})]}),W&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(hl,{problem:W}),W.signIn&&k!=="oauth"&&o&&t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:H||!R||!h.trim(),onClick:()=>void xe(),children:"Sign in"})]}),P&&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 ",P.protocol,(Qe=P.server_info)!=null&&Qe.name?` · ${P.server_info.name}${P.server_info.version?` ${P.server_info.version}`:""}`:""," · ",P.tools.length," tool",P.tools.length===1?"":"s"]}),P.instructions&&t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:P.instructions}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:xI}),t.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:P.tools.map(he=>t.jsxs("li",{className:"px-3 py-2",children:[t.jsx("span",{className:"font-mono text-body",children:he.name}),he.title&&t.jsx("span",{className:"ml-2 text-small",children:he.title}),he.description&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:he.description})]},he.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:H||!y.trim(),children:"Sign in again with these settings"}):k==="oauth"?t.jsx(B,{type:"button",size:"sm",variant:n?"outline":"primary",disabled:H||!R||!h.trim()||!y.trim(),onClick:()=>void xe(),children:n?"Sign in again":"Sign in"}):t.jsx(B,{type:"button",size:"sm",disabled:H||!y.trim(),onClick:Ne,children:"Preview"}),(k!=="oauth"||n&&!z)&&t.jsx(B,{type:"submit",size:"sm",variant:W!=null&&W.signIn&&k!=="oauth"&&o?"outline":"primary",disabled:!me,children:H?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{var he;(he=f.current)==null||he.reset(),d()},children:"Cancel"})]})]})}const V0=e=>e instanceof Fe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function SW({v2:e,needs:n,model:s,onSaved:r,writable:o,whyNot:i="sign_in",plan:c,onPlan:d,onDone:u,harnesses:f}){const[g,b]=p.useState(null),[x,h]=p.useState(null),[v,y]=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),M=()=>{const q=++_.current;e.listToolKeys().then(F=>{q===_.current&&(b(F.keys.filter(G=>G.kind==="model")),h(null))}).catch(F=>{q===_.current&&h(V0(F))})};p.useEffect(()=>{n!=="model"&&M()},[e,n]);const O=s!=null&&s.includes("/")&&!qc(s)?s.slice(0,s.indexOf("/")):void 0,L=g==null?void 0:g.find(q=>q.id===O),A=L?[L]:g,R=g==null?void 0:g.find(q=>q.id===v),P=(R==null?void 0:R.fields.filter(q=>{var F;return((F=R.secrets.find(G=>Xf(G.name)===q.name))==null?void 0:F.source)!=="env"}))??[],D=!!E&&n!=="model"&&!O,W=n!=="model"&&(!D||N),K=q=>{S(q),d==null||d(q)},H=f&&t.jsx(qC,{harnesses:f});return D&&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(Ia,{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(kx,{v2:e,view:E,onView:K}),H,t.jsx(B,{type:"button",size:"sm",onClick:()=>u==null?void 0:u(),children:"Done"})]})]})}):t.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Ia,{className:"mt-1 size-4 shrink-0 text-warning-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[t.jsx("h2",{className:"text-prose font-semibold",children:n==="model"?"This server's default model doesn't run":D?"Sign in with ChatGPT or add a model key to run agents":"Add a model key to run agents"}),n==="model"?t.jsx("p",{className:"text-body text-muted-foreground",children:"The server's AGENT_MODEL names a model it doesn't know, so an agent that names no model can't run. Set AGENT_MODEL to a provider/model-id where the server starts, or name a model in each agent."}):L?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 ",L.label," key is set, so an agent that names no model can't run. Save the ",L.label," key: such an agent then runs on that model."]}):D?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"This server has no model yet, so an agent that names no model can't run."}),t.jsx(kx,{v2:e,view:E,onView:K,writable:o,whyNot:i,beside:t.jsx(B,{type:"button",size:"sm","aria-expanded":N,onClick:()=>$(q=>!q),children:"Add a key"})}),t.jsx("p",{className:"text-body text-muted-foreground",children:q2}),N&&t.jsx("p",{className:"text-body text-muted-foreground",children:Tx})]}):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:Tx})]}),W&&x&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The keys could not be read: ",x.code,": ",x.message]}),t.jsx(B,{type:"button",onClick:M,size:"sm",className:"mt-2",children:"Try again"})]}),W&&g&&!o&&t.jsx("p",{className:"text-body",role:"status",children:ti[i]}),W&&g&&o&&t.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:A.map(q=>t.jsx(B,{size:"sm",variant:v===q.id?"solid":"primary","aria-pressed":v===q.id,onClick:()=>{y(v===q.id?null:q.id),k(null)},children:q.label},q.id))}),W&&R&&o&&(P.length?t.jsx(QE,{tool:R,fields:P,onCancel:()=>y(null),onSave:async q=>{k(null);try{await e.saveToolKey(R.id,q)}catch(F){return F instanceof Fe&&F.status===422?F:(k(V0(F)),null)}return y(null),M(),r==null||r(),null}},R.id):t.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",R.label," key when it starts: change it there."]})),j&&t.jsx("div",{className:"border",children:t.jsx(oa,{error:j,title:"The key was not saved"})}),H,t.jsxs("p",{className:"text-small text-muted-foreground",children:["Every key is in ",t.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:"#/settings/keys",children:"Settings"}),"."]})]})]})})}function CW({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 Y0=[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"icloud",label:"iCloud"},{value:"other",label:"Other"}],EW={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."})},$W="Outlook needs Microsoft sign-in, which this server doesn't do yet.";function _W(e){return e==="other"?"Password":"App password"}const TW={configured:!1,preset:null,address:null,user:null,imap:null,smtp:null,password_unreadable:!1},Q0=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"}},J0=e=>e instanceof Fe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},RW=e=>Object.fromEntries((e instanceof Fe?e.fields??[]:[]).map(n=>[n.field,n.message]));function AW({v2:e,writable:n,whyNot:s="sign_in"}){var G;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(Q0(null)),[f,g]=p.useState(""),[b,x]=p.useState(null),[h,v]=p.useState({}),[y,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),$=p.useRef(0),_=U=>{o(U),u(Q0(U))},M=()=>{const U=++$.current;e.emailAccount().then(z=>{U===$.current&&(_(z),c(null))}).catch(z=>{U===$.current&&c(J0(z))})};p.useEffect(()=>{n&&M()},[e,n]);const O=U=>{u(U),j(null)},L=U=>z=>O(Y=>({...Y,[U]:z.target.value})),A=()=>{const U=d.user.trim(),z=d.preset===(r==null?void 0:r.preset)&&r.imap&&r.smtp?{imap:r.imap,smtp:r.smtp}:{};return{preset:d.preset,address:d.address.trim(),...U?{user:U}:{},...f?{password:f}:{},...d.preset==="other"?{imap:{host:d.imapHost.trim(),port:Number(d.imapPort)},smtp:{host:d.smtpHost.trim(),port:Number(d.smtpPort)}}:z}},R=async(U,z)=>{x(null),v({}),N(!0);try{await z()}catch(Y){const J=RW(Y);Object.keys(J).length?v(J):x({title:U,error:J0(Y)})}finally{N(!1)}},P=U=>{U.preventDefault(),R("The account was not saved",async()=>{_(await e.saveEmailAccount(A())),g(""),j(null)})},D=()=>R("The account was not tested",async()=>{j(null),j(await e.testEmailAccount(A()))}),W=()=>R("The account was not removed",async()=>{E(!1),await e.removeEmailAccount(),_(TW),g(""),j(null)}),K=t.jsxs("div",{className:ni,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:Ko,children:[K,t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:ti[s]})]})});if(!r)return i?t.jsx(vt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:M,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The email account could not be read: ",i.code,": ",i.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const H=r.configured||r.password_unreadable,q=d.preset==="other",F=(U,z,Y)=>t.jsxs("div",{className:"grid grid-cols-[1fr_7rem] gap-2",children:[t.jsx(bt,{label:`${z} server`,error:h[`${U}.host`],children:t.jsx(Pe,{name:`${U}_host`,value:U==="imap"?d.imapHost:d.smtpHost,onChange:L(U==="imap"?"imapHost":"smtpHost"),placeholder:Y,spellCheck:!1,autoCapitalize:"off"})}),t.jsx(bt,{label:"Port",error:h[`${U}.port`],children:t.jsx(Pe,{name:`${U}_port`,inputMode:"numeric",value:U==="imap"?d.imapPort:d.smtpPort,onChange:L(U==="imap"?"imapPort":"smtpPort")})})]});return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[K,t.jsxs("div",{className:si,children:[b&&t.jsx(oa,{error:b.error,title:b.title}),i&&t.jsx(vt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:M,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(Rr,{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(DT,{className:"size-4 text-muted-foreground","aria-hidden":!0}),H?t.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:r.address}):t.jsx("span",{className:"text-body text-muted-foreground",children:"No email account is saved. The agents' email tools and email triggers need one."}),r.configured&&t.jsx(ke,{tone:"success",children:"saved"}),H&&r.preset&&t.jsx(ke,{children:((G=Y0.find(U=>U.value===r.preset))==null?void 0:G.label)??r.preset})]}),H&&r.imap&&r.smtp&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["IMAP ",r.imap.host,":",r.imap.port," · SMTP ",r.smtp.host,":",r.smtp.port,r.user&&r.user!==r.address?` · signs in as ${r.user}`:""]}),r.configured&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"Its password is sealed on this server. It is never shown again; type it again only to change the account."}),r.password_unreadable&&t.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),"Its password can't be opened here: it was sealed under another key, or is damaged. The agents can't read or send mail until it is saved again."]})]}),t.jsxs("form",{className:"space-y-4 border bg-card p-4","aria-label":"Account",onSubmit:P,children:[t.jsxs("fieldset",{disabled:S,className:"min-w-0 space-y-4",children:[t.jsx(bt,{label:"Provider",group:"heading",note:$W,error:h.preset,children:t.jsx(dd,{name:"email-preset",label:"Provider",value:d.preset,onChange:U=>O(z=>({...z,preset:U})),options:Y0})}),t.jsx("p",{className:"text-small text-muted-foreground",children:EW[d.preset]}),t.jsx(bt,{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:L("address")})}),t.jsx(bt,{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:L("user")})}),t.jsx(bt,{label:_W(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:U=>{g(U.target.value),j(null)}})}),q&&F("imap","IMAP","imap.example.com"),q&&F("smtp","SMTP","smtp.example.com")]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",variant:"solid",disabled:S||!d.address.trim()||!f,children:"Save"}),t.jsx(B,{type:"button",variant:"outline",disabled:S||!d.address.trim()||!f&&!r.configured,onClick:()=>void D(),children:"Test"}),H&&!k&&t.jsx(B,{type:"button",variant:"outline",disabled:S,onClick:()=>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 W(),children:"Remove the account"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>E(!1),children:"Cancel"})]}),y&&t.jsxs("div",{"aria-label":"Test",className:"space-y-1 font-mono text-body",children:[["imap","smtp"].map(U=>t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(ke,{tone:y[U].ok?"success":"error",children:U==="imap"?"IMAP":"SMTP"}),t.jsx("span",{className:y[U].ok?"":"text-destructive-text",children:y[U].message})]},U)),t.jsx("p",{className:"text-small text-muted-foreground",children:y.ok?"Both signed in. Nothing was sent, and nothing was saved by the test.":"Nothing was sent, and nothing was saved by the test."})]})]})]})]})]})})}const X0=e=>e instanceof Fe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},OW={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 MW({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),[b,x]=p.useState(null),[h,v]=p.useState(!1),[y,j]=p.useState(!1),[k,E]=p.useState(""),S=p.useRef(0),N=()=>{const M=++S.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([O,L])=>{M===S.current&&(s(O),o(L.attempts),c(null))}).catch(O=>{M===S.current&&c(X0(O))})};p.useEffect(N,[e]);const $=async(M,O)=>{g(null),j(!0);try{await O()}catch(L){g({title:M,error:X0(L)})}finally{j(!1)}N()},_=M=>{M.preventDefault(),$("The webhook was not saved",async()=>{const O=await e.saveWebhook(k.trim());O.signing_secret&&u(O.signing_secret);const{signing_secret:L,...A}=O;s(A)})};return n?t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:ni,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:si,children:[f&&t.jsx(oa,{error:f.error,title:f.title}),i&&t.jsx(vt,{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(Rr,{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(rl,{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(ke,{tone:"error",children:"off"}):n.signing==="sealed"?t.jsx(ke,{tone:"success",children:"on"}):t.jsx(ke,{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,", ",ht(n.disabled.at),". Nothing is sent until the URL is saved again: enter it below."]}),n.configured&&n.signing!=="sealed"&&t.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),OW[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:M=>E(M.target.value),className:"h-9 min-w-[280px] flex-1","aria-label":"Webhook URL"}),t.jsx(B,{type:"submit",variant:"solid",disabled:y||!k.trim(),children:"Save"}),n.configured&&t.jsx(B,{type:"button",variant:"outline",disabled:y,onClick:()=>$("The test was not sent",async()=>x(await e.testWebhook())),children:"Send a test"}),n.configured&&!h&&t.jsx(B,{type:"button",variant:"outline",disabled:y,onClick:()=>v(!0),children:"Remove"})]}),h&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-body",children:[t.jsx("span",{children:"Its pending messages are dropped; the log of attempts stays."}),t.jsx(B,{type:"button",variant:"destructive",disabled:y,onClick:()=>{v(!1),E(""),x(null),$("The webhook was not removed",async()=>{await e.removeWebhook(),s({configured:!1,secret:{name:"webhook:outbound",set:!1,source:null,changed_at:null}}),u(null)})},children:"Remove the webhook"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>v(!1),children:"Cancel"})]}),b&&t.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",Z0(b)]})]})}),t.jsx(Rr,{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((M,O)=>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:ht(M.at)}),t.jsx("span",{className:"w-[130px] shrink-0 font-mono",children:M.type}),t.jsx("span",{className:M.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:Z0(M)}),M.redelivery&&t.jsx(ke,{children:"redelivery"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:M.webhook_id,children:[M.webhook_id.slice(0,12),"…"]}),t.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:y,onClick:()=>$("The message was not sent again",()=>e.redeliverWebhook(M.webhook_id)),children:"Redeliver"})]},`${M.webhook_id}:${M.at}:${O}`))})})]})]})}):i?t.jsx(vt,{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 Z0(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 ${ht(e.retry_at)}`:""}`}const PW={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."}},Rx=e=>PW[e]??{label:e,gives:""},LW=e=>e instanceof Fe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},Ax=e=>e.slice(e.lastIndexOf(":")+1),IW=2e3;function zW({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),[b,x]=p.useState({}),[h,v]=p.useState(new Set),y=p.useRef(0),j=p.useCallback(()=>{const $=++y.current;c(null),e.computers().then(_=>{$===y.current&&o(_)},_=>{$===y.current&&c(LW(_))})},[e]);if(p.useEffect(j,[j]),!r)return i?t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The computers could not be read: ",i.code,": ",i.message]}),t.jsx(B,{size:"sm",onClick:j,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Un,{label:"Loading the computers",rows:3})});const k=new Set(r.paired.map($=>$.id)),E=$=>r.kinds.filter(_=>_.providers.some(M=>M.id===$)).map(_=>_.kind),S=async($,_,M)=>{g(null);try{await e.saveComputerKeys(_.id,M)}catch(O){return O instanceof Fe&&O.status===422?O:(g({at:$,words:Ut(O)}),null)}return u(null),j(),null},N=async $=>{v(M=>new Set(M).add($.id));let _;try{const M=await e.testComputer($.id);_=M.ok?{ok:!0,words:M.detail,at:new Date().toISOString()}:{ok:!1,words:M.why,at:new Date().toISOString()}}catch(M){_={ok:!1,words:Ut(M),at:new Date().toISOString()}}x(M=>({...M,[$.id]:_})),v(M=>{const O=new Set(M);return O.delete($.id),O})};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:ni,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:si,children:[t.jsx(UW,{v2:e,paired:r.paired,reload:j}),!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:ti[s]}),r.kinds.map($=>t.jsx(WW,{kind:$,providers:$.providers.filter(_=>!k.has(_.id)),own:$.providers.filter(_=>k.has(_.id)).map(_=>_.name),children:$.providers.filter(_=>!k.has(_.id)).map(_=>{const M=`${$.kind}/${_.id}`;return t.jsx(HW,{v2:e,kind:$.kind,provider:_,writable:n,serves:E(_.id),tested:b[_.id],testing:h.has(_.id),open:(d==null?void 0:d.at)===M?d.mode:null,problem:(f==null?void 0:f.at)===M?f.words:null,onOpen:O=>{u(O?{at:M,mode:O}:null),g(null)},onSave:O=>S(M,_,O),onRemove:async O=>{var A;const L=await S(M,_,{[O]:null});L&&g({at:M,words:((A=L.fields)==null?void 0:A.map(R=>R.message).join(" "))||L.message})},onTest:()=>void N(_)},_.id)})},$.kind))]})]})})}function DW(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=>Rx(o).label).join(", ")||Rx(e.kind).label,n,s,e.arch,r].filter(Boolean).join(" · ")}function FW(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 UW({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),[b,x]=p.useState(null),[h,v]=p.useState(null),y=r?Date.parse(r.code.expires_at)-d:0,j=r!==null&&y>0;p.useEffect(()=>{if(!j)return;const N=setInterval(()=>u(Date.now()),1e3),$=setInterval(s,IW);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),v(null),g(null);try{const N=await e.createPairing();u(Date.now()),o({code:N})}catch(N){v(Ut(N))}c(!1)},E=async N=>{v(null);try{await e.removeComputer(N)}catch($){v(Ut($));return}x(null),s()},S=`${Math.floor(Math.max(0,y)/6e4)}:${String(Math.floor(Math.max(0,y)%6e4/1e3)).padStart(2,"0")}`;return t.jsxs(Rr,{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(DN,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}):t.jsx(Qa,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:N.name}),N.online?t.jsx(ke,{tone:"success",children:"Online"}):t.jsx(ke,{tone:"muted",children:"Offline"}),N.held_by_run&&t.jsxs(ke,{tone:"active",children:["In use by run ",na(N.held_by_run)]}),N.unserved&&t.jsx(ke,{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 ",ht(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:DW(N)}),N.groups.length>0&&t.jsx("p",{"data-offers":!0,className:"mt-1 text-small text-muted-foreground",children:FW(N)}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:`Driver ${N.driver} · paired ${ht(N.created_at)}${N.seen_at?` · last attached ${ht(N.seen_at)}`:""}`})]}),t.jsx(B,{size:"sm",onClick:()=>{x(N.id),v(null)},disabled:b!==null,children:"Remove"})]}),b===N.id&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",N.name,"? Its driver stops dialing and asks for a new code",N.held_by_run?", and the run using it loses it":"","."]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void E(N.id),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>x(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 WW({kind:e,providers:n,own:s,children:r}){const{label:o,gives:i}=Rx(e.kind);return t.jsx(Rr,{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(ke,{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 HW({v2:e,kind:n,provider:s,writable:r,serves:o,tested:i,testing:c,open:d,problem:u,onOpen:f,onSave:g,onRemove:b,onTest:x}){const h=p.useRef(null),v=d&&"paste"in d?d.paste:null,y=d&&"remove"in d?d.remove:null;return t.jsxs("li",{ref:h,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(Qa,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:s.name}),s.ready?t.jsx(ke,{tone:"success",children:"Ready"}):t.jsx(ke,{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&&uy.has(n)&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:dy}),s.secrets.length>0&&t.jsx("ul",{className:"mt-3 space-y-1.5",children:s.secrets.map(j=>{var S;const k=Ax(j.name),E=((S=s.picked)==null?void 0:S.includes(j.name))??!1;return t.jsx(ch,{field:j,required:s.required.includes(j.name),writable:r&&!d,onPaste:E?void 0:()=>void lh(()=>f({paste:k}),()=>{var N,$;return($=(N=h.current)==null?void 0:N.querySelector("form"))==null?void 0:$.elements.namedItem(k)}),onRemove:()=>f({remove:k})},j.name)})}),s.picked&&s.picked.length>0&&s.required.every(j=>s.secrets.some(k=>k.name===j&&k.set))&&t.jsx(BW,{v2:e,provider:s,writable:r&&!d,onSave:g}),i&&t.jsx("p",{"data-test":!0,className:`mt-2 text-small ${i.ok?"text-success-text":"text-destructive-text"}`,children:`${i.ok?"Passed":"Failed"} · ${md(i.at)} · ${i.words}`}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:[s.secrets.length?"":"No key. ","Serves: ",o.join(", ")]})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx(B,{size:"sm",onClick:x,disabled:c,children:c?"Testing…":"Test connection"})})]}),r&&v&&t.jsx(GW,{provider:s.name,name:v,set:s.secrets.some(j=>Ax(j.name)===v&&j.set),onSave:g,onCancel:()=>f(null)}),r&&y&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",y," saved on this server?"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void b(y),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>f(null),children:"Cancel"})]}),u&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:u})]})}function BW({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(x=>`${x.name}:${x.set}:${x.changed_at??""}`).join(" ");p.useEffect(()=>{let x=!0;return i(null),d(null),e.computerChoices(n.id).then(h=>{x&&i(h)},h=>{x&&d(Ut(h))}),()=>{x=!1}},[e,n.id,g]);const b=async(x,h)=>{var y;f({key:x.key,value:h}),d(null);const v=await r({[x.key]:h});f(null),v&&d(((y=v.fields)==null?void 0:y.map(j=>j.message).join(" "))||v.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(x=>{const h=n.secrets.find(y=>Ax(y.name)===x.key),v=(h==null?void 0:h.source)==="env";return t.jsxs("div",{"data-choices":x.key,className:"border bg-card p-3",children:[t.jsx("p",{className:"caps mb-2 text-small font-semibold",children:x.key}),"why"in x?t.jsx("p",{"data-why":!0,className:"font-mono text-small text-warning-text",children:x.why}):t.jsxs(t.Fragment,{children:[t.jsx(Ct,{label:`${n.name} ${x.key}`,value:(u==null?void 0:u.key)===x.key?u.value:x.saved??"",disabled:!s||v||u!==null,options:x.options.map(y=>({value:y.value,label:y.label})),placeholder:"Pick one",onChange:y=>void b(x,y),className:"w-full max-w-md"}),t.jsx("p",{"data-choice-note":!0,className:`mt-2 text-small ${h!=null&&h.set&&x.saved===void 0?"text-warning-text":"text-muted-foreground"}`,children:v?`Set in the environment where AgentRun starts, and that one is used: change ${x.key} there.`:x.saved!==void 0?"Picked and saved on this server.":h!=null&&h.set?`The ${x.key} saved on this server is not one of these any more, and runs still ask for it: pick one.`:x.options.length===1?`The only one, ${x.options[0].label}, is used while none is picked.`:`${x.options.length} to pick from. Pick the one this server's computers use.`})]})]},x.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 GW({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,b]=p.useState(null),x=()=>{var y,j;return((j=(y=i.current)==null?void 0:y.elements.namedItem(n))==null?void 0:j.value)??""},h=()=>{var y;(y=i.current)==null||y.reset(),d(!1)},v=async y=>{var N;y.preventDefault();const j=x();if(!j)return;f(!0),b(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);b(E?{field:E.message,message:S.join(" ")}:{field:null,message:S.join(" ")||k.message})};return t.jsxs("form",{ref:i,autoComplete:"off",onSubmit:y=>void v(y),onInput:()=>d(!!x()),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 qW="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.",eN=[{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)"}],KW=e=>({region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),wr="ARCHIL_API_KEY",VW=e=>e instanceof Fe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function YW({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),[b,x]=p.useState(null),[h,v]=p.useState(!1),[y,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),[$,_]=p.useState(!1),[M,O]=p.useState(!1),L=p.useRef(null),A=p.useRef(0),R=p.useCallback(F=>{o(F),u(KW(F))},[]),P=p.useCallback(()=>{const F=++A.current;c(null),e.archil().then(G=>{F===A.current&&R(G)},G=>{F===A.current&&c(VW(G))})},[e,R]);if(p.useEffect(P,[P]),!r)return i?t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["Archil's settings could not be read: ",i.code,": ",i.message]}),t.jsx(B,{size:"sm",onClick:P,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Un,{label:"Loading Archil's settings",rows:2})});const D=()=>{var F,G;return((G=(F=L.current)==null?void 0:F.elements.namedItem(wr))==null?void 0:G.value)??""},W=async F=>{const G={region:d.region,s3Url:d.s3Url,...d.image?{image:d.image}:{},...F!==void 0?{keys:{[wr]:F}}:{}};v(!0),g(null),x(null);try{const U=await e.saveArchil(G);_(!1),O(!1),R(U)}catch(U){if(U instanceof Fe&&U.status===422){const z={},Y=[];for(const J of U.fields??[]){const X=J.field.startsWith("keys.")?J.field.slice(5):J.field;eN.some(le=>le.name===X)||X===wr?z[X]=J.message:Y.push(J.message)}g({fields:z,message:Y.length?Y.join(" "):Object.keys(z).length?null:U.message})}else x(Ut(U))}finally{v(!1)}},K=F=>{F.preventDefault(),W($&&D()?D():void 0)},H=async()=>{E(!0);try{const F=await e.testArchil();j(F.ok?{ok:!0,words:F.detail,at:new Date().toISOString()}:{ok:!1,words:F.why,at:new Date().toISOString()})}catch(F){j({ok:!1,words:Ut(F),at:new Date().toISOString()})}finally{E(!1)}},q=async()=>{x(null);try{R(await e.archilOff()),N(!1)}catch(F){x(Ut(F))}};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:ni,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:qW})]}),t.jsxs("div",{className:si,children:[!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:ti[s]}),t.jsx(Rr,{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(OT,{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(ke,{tone:"success",children:"On"}):t.jsx(ke,{children:"Off"})}),r.on&&t.jsx("span",{"data-disk":!0,className:"font-mono text-small text-muted-foreground",children:r.region??""}),t.jsx("span",{className:"flex-1"}),t.jsx(B,{size:"sm",onClick:()=>void H(),disabled:k,children:k?"Testing…":"Test"}),r.on&&t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Turn off"})]}),y&&t.jsx("p",{"data-test":!0,className:`mt-3 text-small ${y.ok?"text-success-text":"text-destructive-text"}`,children:`${y.ok?"Passed":"Failed"} · ${md(y.at)} · ${y.words}`}),S&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Turn Archil off? Its keys are kept, for turning it on again."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void q(),children:"Turn off"}),t.jsx(B,{size:"sm",onClick:()=>N(!1),children:"Cancel"})]}),b&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:b}),t.jsxs("form",{ref:L,autoComplete:"off",onSubmit:K,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[eN.map(F=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:F.label}),t.jsx(Pe,{name:F.name,value:d[F.name],placeholder:F.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:G=>{const U=G.currentTarget.value;u(z=>({...z,[F.name]:U}))}}),(f==null?void 0:f.fields[F.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[F.name]})]},F.name)),t.jsx("ul",{children:t.jsx(ch,{field:r.secret,label:wr,writable:n&&!$&&!M,onPaste:()=>void lh(()=>_(!0),()=>{var F;return(F=L.current)==null?void 0:F.elements.namedItem(wr)}),onRemove:()=>O(!0)})}),n&&M&&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 ",wr," saved on this server?"]}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:()=>void W(null),children:"Remove"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>O(!1),children:"Cancel"})]}),n&&$&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:wr}),t.jsx(Pe,{type:"password",name:wr,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(f==null?void 0:f.fields[wr])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[wr]})]}),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 e$="tool_approval_requested";function QW(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 JW(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 ${to(e)} per call`:null}function XW(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 ZW={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 t$(e){var n;if(e instanceof Fe){const s=((n=e.details)==null?void 0:n.reason)==="already_answered"&&typeof e.details.decision=="string"?ZW[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 Ut(e)}const e9=2e3;function n$({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,b]=p.useState(null),[x,h]=p.useState(!1),v=e.destructive===!0,y=p.useRef(!1),j=p.useRef(null),k=p.useRef(!1);p.useEffect(()=>{var N;x||!k.current||(k.current=!1,(N=j.current)==null||N.focus())},[x]);const E=JW(e.price),S=async(N,$)=>{if(y.current)return;y.current=!0,d(!0),f(null),h(!1);const _=o.trim(),M=await($?n(N,void 0,$):n(N,N==="deny"&&_?_:void 0));y.current=!1,d(!1),M?f(M):b(N)};return t.jsxs("section",{"aria-label":"Approval required",className:ae("min-w-0 border border-warning/50 bg-warning/5",s?"p-4":"p-4 md:p-5"),children:[r,t.jsxs("p",{className:ae("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-2"),children:[t.jsx(zN,{className:"size-3.5","aria-hidden":!0})," Approval required"]}),t.jsxs("p",{className:"mt-2 text-prose leading-snug",children:["The agent wants to run ",t.jsx("span",{className:"break-all font-mono text-lead",children:e.tool}),".",v&&t.jsxs(t.Fragment,{children:[" ",t.jsx(ke,{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:XW(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(tn,{value:o,onChange:N=>i(N.target.value),maxLength:e9,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||x,onClick:()=>v?h(!0):void S("allow"),children:"Allow once"}),t.jsx(B,{type:"button",size:"sm",disabled:c,onClick:()=>void S("deny"),children:"Deny"}),c&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]}),x&&t.jsx(t9,{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 t9({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 n9={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 s9({mode:e,onSend:n,sending:s,sent:r,purpose:o}){const i=o??n9[e],[c,d]=p.useState(""),[u,f]=p.useState(!1),g=s||u,b=async()=>{if(!c.trim()||!n||g)return;f(!0);const x=await n(c.trim());f(!1),x!==!1&&d("")};return t.jsxs("form",{className:"border bg-card focus-within:border-foreground",onSubmit:x=>{x.preventDefault(),b()},children:[t.jsx(tn,{bare:!0,id:"composer",rows:2,value:c,readOnly:g,"aria-busy":g,onChange:x=>d(x.target.value),placeholder:i.placeholder,onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),b())},className:"block w-full resize-none px-4 pt-3"}),t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 pb-3",children:[t.jsxs("span",{className:"min-w-0 text-label text-muted-foreground",children:[t.jsx("label",{htmlFor:"composer",className:"font-semibold text-foreground",children:i.label})," · ",r?"Sent. It appears on the timeline when the run takes it.":i.does]}),t.jsxs(B,{type:"submit",size:"sm",disabled:!c.trim()||!n||g,children:[g?"Sending":"Send"," ",t.jsx(CT,{"aria-hidden":!0})]})]})]})}function Jr(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 s$=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${Jr(e.cap_usd)} `:""}spend cap`;function r9({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(Bx,{className:"size-3.5","aria-hidden":!0})," ",s$(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 r$=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,o$=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function o9(e){var n,s;return e instanceof Fe?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 a$({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),[b,x]=p.useState(null),h=p.useRef(!1),v=Number(i),y=i.trim()!==""&&Number.isFinite(v)&&v>0,j=async k=>{if(k==null||k.preventDefault(),!(!y||h.current)){h.current=!0,u(!0),g(null),x(null);try{const E=await o(v);E.note&&x(E.note)}catch(E){g(o9(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 ${Jr(e)}`,className:"h-9 w-32"})]}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:d||!y,children:d?"Raising":r?"Raise the cap and continue":"Raise the cap"})]}),(s!==null||n!==null)&&t.jsxs("ul",{className:"mt-2 space-y-0.5 font-mono text-small","aria-label":"Cap figures",children:[s!==null&&t.jsxs("li",{"data-cap-figure":"least",children:["Least to continue: ",Jr(s)]}),n!==null&&t.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",Jr(n)]})]}),n!==null&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The suggestion is prefilled; change it before you raise, if you like."}),f&&t.jsx("p",{className:"mt-2 text-body text-destructive-text",role:"alert",children:f}),b&&t.jsx("p",{className:"mt-2 text-body text-muted-foreground",role:"status",children:b})]})}function a9({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(Kx,{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(sl,{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 tl=0;const Ox=()=>{var n;const e=(n=history.state)==null?void 0:n.console_at;return typeof e=="number"?e:void 0},tN=e=>{tl=e,history.replaceState({...history.state??{},console_at:e},"")};function i9(){const e=Ox();e===void 0?tN(0):tl=e;const n=()=>{const s=Ox();s===void 0?tN(tl+1):tl=s};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)}function l9(){const e=Ox();return e===void 0?-1:tl-e}function c9(e){tl>0?history.back():location.hash=e}const d9=(e,n)=>{const s=kl(e),r=hd(e)?K2:void 0;return s?r?`${gk(s,{ended:n})} ${r}`:gk(s,{ended:n}):e&&e.usd!==null&&XS(e)?r?`A local estimate, not a bill. ${r}`:"A local estimate, not a bill":r};function u9({run:e,agentName:n,actions:s={},costText:r}){var E,S,N;const o=es(e),i=o?"your backend":ZP(e.place),c=Um(e.status,e.state,e.kind,Fm,!0,e.error,e.review,e.computer),d=o?{...c,canStop:!1,canCancel:!1}:c,[u,f]=p.useState(!1),g=!!e.archived_at,b=(E=e.cost)==null?void 0:E.cap_usd,x=!!e.pending&&e.pending.kind!=="budget"&&e.pending.kind!=="stopped",h=!o&&!!s.onRaiseCap&&!d.final&&typeof b=="number"&&!x,[v,y]=p.useState(!1),j=((S=e.pending)==null?void 0:S.kind)==="budget"?e.pending:null,k=!!hd(e.cost);return t.jsxs("header",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[t.jsxs("nav",{className:"caps flex min-w-0 items-center gap-2 text-label text-muted-foreground","aria-label":"Breadcrumb",children:[t.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:()=>c9(cn(e.agent_id)),className:"-m-1.5 shrink-0 p-1.5 hover:text-foreground",children:t.jsx(Rn,{className:"size-3.5","aria-hidden":!0})}),t.jsx("a",{href:cn(e.agent_id),className:"-my-1 truncate py-1 hover:text-foreground hover:underline",children:n}),t.jsx("span",{"aria-hidden":!0,children:"/"}),t.jsxs("span",{className:"truncate",children:["Run ",na(e.run_id)]})]}),t.jsxs("div",{"data-phone-row":!0,className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 max-sm:mt-2 max-sm:flex-row max-sm:flex-wrap max-sm:items-center max-sm:gap-x-3 max-sm:gap-y-2 sm:flex-row sm:flex-wrap",children:[t.jsxs("div",{className:"min-w-0 flex-1 self-stretch max-sm:contents sm:basis-64",children:[t.jsx("h1",{className:"line-clamp-2 break-words text-2xl font-semibold leading-tight max-sm:basis-full max-sm:text-lg",title:Sn(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?n:Sn(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(Cl,{run:e}),g&&t.jsx(ke,{tone:"muted",children:"Archived"}),e.approvals==="never"&&t.jsx(ke,{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:[Yo(o.runtime)," · ",((N=e.sdk)==null?void 0:N.model)??"Model not reported"]}),t.jsx("span",{className:"font-mono",children:ht(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:xk(e.cost,b,{text:r})}):t.jsxs("span",{className:"font-mono",title:d9(e.cost,Ba(e.status)),children:[xk(e.cost,b,{ended:Ba(e.status)}),k&&t.jsxs(t.Fragment,{children:[" · ",t.jsx(my,{})]})]}),t.jsx(iy,{run:e,link:!0}),t.jsx(KE,{run:e})]}),e.status==="completed"&&e.review&&t.jsxs("p",{className:"mt-2 text-body text-warning-text max-sm:mt-0 max-sm:basis-full",children:["Needs review: ",e.review.reason]})]}),(d.canStop||d.canCancel||s.onArchive||h)&&t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[h&&t.jsxs(B,{size:"sm",onClick:()=>y($=>!$),"aria-expanded":v,title:`Raise its ${Jr(b)} spend cap.`,children:[t.jsx(Bx,{"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(JT,{"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(RN,{"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(TN,{"aria-hidden":!0}):t.jsx(nd,{"aria-hidden":!0})," ",s.busy==="archive"?g?"Unarchiving":"Archiving":g?"Unarchive":"Archive"]})]})]}),h&&v&&t.jsx("div",{className:"mt-3 max-w-xl",children:t.jsx(a$,{cap:b,suggested:r$(j),least:o$(j),paused:!!j,onRaise:s.onRaiseCap},j?`${e.run_id}:${j.at}`:`${e.run_id}:working`)})]})}const f9=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function m9({view:e,onView:n}){return t.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:f9.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 i$=(e,n)=>n?e:e.filter(s=>!j2(s.path));function h9({files:e,onOpen:n,showHidden:s,onShowHidden:r}){const o=e.filter(d=>j2(d.path)).length,i=i$(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(RT,{className:"size-3.5","aria-hidden":!0})," Files · ",i.length," ",i.length===1?"file":"files"," (",il(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(Ya,{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:ht(d.modified_at)}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:il(d.size_bytes)})]})},d.path))})]})}function p9({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 y=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=y==null?void 0:y.focus)==null||E.call(y)}},[]),p.useEffect(()=>c(!1),[e.path]);const u=p.useRef(!1),f=p.useRef(!1),g=AP(e),[b,x]=p.useState(g==="markdown"?"rendered":"raw");p.useEffect(()=>x(g==="markdown"?"rendered":"raw"),[e.path]);const h=$v(y=>{const j=r.find(k=>k.path===y);j&&(o==null||o(j))}),v=()=>{if(n===null)return;const y=URL.createObjectURL(new Blob([n],{type:e.content_type??"application/octet-stream"}));Object.assign(document.createElement("a"),{href:y,download:e.path.split("/").pop()}).click(),URL.revokeObjectURL(y)};return t.jsx("dialog",{ref:d,"aria-label":e.path,onCancel:y=>{y.preventDefault(),s()},onMouseDown:y=>{u.current=y.target===y.currentTarget},onMouseUp:y=>{f.current=y.target===y.currentTarget},onClick:y=>{u.current&&f.current&&y.target===y.currentTarget&&s(),u.current=f.current=!1},className:"m-0 h-full max-h-none w-full max-w-none border-0 bg-transparent p-0 text-foreground backdrop:bg-overlay/60 md:p-8",children:t.jsxs("div",{className:"mx-auto flex h-full w-full max-w-5xl flex-col border bg-background",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2.5",children:[t.jsx(B,{size:"icon",variant:"ghost",onClick:s,"aria-label":"Close",children:t.jsx(Xo,{"aria-hidden":!0})}),t.jsx(Ya,{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(m9,{view:b,onView:x})}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:async()=>{var y;n!==null&&(await((y=navigator.clipboard)==null?void 0:y.writeText(n)),c(!0))},children:[t.jsx(Va,{"aria-hidden":!0})," ",i?"Copied":"Copy"]}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:v,children:[t.jsx($T,{"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."}):b==="rendered"?t.jsx("article",{className:"report mx-auto max-w-3xl",onClick:h,dangerouslySetInnerHTML:{__html:so(n,o&&{paths:r.map(y=>y.path),from:e.path.split("/").slice(0,-1).join("/")})}}):t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-small leading-[1.8]",children:n})}),t.jsxs("footer",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["File · ",n===null?"...":`${n.length.toLocaleString("en-US")} characters`," · ",e.content_type??"unknown type"]})]})})}function g9(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((x,h)=>h>c&&f.test(x));if(g<0)break;const b=d[2].trim().toLowerCase();o=b==="json"||b===""?{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 x9=e=>e.replace(/[_-]+/g," ").trim()||e,wc=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;function im(e,n){let s=wc(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=wc(o.reduce((f,g)=>{var b;return(b=wc(f))==null?void 0:b[g]},n))??{},u=d.properties||c.properties?{...wc(d.properties),...wc(c.properties)}:void 0;s={...d,...c,...u?{properties:u}:{}}}return s}const v9=(e,n)=>{var s;return((s=im(e,n))==null?void 0:s.contentMediaType)==="text/markdown"};function Ry({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=im(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(Ry,{value:c,schema:i,root:s,linked:r})},d))})}return typeof e=="object"?t.jsx(l$,{record:e,schema:n,root:s,linked:r}):typeof e=="string"&&v9(n,s)?t.jsx("article",{"data-json-markdown":!0,className:"report max-w-none",dangerouslySetInnerHTML:{__html:so(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 l$({record:e,schema:n,root:s,linked:r}){var i;const o=(i=im(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=im(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:x9(c)}),t.jsx("dd",{className:"mt-1 min-w-0 text-prose leading-relaxed",children:t.jsx(Ry,{value:d,schema:u,root:s,linked:r})})]},c)})})}function nN({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(l$,{record:e,schema:n,root:n,linked:s})})]})}function y9({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(Ry,{value:e,schema:n,root:n,linked:s})})}function b9({run:e,rows:n,files:s=[],onOpen:r,schema:o}){var b,x,h,v,y;const i=((b=e.result)==null?void 0:b.final_answer)??((x=n.findLast(j=>j.kind==="final_answer"))==null?void 0:x.text)??null,c=r?{paths:s.map(j=>j.path)}:void 0,d=$v(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(nN,{record:u,schema:o,linked:c}):t.jsx(y9,{value:u,schema:o,linked:c})});const f=e.kind==="agentic"?(v=e.result)==null?void 0:v.output_error:void 0,g=f?t.jsx(vt,{tone:"warning",title:"The answer did not match the output schema",children:f}):null;if(i!=null&&i.trim()){const j=g9(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:so(j.words,c)}}),t.jsx(nN,{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:so(i,c)}})]})}if(g)return g;if(((y=e.result)==null?void 0:y.output)!==void 0&&e.result.output!==null){const j=e.result.output,k=j&&typeof j=="object"&&!Array.isArray(j)?Object.entries(j).filter(S=>typeof S[1]=="string"&&S[1].includes(`
|
|
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:so(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 w9({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",yd(e.runtime)],["Project",e.project],["Selector",Wv(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":to(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 j9={seeded:"Prepared",reflecting:"Reflecting",proposed:"Under review",merged:"Saved",dropped:"Not saved",pending:"Awaiting approval"},ff=e=>typeof e=="number"&&Number.isFinite(e)?e.toLocaleString("en-US"):"Not reported";function k9({run:e,read:n,onViewChanges:s}){var y,j,k,E,S,N,$,_,M,O,L;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=(y=e.learning)==null?void 0:y.state,b=(j=e.learning)==null?void 0:j.at;p.useEffect(()=>{let A=!0;if(!u){o({data:void 0,reading:!1});return}return o(R=>({...R,error:void 0,reading:!0})),Promise.resolve().then(()=>d.current()).then(R=>{if(R&&R.run!==f)throw new Error("The learning result belongs to a different run. Refresh to try again.");A&&o({data:R,reading:!1})}).catch(R=>{A&&o(P=>({...P,error:R??new Error("The learning result could not be read."),reading:!1}))}),()=>{A=!1}},[f,g,b,u,i]),p.useEffect(()=>{const A=()=>{document.hidden||c(R=>R+1)};return window.addEventListener("focus",A),document.addEventListener("visibilitychange",A),()=>{window.removeEventListener("focus",A),document.removeEventListener("visibilitychange",A)}},[]);const x=r.data,h=()=>c(A=>A+1),v=(k=x==null?void 0:x.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"}),x&&t.jsx(ke,{children:j9[x.state]??x.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(fr,{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(Jo,{"aria-hidden":!0})})]})]}),r.reading&&t.jsx("p",{className:"px-5 py-3 text-body text-muted-foreground",role:"status",children:x===void 0?"Reading learning result…":"Refreshing learning result…"}),r.error!==void 0&&t.jsxs("div",{className:"space-y-2 p-4",children:[x!==void 0&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Showing the last result read."}),t.jsx(Qt,{problem:Wt(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&&x===null&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"No learning result was recorded for this run."}),x&&t.jsxs("div",{className:"space-y-6 p-5",children:[t.jsxs("div",{children:[x.detail&&t.jsx("p",{className:"break-words text-body leading-relaxed",children:x.detail}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-label text-muted-foreground",children:[x.at&&t.jsxs("span",{children:["Updated ",ht(x.at)]}),x.reason&&t.jsxs("span",{children:["Reason: ",x.reason]})]})]}),t.jsxs("section",{"aria-label":"Grader decision",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"Grader decision"}),x.verdict?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-small text-muted-foreground",children:x.verdict.merge?(E=x.verdict.items)!=null&&E.some(A=>!A.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:x.verdict.reason}),(S=x.verdict.items)!=null&&S.length?t.jsx("ul",{className:"mt-3 divide-y border",children:x.verdict.items.map((A,R)=>t.jsxs("li",{className:"space-y-2 p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("code",{className:"min-w-0 break-all text-small",children:A.file}),t.jsx(ke,{tone:A.pending?"warning":A.keep?"success":"muted",children:A.pending?"Needs approval":A.keep?"Keep":"Do not keep"})]}),t.jsx("p",{className:"break-words text-body leading-relaxed text-muted-foreground",children:A.why}),A.question&&t.jsx("p",{className:"text-small",children:A.question}),A.origin&&t.jsx("p",{className:"text-label text-muted-foreground",children:A.origin==="you"?"From your instruction":`Origin: ${A.origin}`})]},`${A.file}-${R}`))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"No item decisions reported."})]}):t.jsx("p",{className:"text-body text-muted-foreground",children:Vm(x)?"No grader decision recorded yet.":"No grader decision was recorded for this run."})]}),!!((N=x.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:[x.pending.map(A=>A.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"}),($=x.problems)!=null&&$.length||(_=x.draft_errors)!=null&&_.length?t.jsxs("ul",{className:"space-y-3",children:[(M=x.problems)==null?void 0:M.map((A,R)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"text-body",children:A.detail}),t.jsx("p",{className:"mt-1 break-all font-mono text-label text-muted-foreground",children:[A.rule,A.path].filter(Boolean).join(" · ")})]},`problem-${R}`)),(O=x.draft_errors)==null?void 0:O.map((A,R)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"mb-1 font-mono text-label text-muted-foreground",children:"Workflow draft"}),t.jsx("p",{className:"break-words text-body",children:A})]},`draft-${R}`))]}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No validation problems reported."})]}),t.jsxs("section",{"aria-label":"Grading usage",children:[t.jsx("h3",{className:"mb-3 text-body font-semibold",children:"Grading usage"}),t.jsx("dl",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[["Grading cost",typeof((L=x.cost_usd)==null?void 0:L.grade)=="number"?Pa(x.cost_usd.grade):"Not reported"],["Input",ff(v==null?void 0:v.input)],["Output",ff(v==null?void 0:v.output)],["Cache reads",ff(v==null?void 0:v.cache_read)],["Cache writes",ff(v==null?void 0:v.cache_write)]].map(([A,R])=>t.jsxs("div",{className:"border p-3",children:[t.jsx("dt",{className:"mb-1 text-label text-muted-foreground",children:A}),t.jsx("dd",{className:"font-mono text-body",children:R})]},A))}),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(fr,{"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:x.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:x.merged??"Not merged"})]})]})]})]})]})}const sN=32,N9=360,S9=.7;function C9(e,n){const s=e.getBoundingClientRect().top;if(!n)return window.innerHeight-(s+window.scrollY)-sN;const r=s-n.getBoundingClientRect().top+n.scrollTop;return n.clientHeight-r-sN}const E9=(e,n)=>Math.round(Math.max(N9,Math.min(e,n*S9)));function $9(e,n,s=3e3,r=Math.min(s,_9),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),b=p.useRef(!1),x=p.useRef(0),h=p.useRef(null),v=p.useRef(null),y=p.useRef(o);y.current=o,p.useEffect(()=>{o&&(v.current=null)},[o]);const j=!!e;p.useEffect(()=>{if(!j||d)return;if(n||(v.current=null),!n&&g.current&&!b.current){c(M=>M&&rN(M));return}let E=!0,S;const N=M=>{clearTimeout(S),S=setTimeout(()=>{h.current=null,_()},M),h.current=()=>N(r)};let $=!1;const _=async()=>{try{const M=await f.current();if(!E)return;g.current=!0,M.state==="live"&&!y.current&&(v.current=M.kind);const O=M.state==="none"&&M.session==="opening"&&M.kind!=="browser"&&M.kind===v.current?{...M,session:"closed"}:M;b.current=O.state==="none"&&O.session==="unopened",$=O.state==="none"&&O.session==="opening"||O.state==="live"&&O.hold==="pending",O.state==="off"?c(null):c(n?L=>R9(L,O)?L:O:rN(O))}catch(M){if(!E)return;if(M instanceof Fe&&M.status===401){u(!0),c(O=>O?{state:"signed_out"}:null);return}if(M instanceof Fe&&M.status===403){u(!0),c(null);return}}E&&n&&N($||Date.now()<x.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),x.current=Date.now()+T9,(S=h.current)==null||S.call(h)},[]);return{view:i,held:k}}const _9=400,T9=4e3,R9=(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))},rN=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"},A9={browser:PN,desktop:Qa,phone:DN,sandbox:ZT},O9={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},M9={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function P9({runId:e,screen:n,machine:s,opens:r,followUp:o,metered:i,waitsFor:c,keptUntil:d,onTake:u,onHand:f}){const g=p.useRef({viewer:"",n:0});(n==null?void 0:n.state)==="live"&&n.viewer!==g.current.viewer&&(g.current={viewer:n.viewer,n:g.current.n+1});const b=n&&n.state!=="signed_out"?n.kind:(s==null?void 0:s.kind)??"browser",x=(n==null?void 0:n.state)==="live"?F9(n.viewer,e):void 0,h=x&&b!=="browser"?`${x}${x.includes("#")?"&":"#"}hands=page`:x,v=A9[b],y=(n==null?void 0:n.state)==="live"?n:null,[j,k]=p.useState(!1),[E,S]=p.useState(null),N=async F=>{if(!(!F||j)){k(!0),S(null);try{S(await F())}finally{k(!1)}}},$=y&&h&&b!=="browser"?y:null,[_,M]=p.useState(!1),O=p.useRef(null),L=p.useRef(null),A=p.useRef(null),R=p.useRef(!1),P=!!(y&&h);p.useEffect(()=>{P||M(!1)},[P]);const[D,W]=p.useState(void 0);p.useLayoutEffect(()=>{const F=O.current;if(b!=="phone"||_||!P||!F)return;const G=F.closest("[data-scroll-pane]"),U=()=>W(E9(C9(F,G),window.innerHeight));U();const z=typeof ResizeObserver=="function"&&G?new ResizeObserver(U):void 0;if(G)for(const Y of[G,...G.children])z==null||z.observe(Y);return window.addEventListener("resize",U),()=>{z==null||z.disconnect(),window.removeEventListener("resize",U)}},[b,_,P,E,i,g.current.n]),p.useEffect(()=>{var F,G,U;if(_){R.current=!0,(G=(F=L.current)==null?void 0:F.querySelector("button"))==null||G.focus();return}R.current&&(R.current=!1,(U=A.current)==null||U.focus())},[_]),p.useEffect(()=>{if(!_)return;const F=J=>{if(J.key==="Escape"){M(!1);return}if(J.key!=="Tab"||!L.current)return;const X=[...L.current.querySelectorAll("button:not([disabled]), iframe")];if(!X.length)return;const le=X[0],se=X[X.length-1],fe=document.activeElement;L.current.contains(fe)?J.shiftKey&&fe===le?(J.preventDefault(),se.focus()):!J.shiftKey&&fe===se&&(J.preventDefault(),le.focus()):(J.preventDefault(),le.focus())},G=J=>{J.key==="Escape"&&M(!1)};document.addEventListener("keydown",F);const U=O.current;let z=null;const Y=()=>{try{z==null||z.removeEventListener("keydown",G,!0)}catch{}try{z=(U==null?void 0:U.contentWindow)??null,z==null||z.addEventListener("keydown",G,!0)}catch{z=null}};return Y(),U==null||U.addEventListener("load",Y),()=>{document.removeEventListener("keydown",F),U==null||U.removeEventListener("load",Y);try{z==null||z.removeEventListener("keydown",G,!0)}catch{}}},[_,g.current.n]);const K=y?b==="browser"?"browser · take over in the view below":`${M9[y.hold]} · ${b}`:"",H=$&&($.hold==="person"?t.jsx(B,{size:"sm",variant:"solid",disabled:j,onClick:()=>void N(f),children:"Hand back"}):t.jsx(B,{size:"sm",variant:"solid",disabled:j||$.hold==="pending",onClick:()=>void N(u),children:$.hold==="pending"?"Taking over":"Take over"})),q=P&&t.jsx(B,{ref:_?void 0:A,size:"sm",variant:"ghost",onClick:()=>M(F=>!F),"aria-label":_?"Exit full window (Esc)":"Fill the window",title:_?"Exit full window (Esc)":"Fill the window","aria-pressed":_,children:_?t.jsx(HT,{className:"size-4","aria-hidden":!0}):t.jsx(FT,{className:"size-4","aria-hidden":!0})});return t.jsxs("section",{"aria-label":"Screen",className:"border",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2.5",children:[t.jsx(v,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:y?"Live":O9[b]}),t.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:K}),!_&&q,!_&&H]}),i&&b!=="browser"&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:dy}),!_&&E&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:E}),y&&h?t.jsxs("div",{ref:L,"data-testid":"screen-frame",className:_?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:_?"dialog":void 0,"aria-modal":_?!0:void 0,"aria-label":_?"The run's screen, filling the window":void 0,children:[_&&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}),q,H]}),_&&E&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:E}),t.jsx("iframe",{ref:O,src:h,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:_?"block min-h-0 w-full flex-1 bg-background":b==="phone"?ae("mx-auto block aspect-[9/19] max-w-full bg-background",D===void 0&&"h-[70vh]"):"block aspect-[16/10] w-full bg-background",style:!_&&b==="phone"&&D!==void 0?{height:`${D}px`}:void 0},g.current.n)]}):t.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:D9(b,n,s,r,o,c,d)})]})}const L9={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."},I9=/^The (desktop|phone) is kept for (\d+) minutes while you decide\.$/;function z9(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=I9.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 D9(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`${L9[i]} The ${e} is kept until ${oN(c).replace(/^at /,"")}.`;if(r&&(n==null?void 0:n.state)==="none"&&n.ended)return e==="browser"?`${n.ended.why} (${oN(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 oN(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:`at ${n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function F9(e,n){let s;try{s=new URL(e,location.origin).href}catch{return}const r=dr(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 Bi=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 Mx(e,n){var s;if(e instanceof Fe&&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 Fe&&e.code==="computer_not_live"?e.message:e instanceof Fe&&e.status===404?n==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof Fe&&e.status===403?"Sign in with your password to do this from here.":`${n==="hand"?"Not answered":"Not taken"}: ${Ut(e)}`}function d$({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 b=>{if(!n||f.current)return;f.current=!0,c(!0),u(null);let x=!1;try{const h=await n(b);x=h===null,u(h)}finally{x||(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(Qa,{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 ",ht(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 U9(e,n){const s=!!n&&Vc(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:dD(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 W9({got:e,retry:n}){if(e.state==="read"&&!e.changes.length)return null;const s=e.state==="failed"?Wt(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(H9,{change:r})},r.file))})]})}function H9({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(Es,{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(aN,{name:"before",lines:e.before,none:"Not there before."}),t.jsx(aN,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function aN({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 B9=4e3,G9=e=>!!e.learning&&e.learning.reason!=="use",q9="The agent looks back on your words: what was wrong, and what a right answer does.",K9="A look-back needs words. Without them the grade is still kept.",V9='A JSON object of the fields a right answer holds, like {"total": 42}. Replays of a learned workflow are scored against it.',iN='Write it as a JSON object, like {"total": 42}, or leave it empty.';function Y9(e){if(!e.trim())return{};try{const n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{value:n}:{error:iN}}catch{return{error:iN}}}function Q9(e){const n=Wt(e,"the grade");return e instanceof Fe&&e.status<500&&n.said?n.said:`${n.why} ${n.next}`}const J9="The review could not run.";function X9(e,n,s){var r;if(e.feedback&&e.feedback_status==="not_run")return J9;if(e.feedback==="look_back")return n?"The agent is looking back on your words.":"The agent looked back on your words.";if(e.feedback==="revise"){if(n)return"The learned workflow that answered is being revised with your grade.";const o=(s==null?void 0:s.state)==="merged"?(r=s.workflows)==null?void 0:r.find(i=>!e.workflow||i.name===e.workflow):void 0;return o?o.pending?"The learned workflow that answered was revised with your grade. The revision waits for your OK.":"The learned workflow that answered was revised with your grade.":"The agent looked back at your grade; nothing changed."}return"Kept for this agent."}function Z9({run:e,graded:n,onGrade:s,onOpenTimeline:r}){const[o,i]=p.useState("auto"),[c,d]=p.useState(""),[u,f]=p.useState(""),[g,b]=p.useState(!1),[x,h]=p.useState(!1),[v,y]=p.useState(null),j=p.useRef(!1),k=Ba(e.status),E=n!=null&&n.feedback?n.feedback_status:null,S=E==="running"||E==="ended"&&Vm(e.learning??void 0);if(!G9(e)||!k&&!n)return null;const N=o==="auto"?n?"closed":"choose":o,$=k&&!S,_=Y9(u),M=n?X9(n,S,e.learning):null,O=async L=>{if(j.current||!s)return;const A=L?"":c.trim();if(!L&&_.error){b(!0);return}j.current=!0,h(!0),y(null);try{await s({correct:L,...A?{label:A}:{},...!L&&_.value?{expected:_.value}:{}}),i("auto"),d(""),f(""),b(!1)}catch(R){y(Q9(R))}j.current=!1,h(!1)};return t.jsxs("section",{className:"border","aria-label":"Grade",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Grade"}),n&&t.jsxs(ke,{tone:n.correct?"success":"error",children:["Graded ",n.correct?"right":"wrong"]}),S&&t.jsx(ke,{tone:"active",children:"Reviewing"}),t.jsx("span",{className:"flex-1"}),n&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(n.graded_at)})]}),t.jsxs("div",{className:"space-y-3 px-4 py-3",children:[M&&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:M}),r&&!!(n!=null&&n.feedback)&&t.jsx(B,{type:"button",size:"xs",variant:"ghost",onClick:r,children:"Open the Timeline"})]}),$&&N==="closed"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:!s,onClick:()=>{i("choose"),y(null)},children:"Grade again"}),t.jsx("span",{className:"text-small text-muted-foreground",children:"A new grade replaces this one."})]}),$&&N==="choose"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"Was the answer right? Your grade teaches the agent."}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:x||!s,onClick:()=>void O(!0),children:"Right"}),t.jsx(B,{type:"button",size:"sm",disabled:x||!s,onClick:()=>{i("wrong"),y(null)},children:"Wrong"}),n&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",disabled:x,onClick:()=>i("closed"),children:"Cancel"}),x&&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:L=>{L.preventDefault(),O(!1)},children:[t.jsx(bt,{label:"What was wrong?",note:q9,warning:c.trim()?void 0:K9,children:t.jsx(tn,{value:c,onChange:L=>d(L.target.value),maxLength:B9,rows:3,disabled:x,className:"resize-y font-sans text-lead"})}),t.jsx(bt,{label:"Correct answer",optional:!0,note:V9,error:g?_.error:void 0,children:t.jsx(tn,{value:u,onChange:L=>{f(L.target.value),b(!1)},rows:2,disabled:x,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:x,children:"Send grade"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",disabled:x,onClick:()=>{i(n?"closed":"choose"),b(!1)},children:"Cancel"}),x&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),v&&t.jsxs("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:["Your grade wasn't taken: ",v]})]})]})}const eH=(e,n)=>n&&(!e||Date.parse(n.graded_at)>Date.parse(e.graded_at))?n:e;function tH(e,n,s){const r=!!s&&!!e.learning,[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,b]=p.useState(0);p.useEffect(()=>{if(!r)return;let j=!0;return Promise.resolve().then(()=>s()).then(k=>{j&&(i(k??null),f(0))},()=>{j&&(i(null),f(k=>k+1))}),()=>{j=!1}},[e.run_id,r,n,e.ended_at,g]);const x=p.useCallback(({expected:j,...k})=>{d({run:k.run_id,grade:{...k,feedback_status:k.feedback?"running":null}})},[]),h=r?o:null,v=eH((h==null?void 0:h.graded)??null,(c==null?void 0:c.run)===e.run_id?c.grade:null),y=r&&(v==null?void 0:v.feedback_status)==="running";return p.useEffect(()=>{if(!y||u===0||u>nH)return;const j=setTimeout(()=>b(k=>k+1),nx(u-1));return()=>clearTimeout(j)},[y,u]),{read:h,grade:v,graded:x}}const nH=8,sH=e=>e===1?"once":e===2?"twice":`${e} times`;function rH({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:Ym(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(Sf,{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(ke,{tone:"success",children:"Read"}):t.jsx(ke,{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(Ja,{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 ",sH(s.calls)]}),s.failed>0&&t.jsxs(ke,{tone:"error",children:[s.failed," failed"]})]},`workflow:${s.name}`))]})]})}const zi=(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}),Ar=(e,n=[])=>({type:"object",additionalProperties:!1,properties:e,...n.length?{required:n}:{}}),oH={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:Ar({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},aH=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."}),iH=e=>`Browse and automate websites in the persistent browser. ${aH.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"}]}.`,lH={name:"run",label:"Browser: run",description:iH(),parameters:Ar({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},zi("click"),zi("hover"),zi("fill",{value:{type:"string"}}),zi("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),zi("press",{key:{type:"string"}}),zi("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},cH={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:Ar({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:{...Ar({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"},dH={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:Ar({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},uH={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:Ar({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},fH={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:Ar({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"},mH={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:Ar({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"},hH={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:Ar({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},pH={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:Ar({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"},gH=Object.freeze([oH,lH,cH,dH,uH,fH,mH,hH,pH]),xH=Object.freeze(gH.map(e=>e.name)),vH={"com.apple.systempreferences":"System Settings","com.apple.iCal":"Calendar","com.apple.finder":"Finder","com.android.settings":"Settings","com.android.chrome":"Chrome","xfce4-terminal":"Terminal","org.xfce.terminal":"Terminal",xterm:"XTerm","firefox-esr":"Firefox","google-chrome":"Chrome"};function yH(e){const n=e.split(".").at(-1)||e;return vH[e]??(n?n[0].toUpperCase()+n.slice(1):e)}const bH=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"]),wH=new Set(["ctrl","alt","super"]);function jH(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=>wH.has(r))||s.every(r=>bH.has(r))?e:void 0}const kH=["press","set","perform","click","type","key","nav","scroll","drag"];function NH(e,n){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=kH.find(u=>u in s)??"step",o=r==="type"?s.into:s[r],i=typeof o=="string"?n(o):void 0,c=r==="key"?jH(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 SH={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"},CH=new Set(["button","link","menuitem","tab","listitem","row","cell","radio","generic","text","heading"]);function EH(e){if(!e)return;const n=SH[e.role]??(e.role==="generic"?"element":e.role);return e.name?CH.has(e.role)?`“${e.name}”`:`the ${n} “${e.name}”`:`the ${n}`}const $H={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"]},_H={super:"⌘",shift:"⇧",alt:"⌥",ctrl:"⌃"},Tg={enter:"Return",escape:"Esc",tab:"Tab",space:"Space",backspace:"Delete",delete:"Forward Delete",up:"↑",down:"↓",left:"←",right:"→"},hn=(e,n,s="")=>({did:`${e}${s}`,tried:`${n}${s}`});function TH(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&&Tg[s.toLowerCase()]?Tg[s.toLowerCase()]:`${r.map(c=>_H[c]??`${c}+`).join("")}${Tg[s.toLowerCase()]??(s.length===1?s.toUpperCase():s)}`,i=r.length===1&&r[0]==="super"?$H[s.toLowerCase()]:void 0;return i?hn(i[0],i[1],` (${o})`):hn("Pressed","press",` ${o}`)}const RH={back:["Went","go"," back"],home:["Went","go"," home"],app_switch:["Opened","open"," the recent apps"]};function AH(e){const n=EH(e.on),s=r=>` ${n??r}`;switch(e.do){case"press":return hn("Pressed","press",s("an element"));case"click":return hn("Clicked","click",n?` ${n}`:" at a point");case"set":return hn("Set","set",s("an element"));case"perform":return hn("Acted on","act on",s("an element"));case"type":return n?hn("Typed into","type into",` ${n}`):hn("Typed text","type text");case"key":return e.keys?TH(e.keys):hn("Pressed a key","press a key");case"nav":{const[r,o,i]=e.nav&&RH[e.nav]||["Navigated","navigate",""];return hn(r,o,i)}case"scroll":return n?hn("Scrolled","scroll",` ${n}`):hn("Scrolled","scroll");case"drag":return hn("Dragged","drag"," across the screen");default:return hn("Acted","act")}}function lN(e){const n=AH(e);return e.error===void 0?n.did:`Could not ${n.tried}`}const cN=3,Px=e=>e[0].toLowerCase()+e.slice(1);function OH(e){const n=e.slice(0,cN).map(lN),s=e.slice(cN),r=s.findIndex(i=>i.error!==void 0),o=r<0?s.length:s.length-1;return[n[0],...n.slice(1).map(Px),...o>0?[`+${o} more`]:[],...r<0?[]:[Px(lN(s[r]))]].join(", ")}const MH={"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 $r(e){const n=e.app?yH(e.app):void 0,s=(()=>{var r;switch(e.method){case"apps.launch":return hn("Opened","open",` ${n??"an app"}`);case"apps.terminate":return hn("Quit","quit",` ${n??"an app"}`);case"ui.observe":return hn("Looked at","look at",` ${n??"the window"}`);case"ui.act":return e.ok&&((r=e.steps)!=null&&r.length)?{did:OH(e.steps),tried:""}:e.ok?hn("Waited for","wait for",` ${n??"the window"}${e.expect==="unmet"?" (not seen)":""}`):hn("Acted on","act on",` ${n??"the computer"}`);default:{const[o,i]=MH[e.method]??[e.method,e.method];return hn(o,i)}}})();return e.ok?s.did:`Could not ${s.tried}`}const PH=e=>e.map((n,s)=>s===0?$r(n):Px($r(n))).join(", "),u$='\\s"`<>\\\\',LH=new RegExp(`https?://[^${u$}|]+`,"gi"),IH=new RegExp(`https?://[^${u$}]+`,"gi"),zH=".,;:!?*)]}'",DH={")":"(","]":"[","}":"{"};function FH(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&&zH.includes(e[s-1]);s--){const r=e[s-1],o=DH[r];if(o&&n[o]>=n[r])break;o&&(n[r]-=1)}return e.slice(0,s)}new RegExp(`\\]\\(|${LH.source}`,"gi");const Vo=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,dn=e=>typeof e=="string"?e:void 0,Ka=(e,n)=>e.length>n?`${e.slice(0,n-3)}...`:e,f$=e=>e.split(`
|
|
709
|
+
`).map(n=>n.trim()).find(Boolean)??"";function lm(e){try{return Vo(JSON.parse(e))}catch{return}}const UH=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function ed(e){const n=UH.exec(e.trim());return Ka(n?`${n[1]}${n[2]==="/"?"":n[2]}`:e.split(/[?#]/)[0]??"",80)}const WH="…",HH=/https?:\/\//gi,BH=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i,GH=/(https?:\/\/)[^@/?#\s]*@/gi,qH=/[A-Za-z0-9]/;function Ay(e){return e.replace(IH,n=>{const s=[0];let[r,o]=[0,!1];for(const i of n.matchAll(HH)){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)&&!qH.test(n[d]);d--)c||(c=n[d]==="'");c&&s.push(i.index)}return s.map((i,c)=>KH(n.slice(i,s[c+1]??n.length))).join("")})}function KH(e){const n=FH(e).length,s=BH.exec(e.slice(0,n));if(!s)return e;const r=i=>i.replace(GH,"$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}=${WH}`).join("&")}`:""}${e.slice(n)}`}const VH=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),YH=new Map,QH=new Map,m$=new Map,JH=new Set;function un(e,n,s,{name:r,saysFailure:o}={}){YH.set(e,n),s&&QH.set(e,s),r&&m$.set(e,r),o&&JH.add(e)}const XH=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,ZH=/^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/,e7=e=>{const n=ZH.exec(e)??XH.exec(e);return n&&n[1]!=="hands"?`${n[1]} · ${n[2]}`:void 0},t7=e=>m$.get(e)??e7(e)??e,n7=new Map;function Oy(e,n){n7.set(e,n)}const s7=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...s7];const My=e=>dn(e.path)??dn(e.file_path),r7=/page\.goto\(\s*["'`]([^"'`]+)/;un("read",e=>`Read ${My(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});un("write",e=>`Wrote ${My(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});un("edit",e=>`Edited ${My(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});un("bash",e=>`Ran \`${Ka(Ay(f$(dn(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const h$=e=>{const n=e&&Vo(lm(e.text)??lm(f$(e.text)));if((n==null?void 0:n.ok)!==!1)return;const s=dn(n.refused);return s!==void 0?{refused:!0,detail:s.replace(/^refused:\s*/,"")}:{refused:!1,detail:dn(n.error)??dn(n.message)??"no detail"}},o7=(e,n)=>`${h$(n)?"Tried to fetch":"Fetched"} ${ed(dn(e.url)??"a page")}`,a7={many:e=>`Fetched ${e} pages`,subject:e=>e?ed(e):void 0},i7=e=>{const n=h$(e);return n&&{failed:!0,text:`${n.refused?"refused":"failed"}: ${n.detail}`}};un("web_fetch",o7,a7,{name:"Fetch web pages"});Oy("web_fetch",i7);un("web_search",e=>{const n=dn(e.query);return n?`Searched the web for "${Ka(Ay(n),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${Ka(e,40)}"`:void 0},{name:"Search the web"});Oy("web_search",e=>{var s;const n=dn((s=Vo(lm(e.text)))==null?void 0:s.error);return n!==void 0?{failed:!0,text:`failed: ${n}`}:void 0});un("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 "${Ka(Ay(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?ed(s):void 0}},{name:"Read the browser's page"});un("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});un("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});un("run",(e,n)=>{var i,c;const s=(i=r7.exec(dn(e.code)??""))==null?void 0:i[1];if(s)return`Opened ${ed(s)}`;const r=(c=Vo(n==null?void 0:n.details))==null?void 0:c.sent,o=Array.isArray(r)?r.flatMap(d=>{const u=Vo(d),[f,g]=[dn(u==null?void 0:u.method),dn(u==null?void 0:u.url)];return f&&g?`${f} ${ed(g)}`:[]}):[];return o.length?`Acted on the page (${o.length} request${o.length===1?"":"s"} sent: ${VH(o)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});un("browser_downloads",(e,n)=>{var o;const s=n&&((o=lm(n.text))==null?void 0:o.fetched),r=Array.isArray(s)?s.flatMap(i=>{var c;return dn((c=Vo(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"});un("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});un("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});un("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});un("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});un("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const l7=/^(\d+)\. [a-z_.]+(?: into)?(?: @\S+ ([a-z]+)(?: ("(?:[^"\\]|\\.)*"))?)?(?: \[secure\])?: (.*)$/,c7=e=>{if(e!==void 0)try{return dn(JSON.parse(e))}catch{return}};function p$(e){var s;const n=new Map;for(const r of(e??"").split(`
|
|
710
|
+
`)){const o=l7.exec(r);if(!o)continue;const i=c7(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 d7(e,n){return{...NH(e,()=>n==null?void 0:n.on),...(n==null?void 0:n.refused)!==void 0?{error:"refused"}:{}}}un("computer_act",(e,n)=>{var d;const s=Array.isArray(e.steps)?e.steps.flatMap(u=>{const f=Vo(u);return f?[f]:[]}):[],r={method:"ui.act",started_at:"",ms:0,...dn(e.app)?{app:dn(e.app)}:{}};if(n!=null&&n.isError)return $r({...r,ok:!1});const o=n===void 0?void 0:p$(n.text),i=o===void 0?s:s.filter((u,f)=>o.has(f+1));if(s.length>0&&i.length===0)return $r({...r,ok:!1});const c=n&&((d=/^expect: (met|unmet)$/m.exec(n.text))==null?void 0:d[1]);return $r({...r,ok:!0,steps:i.map((u,f)=>d7(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});Oy("computer_act",e=>{for(const[n,s]of p$(e.text))if(s.refused!==void 0)return{failed:!0,text:`step ${n} refused: ${s.refused}`}});const dN=/^state \S+ · (\S+)/,u7=/^screen \S+ px · (?:\S+ in front|no app in front)/;un("computer_observe",(e,n)=>{var r;if(n&&!n.isError&&!dN.test(n.text)){const o=u7.test(n.text),i=(d,u)=>({method:d,started_at:"",ms:0,ok:!0,...u?{app:u}:{}}),c=o?dn(e.app):void 0;return PH([...c?[i("apps.launch",c)]:[],i("screen.shot"),...o?[i("apps.list")]:[]])}const s=dn(e.app)??(n&&((r=dN.exec(n.text))==null?void 0:r[1]));return $r({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});un("computer_screenshot",(e,n)=>$r({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 uN={"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"};un("computer_op",(e,n)=>{var i;const s=dn(e.op),r=s!==void 0&&Object.hasOwn(uN,s)?uN[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"?dn((i=Vo(e.args))==null?void 0:i.id):void 0;return $r({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});un("computer_script",(e,n)=>{var r;const s=(r=dn(e.title))==null?void 0:r.replace(/\s+/g," ").trim();return n!=null&&n.isError?s?`Could not run the script “${Ka(s,120)}”`:"Could not run a script on the computer":s?Ka(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 f7=["schedule","webhook","slack","github","composio","email","feed"];new Set(f7);const m7=":feedback",h7=e=>{var n;return e.kind==="user_message"&&((n=e.id)==null?void 0:n.endsWith(m7))===!0},p7={user_message:Xx,thinking:Cf,tool_use:Ef,tool_result:Ef,waiting:Kx,usage:Bx,final_answer:Ya,phase:MN,error:nl,decision:YT,text_block:WT,tool_approval_requested:zN},fN=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},mN=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),Py=e=>e.origin==="server",g$=e=>e.origin==="trigger",x$=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 v$(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:v$(s.slice(2,-2))},r))}const g7=e=>{var r;const n=g$(e)?x$(e).said:(e.summary??"").replace(Py(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())?k2:`${n.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${s}`:e.kind==="user_message"?`${n}${s}`:n},td=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,x7=new Set(xH),v7=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 y7(e){const n=v7.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 hN=e=>e&&(kI(e)??(x7.has(e)?t7(e):y7(e))),pN=e=>Py(e)?"AgentRun":g$(e)?x$(e).who??"Trigger":h7(e)?"Your grade":{user_message:"You",thinking:"Thinking",tool_use:hN(e.tool_name)??"Tool",tool_result:hN(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,b7={budget:"Paused at cap"};function w7({step:e,last:n,ended:s,waitingChip:r,files:o,onOpen:i}){var y,j;const c=e.row,[d,u]=p.useState(!1),g=BM(c)?ON:p7[c.kind]??MN,b=e.above?c.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":g7(c),x=e.above?null:e.detail??n2(c),h=x&&x.trim()!==b.trim()?x:null,v=r2(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"||mN(c))&&"border-warning/60 text-warning-text",v&&"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:pN(c),children:pN(c)}),(c.kind==="tool_use"||c.kind==="tool_result")&&c.usage&&t.jsxs("span",{className:"font-mono text-label",children:["· ",zM(c.usage,{ended:s})]}),c.kind==="waiting"&&t.jsx(ke,{tone:"warning",children:r??"Input required"}),mN(c)&&t.jsx(ke,{tone:"warning",children:"Approval required"}),v&&t.jsx(ke,{tone:"error",children:"Error"}),s2(c)&&t.jsx(ke,{tone:"muted",title:"Not run: refused before it ran",children:"Refused"}),c.agent_label&&t.jsx(ke,{label:!0,title:c.agent_label,children:c.agent_label}),e.ms!==void 0&&t.jsx("span",{className:"font-mono text-label",children:td(e.ms)}),e.times&&t.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${td(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",Py(c)&&"text-muted-foreground"),children:v$(b)}),e.saved&&t.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),fN(c)&&t.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:fN(c)})]}),t.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:md(c.timestamp)}),h&&t.jsx(Es,{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:$v(k=>{const E=o==null?void 0:o.find(S=>S.path===k);E&&(i==null||i(E))}),dangerouslySetInnerHTML:{__html:so(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}),(y=c.learned_nodes)!=null&&y.length?t.jsx(N7,{nodes:c.learned_nodes}):null,(j=c.computer_calls)!=null&&j.length?t.jsx(j7,{calls:c.computer_calls,dropped:c.computer_calls_dropped??0}):null]})]})}function j7({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(Es,{className:ae("size-3 transition-transform",s&&"rotate-90"),"aria-hidden":!0}),t.jsx(Qa,{className:"size-3","aria-hidden":!0}),c]}),s&&t.jsxs("ol",{"aria-label":"The computer calls",className:"mt-2 divide-y border bg-card",children:[e.map((u,f)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[t.jsxs("span",{className:"w-14 shrink-0 font-mono text-label text-muted-foreground",children:["+",td(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:$r(u),children:$r(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:td(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 k7={ok:"success",failed:"error",escalated:"warning"};function N7({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(Es,{className:ae("size-3 transition-transform",n&&"rotate-90"),"aria-hidden":!0}),t.jsx(Ja,{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(ke,{tone:k7[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:J2(i)||void 0,children:Xv(i.kind,i)}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:td(i.duration_ms)})]},c))})]})}function S7({rows:e,live:n,fold:s=6,asking:r,waitingOn:o,files:i,onOpen:c,ended:d=!1}){var y;const u=o==="budget"?e.findLastIndex(j=>j.paused===!0):-1,f=u>=0?(y=e.slice(u+1).findLast(j=>j.kind==="waiting"))==null?void 0:y.id:void 0,[g,b]=p.useState(!1),x=GM(e).map(j=>r&&j.row.id===r?{...j,above:!0}:j),h=g?0:Math.max(0,x.length-s),v=x.slice(h);return e.length?t.jsxs("div",{children:[h>0&&t.jsxs("button",{type:"button",className:"caps mb-1 ml-10 flex items-center gap-1 py-2 text-label text-muted-foreground hover:text-foreground",onClick:()=>b(!0),children:[t.jsx(Es,{className:"size-3","aria-hidden":!0})," ",h," earlier ",h===1?"step":"steps"]}),t.jsx("ol",{children:v.map((j,k)=>t.jsx(w7,{step:j,last:k===v.length-1&&!n,ended:d,waitingChip:j.row.id===f&&o?b7[o]:void 0,files:i,onOpen:c},j.row.id))}),n&&t.jsx(Lx,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):t.jsx(Lx,{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 Lx({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(S5,{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 C7={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."},E7={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 $7(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 ${Jr(d)} for steps still running`:"";return{title:"Paused at its spend cap",note:`${u&&typeof c=="number"?`It has spent ${Jr(c)} of its ${Jr(i)} cap${f}.`:u?`Its ${Jr(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=Bi(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 _7({run:e,agentName:n,messages:s,harnessSteers:r,rows:o,files:i,outputSchema:c,readFile:d,openFile:u=null,actions:f,onMessage:g,onApprove:b,tab:x,graphView:h,costText:v,readLearningDiff:y,readLearning:j,readLearningResult:k,readComputer:E,computerEvery:S,onTakeOver:N,onHandBack:$,readComputers:_,onGrade:M}){var de,We,Ze,at,Q,ve,He;const O=e.native,L=es(e),A=((de=e.pending)==null?void 0:de.kind)==="budget"?e.pending:null,R=Bi(e),P=!L&&!O&&R?r&&s.steer?"steer":s.follow_up?"follow_up":null:null,D=Um(e.status,e.state,e.kind,s,r,e.error,e.review,e.computer),W=L||O||A?{...D,canMessage:!1,messageMode:null}:R?{...D,canMessage:P!==null,messageMode:P}:D,K=h?"graph":W.final&&e.status==="completed"?"report":"timeline",[H,q]=p.useState(x??K),F=H==="graph"&&!h?K:H,[G,U]=p.useState(!1),[z,Y]=p.useState(u?{file:u,text:null}:null),J=QW(e),X=J||R?null:RP(e.status,e.state,o),le=J?o.findLast(Se=>Se.kind===e$&&Se.tool_use_id===J.call_id):void 0,[se,fe]=p.useState(null),xe=async(Se,Je,Nt,zt)=>{const it=b?await(zt?b(Se,Je,Nt,zt):b(Se,Je,Nt)):"This page can't answer an approval.";return fe(it?{id:Se,text:it}:null),it},Ne=p.useRef(rx()).current,ge=async Se=>{const Je=Ne.begin();if(Y({file:Se,text:null}),!d)return;const Nt=await d(Se);Ne.current(Je)&&Y({file:Se,text:Nt})},me=()=>{Ne.cancel(),Y(null)},Le=U9(e,y),{read:Ue,grade:De,graded:Ee}=tH(e,W.final,j),re=M&&(async Se=>{const Je=await M(Se);return Ee(Je),Je}),_e=W.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",Qe=e.computer,he=Qe?z9(o,Qe.kind):void 0,{view:Ie,held:et}=$9(E,!W.final,S,void 0,e.status==="queued"||he!==void 0),pt=!!Ie||!!Qe||!!R,oe=p.useRef(!1);p.useEffect(()=>{if(pt){oe.current=!0;return}oe.current&&F==="screen"&&q(K),oe.current=!1},[pt,F,K]);const[$e,st]=p.useState(!1);p.useEffect(()=>{if(!Qe||!uy.has(Qe.kind)||!_)return;let Se=!0;return _().then(Je=>{var Nt,zt;Se&&st(!!((zt=(Nt=Je.kinds.find(it=>it.kind===Qe.kind))==null?void 0:Nt.providers.find(it=>it.id===Qe.provider))!=null&&zt.metered))}).catch(()=>{}),()=>{Se=!1}},[Qe==null?void 0:Qe.kind,Qe==null?void 0:Qe.provider]);const Oe=R?`${R.kind}:${R.asked_at}`:null,dt=p.useRef(null);p.useEffect(()=>{!Oe||dt.current===Oe||!pt||(dt.current=Oe,q("screen"))},[Oe,pt]);const Tt=async()=>{if(!N)return"This page can't take the computer over.";try{return et((await N()).hold),null}catch(Se){return Mx(Se,"take")}},nt=async Se=>{if(!$)return"This page can't hand the computer back.";try{return et((await $(Se)).hold),null}catch(Je){return Mx(Je,"hand")}},[ft,Kt]=p.useState(null),Dt=async Se=>{const Je=(R==null?void 0:R.asked_at)??"",Nt=await nt(Se);return Kt(Nt?{at:Je,text:Nt}:null),Nt};p.useEffect(()=>{u&&d&&ge(u)},[u]);const ye=[...h?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],...e.learning?[["learning","Learning"]]:[],["files",`Files ${i$(i,G).length}`],...pt?[["screen","Screen"]]:[]];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[t.jsx(u9,{run:e,agentName:n,actions:f,costText:v}),t.jsx(MS,{id:"run-views",label:"Run views",value:F,onChange:Se=>q(Se),tabs:ye.map(([Se,Je])=>({id:Se,label:Je}))}),F==="graph"?t.jsx("div",{className:"min-h-0 flex-1 short:min-h-96",children:h}):t.jsx("div",{"data-scroll-pane":!0,className:"min-h-0 flex-1 overflow-auto short:flex-none short:overflow-visible",children:t.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 px-5 py-8 md:px-8",children:[O&&t.jsx(w9,{native:O,agentId:e.agent_id}),e.status==="failed"&&e.error&&t.jsx(oa,{error:e.error,title:$2(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."]})]}),se&&se.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: ",se.text]}),ft&&ft.at!==(R==null?void 0:R.asked_at)&&t.jsxs("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:["Your answer wasn't taken: ",ft.text]}),J?t.jsx(n$,{pending:J,onAnswer:(Se,Je,Nt)=>Nt?xe(J.id,Se,Je,Nt):xe(J.id,Se,Je)},J.id):R?t.jsx(d$,{ask:R,onAnswer:$?Dt:void 0,open:F!=="screen"?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>q("screen"),children:"Open the screen"}):null},Oe):!O&&W.needsYou&&(A?t.jsx(r9,{pending:A}):t.jsx(a9,{waiting:X})),W.needsYou&&A&&typeof A.cap_usd=="number"&&(f==null?void 0:f.onRaiseCap)&&t.jsx(a$,{cap:A.cap_usd,suggested:r$(A),least:o$(A),paused:!0,onRaise:f.onRaiseCap},`${e.run_id}:${A.at}`),F==="report"&&t.jsx(b9,{run:e,rows:o,files:i,onOpen:ge,schema:c}),F==="report"&&!e.result&&!W.final&&t.jsx(Lx,{...$7(e,W)}),F==="report"&&W.final&&!((Ze=(We=e.result)==null?void 0:We.final_answer)!=null&&Ze.trim())&&!((at=e.result)!=null&&at.output)&&!o.some(Se=>{var Je;return Se.kind==="final_answer"&&((Je=Se.text)==null?void 0:Je.trim())})&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:[k2,W.canMessage?" Send a follow-up below to ask for one.":""]}),F==="timeline"&&t.jsx(S7,{rows:iD(o,e.learning),live:W.live,ended:Ba(e.status),asking:(le==null?void 0:le.id)??(W.needsYou&&!A?X==null?void 0:X.id:void 0),waitingOn:e.status==="input_required"?(Q=e.pending)==null?void 0:Q.kind:void 0,files:i,onOpen:ge}),(F==="report"||F==="timeline")&&t.jsx(Z9,{run:e,graded:De,onGrade:re,onOpenTimeline:F==="timeline"?void 0:()=>q("timeline")}),(F==="report"||F==="timeline")&&t.jsx(rH,{used:(Ue==null?void 0:Ue.used)??null,agentId:e.agent_id}),(F==="report"||F==="timeline")&&Le&&t.jsx(W9,{got:Le.got,retry:Le.retry}),F==="learning"&&t.jsx(k9,{run:e,read:k,onViewChanges:Le?()=>q("report"):void 0},e.run_id),F==="files"&&t.jsx(h9,{files:i,onOpen:ge,showHidden:G,onShowHidden:U}),F==="screen"&&pt&&t.jsx(P9,{runId:e.run_id,screen:Ie,machine:Qe,opens:_e,followUp:W.canMessage&&W.messageMode==="follow_up",metered:$e,waitsFor:e.status==="input_required"&&((ve=e.pending)==null?void 0:ve.kind)!=="stopped"?(He=e.pending)==null?void 0:He.kind:void 0,keptUntil:e.status==="input_required"?he:void 0,onTake:N?Tt:void 0,onHand:$?()=>nt():void 0})]})}),O&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:["Native sessions cannot receive steering or follow-up messages. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(e.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," for another task."]}),L&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:[Yo(L.runtime)," runs in your backend. Start, stop and follow up through that application's controls. AgentRun records the result and checked learning."]}),W.canMessage&&t.jsx("div",{className:"border-t px-5 py-4 md:px-8",children:t.jsx("div",{className:"mx-auto max-w-4xl",children:t.jsx(s9,{mode:W.messageMode,onSend:g,purpose:J?C7:R&&P?E7[P]:void 0})})}),z&&t.jsx(p9,{file:z.file,text:z.text,onClose:me,files:i,onOpen:ge})]})}const y$=new Set(["chain","parallel","route","map","loop","workflow"]),T7={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},R7=e=>e==="review"?"needs review":e.replace("-"," ");function Ly({state:e}){const n=Uf(e)??"pending";return t.jsx(ke,{tone:T7[n]??"plain",className:"whitespace-nowrap",children:R7(n)})}function Iy({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 b$={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},zy=(e,n)=>e&&n?Date.parse(n)-Date.parse(e):void 0;function A7({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=Pv(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,b=n.item!=null&&g?(E=(k=e.nodes[g])==null?void 0:k.items)==null?void 0:E.find(_=>_.index===n.item):void 0,x=e.decisions.filter(_=>_.node===i.path),h=e.effects.filter(_=>_.node===i.path),v=!!g&&i.kind!=="map",y=zy(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:Xv(i.kind,u),f.tool?` · ${k$(f.tool)}`:i.via?` · ${i.via}`:"",f.tool&&jd(f.tool)&&t.jsx(N$,{}),b&&t.jsxs(t.Fragment,{children:[t.jsx(Es,{className:"size-3","aria-hidden":!0})," item ",b.index+1]})]}),t.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:b?Bc(e,g,b.index)??`Item ${b.index+1}`:i.label}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t.jsx(Ly,{state:b?b.status:u==null?void 0:u.status}),b&&(()=>{const _=Lv(e,g,b);return _.outcome?t.jsxs("span",{className:"font-mono text-label",title:_.pNote,children:["outcome ",t.jsx("b",{className:b$[_.tone??""],children:_.outcome}),_.p!==void 0&&t.jsxs("span",{className:"text-muted-foreground",children:[" · ",Bs(_.p)]})]}):null})(),f.decision&&t.jsx(Iy,{provider:f.provider}),f.decision&&((u==null?void 0:u.model)??f.model)&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:(u==null?void 0:u.model)??f.model}),(u==null?void 0:u.branch)&&t.jsxs("span",{className:"font-mono text-label",children:["took ",t.jsx("b",{children:u.branch})]}),!b&&y!==void 0&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Qi(y)})]})]}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:r,children:t.jsx(Xo,{"aria-hidden":!0})})]}),b&&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:[b?t.jsx(L7,{data:e,mapPath:g,index:b.index,status:b.status,fileUrl:o,zoom:d}):i.kind==="map"?t.jsx(O7,{data:e,mapPath:i.path,onSelect:s}):v&&(x.length||h.length)?t.jsx(M7,{data:e,path:i.path,mapPath:g,onSelect:s}):t.jsxs(t.Fragment,{children:[i.kind==="parallel"&&t.jsx(P7,{data:e,path:i.path,onSelect:s}),x.map((_,M)=>t.jsx(j$,{d:_,fileUrl:o,zoom:d},_.id??M)),h.map((_,M)=>t.jsx(S$,{e:_,fileUrl:o,zoom:d},M)),!x.length&&!h.length&&i.kind!=="parallel"&&t.jsx(w$,{kind:i.kind,status:u==null?void 0:u.status,meta:f})]}),t.jsx(U7,{workflow:e.workflow,path:i.path,kind:i.kind})]}),c&&t.jsx(W7,{src:c,onClose:()=>d(null)})]})}function w$({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.":y$.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 O7({data:e,mapPath:n,onSelect:s}){var i;const r=((i=e.nodes[n])==null?void 0:i.items)??[],o=b2(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 b;return g.item===c.index&&!!((b=g.node)!=null&&b.startsWith(`${n}/body`))}),u=Lv(e,n,c),f=d.length?d.some(g=>g.cost_usd===null)?null:d.reduce((g,b)=>g+(b.cost_usd??0),0):void 0;return t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>s({path:n,item:c.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:c.index+1}),t.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:Bc(e,n,c.index),children:Bc(e,n,c.index)??"—"}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:t.jsx(Ly,{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=>cl(g))].filter(Boolean).join(", "),children:u.outcome?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:ae("font-semibold",b$[u.tone??""]),children:u.outcome}),u.p!==void 0&&t.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:Bs(u.p)})]}):d.map(g=>cl(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:"—"}):Sl(f)})]},c.index)})})]})]})}function M7({data:e,path:n,mapPath:s,onSelect:r}){var g;const o=e.decisions.filter(b=>b.node===n),i=e.effects.filter(b=>b.node===n),c=(((g=e.nodes[s])==null?void 0:g.items)??[]).map(b=>({it:b,d:o.find(x=>x.item===b.index),e:i.find(x=>x.item===b.index)})).filter(b=>b.d||b.e),d=o.filter(b=>b.cost_usd!==null),u=o.filter(b=>b.latency_ms!==null),f=u.length?u.reduce((b,x)=>b+(x.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 · ",Sl(d.reduce((b,x)=>b+(x.cost_usd??0),0)),d.length<o.length?` + ${o.length-d.length} unknown`:""," · mean ",Qi(f)]}),t.jsx("table",{className:"w-full border-collapse font-mono text-small",children:t.jsx("tbody",{children:c.map(({it:b,d:x,e:h})=>t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>r({path:s,item:b.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:b.index+1}),t.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:Bc(e,s,b.index)}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:x?cl(x):h?t.jsx(Ly,{state:h.status}):null}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:x?Qi(x.latency_ms):h?Qi(zy(h.startedAt,h.endedAt)):""})]},b.index))})})]})}function P7({data:e,path:n,onSelect:s}){var x,h;const r=`${n}/branches/`,o=e.decisions.filter(v=>{var y;return((y=v.node)==null?void 0:y.startsWith(r))&&/^\d+$/.test(v.node.slice(r.length))&&v.item===null}),i=new Set(o.flatMap(v=>Object.keys(v.answers??{}))),[c]=[...i],d=o.map(v=>{var y;return{d:v,a:(y=v.answers)==null?void 0:y[c]}}).filter(v=>{var y;return((y=v.a)==null?void 0:y.type)==="noul"});if(i.size!==1||d.length<2)return t.jsx(w$,{kind:"parallel",meta:{decision:!1}});const u=d.map(v=>v.a.noul),f=u.reduce((v,y)=>v+y,0)/u.length,g=Math.max(...u)-Math.min(...u),b=v=>{var y;return((y=e.graph.nodes.find(j=>j.path===v.node))==null?void 0:y.label)??v.node};return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"border-b px-4 py-2.5",children:[t.jsxs("p",{className:"caps text-micro text-muted-foreground",children:["Jury · ",d.length," models · ",c]}),t.jsx("p",{className:"mt-1 text-body leading-snug",children:((h=(x=o[0].questions)==null?void 0:x[c])==null?void 0:h.instructions)??c})]}),t.jsx("ul",{className:"divide-y",children:d.map(({d:v,a:y})=>t.jsx("li",{children:t.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-2 text-left font-mono text-small hover:bg-accent",onClick:()=>s({path:v.node,item:null}),children:[t.jsx("span",{className:"w-[92px] shrink-0",children:t.jsx(Iy,{provider:v.provider})}),t.jsx("span",{className:"w-[132px] shrink-0 truncate",title:v.model??"",children:v.model??b(v)}),t.jsx(Ix,{p:y.noul,strong:!0,tick:.5,tone:y.noul>=.5?"fg":"muted"}),t.jsx("span",{className:"w-10 text-right tabular-nums",children:Bs(y.noul)})]})},v.id??v.executionPath))}),t.jsxs("dl",{className:"grid grid-cols-3 border-t font-mono text-small",children:[t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Mean P(yes)"}),t.jsx("dd",{className:"font-semibold tabular-nums",children:Bs(f)})]}),t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Spread"}),t.jsx("dd",{className:ae("font-semibold tabular-nums",g>.3&&"text-warning-text"),children:Bs(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:Sl(d.some(v=>v.d.cost_usd===null)?null:d.reduce((v,y)=>v+(y.d.cost_usd??0),0))})]})]})]})}function L7({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=>!y$.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((b,x)=>t.jsx(S$,{e:b,fileUrl:o,zoom:i,compact:!0},x)),f.map((b,x)=>t.jsx(j$,{d:b,fileUrl:o,zoom:i},b.id??x))]},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 gN=e=>`${Math.round(e*100)}%`,Bs=e=>e.toFixed(2);function Ix({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:gN(Math.max(0,Math.min(1,e)))}}),s!==void 0&&t.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:gN(s)},title:`threshold ${Bs(s)}`})]})}function I7({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(Ix,{p:s.noul,strong:!0,tick:.5,tone:s.noul>=.5?"fg":"muted"}),t.jsxs("span",{className:"w-24 text-right tabular-nums text-muted-foreground",children:["P(yes) ",Bs(s.noul)]})]}):s.type==="box"?t.jsxs("p",{className:"font-mono text-small",children:["box ",JSON.stringify(s.box)]}):t.jsxs("div",{className:"space-y-1.5",children:[Object.entries(s.probabilities).sort((d,u)=>u[1]-d[1]).slice(0,(r==null?void 0:r.kind)==="pick"?5:void 0).map(([d,u])=>{const f=(s.type==="choice"?s.choice:String(s.score))===d;return t.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[t.jsx("span",{className:ae("truncate",(r==null?void 0:r.kind)==="pick"?"w-48":"w-28",f?"font-semibold":"text-muted-foreground"),title:o(d),children:s.type==="score"?`${d} ${s.legend[d]??""}`:o(d)}),t.jsx(Ix,{p:u,strong:f,tick:f&&c?c.gte:void 0}),t.jsx("span",{className:"w-12 text-right tabular-nums text-muted-foreground",children:Bs(u)})]},d)}),(r==null?void 0:r.kind)==="pick"&&Object.keys(s.probabilities).length>5&&t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[Object.keys(s.probabilities).length-5," more options, each less likely"]})]}):t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No answer."})]})}function z7(e){if(!e)return"No rule applied: nothing came back to decide on.";switch(e.kind){case"judge":return"Each answer is decoded on its own: a yes/no is yes at P(yes) ≥ 0.50, a choice is its top option.";case"route":return e.unsure?`Take the chosen branch; below ${Bs(e.unsure.gte)} confidence take "${e.unsure.branch}".`:"Take the chosen branch.";case"pick":return`Pick one of ${e.options.length} options${e.none?`, or "${e.none}"`:""}.`;case"ask":return`Holds when P(yes) ≥ ${Bs(e.gte)}.`;case"sift":return e.keep?`Keep an item when its ${e.keep.id} ${e.keep.measure} ≥ ${Bs(e.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function D7(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?Bs(c):"?"} is below the threshold.`:`Took "${String(n.taken??n.branch)}".`}if(((i=e.rule)==null?void 0:i.kind)==="pick"&&typeof n.index=="number"){const c=e.rule.options[n.index];return n.none?`None of the options: "${e.rule.none??"none"}".`:`Picked ${c!==void 0?`"${v2(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 j$({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(Iy,{provider:e.provider}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:e.model??"default model"}),t.jsx(ke,{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:cl(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:Sl(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:Qi(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)||dr(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(I7,{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:z7(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:D7(e)})]})]}),!!((d=e.evidence)!=null&&d.length)&&t.jsx(F7,{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(Es,{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(cm,{value:e.state})]})]})}function F7({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=dr(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(_T,{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 k$=e=>{const n=jd(e);return n?`${n.tool} on ${n.server}`:e},N$=()=>t.jsx(ke,{tone:"muted",title:"An MCP server's tool",children:t.jsx("span",{"data-mcp":!0,children:"MCP"})});function S$({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:k$(e.tool)}),jd(e.tool)&&t.jsx(N$,{}),t.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?Qi(zy(e.startedAt,e.endedAt)):""}),t.jsx(ke,{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(cm,{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(b=>t.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>s(n(b.image)),"aria-label":`Open page ${b.page}`,children:t.jsx("img",{src:n(b.image),alt:`Page ${b.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},b.page))}),i&&!u&&t.jsxs("details",{className:"group",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[t.jsx(Es,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),t.jsx(cm,{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 U7({workflow:e,path:n,kind:s}){const r=g2(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)?`… ${qm(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(Es,{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(cm,{value:o})]})}function cm({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 W7({src:e,onClose:n}){return t.jsx(Mm,{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 C$=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function H7(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,b]=p.useState(0),x=p.useRef(e);return x.current=e,p.useEffect(()=>{if(!r)return;const h=new AbortController;let v;const y=async()=>{try{const j=Date.now(),k=await x.current(h.signal);if(h.signal.aborted||(i(k),d(null),f(j),pd(k.run.status)))return}catch(j){if(h.signal.aborted)return;d(j);const k=j;if(k.retryable){v=setTimeout(y,Math.min(n,k.retryAfterMs??500));return}if(C$(j))return}v=setTimeout(y,n)};return y(),()=>{h.abort(),clearTimeout(v)}},[s,n,g,r]),{data:o,error:c,readAt:u,reload:()=>b(h=>h+1)}}function B7({data:e,actions:n={},fileUrl:s,initial:r=null,lastRead:o}){const[i,c]=p.useState(r),d=p.useMemo(()=>EP(e,i),[e,i]),u=pd(e.run.status),[f,g]=p.useState(()=>Date.now()),b=p.useMemo(()=>Date.now(),[e]);return p.useEffect(()=>{if(u||e.run.paused)return;const x=setInterval(()=>g(Date.now()),1e3);return()=>clearInterval(x)},[u,e.run.paused]),t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsx(G7,{data:e,readAt:b,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(Nd,{graph:e.graph,marks:d,onSelect:x=>c(h=>h&&h.path===x.path&&(h.item??null)===x.item?null:x),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(A7,{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(Sd,{run:!0})})]})}function G7({data:e,readAt:n,now:s,actions:r,stale:o}){const i=pd(e.run.status),c=e.graph.nodes.find(b=>{var x,h;return b.kind==="map"&&((h=(x=e.nodes[b.path])==null?void 0:x.items)==null?void 0:h.length)}),d=c?b2(e.nodes[c.path].items):null,{usd:u,unknown:f}=w2(e),g=[["Elapsed",dl(TP(e,n,s))],["Cost",t.jsxs(t.Fragment,{children:[Sl(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",K7(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(ke,{tone:"warning",children:[t.jsx(sl,{className:"size-3","aria-hidden":!0})," Paused"]})}),g.map(([b,x,h],v)=>t.jsxs("div",{className:ae("px-4 py-2",v?"border-l":"pl-5 md:pl-8"),title:h,children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:b}),t.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:x})]},b)),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 ",dl(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(Qo,{"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(sl,{"aria-hidden":!0})," ",r.busy==="pause"?"Pausing":"Pause"]}))]})]})}const q7=new Set(["agent","decide","extract","report","artifact"]),K7=e=>e.graph.nodes.filter(n=>{var s;return q7.has(n.kind)&&!["pending","not_run"].includes(((s=e.nodes[n.path])==null?void 0:s.status)??"pending")}).length;function V7({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 Y7(e,n){return!n||e.state==="loading"?{messages:Fm,steers:!1}:e.state==="failed"?{messages:n.features.messages,steers:!1}:{messages:n.features.messages,steers:qP(e.id,n.harnesses)}}async function Q7(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 xN=new Set(["completed","failed","cancelled"]),J7={firstMs:2e3,maxMs:16e3,totalMs:12e4};function X7(e,n,s,r=J7){var g;const o=!!e&&xN.has(e.status)&&Vm(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&&xN.has(e.status),f=p.useRef(d);p.useEffect(()=>{var x;const b=f.current;f.current=d,b!==void 0&&b!==d&&u&&((x=c.current)==null||x.call(c))},[d,u]),p.useEffect(()=>{if(!o)return;let b,x=0,h=r.firstMs,v=!1,y=!1;const j=()=>{y||x+h>r.totalMs||(b=setTimeout(k,h))},k=()=>{if(b=void 0,document.visibilityState==="hidden"){v=!0;return}x+=h,h=Math.min(h*2,r.maxMs),i.current(),j()},E=()=>{v&&document.visibilityState!=="hidden"&&(v=!1,k())};return document.addEventListener("visibilitychange",E),j(),()=>{y=!0,b&&clearTimeout(b),document.removeEventListener("visibilitychange",E)}},[o])}const vN=new Set(["completed","failed","cancelled"]),Z7=e=>{const n=w2(e);return`${Sl(n.usd)}${n.unknown?` + ${n.unknown} unknown`:""}`},eB=e=>e instanceof Fe?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},Di=e=>({api:eB(e),title:lP(e),cause:e});function yN({v2:e,runId:n,caps:s,agentName:r}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[g,b]=p.useState([]),[x,h]=p.useState(null),[v,y]=p.useState(null),[j,k]=p.useState(0),E=p.useRef(""),S=p.useRef(rx()).current,N=p.useRef(rx()).current,$=p.useRef(Ys()).current,_=p.useRef(0),M=p.useRef(""),[O,L]=p.useState({state:"loading"});p.useEffect(()=>{o&&O.state==="loading"&&Q7(e,o).then(L)},[o==null?void 0:o.revision]);const A=Y7(O,s);X7(o,()=>R(),()=>k(J=>J+1));const R=async()=>{const J=S.begin();try{const[X,le]=await Promise.all([e.getRun(n),e.listFiles(n)]);S.current(J)&&(i(X),b(le.files))}catch(X){S.current(J)&&h(Di(X))}};p.useEffect(()=>{R()},[n]),JE(()=>{R()}),p.useEffect(()=>{const J=new AbortController;return d(null),o2(e,n,{signal:J.signal,onRows:X=>{f(X);const le=X.filter(fe=>fe.kind===e$).map(fe=>`${fe.id}\0${fe.summary}`).join("");le!==M.current&&(M.current=le,R());const se=X.filter(fe=>fe.kind==="tool_result").length;if(se>_.current){_.current=se;const fe=N.begin();e.listFiles(n).then(xe=>{N.current(fe)&&b(xe.files)}).catch(()=>{})}},onPage:X=>{X.cost&&d(X.cost);const le=`${X.status}/${X.state}`;(le!==E.current||X.status==="input_required"&&!X.unchanged)&&(E.current=le,R())}}).catch(X=>{J.signal.aborted||h(Di(X))}),()=>J.abort()},[n,j]);const P=async J=>{y(J);try{await e[J](n),h(null)}catch(X){h(Di(X))}y(null),await R(),k(X=>X+1)},D=async()=>{if(o){y("archive");try{const J=await(o.archived_at?e.unarchiveRun(n):e.archiveRun(n));i(X=>X?{...X,archived_at:J.archived_at}:J),h(null)}catch(J){h(Di(J))}y(null),R()}},W=async J=>{const X=await J();return await R(),k(le=>le+1),X},K=J=>W(()=>e.raiseCap(n,J)),H=J=>W(()=>e.gradeRun(n,J)),q=async J=>{let X=!0;try{await bC($,n,J,e.sendMessage),h(null)}catch(le){h(Di(le)),X=!1}return await R(),k(le=>le+1),X},F=async(J,X,le,se)=>{let fe=null;try{await e.answerApproval(n,J,X,le,se)}catch(xe){fe=t$(xe)}return await R(),k(xe=>xe+1),fe},G=async J=>{try{return await J()}finally{R(),k(X=>X+1)}},U=H7(J=>e.getRunGraph(n,J),{key:n,enabled:(o==null?void 0:o.kind)==="workflow"}),z=!U.data&&C$(U.error);if(!o)return x?x.cause instanceof Fe&&x.cause.status===404?t.jsx(l2,{what:"run",id:n,list:{href:"#/runs",label:"Open the runs list"}}):t.jsx(Qt,{problem:Wt(x.cause,"the run"),onRetry:()=>{h(null),R(),k(J=>J+1)}}):t.jsx(sP,{});const Y=c&&!vN.has(o.status)?{...o,cost:c}:o;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[x&&t.jsx("div",{className:"border-b p-3",children:t.jsx(oa,{title:x.title,error:x.api})}),t.jsx(_7,{run:Y,agentName:r(o.agent_id),messages:A.messages,harnessSteers:A.steers,graphView:o.kind==="workflow"&&!z?t.jsx(tB,{v2:e,runId:n,graph:U,onMoved:()=>{R()}}):void 0,costText:o.kind==="workflow"&&!vN.has(o.status)&&U.data?Z7(U.data):void 0,outputSchema:O.state==="read"?O.outputSchema:void 0,rows:u,files:g,readFile:J=>e.readFile(n,J.path),readLearningDiff:()=>e.runLearningDiff(n),readLearning:()=>e.runLearning(n),readLearningResult:()=>e.runLearningResult(n),readComputer:()=>e.runComputer(n),onTakeOver:()=>G(()=>e.takeOverComputer(n)),onHandBack:J=>G(()=>e.handBackComputer(n,J)),readComputers:()=>e.computers(),onMessage:q,onApprove:F,onGrade:H,actions:{onStop:()=>void P("stop"),onCancel:()=>void P("cancel"),onArchive:()=>void D(),onRaiseCap:K,busy:v}},o.run_id)]})}function tB({v2:e,runId:n,graph:s,onMoved:r}){const{data:o,error:i,readAt:c,reload:d}=s,[u,f]=p.useState(null),[g,b]=p.useState(null),[x,h]=p.useState(null),v=async j=>{f(j);try{const k=await(j==="pause"?e.pauseRun(n):e.resumeRun(n));h({paused:k.paused,status:k.status,at:Date.now()}),b(null)}catch(k){b(Di(k))}f(null),d(),r()},y=o&&x&&c<x.at?{...o,run:{...o.run,paused:x.paused,...x.status?{status:x.status}:{}}}:o;return y?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(oa,{title:g.title,error:g.api})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(B7,{data:y,lastRead:c,fileUrl:j=>e.fileUrl(n,j),actions:{onPause:()=>void v("pause"),onResume:()=>void v("resume"),busy:u}})})]}):t.jsx(V7,{error:i})}function bN({actions:e,children:n}){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center justify-between gap-2 border-b px-5 py-2 md:px-6",children:[t.jsxs("h1",{className:"flex items-center gap-2.5 font-mono text-small font-semibold",children:[t.jsx(Yx,{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 nB({view:e,error:n,onRetry:s,scope:r,needsYou:o,asking:i,failed:c,live:d,startHere:u,actions:f,observations:g,hasObservedSessions:b=!1}){if(!e)return t.jsx(bN,{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(Qt,{problem:n,onRetry:s}):t.jsx(nP,{}),g]})});const x=y=>{var j;return((j=e.perAgent.find(k=>k.agentId===y))==null?void 0:j.name)??y},h=r!=null&&r.agent?e.perAgent.filter(y=>y.agentId===r.agent):e.perAgent,v=[["Agents",String(e.agents),"#/agents"],["Runs",String(e.runs.total),"#/runs"],["Active",String(e.runs.active),void 0,void 0,[typeof d=="number"&&d!==e.runs.active?`${d} running now`:"",e.runs.statusUnknown?`${e.runs.statusUnknown} unknown`:""].filter(Boolean).join(" · ")||void 0],["Needs input",i===null?"–":String(i??e.runs.needsInput),"#/runs?status=input_required",i??e.runs.needsInput?"text-warning-text":void 0],c===void 0?["Failed",String(e.runs.failed),"#/runs?status=failed",e.runs.failed?"text-destructive-text":void 0,wN(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}`,wN(e.runs.needsReview)??""].filter(Boolean).join(" · ")]];return t.jsx(bN,{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(Qt,{problem:n,onRetry:s,className:""}),u,o,t.jsxs("section",{className:"space-y-4","aria-label":b?"Registered agents and runs":void 0,children:[b&&t.jsx("h2",{className:"text-lead font-semibold",children:"Registered agents & runs"}),t.jsx("ul",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:v.map(([y,j,k,E,S])=>{const N=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:y}),t.jsx("p",{className:ae("mt-3 font-mono text-display leading-none",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})},y)})})]}),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:sB(e)})]}),r&&t.jsx(m2,{range:r.range,onRange:r.onRange,agent:r.agent,agents:e.perAgent,onAgent:r.onAgent})]}),t.jsx(h2,{a:e.analytics,basis:e.cost.basis,refreshing:r==null?void 0:r.refreshing})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsxs("h2",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:[t.jsx(Cf,{className:"size-4","aria-hidden":!0}),"Runs per agent"]}),h.length?t.jsx("ul",{children:h.map(y=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:cn(y.agentId,"runs"),className:"flex items-center justify-between gap-3 px-4 py-3 text-lead hover:bg-accent",children:[t.jsx("span",{className:"min-w-0 truncate",children:y.name}),t.jsx("span",{className:"font-mono text-body text-muted-foreground",children:y.runs})]})},y.agentId))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No agents yet."})]}),t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsxs("h2",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:[t.jsx(sd,{className:"size-4","aria-hidden":!0}),"Recent runs"]}),e.recent.length?t.jsx("ul",{children:e.recent.map(y=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(y.run_id)}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-accent",children:[t.jsx(Cl,{run:y}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-lead",children:Sn(y)}),t.jsx(iy,{run:y,className:"hidden sm:inline-flex"}),BU(y)&&t.jsx("span",{className:"shrink-0 text-small text-muted-foreground",children:"send a message to continue"})]}),t.jsx("span",{className:"hidden shrink-0 text-body text-muted-foreground md:inline",children:x(y.agent_id)}),y.ended_at&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",title:"How long it ran",children:dl(Date.parse(y.ended_at)-Date.parse(y.created_at))}),y.cost&&(y.cost.usd!==null||kl(y.cost))&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:no(y.cost,{ended:Ba(y.status)})}),t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:ht(y.created_at)})]})},y.run_id))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs yet."})]})]})]})})}const wN=e=>e?`${e} ${e===1?"needs":"need"} review`:void 0;function sB(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?Av.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 hs=e=>`#/runs/${encodeURIComponent(e)}`;function rB({asking:e,failed:n,failedAll:s,live:r,learning:o=[],agentName:i,onAnswer:c,onApprove:d,onHandBack:u,onRunAgain:f,onStop:g,problem:b,now:x=Date.now}){const h=DU(n.filter(R=>!es(R))),v=n.filter(R=>!R.imported_from&&es(R)),[,y]=p.useState(0);p.useEffect(()=>{if(!r.length)return;const R=setInterval(()=>y(P=>P+1),1e3);return()=>clearInterval(R)},[r.length]);const[j,k]=p.useState([]),E=(R,P,D)=>{const W=e.find(H=>H.run_id===R),K=W?Sn(W):R;k(H=>[...H.filter(q=>q.runId!==R),...D?[{runId:R,what:P,title:K,text:D}]:[]])},S=d&&(async(R,P,D,W,K)=>{const H=await(K?d(R,P,D,W,K):d(R,P,D,W));return E(R,P,H),H}),N=u&&(async(R,P,D)=>{const W=await u(R,D);return E(R,`ask:${P.asked_at}`,W),W}),$=R=>{var D;const P=Bi(R);return((D=R.pending)==null?void 0:D.kind)==="approval"?R.pending.id:P?`ask:${P.asked_at}`:null},_=VE(n),M=o.filter(R=>R.pending>0),O=M.reduce((R,P)=>R+P.pending,0),L=e.length+_+O;if(!L&&!r.length&&!b&&!j.length)return null;const A=x();return t.jsxs("section",{"aria-label":"Needs you",className:"space-y-3",children:[L>0&&t.jsxs("h2",{className:"caps text-small font-semibold",children:["Needs you ",t.jsxs("span",{className:"text-warning-text",children:["· ",L]})]}),b&&t.jsx("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:b}),j.filter(R=>!e.some(P=>P.run_id===R.runId&&$(P)===R.what)).map(R=>t.jsxs("p",{className:"flex items-start gap-3 border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("a",{href:hs(R.runId),className:"underline-offset-4 hover:underline",children:R.title}),": your answer wasn't taken. ",R.text]}),t.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>k(P=>P.filter(D=>D.runId!==R.runId)),children:"Dismiss"})]},R.runId)),e.length>0&&t.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(R=>{var P,D,W;return R.native?t.jsxs("li",{className:"space-y-2 border p-4",children:[t.jsx("a",{href:hs(R.run_id),className:"text-body underline underline-offset-2",children:Sn(R)}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native sessions cannot receive another message. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(R.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," to continue."]})]},R.run_id):((P=R.pending)==null?void 0:P.kind)==="approval"?t.jsx(oB,{run:R,pending:R.pending,agentName:i(R.agent_id),at:A,onApprove:S},`${R.run_id}:${R.pending.id}`):Bi(R)?t.jsx(aB,{run:R,ask:Bi(R),agentName:i(R.agent_id),at:A,onHandBack:N},`${R.run_id}:${Bi(R).asked_at}`):t.jsx(iB,{run:R,agentName:i(R.agent_id),at:A,onAnswer:c},`${R.run_id}:${((D=R.pending)==null?void 0:D.kind)==="question"?R.pending.asked_at:((W=R.pending)==null?void 0:W.kind)==="budget"?R.pending.at??"":""}`)})}),(h.length>0||v.length>0)&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps flex items-center justify-between gap-3 border-b px-4 py-2.5 text-label text-muted-foreground",children:[t.jsxs("span",{children:["Failed in the last 24 h · ",_]}),t.jsx("a",{href:"#/runs?status=failed",className:"-my-1 py-1 normal-case tracking-normal hover:text-foreground",children:s===void 0?"All failed runs →":`All ${s} failed ${s===1?"run":"runs"} →`})]}),t.jsxs("ul",{children:[h.map(R=>t.jsx(dB,{message:R.message,runs:R.runs,agentName:i,at:A,onRunAgain:f},R.message)),v.map(R=>t.jsx(jN,{run:R,agentName:i(R.agent_id)},R.run_id))]})]}),M.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 · ",O]}),t.jsx("ul",{children:M.map(R=>t.jsxs("li",{className:"flex min-w-0 items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:R.name}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:oy(R.pending)}),t.jsx("a",{href:`#/agents/${encodeURIComponent(R.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},R.agent_id))})]}),r.length>0&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Running now · ",r.length]}),t.jsx("ul",{children:r.map(R=>es(R)?t.jsx(jN,{run:R,agentName:i(R.agent_id)},R.run_id):t.jsx(uB,{run:R,agentName:i(R.agent_id),at:A,onStop:g},R.run_id))})]})]})}function oB({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(n$,{compact:!0,pending:n,heading:t.jsx(Dy,{run:e,agentName:s,since:`asked ${Od(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 aB({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(d$,{compact:!0,ask:n,heading:t.jsx(Dy,{run:e,agentName:s,since:`asked ${Od(n.asked_at,r)} ago`}),open:t.jsx("a",{href:hs(e.run_id),className:"text-body underline underline-offset-2",children:"Open its screen"}),onAnswer:o&&(i=>o(e.run_id,n,i))})})}function iB(e){var n;return((n=e.run.pending)==null?void 0:n.kind)==="budget"?t.jsx(lB,{run:e.run,pending:e.run.pending,agentName:e.agentName}):t.jsx(cB,{...e})}function lB({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:hs(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:Sn(e)})]}),t.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:s$(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:hs(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})})]})}function Dy({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:hs(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:Sn(e)}),s&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:s})]})}function cB({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=zU(i),[d,u]=p.useState(""),[f,g]=p.useState(!1),[b,x]=p.useState(null),[h,v]=p.useState(null),y=async k=>{k.preventDefault();const E=d.trim();if(!E||f)return;g(!0),x(null);const S=await r(e.run_id,E);g(!1),S?x(S):v(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(Dy,{run:e,agentName:n,since:o!=null&&o.asked_at?`asked ${Od(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:hs(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})]}):t.jsxs("form",{onSubmit:k=>void y(k),className:"mt-3 flex flex-wrap items-center gap-2",children:[c.map(k=>t.jsx("button",{type:"button",onClick:()=>u(k),className:ae("border px-3 py-1.5 text-body hover:border-border-strong",d===k?"border-warning text-warning-text":"border-border"),children:k},k)),t.jsx(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"}),b&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:b})]})]})}function dB({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),b=n.filter(k=>!f.has(k.run_id)),x=n.length-b.length,h=async()=>{c(!0),u(null);const{started:k,problem:E}=await o(b);c(!1),u(E),g(S=>new Set([...S,...k]))},v=x>0&&t.jsxs("span",{className:"font-mono text-small text-success-text",children:["Started again: ",x===1?"1 run":`${x} runs`]});if(!b.length)return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-border-strong","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 truncate font-mono text-small text-muted-foreground",children:e}),v]});const y=b[0],j=b.length===1;return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-destructive","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[j?t.jsxs("p",{className:"flex min-w-0 gap-3 text-lead",children:[t.jsx("span",{className:"shrink-0 font-mono text-small leading-5",children:s(y.agent_id)}),t.jsx("a",{href:hs(y.run_id),className:"min-w-0 truncate hover:underline",children:Sn(y)})]}):t.jsxs("p",{className:"text-lead",children:[b.length," runs failed ",t.jsxs("span",{className:"text-muted-foreground",children:["· ",[...new Set(b.map(k=>s(k.agent_id)))].join(", ")]})]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-small text-destructive-text",children:e}),!j&&t.jsxs("details",{className:"mt-1 text-body",children:[t.jsx("summary",{className:"cursor-pointer font-mono text-small text-muted-foreground",children:"The runs"}),t.jsx("ul",{className:"mt-1 space-y-1",children:b.map(k=>t.jsxs("li",{children:[t.jsx("a",{href:hs(k.run_id),className:"hover:underline",children:Sn(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:[Od(y.ended_at??y.created_at,r)," ago"]}),v,t.jsx(B,{type:"button",size:"sm",disabled:i,onClick:()=>void h(),children:j?"Run again":"Run all again"})]})}function jN({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," · ",Yo(es(e).runtime)]}),t.jsx("a",{href:hs(e.run_id),className:"text-lead hover:underline",children:Sn(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:hs(e.run_id),className:"caps shrink-0 text-small text-muted-foreground hover:text-foreground",children:"Open"})]})}function uB({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=hd(e.cost)?`${no(e.cost)} so far`:u===0?"nothing spent yet":typeof u=="number"?`${no(e.cost)} so far`:kl(e.cost)?no(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:hs(e.run_id),className:"min-w-0 flex-1 truncate text-lead hover:underline",children:Sn(e)}),t.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",dl(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:hs(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Steer"}),Um(e.status,e.state,e.kind,Fm,!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:hs(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 fB=[{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 E$(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 mB(e,n,s){const r=Wm(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 hB(e,n,s,r=Ys()){const i=(await Vr(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 $$="agentrun.console.start-here.dismissed",pB={hello:Ya,web:PN,plan:LT};function gB(){try{return localStorage.getItem($$)==="true"}catch{return!1}}function xB({harnesses:e,tools:n,onTry:s,imported:r=0,keySettings:o=!1,importAction:i,modelSetup:c}){const[d,u]=p.useState(gB),[f,g]=p.useState(!1),[b,x]=p.useState(!1),[h,v]=p.useState(null),[y,j]=p.useState(null),k=E$(e),E=async S=>{v(S.id),j(null);try{j(await s(S))}finally{v(null)}};return d?null:t.jsxs("section",{"aria-label":"Start here",className:"border bg-card p-5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-base font-semibold",children:"Bring your agents into view"}),t.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:"Connect your Claude Code or Codex setup on this server or another machine. Your coding agent helps choose a live connection or a history import. No model key needed to connect."}),r>0&&t.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:[r," imported ",r===1?"session":"sessions"," · ",t.jsx("a",{href:"#/runs",className:"text-primary-text underline-offset-4 hover:underline",children:"Browse history"})]})]}),t.jsx("button",{type:"button","aria-label":"Dismiss introduction",className:"shrink-0 p-1 text-muted-foreground hover:bg-accent hover:text-foreground",onClick:()=>{u(!0);try{localStorage.setItem($$,"true")}catch{}},children:t.jsx(Xo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[t.jsx(Xm,{}),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:()=>{x(!0),g(S=>!S)},children:["Run an agent here ",t.jsx(Or,{className:`size-3.5 transition-transform ${f?"rotate-180":""}`,"aria-hidden":!0})]})]}),b&&t.jsxs("div",{hidden:!f,className:"mt-4 border-t pt-4",children:[c,k?t.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:fB.map(S=>{const N=mB(S,k,n),$=pB[S.id]??Ya;return t.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[t.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[t.jsx($,{className:"size-4 text-primary-text","aria-hidden":!0}),S.name]}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:S.shows}),t.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:S.description}),N.ok?t.jsx(B,{type:"button",variant:S.id==="hello"?"solid":"outline",size:"sm",className:"mt-4 self-start",disabled:h!==null,onClick:()=>void 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."]}),y&&t.jsx("p",{className:"mt-3 font-mono text-body text-destructive-text",role:"alert",children:y})]})]})}const vB=["system","light","dark"],zx="agentrun.theme",yB="(prefers-color-scheme: dark)",dh=()=>{try{return globalThis.localStorage??null}catch{return null}},_$=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(yB):null;let Dx=null;function bB(e=dh()){try{const n=e==null?void 0:e.getItem(zx);return n==="light"||n==="dark"?n:"system"}catch{return"system"}}const Fx=(e=dh())=>Dx??bB(e);function wB(e,n=dh()){Dx=null;try{e==="system"?n==null||n.removeItem(zx):n==null||n.setItem(zx,e)}catch{Dx=e}}function Ux(e,n=document.documentElement,s=_$()){const r=e==="dark"||e==="system"&&!!(s!=null&&s.matches);n.classList.toggle("dark",r),n.classList.toggle("light",!r)}function jB(e=document.documentElement,n=_$(),s=dh()){Ux(Fx(s),e,n);const r=()=>{Fx(s)==="system"&&Ux("system",e,n)};return n==null||n.addEventListener("change",r),()=>n==null?void 0:n.removeEventListener("change",r)}const kB={mission:"Mission Control",playground:"Playground",agents:"Agents",runs:"Runs",dojo:"Dojo",templates:"Templates",triggers:"Triggers",settings:"Settings"},NB={mission:"#/",playground:"#/playground",agents:"#/agents",runs:"#/runs",dojo:"#/dojo",templates:"#/templates",triggers:"#/triggers",settings:"#/settings/keys"},SB={system:["System",Qa],light:["Light",XT],dark:["Dark",BT]};function CB(){const[e,n]=p.useState(()=>Fx()),s=r=>{wB(r),Ux(r),n(r)};return t.jsx("div",{role:"group","aria-label":"Theme",className:"flex gap-1 border p-1",children:vB.map(r=>{const[o,i]=SB[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 kN(){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 EB({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,b]=p.useState(!1),[x,h]=p.useState(!1),v=p.useRef(null),y=p.useRef(null),j=p.useRef(!1);p.useEffect(()=>{var L,A;x?(L=y.current)==null||L.focus():j.current&&((A=v.current)==null||A.focus())},[x]);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 $=L=>{c?c(L):location.hash=NB[L],b(!1)},_=()=>{i?i():location.hash="#/agents/new",b(!1)},M=kB[e];p.useEffect(()=>{document.title=M?`${M} · AgentRun`:"AgentRun"},[M]);const O=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 L;return(L=O.current)==null?void 0:L.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(kN,{})}),t.jsx(B,{size:"icon","aria-label":"Navigation","aria-expanded":g,onClick:()=>b(L=>!L),children:t.jsx(UT,{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(kN,{})})}),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(yr,{className:"w-full",active:e==="mission",onClick:()=>$("mission"),children:[t.jsx(PT,{className:"size-4 shrink-0","aria-hidden":!0}),"Mission Control"]}),t.jsxs(yr,{className:"w-full",active:e==="playground",onClick:()=>$("playground"),children:[t.jsx(mm,{className:"size-4 shrink-0","aria-hidden":!0}),"API playground"]}),t.jsxs("div",{children:[t.jsxs(yr,{className:ae("w-full",N&&"text-primary-text"),"aria-expanded":E,"aria-controls":"agent-navigation",onClick:()=>S(L=>!L),children:[t.jsx(Cf,{className:"size-4 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"flex-1",children:"Agents"}),t.jsx(Or,{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(yr,{className:"w-full pl-8",active:o,onClick:_,children:[t.jsx(AT,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Build"]}),t.jsxs(yr,{className:"w-full pl-8",active:e==="agents"&&!o,onClick:()=>$("agents"),children:[t.jsx(Cf,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Connected agents"]}),t.jsxs(yr,{className:"w-full pl-8",active:e==="templates",onClick:()=>$("templates"),children:[t.jsx(qx,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Templates"]}),t.jsxs(yr,{className:"w-full pl-8",active:e==="runs",onClick:()=>$("runs"),children:[t.jsx(sd,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Runs"]})]})]}),s&&t.jsxs(yr,{className:"w-full",active:e==="triggers",onClick:()=>$("triggers"),children:[t.jsx(fm,{className:"size-4 shrink-0","aria-hidden":!0}),"Triggers"]}),t.jsxs(yr,{className:"w-full",active:e==="dojo",onClick:()=>$("dojo"),children:[t.jsx(MC,{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(yr,{className:"w-full",active:e==="settings",onClick:()=>$("settings"),children:[t.jsx(IN,{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(CB,{}),t.jsxs(B,{onClick:d,className:"w-full justify-start",children:[t.jsx(zT,{"aria-hidden":!0}),"Sign out"]}),u&&(x?t.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:L=>{L.key==="Escape"&&k()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[t.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"xs",variant:"destructive",onClick:()=>{h(!1),u()},children:"Sign out everywhere"}),t.jsx(B,{size:"xs",ref:y,onClick:k,children:"Cancel"})]})]}):t.jsx(B,{size:"sm",variant:"ghost",ref:v,onClick:()=>h(!0),className:"mt-1 w-full justify-start text-muted-foreground hover:text-foreground",children:"Sign out everywhere"}))]})]}),t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx(eW,{}),r,t.jsx("main",{ref:O,tabIndex:-1,className:"relative min-h-0 min-w-0 flex-1 overflow-auto outline-none",children:f})]})]})}const Rg={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},NN={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 $B({mode:e,code:n=null,codeNeeded:s=!1,onSubmit:r,problem:o=null,offer:i=null}){const[c,d]=p.useState(""),[u,f]=p.useState(!1),[g,b]=p.useState(""),[x,h]=p.useState(n??"");p.useEffect(()=>{n!==null&&h(n)},[n]);const[v,y]=p.useState(o),[j,k]=p.useState(!1),E=e==="setup",S=E&&i!==null&&!("sessions"in i&&i.sessions===0),N=E&&(s||n!==null),$=e!=="token_link"&&c.length>0&&(!E||c===g&&c.length>=12)&&(!N||x.trim()!==""),_=async()=>{if(!$||!r)return;k(!0);const M=await r(c,N&&x.trim()?x.trim():void 0,E&&S&&u);k(!1),y(M)};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(Es,{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:NN[e].title}),t.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:NN[e].body}),e!=="token_link"&&t.jsxs("form",{className:"space-y-5",onSubmit:M=>{M.preventDefault(),_()},children:[N&&t.jsx(bt,{label:"Setup code",id:"setup-code",hint:"On Render: paste the server's AGENTRUN_TOKEN from the service's Environment tab. Elsewhere: paste the setup code the server printed in its log, or open the link it prints.",children:t.jsx(Pe,{name:"setup-code",value:x,onChange:M=>h(M.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),t.jsx(bt,{label:Rg[e].label,note:E?"12 characters or more.":void 0,children:t.jsxs("span",{className:ae(Hc,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Ia,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,type:"password",value:c,onChange:M=>d(M.target.value),autoComplete:Rg[e].autocomplete,autoFocus:!0,"aria-label":Rg[e].label,className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),E&&t.jsx(bt,{label:"Again",note:g&&g!==c?"The two passwords differ.":void 0,children:t.jsxs("span",{className:ae(Hc,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Ia,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,type:"password",value:g,onChange:M=>b(M.target.value),autoComplete:"new-password","aria-label":"Password again",className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),S&&t.jsxs("label",{className:"flex items-start gap-3 text-lead",children:[t.jsx("input",{type:"checkbox",name:"import",checked:u,onChange:M=>f(M.target.checked),className:"mt-1 size-4 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"block",children:"Import this machine's Claude Code, Codex and pi sessions"}),t.jsx("span",{className:"mt-1 block text-small text-muted-foreground","aria-live":"polite",children:_B(i)})]})]}),t.jsx(B,{type:"submit",variant:"solid",disabled:!$||j,"aria-busy":j||void 0,className:"w-full text-body",children:j?"Signing in":E?"Set password and continue":"Continue"}),v&&t.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:v}),!E&&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 SN=(e,n)=>`${e.toLocaleString("en-US")} ${n}${e===1?"":"s"}`,Ag="Each project becomes an agent, each session a run you can read.";function _B(e){return"counting"in e?`Counting sessions… ${Ag}`:e.sessions===null||e.projects===null?`The count isn't known. ${Ag}`:`${SN(e.sessions,"session")} in ${SN(e.projects,"project")}. ${Ag}`}function TB({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(Es,{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 T$=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.accounts)===!1};function RB(e,n){if(T$(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 AB=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.setup_code)===!0};function OB(e){var n,s;if(e.status===401)return"That is not the password.";if(e.status===429){const r=e.retryAfterMs===void 0?60:Math.max(1,Math.ceil(e.retryAfterMs/1e3));return`Too many sign-ins. Try again in ${r===1?"a second":r>=60?"a minute":`${r} seconds`}.`}return e.status===403&&/has its owner/.test(e.message)?"This server has its owner already: sign in.":e.status===403&&/a new one is in the server's log/.test(e.message)?"That setup code expired or was voided after too many wrong tries: a new one is in the server's log (on Render, the Logs tab).":e.status===403&&/takes the setup code/.test(e.message)?"Enter the setup code from the server's log.":e.status===403&&/setup code/.test(e.message)?"That setup code was refused: open the newest setup link in the server's log, or paste the server's token (AGENTRUN_TOKEN) here.":((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message}function R$(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 MB=1e4;function CN(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"&&am.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=gI(s[1]);return{section:"settings",settings:"mcp",signIn:jI(s[1]),...c?{add:c}:{}}}if(s=e.match(/^#\/settings\/github(?:\?(.*))?$/),s){const c=rW(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&&am.includes(i)?{status:i}:{},...r.get("archived")==="true"?{archived:!0}:{}}}function PB({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 Og;function LB(){if(!Og){const{code:e,rest:n}=R$(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${n}`),Og={code:e}}return Og.code}const IB=e=>Math.min(1e3*2**e,3e4),A$=1e3,zB=30;function DB(e){return e.state==="running"?"Importing this machine's sessions: agents appear as they arrive.":e.state==="stopped"?"The import of this machine's sessions stopped. It goes on when the server starts again.":`Imported ${`${e.runs.toLocaleString("en-US")} session${e.runs===1?"":"s"}`} into ${e.agents.toLocaleString("en-US")} agent${e.agents===1?"":"s"}${e.skipped?`; ${e.skipped.toLocaleString("en-US")} left out`:""}.`}function FB(){const[e]=p.useState(aP),[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(()=>KM({fetch:e.fetch,onSignedOut:()=>void d.current()}),[e]),[f,g]=p.useState(LB);p.useEffect(()=>{if(n!=="setup")return;const _=()=>{const{code:M,rest:O}=R$(location.hash);M!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${O}`),g(M))};return window.addEventListener("hashchange",_),_(),()=>window.removeEventListener("hashchange",_)},[n]);const[b,x]=p.useState(!1),h=async()=>{const _=await u.session(),M=T$(_)?await u.listAgents().then(()=>200,O=>O instanceof Fe?O.status:0):void 0;return{mode:RB(_,M),codeNeeded:AB(_)}},v=async()=>{const _=await h();return x(_.codeNeeded),_.mode},y=async()=>s(await v());d.current=async()=>{if(!(i.current!=="signed_in"||c.current)){c.current=!0;try{const _=await v();_!=="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,M;return h().then(O=>{!_||i.current!==null||(x(O.codeNeeded),s(O.mode),k(null))},O=>{if(!_||i.current!==null)return;const L=IB(E),A=O instanceof Fe?O:null,R=(A==null?void 0:A.code)==="http_error",P=R&&[502,503,504].includes(A.status);k({problem:A===null?Ut(O):P?`Its address answered ${A.status}, not the server.`:`GET /v2/auth/session answered ${A.status}${R?", not as this server answers":`: ${A.message}`}`,starting:P}),M=setTimeout(()=>S(D=>D+1),L)}),()=>{_=!1,clearTimeout(M)}},[u,E]);const[N,$]=p.useState(null);return p.useEffect(()=>{if(n!=="setup")return;let _=!0;return(async()=>{for(let M=!1;_;){const O=await u.setupImport().then(L=>L,()=>{});if(!_)return;if(O===void 0&&M)return void $({projects:null,sessions:null});if(O!==void 0&&(!O||!("counting"in O||"sessions"in O)||($(O),M=!0,!("counting"in O))))return;await new Promise(L=>setTimeout(L,A$))}})(),()=>{_=!1}},[u,n]),n===null&&j!==null?t.jsx(TB,{problem:j.problem,starting:j.starting,onRetry:()=>S(_=>_+1)}):n===null?t.jsx(B0,{connection:e,children:t.jsx(UB,{})}):n!=="signed_in"?t.jsx($B,{mode:n,code:f,codeNeeded:b,offer:N,problem:r&&n==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async(_,M,O)=>{try{return await(n==="setup"?u.setup(_,M,O):u.signIn(_)),o(!1),s("signed_in"),null}catch(L){return L instanceof Fe&&L.status===403&&n==="setup"&&await y().catch(()=>{}),L instanceof Fe?OB(L):L instanceof Error?L.message:String(L)}}},n):t.jsx(B0,{connection:e,children:t.jsx(WB,{v2:u,onSignedOut:()=>{o(!1),s("sign_in")}})})}function UB(){return Ty().state==="offline"?t.jsx(tW,{}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function WB(e){const n=p.useMemo(Ed,[e.v2]);return t.jsx(HB,{...e},n)}function HB({v2:e,onSignedOut:n}){var aa,vs,Pd,rs,Ld,Id,zd,ia,la,lo,ca,Dd,Fd,oi,_l,ai,co,Ud,ii,Et,Tl,Rl,li,Al,Ol,Ml,ci,da,Js,Xs,Zs;const{writable:s,whyNot:r}=u6(e),[o,i]=p.useState(null),[c,d]=p.useState(()=>CN()),[u,f]=p.useState(null),g=((vs=(aa=u==null?void 0:u.features)==null?void 0:aa.triggers)==null?void 0:vs.routes)===!0,[b,x]=p.useState(new Map);p.useEffect(()=>{if(!g)return;let pe=!0;return e.listTriggers().then(Te=>{pe&&x(new Map(Te.triggers.map(ze=>[ze.id,{name:ze.name,kind:ze.source.kind}])))},()=>{}),()=>{pe=!1}},[e,g,c.section,c.trigger]);const[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=p.useState(0),[S,N]=p.useState("30d"),$=S==="7d"?7:30,_=_v(e,{active:c.section==="mission"||c.section==="runs"&&!c.run&&!c.runsOf&&!c.archived&&!c.status,days:$}),[M,O]=p.useState(null),[L,A]=p.useState(!1),R=p.useRef(!1),[P,D]=p.useState(null),[W,K]=p.useState(null),[H,q]=p.useState(null),[F,G]=p.useState(0),U=p.useRef(null),[z,Y]=p.useState(!1),[J,X]=p.useState(!1),[le,se]=p.useState(!1),[fe,xe]=p.useState(null),[Ne,ge]=p.useState(null),[me,Le]=p.useState(!1),[Ue,De]=p.useState({}),[Ee,re]=p.useState(!1),_e=p.useRef(0),[Qe,he]=p.useState([]),Ie=p.useRef(-1),[et,pt]=p.useState(null),[oe,$e]=p.useState(0),st=p.useRef(0),Oe=pe=>{rf(pe)||(location.hash=pe)},[dt,Tt]=p.useState(null),[nt,ft]=p.useState(0);p.useEffect(()=>{let pe=!0;return(async()=>{let Te=!1;for(let ze=0;pe&&ze<zB;){const $t=await e.setupImport().then(jt=>jt,()=>{});if(!pe)return;if($t===void 0)ze+=1;else{if(ze=0,!$t||!("state"in $t))return;if(Tt($t),$t.state!=="running")return void(Te&&ft(jt=>jt+1));Te=!0}await new Promise(jt=>setTimeout(jt,A$))}})(),()=>{pe=!1}},[e]),p.useEffect(()=>{const pe=()=>{const Te=l9();rf(location.hash,()=>{Te&&history.go(-Te)})?Te&&history.go(Te):d(CN())};return window.addEventListener("hashchange",pe),()=>window.removeEventListener("hashchange",pe)},[]),p.useEffect(()=>i9(),[]);const Kt=p.useRef(0),Dt=p.useRef(!1),ye=()=>{const pe=++Kt.current;return e.capabilities().then(Te=>(pe===Kt.current&&f(Te),!0),()=>!1)};p.useEffect(()=>{ye()},[e]),p.useEffect(()=>{if(_e.current&&c.section!=="runs"&&c.section!=="mission"&&Ie.current===nt)return;Ie.current=nt;const pe=++_e.current;re(!1),Promise.allSettled([!1,!0].map(Te=>Vr(ze=>e.listAgents({archived:Te,cursor:ze}),ze=>ze.agents))).then(Te=>{if(pe!==_e.current)return;const ze=Object.fromEntries(Te.flatMap(jt=>jt.status==="fulfilled"?jt.value:[]).map(jt=>[jt.agent_id,jt.definition.name??jt.agent_id])),$t=Te.every(jt=>jt.status==="fulfilled");De(jt=>$t?ze:{...jt,...ze}),re($t)})},[e,c,nt]);const de={status:c.status,archived:c.archived};p.useEffect(()=>{if(c.section!=="runs"||c.run)return;const pe=++st.current;xe(null),pt(null),(c.runsOf?e.listAgentRuns(c.runsOf,50,null,de):e.listRuns(50,null,de)).then(Te=>{pe===st.current&&(xe(Te.runs),ge(Te.next_cursor))}).catch(Te=>{pe===st.current&&pt(Wt(Te,"the runs"))})},[e,c,nt,oe]);const We=pe=>{var Te;return Ue[pe]??((Te=it==null?void 0:it.find(ze=>ze.agent_id===pe))==null?void 0:Te.definition.name)??(Ee?pe:"")},Ze=u,at={harnesses:(Ze==null?void 0:Ze.harnesses)??[],tools:lL(Ze==null?void 0:Ze.tools),thinking:((Pd=Ze==null?void 0:Ze.features)==null?void 0:Pd.thinking)??[],...typeof((rs=u==null?void 0:u.limits)==null?void 0:rs.free_model_requests)=="number"?{freeRequests:u.limits.free_model_requests}:{}},Q=DD(Ze==null?void 0:Ze.tools),ve=UD(Ze==null?void 0:Ze.tools),He=[...(Id=(Ld=u==null?void 0:u.features)==null?void 0:Ld.tool_keys)!=null&&Id.routes?["keys"]:[],...Q.length||ve.length?["tools"]:[],"mcp","github","email","computers","workspace",...(ia=(zd=u==null?void 0:u.features)==null?void 0:zd.webhooks)!=null&&ia.routes?["webhook"]:[]],Se=pe=>Oe({runs:"#/runs",agents:"#/agents",playground:"#/playground",dojo:"#/dojo",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${He[0]??"keys"}`}[pe]),Je=p.useRef(Ys()).current,Nt=async pe=>{const Te=E$(at.harnesses);if(!Te)return"This server has no model to run it on yet.";try{const ze=await hB(e,pe,Te,Je);return Oe(`#/runs/${encodeURIComponent(ze)}`),null}catch(ze){return Ut(ze)}},zt=((h==null?void 0:h.analytics.by_source)??[]).filter(pe=>pe.source!=="live").reduce((pe,Te)=>pe+Te.runs,0),[it,An]=p.useState(null),[ps,Qs]=p.useState([]),[En,Wn]=p.useState(null),gs=p.useRef(En);gs.current=En;const[xs,fn]=p.useState(null),[Hn,_s]=p.useState(0),Bn=p.useRef(0);p.useEffect(()=>{An(null),fn(null),Wn(null),gs.current=null},[e,c.section,c.operation,c.playgroundAgent]),p.useEffect(()=>{if(c.section!=="playground"||c.operation)return;fn(null);const pe=++Bn.current;return Vr(Te=>e.listAgents({cursor:Te}),Te=>Te.agents).then(Te=>{var jt;if(pe!==Bn.current)return;const ze=Te.filter(os=>!os.archived_at),$t=gs.current??c.playgroundAgent;if($t&&!ze.some(os=>os.agent_id===$t)){An(null),Wn(null),fn("The selected agent is unavailable or archived. Choose another agent from Agents.");return}An(Te),Wn($t??((jt=ze[0])==null?void 0:jt.agent_id)??null)}).catch(Te=>{if(pe===Bn.current){const ze=Wt(Te,"the agents");fn(`${ze.why} ${ze.next}${ze.said?` (${ze.said})`:""}`)}}),()=>{Bn.current++}},[e,c.section,c.operation,c.playgroundAgent,Hn,nt]),p.useEffect(()=>{if(c.section!=="mission")return;let pe=!0;R.current=!0,j(null),A(!0);const Te=Ov(S);return Promise.all([e.statsOver({...Te?{from:Te}:{},...M?{agent:M}:{}}),M?e.listAgentRuns(M,10):e.listRuns(10)]).then(([ze,$t])=>{pe&&(v(hP(ze,$t.runs)),M||q(jt=>jt||UU($t.runs,ze.analytics.by_source)))}).catch(ze=>{pe&&j(Wt(ze,"Mission Control"))}).finally(()=>{pe&&(R.current=!1,A(!1))}),()=>{pe=!1,R.current=!1}},[e,c.section,k,S,M,nt]),JE(()=>E(pe=>pe+1)),p.useEffect(()=>{if(c.section!=="mission")return;const pe=()=>{!document.hidden&&!R.current&&E(ze=>ze+1)};window.addEventListener("focus",pe),document.addEventListener("visibilitychange",pe);const Te=setInterval(pe,15e3);return()=>{window.removeEventListener("focus",pe),document.removeEventListener("visibilitychange",pe),clearInterval(Te)}},[c.section]),p.useEffect(()=>{if(c.section!=="mission"){U.current=null;return}let pe=!0;const Te=U,ze=Gn=>Vr(qn=>e.listRuns(50,qn,{status:Gn}),qn=>qn.runs,2),$t=()=>Vr(Gn=>e.listAgents({archived:!1,cursor:Gn}),Gn=>Gn.agents).then(Gn=>{pe&&he(Gn.filter(qn=>Kf(qn)>0).map(qn=>({agent_id:qn.agent_id,name:qn.definition.name??qn.agent_id,pending:Kf(qn)})))},()=>{}),os=HU(()=>Promise.allSettled([ze("input_required"),ze("failed"),ze("working"),$t()]).then(([Gn,qn,di])=>{var uo,fo,Pr;if(!pe)return;const Mr=[Gn,qn,di],uh=Date.now()-FU;if(K(D0(null,Mr).problem),((uo=Mr[0])==null?void 0:uo.status)==="fulfilled"&&Y(!0),((fo=Mr[1])==null?void 0:fo.status)==="fulfilled"){X(!0);const Lr=Mr[1].value.map(hr=>hr.run_id),mo=Te.current;mo&&Lr.some(hr=>!mo.has(hr))&&E(hr=>hr+1),Te.current=new Set(Lr)}((Pr=Mr[2])==null?void 0:Pr.status)==="fulfilled"&&se(!0),D(Lr=>{const{needs:mo}=D0(Lr,Mr);return{asking:mo.asking.filter(YE),failed:mo.failed.filter(hr=>Date.parse(hr.ended_at??hr.created_at)>uh),live:mo.live}})}),1e4);return()=>{pe=!1,os()}},[e,c.section,F]);const Ts=p.useRef(fD()).current,Rs=()=>setTimeout(()=>G(pe=>pe+1),2500),On=async(pe,Te)=>{try{return await bC(Ts(pe),pe,Te,e.sendMessage),Rs(),null}catch(ze){return Ut(ze)}},ee=p.useRef(new Map).current,Me=async pe=>{const Te=[];try{for(const ze of pe){const $t=WU(ze.kind==="workflow"?ze:await e.getRun(ze.run_id));if("refusal"in $t)throw new Error($t.refusal);const jt=ee.get(ze.run_id)??Ed();ee.set(ze.run_id,jt),await e.startRun(ze.agent_id,$t.body,jt),Te.push(ze.run_id)}return Rs(),{started:Te,problem:null}}catch(ze){return Te.length&&Rs(),{started:Te,problem:Ut(ze)}}},mt=async pe=>{try{return await e.stop(pe),Rs(),null}catch(Te){return Ut(Te)}},At=async(pe,Te,ze,$t,jt)=>{let os=null;try{await e.answerApproval(pe,Te,ze,$t,jt)}catch(Gn){os=t$(Gn)}return G(Gn=>Gn+1),os},Jt=async(pe,Te)=>{let ze=null;try{await e.handBackComputer(pe,Te)}catch($t){ze=Mx($t,"hand")}return G($t=>$t+1),ze},Be=p.useRef(0);p.useEffect(()=>{const pe=++Be.current;Qs([]),En&&Vr(Te=>e.listRevisions(En,Te),Te=>Te.revisions).then(Te=>{pe===Be.current&&Qs(Te)}).catch(()=>{})},[e,En]);const te=async(pe,Te,ze)=>{const $t=performance.now();try{const jt=await e.startRun(pe,Te,ze);return{status:jt.status,ms:Math.round(performance.now()-$t),body:jt.run,runId:jt.run.run_id}}catch(jt){return _y(jt,Math.round(performance.now()-$t))}},be=((la=u==null?void 0:u.features)==null?void 0:la.efforts)??[],qe=u?((lo=u.features)==null?void 0:lo.learning)??null:void 0;at.learning=qe??void 0;const kt=(ca=u==null?void 0:u.models)==null?void 0:ca.ready;p.useEffect(()=>{if(kt!==!1)return;const pe=()=>{Dt.current||(Dt.current=!0,ye().finally(()=>{Dt.current=!1}))},Te=()=>ye(),ze=setInterval(pe,MB);return window.addEventListener("focus",Te),()=>{clearInterval(ze),window.removeEventListener("focus",Te)}},[e,kt]);const[Lt,lt]=p.useState(null);p.useEffect(()=>{if(kt!==!1)return;let pe=!0;return e.chatGPT().then(Te=>{pe&<(Bf(Te))},()=>{pe&<(null)}),()=>{pe=!1}},[e,kt]);const[bn,$n]=p.useState(!1),mr=pe=>{lt(pe),(pe.state==="pending"||pe.state==="signed_in")&&$n(!0),pe.state==="signed_in"&&ye()},Ht=(Dd=it==null?void 0:it.find(pe=>pe.agent_id===En))==null?void 0:Dd.definition,ri=(Ht==null?void 0:Ht.native)||es(Ht),io=c.operation?c.playgroundAgent:En??c.playgroundAgent;return t.jsx(qE.Provider,{value:b,children:t.jsx(EB,{active:c.section,building:c.section==="agents"&&c.agent===null,onBuild:()=>Oe("#/agents/new"),settings:He.length>0,triggers:g,onNavigate:Se,onSignOut:()=>{const pe=()=>void e.signOut().then(n,Te=>i(Te instanceof Fe?Te.message:"The sign-out did not reach the server. Try again."));rf(null,pe)||pe()},onSignOutEverywhere:()=>{const pe=()=>void e.signOutEverywhere().then(n,Te=>i(Te instanceof Fe?Te.message:"The sign-out did not reach the server. Try again."));rf(null,pe)||pe()},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]}),dt&&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:DB(dt)}),dt.state!=="running"&&t.jsx(B,{size:"xs",type:"button",onClick:()=>Tt(null),children:"Dismiss"})]})]}),children:c.section==="settings"?t.jsx(RU,{active:c.settings??"keys",offered:He,children:c.settings==="tools"?t.jsx(sW,{v2:e,choices:Q,gates:ve,harnesses:at.harnesses,mcp:!!((Fd=u==null?void 0:u.features)!=null&&Fd.mcp_client),onSaved:ye,onOpen:ye}):c.settings==="mcp"?t.jsx(uW,{v2:e,signIn:c.signIn,add:c.add,writable:s,whyNot:r,choices:Q}):c.settings==="github"?t.jsx(lW,{v2:e,returned:c.github}):c.settings==="email"?t.jsx(AW,{v2:e,writable:s,whyNot:r}):c.settings==="computers"?t.jsx(zW,{v2:e,writable:s,whyNot:r}):c.settings==="workspace"?t.jsx(YW,{v2:e,writable:s,whyNot:r}):c.settings==="webhook"?t.jsx(MW,{v2:e}):t.jsx(QU,{v2:e,onChange:ye,writable:s,whyNot:r,harnesses:at.harnesses,plan:t.jsx(p6,{v2:e,writable:s,whyNot:r,onChange:()=>void ye()})})}):c.section==="dojo"?t.jsx(lF,{v2:e,server:qe},nt):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(nB,{hasObservedSessions:!!((oi=_.data)!=null&&oi.sessions.length),observations:t.jsx(Tv,{read:_,view:"summary",days:$}),view:h,error:y,onRetry:()=>E(pe=>pe+1),actions:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"icon","aria-label":"Refresh Mission Control",disabled:L,onClick:()=>{E(pe=>pe+1),G(pe=>pe+1)},children:t.jsx(Jo,{className:"size-4","aria-hidden":!0})}),t.jsx(nn,{label:"Query",prompt:Dm(location.origin,M??void 0),playgroundHref:Rv(M??void 0)}),t.jsx(Xm,{variant:"primary"})]}),scope:{range:S,onRange:N,agent:M,onAgent:O,refreshing:L&&h!==null},asking:P&&z?P.asking.length:null,failed:P&&J?VE(P.failed):null,live:P&&le?P.live.length:null,needsYou:P&&t.jsx(rB,{asking:P.asking,failed:P.failed,failedAll:h==null?void 0:h.runs.failed,live:P.live,learning:Qe,problem:W,agentName:We,onAnswer:On,onApprove:At,onHandBack:Jt,onRunAgain:Me,onStop:mt}),startHere:H===!1&&!((_l=_.data)!=null&&_l.sessions.length)?t.jsx(xB,{harnesses:at.harnesses,tools:at.tools,onTry:Nt,imported:zt,keySettings:((co=(ai=u==null?void 0:u.features)==null?void 0:ai.tool_keys)==null?void 0:co.routes)===!0&&u.features.tool_keys.at_rest==="sealed",modelSetup:u&&(u.models.ready===!1||bn)?t.jsx(SW,{v2:e,needs:u.models.needs,model:u.models.default,onSaved:ye,writable:s,whyNot:r,plan:Lt,harnesses:at.harnesses,onPlan:mr,onDone:()=>$n(!1)}):void 0}):void 0})})}):c.section==="templates"?t.jsx(O0,{v2:e,name:c.template,install:c.install,go:Oe},c.install!==void 0?`install:${c.install}`:c.template??""):c.section==="triggers"?t.jsx(H8,{v2:e,view:{trigger:c.trigger,kind:c.kind,edit:c.edit},go:Oe,agentName:We,minEvery:(ii=(Ud=u==null?void 0:u.features)==null?void 0:Ud.triggers)==null?void 0:ii.min_every_s,failuresToPause:(Tl=(Et=u==null?void 0:u.features)==null?void 0:Et.triggers)==null?void 0:Tl.failures_to_pause,publicUrl:(li=(Rl=u==null?void 0:u.features)==null?void 0:Rl.triggers)==null?void 0:li.public_url}):c.section==="playground"?t.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 items-center gap-2 border-b px-5",children:[t.jsx(mm,{className:"size-4","aria-hidden":!0}),t.jsx("h1",{className:"caps text-body font-semibold",children:"API playground"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-6 py-4",children:[t.jsx("label",{className:"sr-only",htmlFor:"api-operation",children:"API operation"}),t.jsx(Ct,{id:"api-operation",label:"API operation",value:c.operation??"run",onChange:pe=>{const Te=io,ze=new URLSearchParams;pe!=="run"&&ze.set("operation",pe),pe!=="create-agent"&&pe!=="apply-template"&&Te&&ze.set("agent",Te),Oe(`#/playground${ze.size?`?${ze}`:""}`)},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:!io}]}),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(O0,{v2:e,name:c.template,go:Oe,playground:!0,draft:c.draft},c.template??"")}):c.operation==="list-runs"?t.jsx($U,{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(_U,{v2:e,operation:c.operation,origin:location.origin,agentId:c.playgroundAgent,draft:c.draft,harnesses:at.harnesses},`${c.operation}:${c.playgroundAgent??""}:${c.draft??""}`):t.jsxs(t.Fragment,{children:[!ri&&((Al=u==null?void 0:u.models)==null?void 0:Al.ready)===!1&&t.jsx(CW,{needs:u.models.needs,source:u.models.source,model:u.models.default,settings:((Ml=(Ol=u.features)==null?void 0:Ol.tool_keys)==null?void 0:Ml.routes)===!0&&u.features.tool_keys.at_rest==="sealed",chatgpt:(Lt==null?void 0:Lt.state)==="signed_out"||(Lt==null?void 0:Lt.state)==="expired"}),xs&&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: ",xs]}),t.jsx(B,{size:"sm",className:"mt-3",type:"button",onClick:()=>_s(pe=>pe+1),children:"Try again"})]}),it&&t.jsx(CU,{agents:it.filter(pe=>!pe.archived_at),revisions:ps,efforts:be,origin:location.origin,agentId:En??void 0,onAgent:Wn,onSend:te,limits:u==null?void 0:u.limits,removeUpload:e.deleteUpload,onOpenRun:pe=>Oe(`#/runs/${encodeURIComponent(pe)}`),live:pe=>t.jsx(yN,{v2:e,runId:pe,caps:u,agentName:We},pe)})]})]}):c.section==="agents"?c.observation?t.jsx(YM,{v2:e,sessionId:c.observation,go:Oe}):c.nativeConnect?t.jsx(t6,{v2:e,go:Oe,initialSource:c.connectionSource}):c.agent===void 0?t.jsx(n6,{v2:e,archived:!!c.archived,go:Oe},nt):c.agent===null?t.jsx(gU,{origin:location.origin,v2:e}):c.agent!==null&&!c.edit?t.jsx(ZD,{v2:e,agentId:c.agent,tab:c.tab,notes:c.notes,learning:qe,routePrefix:(ci=Ze==null?void 0:Ze.models)==null?void 0:ci.route_prefix,harnesses:at.harnesses,efforts:be,limits:u==null?void 0:u.limits,places:Ok(u),go:Oe},c.agent):t.jsx(s6,{v2:e,choices:Q,gates:ve,focusTool:c.tool,caps:{...at,routePrefix:(da=Ze==null?void 0:Ze.models)==null?void 0:da.route_prefix,decisionProvider:oL(u==null?void 0:u.workflows),places:Ok(u),mcp:!!((Js=u==null?void 0:u.features)!=null&&Js.mcp_client),mcpHarnesses:(Zs=(Xs=u==null?void 0:u.features)==null?void 0:Xs.mcp_client)==null?void 0:Zs.harnesses},agentId:c.agent,go:Oe},`${c.agent??"new"}:${c.tool??""}`):c.run?t.jsx(yN,{v2:e,runId:c.run,caps:u,agentName:We},c.run):t.jsx(yU,{observations:!c.runsOf&&!c.archived&&!c.status?_:void 0,runs:fe,agentName:We,agentId:c.runsOf,error:et,onRetry:()=>$e(pe=>pe+1),onOpen:pe=>Oe(`#/runs/${encodeURIComponent(pe)}`),loadingMore:me,filter:de,onFilter:pe=>Oe(PB({runsOf:c.runsOf,...pe})),onMore:Ne?()=>{const pe=st.current;Le(!0),(c.runsOf?e.listAgentRuns(c.runsOf,50,Ne,de):e.listRuns(50,Ne,de)).then(Te=>{pe===st.current&&(xe(ze=>gx(ze??[],Te.runs)),ge(Te.next_cursor),pt(null))}).catch(Te=>pt(Wt(Te,"more runs"))).finally(()=>Le(!1))}:void 0})})})}jB();gT.createRoot(document.getElementById("root")).render(t.jsx(p.StrictMode,{children:t.jsx(O5,{children:t.jsx(FB,{})})}));
|