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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/README.md +213 -24
  3. package/dist/cli.js +42 -8
  4. package/dist/composio-preset.d.ts +4 -3
  5. package/dist/composio-preset.js +12 -4
  6. package/dist/composio-triggers.d.ts +20 -2
  7. package/dist/composio-triggers.js +183 -17
  8. package/dist/computer-lost.d.ts +11 -0
  9. package/dist/computer-lost.js +19 -0
  10. package/dist/computer-record.d.ts +10 -2
  11. package/dist/computer-record.js +50 -18
  12. package/dist/computer-setting.d.ts +1 -0
  13. package/dist/computer-setting.js +2 -2
  14. package/dist/console/assets/index-BUktRvS-.css +1 -0
  15. package/dist/console/assets/index-nB9kTfIN.js +711 -0
  16. package/dist/console/index.html +2 -2
  17. package/dist/errors.d.ts +1 -0
  18. package/dist/errors.js +3 -0
  19. package/dist/harness-table.d.ts +51 -3
  20. package/dist/harness-table.js +101 -13
  21. package/dist/harness.d.ts +18 -1
  22. package/dist/harness.js +21 -9
  23. package/dist/host.d.ts +12 -10
  24. package/dist/host.js +18 -16
  25. package/dist/import-worker.d.ts +3 -0
  26. package/dist/import-worker.js +7 -5
  27. package/dist/import.d.ts +22 -1
  28. package/dist/import.js +141 -28
  29. package/dist/learn/check.d.ts +3 -0
  30. package/dist/learn/check.js +1 -1
  31. package/dist/learn/compile.js +1 -1
  32. package/dist/learn/delete.d.ts +17 -0
  33. package/dist/learn/delete.js +44 -0
  34. package/dist/learn/promote.d.ts +7 -1
  35. package/dist/learn/promote.js +8 -4
  36. package/dist/learn/skills.d.ts +4 -0
  37. package/dist/learn/skills.js +17 -1
  38. package/dist/learn/workflow-nodes.d.ts +22 -1
  39. package/dist/learn/workflow-nodes.js +28 -9
  40. package/dist/learning-cost.d.ts +100 -0
  41. package/dist/learning-cost.js +116 -1
  42. package/dist/learning-evals.d.ts +2 -0
  43. package/dist/learning-evals.js +4 -3
  44. package/dist/learning-routes.d.ts +8 -0
  45. package/dist/learning-routes.js +17 -0
  46. package/dist/learning.d.ts +1 -1
  47. package/dist/listen-first.d.ts +30 -0
  48. package/dist/listen-first.js +115 -0
  49. package/dist/llms.txt +2 -1
  50. package/dist/mcp-servers-store.d.ts +12 -12
  51. package/dist/model.d.ts +8 -4
  52. package/dist/model.js +16 -8
  53. package/dist/openapi.js +115 -39
  54. package/dist/owner.d.ts +8 -0
  55. package/dist/owner.js +11 -0
  56. package/dist/paid-calls.d.ts +6 -0
  57. package/dist/paid-calls.js +11 -1
  58. package/dist/place.d.ts +8 -3
  59. package/dist/place.js +13 -9
  60. package/dist/provider.js +15 -1
  61. package/dist/run-learning-served.d.ts +1 -1
  62. package/dist/run-model-key.d.ts +64 -0
  63. package/dist/run-model-key.js +147 -0
  64. package/dist/runner/adapter-loop.d.ts +6 -0
  65. package/dist/runner/adapter-loop.js +9 -2
  66. package/dist/runner/adapter-run-spec.d.ts +6 -3
  67. package/dist/runner/adapter-run-spec.js +70 -23
  68. package/dist/runner/adapters/index.d.ts +4 -2
  69. package/dist/runner/adapters/index.js +13 -4
  70. package/dist/runner/audit.d.ts +4 -0
  71. package/dist/runner/audit.js +15 -4
  72. package/dist/runner/beside.d.ts +2 -1
  73. package/dist/runner/beside.js +5 -2
  74. package/dist/runner/claim-secrets.d.ts +49 -0
  75. package/dist/runner/claim-secrets.js +110 -1
  76. package/dist/runner/cli-run-spec.d.ts +2 -1
  77. package/dist/runner/cli-run-spec.js +32 -13
  78. package/dist/runner/commands.d.ts +3 -6
  79. package/dist/runner/feedback-round.d.ts +3 -2
  80. package/dist/runner/feedback-round.js +7 -3
  81. package/dist/runner/harness-loops.js +30 -8
  82. package/dist/runner/journal-kinds.d.ts +5 -0
  83. package/dist/runner/learning-end.d.ts +3 -0
  84. package/dist/runner/learning-end.js +4 -0
  85. package/dist/runner/loop-contract.d.ts +6 -0
  86. package/dist/runner/loop-contract.js +4 -0
  87. package/dist/runner/loop.js +6 -2
  88. package/dist/runner/main.d.ts +1 -0
  89. package/dist/runner/main.js +24 -7
  90. package/dist/runner/memory-claim.d.ts +9 -6
  91. package/dist/runner/memory-claim.js +12 -9
  92. package/dist/runner/promotion.d.ts +5 -0
  93. package/dist/runner/promotion.js +46 -7
  94. package/dist/runner/reflect-hook.d.ts +4 -0
  95. package/dist/runner/reflect-hook.js +22 -3
  96. package/dist/runner/runner.js +57 -4
  97. package/dist/runner/store-secrets.js +9 -5
  98. package/dist/runner/workflow-spec.js +10 -2
  99. package/dist/runs-over-store.d.ts +5 -4
  100. package/dist/runs-over-store.js +13 -3
  101. package/dist/sdk/workflows.d.ts +1 -1
  102. package/dist/server.d.ts +64 -50
  103. package/dist/server.js +457 -120
  104. package/dist/store/index.d.ts +2 -2
  105. package/dist/store/index.js +1 -1
  106. package/dist/store/seal.d.ts +20 -2
  107. package/dist/store/seal.js +24 -8
  108. package/dist/store/sqlite/run-launch.d.ts +4 -1
  109. package/dist/store/sqlite/run-launch.js +12 -0
  110. package/dist/store/sqlite/store.d.ts +3 -2
  111. package/dist/store/sqlite/store.js +118 -16
  112. package/dist/store/store.d.ts +38 -3
  113. package/dist/store-reads/analytics.js +11 -1
  114. package/dist/store-reads/learning.d.ts +41 -2
  115. package/dist/store-reads/learning.js +158 -5
  116. package/dist/store-reads/stats.js +13 -3
  117. package/dist/store-view.d.ts +5 -1
  118. package/dist/store-view.js +12 -11
  119. package/dist/telemetry.d.ts +59 -0
  120. package/dist/telemetry.js +153 -0
  121. package/dist/tool-keys-store.d.ts +1 -1
  122. package/dist/tool-keys.d.ts +2 -2
  123. package/dist/tool-plane.d.ts +12 -12
  124. package/dist/tools.d.ts +11 -11
  125. package/dist/tools.js +18 -5
  126. package/dist/trigger-adapter.d.ts +3 -0
  127. package/dist/trigger-adapters.d.ts +4 -0
  128. package/dist/trigger-adapters.js +13 -0
  129. package/dist/trigger-composio.d.ts +58 -1
  130. package/dist/trigger-composio.js +160 -6
  131. package/dist/triggers.d.ts +4 -0
  132. package/dist/triggers.js +22 -3
  133. package/dist/validate.d.ts +11 -7
  134. package/dist/validate.js +8 -7
  135. package/dist/workspace/computer-for-claim.d.ts +15 -5
  136. package/dist/workspace/computer-for-claim.js +228 -32
  137. package/dist/workspace/resolve-computer.d.ts +8 -2
  138. package/dist/workspace/resolve-computer.js +1 -1
  139. package/package.json +10 -9
  140. package/dist/console/assets/index-BrcDSBD8.css +0 -1
  141. package/dist/console/assets/index-Bz6IWncl.js +0 -711
@@ -1,711 +0,0 @@
1
- var nT=Object.defineProperty;var sT=(e,n,s)=>n in e?nT(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var At=(e,n,s)=>sT(e,typeof n!="symbol"?n+"":n,s);function rT(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 jN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var zp={exports:{}},ic={},Dp={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 Jw;function oT(){if(Jw)return xt;Jw=1;var e=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.iterator;function x(z){return z===null||typeof z!="object"?null:(z=y&&z[y]||z["@@iterator"],typeof z=="function"?z:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function j(z,Y,se){this.props=z,this.context=Y,this.refs=b,this.updater=se||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,se){this.props=z,this.context=Y,this.refs=b,this.updater=se||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},P={key:!0,ref:!0,__self:!0,__source:!0};function O(z,Y,se){var Q,re={},te=null,he=null;if(Y!=null)for(Q in Y.ref!==void 0&&(he=Y.ref),Y.key!==void 0&&(te=""+Y.key),Y)$.call(Y,Q)&&!P.hasOwnProperty(Q)&&(re[Q]=Y[Q]);var ge=arguments.length-2;if(ge===1)re.children=se;else if(1<ge){for(var ye=Array(ge),xe=0;xe<ge;xe++)ye[xe]=arguments[xe+2];re.children=ye}if(z&&z.defaultProps)for(Q in ge=z.defaultProps,ge)re[Q]===void 0&&(re[Q]=ge[Q]);return{$$typeof:e,type:z,key:te,ref:he,props:re,_owner:_.current}}function M(z,Y){return{$$typeof:e,type:z.type,key:Y,ref:z.ref,props:z.props,_owner:z._owner}}function R(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function A(z){var Y={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(se){return Y[se]})}var L=/\/+/g;function D(z,Y){return typeof z=="object"&&z!==null&&z.key!=null?A(""+z.key):Y.toString(36)}function W(z,Y,se,Q,re){var te=typeof z;(te==="undefined"||te==="boolean")&&(z=null);var he=!1;if(z===null)he=!0;else switch(te){case"string":case"number":he=!0;break;case"object":switch(z.$$typeof){case e:case n:he=!0}}if(he)return he=z,re=re(he),z=Q===""?"."+D(he,0):Q,N(re)?(se="",z!=null&&(se=z.replace(L,"$&/")+"/"),W(re,Y,se,"",function(xe){return xe})):re!=null&&(R(re)&&(re=M(re,se+(!re.key||he&&he.key===re.key?"":(""+re.key).replace(L,"$&/")+"/")+z)),Y.push(re)),1;if(he=0,Q=Q===""?".":Q+":",N(z))for(var ge=0;ge<z.length;ge++){te=z[ge];var ye=Q+D(te,ge);he+=W(te,Y,se,ye,re)}else if(ye=x(z),typeof ye=="function")for(z=ye.call(z),ge=0;!(te=z.next()).done;)te=te.value,ye=Q+D(te,ge++),he+=W(te,Y,se,ye,re);else if(te==="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 he}function q(z,Y,se){if(z==null)return z;var Q=[],re=0;return W(z,Q,"","",function(te){return Y.call(se,te,re++)}),Q}function H(z){if(z._status===-1){var Y=z._result;Y=Y(),Y.then(function(se){(z._status===0||z._status===-1)&&(z._status=1,z._result=se)},function(se){(z._status===0||z._status===-1)&&(z._status=2,z._result=se)}),z._status===-1&&(z._status=0,z._result=Y)}if(z._status===1)return z._result.default;throw z._result}var K={current:null},U={transition:null},G={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:U,ReactCurrentOwner:_};function F(){throw Error("act(...) is not supported in production builds of React.")}return xt.Children={map:q,forEach:function(z,Y,se){q(z,function(){Y.apply(this,arguments)},se)},count:function(z){var Y=0;return q(z,function(){Y++}),Y},toArray:function(z){return q(z,function(Y){return Y})||[]},only:function(z){if(!R(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=F,xt.cloneElement=function(z,Y,se){if(z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+z+".");var Q=v({},z.props),re=z.key,te=z.ref,he=z._owner;if(Y!=null){if(Y.ref!==void 0&&(te=Y.ref,he=_.current),Y.key!==void 0&&(re=""+Y.key),z.type&&z.type.defaultProps)var ge=z.type.defaultProps;for(ye in Y)$.call(Y,ye)&&!P.hasOwnProperty(ye)&&(Q[ye]=Y[ye]===void 0&&ge!==void 0?ge[ye]:Y[ye])}var ye=arguments.length-2;if(ye===1)Q.children=se;else if(1<ye){ge=Array(ye);for(var xe=0;xe<ye;xe++)ge[xe]=arguments[xe+2];Q.children=ge}return{$$typeof:e,type:z.type,key:re,ref:te,props:Q,_owner:he}},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=R,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=U.transition;U.transition={};try{z()}finally{U.transition=Y}},xt.unstable_act=F,xt.useCallback=function(z,Y){return K.current.useCallback(z,Y)},xt.useContext=function(z){return K.current.useContext(z)},xt.useDebugValue=function(){},xt.useDeferredValue=function(z){return K.current.useDeferredValue(z)},xt.useEffect=function(z,Y){return K.current.useEffect(z,Y)},xt.useId=function(){return K.current.useId()},xt.useImperativeHandle=function(z,Y,se){return K.current.useImperativeHandle(z,Y,se)},xt.useInsertionEffect=function(z,Y){return K.current.useInsertionEffect(z,Y)},xt.useLayoutEffect=function(z,Y){return K.current.useLayoutEffect(z,Y)},xt.useMemo=function(z,Y){return K.current.useMemo(z,Y)},xt.useReducer=function(z,Y,se){return K.current.useReducer(z,Y,se)},xt.useRef=function(z){return K.current.useRef(z)},xt.useState=function(z){return K.current.useState(z)},xt.useSyncExternalStore=function(z,Y,se){return K.current.useSyncExternalStore(z,Y,se)},xt.useTransition=function(){return K.current.useTransition()},xt.version="18.3.1",xt}var Xw;function lm(){return Xw||(Xw=1,Dp.exports=oT()),Dp.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 Zw;function aT(){if(Zw)return ic;Zw=1;var e=lm(),n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(d,u,f){var g,y={},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)&&(y[g]=u[g]);if(d&&d.defaultProps)for(g in u=d.defaultProps,u)y[g]===void 0&&(y[g]=u[g]);return{$$typeof:n,type:d,key:x,ref:h,props:y,_owner:o.current}}return ic.Fragment=s,ic.jsx=c,ic.jsxs=c,ic}var ej;function iT(){return ej||(ej=1,zp.exports=aT()),zp.exports}var t=iT(),p=lm();const Ke=jN(p),Ag=rT({__proto__:null,default:Ke},[p]);var Iu={},Fp={exports:{}},us={},Up={exports:{}},Wp={};/**
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 tj;function lT(){return tj||(tj=1,(function(e){function n(U,G){var F=U.length;U.push(G);e:for(;0<F;){var z=F-1>>>1,Y=U[z];if(0<o(Y,G))U[z]=G,U[F]=Y,F=z;else break e}}function s(U){return U.length===0?null:U[0]}function r(U){if(U.length===0)return null;var G=U[0],F=U.pop();if(F!==G){U[0]=F;e:for(var z=0,Y=U.length,se=Y>>>1;z<se;){var Q=2*(z+1)-1,re=U[Q],te=Q+1,he=U[te];if(0>o(re,F))te<Y&&0>o(he,re)?(U[z]=he,U[te]=F,z=te):(U[z]=re,U[Q]=F,z=Q);else if(te<Y&&0>o(he,F))U[z]=he,U[te]=F,z=te;else break e}}return G}function o(U,G){var F=U.sortIndex-G.sortIndex;return F!==0?F:U.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,y=null,x=3,h=!1,v=!1,b=!1,j=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(U){for(var G=s(f);G!==null;){if(G.callback===null)r(f);else if(G.startTime<=U)r(f),G.sortIndex=G.expirationTime,n(u,G);else break;G=s(f)}}function N(U){if(b=!1,S(U),!v)if(s(u)!==null)v=!0,H($);else{var G=s(f);G!==null&&K(N,G.startTime-U)}}function $(U,G){v=!1,b&&(b=!1,k(O),O=-1),h=!0;var F=x;try{for(S(G),y=s(u);y!==null&&(!(y.expirationTime>G)||U&&!A());){var z=y.callback;if(typeof z=="function"){y.callback=null,x=y.priorityLevel;var Y=z(y.expirationTime<=G);G=e.unstable_now(),typeof Y=="function"?y.callback=Y:y===s(u)&&r(u),S(G)}else r(u);y=s(u)}if(y!==null)var se=!0;else{var Q=s(f);Q!==null&&K(N,Q.startTime-G),se=!1}return se}finally{y=null,x=F,h=!1}}var _=!1,P=null,O=-1,M=5,R=-1;function A(){return!(e.unstable_now()-R<M)}function L(){if(P!==null){var U=e.unstable_now();R=U;var G=!0;try{G=P(!0,U)}finally{G?D():(_=!1,P=null)}}else _=!1}var D;if(typeof E=="function")D=function(){E(L)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,q=W.port2;W.port1.onmessage=L,D=function(){q.postMessage(null)}}else D=function(){j(L,0)};function H(U){P=U,_||(_=!0,D())}function K(U,G){O=j(function(){U(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(U){U.callback=null},e.unstable_continueExecution=function(){v||h||(v=!0,H($))},e.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<U?Math.floor(1e3/U):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return s(u)},e.unstable_next=function(U){switch(x){case 1:case 2:case 3:var G=3;break;default:G=x}var F=x;x=G;try{return U()}finally{x=F}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(U,G){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var F=x;x=U;try{return G()}finally{x=F}},e.unstable_scheduleCallback=function(U,G,F){var z=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?z+F:z):F=z,U){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=F+Y,U={id:g++,callback:G,priorityLevel:U,startTime:F,expirationTime:Y,sortIndex:-1},F>z?(U.sortIndex=F,n(f,U),s(u)===null&&U===s(f)&&(b?(k(O),O=-1):b=!0,K(N,F-z))):(U.sortIndex=Y,n(u,U),v||h||(v=!0,H($))),U},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(U){var G=x;return function(){var F=x;x=G;try{return U.apply(this,arguments)}finally{x=F}}}})(Wp)),Wp}var nj;function cT(){return nj||(nj=1,Up.exports=lT()),Up.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 sj;function dT(){if(sj)return us;sj=1;var e=lm(),n=cT();function s(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,m=1;m<arguments.length;m++)l+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(a,l){c(a,l),c(a+"Capture",l)}function c(a,l){for(o[a]=l,a=0;a<l.length;a++)r.add(l[a])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,g={},y={};function x(a){return u.call(y,a)?!0:u.call(g,a)?!1:f.test(a)?y[a]=!0:(g[a]=!0,!1)}function h(a,l,m,w){if(m!==null&&m.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return w?!1:m!==null?!m.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function 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 b(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 b(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];j[l]=new b(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){j[a]=new b(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){j[a]=new b(a,2,!1,a,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){j[a]=new b(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){j[a]=new b(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){j[a]=new b(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){j[a]=new b(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){j[a]=new b(a,5,!1,a.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function E(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var l=a.replace(k,E);j[l]=new b(l,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var l=a.replace(k,E);j[l]=new b(l,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var l=a.replace(k,E);j[l]=new b(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){j[a]=new b(a,1,!1,a.toLowerCase(),null,!1,!1)}),j.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){j[a]=new b(a,1,!1,a.toLowerCase(),null,!0,!0)});function S(a,l,m,w){var C=j.hasOwnProperty(l)?j[l]:null;(C!==null?C.type!==0:w||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(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"),P=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),R=Symbol.for("react.provider"),A=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),U=Symbol.iterator;function G(a){return a===null||typeof a!="object"?null:(a=U&&a[U]||a["@@iterator"],typeof a=="function"?a:null)}var F=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 se=!1;function Q(a,l){if(!a||se)return"";se=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ue){var w=ue}Reflect.construct(a,[],l)}else{try{l.call()}catch(ue){w=ue}a.call(l.prototype)}else{try{throw Error()}catch(ue){w=ue}a()}}catch(ue){if(ue&&w&&typeof ue.stack=="string"){for(var C=ue.stack.split(`
35
- `),T=w.stack.split(`
36
- `),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 X=`
37
- `+C[I].replace(" at new "," at ");return a.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",a.displayName)),X}while(1<=I&&0<=V);break}}}finally{se=!1,Error.prepareStackTrace=m}return(a=a?a.displayName||a.name:"")?Y(a):""}function re(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=Q(a.type,!1),a;case 11:return a=Q(a.type.render,!1),a;case 1:return a=Q(a.type,!0),a;default:return""}}function te(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 P:return"Fragment";case _:return"Portal";case M:return"Profiler";case O:return"StrictMode";case D:return"Suspense";case W:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case A:return(a.displayName||"Context")+".Consumer";case R:return(a._context.displayName||"Context")+".Provider";case L:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case q:return l=a.displayName||null,l!==null?l:te(a.type)||"Memo";case H:l=a._payload,a=a._init;try{return te(a(l))}catch{}}return null}function he(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 te(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 ge(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function ye(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function xe(a){var l=ye(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 fe(a){a._valueTracker||(a._valueTracker=xe(a))}function De(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var m=l.getValue(),w="";return a&&(w=ye(a)?a.checked?"true":"false":a.value),a=w,a!==m?(l.setValue(a),!0):!1}function Fe(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 Le(a,l){var m=l.checked;return F({},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=ge(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 ae(a,l){l=l.checked,l!=null&&S(a,"checked",l,!1)}function $e(a,l){ae(a,l);var m=ge(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")?me(a,l.type,m):l.hasOwnProperty("defaultValue")&&me(a,l.type,ge(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(a.defaultChecked=!!l.defaultChecked)}function ot(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 me(a,l,m){(l!=="number"||Fe(a.ownerDocument)!==a)&&(m==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+m&&(a.defaultValue=""+m))}var Me=Array.isArray;function Ze(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=""+ge(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 bt(a,l){if(l.dangerouslySetInnerHTML!=null)throw Error(s(91));return F({},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(Me(m)){if(1<m.length)throw Error(s(93));m=m[0]}l=m}l==null&&(l=""),m=l}a._wrapperState={initialValue:ge(m)}}function Se(a,l){var m=ge(l.value),w=ge(l.defaultValue);m!=null&&(m=""+m,m!==a.value&&(a.value=m),l.defaultValue==null&&a.defaultValue!==m&&(a.defaultValue=m)),w!=null&&(a.defaultValue=""+w)}function tt(a){var l=a.textContent;l===a._wrapperState.initialValue&&l!==""&&l!==null&&(a.value=l)}function Ae(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 it(a,l){return a==null||a==="http://www.w3.org/1999/xhtml"?Ae(l):a==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var $t,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($t=$t||document.createElement("div"),$t.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=$t.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 Dt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ft=["Webkit","ms","Moz","O"];Object.keys(Dt).forEach(function(a){Ft.forEach(function(l){l=l+a.charAt(0).toUpperCase()+a.substring(1),Dt[l]=Dt[a]})});function be(a,l,m){return l==null||typeof l=="boolean"||l===""?"":m||typeof l!="number"||l===0||Dt.hasOwnProperty(a)&&Dt[a]?(""+l).trim():l+"px"}function de(a,l){a=a.style;for(var m in l)if(l.hasOwnProperty(m)){var w=m.indexOf("--")===0,C=be(m,l[m],w);m==="float"&&(m="cssFloat"),w?a.setProperty(m,C):a[m]=C}}var Ue=F({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 Xe(a,l){if(l){if(Ue[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 J=null;function ve(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var We=null,Ve=null,He=null;function gt(a){if(a=ql(a)){if(typeof We!="function")throw Error(s(280));var l=a.stateNode;l&&(l=Xd(l),We(a.stateNode,a.type,l))}}function kt(a){Ve?He?He.push(a):He=[a]:Ve=a}function lt(){if(Ve){var a=Ve,l=He;if(He=Ve=null,gt(a),l)for(a=0;a<l.length;a++)gt(l[a])}}function Vt(a,l){return a(l)}function ps(){}var Qs=!1;function $n(a,l,m){if(Qs)return a(l,m);Qs=!0;try{return Vt(a,l,m)}finally{Qs=!1,(Ve!==null||He!==null)&&(ps(),lt())}}function Wn(a,l){var m=a.stateNode;if(m===null)return null;var w=Xd(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 mn(a,l,m,w,C,T,I,V,X){var ue=Array.prototype.slice.call(arguments,3);try{l.apply(m,ue)}catch(ke){this.onError(ke)}}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,X){Hn=!1,_s=null,mn.apply(Rs,arguments)}function Z(a,l,m,w,C,T,I,V,X){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 Oe(a){var l=a,m=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(m=l.return),a=l.return;while(a)}return l.tag===3?m:null}function mt(a){if(a.tag===13){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function Ot(a){if(Oe(a)!==a)throw Error(s(188))}function Xt(a){var l=a.alternate;if(!l){if(l=Oe(a),l===null)throw Error(s(188));return l!==a?null:a}for(var m=a,w=l;;){var C=m.return;if(C===null)break;var T=C.alternate;if(T===null){if(w=C.return,w!==null){m=w;continue}break}if(C.child===T.child){for(T=C.child;T;){if(T===m)return Ot(C),a;if(T===w)return Ot(C),l;T=T.sibling}throw Error(s(188))}if(m.return!==w.return)m=C,w=T;else{for(var 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=Xt(a),a!==null?ee(a):null}function ee(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var l=ee(a);if(l!==null)return l;a=a.sibling}return null}var we=n.unstable_scheduleCallback,qe=n.unstable_cancelCallback,St=n.unstable_shouldYield,It=n.unstable_requestPaint,ct=n.unstable_now,wn=n.unstable_getCurrentPriorityLevel,_n=n.unstable_ImmediatePriority,mr=n.unstable_UserBlockingPriority,Bt=n.unstable_NormalPriority,si=n.unstable_LowPriority,ao=n.unstable_IdlePriority,ra=null,vs=null;function Od(a){if(vs&&typeof vs.onCommitFiberRoot=="function")try{vs.onCommitFiberRoot(ra,a,void 0,(a.current.flags&128)===128)}catch{}}var rs=Math.clz32?Math.clz32:Md,Pd=Math.log,Ld=Math.LN2;function Md(a){return a>>>=0,a===0?32:31-(Pd(a)/Ld|0)|0}var oa=64,aa=4194304;function io(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 ia(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=io(V):(T&=I,T!==0&&(w=io(T)))}else I=m&~C,I!==0?w=io(I):T!==0&&(w=io(T));if(w===0)return 0;if(l!==0&&l!==w&&(l&C)===0&&(C=w&-w,T=l&-l,C>=T||C===16&&(T&4194240)!==0))return l;if((w&4)!==0&&(w|=m&16),l=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 Id(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 zd(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,X=C[I];X===-1?((V&m)===0||(V&w)!==0)&&(C[I]=Id(V,l)):X<=l&&(a.expiredLanes|=V),T&=~V}}function ri(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function _l(){var a=oa;return oa<<=1,(oa&4194240)===0&&(oa=64),a}function oi(a){for(var l=[],m=0;31>m;m++)l.push(a);return l}function lo(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 Dd(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 ai(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 _t=0;function Tl(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var Rl,ii,Al,Ol,Pl,li=!1,la=[],Js=null,Xs=null,Zs=null,pe=new Map,_e=new Map,Ie=[],Tt="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 Nt(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":_e.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&&ii(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,_e.set(T,os(_e.get(T)||null,a,l,m,w,C)),!0}return!1}function qn(a){var l=ca(a.target);if(l!==null){var m=Oe(l);if(m!==null){if(l=m.tag,l===13){if(l=mt(m),l!==null){a.blockedOn=l,Pl(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 ci(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var m=uh(a.domEventName,a.eventSystemFlags,l[0],a.nativeEvent);if(m===null){m=a.nativeEvent;var w=new m.constructor(m.type,m);J=w,m.target.dispatchEvent(w),J=null}else return l=ql(m),l!==null&&ii(l),a.blockedOn=m,!1;l.shift()}return!0}function Or(a,l,m){ci(a)&&m.delete(l)}function ch(){li=!1,Js!==null&&ci(Js)&&(Js=null),Xs!==null&&ci(Xs)&&(Xs=null),Zs!==null&&ci(Zs)&&(Zs=null),pe.forEach(Or),_e.forEach(Or)}function co(a,l){a.blockedOn===l&&(a.blockedOn=null,li||(li=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,ch)))}function uo(a){function l(C){return co(C,a)}if(0<la.length){co(la[0],a);for(var m=1;m<la.length;m++){var w=la[m];w.blockedOn===a&&(w.blockedOn=null)}}for(Js!==null&&co(Js,a),Xs!==null&&co(Xs,a),Zs!==null&&co(Zs,a),pe.forEach(l),_e.forEach(l),m=0;m<Ie.length;m++)w=Ie[m],w.blockedOn===a&&(w.blockedOn=null);for(;0<Ie.length&&(m=Ie[0],m.blockedOn===null);)qn(m),m.blockedOn===null&&Ie.shift()}var Pr=N.ReactCurrentBatchConfig,Lr=!0;function fo(a,l,m,w){var C=_t,T=Pr.transition;Pr.transition=null;try{_t=1,dh(a,l,m,w)}finally{_t=C,Pr.transition=T}}function hr(a,l,m,w){var C=_t,T=Pr.transition;Pr.transition=null;try{_t=4,dh(a,l,m,w)}finally{_t=C,Pr.transition=T}}function dh(a,l,m,w){if(Lr){var C=uh(a,l,m,w);if(C===null)$h(a,l,w,Fd,m),Nt(a,w);else if(Gn(C,a,l,m,w))w.stopPropagation();else if(Nt(a,w),l&4&&-1<Tt.indexOf(a)){for(;C!==null;){var T=ql(C);if(T!==null&&Rl(T),T=uh(a,l,m,w),T===null&&$h(a,l,w,Fd,m),T===C)break;C=T}C!==null&&w.stopPropagation()}else $h(a,l,w,null,m)}}var Fd=null;function uh(a,l,m,w){if(Fd=null,a=ve(w),a=ca(a),a!==null)if(l=Oe(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 Fd=a,null}function Ib(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(wn()){case _n:return 1;case mr:return 4;case Bt:case si:return 16;case ao:return 536870912;default:return 16}default:return 16}}var mo=null,fh=null,Ud=null;function zb(){if(Ud)return Ud;var a,l=fh,m=l.length,w,C="value"in mo?mo.value:mo.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 Ud=C.slice(a,1<w?1-w:void 0)}function Wd(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 Hd(){return!0}function Db(){return!1}function bs(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)?Hd:Db,this.isPropagationStopped=Db,this}return F(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=Hd)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=Hd)},persist:function(){},isPersistent:Hd}),l}var di={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},mh=bs(di),Ll=F({},di,{view:0,detail:0}),_$=bs(Ll),hh,ph,Ml,Bd=F({},Ll,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:xh,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!==Ml&&(Ml&&a.type==="mousemove"?(hh=a.screenX-Ml.screenX,ph=a.screenY-Ml.screenY):ph=hh=0,Ml=a),hh)},movementY:function(a){return"movementY"in a?a.movementY:ph}}),Fb=bs(Bd),T$=F({},Bd,{dataTransfer:0}),R$=bs(T$),A$=F({},Ll,{relatedTarget:0}),gh=bs(A$),O$=F({},di,{animationName:0,elapsedTime:0,pseudoElement:0}),P$=bs(O$),L$=F({},di,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),M$=bs(L$),I$=F({},di,{data:0}),Ub=bs(I$),z$={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},D$={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"},F$={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function U$(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=F$[a])?!!l[a]:!1}function xh(){return U$}var W$=F({},Ll,{key:function(a){if(a.key){var l=z$[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=Wd(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?D$[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:xh,charCode:function(a){return a.type==="keypress"?Wd(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Wd(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),H$=bs(W$),B$=F({},Bd,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wb=bs(B$),G$=F({},Ll,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:xh}),q$=bs(G$),K$=F({},di,{propertyName:0,elapsedTime:0,pseudoElement:0}),V$=bs(K$),Y$=F({},Bd,{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}),Q$=bs(Y$),J$=[9,13,27,32],vh=d&&"CompositionEvent"in window,Il=null;d&&"documentMode"in document&&(Il=document.documentMode);var X$=d&&"TextEvent"in window&&!Il,Hb=d&&(!vh||Il&&8<Il&&11>=Il),Bb=" ",Gb=!1;function qb(a,l){switch(a){case"keyup":return J$.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kb(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var ui=!1;function Z$(a,l){switch(a){case"compositionend":return Kb(l);case"keypress":return l.which!==32?null:(Gb=!0,Bb);case"textInput":return a=l.data,a===Bb&&Gb?null:a;default:return null}}function e_(a,l){if(ui)return a==="compositionend"||!vh&&qb(a,l)?(a=zb(),Ud=fh=mo=null,ui=!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 Hb&&l.locale!=="ko"?null:l.data;default:return null}}var t_={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 Vb(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!t_[a.type]:l==="textarea"}function Yb(a,l,m,w){kt(w),l=Yd(l,"onChange"),0<l.length&&(m=new mh("onChange","change",null,m,w),a.push({event:m,listeners:l}))}var zl=null,Dl=null;function n_(a){my(a,0)}function Gd(a){var l=gi(a);if(De(l))return a}function s_(a,l){if(a==="change")return l}var Qb=!1;if(d){var bh;if(d){var yh="oninput"in document;if(!yh){var Jb=document.createElement("div");Jb.setAttribute("oninput","return;"),yh=typeof Jb.oninput=="function"}bh=yh}else bh=!1;Qb=bh&&(!document.documentMode||9<document.documentMode)}function Xb(){zl&&(zl.detachEvent("onpropertychange",Zb),Dl=zl=null)}function Zb(a){if(a.propertyName==="value"&&Gd(Dl)){var l=[];Yb(l,Dl,a,ve(a)),$n(n_,l)}}function r_(a,l,m){a==="focusin"?(Xb(),zl=l,Dl=m,zl.attachEvent("onpropertychange",Zb)):a==="focusout"&&Xb()}function o_(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Gd(Dl)}function a_(a,l){if(a==="click")return Gd(l)}function i_(a,l){if(a==="input"||a==="change")return Gd(l)}function l_(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var er=typeof Object.is=="function"?Object.is:l_;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 ey(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function ty(a,l){var m=ey(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=ey(m)}}function ny(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?ny(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function sy(){for(var a=window,l=Fe();l instanceof a.HTMLIFrameElement;){try{var m=typeof l.contentWindow.location.href=="string"}catch{m=!1}if(m)a=l.contentWindow;else break;l=Fe(a.document)}return l}function wh(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 c_(a){var l=sy(),m=a.focusedElem,w=a.selectionRange;if(l!==m&&m&&m.ownerDocument&&ny(m.ownerDocument.documentElement,m)){if(w!==null&&wh(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=ty(m,T);var I=ty(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 d_=d&&"documentMode"in document&&11>=document.documentMode,fi=null,jh=null,Ul=null,kh=!1;function ry(a,l,m){var w=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;kh||fi==null||fi!==Fe(w)||(w=fi,"selectionStart"in w&&wh(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=Yd(jh,"onSelect"),0<w.length&&(l=new mh("onSelect","select",null,l,m),a.push({event:l,listeners:w}),l.target=fi)))}function qd(a,l){var m={};return m[a.toLowerCase()]=l.toLowerCase(),m["Webkit"+a]="webkit"+l,m["Moz"+a]="moz"+l,m}var mi={animationend:qd("Animation","AnimationEnd"),animationiteration:qd("Animation","AnimationIteration"),animationstart:qd("Animation","AnimationStart"),transitionend:qd("Transition","TransitionEnd")},Nh={},oy={};d&&(oy=document.createElement("div").style,"AnimationEvent"in window||(delete mi.animationend.animation,delete mi.animationiteration.animation,delete mi.animationstart.animation),"TransitionEvent"in window||delete mi.transitionend.transition);function Kd(a){if(Nh[a])return Nh[a];if(!mi[a])return a;var l=mi[a],m;for(m in l)if(l.hasOwnProperty(m)&&m in oy)return Nh[a]=l[m];return a}var ay=Kd("animationend"),iy=Kd("animationiteration"),ly=Kd("animationstart"),cy=Kd("transitionend"),dy=new Map,uy="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ho(a,l){dy.set(a,l),i(l,[a])}for(var Sh=0;Sh<uy.length;Sh++){var Ch=uy[Sh],u_=Ch.toLowerCase(),f_=Ch[0].toUpperCase()+Ch.slice(1);ho(u_,"on"+f_)}ho(ay,"onAnimationEnd"),ho(iy,"onAnimationIteration"),ho(ly,"onAnimationStart"),ho("dblclick","onDoubleClick"),ho("focusin","onFocus"),ho("focusout","onBlur"),ho(cy,"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(" "),m_=new Set("cancel close invalid load scroll toggle".split(" ").concat(Wl));function fy(a,l,m){var w=a.type||"unknown-event";a.currentTarget=m,Z(w,l,void 0,a),a.currentTarget=null}function my(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],X=V.instance,ue=V.currentTarget;if(V=V.listener,X!==T&&C.isPropagationStopped())break e;fy(C,V,ue),T=X}else for(I=0;I<w.length;I++){if(V=w[I],X=V.instance,ue=V.currentTarget,V=V.listener,X!==T&&C.isPropagationStopped())break e;fy(C,V,ue),T=X}}}if(Bn)throw a=Ts,Bn=!1,Ts=null,a}function Gt(a,l){var m=l[Ph];m===void 0&&(m=l[Ph]=new Set);var w=a+"__bubble";m.has(w)||(hy(l,a,2,!1),m.add(w))}function Eh(a,l,m){var w=0;l&&(w|=4),hy(m,a,w,l)}var Vd="_reactListening"+Math.random().toString(36).slice(2);function Hl(a){if(!a[Vd]){a[Vd]=!0,r.forEach(function(m){m!=="selectionchange"&&(m_.has(m)||Eh(m,!1,a),Eh(m,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[Vd]||(l[Vd]=!0,Eh("selectionchange",!1,l))}}function hy(a,l,m,w){switch(Ib(l)){case 1:var C=fo;break;case 4:C=hr;break;default:C=dh}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 $h(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 X=I.tag;if((X===3||X===4)&&(X=I.stateNode.containerInfo,X===C||X.nodeType===8&&X.parentNode===C))return;I=I.return}for(;V!==null;){if(I=ca(V),I===null)return;if(X=I.tag,X===5||X===6){w=T=I;continue e}V=V.parentNode}}w=w.return}$n(function(){var ue=T,ke=ve(m),Ce=[];e:{var je=dy.get(a);if(je!==void 0){var Ge=mh,Qe=a;switch(a){case"keypress":if(Wd(m)===0)break e;case"keydown":case"keyup":Ge=H$;break;case"focusin":Qe="focus",Ge=gh;break;case"focusout":Qe="blur",Ge=gh;break;case"beforeblur":case"afterblur":Ge=gh;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=Fb;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ge=R$;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ge=q$;break;case ay:case iy:case ly:Ge=P$;break;case cy:Ge=V$;break;case"scroll":Ge=_$;break;case"wheel":Ge=Q$;break;case"copy":case"cut":case"paste":Ge=M$;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ge=Wb}var Je=(l&4)!==0,an=!Je&&a==="scroll",le=Je?je!==null?je+"Capture":null:je;Je=[];for(var ne=ue,ce;ne!==null;){ce=ne;var Re=ce.stateNode;if(ce.tag===5&&Re!==null&&(ce=Re,le!==null&&(Re=Wn(ne,le),Re!=null&&Je.push(Bl(ne,Re,ce)))),an)break;ne=ne.return}0<Je.length&&(je=new Ge(je,Qe,null,m,ke),Ce.push({event:je,listeners:Je}))}}if((l&7)===0){e:{if(je=a==="mouseover"||a==="pointerover",Ge=a==="mouseout"||a==="pointerout",je&&m!==J&&(Qe=m.relatedTarget||m.fromElement)&&(ca(Qe)||Qe[Mr]))break e;if((Ge||je)&&(je=ke.window===ke?ke:(je=ke.ownerDocument)?je.defaultView||je.parentWindow:window,Ge?(Qe=m.relatedTarget||m.toElement,Ge=ue,Qe=Qe?ca(Qe):null,Qe!==null&&(an=Oe(Qe),Qe!==an||Qe.tag!==5&&Qe.tag!==6)&&(Qe=null)):(Ge=null,Qe=ue),Ge!==Qe)){if(Je=Fb,Re="onMouseLeave",le="onMouseEnter",ne="mouse",(a==="pointerout"||a==="pointerover")&&(Je=Wb,Re="onPointerLeave",le="onPointerEnter",ne="pointer"),an=Ge==null?je:gi(Ge),ce=Qe==null?je:gi(Qe),je=new Je(Re,ne+"leave",Ge,m,ke),je.target=an,je.relatedTarget=ce,Re=null,ca(ke)===ue&&(Je=new Je(le,ne+"enter",Qe,m,ke),Je.target=ce,Je.relatedTarget=an,Re=Je),an=Re,Ge&&Qe)t:{for(Je=Ge,le=Qe,ne=0,ce=Je;ce;ce=hi(ce))ne++;for(ce=0,Re=le;Re;Re=hi(Re))ce++;for(;0<ne-ce;)Je=hi(Je),ne--;for(;0<ce-ne;)le=hi(le),ce--;for(;ne--;){if(Je===le||le!==null&&Je===le.alternate)break t;Je=hi(Je),le=hi(le)}Je=null}else Je=null;Ge!==null&&py(Ce,je,Ge,Je,!1),Qe!==null&&an!==null&&py(Ce,an,Qe,Je,!0)}}e:{if(je=ue?gi(ue):window,Ge=je.nodeName&&je.nodeName.toLowerCase(),Ge==="select"||Ge==="input"&&je.type==="file")var et=s_;else if(Vb(je))if(Qb)et=i_;else{et=o_;var st=r_}else(Ge=je.nodeName)&&Ge.toLowerCase()==="input"&&(je.type==="checkbox"||je.type==="radio")&&(et=a_);if(et&&(et=et(a,ue))){Yb(Ce,et,m,ke);break e}st&&st(a,je,ue),a==="focusout"&&(st=je._wrapperState)&&st.controlled&&je.type==="number"&&me(je,"number",je.value)}switch(st=ue?gi(ue):window,a){case"focusin":(Vb(st)||st.contentEditable==="true")&&(fi=st,jh=ue,Ul=null);break;case"focusout":Ul=jh=fi=null;break;case"mousedown":kh=!0;break;case"contextmenu":case"mouseup":case"dragend":kh=!1,ry(Ce,m,ke);break;case"selectionchange":if(d_)break;case"keydown":case"keyup":ry(Ce,m,ke)}var rt;if(vh)e:{switch(a){case"compositionstart":var dt="onCompositionStart";break e;case"compositionend":dt="onCompositionEnd";break e;case"compositionupdate":dt="onCompositionUpdate";break e}dt=void 0}else ui?qb(a,m)&&(dt="onCompositionEnd"):a==="keydown"&&m.keyCode===229&&(dt="onCompositionStart");dt&&(Hb&&m.locale!=="ko"&&(ui||dt!=="onCompositionStart"?dt==="onCompositionEnd"&&ui&&(rt=zb()):(mo=ke,fh="value"in mo?mo.value:mo.textContent,ui=!0)),st=Yd(ue,dt),0<st.length&&(dt=new Ub(dt,a,null,m,ke),Ce.push({event:dt,listeners:st}),rt?dt.data=rt:(rt=Kb(m),rt!==null&&(dt.data=rt)))),(rt=X$?Z$(a,m):e_(a,m))&&(ue=Yd(ue,"onBeforeInput"),0<ue.length&&(ke=new Ub("onBeforeInput","beforeinput",null,m,ke),Ce.push({event:ke,listeners:ue}),ke.data=rt))}my(Ce,l)})}function Bl(a,l,m){return{instance:a,listener:l,currentTarget:m}}function Yd(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 hi(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function py(a,l,m,w,C){for(var T=l._reactName,I=[];m!==null&&m!==w;){var V=m,X=V.alternate,ue=V.stateNode;if(X!==null&&X===w)break;V.tag===5&&ue!==null&&(V=ue,C?(X=Wn(m,T),X!=null&&I.unshift(Bl(m,X,V))):C||(X=Wn(m,T),X!=null&&I.push(Bl(m,X,V)))),m=m.return}I.length!==0&&a.push({event:l,listeners:I})}var h_=/\r\n?/g,p_=/\u0000|\uFFFD/g;function gy(a){return(typeof a=="string"?a:""+a).replace(h_,`
38
- `).replace(p_,"")}function Qd(a,l,m){if(l=gy(l),gy(a)!==l&&m)throw Error(s(425))}function Jd(){}var _h=null,Th=null;function Rh(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 Ah=typeof setTimeout=="function"?setTimeout:void 0,g_=typeof clearTimeout=="function"?clearTimeout:void 0,xy=typeof Promise=="function"?Promise:void 0,x_=typeof queueMicrotask=="function"?queueMicrotask:typeof xy<"u"?function(a){return xy.resolve(null).then(a).catch(v_)}:Ah;function v_(a){setTimeout(function(){throw a})}function Oh(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),uo(l);return}w--}else m!=="$"&&m!=="$?"&&m!=="$!"||w++;m=C}while(m);uo(l)}function po(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 vy(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 pi=Math.random().toString(36).slice(2),pr="__reactFiber$"+pi,Gl="__reactProps$"+pi,Mr="__reactContainer$"+pi,Ph="__reactEvents$"+pi,b_="__reactListeners$"+pi,y_="__reactHandles$"+pi;function ca(a){var l=a[pr];if(l)return l;for(var m=a.parentNode;m;){if(l=m[Mr]||m[pr]){if(m=l.alternate,l.child!==null||m!==null&&m.child!==null)for(a=vy(a);a!==null;){if(m=a[pr])return m;a=vy(a)}return l}a=m,m=a.parentNode}return null}function ql(a){return a=a[pr]||a[Mr],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function gi(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(s(33))}function Xd(a){return a[Gl]||null}var Lh=[],xi=-1;function go(a){return{current:a}}function qt(a){0>xi||(a.current=Lh[xi],Lh[xi]=null,xi--)}function Ut(a,l){xi++,Lh[xi]=a.current,a.current=l}var xo={},Pn=go(xo),as=go(!1),da=xo;function vi(a,l){var m=a.type.contextTypes;if(!m)return xo;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 Zd(){qt(as),qt(Pn)}function by(a,l,m){if(Pn.current!==xo)throw Error(s(168));Ut(Pn,l),Ut(as,m)}function yy(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,he(a)||"Unknown",C));return F({},m,w)}function eu(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||xo,da=Pn.current,Ut(Pn,a),Ut(as,as.current),!0}function wy(a,l,m){var w=a.stateNode;if(!w)throw Error(s(169));m?(a=yy(a,l,da),w.__reactInternalMemoizedMergedChildContext=a,qt(as),qt(Pn),Ut(Pn,a)):qt(as),Ut(as,m)}var Ir=null,tu=!1,Mh=!1;function jy(a){Ir===null?Ir=[a]:Ir.push(a)}function w_(a){tu=!0,jy(a)}function vo(){if(!Mh&&Ir!==null){Mh=!0;var a=0,l=_t;try{var m=Ir;for(_t=1;a<m.length;a++){var w=m[a];do w=w(!0);while(w!==null)}Ir=null,tu=!1}catch(C){throw Ir!==null&&(Ir=Ir.slice(a+1)),we(_n,vo),C}finally{_t=l,Mh=!1}}return null}var bi=[],yi=0,nu=null,su=0,As=[],Os=0,ua=null,zr=1,Dr="";function fa(a,l){bi[yi++]=su,bi[yi++]=nu,nu=a,su=l}function ky(a,l,m){As[Os++]=zr,As[Os++]=Dr,As[Os++]=ua,ua=a;var w=zr;a=Dr;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,zr=1<<32-rs(l)+C|m<<C|w,Dr=T+a}else zr=1<<T|m<<C|w,Dr=a}function Ih(a){a.return!==null&&(fa(a,1),ky(a,1,0))}function zh(a){for(;a===nu;)nu=bi[--yi],bi[yi]=null,su=bi[--yi],bi[yi]=null;for(;a===ua;)ua=As[--Os],As[Os]=null,Dr=As[--Os],As[Os]=null,zr=As[--Os],As[Os]=null}var ys=null,ws=null,Yt=!1,tr=null;function Ny(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 Sy(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,ys=a,ws=po(l.firstChild),!0):!1;case 6:return l=a.pendingProps===""||l.nodeType!==3?null:l,l!==null?(a.stateNode=l,ys=a,ws=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(m=ua!==null?{id:zr,overflow:Dr}:null,a.memoizedState={dehydrated:l,treeContext:m,retryLane:1073741824},m=Is(18,null,null,0),m.stateNode=l,m.return=a,a.child=m,ys=a,ws=null,!0):!1;default:return!1}}function Dh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Fh(a){if(Yt){var l=ws;if(l){var m=l;if(!Sy(a,l)){if(Dh(a))throw Error(s(418));l=po(m.nextSibling);var w=ys;l&&Sy(a,l)?Ny(w,m):(a.flags=a.flags&-4097|2,Yt=!1,ys=a)}}else{if(Dh(a))throw Error(s(418));a.flags=a.flags&-4097|2,Yt=!1,ys=a}}}function Cy(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;ys=a}function ru(a){if(a!==ys)return!1;if(!Yt)return Cy(a),Yt=!0,!1;var l;if((l=a.tag!==3)&&!(l=a.tag!==5)&&(l=a.type,l=l!=="head"&&l!=="body"&&!Rh(a.type,a.memoizedProps)),l&&(l=ws)){if(Dh(a))throw Ey(),Error(s(418));for(;l;)Ny(a,l),l=po(l.nextSibling)}if(Cy(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=po(a.nextSibling);break e}l--}else m!=="$"&&m!=="$!"&&m!=="$?"||l++}a=a.nextSibling}ws=null}}else ws=ys?po(a.stateNode.nextSibling):null;return!0}function Ey(){for(var a=ws;a;)a=po(a.nextSibling)}function wi(){ws=ys=null,Yt=!1}function Uh(a){tr===null?tr=[a]:tr.push(a)}var j_=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 ou(a,l){throw a=Object.prototype.toString.call(l),Error(s(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a))}function $y(a){var l=a._init;return l(a._payload)}function _y(a){function l(le,ne){if(a){var ce=le.deletions;ce===null?(le.deletions=[ne],le.flags|=16):ce.push(ne)}}function m(le,ne){if(!a)return null;for(;ne!==null;)l(le,ne),ne=ne.sibling;return null}function w(le,ne){for(le=new Map;ne!==null;)ne.key!==null?le.set(ne.key,ne):le.set(ne.index,ne),ne=ne.sibling;return le}function C(le,ne){return le=Co(le,ne),le.index=0,le.sibling=null,le}function T(le,ne,ce){return le.index=ce,a?(ce=le.alternate,ce!==null?(ce=ce.index,ce<ne?(le.flags|=2,ne):ce):(le.flags|=2,ne)):(le.flags|=1048576,ne)}function I(le){return a&&le.alternate===null&&(le.flags|=2),le}function V(le,ne,ce,Re){return ne===null||ne.tag!==6?(ne=Ap(ce,le.mode,Re),ne.return=le,ne):(ne=C(ne,ce),ne.return=le,ne)}function X(le,ne,ce,Re){var et=ce.type;return et===P?ke(le,ne,ce.props.children,Re,ce.key):ne!==null&&(ne.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===H&&$y(et)===ne.type)?(Re=C(ne,ce.props),Re.ref=Kl(le,ne,ce),Re.return=le,Re):(Re=_u(ce.type,ce.key,ce.props,null,le.mode,Re),Re.ref=Kl(le,ne,ce),Re.return=le,Re)}function ue(le,ne,ce,Re){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==ce.containerInfo||ne.stateNode.implementation!==ce.implementation?(ne=Op(ce,le.mode,Re),ne.return=le,ne):(ne=C(ne,ce.children||[]),ne.return=le,ne)}function ke(le,ne,ce,Re,et){return ne===null||ne.tag!==7?(ne=ya(ce,le.mode,Re,et),ne.return=le,ne):(ne=C(ne,ce),ne.return=le,ne)}function Ce(le,ne,ce){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=Ap(""+ne,le.mode,ce),ne.return=le,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case $:return ce=_u(ne.type,ne.key,ne.props,null,le.mode,ce),ce.ref=Kl(le,null,ne),ce.return=le,ce;case _:return ne=Op(ne,le.mode,ce),ne.return=le,ne;case H:var Re=ne._init;return Ce(le,Re(ne._payload),ce)}if(Me(ne)||G(ne))return ne=ya(ne,le.mode,ce,null),ne.return=le,ne;ou(le,ne)}return null}function je(le,ne,ce,Re){var et=ne!==null?ne.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return et!==null?null:V(le,ne,""+ce,Re);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:return ce.key===et?X(le,ne,ce,Re):null;case _:return ce.key===et?ue(le,ne,ce,Re):null;case H:return et=ce._init,je(le,ne,et(ce._payload),Re)}if(Me(ce)||G(ce))return et!==null?null:ke(le,ne,ce,Re,null);ou(le,ce)}return null}function Ge(le,ne,ce,Re,et){if(typeof Re=="string"&&Re!==""||typeof Re=="number")return le=le.get(ce)||null,V(ne,le,""+Re,et);if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case $:return le=le.get(Re.key===null?ce:Re.key)||null,X(ne,le,Re,et);case _:return le=le.get(Re.key===null?ce:Re.key)||null,ue(ne,le,Re,et);case H:var st=Re._init;return Ge(le,ne,ce,st(Re._payload),et)}if(Me(Re)||G(Re))return le=le.get(ce)||null,ke(ne,le,Re,et,null);ou(ne,Re)}return null}function Qe(le,ne,ce,Re){for(var et=null,st=null,rt=ne,dt=ne=0,Nn=null;rt!==null&&dt<ce.length;dt++){rt.index>dt?(Nn=rt,rt=null):Nn=rt.sibling;var Rt=je(le,rt,ce[dt],Re);if(Rt===null){rt===null&&(rt=Nn);break}a&&rt&&Rt.alternate===null&&l(le,rt),ne=T(Rt,ne,dt),st===null?et=Rt:st.sibling=Rt,st=Rt,rt=Nn}if(dt===ce.length)return m(le,rt),Yt&&fa(le,dt),et;if(rt===null){for(;dt<ce.length;dt++)rt=Ce(le,ce[dt],Re),rt!==null&&(ne=T(rt,ne,dt),st===null?et=rt:st.sibling=rt,st=rt);return Yt&&fa(le,dt),et}for(rt=w(le,rt);dt<ce.length;dt++)Nn=Ge(rt,le,dt,ce[dt],Re),Nn!==null&&(a&&Nn.alternate!==null&&rt.delete(Nn.key===null?dt:Nn.key),ne=T(Nn,ne,dt),st===null?et=Nn:st.sibling=Nn,st=Nn);return a&&rt.forEach(function(Eo){return l(le,Eo)}),Yt&&fa(le,dt),et}function Je(le,ne,ce,Re){var et=G(ce);if(typeof et!="function")throw Error(s(150));if(ce=et.call(ce),ce==null)throw Error(s(151));for(var st=et=null,rt=ne,dt=ne=0,Nn=null,Rt=ce.next();rt!==null&&!Rt.done;dt++,Rt=ce.next()){rt.index>dt?(Nn=rt,rt=null):Nn=rt.sibling;var Eo=je(le,rt,Rt.value,Re);if(Eo===null){rt===null&&(rt=Nn);break}a&&rt&&Eo.alternate===null&&l(le,rt),ne=T(Eo,ne,dt),st===null?et=Eo:st.sibling=Eo,st=Eo,rt=Nn}if(Rt.done)return m(le,rt),Yt&&fa(le,dt),et;if(rt===null){for(;!Rt.done;dt++,Rt=ce.next())Rt=Ce(le,Rt.value,Re),Rt!==null&&(ne=T(Rt,ne,dt),st===null?et=Rt:st.sibling=Rt,st=Rt);return Yt&&fa(le,dt),et}for(rt=w(le,rt);!Rt.done;dt++,Rt=ce.next())Rt=Ge(rt,le,dt,Rt.value,Re),Rt!==null&&(a&&Rt.alternate!==null&&rt.delete(Rt.key===null?dt:Rt.key),ne=T(Rt,ne,dt),st===null?et=Rt:st.sibling=Rt,st=Rt);return a&&rt.forEach(function(tT){return l(le,tT)}),Yt&&fa(le,dt),et}function an(le,ne,ce,Re){if(typeof ce=="object"&&ce!==null&&ce.type===P&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:e:{for(var et=ce.key,st=ne;st!==null;){if(st.key===et){if(et=ce.type,et===P){if(st.tag===7){m(le,st.sibling),ne=C(st,ce.props.children),ne.return=le,le=ne;break e}}else if(st.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===H&&$y(et)===st.type){m(le,st.sibling),ne=C(st,ce.props),ne.ref=Kl(le,st,ce),ne.return=le,le=ne;break e}m(le,st);break}else l(le,st);st=st.sibling}ce.type===P?(ne=ya(ce.props.children,le.mode,Re,ce.key),ne.return=le,le=ne):(Re=_u(ce.type,ce.key,ce.props,null,le.mode,Re),Re.ref=Kl(le,ne,ce),Re.return=le,le=Re)}return I(le);case _:e:{for(st=ce.key;ne!==null;){if(ne.key===st)if(ne.tag===4&&ne.stateNode.containerInfo===ce.containerInfo&&ne.stateNode.implementation===ce.implementation){m(le,ne.sibling),ne=C(ne,ce.children||[]),ne.return=le,le=ne;break e}else{m(le,ne);break}else l(le,ne);ne=ne.sibling}ne=Op(ce,le.mode,Re),ne.return=le,le=ne}return I(le);case H:return st=ce._init,an(le,ne,st(ce._payload),Re)}if(Me(ce))return Qe(le,ne,ce,Re);if(G(ce))return Je(le,ne,ce,Re);ou(le,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,ne!==null&&ne.tag===6?(m(le,ne.sibling),ne=C(ne,ce),ne.return=le,le=ne):(m(le,ne),ne=Ap(ce,le.mode,Re),ne.return=le,le=ne),I(le)):m(le,ne)}return an}var ji=_y(!0),Ty=_y(!1),au=go(null),iu=null,ki=null,Wh=null;function Hh(){Wh=ki=iu=null}function Bh(a){var l=au.current;qt(au),a._currentValue=l}function Gh(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 Ni(a,l){iu=a,Wh=ki=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&l)!==0&&(ls=!0),a.firstContext=null)}function Ps(a){var l=a._currentValue;if(Wh!==a)if(a={context:a,memoizedValue:l,next:null},ki===null){if(iu===null)throw Error(s(308));ki=a,iu.dependencies={lanes:0,firstContext:a}}else ki=ki.next=a;return l}var ma=null;function qh(a){ma===null?ma=[a]:ma.push(a)}function Ry(a,l,m,w){var C=l.interleaved;return C===null?(m.next=m,qh(l)):(m.next=C.next,C.next=m),l.interleaved=m,Fr(a,w)}function Fr(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 Kh(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ay(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 Ur(a,l){return{eventTime:a,lane:l,tag:0,payload:null,callback:null,next:null}}function yo(a,l,m){var w=a.updateQueue;if(w===null)return null;if(w=w.shared,(Ct&2)!==0){var C=w.pending;return C===null?l.next=l:(l.next=C.next,C.next=l),w.pending=l,Fr(a,m)}return C=w.interleaved,C===null?(l.next=l,qh(w)):(l.next=C.next,C.next=l),w.interleaved=l,Fr(a,m)}function lu(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,ai(a,m)}}function Oy(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 cu(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 X=V,ue=X.next;X.next=null,I===null?T=ue:I.next=ue,I=X;var ke=a.alternate;ke!==null&&(ke=ke.updateQueue,V=ke.lastBaseUpdate,V!==I&&(V===null?ke.firstBaseUpdate=ue:V.next=ue,ke.lastBaseUpdate=X))}if(T!==null){var Ce=C.baseState;I=0,ke=ue=X=null,V=T;do{var je=V.lane,Ge=V.eventTime;if((w&je)===je){ke!==null&&(ke=ke.next={eventTime:Ge,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var Qe=a,Je=V;switch(je=l,Ge=m,Je.tag){case 1:if(Qe=Je.payload,typeof Qe=="function"){Ce=Qe.call(Ge,Ce,je);break e}Ce=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=Je.payload,je=typeof Qe=="function"?Qe.call(Ge,Ce,je):Qe,je==null)break e;Ce=F({},Ce,je);break e;case 2:bo=!0}}V.callback!==null&&V.lane!==0&&(a.flags|=64,je=C.effects,je===null?C.effects=[V]:je.push(V))}else Ge={eventTime:Ge,lane:je,tag:V.tag,payload:V.payload,callback:V.callback,next:null},ke===null?(ue=ke=Ge,X=Ce):ke=ke.next=Ge,I|=je;if(V=V.next,V===null){if(V=C.shared.pending,V===null)break;je=V,V=je.next,je.next=null,C.lastBaseUpdate=je,C.shared.pending=null}}while(!0);if(ke===null&&(X=Ce),C.baseState=X,C.firstBaseUpdate=ue,C.lastBaseUpdate=ke,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);ga|=I,a.lanes=I,a.memoizedState=Ce}}function Py(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=go(Vl),Yl=go(Vl),Ql=go(Vl);function ha(a){if(a===Vl)throw Error(s(174));return a}function Vh(a,l){switch(Ut(Ql,l),Ut(Yl,a),Ut(gr,Vl),a=l.nodeType,a){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:it(null,"");break;default:a=a===8?l.parentNode:l,l=a.namespaceURI||null,a=a.tagName,l=it(l,a)}qt(gr),Ut(gr,l)}function Si(){qt(gr),qt(Yl),qt(Ql)}function Ly(a){ha(Ql.current);var l=ha(gr.current),m=it(l,a.type);l!==m&&(Ut(Yl,a),Ut(gr,m))}function Yh(a){Yl.current===a&&(qt(gr),qt(Yl))}var Zt=go(0);function du(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 Qh=[];function Jh(){for(var a=0;a<Qh.length;a++)Qh[a]._workInProgressVersionPrimary=null;Qh.length=0}var uu=N.ReactCurrentDispatcher,Xh=N.ReactCurrentBatchConfig,pa=0,en=null,vn=null,jn=null,fu=!1,Jl=!1,Xl=0,k_=0;function Ln(){throw Error(s(321))}function Zh(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 ep(a,l,m,w,C,T){if(pa=T,en=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,uu.current=a===null||a.memoizedState===null?E_:$_,a=m(w,C),Jl){T=0;do{if(Jl=!1,Xl=0,25<=T)throw Error(s(301));T+=1,jn=vn=null,l.updateQueue=null,uu.current=__,a=m(w,C)}while(Jl)}if(uu.current=pu,l=vn!==null&&vn.next!==null,pa=0,jn=vn=en=null,fu=!1,l)throw Error(s(300));return a}function tp(){var a=Xl!==0;return Xl=0,a}function xr(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jn===null?en.memoizedState=jn=a:jn=jn.next=a,jn}function Ls(){if(vn===null){var a=en.alternate;a=a!==null?a.memoizedState:null}else a=vn.next;var l=jn===null?en.memoizedState:jn.next;if(l!==null)jn=l,vn=a;else{if(a===null)throw Error(s(310));vn=a,a={memoizedState:vn.memoizedState,baseState:vn.baseState,baseQueue:vn.baseQueue,queue:vn.queue,next:null},jn===null?en.memoizedState=jn=a:jn=jn.next=a}return jn}function Zl(a,l){return typeof l=="function"?l(a):l}function np(a){var l=Ls(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=a;var w=vn,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,X=null,ue=T;do{var ke=ue.lane;if((pa&ke)===ke)X!==null&&(X=X.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:ke,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};X===null?(V=X=Ce,I=w):X=X.next=Ce,en.lanes|=ke,ga|=ke}ue=ue.next}while(ue!==null&&ue!==T);X===null?I=w:X.next=V,er(w,l.memoizedState)||(ls=!0),l.memoizedState=w,l.baseState=I,l.baseQueue=X,m.lastRenderedState=w}if(a=m.interleaved,a!==null){C=a;do T=C.lane,en.lanes|=T,ga|=T,C=C.next;while(C!==a)}else C===null&&(m.lanes=0);return[l.memoizedState,m.dispatch]}function sp(a){var l=Ls(),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 My(){}function Iy(a,l){var m=en,w=Ls(),C=l(),T=!er(w.memoizedState,C);if(T&&(w.memoizedState=C,ls=!0),w=w.queue,rp(Fy.bind(null,m,w,a),[a]),w.getSnapshot!==l||T||jn!==null&&jn.memoizedState.tag&1){if(m.flags|=2048,ec(9,Dy.bind(null,m,w,C,l),void 0,null),kn===null)throw Error(s(349));(pa&30)!==0||zy(m,l,C)}return C}function zy(a,l,m){a.flags|=16384,a={getSnapshot:l,value:m},l=en.updateQueue,l===null?(l={lastEffect:null,stores:null},en.updateQueue=l,l.stores=[a]):(m=l.stores,m===null?l.stores=[a]:m.push(a))}function Dy(a,l,m,w){l.value=m,l.getSnapshot=w,Uy(l)&&Wy(a)}function Fy(a,l,m){return m(function(){Uy(l)&&Wy(a)})}function Uy(a){var l=a.getSnapshot;a=a.value;try{var m=l();return!er(a,m)}catch{return!0}}function Wy(a){var l=Fr(a,1);l!==null&&or(l,a,1,-1)}function Hy(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=C_.bind(null,en,a),[l.memoizedState,a]}function ec(a,l,m,w){return a={tag:a,create:l,destroy:m,deps:w,next:null},l=en.updateQueue,l===null?(l={lastEffect:null,stores:null},en.updateQueue=l,l.lastEffect=a.next=a):(m=l.lastEffect,m===null?l.lastEffect=a.next=a:(w=m.next,m.next=a,a.next=w,l.lastEffect=a)),a}function By(){return Ls().memoizedState}function mu(a,l,m,w){var C=xr();en.flags|=a,C.memoizedState=ec(1|l,m,void 0,w===void 0?null:w)}function hu(a,l,m,w){var C=Ls();w=w===void 0?null:w;var T=void 0;if(vn!==null){var I=vn.memoizedState;if(T=I.destroy,w!==null&&Zh(w,I.deps)){C.memoizedState=ec(l,m,T,w);return}}en.flags|=a,C.memoizedState=ec(1|l,m,T,w)}function Gy(a,l){return mu(8390656,8,a,l)}function rp(a,l){return hu(2048,8,a,l)}function qy(a,l){return hu(4,2,a,l)}function Ky(a,l){return hu(4,4,a,l)}function Vy(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 Yy(a,l,m){return m=m!=null?m.concat([a]):null,hu(4,4,Vy.bind(null,l,a),m)}function op(){}function Qy(a,l){var m=Ls();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&Zh(l,w[1])?w[0]:(m.memoizedState=[a,l],a)}function Jy(a,l){var m=Ls();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&Zh(l,w[1])?w[0]:(a=a(),m.memoizedState=[a,l],a)}function Xy(a,l,m){return(pa&21)===0?(a.baseState&&(a.baseState=!1,ls=!0),a.memoizedState=m):(er(m,l)||(m=_l(),en.lanes|=m,ga|=m,a.baseState=!0),l)}function N_(a,l){var m=_t;_t=m!==0&&4>m?m:4,a(!0);var w=Xh.transition;Xh.transition={};try{a(!1),l()}finally{_t=m,Xh.transition=w}}function Zy(){return Ls().memoizedState}function S_(a,l,m){var w=No(a);if(m={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null},ew(a))tw(l,m);else if(m=Ry(a,l,m,w),m!==null){var C=Vn();or(m,a,w,C),nw(m,l,w)}}function C_(a,l,m){var w=No(a),C={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null};if(ew(a))tw(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 X=l.interleaved;X===null?(C.next=C,qh(l)):(C.next=X.next,X.next=C),l.interleaved=C;return}}catch{}finally{}m=Ry(a,l,C,w),m!==null&&(C=Vn(),or(m,a,w,C),nw(m,l,w))}}function ew(a){var l=a.alternate;return a===en||l!==null&&l===en}function tw(a,l){Jl=fu=!0;var m=a.pending;m===null?l.next=l:(l.next=m.next,m.next=l),a.pending=l}function nw(a,l,m){if((m&4194240)!==0){var w=l.lanes;w&=a.pendingLanes,m|=w,l.lanes=m,ai(a,m)}}var pu={readContext:Ps,useCallback:Ln,useContext:Ln,useEffect:Ln,useImperativeHandle:Ln,useInsertionEffect:Ln,useLayoutEffect:Ln,useMemo:Ln,useReducer:Ln,useRef:Ln,useState:Ln,useDebugValue:Ln,useDeferredValue:Ln,useTransition:Ln,useMutableSource:Ln,useSyncExternalStore:Ln,useId:Ln,unstable_isNewReconciler:!1},E_={readContext:Ps,useCallback:function(a,l){return xr().memoizedState=[a,l===void 0?null:l],a},useContext:Ps,useEffect:Gy,useImperativeHandle:function(a,l,m){return m=m!=null?m.concat([a]):null,mu(4194308,4,Vy.bind(null,l,a),m)},useLayoutEffect:function(a,l){return mu(4194308,4,a,l)},useInsertionEffect:function(a,l){return mu(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=S_.bind(null,en,a),[w.memoizedState,a]},useRef:function(a){var l=xr();return a={current:a},l.memoizedState=a},useState:Hy,useDebugValue:op,useDeferredValue:function(a){return xr().memoizedState=a},useTransition:function(){var a=Hy(!1),l=a[0];return a=N_.bind(null,a[1]),xr().memoizedState=a,[l,a]},useMutableSource:function(){},useSyncExternalStore:function(a,l,m){var w=en,C=xr();if(Yt){if(m===void 0)throw Error(s(407));m=m()}else{if(m=l(),kn===null)throw Error(s(349));(pa&30)!==0||zy(w,l,m)}C.memoizedState=m;var T={value:m,getSnapshot:l};return C.queue=T,Gy(Fy.bind(null,w,T,a),[a]),w.flags|=2048,ec(9,Dy.bind(null,w,T,m,l),void 0,null),m},useId:function(){var a=xr(),l=kn.identifierPrefix;if(Yt){var m=Dr,w=zr;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=k_++,l=":"+l+"r"+m.toString(32)+":";return a.memoizedState=l},unstable_isNewReconciler:!1},$_={readContext:Ps,useCallback:Qy,useContext:Ps,useEffect:rp,useImperativeHandle:Yy,useInsertionEffect:qy,useLayoutEffect:Ky,useMemo:Jy,useReducer:np,useRef:By,useState:function(){return np(Zl)},useDebugValue:op,useDeferredValue:function(a){var l=Ls();return Xy(l,vn.memoizedState,a)},useTransition:function(){var a=np(Zl)[0],l=Ls().memoizedState;return[a,l]},useMutableSource:My,useSyncExternalStore:Iy,useId:Zy,unstable_isNewReconciler:!1},__={readContext:Ps,useCallback:Qy,useContext:Ps,useEffect:rp,useImperativeHandle:Yy,useInsertionEffect:qy,useLayoutEffect:Ky,useMemo:Jy,useReducer:sp,useRef:By,useState:function(){return sp(Zl)},useDebugValue:op,useDeferredValue:function(a){var l=Ls();return vn===null?l.memoizedState=a:Xy(l,vn.memoizedState,a)},useTransition:function(){var a=sp(Zl)[0],l=Ls().memoizedState;return[a,l]},useMutableSource:My,useSyncExternalStore:Iy,useId:Zy,unstable_isNewReconciler:!1};function nr(a,l){if(a&&a.defaultProps){l=F({},l),a=a.defaultProps;for(var m in a)l[m]===void 0&&(l[m]=a[m]);return l}return l}function ap(a,l,m,w){l=a.memoizedState,m=m(w,l),m=m==null?l:F({},l,m),a.memoizedState=m,a.lanes===0&&(a.updateQueue.baseState=m)}var gu={isMounted:function(a){return(a=a._reactInternals)?Oe(a)===a:!1},enqueueSetState:function(a,l,m){a=a._reactInternals;var w=Vn(),C=No(a),T=Ur(w,C);T.payload=l,m!=null&&(T.callback=m),l=yo(a,T,C),l!==null&&(or(l,a,C,w),lu(l,a,C))},enqueueReplaceState:function(a,l,m){a=a._reactInternals;var w=Vn(),C=No(a),T=Ur(w,C);T.tag=1,T.payload=l,m!=null&&(T.callback=m),l=yo(a,T,C),l!==null&&(or(l,a,C,w),lu(l,a,C))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var m=Vn(),w=No(a),C=Ur(m,w);C.tag=2,l!=null&&(C.callback=l),l=yo(a,C,w),l!==null&&(or(l,a,w,m),lu(l,a,w))}};function sw(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 rw(a,l,m){var w=!1,C=xo,T=l.contextType;return typeof T=="object"&&T!==null?T=Ps(T):(C=is(l)?da:Pn.current,w=l.contextTypes,T=(w=w!=null)?vi(a,C):xo),l=new l(m,T),a.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=gu,a.stateNode=l,l._reactInternals=a,w&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=C,a.__reactInternalMemoizedMaskedChildContext=T),l}function ow(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&&gu.enqueueReplaceState(l,l.state,null)}function ip(a,l,m,w){var C=a.stateNode;C.props=m,C.state=a.memoizedState,C.refs={},Kh(a);var T=l.contextType;typeof T=="object"&&T!==null?C.context=Ps(T):(T=is(l)?da:Pn.current,C.context=vi(a,T)),C.state=a.memoizedState,T=l.getDerivedStateFromProps,typeof T=="function"&&(ap(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&&gu.enqueueReplaceState(C,C.state,null),cu(a,m,C,w),C.state=a.memoizedState),typeof C.componentDidMount=="function"&&(a.flags|=4194308)}function Ci(a,l){try{var m="",w=l;do m+=re(w),w=w.return;while(w);var C=m}catch(T){C=`
39
- Error generating stack: `+T.message+`
40
- `+T.stack}return{value:a,source:l,stack:C,digest:null}}function lp(a,l,m){return{value:a,source:null,stack:m??null,digest:l??null}}function cp(a,l){try{console.error(l.value)}catch(m){setTimeout(function(){throw m})}}var T_=typeof WeakMap=="function"?WeakMap:Map;function aw(a,l,m){m=Ur(-1,m),m.tag=3,m.payload={element:null};var w=l.value;return m.callback=function(){ku||(ku=!0,Np=w),cp(a,l)},m}function iw(a,l,m){m=Ur(-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(){cp(a,l)}}var T=a.stateNode;return T!==null&&typeof T.componentDidCatch=="function"&&(m.callback=function(){cp(a,l),typeof w!="function"&&(jo===null?jo=new Set([this]):jo.add(this));var I=l.stack;this.componentDidCatch(l.value,{componentStack:I!==null?I:""})}),m}function lw(a,l,m){var w=a.pingCache;if(w===null){w=a.pingCache=new T_;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=B_.bind(null,a,l,m),l.then(a,a))}function cw(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 dw(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=Ur(-1,1),l.tag=2,yo(m,l,1))),m.lanes|=1),a):(a.flags|=65536,a.lanes=C,a)}var R_=N.ReactCurrentOwner,ls=!1;function Kn(a,l,m,w){l.child=a===null?Ty(l,null,m,w):ji(l,a.child,m,w)}function uw(a,l,m,w,C){m=m.render;var T=l.ref;return Ni(l,C),w=ep(a,l,m,w,T,C),m=tp(),a!==null&&!ls?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~C,Wr(a,l,C)):(Yt&&m&&Ih(l),l.flags|=1,Kn(a,l,w,C),l.child)}function fw(a,l,m,w,C){if(a===null){var T=m.type;return typeof T=="function"&&!Rp(T)&&T.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(l.tag=15,l.type=T,mw(a,l,T,w,C)):(a=_u(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 Wr(a,l,C)}return l.flags|=1,a=Co(T,w),a.ref=l.ref,a.return=l,l.child=a}function mw(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,Wr(a,l,C)}return dp(a,l,m,w,C)}function hw(a,l,m){var w=l.pendingProps,C=w.children,T=a!==null?a.memoizedState:null;if(w.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ut($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,Ut($i,js),js|=a,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=T!==null?T.baseLanes:m,Ut($i,js),js|=w}else T!==null?(w=T.baseLanes|m,l.memoizedState=null):w=m,Ut($i,js),js|=w;return Kn(a,l,C,m),l.child}function pw(a,l){var m=l.ref;(a===null&&m!==null||a!==null&&a.ref!==m)&&(l.flags|=512,l.flags|=2097152)}function dp(a,l,m,w,C){var T=is(m)?da:Pn.current;return T=vi(l,T),Ni(l,C),m=ep(a,l,m,w,T,C),w=tp(),a!==null&&!ls?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~C,Wr(a,l,C)):(Yt&&w&&Ih(l),l.flags|=1,Kn(a,l,m,C),l.child)}function gw(a,l,m,w,C){if(is(m)){var T=!0;eu(l)}else T=!1;if(Ni(l,C),l.stateNode===null)vu(a,l),rw(l,m,w),ip(l,m,w,C),w=!0;else if(a===null){var I=l.stateNode,V=l.memoizedProps;I.props=V;var X=I.context,ue=m.contextType;typeof ue=="object"&&ue!==null?ue=Ps(ue):(ue=is(m)?da:Pn.current,ue=vi(l,ue));var ke=m.getDerivedStateFromProps,Ce=typeof ke=="function"||typeof I.getSnapshotBeforeUpdate=="function";Ce||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==w||X!==ue)&&ow(l,I,w,ue),bo=!1;var je=l.memoizedState;I.state=je,cu(l,w,I,C),X=l.memoizedState,V!==w||je!==X||as.current||bo?(typeof ke=="function"&&(ap(l,m,ke,w),X=l.memoizedState),(V=bo||sw(l,m,V,w,je,X,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=X),I.props=w,I.state=X,I.context=ue,w=V):(typeof I.componentDidMount=="function"&&(l.flags|=4194308),w=!1)}else{I=l.stateNode,Ay(a,l),V=l.memoizedProps,ue=l.type===l.elementType?V:nr(l.type,V),I.props=ue,Ce=l.pendingProps,je=I.context,X=m.contextType,typeof X=="object"&&X!==null?X=Ps(X):(X=is(m)?da:Pn.current,X=vi(l,X));var Ge=m.getDerivedStateFromProps;(ke=typeof Ge=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==Ce||je!==X)&&ow(l,I,w,X),bo=!1,je=l.memoizedState,I.state=je,cu(l,w,I,C);var Qe=l.memoizedState;V!==Ce||je!==Qe||as.current||bo?(typeof Ge=="function"&&(ap(l,m,Ge,w),Qe=l.memoizedState),(ue=bo||sw(l,m,ue,w,je,Qe,X)||!1)?(ke||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(w,Qe,X),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(w,Qe,X)),typeof I.componentDidUpdate=="function"&&(l.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof I.componentDidUpdate!="function"||V===a.memoizedProps&&je===a.memoizedState||(l.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===a.memoizedProps&&je===a.memoizedState||(l.flags|=1024),l.memoizedProps=w,l.memoizedState=Qe),I.props=w,I.state=Qe,I.context=X,w=ue):(typeof I.componentDidUpdate!="function"||V===a.memoizedProps&&je===a.memoizedState||(l.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===a.memoizedProps&&je===a.memoizedState||(l.flags|=1024),w=!1)}return up(a,l,m,w,T,C)}function up(a,l,m,w,C,T){pw(a,l);var I=(l.flags&128)!==0;if(!w&&!I)return C&&wy(l,m,!1),Wr(a,l,T);w=l.stateNode,R_.current=l;var V=I&&typeof m.getDerivedStateFromError!="function"?null:w.render();return l.flags|=1,a!==null&&I?(l.child=ji(l,a.child,null,T),l.child=ji(l,null,V,T)):Kn(a,l,V,T),l.memoizedState=w.state,C&&wy(l,m,!0),l.child}function xw(a){var l=a.stateNode;l.pendingContext?by(a,l.pendingContext,l.pendingContext!==l.context):l.context&&by(a,l.context,!1),Vh(a,l.containerInfo)}function vw(a,l,m,w,C){return wi(),Uh(C),l.flags|=256,Kn(a,l,m,w),l.child}var fp={dehydrated:null,treeContext:null,retryLane:0};function mp(a){return{baseLanes:a,cachePool:null,transitions:null}}function bw(a,l,m){var w=l.pendingProps,C=Zt.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),Ut(Zt,C&1),a===null)return Fh(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=Tu(I,w,0,null),a=ya(a,w,m,null),T.return=l,a.return=l,T.sibling=a,l.child=T,l.child.memoizedState=mp(m),l.memoizedState=fp,a):hp(l,I));if(C=a.memoizedState,C!==null&&(V=C.dehydrated,V!==null))return A_(a,l,I,w,V,C,m);if(T){T=w.fallback,I=l.mode,C=a.child,V=C.sibling;var X={mode:"hidden",children:w.children};return(I&1)===0&&l.child!==C?(w=l.child,w.childLanes=0,w.pendingProps=X,l.deletions=null):(w=Co(C,X),w.subtreeFlags=C.subtreeFlags&14680064),V!==null?T=Co(V,T):(T=ya(T,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?mp(m):{baseLanes:I.baseLanes|m,cachePool:null,transitions:I.transitions},T.memoizedState=I,T.childLanes=a.childLanes&~m,l.memoizedState=fp,w}return T=a.child,a=T.sibling,w=Co(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 hp(a,l){return l=Tu({mode:"visible",children:l},a.mode,0,null),l.return=a,a.child=l}function xu(a,l,m,w){return w!==null&&Uh(w),ji(l,a.child,null,m),a=hp(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function A_(a,l,m,w,C,T,I){if(m)return l.flags&256?(l.flags&=-257,w=lp(Error(s(422))),xu(a,l,I,w)):l.memoizedState!==null?(l.child=a.child,l.flags|=128,null):(T=w.fallback,C=l.mode,w=Tu({mode:"visible",children:w.children},C,0,null),T=ya(T,C,I,null),T.flags|=2,w.return=l,T.return=l,w.sibling=T,l.child=w,(l.mode&1)!==0&&ji(l,a.child,null,I),l.child.memoizedState=mp(I),l.memoizedState=fp,T);if((l.mode&1)===0)return xu(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=lp(T,w,void 0),xu(a,l,I,w)}if(V=(I&a.childLanes)!==0,ls||V){if(w=kn,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,Fr(a,C),or(w,a,C,-1))}return Tp(),w=lp(Error(s(421))),xu(a,l,I,w)}return C.data==="$?"?(l.flags|=128,l.child=a.child,l=G_.bind(null,a),C._reactRetry=l,null):(a=T.treeContext,ws=po(C.nextSibling),ys=l,Yt=!0,tr=null,a!==null&&(As[Os++]=zr,As[Os++]=Dr,As[Os++]=ua,zr=a.id,Dr=a.overflow,ua=l),l=hp(l,w.children),l.flags|=4096,l)}function yw(a,l,m){a.lanes|=l;var w=a.alternate;w!==null&&(w.lanes|=l),Gh(a.return,l,m)}function pp(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 ww(a,l,m){var w=l.pendingProps,C=w.revealOrder,T=w.tail;if(Kn(a,l,w.children,m),w=Zt.current,(w&2)!==0)w=w&1|2,l.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=l.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&yw(a,m,l);else if(a.tag===19)yw(a,m,l);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===l)break e;for(;a.sibling===null;){if(a.return===null||a.return===l)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}w&=1}if(Ut(Zt,w),(l.mode&1)===0)l.memoizedState=null;else switch(C){case"forwards":for(m=l.child,C=null;m!==null;)a=m.alternate,a!==null&&du(a)===null&&(C=m),m=m.sibling;m=C,m===null?(C=l.child,l.child=null):(C=m.sibling,m.sibling=null),pp(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&&du(a)===null){l.child=C;break}a=C.sibling,C.sibling=m,m=C,C=a}pp(l,!0,m,null,T);break;case"together":pp(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function vu(a,l){(l.mode&1)===0&&a!==null&&(a.alternate=null,l.alternate=null,l.flags|=2)}function Wr(a,l,m){if(a!==null&&(l.dependencies=a.dependencies),ga|=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=Co(a,a.pendingProps),l.child=m,m.return=l;a.sibling!==null;)a=a.sibling,m=m.sibling=Co(a,a.pendingProps),m.return=l;m.sibling=null}return l.child}function O_(a,l,m){switch(l.tag){case 3:xw(l),wi();break;case 5:Ly(l);break;case 1:is(l.type)&&eu(l);break;case 4:Vh(l,l.stateNode.containerInfo);break;case 10:var w=l.type._context,C=l.memoizedProps.value;Ut(au,w._currentValue),w._currentValue=C;break;case 13:if(w=l.memoizedState,w!==null)return w.dehydrated!==null?(Ut(Zt,Zt.current&1),l.flags|=128,null):(m&l.child.childLanes)!==0?bw(a,l,m):(Ut(Zt,Zt.current&1),a=Wr(a,l,m),a!==null?a.sibling:null);Ut(Zt,Zt.current&1);break;case 19:if(w=(m&l.childLanes)!==0,(a.flags&128)!==0){if(w)return ww(a,l,m);l.flags|=128}if(C=l.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),Ut(Zt,Zt.current),w)break;return null;case 22:case 23:return l.lanes=0,hw(a,l,m)}return Wr(a,l,m)}var jw,gp,kw,Nw;jw=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}},gp=function(){},kw=function(a,l,m,w){var C=a.memoizedProps;if(C!==w){a=l.stateNode,ha(gr.current);var T=null;switch(m){case"input":C=Le(a,C),w=Le(a,w),T=[];break;case"select":C=F({},C,{value:void 0}),w=F({},w,{value:void 0}),T=[];break;case"textarea":C=bt(a,C),w=bt(a,w),T=[];break;default:typeof C.onClick!="function"&&typeof w.onClick=="function"&&(a.onclick=Jd)}Xe(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 X=w[ue];if(V=C!=null?C[ue]:void 0,w.hasOwnProperty(ue)&&X!==V&&(X!=null||V!=null))if(ue==="style")if(V){for(I in V)!V.hasOwnProperty(I)||X&&X.hasOwnProperty(I)||(m||(m={}),m[I]="");for(I in X)X.hasOwnProperty(I)&&V[I]!==X[I]&&(m||(m={}),m[I]=X[I])}else m||(T||(T=[]),T.push(ue,m)),m=X;else ue==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,V=V?V.__html:void 0,X!=null&&V!==X&&(T=T||[]).push(ue,X)):ue==="children"?typeof X!="string"&&typeof X!="number"||(T=T||[]).push(ue,""+X):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(o.hasOwnProperty(ue)?(X!=null&&ue==="onScroll"&&Gt("scroll",a),T||V===X||(T=[])):(T=T||[]).push(ue,X))}m&&(T=T||[]).push("style",m);var ue=T;(l.updateQueue=ue)&&(l.flags|=4)}},Nw=function(a,l,m,w){m!==w&&(l.flags|=4)};function tc(a,l){if(!Yt)switch(a.tailMode){case"hidden":l=a.tail;for(var m=null;l!==null;)l.alternate!==null&&(m=l),l=l.sibling;m===null?a.tail=null:m.sibling=null;break;case"collapsed":m=a.tail;for(var w=null;m!==null;)m.alternate!==null&&(w=m),m=m.sibling;w===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:w.sibling=null}}function Mn(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 P_(a,l,m){var w=l.pendingProps;switch(zh(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Mn(l),null;case 1:return is(l.type)&&Zd(),Mn(l),null;case 3:return w=l.stateNode,Si(),qt(as),qt(Pn),Jh(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(a===null||a.child===null)&&(ru(l)?l.flags|=4:a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,tr!==null&&(Ep(tr),tr=null))),gp(a,l),Mn(l),null;case 5:Yh(l);var C=ha(Ql.current);if(m=l.type,a!==null&&l.stateNode!=null)kw(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 Mn(l),null}if(a=ha(gr.current),ru(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":Gt("cancel",w),Gt("close",w);break;case"iframe":case"object":case"embed":Gt("load",w);break;case"video":case"audio":for(C=0;C<Wl.length;C++)Gt(Wl[C],w);break;case"source":Gt("error",w);break;case"img":case"image":case"link":Gt("error",w),Gt("load",w);break;case"details":Gt("toggle",w);break;case"input":Ee(w,T),Gt("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!T.multiple},Gt("invalid",w);break;case"textarea":oe(w,T),Gt("invalid",w)}Xe(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&&Qd(w.textContent,V,a),C=["children",V]):typeof V=="number"&&w.textContent!==""+V&&(T.suppressHydrationWarning!==!0&&Qd(w.textContent,V,a),C=["children",""+V]):o.hasOwnProperty(I)&&V!=null&&I==="onScroll"&&Gt("scroll",w)}switch(m){case"input":fe(w),ot(w,T,!0);break;case"textarea":fe(w),tt(w);break;case"select":case"option":break;default:typeof T.onClick=="function"&&(w.onclick=Jd)}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=Ae(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,jw(a,l,!1,!1),l.stateNode=a;e:{switch(I=at(m,w),m){case"dialog":Gt("cancel",a),Gt("close",a),C=w;break;case"iframe":case"object":case"embed":Gt("load",a),C=w;break;case"video":case"audio":for(C=0;C<Wl.length;C++)Gt(Wl[C],a);C=w;break;case"source":Gt("error",a),C=w;break;case"img":case"image":case"link":Gt("error",a),Gt("load",a),C=w;break;case"details":Gt("toggle",a),C=w;break;case"input":Ee(a,w),C=Le(a,w),Gt("invalid",a);break;case"option":C=w;break;case"select":a._wrapperState={wasMultiple:!!w.multiple},C=F({},w,{value:void 0}),Gt("invalid",a);break;case"textarea":oe(a,w),C=bt(a,w),Gt("invalid",a);break;default:C=w}Xe(m,C),V=C;for(T in V)if(V.hasOwnProperty(T)){var X=V[T];T==="style"?de(a,X):T==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&nt(a,X)):T==="children"?typeof X=="string"?(m!=="textarea"||X!=="")&&ft(a,X):typeof X=="number"&&ft(a,""+X):T!=="suppressContentEditableWarning"&&T!=="suppressHydrationWarning"&&T!=="autoFocus"&&(o.hasOwnProperty(T)?X!=null&&T==="onScroll"&&Gt("scroll",a):X!=null&&S(a,T,X,I))}switch(m){case"input":fe(a),ot(a,w,!1);break;case"textarea":fe(a),tt(a);break;case"option":w.value!=null&&a.setAttribute("value",""+ge(w.value));break;case"select":a.multiple=!!w.multiple,T=w.value,T!=null?Ze(a,!!w.multiple,T,!1):w.defaultValue!=null&&Ze(a,!!w.multiple,w.defaultValue,!0);break;default:typeof C.onClick=="function"&&(a.onclick=Jd)}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 Mn(l),null;case 6:if(a&&l.stateNode!=null)Nw(a,l,a.memoizedProps,w);else{if(typeof w!="string"&&l.stateNode===null)throw Error(s(166));if(m=ha(Ql.current),ha(gr.current),ru(l)){if(w=l.stateNode,m=l.memoizedProps,w[pr]=l,(T=w.nodeValue!==m)&&(a=ys,a!==null))switch(a.tag){case 3:Qd(w.nodeValue,m,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Qd(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 Mn(l),null;case 13:if(qt(Zt),w=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(Yt&&ws!==null&&(l.mode&1)!==0&&(l.flags&128)===0)Ey(),wi(),l.flags|=98560,T=!1;else if(T=ru(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 wi(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Mn(l),T=!1}else tr!==null&&(Ep(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||(Zt.current&1)!==0?bn===0&&(bn=3):Tp())),l.updateQueue!==null&&(l.flags|=4),Mn(l),null);case 4:return Si(),gp(a,l),a===null&&Hl(l.stateNode.containerInfo),Mn(l),null;case 10:return Bh(l.type._context),Mn(l),null;case 17:return is(l.type)&&Zd(),Mn(l),null;case 19:if(qt(Zt),T=l.memoizedState,T===null)return Mn(l),null;if(w=(l.flags&128)!==0,I=T.rendering,I===null)if(w)tc(T,!1);else{if(bn!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(I=du(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 Ut(Zt,Zt.current&1|2),l.child}a=a.sibling}T.tail!==null&&ct()>_i&&(l.flags|=128,w=!0,tc(T,!1),l.lanes=4194304)}else{if(!w)if(a=du(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&&!Yt)return Mn(l),null}else 2*ct()-T.renderingStartTime>_i&&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=ct(),l.sibling=null,m=Zt.current,Ut(Zt,w?m&1|2:m&1),l):(Mn(l),null);case 22:case 23:return _p(),w=l.memoizedState!==null,a!==null&&a.memoizedState!==null!==w&&(l.flags|=8192),w&&(l.mode&1)!==0?(js&1073741824)!==0&&(Mn(l),l.subtreeFlags&6&&(l.flags|=8192)):Mn(l),null;case 24:return null;case 25:return null}throw Error(s(156,l.tag))}function L_(a,l){switch(zh(l),l.tag){case 1:return is(l.type)&&Zd(),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return Si(),qt(as),qt(Pn),Jh(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 5:return Yh(l),null;case 13:if(qt(Zt),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(s(340));wi()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return qt(Zt),null;case 4:return Si(),null;case 10:return Bh(l.type._context),null;case 22:case 23:return _p(),null;case 24:return null;default:return null}}var bu=!1,In=!1,M_=typeof WeakSet=="function"?WeakSet:Set,Ye=null;function Ei(a,l){var m=a.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(w){rn(a,l,w)}else m.current=null}function xp(a,l,m){try{m()}catch(w){rn(a,l,w)}}var Sw=!1;function I_(a,l){if(_h=Lr,a=sy(),wh(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,X=-1,ue=0,ke=0,Ce=a,je=null;t:for(;;){for(var Ge;Ce!==m||C!==0&&Ce.nodeType!==3||(V=I+C),Ce!==T||w!==0&&Ce.nodeType!==3||(X=I+w),Ce.nodeType===3&&(I+=Ce.nodeValue.length),(Ge=Ce.firstChild)!==null;)je=Ce,Ce=Ge;for(;;){if(Ce===a)break t;if(je===m&&++ue===C&&(V=I),je===T&&++ke===w&&(X=I),(Ge=Ce.nextSibling)!==null)break;Ce=je,je=Ce.parentNode}Ce=Ge}m=V===-1||X===-1?null:{start:V,end:X}}else m=null}m=m||{start:0,end:0}}else m=null;for(Th={focusedElem:a,selectionRange:m},Lr=!1,Ye=l;Ye!==null;)if(l=Ye,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,Ye=a;else for(;Ye!==null;){l=Ye;try{var Qe=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Qe!==null){var Je=Qe.memoizedProps,an=Qe.memoizedState,le=l.stateNode,ne=le.getSnapshotBeforeUpdate(l.elementType===l.type?Je:nr(l.type,Je),an);le.__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(Re){rn(l,l.return,Re)}if(a=l.sibling,a!==null){a.return=l.return,Ye=a;break}Ye=l.return}return Qe=Sw,Sw=!1,Qe}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&&xp(l,m,T)}C=C.next}while(C!==w)}}function yu(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 vp(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 Cw(a){var l=a.alternate;l!==null&&(a.alternate=null,Cw(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[Ph],delete l[b_],delete l[y_])),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 Ew(a){return a.tag===5||a.tag===3||a.tag===4}function $w(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||Ew(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 bp(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=Jd));else if(w!==4&&(a=a.child,a!==null))for(bp(a,l,m),a=a.sibling;a!==null;)bp(a,l,m),a=a.sibling}function yp(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(yp(a,l,m),a=a.sibling;a!==null;)yp(a,l,m),a=a.sibling}var Tn=null,sr=!1;function wo(a,l,m){for(m=m.child;m!==null;)_w(a,l,m),m=m.sibling}function _w(a,l,m){if(vs&&typeof vs.onCommitFiberUnmount=="function")try{vs.onCommitFiberUnmount(ra,m)}catch{}switch(m.tag){case 5:In||Ei(m,l);case 6:var w=Tn,C=sr;Tn=null,wo(a,l,m),Tn=w,sr=C,Tn!==null&&(sr?(a=Tn,m=m.stateNode,a.nodeType===8?a.parentNode.removeChild(m):a.removeChild(m)):Tn.removeChild(m.stateNode));break;case 18:Tn!==null&&(sr?(a=Tn,m=m.stateNode,a.nodeType===8?Oh(a.parentNode,m):a.nodeType===1&&Oh(a,m),uo(a)):Oh(Tn,m.stateNode));break;case 4:w=Tn,C=sr,Tn=m.stateNode.containerInfo,sr=!0,wo(a,l,m),Tn=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)&&xp(m,l,I),C=C.next}while(C!==w)}wo(a,l,m);break;case 1:if(!In&&(Ei(m,l),w=m.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=m.memoizedProps,w.state=m.memoizedState,w.componentWillUnmount()}catch(V){rn(m,l,V)}wo(a,l,m);break;case 21:wo(a,l,m);break;case 22:m.mode&1?(In=(w=In)||m.memoizedState!==null,wo(a,l,m),In=w):wo(a,l,m);break;default:wo(a,l,m)}}function Tw(a){var l=a.updateQueue;if(l!==null){a.updateQueue=null;var m=a.stateNode;m===null&&(m=a.stateNode=new M_),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:Tn=V.stateNode,sr=!1;break e;case 3:Tn=V.stateNode.containerInfo,sr=!0;break e;case 4:Tn=V.stateNode.containerInfo,sr=!0;break e}V=V.return}if(Tn===null)throw Error(s(160));_w(T,I,C),Tn=null,sr=!1;var X=C.alternate;X!==null&&(X.return=null),C.return=null}catch(ue){rn(C,l,ue)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)Rw(l,a),l=l.sibling}function Rw(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),yu(3,a)}catch(Je){rn(a,a.return,Je)}try{nc(5,a,a.return)}catch(Je){rn(a,a.return,Je)}}break;case 1:rr(l,a),vr(a),w&512&&m!==null&&Ei(m,m.return);break;case 5:if(rr(l,a),vr(a),w&512&&m!==null&&Ei(m,m.return),a.flags&32){var C=a.stateNode;try{ft(C,"")}catch(Je){rn(a,a.return,Je)}}if(w&4&&(C=a.stateNode,C!=null)){var T=a.memoizedProps,I=m!==null?m.memoizedProps:T,V=a.type,X=a.updateQueue;if(a.updateQueue=null,X!==null)try{V==="input"&&T.type==="radio"&&T.name!=null&&ae(C,T),at(V,I);var ue=at(V,T);for(I=0;I<X.length;I+=2){var ke=X[I],Ce=X[I+1];ke==="style"?de(C,Ce):ke==="dangerouslySetInnerHTML"?nt(C,Ce):ke==="children"?ft(C,Ce):S(C,ke,Ce,ue)}switch(V){case"input":$e(C,T);break;case"textarea":Se(C,T);break;case"select":var je=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!T.multiple;var Ge=T.value;Ge!=null?Ze(C,!!T.multiple,Ge,!1):je!==!!T.multiple&&(T.defaultValue!=null?Ze(C,!!T.multiple,T.defaultValue,!0):Ze(C,!!T.multiple,T.multiple?[]:"",!1))}C[Gl]=T}catch(Je){rn(a,a.return,Je)}}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(Je){rn(a,a.return,Je)}}break;case 3:if(rr(l,a),vr(a),w&4&&m!==null&&m.memoizedState.isDehydrated)try{uo(l.containerInfo)}catch(Je){rn(a,a.return,Je)}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||(kp=ct())),w&4&&Tw(a);break;case 22:if(ke=m!==null&&m.memoizedState!==null,a.mode&1?(In=(ue=In)||ke,rr(l,a),In=ue):rr(l,a),vr(a),w&8192){if(ue=a.memoizedState!==null,(a.stateNode.isHidden=ue)&&!ke&&(a.mode&1)!==0)for(Ye=a,ke=a.child;ke!==null;){for(Ce=Ye=ke;Ye!==null;){switch(je=Ye,Ge=je.child,je.tag){case 0:case 11:case 14:case 15:nc(4,je,je.return);break;case 1:Ei(je,je.return);var Qe=je.stateNode;if(typeof Qe.componentWillUnmount=="function"){w=je,m=je.return;try{l=w,Qe.props=l.memoizedProps,Qe.state=l.memoizedState,Qe.componentWillUnmount()}catch(Je){rn(w,m,Je)}}break;case 5:Ei(je,je.return);break;case 22:if(je.memoizedState!==null){Pw(Ce);continue}}Ge!==null?(Ge.return=je,Ye=Ge):Pw(Ce)}ke=ke.sibling}e:for(ke=null,Ce=a;;){if(Ce.tag===5){if(ke===null){ke=Ce;try{C=Ce.stateNode,ue?(T=C.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none"):(V=Ce.stateNode,X=Ce.memoizedProps.style,I=X!=null&&X.hasOwnProperty("display")?X.display:null,V.style.display=be("display",I))}catch(Je){rn(a,a.return,Je)}}}else if(Ce.tag===6){if(ke===null)try{Ce.stateNode.nodeValue=ue?"":Ce.memoizedProps}catch(Je){rn(a,a.return,Je)}}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;ke===Ce&&(ke=null),Ce=Ce.return}ke===Ce&&(ke=null),Ce.sibling.return=Ce.return,Ce=Ce.sibling}}break;case 19:rr(l,a),vr(a),w&4&&Tw(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(Ew(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=$w(a);yp(a,T,C);break;case 3:case 4:var I=w.stateNode.containerInfo,V=$w(a);bp(a,V,I);break;default:throw Error(s(161))}}catch(X){rn(a,a.return,X)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function z_(a,l,m){Ye=a,Aw(a)}function Aw(a,l,m){for(var w=(a.mode&1)!==0;Ye!==null;){var C=Ye,T=C.child;if(C.tag===22&&w){var I=C.memoizedState!==null||bu;if(!I){var V=C.alternate,X=V!==null&&V.memoizedState!==null||In;V=bu;var ue=In;if(bu=I,(In=X)&&!ue)for(Ye=C;Ye!==null;)I=Ye,X=I.child,I.tag===22&&I.memoizedState!==null?Lw(C):X!==null?(X.return=I,Ye=X):Lw(C);for(;T!==null;)Ye=T,Aw(T),T=T.sibling;Ye=C,bu=V,In=ue}Ow(a)}else(C.subtreeFlags&8772)!==0&&T!==null?(T.return=C,Ye=T):Ow(a)}}function Ow(a){for(;Ye!==null;){var l=Ye;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||yu(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&&Py(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}Py(l,I,m)}break;case 5:var V=l.stateNode;if(m===null&&l.flags&4){m=V;var X=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":X.autoFocus&&m.focus();break;case"img":X.src&&(m.src=X.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ue=l.alternate;if(ue!==null){var ke=ue.memoizedState;if(ke!==null){var Ce=ke.dehydrated;Ce!==null&&uo(Ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}In||l.flags&512&&vp(l)}catch(je){rn(l,l.return,je)}}if(l===a){Ye=null;break}if(m=l.sibling,m!==null){m.return=l.return,Ye=m;break}Ye=l.return}}function Pw(a){for(;Ye!==null;){var l=Ye;if(l===a){Ye=null;break}var m=l.sibling;if(m!==null){m.return=l.return,Ye=m;break}Ye=l.return}}function Lw(a){for(;Ye!==null;){var l=Ye;try{switch(l.tag){case 0:case 11:case 15:var m=l.return;try{yu(4,l)}catch(X){rn(l,m,X)}break;case 1:var w=l.stateNode;if(typeof w.componentDidMount=="function"){var C=l.return;try{w.componentDidMount()}catch(X){rn(l,C,X)}}var T=l.return;try{vp(l)}catch(X){rn(l,T,X)}break;case 5:var I=l.return;try{vp(l)}catch(X){rn(l,I,X)}}}catch(X){rn(l,l.return,X)}if(l===a){Ye=null;break}var V=l.sibling;if(V!==null){V.return=l.return,Ye=V;break}Ye=l.return}}var D_=Math.ceil,wu=N.ReactCurrentDispatcher,wp=N.ReactCurrentOwner,Ms=N.ReactCurrentBatchConfig,Ct=0,kn=null,hn=null,Rn=0,js=0,$i=go(0),bn=0,sc=null,ga=0,ju=0,jp=0,rc=null,cs=null,kp=0,_i=1/0,Hr=null,ku=!1,Np=null,jo=null,Nu=!1,ko=null,Su=0,oc=0,Sp=null,Cu=-1,Eu=0;function Vn(){return(Ct&6)!==0?ct():Cu!==-1?Cu:Cu=ct()}function No(a){return(a.mode&1)===0?1:(Ct&2)!==0&&Rn!==0?Rn&-Rn:j_.transition!==null?(Eu===0&&(Eu=_l()),Eu):(a=_t,a!==0||(a=window.event,a=a===void 0?16:Ib(a.type)),a)}function or(a,l,m,w){if(50<oc)throw oc=0,Sp=null,Error(s(185));lo(a,m,w),((Ct&2)===0||a!==kn)&&(a===kn&&((Ct&2)===0&&(ju|=m),bn===4&&So(a,Rn)),ds(a,w),m===1&&Ct===0&&(l.mode&1)===0&&(_i=ct()+500,tu&&vo()))}function ds(a,l){var m=a.callbackNode;zd(a,l);var w=ia(a,a===kn?Rn: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?w_(Iw.bind(null,a)):jy(Iw.bind(null,a)),x_(function(){(Ct&6)===0&&vo()}),m=null;else{switch(Tl(w)){case 1:m=_n;break;case 4:m=mr;break;case 16:m=Bt;break;case 536870912:m=ao;break;default:m=Bt}m=Gw(m,Mw.bind(null,a))}a.callbackPriority=l,a.callbackNode=m}}function Mw(a,l){if(Cu=-1,Eu=0,(Ct&6)!==0)throw Error(s(327));var m=a.callbackNode;if(Ti()&&a.callbackNode!==m)return null;var w=ia(a,a===kn?Rn:0);if(w===0)return null;if((w&30)!==0||(w&a.expiredLanes)!==0||l)l=$u(a,w);else{l=w;var C=Ct;Ct|=2;var T=Dw();(kn!==a||Rn!==l)&&(Hr=null,_i=ct()+500,va(a,l));do try{W_();break}catch(V){zw(a,V)}while(!0);Hh(),wu.current=T,Ct=C,hn!==null?l=0:(kn=null,Rn=0,l=bn)}if(l!==0){if(l===2&&(C=ri(a),C!==0&&(w=C,l=Cp(a,C))),l===1)throw m=sc,va(a,0),So(a,w),ds(a,ct()),m;if(l===6)So(a,w);else{if(C=a.current.alternate,(w&30)===0&&!F_(C)&&(l=$u(a,w),l===2&&(T=ri(a),T!==0&&(w=T,l=Cp(a,T))),l===1))throw m=sc,va(a,0),So(a,w),ds(a,ct()),m;switch(a.finishedWork=C,a.finishedLanes=w,l){case 0:case 1:throw Error(s(345));case 2:ba(a,cs,Hr);break;case 3:if(So(a,w),(w&130023424)===w&&(l=kp+500-ct(),10<l)){if(ia(a,0)!==0)break;if(C=a.suspendedLanes,(C&w)!==w){Vn(),a.pingedLanes|=a.suspendedLanes&C;break}a.timeoutHandle=Ah(ba.bind(null,a,cs,Hr),l);break}ba(a,cs,Hr);break;case 4:if(So(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=ct()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*D_(w/1960))-w,10<w){a.timeoutHandle=Ah(ba.bind(null,a,cs,Hr),w);break}ba(a,cs,Hr);break;case 5:ba(a,cs,Hr);break;default:throw Error(s(329))}}}return ds(a,ct()),a.callbackNode===m?Mw.bind(null,a):null}function Cp(a,l){var m=rc;return a.current.memoizedState.isDehydrated&&(va(a,l).flags|=256),a=$u(a,l),a!==2&&(l=cs,cs=m,l!==null&&Ep(l)),a}function Ep(a){cs===null?cs=a:cs.push.apply(cs,a)}function F_(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 So(a,l){for(l&=~jp,l&=~ju,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 Iw(a){if((Ct&6)!==0)throw Error(s(327));Ti();var l=ia(a,0);if((l&1)===0)return ds(a,ct()),null;var m=$u(a,l);if(a.tag!==0&&m===2){var w=ri(a);w!==0&&(l=w,m=Cp(a,w))}if(m===1)throw m=sc,va(a,0),So(a,l),ds(a,ct()),m;if(m===6)throw Error(s(345));return a.finishedWork=a.current.alternate,a.finishedLanes=l,ba(a,cs,Hr),ds(a,ct()),null}function $p(a,l){var m=Ct;Ct|=1;try{return a(l)}finally{Ct=m,Ct===0&&(_i=ct()+500,tu&&vo())}}function xa(a){ko!==null&&ko.tag===0&&(Ct&6)===0&&Ti();var l=Ct;Ct|=1;var m=Ms.transition,w=_t;try{if(Ms.transition=null,_t=1,a)return a()}finally{_t=w,Ms.transition=m,Ct=l,(Ct&6)===0&&vo()}}function _p(){js=$i.current,qt($i)}function va(a,l){a.finishedWork=null,a.finishedLanes=0;var m=a.timeoutHandle;if(m!==-1&&(a.timeoutHandle=-1,g_(m)),hn!==null)for(m=hn.return;m!==null;){var w=m;switch(zh(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&Zd();break;case 3:Si(),qt(as),qt(Pn),Jh();break;case 5:Yh(w);break;case 4:Si();break;case 13:qt(Zt);break;case 19:qt(Zt);break;case 10:Bh(w.type._context);break;case 22:case 23:_p()}m=m.return}if(kn=a,hn=a=Co(a.current,null),Rn=js=l,bn=0,sc=null,jp=ju=ga=0,cs=rc=null,ma!==null){for(l=0;l<ma.length;l++)if(m=ma[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}ma=null}return a}function zw(a,l){do{var m=hn;try{if(Hh(),uu.current=pu,fu){for(var w=en.memoizedState;w!==null;){var C=w.queue;C!==null&&(C.pending=null),w=w.next}fu=!1}if(pa=0,jn=vn=en=null,Jl=!1,Xl=0,wp.current=null,m===null||m.return===null){bn=1,sc=l,hn=null;break}e:{var T=a,I=m.return,V=m,X=l;if(l=Rn,V.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var ue=X,ke=V,Ce=ke.tag;if((ke.mode&1)===0&&(Ce===0||Ce===11||Ce===15)){var je=ke.alternate;je?(ke.updateQueue=je.updateQueue,ke.memoizedState=je.memoizedState,ke.lanes=je.lanes):(ke.updateQueue=null,ke.memoizedState=null)}var Ge=cw(I);if(Ge!==null){Ge.flags&=-257,dw(Ge,I,V,T,l),Ge.mode&1&&lw(T,ue,l),l=Ge,X=ue;var Qe=l.updateQueue;if(Qe===null){var Je=new Set;Je.add(X),l.updateQueue=Je}else Qe.add(X);break e}else{if((l&1)===0){lw(T,ue,l),Tp();break e}X=Error(s(426))}}else if(Yt&&V.mode&1){var an=cw(I);if(an!==null){(an.flags&65536)===0&&(an.flags|=256),dw(an,I,V,T,l),Uh(Ci(X,V));break e}}T=X=Ci(X,V),bn!==4&&(bn=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 le=aw(T,X,l);Oy(T,le);break e;case 1:V=X;var ne=T.type,ce=T.stateNode;if((T.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(jo===null||!jo.has(ce)))){T.flags|=65536,l&=-l,T.lanes|=l;var Re=iw(T,V,l);Oy(T,Re);break e}}T=T.return}while(T!==null)}Uw(m)}catch(et){l=et,hn===m&&m!==null&&(hn=m=m.return);continue}break}while(!0)}function Dw(){var a=wu.current;return wu.current=pu,a===null?pu:a}function Tp(){(bn===0||bn===3||bn===2)&&(bn=4),kn===null||(ga&268435455)===0&&(ju&268435455)===0||So(kn,Rn)}function $u(a,l){var m=Ct;Ct|=2;var w=Dw();(kn!==a||Rn!==l)&&(Hr=null,va(a,l));do try{U_();break}catch(C){zw(a,C)}while(!0);if(Hh(),Ct=m,wu.current=w,hn!==null)throw Error(s(261));return kn=null,Rn=0,bn}function U_(){for(;hn!==null;)Fw(hn)}function W_(){for(;hn!==null&&!St();)Fw(hn)}function Fw(a){var l=Bw(a.alternate,a,js);a.memoizedProps=a.pendingProps,l===null?Uw(a):hn=l,wp.current=null}function Uw(a){var l=a;do{var m=l.alternate;if(a=l.return,(l.flags&32768)===0){if(m=P_(m,l,js),m!==null){hn=m;return}}else{if(m=L_(m,l),m!==null){m.flags&=32767,hn=m;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{bn=6,hn=null;return}}if(l=l.sibling,l!==null){hn=l;return}hn=l=a}while(l!==null);bn===0&&(bn=5)}function ba(a,l,m){var w=_t,C=Ms.transition;try{Ms.transition=null,_t=1,H_(a,l,m,w)}finally{Ms.transition=C,_t=w}return null}function H_(a,l,m,w){do Ti();while(ko!==null);if((Ct&6)!==0)throw Error(s(327));m=a.finishedWork;var C=a.finishedLanes;if(m===null)return null;if(a.finishedWork=null,a.finishedLanes=0,m===a.current)throw Error(s(177));a.callbackNode=null,a.callbackPriority=0;var T=m.lanes|m.childLanes;if(Dd(a,T),a===kn&&(hn=kn=null,Rn=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||Nu||(Nu=!0,Gw(Bt,function(){return Ti(),null})),T=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||T){T=Ms.transition,Ms.transition=null;var I=_t;_t=1;var V=Ct;Ct|=4,wp.current=null,I_(a,m),Rw(m,a),c_(Th),Lr=!!_h,Th=_h=null,a.current=m,z_(m),It(),Ct=V,_t=I,Ms.transition=T}else a.current=m;if(Nu&&(Nu=!1,ko=a,Su=C),T=a.pendingLanes,T===0&&(jo=null),Od(m.stateNode),ds(a,ct()),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(ku)throw ku=!1,a=Np,Np=null,a;return(Su&1)!==0&&a.tag!==0&&Ti(),T=a.pendingLanes,(T&1)!==0?a===Sp?oc++:(oc=0,Sp=a):oc=0,vo(),null}function Ti(){if(ko!==null){var a=Tl(Su),l=Ms.transition,m=_t;try{if(Ms.transition=null,_t=16>a?16:a,ko===null)var w=!1;else{if(a=ko,ko=null,Su=0,(Ct&6)!==0)throw Error(s(331));var C=Ct;for(Ct|=4,Ye=a.current;Ye!==null;){var T=Ye,I=T.child;if((Ye.flags&16)!==0){var V=T.deletions;if(V!==null){for(var X=0;X<V.length;X++){var ue=V[X];for(Ye=ue;Ye!==null;){var ke=Ye;switch(ke.tag){case 0:case 11:case 15:nc(8,ke,T)}var Ce=ke.child;if(Ce!==null)Ce.return=ke,Ye=Ce;else for(;Ye!==null;){ke=Ye;var je=ke.sibling,Ge=ke.return;if(Cw(ke),ke===ue){Ye=null;break}if(je!==null){je.return=Ge,Ye=je;break}Ye=Ge}}}var Qe=T.alternate;if(Qe!==null){var Je=Qe.child;if(Je!==null){Qe.child=null;do{var an=Je.sibling;Je.sibling=null,Je=an}while(Je!==null)}}Ye=T}}if((T.subtreeFlags&2064)!==0&&I!==null)I.return=T,Ye=I;else e:for(;Ye!==null;){if(T=Ye,(T.flags&2048)!==0)switch(T.tag){case 0:case 11:case 15:nc(9,T,T.return)}var le=T.sibling;if(le!==null){le.return=T.return,Ye=le;break e}Ye=T.return}}var ne=a.current;for(Ye=ne;Ye!==null;){I=Ye;var ce=I.child;if((I.subtreeFlags&2064)!==0&&ce!==null)ce.return=I,Ye=ce;else e:for(I=ne;Ye!==null;){if(V=Ye,(V.flags&2048)!==0)try{switch(V.tag){case 0:case 11:case 15:yu(9,V)}}catch(et){rn(V,V.return,et)}if(V===I){Ye=null;break e}var Re=V.sibling;if(Re!==null){Re.return=V.return,Ye=Re;break e}Ye=V.return}}if(Ct=C,vo(),vs&&typeof vs.onPostCommitFiberRoot=="function")try{vs.onPostCommitFiberRoot(ra,a)}catch{}w=!0}return w}finally{_t=m,Ms.transition=l}}return!1}function Ww(a,l,m){l=Ci(m,l),l=aw(a,l,1),a=yo(a,l,1),l=Vn(),a!==null&&(lo(a,1,l),ds(a,l))}function rn(a,l,m){if(a.tag===3)Ww(a,a,m);else for(;l!==null;){if(l.tag===3){Ww(l,a,m);break}else if(l.tag===1){var w=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(jo===null||!jo.has(w))){a=Ci(m,a),a=iw(l,a,1),l=yo(l,a,1),a=Vn(),l!==null&&(lo(l,1,a),ds(l,a));break}}l=l.return}}function B_(a,l,m){var w=a.pingCache;w!==null&&w.delete(l),l=Vn(),a.pingedLanes|=a.suspendedLanes&m,kn===a&&(Rn&m)===m&&(bn===4||bn===3&&(Rn&130023424)===Rn&&500>ct()-kp?va(a,0):jp|=m),ds(a,l)}function Hw(a,l){l===0&&((a.mode&1)===0?l=1:(l=aa,aa<<=1,(aa&130023424)===0&&(aa=4194304)));var m=Vn();a=Fr(a,l),a!==null&&(lo(a,l,m),ds(a,m))}function G_(a){var l=a.memoizedState,m=0;l!==null&&(m=l.retryLane),Hw(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),Hw(a,m)}var Bw;Bw=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,O_(a,l,m);ls=(a.flags&131072)!==0}else ls=!1,Yt&&(l.flags&1048576)!==0&&ky(l,su,l.index);switch(l.lanes=0,l.tag){case 2:var w=l.type;vu(a,l),a=l.pendingProps;var C=vi(l,Pn.current);Ni(l,m),C=ep(null,l,w,a,C,m);var T=tp();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,eu(l)):T=!1,l.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,Kh(l),C.updater=gu,l.stateNode=C,C._reactInternals=l,ip(l,w,a,m),l=up(null,l,w,!0,T,m)):(l.tag=0,Yt&&T&&Ih(l),Kn(null,l,C,m),l=l.child),l;case 16:w=l.elementType;e:{switch(vu(a,l),a=l.pendingProps,C=w._init,w=C(w._payload),l.type=w,C=l.tag=V_(w),a=nr(w,a),C){case 0:l=dp(null,l,w,a,m);break e;case 1:l=gw(null,l,w,a,m);break e;case 11:l=uw(null,l,w,a,m);break e;case 14:l=fw(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),dp(a,l,w,C,m);case 1:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:nr(w,C),gw(a,l,w,C,m);case 3:e:{if(xw(l),a===null)throw Error(s(387));w=l.pendingProps,T=l.memoizedState,C=T.element,Ay(a,l),cu(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=Ci(Error(s(423)),l),l=vw(a,l,w,m,C);break e}else if(w!==C){C=Ci(Error(s(424)),l),l=vw(a,l,w,m,C);break e}else for(ws=po(l.stateNode.containerInfo.firstChild),ys=l,Yt=!0,tr=null,m=Ty(l,null,w,m),l.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(wi(),w===C){l=Wr(a,l,m);break e}Kn(a,l,w,m)}l=l.child}return l;case 5:return Ly(l),a===null&&Fh(l),w=l.type,C=l.pendingProps,T=a!==null?a.memoizedProps:null,I=C.children,Rh(w,C)?I=null:T!==null&&Rh(w,T)&&(l.flags|=32),pw(a,l),Kn(a,l,I,m),l.child;case 6:return a===null&&Fh(l),null;case 13:return bw(a,l,m);case 4:return Vh(l,l.stateNode.containerInfo),w=l.pendingProps,a===null?l.child=ji(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),uw(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,Ut(au,w._currentValue),w._currentValue=I,T!==null)if(er(T.value,I)){if(T.children===C.children&&!as.current){l=Wr(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 X=V.firstContext;X!==null;){if(X.context===w){if(T.tag===1){X=Ur(-1,m&-m),X.tag=2;var ue=T.updateQueue;if(ue!==null){ue=ue.shared;var ke=ue.pending;ke===null?X.next=X:(X.next=ke.next,ke.next=X),ue.pending=X}}T.lanes|=m,X=T.alternate,X!==null&&(X.lanes|=m),Gh(T.return,m,l),V.lanes|=m;break}X=X.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),Gh(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,Ni(l,m),C=Ps(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),fw(a,l,w,C,m);case 15:return mw(a,l,l.type,l.pendingProps,m);case 17:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:nr(w,C),vu(a,l),l.tag=1,is(w)?(a=!0,eu(l)):a=!1,Ni(l,m),rw(l,w,C),ip(l,w,C,m),up(null,l,w,!0,a,m);case 19:return ww(a,l,m);case 22:return hw(a,l,m)}throw Error(s(156,l.tag))};function Gw(a,l){return we(a,l)}function K_(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 K_(a,l,m,w)}function Rp(a){return a=a.prototype,!(!a||!a.isReactComponent)}function V_(a){if(typeof a=="function")return Rp(a)?1:0;if(a!=null){if(a=a.$$typeof,a===L)return 11;if(a===q)return 14}return 2}function Co(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 _u(a,l,m,w,C,T){var I=2;if(w=a,typeof a=="function")Rp(a)&&(I=1);else if(typeof a=="string")I=5;else e:switch(a){case P:return ya(m.children,C,T,l);case O:I=8,C|=8;break;case M:return a=Is(12,m,l,C|2),a.elementType=M,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 K:return Tu(m,C,T,l);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case R:I=10;break e;case A:I=9;break e;case L:I=11;break e;case q: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 ya(a,l,m,w){return a=Is(7,a,w,l),a.lanes=m,a}function Tu(a,l,m,w){return a=Is(22,a,w,l),a.elementType=K,a.lanes=m,a.stateNode={isHidden:!1},a}function Ap(a,l,m){return a=Is(6,a,null,l),a.lanes=m,a}function Op(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 Y_(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=oi(0),this.expirationTimes=oi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=oi(0),this.identifierPrefix=w,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function Pp(a,l,m,w,C,T,I,V,X){return a=new Y_(a,l,m,V,X),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},Kh(T),a}function Q_(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 qw(a){if(!a)return xo;a=a._reactInternals;e:{if(Oe(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 yy(a,m,l)}return l}function Kw(a,l,m,w,C,T,I,V,X){return a=Pp(m,w,!0,a,C,T,I,V,X),a.context=qw(null),m=a.current,w=Vn(),C=No(m),T=Ur(w,C),T.callback=l??null,yo(m,T,C),a.current.lanes=C,lo(a,C,w),ds(a,w),a}function Ru(a,l,m,w){var C=l.current,T=Vn(),I=No(C);return m=qw(m),l.context===null?l.context=m:l.pendingContext=m,l=Ur(T,I),l.payload={element:a},w=w===void 0?null:w,w!==null&&(l.callback=w),a=yo(C,l,I),a!==null&&(or(a,C,I,T),lu(a,C,I)),I}function Au(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 Vw(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var m=a.retryLane;a.retryLane=m!==0&&m<l?m:l}}function Lp(a,l){Vw(a,l),(a=a.alternate)&&Vw(a,l)}function J_(){return null}var Yw=typeof reportError=="function"?reportError:function(a){console.error(a)};function Mp(a){this._internalRoot=a}Ou.prototype.render=Mp.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(s(409));Ru(a,l,null,null)},Ou.prototype.unmount=Mp.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;xa(function(){Ru(null,a,null,null)}),l[Mr]=null}};function Ou(a){this._internalRoot=a}Ou.prototype.unstable_scheduleHydration=function(a){if(a){var l=Ol();a={blockedOn:null,target:a,priority:l};for(var m=0;m<Ie.length&&l!==0&&l<Ie[m].priority;m++);Ie.splice(m,0,a),m===0&&qn(a)}};function Ip(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Pu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function Qw(){}function X_(a,l,m,w,C){if(C){if(typeof w=="function"){var T=w;w=function(){var ue=Au(I);T.call(ue)}}var I=Kw(l,w,a,0,null,!1,!1,"",Qw);return a._reactRootContainer=I,a[Mr]=I.current,Hl(a.nodeType===8?a.parentNode:a),xa(),I}for(;C=a.lastChild;)a.removeChild(C);if(typeof w=="function"){var V=w;w=function(){var ue=Au(X);V.call(ue)}}var X=Pp(a,0,!1,null,null,!1,!1,"",Qw);return a._reactRootContainer=X,a[Mr]=X.current,Hl(a.nodeType===8?a.parentNode:a),xa(function(){Ru(l,X,m,w)}),X}function Lu(a,l,m,w,C){var T=m._reactRootContainer;if(T){var I=T;if(typeof C=="function"){var V=C;C=function(){var X=Au(I);V.call(X)}}Ru(l,I,a,C)}else I=X_(m,l,a,C,w);return Au(I)}Rl=function(a){switch(a.tag){case 3:var l=a.stateNode;if(l.current.memoizedState.isDehydrated){var m=io(l.pendingLanes);m!==0&&(ai(l,m|1),ds(l,ct()),(Ct&6)===0&&(_i=ct()+500,vo()))}break;case 13:xa(function(){var w=Fr(a,1);if(w!==null){var C=Vn();or(w,a,1,C)}}),Lp(a,1)}},ii=function(a){if(a.tag===13){var l=Fr(a,134217728);if(l!==null){var m=Vn();or(l,a,134217728,m)}Lp(a,134217728)}},Al=function(a){if(a.tag===13){var l=No(a),m=Fr(a,l);if(m!==null){var w=Vn();or(m,a,l,w)}Lp(a,l)}},Ol=function(){return _t},Pl=function(a,l){var m=_t;try{return _t=a,l()}finally{_t=m}},We=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=Xd(w);if(!C)throw Error(s(90));De(w),$e(w,C)}}}break;case"textarea":Se(a,m);break;case"select":l=m.value,l!=null&&Ze(a,!!m.multiple,l,!1)}},Vt=$p,ps=xa;var Z_={usingClientEntryPoint:!1,Events:[ql,gi,Xd,kt,lt,$p]},ac={findFiberByHostInstance:ca,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},eT={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||J_,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 Mu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Mu.isDisabled&&Mu.supportsFiber)try{ra=Mu.inject(eT),vs=Mu}catch{}}return us.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Z_,us.createPortal=function(a,l){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ip(l))throw Error(s(200));return Q_(a,l,null,m)},us.createRoot=function(a,l){if(!Ip(a))throw Error(s(299));var m=!1,w="",C=Yw;return l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(w=l.identifierPrefix),l.onRecoverableError!==void 0&&(C=l.onRecoverableError)),l=Pp(a,1,!1,null,null,m,!1,w,C),a[Mr]=l.current,Hl(a.nodeType===8?a.parentNode:a),new Mp(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 xa(a)},us.hydrate=function(a,l,m){if(!Pu(l))throw Error(s(200));return Lu(null,a,l,!0,m)},us.hydrateRoot=function(a,l,m){if(!Ip(a))throw Error(s(405));var w=m!=null&&m.hydratedSources||null,C=!1,T="",I=Yw;if(m!=null&&(m.unstable_strictMode===!0&&(C=!0),m.identifierPrefix!==void 0&&(T=m.identifierPrefix),m.onRecoverableError!==void 0&&(I=m.onRecoverableError)),l=Kw(l,null,a,1,m??null,C,!1,T,I),a[Mr]=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 Ou(l)},us.render=function(a,l,m){if(!Pu(l))throw Error(s(200));return Lu(null,a,l,!1,m)},us.unmountComponentAtNode=function(a){if(!Pu(a))throw Error(s(40));return a._reactRootContainer?(xa(function(){Lu(null,null,a,!1,function(){a._reactRootContainer=null,a[Mr]=null})}),!0):!1},us.unstable_batchedUpdates=$p,us.unstable_renderSubtreeIntoContainer=function(a,l,m,w){if(!Pu(m))throw Error(s(200));if(a==null||a._reactInternals===void 0)throw Error(s(38));return Lu(a,l,m,!1,w)},us.version="18.3.1-next-f1338f8080-20240426",us}var rj;function kN(){if(rj)return Fp.exports;rj=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(),Fp.exports=dT(),Fp.exports}var oj;function uT(){if(oj)return Iu;oj=1;var e=kN();return Iu.createRoot=e.createRoot,Iu.hydrateRoot=e.hydrateRoot,Iu}var fT=uT();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 Ko=e=>e==="claude-agent-sdk"?"Claude Agent SDK":"Codex SDK";/**
41
- * @license lucide-react v0.468.0 - ISC
42
- *
43
- * This source code is licensed under the ISC license.
44
- * See the LICENSE file in the root directory of this source tree.
45
- */const mT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),NN=(...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 hT={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 pT=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,...hT,width:n,height:n,stroke:e,strokeWidth:r?Number(s)*24/Number(n):s,className:NN("lucide",o),...d},[...c.map(([f,g])=>p.createElement(f,g)),...Array.isArray(i)?i:[i]]));/**
56
- * @license lucide-react v0.468.0 - ISC
57
- *
58
- * This source code is licensed under the ISC license.
59
- * See the LICENSE file in the root directory of this source tree.
60
- */const Te=(e,n)=>{const s=p.forwardRef(({className:r,...o},i)=>p.createElement(pT,{ref:i,iconNode:n,className:NN(`lucide-${mT(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 gT=Te("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
66
- * @license lucide-react v0.468.0 - ISC
67
- *
68
- * This source code is licensed under the ISC license.
69
- * See the LICENSE file in the root directory of this source tree.
70
- */const SN=Te("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
71
- * @license lucide-react v0.468.0 - ISC
72
- *
73
- * This source code is licensed under the ISC license.
74
- * See the LICENSE file in the root directory of this source tree.
75
- */const ed=Te("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
76
- * @license lucide-react v0.468.0 - ISC
77
- *
78
- * This source code is licensed under the ISC license.
79
- * See the LICENSE file in the root directory of this source tree.
80
- */const An=Te("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
81
- * @license lucide-react v0.468.0 - ISC
82
- *
83
- * This source code is licensed under the ISC license.
84
- * See the LICENSE file in the root directory of this source tree.
85
- */const Dx=Te("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
86
- * @license lucide-react v0.468.0 - ISC
87
- *
88
- * This source code is licensed under the ISC license.
89
- * See the LICENSE file in the root directory of this source tree.
90
- */const fr=Te("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
91
- * @license lucide-react v0.468.0 - ISC
92
- *
93
- * This source code is licensed under the ISC license.
94
- * See the LICENSE file in the root directory of this source tree.
95
- */const CN=Te("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
96
- * @license lucide-react v0.468.0 - ISC
97
- *
98
- * This source code is licensed under the ISC license.
99
- * See the LICENSE file in the root directory of this source tree.
100
- */const cm=Te("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/**
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 kf=Te("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
106
- * @license lucide-react v0.468.0 - ISC
107
- *
108
- * This source code is licensed under the ISC license.
109
- * See the LICENSE file in the root directory of this source tree.
110
- */const Fx=Te("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
111
- * @license lucide-react v0.468.0 - ISC
112
- *
113
- * This source code is licensed under the ISC license.
114
- * See the LICENSE file in the root directory of this source tree.
115
- */const Nf=Te("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
116
- * @license lucide-react v0.468.0 - ISC
117
- *
118
- * This source code is licensed under the ISC license.
119
- * See the LICENSE file in the root directory of this source tree.
120
- */const dm=Te("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
121
- * @license lucide-react v0.468.0 - ISC
122
- *
123
- * This source code is licensed under the ISC license.
124
- * See the LICENSE file in the root directory of this source tree.
125
- */const pl=Te("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
126
- * @license lucide-react v0.468.0 - ISC
127
- *
128
- * This source code is licensed under the ISC license.
129
- * See the LICENSE file in the root directory of this source tree.
130
- */const Ar=Te("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
131
- * @license lucide-react v0.468.0 - ISC
132
- *
133
- * This source code is licensed under the ISC license.
134
- * See the LICENSE file in the root directory of this source tree.
135
- */const xT=Te("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
136
- * @license lucide-react v0.468.0 - ISC
137
- *
138
- * This source code is licensed under the ISC license.
139
- * See the LICENSE file in the root directory of this source tree.
140
- */const Es=Te("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
141
- * @license lucide-react v0.468.0 - ISC
142
- *
143
- * This source code is licensed under the ISC license.
144
- * See the LICENSE file in the root directory of this source tree.
145
- */const tl=Te("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
146
- * @license lucide-react v0.468.0 - ISC
147
- *
148
- * This source code is licensed under the ISC license.
149
- * See the LICENSE file in the root directory of this source tree.
150
- */const vT=Te("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/**
151
- * @license lucide-react v0.468.0 - ISC
152
- *
153
- * This source code is licensed under the ISC license.
154
- * See the LICENSE file in the root directory of this source tree.
155
- */const EN=Te("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
156
- * @license lucide-react v0.468.0 - ISC
157
- *
158
- * This source code is licensed under the ISC license.
159
- * See the LICENSE file in the root directory of this source tree.
160
- */const Ux=Te("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/**
161
- * @license lucide-react v0.468.0 - ISC
162
- *
163
- * This source code is licensed under the ISC license.
164
- * See the LICENSE file in the root directory of this source tree.
165
- */const bT=Te("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
166
- * @license lucide-react v0.468.0 - ISC
167
- *
168
- * This source code is licensed under the ISC license.
169
- * See the LICENSE file in the root directory of this source tree.
170
- */const $N=Te("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
171
- * @license lucide-react v0.468.0 - ISC
172
- *
173
- * This source code is licensed under the ISC license.
174
- * See the LICENSE file in the root directory of this source tree.
175
- */const yT=Te("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/**
176
- * @license lucide-react v0.468.0 - ISC
177
- *
178
- * This source code is licensed under the ISC license.
179
- * See the LICENSE file in the root directory of this source tree.
180
- */const wT=Te("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
181
- * @license lucide-react v0.468.0 - ISC
182
- *
183
- * This source code is licensed under the ISC license.
184
- * See the LICENSE file in the root directory of this source tree.
185
- */const um=Te("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
186
- * @license lucide-react v0.468.0 - ISC
187
- *
188
- * This source code is licensed under the ISC license.
189
- * See the LICENSE file in the root directory of this source tree.
190
- */const Ka=Te("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
191
- * @license lucide-react v0.468.0 - ISC
192
- *
193
- * This source code is licensed under the ISC license.
194
- * See the LICENSE file in the root directory of this source tree.
195
- */const jT=Te("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/**
196
- * @license lucide-react v0.468.0 - ISC
197
- *
198
- * This source code is licensed under the ISC license.
199
- * See the LICENSE file in the root directory of this source tree.
200
- */const kT=Te("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
201
- * @license lucide-react v0.468.0 - ISC
202
- *
203
- * This source code is licensed under the ISC license.
204
- * See the LICENSE file in the root directory of this source tree.
205
- */const _N=Te("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
206
- * @license lucide-react v0.468.0 - ISC
207
- *
208
- * This source code is licensed under the ISC license.
209
- * See the LICENSE file in the root directory of this source tree.
210
- */const NT=Te("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
211
- * @license lucide-react v0.468.0 - ISC
212
- *
213
- * This source code is licensed under the ISC license.
214
- * See the LICENSE file in the root directory of this source tree.
215
- */const ST=Te("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
216
- * @license lucide-react v0.468.0 - ISC
217
- *
218
- * This source code is licensed under the ISC license.
219
- * See the LICENSE file in the root directory of this source tree.
220
- */const fm=Te("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
221
- * @license lucide-react v0.468.0 - ISC
222
- *
223
- * This source code is licensed under the ISC license.
224
- * See the LICENSE file in the root directory of this source tree.
225
- */const Va=Te("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
226
- * @license lucide-react v0.468.0 - ISC
227
- *
228
- * This source code is licensed under the ISC license.
229
- * See the LICENSE file in the root directory of this source tree.
230
- */const TN=Te("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
231
- * @license lucide-react v0.468.0 - ISC
232
- *
233
- * This source code is licensed under the ISC license.
234
- * See the LICENSE file in the root directory of this source tree.
235
- */const CT=Te("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
236
- * @license lucide-react v0.468.0 - ISC
237
- *
238
- * This source code is licensed under the ISC license.
239
- * See the LICENSE file in the root directory of this source tree.
240
- */const mm=Te("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/**
241
- * @license lucide-react v0.468.0 - ISC
242
- *
243
- * This source code is licensed under the ISC license.
244
- * See the LICENSE file in the root directory of this source tree.
245
- */const aj=Te("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/**
246
- * @license lucide-react v0.468.0 - ISC
247
- *
248
- * This source code is licensed under the ISC license.
249
- * See the LICENSE file in the root directory of this source tree.
250
- */const RN=Te("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
251
- * @license lucide-react v0.468.0 - ISC
252
- *
253
- * This source code is licensed under the ISC license.
254
- * See the LICENSE file in the root directory of this source tree.
255
- */const ET=Te("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/**
256
- * @license lucide-react v0.468.0 - ISC
257
- *
258
- * This source code is licensed under the ISC license.
259
- * See the LICENSE file in the root directory of this source tree.
260
- */const $T=Te("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
261
- * @license lucide-react v0.468.0 - ISC
262
- *
263
- * This source code is licensed under the ISC license.
264
- * See the LICENSE file in the root directory of this source tree.
265
- */const td=Te("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
266
- * @license lucide-react v0.468.0 - ISC
267
- *
268
- * This source code is licensed under the ISC license.
269
- * See the LICENSE file in the root directory of this source tree.
270
- */const Wx=Te("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/**
271
- * @license lucide-react v0.468.0 - ISC
272
- *
273
- * This source code is licensed under the ISC license.
274
- * See the LICENSE file in the root directory of this source tree.
275
- */const Og=Te("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
276
- * @license lucide-react v0.468.0 - ISC
277
- *
278
- * This source code is licensed under the ISC license.
279
- * See the LICENSE file in the root directory of this source tree.
280
- */const La=Te("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
281
- * @license lucide-react v0.468.0 - ISC
282
- *
283
- * This source code is licensed under the ISC license.
284
- * See the LICENSE file in the root directory of this source tree.
285
- */const _T=Te("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/**
286
- * @license lucide-react v0.468.0 - ISC
287
- *
288
- * This source code is licensed under the ISC license.
289
- * See the LICENSE file in the root directory of this source tree.
290
- */const TT=Te("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
291
- * @license lucide-react v0.468.0 - ISC
292
- *
293
- * This source code is licensed under the ISC license.
294
- * See the LICENSE file in the root directory of this source tree.
295
- */const Hx=Te("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
296
- * @license lucide-react v0.468.0 - ISC
297
- *
298
- * This source code is licensed under the ISC license.
299
- * See the LICENSE file in the root directory of this source tree.
300
- */const RT=Te("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
301
- * @license lucide-react v0.468.0 - ISC
302
- *
303
- * This source code is licensed under the ISC license.
304
- * See the LICENSE file in the root directory of this source tree.
305
- */const AT=Te("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
306
- * @license lucide-react v0.468.0 - ISC
307
- *
308
- * This source code is licensed under the ISC license.
309
- * See the LICENSE file in the root directory of this source tree.
310
- */const Hp=Te("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/**
311
- * @license lucide-react v0.468.0 - ISC
312
- *
313
- * This source code is licensed under the ISC license.
314
- * See the LICENSE file in the root directory of this source tree.
315
- */const OT=Te("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
316
- * @license lucide-react v0.468.0 - ISC
317
- *
318
- * This source code is licensed under the ISC license.
319
- * See the LICENSE file in the root directory of this source tree.
320
- */const PT=Te("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
321
- * @license lucide-react v0.468.0 - ISC
322
- *
323
- * This source code is licensed under the ISC license.
324
- * See the LICENSE file in the root directory of this source tree.
325
- */const LT=Te("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
326
- * @license lucide-react v0.468.0 - ISC
327
- *
328
- * This source code is licensed under the ISC license.
329
- * See the LICENSE file in the root directory of this source tree.
330
- */const MT=Te("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
331
- * @license lucide-react v0.468.0 - ISC
332
- *
333
- * This source code is licensed under the ISC license.
334
- * See the LICENSE file in the root directory of this source tree.
335
- */const Bx=Te("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
336
- * @license lucide-react v0.468.0 - ISC
337
- *
338
- * This source code is licensed under the ISC license.
339
- * See the LICENSE file in the root directory of this source tree.
340
- */const IT=Te("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/**
341
- * @license lucide-react v0.468.0 - ISC
342
- *
343
- * This source code is licensed under the ISC license.
344
- * See the LICENSE file in the root directory of this source tree.
345
- */const zT=Te("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
346
- * @license lucide-react v0.468.0 - ISC
347
- *
348
- * This source code is licensed under the ISC license.
349
- * See the LICENSE file in the root directory of this source tree.
350
- */const Ya=Te("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
351
- * @license lucide-react v0.468.0 - ISC
352
- *
353
- * This source code is licensed under the ISC license.
354
- * See the LICENSE file in the root directory of this source tree.
355
- */const DT=Te("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
356
- * @license lucide-react v0.468.0 - ISC
357
- *
358
- * This source code is licensed under the ISC license.
359
- * See the LICENSE file in the root directory of this source tree.
360
- */const FT=Te("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
361
- * @license lucide-react v0.468.0 - ISC
362
- *
363
- * This source code is licensed under the ISC license.
364
- * See the LICENSE file in the root directory of this source tree.
365
- */const UT=Te("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);/**
366
- * @license lucide-react v0.468.0 - ISC
367
- *
368
- * This source code is licensed under the ISC license.
369
- * See the LICENSE file in the root directory of this source tree.
370
- */const nl=Te("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
371
- * @license lucide-react v0.468.0 - ISC
372
- *
373
- * This source code is licensed under the ISC license.
374
- * See the LICENSE file in the root directory of this source tree.
375
- */const Gx=Te("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
376
- * @license lucide-react v0.468.0 - ISC
377
- *
378
- * This source code is licensed under the ISC license.
379
- * See the LICENSE file in the root directory of this source tree.
380
- */const Vo=Te("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
381
- * @license lucide-react v0.468.0 - ISC
382
- *
383
- * This source code is licensed under the ISC license.
384
- * See the LICENSE file in the root directory of this source tree.
385
- */const WT=Te("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
386
- * @license lucide-react v0.468.0 - ISC
387
- *
388
- * This source code is licensed under the ISC license.
389
- * See the LICENSE file in the root directory of this source tree.
390
- */const gl=Te("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
391
- * @license lucide-react v0.468.0 - ISC
392
- *
393
- * This source code is licensed under the ISC license.
394
- * See the LICENSE file in the root directory of this source tree.
395
- */const HT=Te("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/**
396
- * @license lucide-react v0.468.0 - ISC
397
- *
398
- * This source code is licensed under the ISC license.
399
- * See the LICENSE file in the root directory of this source tree.
400
- */const qx=Te("RadioTower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);/**
401
- * @license lucide-react v0.468.0 - ISC
402
- *
403
- * This source code is licensed under the ISC license.
404
- * See the LICENSE file in the root directory of this source tree.
405
- */const Yo=Te("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
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 AN=Te("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
411
- * @license lucide-react v0.468.0 - ISC
412
- *
413
- * This source code is licensed under the ISC license.
414
- * See the LICENSE file in the root directory of this source tree.
415
- */const Kx=Te("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/**
416
- * @license lucide-react v0.468.0 - ISC
417
- *
418
- * This source code is licensed under the ISC license.
419
- * See the LICENSE file in the root directory of this source tree.
420
- */const BT=Te("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/**
421
- * @license lucide-react v0.468.0 - ISC
422
- *
423
- * This source code is licensed under the ISC license.
424
- * See the LICENSE file in the root directory of this source tree.
425
- */const hm=Te("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
426
- * @license lucide-react v0.468.0 - ISC
427
- *
428
- * This source code is licensed under the ISC license.
429
- * See the LICENSE file in the root directory of this source tree.
430
- */const ON=Te("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
431
- * @license lucide-react v0.468.0 - ISC
432
- *
433
- * This source code is licensed under the ISC license.
434
- * See the LICENSE file in the root directory of this source tree.
435
- */const GT=Te("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
436
- * @license lucide-react v0.468.0 - ISC
437
- *
438
- * This source code is licensed under the ISC license.
439
- * See the LICENSE file in the root directory of this source tree.
440
- */const PN=Te("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
441
- * @license lucide-react v0.468.0 - ISC
442
- *
443
- * This source code is licensed under the ISC license.
444
- * See the LICENSE file in the root directory of this source tree.
445
- */const LN=Te("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
446
- * @license lucide-react v0.468.0 - ISC
447
- *
448
- * This source code is licensed under the ISC license.
449
- * See the LICENSE file in the root directory of this source tree.
450
- */const Vx=Te("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
451
- * @license lucide-react v0.468.0 - ISC
452
- *
453
- * This source code is licensed under the ISC license.
454
- * See the LICENSE file in the root directory of this source tree.
455
- */const qT=Te("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
456
- * @license lucide-react v0.468.0 - ISC
457
- *
458
- * This source code is licensed under the ISC license.
459
- * See the LICENSE file in the root directory of this source tree.
460
- */const KT=Te("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
461
- * @license lucide-react v0.468.0 - ISC
462
- *
463
- * This source code is licensed under the ISC license.
464
- * See the LICENSE file in the root directory of this source tree.
465
- */const VT=Te("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
466
- * @license lucide-react v0.468.0 - ISC
467
- *
468
- * This source code is licensed under the ISC license.
469
- * See the LICENSE file in the root directory of this source tree.
470
- */const MN=Te("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
471
- * @license lucide-react v0.468.0 - ISC
472
- *
473
- * This source code is licensed under the ISC license.
474
- * See the LICENSE file in the root directory of this source tree.
475
- */const Gs=Te("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
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 Yx=Te("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
481
- * @license lucide-react v0.468.0 - ISC
482
- *
483
- * This source code is licensed under the ISC license.
484
- * See the LICENSE file in the root directory of this source tree.
485
- */const sl=Te("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/**
486
- * @license lucide-react v0.468.0 - ISC
487
- *
488
- * This source code is licensed under the ISC license.
489
- * See the LICENSE file in the root directory of this source tree.
490
- */const IN=Te("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
491
- * @license lucide-react v0.468.0 - ISC
492
- *
493
- * This source code is licensed under the ISC license.
494
- * See the LICENSE file in the root directory of this source tree.
495
- */const Qa=Te("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/**
496
- * @license lucide-react v0.468.0 - ISC
497
- *
498
- * This source code is licensed under the ISC license.
499
- * See the LICENSE file in the root directory of this source tree.
500
- */const Sf=Te("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
501
- * @license lucide-react v0.468.0 - ISC
502
- *
503
- * This source code is licensed under the ISC license.
504
- * See the LICENSE file in the root directory of this source tree.
505
- */const Qo=Te("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
506
- * @license lucide-react v0.468.0 - ISC
507
- *
508
- * This source code is licensed under the ISC license.
509
- * See the LICENSE file in the root directory of this source tree.
510
- */const YT=Te("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function zN(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=zN(e[n]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function DN(){for(var e,n,s=0,r="",o=arguments.length;s<o;s++)(e=arguments[s])&&(n=zN(e))&&(r&&(r+=" "),r+=n);return r}const Qx="-",QT=e=>{const n=XT(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const d=c.split(Qx);return d[0]===""&&d.length!==1&&d.shift(),FN(d,n)||JT(c)},getConflictingClassGroupIds:(c,d)=>{const u=s[c]||[];return d&&r[c]?[...u,...r[c]]:u}}},FN=(e,n)=>{var c;if(e.length===0)return n.classGroupId;const s=e[0],r=n.nextPart.get(s),o=r?FN(e.slice(1),r):void 0;if(o)return o;if(n.validators.length===0)return;const i=e.join(Qx);return(c=n.validators.find(({validator:d})=>d(i)))==null?void 0:c.classGroupId},ij=/^\[(.+)\]$/,JT=e=>{if(ij.test(e)){const n=ij.exec(e)[1],s=n==null?void 0:n.substring(0,n.indexOf(":"));if(s)return"arbitrary.."+s}},XT=e=>{const{theme:n,prefix:s}=e,r={nextPart:new Map,validators:[]};return eR(Object.entries(e.classGroups),s).forEach(([i,c])=>{Pg(c,r,i,n)}),r},Pg=(e,n,s,r)=>{e.forEach(o=>{if(typeof o=="string"){const i=o===""?n:lj(n,o);i.classGroupId=s;return}if(typeof o=="function"){if(ZT(o)){Pg(o(r),n,s,r);return}n.validators.push({validator:o,classGroupId:s});return}Object.entries(o).forEach(([i,c])=>{Pg(c,lj(n,i),s,r)})})},lj=(e,n)=>{let s=e;return n.split(Qx).forEach(r=>{s.nextPart.has(r)||s.nextPart.set(r,{nextPart:new Map,validators:[]}),s=s.nextPart.get(r)}),s},ZT=e=>e.isThemeGetter,eR=(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,tR=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)}}},UN="!",nR=e=>{const{separator:n,experimentalParseClassName:s}=e,r=n.length===1,o=n[0],i=n.length,c=d=>{const u=[];let f=0,g=0,y;for(let j=0;j<d.length;j++){let k=d[j];if(f===0){if(k===o&&(r||d.slice(j,j+i)===n)){u.push(d.slice(g,j)),g=j+i;continue}if(k==="/"){y=j;continue}}k==="["?f++:k==="]"&&f--}const x=u.length===0?d:d.substring(g),h=x.startsWith(UN),v=h?x.substring(1):x,b=y&&y>g?y-g:void 0;return{modifiers:u,hasImportantModifier:h,baseClassName:v,maybePostfixModifierPosition:b}};return s?d=>s({className:d,parseClassName:c}):c},sR=e=>{if(e.length<=1)return e;const n=[];let s=[];return e.forEach(r=>{r[0]==="["?(n.push(...s.sort(),r),s=[]):s.push(r)}),n.push(...s.sort()),n},rR=e=>({cache:tR(e.cacheSize),parseClassName:nR(e),...QT(e)}),oR=/\s+/,aR=(e,n)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:o}=n,i=[],c=e.trim().split(oR);let d="";for(let u=c.length-1;u>=0;u-=1){const f=c[u],{modifiers:g,hasImportantModifier:y,baseClassName:x,maybePostfixModifierPosition:h}=s(f);let v=!!h,b=r(v?x.substring(0,h):x);if(!b){if(!v){d=f+(d.length>0?" "+d:d);continue}if(b=r(x),!b){d=f+(d.length>0?" "+d:d);continue}v=!1}const j=sR(g).join(":"),k=y?j+UN:j,E=k+b;if(i.includes(E))continue;i.push(E);const S=o(b,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 iR(){let e=0,n,s,r="";for(;e<arguments.length;)(n=arguments[e++])&&(s=WN(n))&&(r&&(r+=" "),r+=s);return r}const WN=e=>{if(typeof e=="string")return e;let n,s="";for(let r=0;r<e.length;r++)e[r]&&(n=WN(e[r]))&&(s&&(s+=" "),s+=n);return s};function cj(e,...n){let s,r,o,i=c;function c(u){const f=n.reduce((g,y)=>y(g),e());return s=rR(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=aR(u,s);return o(u,g),g}return function(){return i(iR.apply(null,arguments))}}const Kt=e=>{const n=s=>s[e]||[];return n.isThemeGetter=!0,n},HN=/^\[(?:([a-z-]+):)?(.+)\]$/i,lR=/^\d+\/\d+$/,cR=new Set(["px","full","screen"]),dR=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uR=/\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$/,fR=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,mR=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,hR=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Br=e=>Bi(e)||cR.has(e)||lR.test(e),$o=e=>xl(e,"length",jR),Bi=e=>!!e&&!Number.isNaN(Number(e)),Bp=e=>xl(e,"number",Bi),lc=e=>!!e&&Number.isInteger(Number(e)),pR=e=>e.endsWith("%")&&Bi(e.slice(0,-1)),pt=e=>HN.test(e),_o=e=>dR.test(e),gR=new Set(["length","size","percentage"]),xR=e=>xl(e,gR,BN),vR=e=>xl(e,"position",BN),bR=new Set(["image","url"]),yR=e=>xl(e,bR,NR),wR=e=>xl(e,"",kR),cc=()=>!0,xl=(e,n,s)=>{const r=HN.exec(e);return r?r[1]?typeof n=="string"?r[1]===n:n.has(r[1]):s(r[2]):!1},jR=e=>uR.test(e)&&!fR.test(e),BN=()=>!1,kR=e=>mR.test(e),NR=e=>hR.test(e),dj=()=>{const e=Kt("colors"),n=Kt("spacing"),s=Kt("blur"),r=Kt("brightness"),o=Kt("borderColor"),i=Kt("borderRadius"),c=Kt("borderSpacing"),d=Kt("borderWidth"),u=Kt("contrast"),f=Kt("grayscale"),g=Kt("hueRotate"),y=Kt("invert"),x=Kt("gap"),h=Kt("gradientColorStops"),v=Kt("gradientColorStopPositions"),b=Kt("inset"),j=Kt("margin"),k=Kt("opacity"),E=Kt("padding"),S=Kt("saturate"),N=Kt("scale"),$=Kt("sepia"),_=Kt("skew"),P=Kt("space"),O=Kt("translate"),M=()=>["auto","contain","none"],R=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto",pt,n],L=()=>[pt,n],D=()=>["",Br,$o],W=()=>["auto",Bi,pt],q=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],H=()=>["solid","dashed","dotted","double","none"],K=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>["start","end","center","between","around","evenly","stretch"],G=()=>["","0",pt],F=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[Bi,pt];return{cacheSize:500,separator:":",theme:{colors:[cc],spacing:[Br,$o],blur:["none","",_o,pt],brightness:z(),borderColor:[e],borderRadius:["none","","full",_o,pt],borderSpacing:L(),borderWidth:D(),contrast:z(),grayscale:G(),hueRotate:z(),invert:G(),gap:L(),gradientColorStops:[e],gradientColorStopPositions:[pR,$o],inset:A(),margin:A(),opacity:z(),padding:L(),saturate:z(),scale:z(),sepia:G(),skew:z(),space:L(),translate:L()},classGroups:{aspect:[{aspect:["auto","square","video",pt]}],container:["container"],columns:[{columns:[_o]}],"break-after":[{"break-after":F()}],"break-before":[{"break-before":F()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...q(),pt]}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[b]}],"inset-x":[{"inset-x":[b]}],"inset-y":[{"inset-y":[b]}],start:[{start:[b]}],end:[{end:[b]}],top:[{top:[b]}],right:[{right:[b]}],bottom:[{bottom:[b]}],left:[{left:[b]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",lc,pt]}],basis:[{basis:A()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",pt]}],grow:[{grow:G()}],shrink:[{shrink:G()}],order:[{order:["first","last","none",lc,pt]}],"grid-cols":[{"grid-cols":[cc]}],"col-start-end":[{col:["auto",{span:["full",lc,pt]},pt]}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":[cc]}],"row-start-end":[{row:["auto",{span:[lc,pt]},pt]}],"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",pt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",pt]}],gap:[{gap:[x]}],"gap-x":[{"gap-x":[x]}],"gap-y":[{"gap-y":[x]}],"justify-content":[{justify:["normal",...U()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...U(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...U(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[E]}],px:[{px:[E]}],py:[{py:[E]}],ps:[{ps:[E]}],pe:[{pe:[E]}],pt:[{pt:[E]}],pr:[{pr:[E]}],pb:[{pb:[E]}],pl:[{pl:[E]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[P]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[P]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",pt,n]}],"min-w":[{"min-w":[pt,n,"min","max","fit"]}],"max-w":[{"max-w":[pt,n,"none","full","min","max","fit","prose",{screen:[_o]},_o]}],h:[{h:[pt,n,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[pt,n,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[pt,n,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[pt,n,"auto","min","max","fit"]}],"font-size":[{text:["base",_o,$o]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Bp]}],"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",pt]}],"line-clamp":[{"line-clamp":["none",Bi,Bp]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Br,pt]}],"list-image":[{"list-image":["none",pt]}],"list-style-type":[{list:["none","disc","decimal",pt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Br,$o]}],"underline-offset":[{"underline-offset":["auto",Br,pt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...q(),vR]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",xR]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},yR]}],"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":[Br,pt]}],"outline-w":[{outline:[Br,$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":[Br,$o]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",_o,wR]}],"shadow-color":[{shadow:[cc]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...K(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":K()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",_o,pt]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[g]}],invert:[{invert:[y]}],saturate:[{saturate:[S]}],sepia:[{sepia:[$]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[g]}],"backdrop-invert":[{"backdrop-invert":[y]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[S]}],"backdrop-sepia":[{"backdrop-sepia":[$]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",pt]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",pt]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",pt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[N]}],"scale-x":[{"scale-x":[N]}],"scale-y":[{"scale-y":[N]}],rotate:[{rotate:[lc,pt]}],"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",pt]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",pt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",pt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Br,$o,Bp]}],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"]}}},SR=(e,{cacheSize:n,prefix:s,separator:r,experimentalParseClassName:o,extend:i={},override:c={}})=>{wc(e,"cacheSize",n),wc(e,"prefix",s),wc(e,"separator",r),wc(e,"experimentalParseClassName",o);for(const d in c)CR(e[d],c[d]);for(const d in i)ER(e[d],i[d]);return e},wc=(e,n,s)=>{s!==void 0&&(e[n]=s)},CR=(e,n)=>{if(n)for(const s in n)wc(e,s,n[s])},ER=(e,n)=>{if(n)for(const s in n){const r=n[s];r!==void 0&&(e[s]=(e[s]||[]).concat(r))}},$R=(e,...n)=>typeof e=="function"?cj(dj,e,...n):cj(()=>SR(dj(),e),...n),_R=$R({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"]}]}}}),ie=(...e)=>_R(DN(e)),TR={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:Og},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:Og},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:EN},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:tl}};function vt({tone:e="neutral",title:n,actions:s,bar:r,icon:o,role:i,className:c,children:d,...u}){const f=TR[e],g=o===!1?null:o??f.Icon;return t.jsxs("div",{role:i??(e==="error"?"alert":"status"),...u,className:ie("flex gap-3 text-body",r?"shrink-0 items-center border-b bg-card px-5 py-2 md:px-8":ie("border p-4",f.box),c),children:[g&&t.jsx(g,{className:ie("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:ie("font-semibold",!r&&"caps text-small",!r&&f.text),children:n}),d&&t.jsx("div",{className:ie(n&&!r&&"mt-2"),children:d})]}),s&&t.jsx("div",{className:"flex shrink-0 items-start gap-2",children:s})]})}const uj=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,fj=DN,RR=(e,n)=>s=>{var r;if((n==null?void 0:n.variants)==null)return fj(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:o,defaultVariants:i}=n,c=Object.keys(o).map(f=>{const g=s==null?void 0:s[f],y=i==null?void 0:i[f];if(g===null)return null;const x=uj(g)||uj(y);return o[f][x]}),d=s&&Object.entries(s).reduce((f,g)=>{let[y,x]=g;return x===void 0||(f[y]=x),f},{}),u=n==null||(r=n.compoundVariants)===null||r===void 0?void 0:r.reduce((f,g)=>{let{class:y,className:x,...h}=g;return Object.entries(h).every(v=>{let[b,j]=v;return Array.isArray(j)?j.includes({...i,...d}[b]):{...i,...d}[b]===j})?[...f,y,x]:f},[]);return fj(e,c,u,s==null?void 0:s.class,s==null?void 0:s.className)},rl=RR("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:ie(rl({variant:n,size:s}),e),...r}));B.displayName="Button";const mj={plain:"border-border text-muted-foreground",active:"border-run-active/50 text-run-active",success:"border-success/50 bg-success/10 text-success-text",warning:"border-warning/50 bg-warning/10 text-warning-text",error:"border-destructive/50 bg-destructive/10 text-destructive-text",info:"border-info/50 bg-info/10 text-info-text",muted:"border-border-strong/60 text-muted-foreground"};function Ne({tone:e="plain",className:n,title:s,label:r,children:o}){return r?t.jsx("span",{title:s,className:ie("caps inline-flex h-5 min-w-0 items-center gap-1 border px-1.5 text-micro leading-none",mj[e],n),children:t.jsx("span",{className:"min-w-0 truncate",children:o})}):t.jsx("span",{title:s,className:ie("caps inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap border px-1.5 text-micro leading-none",mj[e],n),children:o})}const qs=e=>AR(e)?e.document:OR(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),pm=e=>{let n=qs(e);return(n==null?void 0:n.defaultView)??(typeof window<"u"?window:void 0)};function GN(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function AR(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function OR(e){return GN(e)&&e.nodeType===9}function PR(e){return GN(e)&&e.nodeType===11&&"host"in e}let LR=!1;function Jx(){return LR}function _a(e,n){var r;if(!Jx())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:PR(s)?s=s.host:s=s.parentNode}return!1}const Uo=(e=document)=>{var s;if(!Jx())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(Jx()&&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 MR(e){e.focus({preventScroll:!0})}const IR=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 zR(e,n){Object.defineProperty(e,"target",{value:n}),Object.defineProperty(e,"currentTarget",{value:n})}function KN(e){let n=p.useRef({isFocused:!1,observer:null});return IR(()=>{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===Uo()?null:Uo();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 Xx(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 Zx(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 Ja(e){let n=null;return()=>(n==null&&(n=e()),n)}const ev=Ja(function(){return Zx(/^Mac/i)}),DR=Ja(function(){return Zx(/^iPhone/i)}),VN=Ja(function(){return Zx(/^iPad/i)||ev()&&navigator.maxTouchPoints>1}),FR=Ja(function(){return DR()||VN()}),UR=Ja(function(){return Xx(/AppleWebKit/i)&&(FR()||!WR())}),WR=Ja(function(){return Xx(/Chrome|CriOS|CrMo/i)}),HR=Ja(function(){return Xx(/Android/i)});function BR(e){return e.pointerType===""&&e.isTrusted?!0:HR()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Lc(e,n,s=!0){let{metaKey:r,ctrlKey:o,altKey:i,shiftKey:c}=n,d=UR()&&ev()&&!VN()?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});Lc.isOpening=s,MR(e),e.dispatchEvent(d),Lc.isOpening=!1}Lc.isOpening=!1;let vl=null;const Lg=new Set;let Ec=new Map,Ma=!1,uf=!1;const GR={Tab:!0,Escape:!0};function gm(e,n){for(let s of Lg)s(e,n)}function qR(e){return!(e.metaKey||!ev()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Cf(e){Ma=!0,!Lc.isOpening&&qR(e)&&(vl="keyboard",gm("keyboard",e))}function Gi(e){vl="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(Ma=!0,gm("pointer",e))}function YN(e){!Lc.isOpening&&BR(e)&&(Ma=!0,vl="virtual")}function QN(e){let n=Jn(e),s=pm(n),r=qs(n);if(n===s){uf=!0;return}n===r||!e.isTrusted||(!Ma&&!uf&&(vl="virtual",gm("virtual",e)),Ma=!1,uf=!1)}function JN(){Ma=!1,uf=!0}function XN(e){let n=Uo(qs(Jn(e)));queueMicrotask(()=>{Uo(qs(Jn(e)))!==n&&VR("keyboard")})}function Mg(e){if(typeof window>"u"||typeof document>"u")return;const n=pm(e),s=qs(e);if(Ec.get(n))return;let r=n.HTMLElement.prototype.focus;Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){Ma=!0,r.apply(this,arguments)}}),s.addEventListener("keydown",Cf,!0),s.addEventListener("keyup",Cf,!0),s.addEventListener("click",YN,!0),s.addEventListener("invalid",XN,!0),n.addEventListener("focus",QN,!0),n.addEventListener("blur",JN,!1),typeof PointerEvent<"u"&&(s.addEventListener("pointerdown",Gi,!0),s.addEventListener("pointermove",Gi,!0),s.addEventListener("pointerup",Gi,!0)),n.addEventListener("beforeunload",()=>{ZN(e)},{once:!0}),Ec.set(n,{focus:r})}const ZN=(e,n)=>{const s=pm(e),r=qs(e);n&&r.removeEventListener("DOMContentLoaded",n),Ec.has(s)&&(Reflect.defineProperty(s.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:Ec.get(s).focus}),r.removeEventListener("keydown",Cf,!0),r.removeEventListener("keyup",Cf,!0),r.removeEventListener("click",YN,!0),r.removeEventListener("invalid",XN,!0),s.removeEventListener("focus",QN,!0),s.removeEventListener("blur",JN,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",Gi,!0),r.removeEventListener("pointermove",Gi,!0),r.removeEventListener("pointerup",Gi,!0)),Ec.delete(s))};function KR(e){const n=qs(e);let s;return n.readyState!=="loading"?Mg(e):(s=()=>{Mg(e)},n.addEventListener("DOMContentLoaded",s)),()=>ZN(e,s)}typeof document<"u"&&KR();function Ig(){return vl!=="pointer"}function VR(e){vl=e,gm(e,null)}const YR=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function QR(e,n,s){let r=s?Jn(s):void 0,o=qs(r),i=pm(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=Uo(o);return e=e||g instanceof c&&!YR.has(g.type)||g instanceof d||g instanceof u&&g.isContentEditable,!(e&&n==="keyboard"&&s instanceof f&&!GR[s.key])}function JR(e,n,s){Mg(),p.useEffect(()=>{if((s==null?void 0:s.enabled)===!1)return;let r=(o,i)=>{QR(!!(s!=null&&s.isTextInput),o,i)&&e(Ig())};return Lg.add(r),()=>{Lg.delete(r)}},n)}function XR(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=KN(i),d=p.useCallback(u=>{let f=Jn(u);const g=qs(f),y=g?Uo(g):Uo();f===u.currentTarget&&f===y&&(s&&s(u),o&&o(!0),c(u))},[o,s,c]);return{focusProps:{onFocus:!n&&(s||o||r)?d:void 0,onBlur:!n&&(r||o)?i:void 0}}}function e1(){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 ZR(e){let{isDisabled:n,onBlurWithin:s,onFocusWithin:r,onFocusWithinChange:o}=e,i=p.useRef({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:d}=e1(),u=p.useCallback(y=>{_a(y.currentTarget,Jn(y))&&i.current.isFocusWithin&&!_a(y.currentTarget,y.relatedTarget)&&(i.current.isFocusWithin=!1,d(),s&&s(y),o&&o(!1))},[s,o,i,d]),f=KN(u),g=p.useCallback(y=>{if(!_a(y.currentTarget,Jn(y)))return;let x=Jn(y);const h=qs(x),v=Uo(h);if(!i.current.isFocusWithin&&v===x){r&&r(y),o&&o(!0),i.current.isFocusWithin=!0,f(y);let b=y.currentTarget;c(h,"focus",j=>{let k=Jn(j);if(i.current.isFocusWithin&&!_a(b,k)){let E=new h.defaultView.FocusEvent("blur",{relatedTarget:k});zR(E,b);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 eA(e={}){let{autoFocus:n=!1,isTextInput:s,within:r}=e,o=p.useRef({isFocused:!1,isFocusVisible:n||Ig()}),[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=Ig(),c(h),f()},[f]);JR(h=>{o.current.isFocusVisible=h,f()},[s,i],{enabled:i,isTextInput:s});let{focusProps:y}=XR({isDisabled:r,onFocusChange:g}),{focusWithinProps:x}=ZR({isDisabled:!r,onFocusWithinChange:g});return{isFocused:i,isFocusVisible:d,focusProps:r?x:y}}var Ns=kN();let zg=!1,zu=0;function tA(){zg=!0,setTimeout(()=>{zg=!1},500)}function hj(e){e.pointerType==="touch"&&tA()}function nA(){let e=qs(null);if(!(typeof e>"u"))return zu===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",hj),zu++,()=>{zu--,!(zu>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",hj)}}function sA(e){let{onHoverStart:n,onHoverChange:s,onHoverEnd:r,isDisabled:o}=e,[i,c]=p.useState(!1),d=p.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;p.useEffect(nA,[]);let{addGlobalListener:u,removeAllGlobalListeners:f}=e1(),{hoverProps:g,triggerHoverEnd:y}=p.useMemo(()=>{let x=(b,j)=>{if(d.pointerType=j,o||j==="touch"||d.isHovered||!_a(b.currentTarget,Jn(b)))return;d.isHovered=!0;let k=b.currentTarget;d.target=k,u(qs(Jn(b)),"pointerover",E=>{d.isHovered&&d.target&&!_a(d.target,Jn(E))&&h(E,E.pointerType)},{capture:!0}),n&&n({type:"hoverstart",target:k,pointerType:j}),s&&s(!0),c(!0)},h=(b,j)=>{let k=d.target;d.pointerType="",d.target=null,!(j==="touch"||!d.isHovered||!k)&&(d.isHovered=!1,f(),r&&r({type:"hoverend",target:k,pointerType:j}),s&&s(!1),c(!1))},v={};return typeof PointerEvent<"u"&&(v.onPointerEnter=b=>{zg&&b.pointerType==="mouse"||x(b,b.pointerType)},v.onPointerLeave=b=>{!o&&_a(b.currentTarget,Jn(b))&&h(b,b.pointerType)}),{hoverProps:v,triggerHoverEnd:h}},[n,s,r,o,d,u,f]);return p.useEffect(()=>{o&&y({currentTarget:d.target},d.pointerType)},[o]),{hoverProps:g,isHovered:i}}var rA=Object.defineProperty,oA=(e,n,s)=>n in e?rA(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Gp=(e,n,s)=>(oA(e,typeof n!="symbol"?n+"":n,s),s);let aA=class{constructor(){Gp(this,"current",this.detect()),Gp(this,"handoffState","pending"),Gp(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"}},Sr=new aA;function bl(e){var n;return Sr.isServer?null:e==null?document:(n=e==null?void 0:e.ownerDocument)!=null?n:document}function Ef(e){var n,s;return Sr.isServer?null:e==null?document:(s=(n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))!=null?s:document}function t1(e){var n,s;return(s=(n=Ef(e))==null?void 0:n.activeElement)!=null?s:null}function n1(e){return t1(e)===e}function xm(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 xm(()=>{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 Jo(){let[e]=p.useState($s);return p.useEffect(()=>()=>e.dispose(),[e]),e}let tn=(e,n)=>{Sr.isServer?p.useEffect(e,n):p.useLayoutEffect(e,n)};function Xo(e){let n=p.useRef(e);return tn(()=>{n.current=e},[e]),n}let ut=function(e){let n=Xo(e);return Ke.useCallback((...s)=>n.current(...s),[n])};function iA(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 lA(e,n){return!(!e||!n||e.right<n.left||e.left>n.right||e.bottom<n.top||e.top>n.bottom)}function cA({disabled:e=!1}={}){let n=p.useRef(null),[s,r]=p.useState(!1),o=Jo(),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=bl(d.currentTarget);o.addEventListener(u,"pointerup",i,!1),o.addEventListener(u,"pointermove",f=>{if(n.current){let g=iA(f);r(lA(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 dA=p.createContext(void 0);function tv(){return p.useContext(dA)}function Dg(...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||{}),Mo=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Mo||{});function En(){let e=fA();return p.useCallback(n=>uA({mergeRefs:e,...n}),[e])}function uA({ourProps:e,theirProps:n,slot:s,defaultTag:r,features:o,visible:i=!0,name:c,mergeRefs:d}){d=d??mA;let u=s1(n,e);if(i)return Du(u,s,r,c,d);let f=o??0;if(f&2){let{static:g=!1,...y}=u;if(g)return Du(y,s,r,c,d)}if(f&1){let{unmount:g=!0,...y}=u;return ts(g?0:1,{0(){return null},1(){return Du({...y,hidden:!0,style:{display:"none"}},s,r,c,d)}})}return Du(u,s,r,c,d)}function Du(e,n={},s,r,o){let{as:i=s,children:c,refName:d="ref",...u}=qp(e,["unmount","static"]),f=e.ref!==void 0?{[d]:e.ref}:{},g=typeof c=="function"?c(n):c;g=o1(g),"className"in u&&u.className&&typeof u.className=="function"&&(u.className=u.className(n)),u["aria-labelledby"]&&u["aria-labelledby"]===u.id&&(u["aria-labelledby"]=void 0);let y={};if(n){let x=!1,h=[];for(let[v,b]of Object.entries(n))typeof b=="boolean"&&(x=!0),b===!0&&h.push(v.replace(/([A-Z])/g,j=>`-${j.toLowerCase()}`));if(x){y["data-headlessui-state"]=h.join(" ");for(let v of h)y[`data-${v}`]=""}}if($c(i)&&(Object.keys(Po(u)).length>0||Object.keys(Po(y)).length>0))if(!p.isValidElement(g)||Array.isArray(g)&&g.length>1||pA(g)){if(Object.keys(Po(u)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(Po(u)).concat(Object.keys(Po(y))).map(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)=>Dg(h(...k),u.className):Dg(h,u.className),b=v?{className:v}:{},j=s1(g.props,Po(qp(u,["ref"])));for(let k in y)k in j&&delete y[k];return p.cloneElement(g,Object.assign({},j,y,f,{ref:o(hA(g),f.ref)},b))}return p.createElement(i,Object.assign({},qp(u,["ref"]),!$c(i)&&f,!$c(i)&&y),g)}function fA(){let e=p.useRef([]),n=p.useCallback(s=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(s):r.current=s)},[]);return(...s)=>{if(!s.every(r=>r==null))return e.current=s,n}}function mA(...e){return e.every(n=>n==null)?void 0:n=>{for(let s of e)s!=null&&(typeof s=="function"?s(n):s.current=n)}}function s1(...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 r1(...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 xn(e){var n;return Object.assign(p.forwardRef(e),{displayName:(n=e.displayName)!=null?n:e.name})}function Po(e){let n=Object.assign({},e);for(let s in n)n[s]===void 0&&delete n[s];return n}function qp(e,n=[]){let s=Object.assign({},e);for(let r of n)r in s&&delete s[r];return s}function hA(e){return Ke.version.split(".")[0]>="19"?e.props.ref:e.ref}function o1(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let n=e._payload;if(n!=null&&n.status==="fulfilled")return o1(n.value)}return e}function $c(e){return e===p.Fragment||e===Symbol.for("react.fragment")}function pA(e){return $c(e.type)}function gA(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 xA(e){let[n]=p.useState(e);return n}function a1(e={},n=null,s=[]){for(let[r,o]of Object.entries(e))l1(s,i1(n,r),o);return s}function i1(e,n){return e?e+"["+n+"]":n}function l1(e,n,s){if(Array.isArray(s))for(let[r,o]of s.entries())l1(e,i1(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,""]):bA(s)&&!p.isValidElement(s)&&a1(s,n,e)}function vA(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 bA(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}let yA="span";var al=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(al||{});function wA(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 En()({ourProps:i,theirProps:o,slot:{},defaultTag:yA,name:"Hidden"})}let Mc=xn(wA),jA=p.createContext(null);function kA({children:e}){let n=p.useContext(jA);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 NA({data:e,form:n,disabled:s,onReset:r,overrides:o}){let[i,c]=p.useState(null),d=Jo();return p.useEffect(()=>{if(r&&i)return d.addEventListener(i,"reset",r)},[i,n,r]),Ke.createElement(kA,null,Ke.createElement(SA,{setForm:c,formId:n}),a1(e).map(([u,f])=>Ke.createElement(Mc,{features:al.Hidden,...Po({key:u,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:n,disabled:s,name:u,value:f,...o})})))}function SA({setForm:e,formId:n}){return p.useEffect(()=>{if(n){let s=document.getElementById(n);s&&e(s)}},[e,n]),n?null:Ke.createElement(Mc,{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 CA=p.createContext(void 0);function c1(){return p.useContext(CA)}function d1(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function Jr(e){return d1(e)&&"tagName"in e}function Ss(e){return Jr(e)&&"accessKey"in e}function Vr(e){return Jr(e)&&"tabIndex"in e}function EA(e){return Jr(e)&&"style"in e}function $A(e){return Ss(e)&&e.nodeName==="IFRAME"}function u1(e){return Ss(e)&&e.nodeName==="INPUT"}function pj(e){return Ss(e)&&e.nodeName==="LABEL"}function _A(e){return Ss(e)&&e.nodeName==="FIELDSET"}function f1(e){return Ss(e)&&e.nodeName==="LEGEND"}function TA(e){return Jr(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function gj(e){let n=e.parentElement,s=null;for(;n&&!_A(n);)f1(n)&&(s=n),n=n.parentElement;let r=(n==null?void 0:n.getAttribute("disabled"))==="";return r&&RA(s)?!1:r}function RA(e){if(!e)return!1;let n=e.previousElementSibling;for(;n!==null;){if(f1(n))return!1;n=n.previousElementSibling}return!0}let m1=Symbol();function AA(e,n=!0){return Object.assign(e,{[m1]: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[m1]))?void 0:s}let vm=p.createContext(null);vm.displayName="DescriptionContext";function h1(){let e=p.useContext(vm);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,h1),n}return e}function OA(){var e,n;return(n=(e=p.useContext(vm))==null?void 0:e.value)!=null?n:void 0}function PA(){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(vm.Provider,{value:o},s.children)},[n])]}let LA="p";function MA(e,n){let s=p.useId(),r=tv(),{id:o=`headlessui-description-${s}`,...i}=e,c=h1(),d=Fn(n);tn(()=>c.register(o),[o,c.register]);let u=Ks({...c.slot,disabled:r||!1}),f={ref:d,...c.props,id:o};return En()({ourProps:f,theirProps:i,slot:u,defaultTag:LA,name:c.name||"Description"})}let IA=xn(MA),p1=Object.assign(IA,{});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 bm=p.createContext(null);bm.displayName="LabelContext";function g1(){let e=p.useContext(bm);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,g1),n}return e}function x1(e){var n,s,r;let o=(s=(n=p.useContext(bm))==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 zA({inherit:e=!1}={}){let n=x1(),[s,r]=p.useState([]),o=e?[n,...s].filter(Boolean):s;return[o.length>0?o.join(" "):void 0,p.useMemo(()=>function(i){let c=ut(u=>(r(f=>[...f,u]),()=>r(f=>{let g=f.slice(),y=g.indexOf(u);return y!==-1&&g.splice(y,1),g}))),d=p.useMemo(()=>({register:c,slot:i.slot,name:i.name,props:i.props,value:i.value}),[c,i.slot,i.name,i.props,i.value]);return Ke.createElement(bm.Provider,{value:d},i.children)},[r])]}let DA="label";function FA(e,n){var s;let r=p.useId(),o=g1(),i=c1(),c=tv(),{id:d=`headlessui-label-${r}`,htmlFor:u=i??((s=o.props)==null?void 0:s.htmlFor),passive:f=!1,...g}=e,y=Fn(n);tn(()=>o.register(d),[d,o.register]);let x=ut(b=>{let j=b.currentTarget;if(!(b.target!==b.currentTarget&&TA(b.target))&&(pj(j)&&b.preventDefault(),o.props&&"onClick"in o.props&&typeof o.props.onClick=="function"&&o.props.onClick(b),pj(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;(u1(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:y,...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),En()({ourProps:v,theirProps:g,slot:h,defaultTag:u?DA:"div",name:o.name||"Label"})}let UA=xn(FA),WA=Object.assign(UA,{}),HA=p.createContext(()=>{});function BA({value:e,children:n}){return Ke.createElement(HA.Provider,{value:e},n)}function GA(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 qA(e=GA){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 xj(e){if(e===null)return{width:0,height:0};let{width:n,height:s}=e.getBoundingClientRect();return{width:n,height:s}}function KA(e,n,s=!1){let[r,o]=p.useState(()=>xj(n));return tn(()=>{if(!n||!e)return;let i=$s();return i.requestAnimationFrame(function c(){i.requestAnimationFrame(c),o(d=>{let u=xj(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 v1=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(v1||{});function VA(e){let n=p.useRef(null),s=ut(o=>{n.current=o.pointerType,!gj(o.currentTarget)&&o.pointerType==="mouse"&&o.button===v1.Left&&(o.preventDefault(),e(o))}),r=ut(o=>{n.current!=="mouse"&&(gj(o.currentTarget)||e(o))});return{onPointerDown:s,onClick:r}}let b1=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 YA=Object.defineProperty,QA=(e,n,s)=>n in e?YA(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,JA=(e,n,s)=>(QA(e,n+"",s),s),y1=(e,n,s)=>{if(!n.has(e))throw TypeError("Cannot "+s)},zs=(e,n,s)=>(y1(e,n,"read from private field"),s?s.call(e):n.get(e)),Kp=(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)},vj=(e,n,s,r)=>(y1(e,n,"write to private field"),n.set(e,s),s),wr,jc,kc;let w1=class{constructor(n){Kp(this,wr,{}),Kp(this,jc,new b1(()=>new Set)),Kp(this,kc,new Set),JA(this,"disposables",$s()),vj(this,wr,n),Sr.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return zs(this,wr)}subscribe(n,s){if(Sr.isServer)return()=>{};let r={selector:n,callback:s,current:n(zs(this,wr))};return zs(this,kc).add(r),this.disposables.add(()=>{zs(this,kc).delete(r)})}on(n,s){return Sr.isServer?()=>{}:(zs(this,jc).get(n).add(s),this.disposables.add(()=>{zs(this,jc).get(n).delete(s)}))}send(n){let s=this.reduce(zs(this,wr),n);if(s!==zs(this,wr)){vj(this,wr,s);for(let r of zs(this,kc)){let o=r.selector(zs(this,wr));j1(r.current,o)||(r.current=o,r.callback(o))}for(let r of zs(this,jc).get(n.type))r(zs(this,wr),n)}}};wr=new WeakMap,jc=new WeakMap,kc=new WeakMap;function j1(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:Vp(e[Symbol.iterator](),n[Symbol.iterator]()):e instanceof Map&&n instanceof Map||e instanceof Set&&n instanceof Set?e.size!==n.size?!1:Vp(e.entries(),n.entries()):bj(e)&&bj(n)?Vp(Object.entries(e)[Symbol.iterator](),Object.entries(n)[Symbol.iterator]()):!1}function Vp(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 bj(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}function Yp(e){let[n,s]=e(),r=$s();return(...o)=>{n(...o),r.dispose(),r.microTask(s)}}var XA=Object.defineProperty,ZA=(e,n,s)=>n in e?XA(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,yj=(e,n,s)=>(ZA(e,typeof n!="symbol"?n+"":n,s),s),k1=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(k1||{});let e3={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}}},t3=class N1 extends w1{constructor(){super(...arguments),yj(this,"actions",{push:n=>this.send({type:0,id:n}),pop:n=>this.send({type:1,id:n})}),yj(this,"selectors",{isTop:(n,s)=>n.stack[n.stack.length-1]===s,inStack:(n,s)=>n.stack.includes(s)})}static new(){return new N1({stack:[]})}reduce(n,s){return ts(s.type,e3,n,s)}};const ym=new b1(()=>t3.new());var Qp={exports:{}},Jp={};/**
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 wj;function n3(){if(wj)return Jp;wj=1;var e=lm();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 Jp.useSyncExternalStoreWithSelector=function(u,f,g,y,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=$,$=y($),x!==void 0&&v.hasValue){var _=v.value;if(x(_,$))return S=_}return S=$}if(_=S,s(E,$))return _;var P=y($);return x!==void 0&&x(_,P)?(E=$,_):(E=$,S=P)}var k=!1,E,S,N=g===void 0?null:g;return[function(){return j(f())},N===null?void 0:function(){return j(N())}]},[f,g,y,x]);var b=r(u,h[0],h[1]);return i(function(){v.hasValue=!0,v.value=b},[b]),d(b),b},Jp}var jj;function s3(){return jj||(jj=1,Qp.exports=n3()),Qp.exports}var r3=s3();function Qn(e,n,s=j1){return r3.useSyncExternalStoreWithSelector(ut(r=>e.subscribe(o3,r)),ut(()=>e.state),ut(()=>e.state),ut(n),s)}function o3(e){return e}function nd(e,n){let s=p.useId(),r=ym.get(n),[o,i]=Qn(r,p.useCallback(c=>[r.selectors.isTop(c,s),r.selectors.inStack(c,s)],[r,s]));return tn(()=>{if(e)return r.actions.push(s),()=>r.actions.pop(s)},[r,e,s]),e?i?o:!0:!1}let Fg=new Map,_c=new Map;function kj(e){var n;let s=(n=_c.get(e))!=null?n:0;return _c.set(e,s+1),s!==0?()=>Nj(e):(Fg.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Nj(e))}function Nj(e){var n;let s=(n=_c.get(e))!=null?n:1;if(s===1?_c.delete(e):_c.set(e,s-1),s!==1)return;let r=Fg.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,Fg.delete(e))}function S1(e,{allowed:n,disallowed:s}={}){let r=nd(e,"inert-others");tn(()=>{var o,i;if(!r)return;let c=$s();for(let u of(o=s==null?void 0:s())!=null?o:[])u&&c.add(kj(u));let d=(i=n==null?void 0:n())!=null?i:[];for(let u of d){if(!u)continue;let f=bl(u);if(!f)continue;let g=u.parentElement;for(;g&&g!==f.body;){for(let y of g.children)d.some(x=>y.contains(x))||c.add(kj(y));g=g.parentElement}}return c.dispose},[r,n,s])}function C1(e,n,s){let r=Xo(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 $f=["[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(","),a3=["[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||{}),Ug=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(Ug||{}),i3=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(i3||{});function E1(e=document.body){return e==null?[]:Array.from(e.querySelectorAll($f)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}function l3(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(a3)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}var nv=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(nv||{});function $1(e,n=0){var s;return e===((s=bl(e))==null?void 0:s.body)?!1:ts(n,{0(){return e.matches($f)},1(){let r=e;for(;r!==null;){if(r.matches($f))return!0;r=r.parentElement}return!1}})}var c3=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(c3||{});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 Xr(e){e==null||e.focus({preventScroll:!0})}let d3=["textarea","input"].join(",");function u3(e){var n,s;return(s=(n=e==null?void 0:e.matches)==null?void 0:n.call(e,d3))!=null?s:!1}function _1(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 f3(e,n,s=e===null?document.body:Ef(e)){return qi(E1(s),n,{relativeTo:e})}function qi(e,n,{sorted:s=!0,relativeTo:r=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?Ef(e[0]):document:Ef(e),c=Array.isArray(e)?s?_1(e):e:n&64?l3(e):E1(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,y=c.length,x;do{if(g>=y||g+y<=0)return 0;let h=u+g;if(n&16)h=(h+y)%y;else{if(h<0)return 3;if(h>=y)return 1}x=c[h],x==null||x.focus(f),g+=d}while(x!==t1(x));return n&6&&u3(x)&&x.select(),2}function T1(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function m3(){return/Android/gi.test(window.navigator.userAgent)}function Sj(){return T1()||m3()}function Di(e,n,s,r){let o=Xo(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 R1(e,n,s,r){let o=Xo(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 Cj=30;function A1(e,n,s){let r=Xo(s),o=p.useCallback(function(d,u){if(d.defaultPrevented)return;let f=u(d);if(f===null||!f.getRootNode().contains(f)||!f.isConnected)return;let g=(function y(x){return typeof x=="function"?y(x()):Array.isArray(x)||x instanceof Set?x:[x]})(n);for(let y of g)if(y!==null&&(y.contains(f)||d.composed&&d.composedPath().includes(y)))return;return!$1(f,nv.Loose)&&f.tabIndex!==-1&&d.preventDefault(),r.current(d,f)},[r,n]),i=p.useRef(null);Di(e,"pointerdown",d=>{var u,f;Sj()||(i.current=((f=(u=d.composedPath)==null?void 0:u.call(d))==null?void 0:f[0])||d.target)},!0),Di(e,"pointerup",d=>{if(Sj()||!i.current)return;let u=i.current;return i.current=null,o(d,()=>u)},!0);let c=p.useRef({x:0,y:0});Di(e,"touchstart",d=>{c.current.x=d.touches[0].clientX,c.current.y=d.touches[0].clientY},!0),Di(e,"touchend",d=>{let u={x:d.changedTouches[0].clientX,y:d.changedTouches[0].clientY};if(!(Math.abs(u.x-c.current.x)>=Cj||Math.abs(u.y-c.current.y)>=Cj))return o(d,()=>Vr(d.target)?d.target:null)},!0),R1(e,"blur",d=>o(d,()=>$A(window.document.activeElement)?window.document.activeElement:null),!0)}function Ic(...e){return p.useMemo(()=>bl(...e),[...e])}var h3=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(h3||{});const Fu={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},p3=200,Ej=5;function g3(e,{trigger:n,action:s,close:r,select:o}){let i=p.useRef(null),c=p.useRef(null),d=p.useRef(null);Di(e&&n!==null,"pointerdown",u=>{d1(u==null?void 0:u.target)&&n!=null&&n.contains(u.target)&&(c.current=u.x,d.current=u.y,i.current=u.timeStamp)}),Di(e&&n!==null,"pointerup",u=>{var f,g;let y=i.current;if(y===null||(i.current=null,!Vr(u.target))||Math.abs(u.x-((f=c.current)!=null?f:u.x))<Ej&&Math.abs(u.y-((g=d.current)!=null?g:u.y))<Ej)return;let x=s(u);switch(x.kind){case 0:return;case 1:{u.timeStamp-y>p3&&(o(x.target),r());break}case 2:{r();break}}},{capture:!0})}function O1(e,n,s,r){let o=Xo(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 x3(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 v3(e){return p.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function b3(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 y3(){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 w3(){return T1()?{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(Vr(d.target))try{let u=d.target.closest("a");if(!u)return;let{hash:f}=new URL(u.href),g=e.querySelector(f);Vr(g)&&!r(g)&&(c=g)}catch{}},!0),n.group(d=>{n.addEventListener(e,"touchstart",u=>{if(d.dispose(),Vr(u.target)&&EA(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(Vr(d.target)){if(u1(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 j3(){return{before({doc:e,d:n}){n.style(e.documentElement,"overflow","hidden")}}}function $j(e){let n={};for(let s of e)Object.assign(n,s(n));return n}let Ta=b3(()=>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=$j(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=$j(s.meta)),this},SCROLL_PREVENT(e){let n={doc:e.doc,d:e.d,meta(){return e.computedMeta}},s=[w3(),y3(),j3()];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)}});Ta.subscribe(()=>{let e=Ta.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)&&Ta.dispatch(s.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",s),s.count===0&&Ta.dispatch("TEARDOWN",s)}});function k3(e,n,s=()=>({containers:[]})){let r=v3(Ta),o=n?r.get(n):void 0,i=o?o.count>0:!1;return tn(()=>{if(!(!n||!e))return Ta.dispatch("PUSH",n,s),()=>Ta.dispatch("POP",n,s)},[e,n]),i}function P1(e,n,s=()=>[document.body]){let r=nd(e,"scroll-lock");k3(r,n,o=>{var i;return{containers:[...(i=o.containers)!=null?i:[],s]}})}function _j(e){return[e.screenX,e.screenY]}function N3(){let e=p.useRef([-1,-1]);return{wasMoved(n){let s=_j(n);return e.current[0]===s[0]&&e.current[1]===s[1]?!1:(e.current=s,!0)},update(n){e.current=_j(n)}}}function S3(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 C3={},Tj,Rj;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Tj=process==null?void 0:C3)==null?void 0:Tj.NODE_ENV)==="test"&&typeof((Rj=Element==null?void 0:Element.prototype)==null?void 0:Rj.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 E3=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(E3||{});function L1(e){let n={};for(let s in e)e[s]===!0&&(n[`data-${s}`]="");return n}function M1(e,n,s,r){let[o,i]=p.useState(s),{hasFlag:c,addFlag:d,removeFlag:u}=S3(e&&o?3:0),f=p.useRef(!1),g=p.useRef(!1),y=Jo();return tn(()=>{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),$3(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&&R3(n)||(f.current=!1,u(7),s||i(!1),(h=r==null?void 0:r.end)==null||h.call(r,s))}})}},[e,s,n,y]),e?[o,{closed:c(1),enter:c(2),leave:c(4),transition:c(2)||c(4)}]:[s,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function $3(e,{prepare:n,run:s,done:r,inFlight:o}){let i=$s();return T3(e,{prepare:n,inFlight:o}),i.nextFrame(()=>{s(),i.requestAnimationFrame(()=>{i.add(_3(e,r))})}),i.dispose}function _3(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 T3(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 R3(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 sv(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 wm(){return typeof window<"u"}function yl(e){return I1(e)?(e.nodeName||"").toLowerCase():"#document"}function ms(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function oo(e){var n;return(n=(I1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function I1(e){return wm()?e instanceof Node||e instanceof ms(e).Node:!1}function fs(e){return wm()?e instanceof Element||e instanceof ms(e).Element:!1}function Zo(e){return wm()?e instanceof HTMLElement||e instanceof ms(e).HTMLElement:!1}function Aj(e){return!wm()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ms(e).ShadowRoot}function jm(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 A3(e){return/^(table|td|th)$/.test(yl(e))}function km(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const O3=/transform|translate|scale|rotate|perspective|filter/,P3=/paint|layout|strict|content/,wa=e=>!!e&&e!=="none";let Xp;function rv(e){const n=fs(e)?$r(e):e;return wa(n.transform)||wa(n.translate)||wa(n.scale)||wa(n.rotate)||wa(n.perspective)||!ov()&&(wa(n.backdropFilter)||wa(n.filter))||O3.test(n.willChange||"")||P3.test(n.contain||"")}function L3(e){let n=Ia(e);for(;Zo(n)&&!zc(n);){if(rv(n))return n;if(km(n))return null;n=Ia(n)}return null}function ov(){return Xp==null&&(Xp=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Xp}function zc(e){return/^(html|body|#document)$/.test(yl(e))}function $r(e){return ms(e).getComputedStyle(e)}function Nm(e){return fs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ia(e){if(yl(e)==="html")return e;const n=e.assignedSlot||e.parentNode||Aj(e)&&e.host||oo(e);return Aj(n)?n.host:n}function z1(e){const n=Ia(e);return zc(n)?(e.ownerDocument||e).body:Zo(n)&&jm(n)?n:z1(n)}function Dc(e,n,s){var r;n===void 0&&(n=[]),s===void 0&&(s=!0);const o=z1(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),c=ms(o);if(i){const d=Wg(c);return n.concat(c,c.visualViewport||[],jm(o)?o:[],d&&s?Dc(d):[])}else return n.concat(o,Dc(o,[],s))}function Wg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function M3(){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 za=Math.min,Hs=Math.max,Fc=Math.round,Uu=Math.floor,Zr=e=>({x:e,y:e}),I3={left:"right",right:"left",bottom:"top",top:"bottom"};function z3(e,n,s){return Hs(e,za(n,s))}function wl(e,n){return typeof e=="function"?e(n):e}function Da(e){return e.split("-")[0]}function sd(e){return e.split("-")[1]}function D1(e){return e==="x"?"y":"x"}function F1(e){return e==="y"?"height":"width"}function Yr(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function U1(e){return D1(Yr(e))}function D3(e,n,s){s===void 0&&(s=!1);const r=sd(e),o=U1(e),i=F1(o);let c=o==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[i]>n.floating[i]&&(c=_f(c)),[c,_f(c)]}function F3(e){const n=_f(e);return[Hg(e),n,Hg(n)]}function Hg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Oj=["left","right"],Pj=["right","left"],U3=["top","bottom"],W3=["bottom","top"];function H3(e,n,s){switch(e){case"top":case"bottom":return s?n?Pj:Oj:n?Oj:Pj;case"left":case"right":return n?U3:W3;default:return[]}}function B3(e,n,s,r){const o=sd(e);let i=H3(Da(e),s==="start",r);return o&&(i=i.map(c=>c+"-"+o),n&&(i=i.concat(i.map(Hg)))),i}function _f(e){const n=Da(e);return I3[n]+e.slice(n.length)}function G3(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 q3(e){return typeof e!="number"?G3(e):{top:e,right:e,bottom:e,left:e}}function Tf(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 Lj(e,n,s){let{reference:r,floating:o}=e;const i=Yr(n),c=U1(n),d=F1(c),u=Da(n),f=i==="y",g=r.x+r.width/2-o.width/2,y=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};break;case"left":h={x:r.x-o.width,y};break;default:h={x:r.x,y:r.y}}const v=sd(n);return v&&(h[c]+=x*(v==="end"?1:-1)*(s&&f?-1:1)),h}async function W1(e,n){var s;n===void 0&&(n={});const{x:r,y:o,platform:i,rects:c,elements:d,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:x=!1,padding:h=0}=wl(n,e),v=q3(h),j=d[x?y==="floating"?"reference":"floating":y],k=Tf(await i.getClippingRect({element:(s=await(i.isElement==null?void 0:i.isElement(j)))==null||s?j:j.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(d.floating)),boundary:f,rootBoundary:g,strategy:u})),E=y==="floating"?{x:r,y:o,width:c.floating.width,height:c.floating.height}:c.reference,S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d.floating)),N=await(i.isElement==null?void 0:i.isElement(S))&&await(i.getScale==null?void 0:i.getScale(S))||{x:1,y:1},$=Tf(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 K3=50,V3=async(e,n,s)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:c}=s,d=c.detectOverflow?c:{...c,detectOverflow:W1},u=await(c.isRTL==null?void 0:c.isRTL(n));let f=await c.getElementRects({reference:e,floating:n,strategy:o}),{x:g,y}=Lj(f,r,u),x=r,h=0;const v={};for(let b=0;b<i.length;b++){const j=i[b];if(!j)continue;const{name:k,fn:E}=j,{x:S,y:N,data:$,reset:_}=await E({x:g,y,initialPlacement:r,placement:x,strategy:o,middlewareData:v,rects:f,platform:d,elements:{reference:e,floating:n}});g=S??g,y=N??y,v[k]={...v[k],...$},_&&h<K3&&(h++,typeof _=="object"&&(_.placement&&(x=_.placement),_.rects&&(f=_.rects===!0?await c.getElementRects({reference:e,floating:n,strategy:o}):_.rects),{x:g,y}=Lj(f,x,u)),b=-1)}return{x:g,y,placement:x,strategy:o,middlewareData:v}},Y3=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,r;const{placement:o,middlewareData:i,rects:c,initialPlacement:d,platform:u,elements:f}=n,{mainAxis:g=!0,crossAxis:y=!0,fallbackPlacements:x,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:b=!0,...j}=wl(e,n);if((s=i.arrow)!=null&&s.alignmentOffset)return{};const k=Da(o),E=Yr(d),S=Da(d)===d,N=await(u.isRTL==null?void 0:u.isRTL(f.floating)),$=x||(S||!b?[_f(d)]:F3(d)),_=v!=="none";!x&&_&&$.push(...B3(d,b,v,N));const P=[d,...$],O=await u.detectOverflow(n,j),M=[];let R=((r=i.flip)==null?void 0:r.overflows)||[];if(g&&M.push(O[k]),y){const W=D3(o,c,N);M.push(O[W[0]],O[W[1]])}if(R=[...R,{placement:o,overflows:M}],!M.every(W=>W<=0)){var A,L;const W=(((A=i.flip)==null?void 0:A.index)||0)+1,q=P[W];if(q&&(!(y==="alignment"?E!==Yr(q):!1)||R.every(U=>Yr(U.placement)===E?U.overflows[0]>0:!0)))return{data:{index:W,overflows:R},reset:{placement:q}};let H=(L=R.filter(K=>K.overflows[0]<=0).sort((K,U)=>K.overflows[1]-U.overflows[1])[0])==null?void 0:L.placement;if(!H)switch(h){case"bestFit":{var D;const K=(D=R.filter(U=>{if(_){const G=Yr(U.placement);return G===E||G==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(G=>G>0).reduce((G,F)=>G+F,0)]).sort((U,G)=>U[1]-G[1])[0])==null?void 0:D[0];K&&(H=K);break}case"initialPlacement":H=d;break}if(o!==H)return{reset:{placement:H}}}return{}}}},Q3=new Set(["left","top"]);async function J3(e,n){const{placement:s,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),c=Da(s),d=sd(s),u=Yr(s)==="y",f=Q3.has(c)?-1:1,g=i&&u?-1:1,y=wl(n,e);let{mainAxis:x,crossAxis:h,alignmentAxis:v}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.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 X3=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 J3(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}}}}},Z3=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},y=await i.detectOverflow(n,f),x=Yr(o),h=D1(x);let v=g[h],b=g[x];const j=(E,S)=>z3(S+y[E==="y"?"top":"left"],S,S-y[E==="y"?"bottom":"right"]);c&&(v=j(h,v)),d&&(b=j(x,b));const k=u.fn({...n,[h]:v,[x]:b});return{...k,data:{x:k.x-s,y:k.y-r,enabled:{[h]:c,[x]:d}}}}}},e4=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=Da(s),g=sd(s),y=Yr(s)==="y",{width:x,height:h}=r.floating;let v,b;f==="top"||f==="bottom"?(v=f,b=g===(await(o.isRTL==null?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(b=f,v=g==="end"?"top":"bottom");const j=h-u.top-u.bottom,k=x-u.left-u.right,E=za(h-u[v],j),S=za(x-u[b],k),N=n.middlewareData.shift,$=!N;let _=E,P=S;N!=null&&N.enabled.x&&(P=k),N!=null&&N.enabled.y&&(_=j),$&&!g&&(y?P=x-2*Hs(u.left,u.right):_=h-2*Hs(u.top,u.bottom)),await c({...n,availableWidth:P,availableHeight:_});const O=await o.getDimensions(i.floating);return x!==O.width||h!==O.height?{reset:{rects:!0}}:{}}}};function H1(e){const n=$r(e);let s=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const o=Zo(e),i=o?e.offsetWidth:s,c=o?e.offsetHeight:r,d=Fc(s)!==i||Fc(r)!==c;return d&&(s=i,r=c),{width:s,height:r,$:d}}function av(e){return fs(e)?e:e.contextElement}function Ki(e){const n=av(e);if(!Zo(n))return Zr(1);const s=n.getBoundingClientRect(),{width:r,height:o,$:i}=H1(n);let c=(i?Fc(s.width):s.width)/r,d=(i?Fc(s.height):s.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const t4=Zr(0);function B1(e){const n=ms(e);return!ov()||!n.visualViewport?t4:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function n4(e,n,s){return n===void 0&&(n=!1),!!s&&n&&s===ms(e)}function Fa(e,n,s,r){n===void 0&&(n=!1),s===void 0&&(s=!1);const o=e.getBoundingClientRect(),i=av(e);let c=Zr(1);n&&(r?fs(r)&&(c=Ki(r)):c=Ki(e));const d=n4(i,s,r)?B1(i):Zr(0);let u=(o.left+d.x)/c.x,f=(o.top+d.y)/c.y,g=o.width/c.x,y=o.height/c.y;if(i&&r){const x=ms(i),h=fs(r)?ms(r):r;let v=x,b=Wg(v);for(;b&&h!==v;){const j=Ki(b),k=b.getBoundingClientRect(),E=$r(b),S=k.left+(b.clientLeft+parseFloat(E.paddingLeft))*j.x,N=k.top+(b.clientTop+parseFloat(E.paddingTop))*j.y;u*=j.x,f*=j.y,g*=j.x,y*=j.y,u+=S,f+=N,v=ms(b),b=Wg(v)}}return Tf({width:g,height:y,x:u,y:f})}function Sm(e,n){const s=Nm(e).scrollLeft;return n?n.left+s:Fa(oo(e)).left+s}function G1(e,n){const s=e.getBoundingClientRect(),r=s.left+n.scrollLeft-Sm(e,s),o=s.top+n.scrollTop;return{x:r,y:o}}function s4(e){let{elements:n,rect:s,offsetParent:r,strategy:o}=e;const i=o==="fixed",c=oo(r),d=n?km(n.floating):!1;if(r===c||d&&i)return s;let u={scrollLeft:0,scrollTop:0},f=Zr(1);const g=Zr(0),y=Zo(r);if((y||!i)&&((yl(r)!=="body"||jm(c))&&(u=Nm(r)),y)){const h=Fa(r);f=Ki(r),g.x=h.x+r.clientLeft,g.y=h.y+r.clientTop}const x=c&&!y&&!i?G1(c,u):Zr(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 r4(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function o4(e){const n=Nm(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+Sm(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 a4=25;function i4(e,n,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",o=ms(e),i=oo(e),c=o.visualViewport;let d=i.clientWidth,u=i.clientHeight,f=0,g=0;if(c){const x=!ov()||n==="fixed";r?x||(f=-c.offsetLeft,g=-c.offsetTop):(d=c.width,u=c.height,x&&(f=c.offsetLeft,g=c.offsetTop))}if(Sm(i)<=0){const x=i.ownerDocument,h=x.body,v=getComputedStyle(h),b=x.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,j=Math.abs(i.clientWidth-h.clientWidth-b),k=getComputedStyle(i).scrollbarGutter==="stable both-edges"?j/2:j;k<=a4&&(d-=k)}return{width:d,height:u,x:f,y:g}}function l4(e,n){const s=Fa(e,!0,n==="fixed"),r=s.top+e.clientTop,o=s.left+e.clientLeft,i=Ki(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 Mj(e,n,s){let r;if(n==="viewport"||n==="layoutViewport")r=i4(e,s,n);else if(n==="document")r=o4(oo(e));else if(fs(n))r=l4(n,s);else{const o=B1(e);r={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return Tf(r)}function c4(e,n){const s=n.get(e);if(s)return s;let r=Dc(e,[],!1).filter(d=>fs(d)&&yl(d)!=="body"),o=null;const i=$r(e).position==="fixed";let c=i?Ia(e):e;for(;fs(c)&&!zc(c);){const d=$r(c),u=rv(c),f=o?o.position:i?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&d.position==="static")?r=r.filter(y=>y!==c):o=d,c=Ia(c)}return n.set(e,r),r}function d4(e){let{element:n,boundary:s,rootBoundary:r,strategy:o}=e;const c=[...s==="clippingAncestors"?km(n)?[]:c4(n,this._c):[].concat(s),r],d=Mj(n,c[0],o);let u=d.top,f=d.right,g=d.bottom,y=d.left;for(let x=1;x<c.length;x++){const h=Mj(n,c[x],o);u=Hs(h.top,u),f=za(h.right,f),g=za(h.bottom,g),y=Hs(h.left,y)}return{width:f-y,height:g-u,x:y,y:u}}function u4(e){const{width:n,height:s}=H1(e);return{width:n,height:s}}function f4(e,n,s){const r=Zo(n),o=oo(n),i=s==="fixed",c=Fa(e,!0,i,n);let d={scrollLeft:0,scrollTop:0};const u=Zr(0);if((r||!i)&&((yl(n)!=="body"||jm(o))&&(d=Nm(n)),r)){const x=Fa(n,!0,i,n);u.x=x.x+n.clientLeft,u.y=x.y+n.clientTop}!r&&o&&(u.x=Sm(o));const f=o&&!r&&!i?G1(o,d):Zr(0),g=c.left+d.scrollLeft-u.x-f.x,y=c.top+d.scrollTop-u.y-f.y;return{x:g,y,width:c.width,height:c.height}}function Zp(e){return $r(e).position==="static"}function Ij(e,n){if(!Zo(e)||$r(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return oo(e)===s&&(s=s.ownerDocument.body),s}function q1(e,n){const s=ms(e);if(km(e))return s;if(!Zo(e)){let o=Ia(e);for(;o&&!zc(o);){if(fs(o)&&!Zp(o))return o;o=Ia(o)}return s}let r=Ij(e,n);for(;r&&A3(r)&&Zp(r);)r=Ij(r,n);return r&&zc(r)&&Zp(r)&&!rv(r)?s:r||L3(e)||s}const m4=async function(e){const n=this.getOffsetParent||q1,s=this.getDimensions,r=await s(e.floating);return{reference:f4(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function h4(e){return $r(e).direction==="rtl"}const p4={convertOffsetParentRelativeRectToViewportRelativeRect:s4,getDocumentElement:oo,getClippingRect:d4,getOffsetParent:q1,getElementRects:m4,getClientRects:r4,getDimensions:u4,getScale:Ki,isElement:fs,isRTL:h4};function K1(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function g4(e,n,s){let r=null,o;const i=oo(e);function c(){var g;clearTimeout(o),(g=r)==null||g.disconnect(),r=null}function d(g,y){g===void 0&&(g=!1),y===void 0&&(y=1),c();const x=e.getBoundingClientRect(),{left:h,top:v,width:b,height:j}=x;if(g||n(),!b||!j)return;const k=Uu(v),E=Uu(i.clientWidth-(h+b)),S=Uu(i.clientHeight-(v+j)),N=Uu(h),_={rootMargin:-k+"px "+-E+"px "+-S+"px "+-N+"px",threshold:Hs(0,za(1,y))||1};let P=!0;function O(M){const R=M[0].intersectionRatio;if(!K1(x,e.getBoundingClientRect()))return d();if(R!==y){if(!P)return d();R?d(!1,R):o=setTimeout(()=>{d(!1,1e-7)},1e3)}P=!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 x4(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=av(e),g=o||i?[...f?Dc(f):[],...n?Dc(n):[]]:[];g.forEach(k=>{o&&k.addEventListener("scroll",s),i&&k.addEventListener("resize",s)});const y=f&&d?g4(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,b=u?Fa(e):null;u&&j();function j(){const k=Fa(e);b&&!K1(b,k)&&s(),b=k,v=requestAnimationFrame(j)}return s(),()=>{var k;g.forEach(E=>{o&&E.removeEventListener("scroll",s),i&&E.removeEventListener("resize",s)}),y==null||y(),(k=h)==null||k.disconnect(),h=null,u&&cancelAnimationFrame(v)}}const eg=W1,v4=X3,b4=Z3,y4=Y3,w4=e4,j4=(e,n,s)=>{const r=new Map,o=s??{},i={...p4,...o.platform,_c:r};return V3(e,n,{...o,platform:i})};var k4=typeof document<"u",N4=function(){},ff=k4?p.useLayoutEffect:N4;function Rf(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(!Rf(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)&&!Rf(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}function V1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function zj(e,n){const s=V1(e);return Math.round(n*s)/s}function tg(e){const n=p.useRef(e);return ff(()=>{n.current=e}),n}function S4(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:c}={},transform:d=!0,whileElementsMounted:u,open:f}=e,[g,y]=p.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[x,h]=p.useState(r);Rf(x,r)||h(r);const[v,b]=p.useState(null),[j,k]=p.useState(null),E=p.useCallback(U=>{U!==_.current&&(_.current=U,b(U))},[]),S=p.useCallback(U=>{U!==P.current&&(P.current=U,k(U))},[]),N=i||v,$=c||j,_=p.useRef(null),P=p.useRef(null),O=p.useRef(g),M=u!=null,R=tg(u),A=tg(o),L=tg(f),D=p.useCallback(()=>{if(!_.current||!P.current)return;const U={placement:n,strategy:s,middleware:x};A.current&&(U.platform=A.current),j4(_.current,P.current,U).then(G=>{const F={...G,isPositioned:L.current!==!1};W.current&&!Rf(O.current,F)&&(O.current=F,Ns.flushSync(()=>{y(F)}))})},[x,n,s,A,L]);ff(()=>{f===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,y(U=>({...U,isPositioned:!1})))},[f]);const W=p.useRef(!1);ff(()=>(W.current=!0,()=>{W.current=!1}),[]),ff(()=>{if(N&&(_.current=N),$&&(P.current=$),N&&$){if(R.current)return R.current(N,$,D);D()}},[N,$,D,R,M]);const q=p.useMemo(()=>({reference:_,floating:P,setReference:E,setFloating:S}),[E,S]),H=p.useMemo(()=>({reference:N,floating:$}),[N,$]),K=p.useMemo(()=>{const U={position:s,left:0,top:0};if(!H.floating)return U;const G=zj(H.floating,g.x),F=zj(H.floating,g.y);return d?{...U,transform:"translate("+G+"px, "+F+"px)",...V1(H.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:G,top:F}},[s,d,H.floating,g.x,g.y]);return p.useMemo(()=>({...g,update:D,refs:q,elements:H,floatingStyles:K}),[g,D,q,H,K])}const Y1=(e,n)=>{const s=v4(e);return{name:s.name,fn:s.fn,options:[e,n]}},C4=(e,n)=>{const s=b4(e);return{name:s.name,fn:s.fn,options:[e,n]}},E4=(e,n)=>{const s=y4(e);return{name:s.name,fn:s.fn,options:[e,n]}},$4=(e,n)=>{const s=w4(e);return{name:s.name,fn:s.fn,options:[e,n]}},Q1={...Ag},_4=Q1.useInsertionEffect,T4=_4||(e=>e());function J1(e){const n=p.useRef(()=>{});return T4(()=>{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 Bg=typeof document<"u"?p.useLayoutEffect:p.useEffect;let Dj=!1,R4=0;const Fj=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+R4++;function A4(){const[e,n]=p.useState(()=>Dj?Fj():void 0);return Bg(()=>{e==null&&n(Fj())},[]),p.useEffect(()=>{Dj=!0},[]),e}const O4=Q1.useId,P4=O4||A4;function L4(){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 M4=p.createContext(null),I4=p.createContext(null),z4=()=>{var e;return((e=p.useContext(M4))==null?void 0:e.id)||null},D4=()=>p.useContext(I4),F4="data-floating-ui-focusable";function U4(e){const{open:n=!1,onOpenChange:s,elements:r}=e,o=P4(),i=p.useRef({}),[c]=p.useState(()=>L4()),d=z4()!=null,[u,f]=p.useState(r.reference),g=J1((h,v,b)=>{i.current.openEvent=h?v:void 0,c.emit("openchange",{open:h,event:v,reason:b,nested:d}),s==null||s(h,v,b)}),y=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:y}),[n,g,x,c,o,y])}function W4(e){e===void 0&&(e={});const{nodeId:n}=e,s=U4({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||s,o=r.elements,[i,c]=p.useState(null),[d,u]=p.useState(null),g=(o==null?void 0:o.domReference)||i,y=p.useRef(null),x=D4();Bg(()=>{g&&(y.current=g)},[g]);const h=S4({...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]),b=p.useCallback(S=>{(fs(S)||S===null)&&(y.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:b,setPositionReference:v,domReference:y}),[h.refs,b,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 Bg(()=>{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 Uj="active",Wj="selected";function ng(e,n,s){const r=new Map,o=s==="item";let i=e;if(o&&e){const{[Uj]:c,[Wj]:d,...u}=e;i=u}return{...s==="floating"&&{tabIndex:-1,[F4]:""},...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&&[Uj,Wj].includes(f)))if(f.indexOf("on")===0){if(r.has(f)||r.set(f,[]),typeof g=="function"){var y;(y=r.get(f))==null||y.push(g),c[f]=function(){for(var x,h=arguments.length,v=new Array(h),b=0;b<h;b++)v[b]=arguments[b];return(x=r.get(f))==null?void 0:x.map(j=>j(...v)).find(j=>j!==void 0)}}}else c[f]=g}),c),{})}}function H4(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=>ng(d,e,"reference"),n),i=p.useCallback(d=>ng(d,e,"floating"),s),c=p.useCallback(d=>ng(d,e,"item"),r);return p.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:c}),[o,i,c])}function Hj(e,n){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:n}}}}const B4=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:y,elements:{floating:x}}=n,h=s.current[c],v=(f==null?void 0:f.current)||x,b=x.clientTop||v.clientTop,j=x.clientTop!==0,k=v.clientTop!==0,E=x===v;if(!h)return{};const S={...n,...await Y1(-h.offsetTop-x.clientTop-y.reference.height/2-h.offsetHeight/2-i).fn(n)},N=await eg(Hj(S,v.scrollHeight+b+x.clientTop),g),$=await eg(S,{...g,elementContext:"reference"}),_=Hs(0,N.top),P=S.y+_,R=(v.scrollHeight>v.clientHeight?A=>A:Fc)(Hs(0,v.scrollHeight+(j&&E||k?b*2:0)-_-Hs(0,N.bottom)));if(v.style.maxHeight=R+"px",v.scrollTop=_,o){const A=v.offsetHeight<h.offsetHeight*za(d,s.current.length)-1||$.top>=-u||$.bottom>=-u;Ns.flushSync(()=>o(A))}return r&&(r.current=await eg(Hj({...S,y:P},v.offsetHeight+b+x.clientTop),g)),{y:P}}});function G4(e,n){const{open:s,elements:r}=e,{enabled:o=!0,overflowRef:i,scrollRef:c,onChange:d}=n,u=J1(d),f=p.useRef(!1),g=p.useRef(null),y=p.useRef(null);p.useEffect(()=>{if(!o)return;function h(b){if(b.ctrlKey||!v||i.current==null)return;const j=b.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?(b.preventDefault(),Ns.flushSync(()=>{u(_=>_+Math[$](j,S*N))})):/firefox/i.test(M3())&&(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&&(y.current={...i.current})}),()=>{g.current=null,y.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(b=>b+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 iv=p.createContext(null);iv.displayName="PlacementContext";function q4(e){return p.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function K4(){return p.useContext(jl).setReference}function V4(){return p.useContext(jl).getReferenceProps}function Y4(){let{getFloatingProps:e,slot:n}=p.useContext(jl);return p.useCallback((...s)=>Object.assign({},e(...s),{"data-anchor":n.anchor}),[e,n])}function Q4(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let n=p.useContext(iv),s=p.useMemo(()=>e,[JSON.stringify(e,(o,i)=>{var c;return(c=i==null?void 0:i.outerHTML)!=null?c:i})]);tn(()=>{n==null||n(s??null)},[n,s]);let r=p.useContext(jl);return p.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let Bj=4;function J4({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);X4(d);let f=n&&s!==null&&d!==null,{to:g="bottom",gap:y=0,offset:x=0,padding:h=0,inner:v}=Z4(s,d),[b,j="center"]=g.split(" ");tn(()=>{f&&i(0)},[f]);let{refs:k,floatingStyles:E,context:S}=W4({open:f,placement:b==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${b}`:`${b}-${j}`,strategy:"absolute",transform:!1,middleware:[Y1({mainAxis:b==="selection"?0:y,crossAxis:x}),C4({padding:h}),b!=="selection"&&E4({padding:h}),b==="selection"&&v?B4({...v,padding:h,overflowRef:c,offset:o,minItemsVisible:Bj,referenceOverflowThreshold:h,onFallbackChange(A){var L,D;if(!A)return;let W=S.elements.floating;if(!W)return;let q=parseFloat(getComputedStyle(W).scrollPaddingBottom)||0,H=Math.min(Bj,W.childElementCount),K=0,U=0;for(let G of(D=(L=S.elements.floating)==null?void 0:L.childNodes)!=null?D:[])if(Ss(G)){let F=G.offsetTop,z=F+G.clientHeight+q,Y=W.scrollTop,se=Y+W.clientHeight;if(F>=Y&&z<=se)H--;else{U=Math.max(0,Math.min(z,se)-Math.max(F,Y)),K=G.clientHeight;break}}H>=1&&i(G=>{let F=K*H-U+q;return G>=F?G:F})}}):null,$4({padding:h,apply({availableWidth:A,availableHeight:L,elements:D}){Object.assign(D.floating.style,{overflow:"auto",maxWidth:`${A}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${L}px)`})}})].filter(Boolean),whileElementsMounted:x4}),[N=b,$=j]=S.placement.split("-");b==="selection"&&(N="selection");let _=p.useMemo(()=>({anchor:[N,$].filter(Boolean).join(" ")}),[N,$]),P=G4(S,{overflowRef:c,onChange:i}),{getReferenceProps:O,getFloatingProps:M}=H4([P]),R=ut(A=>{u(A),k.setFloating(A)});return p.createElement(iv.Provider,{value:r},p.createElement(jl.Provider,{value:{setFloating:R,setReference:k.setReference,styles:E,getReferenceProps:O,getFloatingProps:M,slot:_}},e))}function X4(e){tn(()=>{if(!e)return;let n=new MutationObserver(()=>{let s=window.getComputedStyle(e).maxHeight,r=parseFloat(s);if(isNaN(r))return;let o=parseInt(s);isNaN(o)||r!==o&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return n.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{n.disconnect()}},[e])}function Z4(e,n){var s,r,o;let i=sg((s=e==null?void 0:e.gap)!=null?s:"var(--anchor-gap, 0)",n),c=sg((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",n),d=sg((o=e==null?void 0:e.padding)!=null?o:"var(--anchor-padding, 0)",n);return{...e,gap:i,offset:c,padding:d}}function sg(e,n,s=void 0){let r=Jo(),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=Gj(u,f);return[g,y=>{let x=X1(u);{let h=x.map(v=>window.getComputedStyle(f).getPropertyValue(v));r.requestAnimationFrame(function v(){r.nextFrame(v);let b=!1;for(let[k,E]of x.entries()){let S=window.getComputedStyle(f).getPropertyValue(E);if(h[k]!==S){h[k]=S,b=!0;break}}if(!b)return;let j=Gj(u,f);g!==j&&(y(j),g=j)})}return r.dispose}]}return[s,null]}),i=p.useMemo(()=>o(e,n)[0],[e,n]),[c=i,d]=p.useState();return tn(()=>{let[u,f]=o(e,n);if(d(u),!!f)return f(d)},[e,n]),c}function X1(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,...X1(o)]:[r]}return[]}function Gj(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 eO({children:e,freeze:n},s){let r=Z1(n,e);return p.isValidElement(r)?p.cloneElement(r,{ref:s}):Ke.createElement(Ke.Fragment,null,r)}Ke.forwardRef(eO);function Z1(e,n){let[s,r]=p.useState(n);return!e&&s!==n&&r(n),e?s:n}let Cm=p.createContext(null);Cm.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 rd(){return p.useContext(Cm)}function eS({value:e,children:n}){return Ke.createElement(Cm.Provider,{value:e},n)}function tO({children:e}){return Ke.createElement(Cm.Provider,{value:null},e)}function nO(e){function n(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",n))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",n),n())}let Lo=[];nO(()=>{function e(n){if(!Vr(n.target)||n.target===document.body||Lo[0]===n.target)return;let s=n.target;s=s.closest($f),Lo.unshift(s??n.target),Lo=Lo.filter(r=>r!=null&&r.isConnected),Lo.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function sO(e){throw new Error("Unexpected object: "+e)}var on=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(on||{});function Wu(e,n){let s=n.resolveItems();if(s.length<=0)return null;let r=n.resolveActiveIndex(),o=r??-1;switch(e.focus){case 0:{for(let i=0;i<s.length;++i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 1:{o===-1&&(o=s.length);for(let i=o-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 2:{for(let i=o+1;i<s.length;++i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 3:{for(let i=s.length-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 4:{for(let i=0;i<s.length;++i)if(n.resolveId(s[i],i,s)===e.id)return i;return r}case 5:return null;default:sO(e)}}function lv(e){let n=ut(e),s=p.useRef(!1);p.useEffect(()=>(s.current=!1,()=>{s.current=!0,xm(()=>{s.current&&n()})}),[n])}function rO(){let e=typeof document>"u";return"useSyncExternalStore"in Ag?(n=>n.useSyncExternalStore)(Ag)(()=>()=>{},()=>!1,()=>!e):!1}function od(){let e=rO(),[n,s]=p.useState(Sr.isHandoffComplete);return n&&Sr.isHandoffComplete===!1&&s(!1),p.useEffect(()=>{n!==!0&&s(!0)},[n]),p.useEffect(()=>Sr.handoff(),[]),e?!1:n}let tS=p.createContext(!1);function oO(){return p.useContext(tS)}function qj(e){return Ke.createElement(tS.Provider,{value:e.force},e.children)}function aO(e){let n=oO(),s=p.useContext(sS),[r,o]=p.useState(()=>{var i;if(!n&&s!==null)return(i=s.current)!=null?i:null;if(Sr.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 nS=p.Fragment,iO=xn(function(e,n){let{ownerDocument:s=null,...r}=e,o=p.useRef(null),i=Fn(AA(h=>{o.current=h}),n),c=Ic(o.current),d=s??c,u=aO(d),f=p.useContext(Gg),g=Jo(),y=od(),x=En();return lv(()=>{var h;u&&u.childNodes.length<=0&&((h=u.parentElement)==null||h.removeChild(u))}),!u||!y?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:nS,name:"Portal"})),u)});function lO(e,n){let s=Fn(n),{enabled:r=!0,ownerDocument:o,...i}=e,c=En();return r?Ke.createElement(iO,{...i,ownerDocument:o,ref:s}):c({ourProps:{ref:s},theirProps:i,slot:{},defaultTag:nS,name:"Portal"})}let cO=p.Fragment,sS=p.createContext(null);function dO(e,n){let{target:s,...r}=e,o={ref:Fn(n)},i=En();return Ke.createElement(sS.Provider,{value:s},i({ourProps:o,theirProps:r,defaultTag:cO,name:"Popover.Group"}))}let Gg=p.createContext(null);function uO(){let e=p.useContext(Gg),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(Gg.Provider,{value:o},i)},[o])]}let fO=xn(lO),rS=xn(dO),oS=Object.assign(fO,{Group:rS});const mf={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function aS(e){let n=e.getBoundingClientRect();return`${n.x},${n.y}`}function mO(e,n,s){let r=$s();if(n.kind==="Tracked"){let o=function(){i!==aS(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 hO(e,n=typeof document<"u"?document.defaultView:null,s){let r=nd(e,"escape");O1(n,"keydown",o=>{r&&(o.defaultPrevented||o.key===yn.Escape&&s(o))})}function pO(){var e;let[n]=p.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[s,r]=p.useState((e=n==null?void 0:n.matches)!=null?e:!1);return tn(()=>{if(!n)return;function o(i){r(i.matches)}return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[n]),s}function gO({defaultContainers:e=[],portals:n,mainTreeNode:s}={}){let r=ut(()=>{var o,i;let c=bl(s),d=[];for(let u of e)u!==null&&(Jr(u)?d.push(u):"current"in u&&Jr(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&&Jr(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 iS=p.createContext(null);function Kj({children:e,node:n}){let[s,r]=p.useState(null),o=lS(n??s);return Ke.createElement(iS.Provider,{value:o},e,o===null&&Ke.createElement(Mc,{features:al.Hidden,ref:i=>{var c,d;if(i){for(let u of(d=(c=bl(i))==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?d:[])if(u!==document.body&&u!==document.head&&Jr(u)&&u!=null&&u.contains(i)){r(u);break}}}}))}function lS(e=null){var n;return(n=p.useContext(iS))!=null?n:e}function cv(){let e=p.useRef(!1);return tn(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Nc=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(Nc||{});function xO(){let e=p.useRef(0);return R1(!0,"keydown",n=>{n.key==="Tab"&&(e.current=n.shiftKey?1:0)},!0),e}function cS(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let n=new Set;for(let s of e.current)Jr(s.current)&&n.add(s.current);return n}let vO="div";var Na=(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))(Na||{});function bO(e,n){let s=p.useRef(null),r=Fn(s,n),{initialFocus:o,initialFocusFallback:i,containers:c,features:d=15,...u}=e;od()||(d=0);let f=Ic(s.current);kO(d,{ownerDocument:f});let g=NO(d,{ownerDocument:f,container:s,initialFocus:o,initialFocusFallback:i});SO(d,{ownerDocument:f,container:s,containers:c,previousActiveElement:g});let y=xO(),x=ut(E=>{if(!Ss(s.current))return;let S=s.current;(N=>N())(()=>{ts(y.current,{[Nc.Forwards]:()=>{qi(S,lr.First,{skipElements:[E.relatedTarget,i]})},[Nc.Backwards]:()=>{qi(S,lr.Last,{skipElements:[E.relatedTarget,i]})}})})}),h=nd(!!(d&2),"focus-trap#tab-lock"),v=Jo(),b=p.useRef(!1),j={ref:r,onKeyDown(E){E.key=="Tab"&&(b.current=!0,v.requestAnimationFrame(()=>{b.current=!1}))},onBlur(E){if(!(d&4))return;let S=cS(c);Ss(s.current)&&S.add(s.current);let N=E.relatedTarget;Vr(N)&&N.dataset.headlessuiFocusGuard!=="true"&&(dS(S,N)||(b.current?qi(s.current,ts(y.current,{[Nc.Forwards]:()=>lr.Next,[Nc.Backwards]:()=>lr.Previous})|lr.WrapAround,{relativeTo:E.target}):Vr(E.target)&&Xr(E.target)))}},k=En();return Ke.createElement(Ke.Fragment,null,h&&Ke.createElement(Mc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:x,features:al.Focusable}),k({ourProps:j,theirProps:u,defaultTag:vO,name:"FocusTrap"}),h&&Ke.createElement(Mc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:x,features:al.Focusable}))}let yO=xn(bO),wO=Object.assign(yO,{features:Na});function jO(e=!0){let n=p.useRef(Lo.slice());return sv(([s],[r])=>{r===!0&&s===!1&&xm(()=>{n.current.splice(0)}),r===!1&&s===!0&&(n.current=Lo.slice())},[e,Lo,n]),ut(()=>{var s;return(s=n.current.find(r=>r!=null&&r.isConnected))!=null?s:null})}function kO(e,{ownerDocument:n}){let s=!!(e&8),r=jO(s);sv(()=>{s||n1(n==null?void 0:n.body)&&Xr(r())},[s]),lv(()=>{s&&Xr(r())})}function NO(e,{ownerDocument:n,container:s,initialFocus:r,initialFocusFallback:o}){let i=p.useRef(null),c=nd(!!(e&1),"focus-trap#initial-focus"),d=cv();return sv(()=>{if(e===0)return;if(!c){o!=null&&o.current&&Xr(o.current);return}let u=s.current;u&&xm(()=>{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)Xr(r.current);else{if(e&16){if(qi(u,lr.First|lr.AutoFocus)!==Ug.Error)return}else if(qi(u,lr.First)!==Ug.Error)return;if(o!=null&&o.current&&(Xr(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 SO(e,{ownerDocument:n,container:s,containers:r,previousActiveElement:o}){let i=cv(),c=!!(e&4);O1(n==null?void 0:n.defaultView,"focus",d=>{if(!c||!i.current)return;let u=cS(r);Ss(s.current)&&u.add(s.current);let f=o.current;if(!f)return;let g=d.target;Ss(g)?dS(u,g)?(o.current=g,Xr(g)):(d.preventDefault(),d.stopPropagation(),Xr(f)):Xr(o.current)},!0)}function dS(e,n){for(let s of e)if(s.contains(n))return!0;return!1}function uS(e){var n;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!$c((n=e.as)!=null?n:mS)||Ke.Children.count(e.children)===1}let Em=p.createContext(null);Em.displayName="TransitionContext";var CO=(e=>(e.Visible="visible",e.Hidden="hidden",e))(CO||{});function EO(){let e=p.useContext(Em);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function $O(){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}let $m=p.createContext(null);$m.displayName="NestingContext";function _m(e){return"children"in e?_m(e.children):e.current.filter(({el:n})=>n.current!==null).filter(({state:n})=>n==="visible").length>0}function fS(e,n){let s=Xo(e),r=p.useRef([]),o=cv(),i=Jo(),c=ut((h,v=Mo.Hidden)=>{let b=r.current.findIndex(({el:j})=>j===h);b!==-1&&(ts(v,{[Mo.Unmount](){r.current.splice(b,1)},[Mo.Hidden](){r.current[b].state="hidden"}}),i.microTask(()=>{var j;!_m(r)&&o.current&&((j=s.current)==null||j.call(s))}))}),d=ut(h=>{let v=r.current.find(({el:b})=>b===h);return v?v.state!=="visible"&&(v.state="visible"):r.current.push({el:h,state:"visible"}),()=>c(h,Mo.Unmount)}),u=p.useRef([]),f=p.useRef(Promise.resolve()),g=p.useRef({enter:[],leave:[]}),y=ut((h,v,b)=>{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(()=>b(v)):b(v)}),x=ut((h,v,b)=>{Promise.all(g.current[v].splice(0).map(([j,k])=>k)).then(()=>{var j;(j=u.current.shift())==null||j()}).then(()=>b(v))});return p.useMemo(()=>({children:r,register:d,unregister:c,onStart:y,onStop:x,wait:f,chains:g}),[d,c,r,y,x,g,f])}let mS=p.Fragment,hS=ol.RenderStrategy;function _O(e,n){var s,r;let{transition:o=!0,beforeEnter:i,afterEnter:c,beforeLeave:d,afterLeave:u,enter:f,enterFrom:g,enterTo:y,entered:x,leave:h,leaveFrom:v,leaveTo:b,...j}=e,[k,E]=p.useState(null),S=p.useRef(null),N=uS(e),$=Fn(...N?[S,n,E]:n===null?[]:[n]),_=(s=j.unmount)==null||s?Mo.Unmount:Mo.Hidden,{show:P,appear:O,initial:M}=EO(),[R,A]=p.useState(P?"visible":"hidden"),L=$O(),{register:D,unregister:W}=L;tn(()=>D(S),[D,S]),tn(()=>{if(_===Mo.Hidden&&S.current){if(P&&R!=="visible"){A("visible");return}return ts(R,{hidden:()=>W(S),visible:()=>D(S)})}},[R,S,D,W,P,_]);let q=od();tn(()=>{if(N&&q&&R==="visible"&&S.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[S,R,q,N]);let H=M&&!O,K=O&&P&&M,U=p.useRef(!1),G=fS(()=>{U.current||(A("hidden"),W(S))},L),F=ut(he=>{U.current=!0;let ge=he?"enter":"leave";G.onStart(S,ge,ye=>{ye==="enter"?i==null||i():ye==="leave"&&(d==null||d())})}),z=ut(he=>{let ge=he?"enter":"leave";U.current=!1,G.onStop(S,ge,ye=>{ye==="enter"?c==null||c():ye==="leave"&&(u==null||u())}),ge==="leave"&&!_m(G)&&(A("hidden"),W(S))});p.useEffect(()=>{N&&o||(F(P),z(P))},[P,N,o]);let Y=!(!o||!N||!q||H),[,se]=M1(Y,k,P,{start:F,end:z}),Q=Po({ref:$,className:((r=Dg(j.className,K&&f,K&&g,se.enter&&f,se.enter&&se.closed&&g,se.enter&&!se.closed&&y,se.leave&&h,se.leave&&!se.closed&&v,se.leave&&se.closed&&b,!se.transition&&P&&x))==null?void 0:r.trim())||void 0,...L1(se)}),re=0;R==="visible"&&(re|=Xn.Open),R==="hidden"&&(re|=Xn.Closed),P&&R==="hidden"&&(re|=Xn.Opening),!P&&R==="visible"&&(re|=Xn.Closing);let te=En();return Ke.createElement($m.Provider,{value:G},Ke.createElement(eS,{value:re},te({ourProps:Q,theirProps:j,defaultTag:mS,features:hS,visible:R==="visible",name:"Transition.Child"})))}function TO(e,n){let{show:s,appear:r=!1,unmount:o=!0,...i}=e,c=p.useRef(null),d=uS(e),u=Fn(...d?[c,n]:n===null?[]:[n]);od();let f=rd();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,y]=p.useState(s?"visible":"hidden"),x=fS(()=>{s||y("hidden")}),[h,v]=p.useState(!0),b=p.useRef([s]);tn(()=>{h!==!1&&b.current[b.current.length-1]!==s&&(b.current.push(s),v(!1))},[b,s]);let j=p.useMemo(()=>({show:s,appear:r,initial:h}),[s,r,h]);tn(()=>{s?y("visible"):!_m(x)&&c.current!==null&&y("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=En();return Ke.createElement($m.Provider,{value:x},Ke.createElement(Em.Provider,{value:j},N({ourProps:{...k,as:p.Fragment,children:Ke.createElement(pS,{ref:u,...k,...i,beforeEnter:E,beforeLeave:S})},theirProps:{},defaultTag:p.Fragment,features:hS,visible:g==="visible",name:"Transition"})))}function RO(e,n){let s=p.useContext(Em)!==null,r=rd()!==null;return Ke.createElement(Ke.Fragment,null,!s&&r?Ke.createElement(qg,{ref:n,...e}):Ke.createElement(pS,{ref:n,...e}))}let qg=xn(TO),pS=xn(_O),dv=xn(RO),AO=Object.assign(qg,{Child:dv,Root:qg});var OO=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(OO||{}),PO=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(PO||{});let LO={0(e,n){return e.titleId===n.id?e:{...e,titleId:n.id}}},uv=p.createContext(null);uv.displayName="DialogContext";function Tm(e){let n=p.useContext(uv);if(n===null){let s=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Tm),s}return n}function MO(e,n){return ts(n.type,LO,e,n)}let Vj=xn(function(e,n){let s=p.useId(),{id:r=`headlessui-dialog-${s}`,open:o,onClose:i,initialFocus:c,role:d="dialog",autoFocus:u=!0,__demoMode:f=!1,unmount:g=!1,...y}=e,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=rd();o===void 0&&h!==null&&(o=(h&Xn.Open)===Xn.Open);let v=p.useRef(null),b=Fn(v,n),j=Ic(v.current),k=o?0:1,[E,S]=p.useReducer(MO,{titleId:null,descriptionId:null,panelRef:p.createRef()}),N=ut(()=>i(!1)),$=ut(se=>S({type:0,id:se})),_=od()?k===0:!1,[P,O]=uO(),M={get current(){var se;return(se=E.panelRef.current)!=null?se:v.current}},R=lS(),{resolveContainers:A}=gO({mainTreeNode:R,portals:P,defaultContainers:[M]}),L=h!==null?(h&Xn.Closing)===Xn.Closing:!1;S1(f||L?!1:_,{allowed:ut(()=>{var se,Q;return[(Q=(se=v.current)==null?void 0:se.closest("[data-headlessui-portal]"))!=null?Q:null]}),disallowed:ut(()=>{var se;return[(se=R==null?void 0:R.closest("body > *:not(#headlessui-portal-root)"))!=null?se:null]})});let D=ym.get(null);tn(()=>{if(_)return D.actions.push(r),()=>D.actions.pop(r)},[D,r,_]);let W=Qn(D,p.useCallback(se=>D.selectors.isTop(se,r),[D,r]));A1(W,A,se=>{se.preventDefault(),N()}),hO(W,j==null?void 0:j.defaultView,se=>{se.preventDefault(),se.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),N()}),P1(f||L?!1:_,j,A),C1(_,v,N);let[q,H]=PA(),K=p.useMemo(()=>[{dialogState:k,close:N,setTitleId:$,unmount:g},E],[k,N,$,g,E]),U=Ks({open:k===0}),G={ref:b,id:r,role:d,tabIndex:-1,"aria-modal":f?void 0:k===0?!0:void 0,"aria-labelledby":E.titleId,"aria-describedby":q,unmount:g},F=!pO(),z=Na.None;_&&!f&&(z|=Na.RestoreFocus,z|=Na.TabLock,u&&(z|=Na.AutoFocus),F&&(z|=Na.InitialFocus));let Y=En();return Ke.createElement(tO,null,Ke.createElement(qj,{force:!0},Ke.createElement(oS,null,Ke.createElement(uv.Provider,{value:K},Ke.createElement(rS,{target:v},Ke.createElement(qj,{force:!1},Ke.createElement(H,{slot:U},Ke.createElement(O,null,Ke.createElement(wO,{initialFocus:c,initialFocusFallback:v,containers:A,features:z},Ke.createElement(BA,{value:N},Y({ourProps:G,theirProps:y,slot:U,defaultTag:IO,features:zO,visible:k===0,name:"Dialog"})))))))))))}),IO="div",zO=ol.RenderStrategy|ol.Static;function DO(e,n){let{transition:s=!1,open:r,...o}=e,i=rd(),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(Kj,null,Ke.createElement(AO,{show:r,transition:s,unmount:o.unmount},Ke.createElement(Vj,{ref:n,...o}))):Ke.createElement(Kj,null,Ke.createElement(Vj,{ref:n,open:r,...o}))}let FO="div";function UO(e,n){let s=p.useId(),{id:r=`headlessui-dialog-panel-${s}`,transition:o=!1,...i}=e,[{dialogState:c,unmount:d},u]=Tm("Dialog.Panel"),f=Fn(n,u.panelRef),g=Ks({open:c===0}),y=ut(j=>{j.stopPropagation()}),x={ref:f,id:r,onClick:y},h=o?dv:p.Fragment,v=o?{unmount:d}:{},b=En();return Ke.createElement(h,{...v},b({ourProps:x,theirProps:i,slot:g,defaultTag:FO,name:"Dialog.Panel"}))}let WO="div";function HO(e,n){let{transition:s=!1,...r}=e,[{dialogState:o,unmount:i}]=Tm("Dialog.Backdrop"),c=Ks({open:o===0}),d={ref:n,"aria-hidden":!0},u=s?dv:p.Fragment,f=s?{unmount:i}:{},g=En();return Ke.createElement(u,{...f},g({ourProps:d,theirProps:r,slot:c,defaultTag:WO,name:"Dialog.Backdrop"}))}let BO="h2";function GO(e,n){let s=p.useId(),{id:r=`headlessui-dialog-title-${s}`,...o}=e,[{dialogState:i,setTitleId:c}]=Tm("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 En()({ourProps:f,theirProps:o,slot:u,defaultTag:BO,name:"Dialog.Title"})}let qO=xn(DO),gS=xn(UO),KO=xn(HO),xS=xn(GO),VO=Object.assign(qO,{Panel:gS,Title:xS,Description:p1}),Yj=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function Qj(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 Yj.test(c)&&(c=c.replace(Yj,"")),c}function YO(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():Qj(i).trim()}return null}).filter(Boolean);if(r.length>0)return r.join(", ")}return Qj(e).trim()}function QO(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=YO(r).trim().toLowerCase();return n.current=o,s.current=i,i})}var JO=Object.defineProperty,XO=(e,n,s)=>n in e?JO(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Jj=(e,n,s)=>(XO(e,typeof n!="symbol"?n+"":n,s),s),zn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(zn||{}),Io=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Io||{}),hf=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(hf||{}),vS=(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))(vS||{});function Xj(e,n=s=>s){let s=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=_1(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 ZO={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=e.buttonElement?mf.Tracked(aS(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:on.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:n}},0(e,n){if(e.dataRef.current.disabled||e.listboxState===0)return e;let s=e.activeOptionIndex,{isSelected:r}=e.dataRef.current,o=e.options.findIndex(i=>r(i.dataRef.current.value));return o!==-1&&(s=o),{...e,frozenValue:!1,pendingFocus:n.focus,listboxState:0,activeOptionIndex:s,__demoMode:!1,buttonPositionState:mf.Idle}},2(e,n){var s,r,o,i,c;if(e.dataRef.current.disabled||e.listboxState===1)return e;let d={...e,searchQuery:"",activationTrigger:(s=n.trigger)!=null?s:1,__demoMode:!1};if(n.focus===on.Nothing)return{...d,activeOptionIndex:null};if(n.focus===on.Specific)return{...d,activeOptionIndex:e.options.findIndex(g=>g.id===n.id)};if(n.focus===on.Previous){let g=e.activeOptionIndex;if(g!==null){let y=e.options[g].dataRef.current.domRef,x=Wu(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=y.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===on.Next){let g=e.activeOptionIndex;if(g!==null){let y=e.options[g].dataRef.current.domRef,x=Wu(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=y.current)==null?void 0:i.nextElementSibling)===h.current||((c=h.current)==null?void 0:c.nextElementSibling)===null)return{...d,activeOptionIndex:x}}}}let u=Xj(e),f=Wu(n,{resolveItems:()=>u.options,resolveActiveIndex:()=>u.activeOptionIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});return{...d,...u,activeOptionIndex:f}},3:(e,n)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let s=e.searchQuery!==""?0:1,r=e.searchQuery+n.value.toLowerCase(),o=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+s).concat(e.options.slice(0,e.activeOptionIndex+s)):e.options).find(c=>{var d;return!c.dataRef.current.disabled&&((d=c.dataRef.current.textValue)==null?void 0:d.startsWith(r))}),i=o?e.options.indexOf(o):-1;return i===-1||i===e.activeOptionIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeOptionIndex:i,activationTrigger:1}},4(e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},5(e){return e.dataRef.current.mode===0?{...e,frozenValue:!0}:{...e}},6:(e,n)=>{let s=e.options.concat(n.options),r=e.activeOptionIndex;if(e.pendingFocus.focus!==on.Nothing&&(r=Wu(e.pendingFocus,{resolveItems:()=>s,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:o=>o.id,resolveDisabled:o=>o.dataRef.current.disabled})),e.activeOptionIndex===null){let{isSelected:o}=e.dataRef.current;if(o){let i=s.findIndex(c=>o==null?void 0:o(c.dataRef.current.value));i!==-1&&(r=i)}}return{...e,options:s,activeOptionIndex:r,pendingFocus:{focus:on.Nothing},pendingShouldSort:!0}},7:(e,n)=>{let s=e.options,r=[],o=new Set(n.options);for(let[i,c]of s.entries())if(o.has(c.id)&&(r.push(i),o.delete(c.id),o.size===0))break;if(r.length>0){s=s.slice();for(let i of r.reverse())s.splice(i,1)}return{...e,options:s,activationTrigger:1}},8:(e,n)=>e.buttonElement===n.element?e:{...e,buttonElement:n.element},9:(e,n)=>e.optionsElement===n.element?e:{...e,optionsElement:n.element},10:e=>e.pendingShouldSort?{...e,...Xj(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:mf.Moved}}};class fv extends w1{constructor(n){super(n),Jj(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:Yp(()=>{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:Yp(()=>{let s=[];return[r=>s.push(r),()=>{this.send({type:7,options:s.splice(0)})}]}),goToOption:Yp(()=>{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})}}),Jj(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=ym.get(null);this.disposables.add(r.on(k1.Push,o=>{!r.selectors.isTop(o,s)&&this.state.listboxState===0&&this.actions.closeListbox()})),this.on(0,()=>r.actions.push(s)),this.on(1,()=>r.actions.pop(s))}this.disposables.group(s=>{this.on(1,r=>{r.buttonElement&&(s.dispose(),s.add(mO(r.buttonElement,r.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(s,r)=>{var o;this.actions.onChange(r.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(o=this.state.buttonElement)==null||o.focus({preventScroll:!0}))})}static new({id:n,__demoMode:s=!1}){return new fv({id:n,dataRef:{current:{}},listboxState:s?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:on.Nothing},frozenValue:!1,__demoMode:s,buttonPositionState:mf.Idle})}reduce(n,s){return ts(s.type,ZO,n,s)}}const bS=p.createContext(null);function mv(e){let n=p.useContext(bS);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,yS),s}return n}function yS({id:e,__demoMode:n=!1}){let s=p.useMemo(()=>fv.new({id:e,__demoMode:n}),[]);return lv(()=>s.dispose()),s}let Rm=p.createContext(null);Rm.displayName="ListboxDataContext";function ad(e){let n=p.useContext(Rm);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,ad),s}return n}let e5=p.Fragment;function t5(e,n){let s=p.useId(),r=tv(),{value:o,defaultValue:i,form:c,name:d,onChange:u,by:f,invalid:g=!1,disabled:y=r||!1,horizontal:x=!1,multiple:h=!1,__demoMode:v=!1,...b}=e;const j=x?"horizontal":"vertical";let k=Fn(n),E=xA(i),[S=h?[]:void 0,N]=gA(o,u,E),$=yS({id:s,__demoMode:v}),_=p.useRef({static:!1,hold:!1}),P=p.useRef(new Map),O=qA(f),M=p.useCallback(Y=>ts(R.mode,{[Io.Multi]:()=>S.some(se=>O(se,Y)),[Io.Single]:()=>O(S,Y)}),[S]),R=Ks({value:S,disabled:y,invalid:g,mode:h?Io.Multi:Io.Single,orientation:j,onChange:N,compare:O,isSelected:M,optionsPropsRef:_,listRef:P});tn(()=>{$.state.dataRef.current=R},[R]);let A=Qn($,Y=>Y.listboxState),L=ym.get(null),D=Qn(L,p.useCallback(Y=>L.selectors.isTop(Y,s),[L,s])),[W,q]=Qn($,Y=>[Y.buttonElement,Y.optionsElement]);A1(D,[W,q],(Y,se)=>{$.send({type:vS.CloseListbox}),$1(se,nv.Loose)||(Y.preventDefault(),W==null||W.focus())});let H=Ks({open:A===zn.Open,disabled:y,invalid:g,value:S}),[K,U]=zA({inherit:!0}),G={ref:k},F=p.useCallback(()=>{if(E!==void 0)return N==null?void 0:N(E)},[N,E]),z=En();return Ke.createElement(U,{value:K,props:{htmlFor:W==null?void 0:W.id},slot:{open:A===zn.Open,disabled:y}},Ke.createElement(J4,null,Ke.createElement(bS.Provider,{value:$},Ke.createElement(Rm.Provider,{value:R},Ke.createElement(eS,{value:ts(A,{[zn.Open]:Xn.Open,[zn.Closed]:Xn.Closed})},d!=null&&S!=null&&Ke.createElement(NA,{disabled:y,data:{[d]:S},form:c,onReset:F}),z({ourProps:G,theirProps:b,slot:H,defaultTag:e5,name:"Listbox"}))))))}let n5="button";function s5(e,n){let s=p.useId(),r=c1(),o=ad("Listbox.Button"),i=mv("Listbox.Button"),{id:c=r||`headlessui-listbox-button-${s}`,disabled:d=o.disabled||!1,autoFocus:u=!1,...f}=e,g=Fn(n,K4(),i.actions.setButtonElement),y=V4(),[x,h,v]=Qn(i,q=>[q.listboxState,q.buttonElement,q.optionsElement]),b=x===zn.Open;g3(b,{trigger:h,action:p.useCallback(q=>{if(h!=null&&h.contains(q.target))return Fu.Ignore;let H=q.target.closest('[role="option"]:not([data-disabled])');return Ss(H)?Fu.Select(H):v!=null&&v.contains(q.target)?Fu.Ignore:Fu.Close},[h,v]),close:i.actions.closeListbox,select:i.actions.selectActiveOption});let j=ut(q=>{switch(q.key){case yn.Enter:vA(q.currentTarget);break;case yn.Space:case yn.ArrowDown:q.preventDefault(),i.actions.openListbox({focus:o.value?on.Nothing:on.First});break;case yn.ArrowUp:q.preventDefault(),i.actions.openListbox({focus:o.value?on.Nothing:on.Last});break}}),k=ut(q=>{switch(q.key){case yn.Space:q.preventDefault();break}}),E=VA(q=>{var H;i.state.listboxState===zn.Open?(Ns.flushSync(()=>i.actions.closeListbox()),(H=i.state.buttonElement)==null||H.focus({preventScroll:!0})):(q.preventDefault(),i.actions.openListbox({focus:on.Nothing}))}),S=ut(q=>q.preventDefault()),N=x1([c]),$=OA(),{isFocusVisible:_,focusProps:P}=eA({autoFocus:u}),{isHovered:O,hoverProps:M}=sA({isDisabled:d}),{pressed:R,pressProps:A}=cA({disabled:d}),L=Ks({open:x===zn.Open,active:R||x===zn.Open,disabled:d,invalid:o.invalid,value:o.value,hover:O,focus:_,autofocus:u}),D=Qn(i,q=>q.listboxState===zn.Open),W=r1(y(),{ref:g,id:c,type:x3(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,P,M,A);return En()({ourProps:W,theirProps:f,slot:L,defaultTag:n5,name:"Listbox.Button"})}let wS=p.createContext(!1),r5="div",o5=ol.RenderStrategy|ol.Static;function a5(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=q4(o),[g,y]=p.useState(null);f&&(i=!0);let x=ad("Listbox.Options"),h=mv("Listbox.Options"),[v,b,j,k]=Qn(h,te=>[te.listboxState,te.buttonElement,te.optionsElement,te.__demoMode]),E=Ic(b),S=Ic(j),N=rd(),[$,_]=M1(d,g,N!==null?(N&Xn.Open)===Xn.Open:v===zn.Open);C1($,b,h.actions.closeListbox);let P=k?!1:c&&v===zn.Open;P1(P,S);let O=k?!1:c&&v===zn.Open;S1(O,{allowed:p.useCallback(()=>[b,j],[b,j])});let M=Qn(h,h.selectors.didButtonMove)?!1:$,R=Qn(h,h.selectors.hasFrozenValue)&&!e.static,A=Z1(R,x.value),L=p.useCallback(te=>x.compare(A,te),[x.compare,A]),D=Qn(h,te=>{var he;if(f==null||!((he=f==null?void 0:f.to)!=null&&he.includes("selection")))return null;let ge=te.options.findIndex(ye=>L(ye.dataRef.current.value));return ge===-1&&(ge=0),ge}),W=(()=>{if(f==null)return;if(D===null)return{...f,inner:void 0};let te=Array.from(x.listRef.current.values());return{...f,inner:{listRef:{current:te},index:D}}})(),[q,H]=Q4(W),K=Y4(),U=Fn(n,f?q:null,h.actions.setOptionsElement,y),G=Jo();p.useEffect(()=>{let te=j;te&&v===zn.Open&&(n1(te)||te==null||te.focus({preventScroll:!0}))},[v,j]);let F=ut(te=>{var he;switch(G.dispose(),te.key){case yn.Space:if(h.state.searchQuery!=="")return te.preventDefault(),te.stopPropagation(),h.actions.search(te.key);case yn.Enter:te.preventDefault(),te.stopPropagation(),h.actions.selectActiveOption();break;case ts(x.orientation,{vertical:yn.ArrowDown,horizontal:yn.ArrowRight}):return te.preventDefault(),te.stopPropagation(),h.actions.goToOption({focus:on.Next});case ts(x.orientation,{vertical:yn.ArrowUp,horizontal:yn.ArrowLeft}):return te.preventDefault(),te.stopPropagation(),h.actions.goToOption({focus:on.Previous});case yn.Home:case yn.PageUp:return te.preventDefault(),te.stopPropagation(),h.actions.goToOption({focus:on.First});case yn.End:case yn.PageDown:return te.preventDefault(),te.stopPropagation(),h.actions.goToOption({focus:on.Last});case yn.Escape:te.preventDefault(),te.stopPropagation(),Ns.flushSync(()=>h.actions.closeListbox()),(he=h.state.buttonElement)==null||he.focus({preventScroll:!0});return;case yn.Tab:te.preventDefault(),te.stopPropagation(),Ns.flushSync(()=>h.actions.closeListbox()),f3(h.state.buttonElement,te.shiftKey?lr.Previous:lr.Next);break;default:te.key.length===1&&(h.actions.search(te.key),G.setTimeout(()=>h.actions.clearSearch(),350));break}}),z=Qn(h,te=>{var he;return(he=te.buttonElement)==null?void 0:he.id}),Y=Ks({open:v===zn.Open}),se=r1(f?K():{},{id:r,ref:U,"aria-activedescendant":Qn(h,h.selectors.activeDescendantId),"aria-multiselectable":x.mode===Io.Multi?!0:void 0,"aria-labelledby":z,"aria-orientation":x.orientation,onKeyDown:F,role:"listbox",tabIndex:v===zn.Open?0:void 0,style:{...u.style,...H,"--button-width":KA($,b,!0).width},...L1(_)}),Q=En(),re=p.useMemo(()=>x.mode===Io.Multi?x:{...x,isSelected:L},[x,L]);return Ke.createElement(oS,{enabled:i?e.static||$:!1,ownerDocument:E},Ke.createElement(Rm.Provider,{value:re},Q({ourProps:se,theirProps:u,slot:Y,defaultTag:r5,features:o5,visible:M,name:"Listbox.Options"})))}let i5="div";function l5(e,n){let s=p.useId(),{id:r=`headlessui-listbox-option-${s}`,disabled:o=!1,value:i,...c}=e,d=p.useContext(wS)===!0,u=ad("Listbox.Option"),f=mv("Listbox.Option"),g=Qn(f,R=>f.selectors.isActive(R,r)),y=u.isSelected(i),x=p.useRef(null),h=QO(x),v=Xo({disabled:o,value:i,domRef:x,get textValue(){return h()}}),b=Fn(n,x,R=>{R?u.listRef.current.set(r,R):u.listRef.current.delete(r)}),j=Qn(f,R=>f.selectors.shouldScrollIntoView(R,r));tn(()=>{if(j)return $s().requestAnimationFrame(()=>{var R,A;(A=(R=x.current)==null?void 0:R.scrollIntoView)==null||A.call(R,{block:"nearest"})})},[j,x]),tn(()=>{if(!d)return f.actions.registerOption(r,v),()=>f.actions.unregisterOption(r)},[v,r,d]);let k=ut(R=>{if(o)return R.preventDefault();f.actions.selectOption(i)}),E=ut(()=>{if(o)return f.actions.goToOption({focus:on.Nothing});f.actions.goToOption({focus:on.Specific,id:r})}),S=N3(),N=ut(R=>S.update(R)),$=ut(R=>{S.wasMoved(R)&&(o||g&&f.state.activationTrigger===hf.Pointer||f.actions.goToOption({focus:on.Specific,id:r},hf.Pointer))}),_=ut(R=>{S.wasMoved(R)&&(o||g&&f.state.activationTrigger===hf.Pointer&&f.actions.goToOption({focus:on.Nothing}))}),P=Ks({active:g,focus:g,selected:y,disabled:o,selectedOption:y&&d}),O=d?{}:{id:r,ref:b,role:"option",tabIndex:o===!0?void 0:-1,"aria-disabled":o===!0?!0:void 0,"aria-selected":y,disabled:void 0,onClick:k,onFocus:E,onPointerEnter:N,onMouseEnter:N,onPointerMove:$,onMouseMove:$,onPointerLeave:_,onMouseLeave:_},M=En();return!y&&d?null:M({ourProps:O,theirProps:c,slot:P,defaultTag:i5,name:"Listbox.Option"})}let c5=p.Fragment;function d5(e,n){let{options:s,placeholder:r,...o}=e,i={ref:Fn(n)},c=ad("ListboxSelectedOption"),d=Ks({}),u=c.value===void 0||c.value===null||c.mode===Io.Multi&&Array.isArray(c.value)&&c.value.length===0,f=En();return Ke.createElement(wS.Provider,{value:!0},f({ourProps:i,theirProps:{...o,children:Ke.createElement(Ke.Fragment,null,r&&u?r:s)},slot:d,defaultTag:c5,name:"ListboxSelectedOption"}))}let u5=xn(t5),jS=xn(s5),f5=WA,kS=xn(a5),NS=xn(l5),m5=xn(d5),h5=Object.assign(u5,{Button:jS,Label:f5,Options:kS,Option:NS,SelectedOption:m5});const p5={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function Am({open:e,onClose:n,title:s,description:r,footer:o,size:i="md",initialFocus:c,hideClose:d,className:u,children:f}){return t.jsxs(VO,{open:e,onClose:n,initialFocus:c,className:"relative z-dialog",children:[t.jsx(KO,{className:"fixed inset-0 bg-overlay/70"}),t.jsx("div",{className:ie("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(gS,{className:ie("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",p5[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(xS,{className:"text-lg font-semibold",children:s}),r&&t.jsx(p1,{className:"mt-1 text-body text-muted-foreground",children:r})]}),!d&&t.jsx(B,{size:"icon",variant:"ghost",onClick:n,"aria-label":"Close",children:t.jsx(Qo,{"aria-hidden":!0})})]}),f&&t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4 text-body",children:f}),o&&t.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t px-5 py-3",children:o})]})})]})}function hv({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(Am,{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 pv=p.createContext(null),g5=()=>p.useContext(pv);function gv(e){const n=p.useContext(pv);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 wt({label:e,id:n,required:s,optional:r,note:o,hint:i,error:c,warning:d,aside:u,group:f,className:g,children:y}){const x=p.useId(),h=n??`${x}-control`,[v,b,j,k,E]=[`${x}-label`,`${x}-note`,`${x}-hint`,`${x}-error`,`${x}-warning`],S=[o&&b,i&&j,c&&k,d&&E].filter(Boolean).join(" ")||void 0,N=t.jsxs(t.Fragment,{children:[e,s&&t.jsx("span",{className:"text-destructive-text","aria-hidden":!0,children:" *"}),r&&t.jsx("span",{className:"font-normal normal-case text-muted-foreground",children:" (optional)"})]});return t.jsxs("div",{className:g,...f===!0?{role:"group","aria-labelledby":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:b,className:"-mt-1 mb-2 text-small text-muted-foreground",children:o}),t.jsx(pv.Provider,{value:f?null:{id:h,describedBy:S,invalid:!!c,required:!!s},children:y}),i&&t.jsx("p",{id:j,className:"mt-1.5 text-small text-muted-foreground",children:i}),c&&t.jsx("p",{id:k,className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{id:E,className:"mt-2 font-mono text-small text-warning-text",children:d})]})}const SS="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",CS="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",id="xl:columns-2 xl:gap-x-10 2xl:columns-3 [&>*]:mb-5 [&>*]:mt-0 [&>*]:break-inside-avoid",Uc="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,...gv(r),className:ie(s?CS:ie(SS,n==="sm"?"h-control-sm":"h-control-md"),e)}));Pe.displayName="Input";const nn=p.forwardRef(({className:e,bare:n,...s},r)=>t.jsx("textarea",{ref:r,...s,...gv(s),className:ie(n?CS:ie(SS,"py-2.5"),e)}));nn.displayName="Textarea";const ES=e=>{const n=p.forwardRef(({label:s,note:r,className:o,disabled:i,...c},d)=>t.jsxs("label",{className:ie("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,...gv(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},x5=ES("checkbox");ES("radio");function br({icon:e,active:n,className:s,children:r,...o}){return t.jsxs("button",{type:"button","aria-current":n?"page":void 0,...o,className:ie("flex min-h-11 items-center gap-2.5 p-3 text-left text-body -outline-offset-2 hover:bg-accent",n&&"!rounded-action bg-primary/[0.06] text-primary-text hover:bg-primary/10",s),children:[e&&t.jsx(e,{className:"size-4 shrink-0","aria-hidden":!0})," ",r]})}function Et({value:e,onChange:n,options:s,label:r,id:o,className:i,disabled:c=!1,name:d,small:u=!1,placeholder:f,autoFocus:g}){const y=s.find(h=>h.value===e),x=g5();return t.jsxs(h5,{value:e,onChange:n,disabled:c,name:d,children:[t.jsxs(jS,{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:ie("flex min-w-0 items-center justify-between gap-2 border border-input bg-background text-left font-mono hover:border-foreground/60 focus-visible:outline-offset-0 disabled:opacity-60 data-[open]:border-foreground",u?"h-control-sm px-2 text-small":"h-control-md px-3 text-body",i),children:[t.jsx("span",{className:ie("min-w-0 truncate",!y&&"text-muted-foreground"),children:(y==null?void 0:y.label)??f??""}),t.jsx(Ar,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsx(kS,{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(NS,{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(Ne,{tone:"success",className:"ml-auto",children:h.tag})]},h.value))})]})}function ld({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:ie("inline-flex",c),children:s.map(d=>t.jsxs("label",{title:d.title,className:ie("caps -ml-px inline-flex items-center justify-center gap-1.5 border first:ml-0 has-[:focus-visible]:relative has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring [&_svg]:size-3.5",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 v5=["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 b5({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:ie(v5,"h-control-sm cursor-pointer disabled:cursor-not-allowed disabled:opacity-45",c)})}function y5({label:e,className:n}){return t.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[t.jsx(AT,{className:ie("size-4 animate-spin text-run-active",n),"aria-hidden":!0}),e&&t.jsx("span",{className:"sr-only",children:e})]})}function cd({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:ie("relative inline-flex h-5 w-9 shrink-0 items-center border transition-colors disabled:cursor-not-allowed disabled:opacity-45",e?"border-primary bg-primary/20":"border-border-strong bg-background hover:border-foreground/60",i&&"motion-safe:animate-pulse",c),children:t.jsx("span",{"aria-hidden":!0,className:ie("absolute top-1/2 size-3 -translate-y-1/2 transition-[left,background-color] duration-fast",e?"left-[calc(100%-16px)] bg-primary":"left-[3px] bg-muted-foreground")})})}const $S="flex shrink-0 gap-x-4 overflow-x-auto border-b px-5 md:px-8",_S=e=>ie("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 TS({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 y=e.findIndex(b=>b.id===n),x=g.key==="ArrowRight"?(y+1)%e.length:g.key==="ArrowLeft"?(y-1+e.length)%e.length:g.key==="Home"?0:g.key==="End"?e.length-1:-1;x<0||x===y||(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:ie($S,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:_S(n===g.id),children:g.label},g.id))})}const w5=(e,n)=>({role:"tabpanel",id:`${e}-panel-${n}`,"aria-labelledby":`${e}-tab-${n}`});function j5({tip:e,children:n,className:s,align:r="start"}){const o=p.useId();return t.jsxs("span",{className:ie("group/tip relative inline-flex",s),children:[p.cloneElement(n,{"aria-describedby":o}),t.jsx("span",{role:"tooltip",id:o,className:ie("pointer-events-none absolute top-full z-popover mt-1.5 hidden w-max max-w-[min(20rem,80vw)] border border-border-strong bg-card px-3 py-2 text-left font-sans text-small normal-case leading-snug tracking-normal text-card-foreground shadow-float group-hover/tip:block group-focus-within/tip:block",r==="end"?"right-0":"left-0"),children:e})]})}const RS=p.createContext(null),k5={neutral:[Og,"text-muted-foreground"],success:[EN,"text-success-text"],warning:[Gs,"text-warning-text"],error:[tl,"text-destructive-text"]},N5=5e3;function S5(){return p.useContext(RS)??C5}const C5=()=>{};function E5({toast:e,done:n}){const s=p.useCallback(()=>n(e.id),[n,e.id]),r=e.tone??"neutral",o=e.duration??(r==="error"?0:N5),[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,y]=k5[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:ie("mt-0.5 size-4 shrink-0",y),"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"font-semibold",children:e.title}),e.description&&t.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:e.description})]}),t.jsx("button",{type:"button",onClick:s,"aria-label":"Dismiss",className:"-m-1 shrink-0 p-1 text-muted-foreground hover:text-foreground",children:t.jsx(Qo,{className:"size-3.5","aria-hidden":!0})})]})}function $5({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(RS.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(E5,{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:AS,setPrototypeOf:Zj,isFrozen:_5,getPrototypeOf:T5,getOwnPropertyDescriptor:R5}=Object;let{freeze:ns,seal:Vs,create:OS}=Object,{apply:Kg,construct:Vg}=typeof Reflect<"u"&&Reflect;ns||(ns=function(n){return n});Vs||(Vs=function(n){return n});Kg||(Kg=function(n,s,r){return n.apply(s,r)});Vg||(Vg=function(n,s){return new n(...s)});const Hu=Cs(Array.prototype.forEach),ek=Cs(Array.prototype.pop),dc=Cs(Array.prototype.push),pf=Cs(String.prototype.toLowerCase),rg=Cs(String.prototype.toString),tk=Cs(String.prototype.match),uc=Cs(String.prototype.replace),A5=Cs(String.prototype.indexOf),O5=Cs(String.prototype.trim),ar=Cs(Object.prototype.hasOwnProperty),Yn=Cs(RegExp.prototype.test),fc=P5(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 Kg(e,n,r)}}function P5(e){return function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return Vg(e,s)}}function yt(e,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pf;Zj&&Zj(e,null);let r=n.length;for(;r--;){let o=n[r];if(typeof o=="string"){const i=s(o);i!==o&&(_5(n)||(n[r]=i),o=i)}e[o]=!0}return e}function L5(e){for(let n=0;n<e.length;n++)ar(e,n)||(e[n]=null);return e}function ka(e){const n=OS(null);for(const[s,r]of AS(e))ar(e,s)&&(Array.isArray(r)?n[s]=L5(r):r&&typeof r=="object"&&r.constructor===Object?n[s]=ka(r):n[s]=r);return n}function mc(e,n){for(;e!==null;){const r=R5(e,n);if(r){if(r.get)return Cs(r.get);if(typeof r.value=="function")return Cs(r.value)}e=T5(e)}function s(){return null}return s}const nk=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"]),og=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"]),ag=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"]),M5=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"]),ig=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"]),I5=ns(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),sk=ns(["#text"]),rk=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"]),lg=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"]),ok=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"]),Bu=ns(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),z5=Vs(/\{\{[\w\W]*|[\w\W]*\}\}/gm),D5=Vs(/<%[\w\W]*|[\w\W]*%>/gm),F5=Vs(/\$\{[\w\W]*}/gm),U5=Vs(/^data-[\-\w.\u00B7-\uFFFF]+$/),W5=Vs(/^aria-[\-\w]+$/),PS=Vs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),H5=Vs(/^(?:\w+script|data):/i),B5=Vs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),LS=Vs(/^html$/i),G5=Vs(/^[a-z][.\w]*(-[.\w]+)+$/i);var ak=Object.freeze({__proto__:null,ARIA_ATTR:W5,ATTR_WHITESPACE:B5,CUSTOM_ELEMENT:G5,DATA_ATTR:U5,DOCTYPE_NAME:LS,ERB_EXPR:D5,IS_ALLOWED_URI:PS,IS_SCRIPT_OR_DATA:H5,MUSTACHE_EXPR:z5,TMPLIT_EXPR:F5});const hc={element:1,text:3,progressingInstruction:7,comment:8,document:9},q5=function(){return typeof window>"u"?null:window},K5=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}},ik=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function MS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:q5();const n=Be=>MS(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:y,DOMParser:x,trustedTypes:h}=e,v=u.prototype,b=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:P,createDocumentFragment:O,getElementsByTagName:M}=s,{importNode:R}=r;let A=ik();n.isSupported=typeof AS=="function"&&typeof S=="function"&&_&&_.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:L,ERB_EXPR:D,TMPLIT_EXPR:W,DATA_ATTR:q,ARIA_ATTR:H,IS_SCRIPT_OR_DATA:K,ATTR_WHITESPACE:U,CUSTOM_ELEMENT:G}=ak;let{IS_ALLOWED_URI:F}=ak,z=null;const Y=yt({},[...nk,...og,...ag,...ig,...sk]);let se=null;const Q=yt({},[...rk,...lg,...ok,...Bu]);let re=Object.seal(OS(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}})),te=null,he=null,ge=!0,ye=!0,xe=!1,fe=!0,De=!1,Fe=!0,Le=!1,Ee=!1,ae=!1,$e=!1,ot=!1,me=!1,Me=!0,Ze=!1;const bt="user-content-";let oe=!0,Se=!1,tt={},Ae=null;const it=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 $t=null;const nt=yt({},["audio","video","img","source","image","track"]);let ft=null;const Dt=yt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ft="http://www.w3.org/1998/Math/MathML",be="http://www.w3.org/2000/svg",de="http://www.w3.org/1999/xhtml";let Ue=de,Xe=!1,at=null;const J=yt({},[Ft,be,de],rg);let ve=yt({},["mi","mo","mn","ms","mtext"]),We=yt({},["annotation-xml"]);const Ve=yt({},["title","style","font","a","script"]);let He=null;const gt=["application/xhtml+xml","text/html"],kt="text/html";let lt=null,Vt=null;const ps=s.createElement("form"),Qs=function(ee){return ee instanceof RegExp||ee instanceof Function},$n=function(){let ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Vt&&Vt===ee)){if((!ee||typeof ee!="object")&&(ee={}),ee=ka(ee),He=gt.indexOf(ee.PARSER_MEDIA_TYPE)===-1?kt:ee.PARSER_MEDIA_TYPE,lt=He==="application/xhtml+xml"?rg:pf,z=ar(ee,"ALLOWED_TAGS")?yt({},ee.ALLOWED_TAGS,lt):Y,se=ar(ee,"ALLOWED_ATTR")?yt({},ee.ALLOWED_ATTR,lt):Q,at=ar(ee,"ALLOWED_NAMESPACES")?yt({},ee.ALLOWED_NAMESPACES,rg):J,ft=ar(ee,"ADD_URI_SAFE_ATTR")?yt(ka(Dt),ee.ADD_URI_SAFE_ATTR,lt):Dt,$t=ar(ee,"ADD_DATA_URI_TAGS")?yt(ka(nt),ee.ADD_DATA_URI_TAGS,lt):nt,Ae=ar(ee,"FORBID_CONTENTS")?yt({},ee.FORBID_CONTENTS,lt):it,te=ar(ee,"FORBID_TAGS")?yt({},ee.FORBID_TAGS,lt):{},he=ar(ee,"FORBID_ATTR")?yt({},ee.FORBID_ATTR,lt):{},tt=ar(ee,"USE_PROFILES")?ee.USE_PROFILES:!1,ge=ee.ALLOW_ARIA_ATTR!==!1,ye=ee.ALLOW_DATA_ATTR!==!1,xe=ee.ALLOW_UNKNOWN_PROTOCOLS||!1,fe=ee.ALLOW_SELF_CLOSE_IN_ATTR!==!1,De=ee.SAFE_FOR_TEMPLATES||!1,Fe=ee.SAFE_FOR_XML!==!1,Le=ee.WHOLE_DOCUMENT||!1,$e=ee.RETURN_DOM||!1,ot=ee.RETURN_DOM_FRAGMENT||!1,me=ee.RETURN_TRUSTED_TYPE||!1,ae=ee.FORCE_BODY||!1,Me=ee.SANITIZE_DOM!==!1,Ze=ee.SANITIZE_NAMED_PROPS||!1,oe=ee.KEEP_CONTENT!==!1,Se=ee.IN_PLACE||!1,F=ee.ALLOWED_URI_REGEXP||PS,Ue=ee.NAMESPACE||de,ve=ee.MATHML_TEXT_INTEGRATION_POINTS||ve,We=ee.HTML_INTEGRATION_POINTS||We,re=ee.CUSTOM_ELEMENT_HANDLING||{},ee.CUSTOM_ELEMENT_HANDLING&&Qs(ee.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(re.tagNameCheck=ee.CUSTOM_ELEMENT_HANDLING.tagNameCheck),ee.CUSTOM_ELEMENT_HANDLING&&Qs(ee.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(re.attributeNameCheck=ee.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),ee.CUSTOM_ELEMENT_HANDLING&&typeof ee.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(re.allowCustomizedBuiltInElements=ee.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),De&&(ye=!1),ot&&($e=!0),tt&&(z=yt({},sk),se=[],tt.html===!0&&(yt(z,nk),yt(se,rk)),tt.svg===!0&&(yt(z,og),yt(se,lg),yt(se,Bu)),tt.svgFilters===!0&&(yt(z,ag),yt(se,lg),yt(se,Bu)),tt.mathMl===!0&&(yt(z,ig),yt(se,ok),yt(se,Bu))),ee.ADD_TAGS&&(z===Y&&(z=ka(z)),yt(z,ee.ADD_TAGS,lt)),ee.ADD_ATTR&&(se===Q&&(se=ka(se)),yt(se,ee.ADD_ATTR,lt)),ee.ADD_URI_SAFE_ATTR&&yt(ft,ee.ADD_URI_SAFE_ATTR,lt),ee.FORBID_CONTENTS&&(Ae===it&&(Ae=ka(Ae)),yt(Ae,ee.FORBID_CONTENTS,lt)),oe&&(z["#text"]=!0),Le&&yt(z,["html","head","body"]),z.table&&(yt(z,["tbody"]),delete te.tbody),ee.TRUSTED_TYPES_POLICY){if(typeof ee.TRUSTED_TYPES_POLICY.createHTML!="function")throw fc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof ee.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw fc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=ee.TRUSTED_TYPES_POLICY,$=N.createHTML("")}else N===void 0&&(N=K5(h,o)),N!==null&&typeof $=="string"&&($=N.createHTML(""));ns&&ns(ee),Vt=ee}},Wn=yt({},[...og,...ag,...M5]),gs=yt({},[...ig,...I5]),xs=function(ee){let we=S(ee);(!we||!we.tagName)&&(we={namespaceURI:Ue,tagName:"template"});const qe=pf(ee.tagName),St=pf(we.tagName);return at[ee.namespaceURI]?ee.namespaceURI===be?we.namespaceURI===de?qe==="svg":we.namespaceURI===Ft?qe==="svg"&&(St==="annotation-xml"||ve[St]):!!Wn[qe]:ee.namespaceURI===Ft?we.namespaceURI===de?qe==="math":we.namespaceURI===be?qe==="math"&&We[St]:!!gs[qe]:ee.namespaceURI===de?we.namespaceURI===be&&!We[St]||we.namespaceURI===Ft&&!ve[St]?!1:!gs[qe]&&(Ve[qe]||!Wn[qe]):!!(He==="application/xhtml+xml"&&at[ee.namespaceURI]):!1},mn=function(ee){dc(n.removed,{element:ee});try{S(ee).removeChild(ee)}catch{j(ee)}},Hn=function(ee,we){try{dc(n.removed,{attribute:we.getAttributeNode(ee),from:we})}catch{dc(n.removed,{attribute:null,from:we})}if(we.removeAttribute(ee),ee==="is")if($e||ot)try{mn(we)}catch{}else try{we.setAttribute(ee,"")}catch{}},_s=function(ee){let we=null,qe=null;if(ae)ee="<remove></remove>"+ee;else{const ct=tk(ee,/^[\r\n\t ]+/);qe=ct&&ct[0]}He==="application/xhtml+xml"&&Ue===de&&(ee='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+ee+"</body></html>");const St=N?N.createHTML(ee):ee;if(Ue===de)try{we=new x().parseFromString(St,He)}catch{}if(!we||!we.documentElement){we=_.createDocument(Ue,"template",null);try{we.documentElement.innerHTML=Xe?$:St}catch{}}const It=we.body||we.documentElement;return ee&&qe&&It.insertBefore(s.createTextNode(qe),It.childNodes[0]||null),Ue===de?M.call(we,Le?"html":"body")[0]:Le?we.documentElement:It},Bn=function(ee){return P.call(ee.ownerDocument||ee,ee,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},Ts=function(ee){return ee instanceof y&&(typeof ee.nodeName!="string"||typeof ee.textContent!="string"||typeof ee.removeChild!="function"||!(ee.attributes instanceof g)||typeof ee.removeAttribute!="function"||typeof ee.setAttribute!="function"||typeof ee.namespaceURI!="string"||typeof ee.insertBefore!="function"||typeof ee.hasChildNodes!="function")},Rs=function(ee){return typeof d=="function"&&ee instanceof d};function On(Be,ee,we){Hu(Be,qe=>{qe.call(n,ee,we,Vt)})}const Z=function(ee){let we=null;if(On(A.beforeSanitizeElements,ee,null),Ts(ee))return mn(ee),!0;const qe=lt(ee.nodeName);if(On(A.uponSanitizeElement,ee,{tagName:qe,allowedTags:z}),ee.hasChildNodes()&&!Rs(ee.firstElementChild)&&Yn(/<[/\w]/g,ee.innerHTML)&&Yn(/<[/\w]/g,ee.textContent)||ee.nodeType===hc.progressingInstruction||Fe&&ee.nodeType===hc.comment&&Yn(/<[/\w]/g,ee.data))return mn(ee),!0;if(!z[qe]||te[qe]){if(!te[qe]&&mt(qe)&&(re.tagNameCheck instanceof RegExp&&Yn(re.tagNameCheck,qe)||re.tagNameCheck instanceof Function&&re.tagNameCheck(qe)))return!1;if(oe&&!Ae[qe]){const St=S(ee)||ee.parentNode,It=E(ee)||ee.childNodes;if(It&&St){const ct=It.length;for(let wn=ct-1;wn>=0;--wn){const _n=b(It[wn],!0);_n.__removalCount=(ee.__removalCount||0)+1,St.insertBefore(_n,k(ee))}}}return mn(ee),!0}return ee instanceof u&&!xs(ee)||(qe==="noscript"||qe==="noembed"||qe==="noframes")&&Yn(/<\/no(script|embed|frames)/i,ee.innerHTML)?(mn(ee),!0):(De&&ee.nodeType===hc.text&&(we=ee.textContent,Hu([L,D,W],St=>{we=uc(we,St," ")}),ee.textContent!==we&&(dc(n.removed,{element:ee.cloneNode()}),ee.textContent=we)),On(A.afterSanitizeElements,ee,null),!1)},Oe=function(ee,we,qe){if(Me&&(we==="id"||we==="name")&&(qe in s||qe in ps))return!1;if(!(ye&&!he[we]&&Yn(q,we))){if(!(ge&&Yn(H,we))){if(!se[we]||he[we]){if(!(mt(ee)&&(re.tagNameCheck instanceof RegExp&&Yn(re.tagNameCheck,ee)||re.tagNameCheck instanceof Function&&re.tagNameCheck(ee))&&(re.attributeNameCheck instanceof RegExp&&Yn(re.attributeNameCheck,we)||re.attributeNameCheck instanceof Function&&re.attributeNameCheck(we))||we==="is"&&re.allowCustomizedBuiltInElements&&(re.tagNameCheck instanceof RegExp&&Yn(re.tagNameCheck,qe)||re.tagNameCheck instanceof Function&&re.tagNameCheck(qe))))return!1}else if(!ft[we]){if(!Yn(F,uc(qe,U,""))){if(!((we==="src"||we==="xlink:href"||we==="href")&&ee!=="script"&&A5(qe,"data:")===0&&$t[ee])){if(!(xe&&!Yn(K,uc(qe,U,"")))){if(qe)return!1}}}}}}return!0},mt=function(ee){return ee!=="annotation-xml"&&tk(ee,G)},Ot=function(ee){On(A.beforeSanitizeAttributes,ee,null);const{attributes:we}=ee;if(!we||Ts(ee))return;const qe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:se,forceKeepAttr:void 0};let St=we.length;for(;St--;){const It=we[St],{name:ct,namespaceURI:wn,value:_n}=It,mr=lt(ct);let Bt=ct==="value"?_n:O5(_n);if(qe.attrName=mr,qe.attrValue=Bt,qe.keepAttr=!0,qe.forceKeepAttr=void 0,On(A.uponSanitizeAttribute,ee,qe),Bt=qe.attrValue,Ze&&(mr==="id"||mr==="name")&&(Hn(ct,ee),Bt=bt+Bt),Fe&&Yn(/((--!?|])>)|<\/(style|title)/i,Bt)){Hn(ct,ee);continue}if(qe.forceKeepAttr||(Hn(ct,ee),!qe.keepAttr))continue;if(!fe&&Yn(/\/>/i,Bt)){Hn(ct,ee);continue}De&&Hu([L,D,W],ao=>{Bt=uc(Bt,ao," ")});const si=lt(ee.nodeName);if(Oe(si,mr,Bt)){if(N&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!wn)switch(h.getAttributeType(si,mr)){case"TrustedHTML":{Bt=N.createHTML(Bt);break}case"TrustedScriptURL":{Bt=N.createScriptURL(Bt);break}}try{wn?ee.setAttributeNS(wn,ct,Bt):ee.setAttribute(ct,Bt),Ts(ee)?mn(ee):ek(n.removed)}catch{}}}On(A.afterSanitizeAttributes,ee,null)},Xt=function Be(ee){let we=null;const qe=Bn(ee);for(On(A.beforeSanitizeShadowDOM,ee,null);we=qe.nextNode();)On(A.uponSanitizeShadowNode,we,null),Z(we),Ot(we),we.content instanceof i&&Be(we.content);On(A.afterSanitizeShadowDOM,ee,null)};return n.sanitize=function(Be){let ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},we=null,qe=null,St=null,It=null;if(Xe=!Be,Xe&&(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||$n(ee),n.removed=[],typeof Be=="string"&&(Se=!1),Se){if(Be.nodeName){const _n=lt(Be.nodeName);if(!z[_n]||te[_n])throw fc("root node is forbidden and cannot be sanitized in-place")}}else if(Be instanceof d)we=_s("<!---->"),qe=we.ownerDocument.importNode(Be,!0),qe.nodeType===hc.element&&qe.nodeName==="BODY"||qe.nodeName==="HTML"?we=qe:we.appendChild(qe);else{if(!$e&&!De&&!Le&&Be.indexOf("<")===-1)return N&&me?N.createHTML(Be):Be;if(we=_s(Be),!we)return $e?null:me?$:""}we&&ae&&mn(we.firstChild);const ct=Bn(Se?Be:we);for(;St=ct.nextNode();)Z(St),Ot(St),St.content instanceof i&&Xt(St.content);if(Se)return Be;if($e){if(ot)for(It=O.call(we.ownerDocument);we.firstChild;)It.appendChild(we.firstChild);else It=we;return(se.shadowroot||se.shadowrootmode)&&(It=R.call(r,It,!0)),It}let wn=Le?we.outerHTML:we.innerHTML;return Le&&z["!doctype"]&&we.ownerDocument&&we.ownerDocument.doctype&&we.ownerDocument.doctype.name&&Yn(LS,we.ownerDocument.doctype.name)&&(wn="<!DOCTYPE "+we.ownerDocument.doctype.name+`>
523
- `+wn),De&&Hu([L,D,W],_n=>{wn=uc(wn,_n," ")}),N&&me?N.createHTML(wn):wn},n.setConfig=function(){let Be=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};$n(Be),Ee=!0},n.clearConfig=function(){Vt=null,Ee=!1},n.isValidAttribute=function(Be,ee,we){Vt||$n({});const qe=lt(Be),St=lt(ee);return Oe(qe,St,we)},n.addHook=function(Be,ee){typeof ee=="function"&&dc(A[Be],ee)},n.removeHook=function(Be){return ek(A[Be])},n.removeHooks=function(Be){A[Be]=[]},n.removeAllHooks=function(){A=ik()},n}var gf=MS();function xv(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Xa=xv();function IS(e){Xa=e}const Tc={exec:()=>null};function zt(e,n=""){let s=typeof e=="string"?e:e.source;const r={replace:(o,i)=>{let c=typeof i=="string"?i:i.source;return c=c.replace(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")},V5=/^(?:[ \t]*(?:\n|$))+/,Y5=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Q5=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,dd=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,J5=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,zS=/(?:[*+-]|\d{1,9}[.)])/,DS=zt(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,zS).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(),vv=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,X5=/^[^\n]+/,bv=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Z5=zt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",bv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),eP=zt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,zS).getRegex(),Om="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",yv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,tP=zt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",yv).replace("tag",Om).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),FS=zt(vv).replace("hr",dd).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",Om).getRegex(),nP=zt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",FS).getRegex(),wv={blockquote:nP,code:Y5,def:Z5,fences:Q5,heading:J5,hr:dd,html:tP,lheading:DS,list:eP,newline:V5,paragraph:FS,table:Tc,text:X5},lk=zt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",dd).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",Om).getRegex(),sP={...wv,table:lk,paragraph:zt(vv).replace("hr",dd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",lk).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",Om).getRegex()},rP={...wv,html:zt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",yv).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:Tc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:zt(vv).replace("hr",dd).replace("heading",` *#{1,6} *[^
524
- ]`).replace("lheading",DS).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},oP=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,aP=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,US=/^( {2,}|\\)\n(?!\s*$)/,iP=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Pm=/[\p{P}\p{S}]/u,jv=/[\s\p{P}\p{S}]/u,WS=/[^\s\p{P}\p{S}]/u,lP=zt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,jv).getRegex(),HS=/(?!~)[\p{P}\p{S}]/u,cP=/(?!~)[\s\p{P}\p{S}]/u,dP=/(?:[^\s\p{P}\p{S}]|~)/u,uP=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,BS=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,fP=zt(BS,"u").replace(/punct/g,Pm).getRegex(),mP=zt(BS,"u").replace(/punct/g,HS).getRegex(),GS="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",hP=zt(GS,"gu").replace(/notPunctSpace/g,WS).replace(/punctSpace/g,jv).replace(/punct/g,Pm).getRegex(),pP=zt(GS,"gu").replace(/notPunctSpace/g,dP).replace(/punctSpace/g,cP).replace(/punct/g,HS).getRegex(),gP=zt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,WS).replace(/punctSpace/g,jv).replace(/punct/g,Pm).getRegex(),xP=zt(/\\(punct)/,"gu").replace(/punct/g,Pm).getRegex(),vP=zt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),bP=zt(yv).replace("(?:-->|$)","-->").getRegex(),yP=zt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",bP).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Af=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,wP=zt(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Af).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),qS=zt(/^!?\[(label)\]\[(ref)\]/).replace("label",Af).replace("ref",bv).getRegex(),KS=zt(/^!?\[(ref)\](?:\[\])?/).replace("ref",bv).getRegex(),jP=zt("reflink|nolink(?!\\()","g").replace("reflink",qS).replace("nolink",KS).getRegex(),kv={_backpedal:Tc,anyPunctuation:xP,autolink:vP,blockSkip:uP,br:US,code:aP,del:Tc,emStrongLDelim:fP,emStrongRDelimAst:hP,emStrongRDelimUnd:gP,escape:oP,link:wP,nolink:KS,punctuation:lP,reflink:qS,reflinkSearch:jP,tag:yP,text:iP,url:Tc},kP={...kv,link:zt(/^!?\[(label)\]\((.*?)\)/).replace("label",Af).getRegex(),reflink:zt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Af).getRegex()},Yg={...kv,emStrongRDelimAst:pP,emStrongLDelim:mP,url:zt(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},NP={...Yg,br:zt(US).replace("{2,}","*").getRegex(),text:zt(Yg.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gu={normal:wv,gfm:sP,pedantic:rP},pc={normal:kv,gfm:Yg,breaks:NP,pedantic:kP},SP={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ck=e=>SP[e];function jr(e,n){if(n){if(Zn.escapeTest.test(e))return e.replace(Zn.escapeReplace,ck)}else if(Zn.escapeTestNoEncode.test(e))return e.replace(Zn.escapeReplaceNoEncode,ck);return e}function dk(e){try{e=encodeURI(e).replace(Zn.percentDecode,"%")}catch{return null}return e}function uk(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 CP(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 fk(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 EP(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 Of{constructor(n){At(this,"options");At(this,"rules");At(this,"lexer");this.options=n||Xa}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=EP(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
- `),y=g.replace(this.rules.other.blockquoteSetextReplace,`
532
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
533
- ${g}`:g,i=i?`${i}
534
- ${y}`:y;const x=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(y,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,b=v.raw+`
535
- `+r.join(`
536
- `),j=this.blockquote(b);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,b=v.raw+`
537
- `+r.join(`
538
- `),j=this.list(b);c[c.length-1]=j,o=o.substring(0,o.length-h.raw.length)+j.raw,i=i.substring(0,i.length-v.raw.length)+j.raw,r=b.substring(c.at(-1).raw.length).split(`
539
- `);continue}}return{type:"blockquote",raw:o,tokens:c,text:i}}}list(n){let s=this.rules.block.list.exec(n);if(s){let r=s[1].trim();const o=r.length>1,i={type:"list",raw:"",ordered:o,start:o?+r.slice(0,-1):"",loose:!1,items:[]};r=o?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=o?r:"[*+-]");const c=this.rules.other.listItemRegex(r);let d=!1;for(;n;){let f=!1,g="",y="";if(!(s=c.exec(n))||this.rules.block.hr.test(n))break;g=s[0],n=n.substring(g.length);let 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(),b=0;if(this.options.pedantic?(b=2,y=x.trimStart()):v?b=s[1].length+1:(b=s[2].search(this.rules.other.nonSpaceChar),b=b>4?1:b,y=x.slice(b),b+=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(b),S=this.rules.other.hrRegex(b),N=this.rules.other.fencesBeginRegex(b),$=this.rules.other.headingBeginRegex(b),_=this.rules.other.htmlBeginRegex(b);for(;n;){const P=n.split(`
543
- `,1)[0];let O;if(h=P,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)>=b||!h.trim())y+=`
544
- `+O.slice(b);else{if(v||x.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(x)||$.test(x)||S.test(x))break;y+=`
545
- `+h}!v&&!h.trim()&&(v=!0),g+=P+`
546
- `,n=n.substring(P.length+1),x=O.slice(b)}}i.loose||(d?i.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(d=!0));let j=null,k;this.options.gfm&&(j=this.rules.other.listIsTask.exec(y),j&&(k=j[0]!=="[ ] ",y=y.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:g,task:!!j,checked:k,loose:!1,text:y,tokens:[]}),i.raw+=g}const u=i.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let f=0;f<i.items.length;f++)if(this.lexer.state.top=!1,i.items[f].tokens=this.lexer.blockTokens(i.items[f].text,[]),!i.loose){const g=i.items[f].tokens.filter(x=>x.type==="space"),y=g.length>0&&g.some(x=>this.rules.other.anyLine.test(x.raw));i.loose=y}if(i.loose)for(let f=0;f<i.items.length;f++)i.items[f].loose=!0;return i}}html(n){const s=this.rules.block.html.exec(n);if(s)return{type:"html",block:!0,raw:s[0],pre:s[1]==="pre"||s[1]==="script"||s[1]==="style",text:s[0]}}def(n){const s=this.rules.block.def.exec(n);if(s){const r=s[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),o=s[2]?s[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=s[3]?s[3].substring(1,s[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):s[3];return{type:"def",tag:r,raw:s[0],href:o,title:i}}}table(n){var d;const s=this.rules.block.table.exec(n);if(!s||!this.rules.other.tableDelimiter.test(s[2]))return;const r=uk(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(uk(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=CP(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)),fk(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 fk(r,i,r[0],this.lexer,this.rules)}}emStrong(n,s,r=""){let o=this.rules.inline.emStrongLDelim.exec(n);if(!o||o[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(o[1]||o[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const c=[...o[0]].length-1;let d,u,f=c,g=0;const y=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(y.lastIndex=0,s=s.slice(-1*n.length+c);(o=y.exec(s))!=null;){if(d=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!d)continue;if(u=[...d].length,o[3]||o[4]){f+=u;continue}else if((o[5]||o[6])&&c%3&&!((c+u)%3)){g+=u;continue}if(f-=u,f>0)continue;u=Math.min(u,u+f+g);const x=[...o[0]][0].length,h=n.slice(0,c+o.index+x+u);if(Math.min(c,u)%2){const b=h.slice(1,-1);return{type:"em",raw:h,text:b,tokens:this.lexer.inlineTokens(b)}}const 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){At(this,"tokens");At(this,"options");At(this,"state");At(this,"tokenizer");At(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||Xa,this.options.tokenizer=this.options.tokenizer||new Of,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:Gu.normal,inline:pc.normal};this.options.pedantic?(s.block=Gu.pedantic,s.inline=pc.pedantic):this.options.gfm&&(s.block=Gu.gfm,this.options.breaks?s.inline=pc.breaks:s.inline=pc.gfm),this.tokenizer.rules=s}static get rules(){return{block:Gu,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 y;this.options.extensions.startBlock.forEach(x=>{y=x.call({lexer:this},g),typeof y=="number"&&y>=0&&(f=Math.min(f,y))}),f<1/0&&f>=0&&(u=n.substring(0,f+1))}if(this.state.top&&(d=this.tokenizer.paragraph(u))){const f=s.at(-1);r&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=`
555
- `+d.raw,f.text+=`
556
- `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):s.push(d),r=u.length!==n.length,n=n.substring(d.raw.length);continue}if(d=this.tokenizer.text(n)){n=n.substring(d.raw.length);const f=s.at(-1);(f==null?void 0:f.type)==="text"?(f.raw+=`
557
- `+d.raw,f.text+=`
558
- `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):s.push(d);continue}if(n){const f="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(f);break}else throw new Error(f)}}return this.state.top=!0,s}inline(n,s=[]){return this.inlineQueue.push({src:n,tokens:s}),s}inlineTokens(n,s=[]){var d,u,f;let r=n,o=null;if(this.tokens.links){const g=Object.keys(this.tokens.links);if(g.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)g.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,o.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i=!1,c="";for(;n;){i||(c=""),i=!1;let g;if((u=(d=this.options.extensions)==null?void 0:d.inline)!=null&&u.some(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 y=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(b=>{v=b.call({lexer:this},h),typeof v=="number"&&v>=0&&(x=Math.min(x,v))}),x<1/0&&x>=0&&(y=n.substring(0,x+1))}if(g=this.tokenizer.inlineText(y)){n=n.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(c=g.raw.slice(-1)),i=!0;const 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 Pf{constructor(n){At(this,"options");At(this,"parser");this.options=n||Xa}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-'+jr(o)+'">'+(r?i:jr(i,!0))+`</code></pre>
560
- `:"<pre><code>"+(r?i:jr(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+" "+jr(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>${jr(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=dk(n);if(i===null)return o;n=i;let c='<a href="'+n+'"';return s&&(c+=' title="'+jr(s)+'"'),c+=">"+o+"</a>",c}image({href:n,title:s,text:r}){const o=dk(n);if(o===null)return jr(r);n=o;let i=`<img src="${n}" alt="${r}"`;return s&&(i+=` title="${jr(s)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:jr(n.text)}}class Nv{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){At(this,"options");At(this,"renderer");At(this,"textRenderer");this.options=n||Xa,this.options.renderer=this.options.renderer||new Pf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Nv}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 Rc{constructor(n){At(this,"options");At(this,"block");this.options=n||Xa}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}}At(Rc,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class $P{constructor(...n){At(this,"defaults",xv());At(this,"options",this.setOptions);At(this,"parse",this.parseMarkdown(!0));At(this,"parseInline",this.parseMarkdown(!1));At(this,"Parser",Us);At(this,"Renderer",Pf);At(this,"TextRenderer",Nv);At(this,"Lexer",Fs);At(this,"Tokenizer",Of);At(this,"Hooks",Rc);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 Pf(this.defaults);for(const c in r.renderer){if(!(c in i))throw new Error(`renderer '${c}' does not exist`);if(["options","parser"].includes(c))continue;const d=c,u=r.renderer[d],f=i[d];i[d]=(...g)=>{let y=u.apply(i,g);return y===!1&&(y=f.apply(i,g)),y||""}}o.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new Of(this.defaults);for(const c in r.tokenizer){if(!(c in i))throw new Error(`tokenizer '${c}' does not exist`);if(["options","rules","lexer"].includes(c))continue;const d=c,u=r.tokenizer[d],f=i[d];i[d]=(...g)=>{let y=u.apply(i,g);return y===!1&&(y=f.apply(i,g)),y}}o.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new Rc;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];Rc.passThroughHooks.has(c)?i[d]=g=>{if(this.defaults.async)return Promise.resolve(u.call(i,g)).then(x=>f.call(i,x));const y=u.call(i,g);return f.call(i,y)}:i[d]=(...g)=>{let y=u.apply(i,g);return y===!1&&(y=f.apply(i,g)),y}}o.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,c=r.walkTokens;o.walkTokens=function(d){let u=[];return u.push(c.call(this,d)),i&&(u=u.concat(i.call(this,d))),u}}this.defaults={...this.defaults,...o}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,s){return 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 y=f(g,c);return c.hooks&&(y=c.hooks.postprocess(y)),y}catch(g){return d(g)}}}onError(n,s){return r=>{if(r.message+=`
578
- Please report this to https://github.com/markedjs/marked.`,n){const o="<p>An error occurred:</p><pre>"+jr(r.message+"",!0)+"</pre>";return s?Promise.resolve(o):o}if(s)return Promise.reject(r);throw r}}}const Ua=new $P;function Mt(e,n){return Ua.parse(e,n)}Mt.options=Mt.setOptions=function(e){return Ua.setOptions(e),Mt.defaults=Ua.defaults,IS(Mt.defaults),Mt};Mt.getDefaults=xv;Mt.defaults=Xa;Mt.use=function(...e){return Ua.use(...e),Mt.defaults=Ua.defaults,IS(Mt.defaults),Mt};Mt.walkTokens=function(e,n){return Ua.walkTokens(e,n)};Mt.parseInline=Ua.parseInline;Mt.Parser=Us;Mt.parser=Us.parse;Mt.Renderer=Pf;Mt.TextRenderer=Nv;Mt.Lexer=Fs;Mt.lexer=Fs.lex;Mt.Tokenizer=Of;Mt.Hooks=Rc;Mt.parse=Mt;Mt.options;Mt.setOptions;Mt.use;Mt.walkTokens;Mt.parseInline;Us.parse;Fs.lex;let xc;const _P=e=>(xc||(gf.addHook("uponSanitizeElement",(n,s)=>{xc??(xc=s.allowedTags)}),gf.sanitize("<b></b>"),gf.removeHook("uponSanitizeElement")),(xc==null?void 0:xc[e.toLowerCase()])===!0),TP=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");Mt.use({breaks:!0,renderer:{html:({text:e,block:n})=>{let s=0;const r=e.replace(/<\/?([A-Za-z][\w:-]*)[^<>]*>/g,(o,i)=>_P(i)?(s++,o):TP(o));return n&&!s&&r!==e?`<p>${r.trim().replace(/\n/g,`<br>
579
- `)}</p>
580
- `:r}}});const ea=e=>e.slice(-8),ud=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 Wa(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const VS=e=>e.basis==="estimate",eo=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Lf=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,mk=(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.`,RP=new Set(["completed","failed","cancelled"]),Ha=e=>typeof e=="string"&&RP.has(e),AP="$0 · free model",YS=e=>e.usd===0&&e.free===!0,QS=e=>e.upper_bound===!0?"at most ":"",OP=(e,{ended:n=!1}={})=>e.usd!==null?`${QS(e)}${eo(e.usd)}`:typeof e.so_far_usd=="number"?n?`${Lf(e.so_far_usd)} known, ${e.unpriced??0} not priced`:`so far ${Lf(e.so_far_usd)}, ${e.unpriced??0} not priced`:"not priced";function to(e,{ended:n=!1}={}){const s=fd(e);if(s&&(e==null?void 0:e.usd)===0)return`${JS(s.tokens)} tokens · Using ChatGPT plan`;const r=PP(e,n);return s?`${r} + ChatGPT plan`:r}function PP(e,n){const s=kl(e),r=o=>VS(o)?" est.":"";return s?n?`${Lf(s.so_far_usd)}${r(s)} known · ${s.unpriced} not priced`:`so far ${Lf(s.so_far_usd)}${r(s)} · ${s.unpriced} not priced`:!e||e.usd===null?"Unknown":YS(e)?AP:`${QS(e)}${eo(e.usd)}${r(e)}`}const fd=e=>e!=null&&e.plan&&e.plan.requests>0?e.plan:void 0;function JS(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 hk(e,n,{ended:s=!1,text:r}={}){const o=r??to(e,{ended:s});return typeof n!="number"?o:(r!==void 0?LP.test(r):!kl(e)&&!fd(e)&&!!e&&e.usd!==null&&!YS(e))?`${o} of ${pk(n)}`:`${o} · cap ${pk(n)}`}const LP=/^<?\$[\d.,]+( est\.)?$/;function pk(e){for(let n=2;n<8;n++)if(Number(e.toFixed(n))===e)return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}function MP(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 no(e,n){const s=gf.sanitize(Mt.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&&MP(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 Sv=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))},IP=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 Cn(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()||IP(n.slice(s))}function zP(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 XS=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,ZS=e=>e.refused===!0,e2=e=>e.tool_status==="failed"&&!ZS(e)||e.kind==="error",DP=e=>e.paused===!0;function FP(e){const n=new Map(e.filter(f=>f.kind==="tool_result"&&f.tool_use_id).map(f=>[f.tool_use_id,f])),s=new Set(e.filter(f=>f.kind==="tool_use"&&f.tool_use_id).map(f=>f.tool_use_id)),r=new Set(e.filter(f=>f.kind==="waiting"&&f.id.endsWith(":waiting")).map(f=>f.id.slice(0,-8))),o=f=>{var g;return r.has(f.id)||(f.tool_use_id?r.has(((g=n.get(f.tool_use_id))==null?void 0:g.id)??""):!1)},i=e.findLast(f=>f.kind==="usage"),c=[],d=new Map;let u;for(const f of e){if(f.kind==="usage")continue;if(f.tool_name==="ask_person"&&(f.kind==="tool_use"||f.kind==="tool_result")&&o(f)){u=void 0;continue}if(f.kind==="tool_result"&&f.tool_use_id&&s.has(f.tool_use_id)){u=d.get(f.tool_use_id);continue}if(f.kind==="phase"&&f.path&&u&&(u.row.kind==="tool_result"||u.row.kind==="tool_use")&&!u.saved){u.saved=f.path;continue}const g=c.at(-1);if(f.kind==="error"&&(g==null?void 0:g.row.kind)==="error"&&g.row.summary===f.summary&&g.row.text===f.text&&(g.row.agent_label??null)===(f.agent_label??null)){g.times=(g.times??1)+1,g.until=f.timestamp,u=g;continue}let y;const 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),b=x.tool_status!==null;y={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}:{}},...b?{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 y={row:f};c.push(y),f.kind==="tool_use"&&f.tool_use_id&&d.set(f.tool_use_id,y),u=y}return i&&c.push({row:i}),c}class ze extends Error{constructor(s,r,o,i=!1,c){super(o);At(this,"fields");At(this,"retryAfterMs");At(this,"details");At(this,"problems");this.status=s,this.code=r,this.retryable=i,this.requestId=c,this.name="ClientError"}toApiError(){return{code:this.code,message:this.message,retryable:this.retryable,request_id:this.requestId,...this.details?{details:this.details}:{}}}}const Wt=e=>e instanceof ze?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),gk=(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}`},UP=new Set(["/auth/sign-in","/setup"]);function WP({fetch:e=globalThis.fetch.bind(globalThis),base:n="/v2",onSignedOut:s}={}){async function r(v,b,j={}){return(await o(v,b,j)).body}async function o(v,b,{body:j,headers:k={},signal:E,text:S=!1}={}){var P;const N=j!==void 0||v!=="GET"&&v!=="HEAD",$=await e(`${n}${b}`,{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&&!UP.has(b)&&(s==null||s());const O=(P=await $.json().catch(()=>null))==null?void 0:P.error,M=new ze($.status,(O==null?void 0:O.code)??"http_error",(O==null?void 0:O.message)??`${v} ${b}: ${$.status}`,(O==null?void 0:O.retryable)??!1,O==null?void 0:O.request_id);throw O!=null&&O.fields&&(M.fields=O.fields),typeof(O==null?void 0:O.retry_after_ms)=="number"&&(M.retryAfterMs=O.retry_after_ms),O!=null&&O.details&&typeof O.details=="object"&&!Array.isArray(O.details)&&(M.details=O.details),Array.isArray(O==null?void 0:O.problems)&&(M.problems=O.problems),M}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,b,j)=>`${i(v)}/learning/workflows/${encodeURIComponent(b)}/revisions/${encodeURIComponent(j)}/replays`,u=v=>`/settings/mcp-servers/${encodeURIComponent(v)}`,f=v=>`/triggers/${encodeURIComponent(v)}`,g=new Map,y=(v,b)=>`${i(v)}/learning/files/${encodeURIComponent(b)}`,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,b,j=!1)=>r("POST","/setup",{body:{password:v,...b?{code:b}:{},...j?{import:!0}:{}}}),setupImport:()=>r("GET","/setup/import").then(v=>(v==null?void 0:v.offer)===!1?null:v,v=>{if(v instanceof ze&&(v.status===404||v.status===403))return null;throw v}),signOut:()=>r("POST","/auth/sign-out",{body:{}}),signOutEverywhere:()=>r("POST","/auth/sign-out-everywhere",{body:{}}),stats:()=>r("GET","/stats"),listRuns:(v=50,b,j)=>r("GET",`/runs${gk(v,b,j)}`),listAgentRuns:(v,b=50,j,k={})=>r("GET",`${i(v)}/runs${gk(b,j,typeof k=="boolean"?{archived:k}:k)}`),discoverNative:(v,b)=>r("POST","/native/discover",{body:{project:v,...b?{runtime:b}:{}}}),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:b}={},j)=>{const k=new URLSearchParams({days:String(v)});return b&&k.set("session_id",b),r("GET",`/observations?${k}`,{signal:j})},listConnectors:()=>r("GET","/connectors"),enrollConnector:(v,b)=>r("POST","/connectors/enrollment",{body:{...v!=null&&v.trim()?{label:v.trim()}:{},...b?{capabilities:b}:{}}}),revokeConnector:v=>r("DELETE",`/connectors/${encodeURIComponent(v)}`),listAgents:({archived:v=!1,cursor:b}={})=>{const j=new URLSearchParams;return v&&j.set("archived","true"),b&&j.set("cursor",b),r("GET",`/agents${j.size?`?${j}`:""}`)},getAgent:async v=>{const b=await o("GET",i(v)),j=g.get(v);return{agent:j&&j.revision===b.body.revision&&!b.body.warnings?{...b.body,warnings:j.warnings}:b.body,etag:b.etag}},createAgent:async v=>{var j;const b=await r("POST","/agents",{body:v});return(j=b.warnings)!=null&&j.length&&g.set(b.agent_id,{revision:b.revision,warnings:b.warnings}),b},updateDefinition:async(v,b,j)=>{const k=await o("PUT",`${i(v)}/definition`,{body:b,headers:j?{"if-match":j}:{}});return g.delete(v),{agent:k.body,etag:k.etag}},listRevisions:(v,b)=>r("GET",`${i(v)}/revisions${b?`?cursor=${encodeURIComponent(b)}`:""}`),setCurrent:async(v,b)=>{const j=await r("POST",`${i(v)}/current`,{body:{revision:b}});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,b)=>r("GET",`${i(v)}/learning/cost${b?`?limit=${b}`:""}`),learningBatches:v=>r("GET",`${i(v)}/learning/batches`),learningBatch:(v,b)=>r("GET",`${i(v)}/learning/batches/${encodeURIComponent(b)}`),startLearningBatch:(v,b)=>r("POST",`${i(v)}/learning/batches`,{body:b}),cancelLearningBatch:(v,b)=>r("POST",`${i(v)}/learning/batches/${encodeURIComponent(b)}/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,b,j)=>r("GET",`${i(v)}/learning/workflows/${encodeURIComponent(b)}/revisions${j?`?limit=${j}`:""}`),startLearnedWorkflowReplay:(v,b,j)=>r("POST",`${d(v,b,j)}`,{body:{}}),learnedWorkflowReplay:(v,b,j,k)=>r("GET",`${d(v,b,j)}/${encodeURIComponent(k)}`),learningNotes:(v,b)=>r("GET",`${i(v)}/learning/notes?cursor=${encodeURIComponent(b)}`),learningLog:(v,b)=>r("GET",`${i(v)}/learning/log?cursor=${encodeURIComponent(b)}`),readNote:async(v,b)=>x(await o("GET",y(v,b),{headers:h,text:!0})),writeNote:async(v,b,j,k)=>x(await o("PUT",y(v,b),{body:{text:j},headers:{...h,..."etag"in k?{"if-match":k.etag}:{"if-none-match":"*"}},text:!0})),retireNote:async(v,b,j)=>x(await o("POST",`${y(v,b)}/retire`,{body:{},headers:{...h,"if-match":j},text:!0})),approveNote:async(v,b,j)=>x(await o("POST",`${y(v,b)}/approve`,{body:{},headers:{...h,"if-match":j},text:!0})),restoreNote:async(v,b,j)=>x(await o("POST",`${y(v,b)}/restore`,{body:{},headers:{...h,"if-match":j},text:!0})),forgetSignIn:(v,b)=>r("DELETE",`${i(v)}/sign-ins/${encodeURIComponent(b)}`),promoteWorkflow:async(v,b,j)=>{var E;const k=await r("POST",`${i(v)}/learning/workflows/${encodeURIComponent(b)}/promote`,{body:{},headers:{"idempotency-key":j}});return(E=k.warnings)!=null&&E.length&&g.set(k.agent_id,{revision:k.revision,warnings:k.warnings}),k},getRun: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,b)=>r("POST",`${c(v)}/computer/hand-back`,{body:b?{outcome:b}:{}}),archiveRun:v=>r("POST",`${c(v)}/archive`,{body:{}}),unarchiveRun:v=>r("POST",`${c(v)}/unarchive`,{body:{}}),raiseCap:(v,b)=>r("PATCH",c(v),{body:{max_cost_usd:b}}),gradeRun:(v,b)=>r("PUT",`${c(v)}/grade`,{body:b}),startRun:async(v,b,j)=>{const k=await o("POST",`${i(v)}/runs`,{body:b,headers:{"idempotency-key":j}});return{run:k.body,status:k.status}},getTimeline:(v,{after:b,waitMs:j,signal:k}={})=>{const E=new URLSearchParams;return b!==void 0&&E.set("after",String(b)),j!==void 0&&E.set("wait_ms",String(j)),r("GET",`${c(v)}/timeline${E.size?`?${E}`:""}`,{signal:k})},listFiles:v=>r("GET",`${c(v)}/files`),deleteUpload:v=>r("DELETE",`/files/${encodeURIComponent(v)}`),readFile:(v,b)=>r("GET",`${c(v)}/files/${b.split("/").map(encodeURIComponent).join("/")}`,{text:!0}),sendMessage:(v,b,j)=>r("POST",`${c(v)}/messages`,{body:{content:b},headers:{"idempotency-key":j}}),getRunGraph:(v,b)=>r("GET",`${c(v)}/graph`,{signal:b}),pauseRun:v=>r("POST",`${c(v)}/pause`,{body:{}}),resumeRun:v=>r("POST",`${c(v)}/resume`,{body:{}}),validateWorkflow:(v,b)=>r("POST","/workflows/validate",{body:v,signal:b}),statsOver:({from:v,agent:b})=>{const j=new URLSearchParams;return v&&j.set("from",v),b&&j.set("agent",b),r("GET",`/stats${j.size?`?${j}`:""}`)},fileUrl:(v,b)=>`${n}${c(v)}/files/${b.split("/").map(encodeURIComponent).join("/")}`,listToolKeys:()=>r("GET","/settings/tool-keys"),saveToolKey:(v,b)=>r("PUT",`/settings/tool-keys/${encodeURIComponent(v)}`,{body:{values:b}}),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,b)=>r("PUT",`/computers/${encodeURIComponent(v)}/keys`,{body:b}),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,b)=>r("POST","/triggers",{body:v,headers:{"idempotency-key":b}}),rotateTriggerSecret:v=>r("POST",`${f(v)}/secret`),updateTrigger:(v,b)=>r("PATCH",f(v),{body:b}),deleteTrigger:v=>r("DELETE",f(v)),fireTrigger:(v,b)=>r("POST",`${f(v)}/fire`,{body:{},headers:{"idempotency-key":b}}),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,b,j)=>r("POST",`/templates/${encodeURIComponent(v)}/apply`,{body:b,headers:{"idempotency-key":j}}),importTemplate:(v,b={})=>r("POST","/templates/import",{body:{source:v,...b.dryRun?{dry_run:!0}:{},...b.trustPublisher?{trust_publisher:!0}:{}}}),deleteTemplate:v=>r("DELETE",`/templates/${encodeURIComponent(v)}`),listMcpServers:()=>r("GET","/settings/mcp-servers"),previewMcpServer:(v,b,j)=>r("POST","/settings/mcp-servers/preview",{body:{url:v,auth:b,...j?{name:j}:{}}}),saveMcpServer:(v,b,j,k={})=>r("PUT",u(v),{body:{url:b,auth:j,...k}}),composioTools:(v,b)=>r("POST","/settings/mcp-servers/composio/tools",{body:{api_key:v,toolkit:b}}),saveComposioServer:(v,b,j,k)=>r("PUT",`${u(v)}/composio`,{body:{api_key:b,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,b)=>r("POST",`${u(v)}/oauth/start`,{body:b}),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,b,j,k,E)=>r("POST",`${c(v)}/approvals/${encodeURIComponent(b)}`,{body:{decision:j,...k?{note:k}:{},...E?{confirm_destructive:!0}:{}}}),cancel:v=>r("POST",`${c(v)}/cancel`,{body:{}})}}async function Kr(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 t2(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=zP(d,g)),r==null||r(g),s==null||s(d),g.final&&!g.has_more))break;u=g.next_after;const y=Math.max(c,g.unchanged?g.poll_after_ms??0:0);y&&await new Promise(x=>setTimeout(x,y))}return f}const xk=e=>`#/observations/${encodeURIComponent(e)}`,Mf=e=>e==="claude"?"Claude Code":e==="codex"?"Codex":e;function Sa(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 Qg=e=>{const n=Sa(e);return n==="Running"?"success":["Needs input","Disconnected","Failed"].includes(n)?"warning":"muted"},Ca=e=>e==null?"—":e.toLocaleString("en-US");function Cv(e,{active:n=!0,days:s=30,sessionId:r}={}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,y]=p.useState(!1);return p.useEffect(()=>{i(null),d(null)},[e,n,s,r]),p.useEffect(()=>{let x=!0;if(!n||typeof e.observations!="function"){y(!1);return}let h=null,v,b;const j=async()=>{if(!x||h)return;clearTimeout(v);const E=h=new AbortController,S=()=>x&&h===E;y(!0);const N=()=>{clearTimeout($),S()&&(h=null,b=void 0,y(!1),clearTimeout(v),v=setTimeout(k,15e3))},$=b=setTimeout(()=>{S()&&(d("The observation read timed out. Try refreshing again."),E.abort(),N())},3e4);try{const _=await e.observations({days:s,sessionId:r},E.signal);S()&&(i(_),d(null))}catch(_){S()&&(_ instanceof ze&&_.status===404?(i(null),d(null)):d(Wt(_)))}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(b),h==null||h.abort(),h=null,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[e,n,s,r,u]),{data:o,error:c,loading:g,refresh:()=>f(x=>x+1)}}function Ev({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(qx,{className:"size-4","aria-hidden":!0}),"Observed sessions"]}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"Agents running in their original applications. Activity refreshes every 15 seconds."})]}),t.jsx(B,{size:"icon","aria-label":"Refresh observed sessions",disabled:e.loading,onClick:c,children:t.jsx(Yo,{className:"size-4","aria-hidden":!0})})]}),d&&t.jsx(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=>Sa(f)==="Running").length],["Needs input",u.filter(f=>Sa(f)==="Needs input").length],["Disconnected",u.filter(f=>Sa(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(n2,{usage:o.usage}),t.jsx(HP,{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:xk(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(Ne,{children:Mf(f.harness)}),t.jsx(Ne,{tone:Qg(f),children:Sa(f)}),t.jsx(Ne,{tone:"muted",children:"Observed"})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:f.models.join(", ")||"Model not reported"}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Session ",f.id.slice(0,8)," · Last received ",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(Ne,{tone:Qg(f),children:Sa(f)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("a",{href:xk(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:Mf(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"?"—":Ca(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 n2({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",Ca(e.input_tokens)],["Output",Ca(e.output_tokens)],["Cache writes",Ca(e.cache_write_tokens)],["Cache reads",Ca(e.cache_read_tokens)],["Total tokens",Ca(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 HP({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:Ca(s)},r))]},n.model))})]})}):null}function BP({v2:e,sessionId:n,go:s}){var i;const r=Cv(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(An,{"aria-hidden":!0})}),t.jsx(qx,{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(Yo,{"aria-hidden":!0})})]}),t.jsxs("main",{className:"mx-auto w-full max-w-page space-y-6 p-5 md:p-8",children:[r.error&&t.jsxs(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(Ne,{tone:"muted",children:"Observed"}),t.jsx(Ne,{tone:Qg(o),children:Sa(o)}),t.jsx(Ne,{children:Mf(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",Mf(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(n2,{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 $v(e,n={}){const s=new URLSearchParams({operation:"list-runs"});return e&&s.set("agent",e),n.status&&s.set("status",n.status),n.archived&&s.set("archived","true"),`#/playground?${s}`}const Qt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),GP=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),Jg=128,qP=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},Xg=(e,n=0)=>n>Jg?'"…"':Array.isArray(e)?`[${e.map(s=>Xg(s,n+1)).join(",")}]`:Qt(e)?`{${Object.keys(e).filter(s=>e[s]!==void 0).sort().map(s=>`${JSON.stringify(s)}:${Xg(e[s],n+1)}`).join(",")}}`:qP(e),KP=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)),VP=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 Qt(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([n,s])=>[n,Qt(s)?vc(s,"body"):s]))}:e;case"workflow":return Qt(e.workflow)?{...e,workflow:vc(e.workflow,"root")}:e;default:return e}};function il(e){const n=[],s=[],r=(o,i,c,d)=>{if(!Qt(o)||typeof o.node!="string"||c>Jg)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:KP(Xg(VP(o))),...QP(o,d)});const u=(f,g,y,x=i,h=d)=>{!Qt(f)||typeof f.node!="string"||c+1>Jg||(s.push({from:x,to:g,kind:y}),r(f,g,c+1,h))};switch(o.node){case"chain":Array.isArray(o.steps)&&o.steps.forEach((f,g)=>u(f,`${i}/steps/${g}`,"next",g===0?i:`${i}/steps/${g-1}`));break;case"parallel":Array.isArray(o.branches)&&o.branches.forEach((f,g)=>u(f,`${i}/branches/${g}`,"branch"));break;case"map":u(o.body,`${i}/body`,"item");break;case"loop":u(o.body,`${i}/body`,"next");break;case"route":if(Qt(o.branches))for(const[f,g]of Object.entries(o.branches))Qt(g)&&u(g.body,`${i}/branches/${GP(f)}/body`,"route");break;case"workflow":Qt(o.workflow)&&u(o.workflow.root,`${i}/workflow/root`,"child",i,Qt(o.workflow.schemas)?o.workflow.schemas:{});break}};return r(Qt(e)?e.root:void 0,"/root",0,Qt(e)&&Qt(e.schemas)?e.schemas:{}),{nodes:n,edges:s}}const YP=(e,n)=>{const s=typeof e=="string"&&Object.hasOwn(n,e)?n[e]:void 0,r=i=>{var c;for(let d=0;Qt(i)&&typeof i.$ref=="string"&&d<8;d+=1){const u=(c=/^#\/definitions\/(.+)$/.exec(i.$ref))==null?void 0:c[1],f=Qt(s)&&Qt(s.definitions)?s.definitions:{};i=u===void 0?void 0:Object.hasOwn(f,u)?f[u]:Object.hasOwn(n,u)?n[u]:void 0}return i},o=r(s);return!Qt(o)||!Qt(o.properties)?[]:Object.entries(o.properties).map(([i,c])=>{const d=r(c),u=Qt(d)&&typeof d.description=="string"?d.description:"",f=Qt(d)?(Array.isArray(d.type)?d.type:[d.type]).filter(g=>g!=="null"):[];return Qt(d)&&Array.isArray(d.enum)?{id:i,type:"choice",instructions:u,options:d.enum.map(String)}:f.length===1&&f[0]==="boolean"?{id:i,type:"noul",instructions:u}:f.length===1&&f[0]==="integer"?{id:i,type:"score",instructions:u}:{id:i,type:"unknown",instructions:u}})},QP=(e,n)=>{let s=e,r;const o=i=>typeof i=="string"?i:"";switch(e.node){case"judge":case"sift":r=YP(e.out,n);break;case"pick":r=[{id:"pick",type:"choice",instructions:o(e.instructions)}];break;case"route":if(e.valuePath!==void 0)return{};r=[{id:"branch",type:"choice",instructions:o(e.instructions),options:Qt(e.branches)?Object.keys(e.branches):[]}];break;case"loop":case"escalate":{const i=e.node==="loop"?e.until:e.when;if(!Qt(i)||i.predicate!=="ask")return{};s=i,r=[{id:"holds",type:"noul",instructions:o(i.instructions)}];break}default:return{}}return{...typeof s.provider=="string"?{provider:s.provider}:{},...typeof s.model=="string"?{model:s.model}:{},questions:r,...Qt(s.images)&&Object.keys(s.images).length?{images:Object.keys(s.images)}:{}}};function s2(e,n){const s=S=>JSON.stringify([S.kind,S.label]),r=S=>{const N=new Map;for(const $ of S.nodes)N.set(s($),(N.get(s($))??0)+1);return N},[o,i]=[r(e),r(n)],c=S=>o.get(s(S))===1&&i.get(s(S))===1,d=new Map,u=new Map,f=(S,N)=>{d.set(N,S),u.set(S,N)},g=new Map(e.nodes.filter(c).map(S=>[s(S),S.path]));for(const S of n.nodes){const N=c(S)?g.get(s(S)):void 0;N!==void 0&&f(N,S.path)}const y=new Map(e.nodes.map(S=>[S.path,S])),x=[];for(const S of n.nodes){const N=y.get(S.path);d.has(S.path)||N===void 0||u.has(N.path)||(f(N.path,S.path),(N.kind!==S.kind||N.label!==S.label)&&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:y.get(N);$===void 0||$.kind!==S.kind||$.label!==S.label||$.changeCheck!==void 0&&S.changeCheck!==void 0&&$.changeCheck!==S.changeCheck&&h.push({prev:$.path,next:S.path,kind:S.kind,label:S.label})}const v=({path:S,kind:N,label:$})=>({path:S,kind:N,label:$}),b=(S,N,$)=>JSON.stringify([S,N,$]),j=new Set(e.edges.map(S=>b(S.from,S.to,S.kind))),k=new Set(n.edges.map(S=>b(S.from,S.to,S.kind))),E=(S,N,$)=>{const[_,P]=[N.get(S.from),N.get(S.to)];return _!==void 0&&P!==void 0&&$.has(b(_,P,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 gn({className:e}){return t.jsx("span",{"aria-hidden":!0,className:ie("block bg-muted motion-safe:animate-pulse",e)})}function Lm({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 JP(){return t.jsxs(Lm,{label:"Loading Mission Control",className:"space-y-8 p-5 md:p-8",children:[t.jsx(gn,{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(gn,{className:"h-3 w-16"}),t.jsx(gn,{className:"mt-3 h-6 w-12"})]},n))}),t.jsx(gn,{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(If,{n:4}),t.jsx(If,{n:6})]})]})}function If({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(gn,{className:"h-4 w-20"}),t.jsx(gn,{className:"h-4 flex-1"}),t.jsx(gn,{className:"hidden h-4 w-24 sm:block"})]},s))})}function Un({label:e,rows:n=8}){return t.jsx(Lm,{label:e,children:t.jsx(If,{n})})}function XP(){return t.jsxs(Lm,{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(gn,{className:"h-4 w-24"}),t.jsx(gn,{className:"h-7 w-2/3"}),t.jsx(gn,{className:"h-3 w-1/3"})]}),t.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,n)=>t.jsx(gn,{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(gn,{className:"size-4 shrink-0"}),t.jsx(gn,{className:ie("h-4",n%2?"w-1/2":"w-3/4")})]},n))})]})}function ZP(){return t.jsxs(Lm,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(gn,{className:"h-7 w-64"}),t.jsx(gn,{className:"h-3 w-80 max-w-full"})]}),t.jsx(gn,{className:"h-12 w-full"}),t.jsx(If,{n:5})]})}function Jt({problem:e,onRetry:n,link:s,className:r="m-8"}){return t.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${r}`,role:"alert",children:[t.jsx(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 r2({what:e,id:n,list:s}){return t.jsx(Jt,{problem:{title:`No ${e} with this id.`,why:`This server has no ${e} ${n}.`,next:`Check the address, or find the ${e} in the list.`},link:s})}class Zg extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const ex=e=>Math.min(1e4,1e3*2**e),vk=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),eL=e=>(e==null?void 0:e.name)==="AbortError",bk=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function tL({fetch:e=(o,i)=>globalThis.fetch(o,i),probe:n="/v2/health",resumedMs:s=5e3,probeMs:r=5e3}={}){let o={state:"online"};const i=new Set,c=new Set;let d=[],u,f=null,g=null;const y=N=>{o=N;for(const $ of[...i])$()},x=N=>{const $=ex(N);clearTimeout(u),y({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),y({state:"resumed"});const N=d;d=[];for(const $ of N)$();for(const $ of[...c])$();u=setTimeout(()=>{o.state==="resumed"&&y({state:"online"})},s)};async function b(N){const $=setTimeout(()=>N.abort(),r);try{return!vk(await e(n,{method:"GET",cache:"no-store",credentials:"same-origin",signal:N.signal}))}catch{return!1}finally{clearTimeout($)}}async function j(){if(o.state!=="offline")return;clearTimeout(u),f==null||f.abort();const N=f=new AbortController,$=await b(N);f===N&&(f=null,o.state==="offline"&&($?v():x(o.attempt+1)))}const k=()=>g??(g=b(new AbortController).finally(()=>{g=null})),E=N=>new Promise(($,_)=>{if(N!=null&&N.aborted)return _(bk(N));const P=()=>{d=d.filter(M=>M!==O),_(bk(N))},O=()=>{N==null||N.removeEventListener("abort",P),$()};d.push(O),N==null||N.addEventListener("abort",P,{once:!0})});return{fetch:async(N,$)=>{var O;const _=(($==null?void 0:$.method)??"GET").toUpperCase(),P=_==="GET"||_==="HEAD";for(let M=0;;M++){let R,A;try{R=await e(N,$)}catch(L){if((O=$==null?void 0:$.signal)!=null&&O.aborted||eL(L))throw L;A=L}if(R&&!vk(R))return v(),R;if(o.state!=="offline"&&await k()){if(R)return R;if(!P)throw new Zg;if(M>=2)throw A;await new Promise(L=>setTimeout(L,ex(M)));continue}if(h(),!P)throw new Zg;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 nL=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),o2=e=>e instanceof Zg||e instanceof TypeError&&/fetch|network/i.test(e.message);function Ht(e,n){const s=`${nL(n)} could not be read.`;if(o2(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof ze))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=e.message,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 sL(e){return o2(e)?"Can't reach agentrun-serve":e instanceof ze?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}function rL({agent:e,v2:n}){const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,y]=p.useState(null),x=p.useRef(0),h=p.useRef(!1),v=async b=>{if(h.current)return;h.current=!0;const j=++x.current;f(!0);try{const k=await n.listRevisions(e.agent_id,b);if(j!==x.current)return;r(E=>{const S=new Map((b?E??[]:[]).map(N=>[N.revision,N]));for(const N of k.revisions)S.set(N.revision,N);return[...S.values()]}),i(k.next_cursor),d(null)}catch(k){j===x.current&&d(Ht(k,b?"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),y(null),v(null),()=>{x.current++,h.current=!1}),[n,e.agent_id,e.revision,e.revisions]),c&&!s?t.jsx(Jt,{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(b=>t.jsx("th",{className:"px-4 py-3 font-semibold",children:b},b))})}),t.jsx("tbody",{children:s.map(b=>t.jsxs(p.Fragment,{children:[t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsxs("td",{className:"whitespace-nowrap px-4 py-3",children:[t.jsxs("span",{className:"font-semibold",children:["v",b.version]}),b.revision===e.revision&&t.jsx("span",{className:"ml-2 bg-primary/10 px-2 py-1 text-micro text-primary-text",children:"Current"})]}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:ht(b.created_at)}),t.jsx("td",{className:"min-w-40 px-4 py-3 text-muted-foreground",children:b.note||"—"}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(B,{size:"sm","aria-expanded":g===b.revision,"aria-label":`View configuration for version ${b.version}`,onClick:()=>y(j=>j===b.revision?null:b.revision),children:g===b.revision?"Hide":"View"})})]}),g===b.revision&&t.jsx("tr",{className:"border-b bg-card",children:t.jsxs("td",{colSpan:4,className:"p-4",children:[t.jsx("p",{className:"mb-3 break-all font-mono text-label text-muted-foreground",children:b.revision}),t.jsx("pre",{"aria-label":`Version ${b.version} configuration`,className:"max-h-[520px] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:JSON.stringify(b.definition,null,2)})]})})]},b.revision))})]})}):t.jsx("p",{className:"p-10 text-center text-body text-muted-foreground",children:"No versions were returned for this agent."}),c&&t.jsx(Jt,{problem:c,className:"m-4"}),o&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",disabled:u,onClick:()=>void v(o),children:u?"Loading":"Load more versions"})})]}):t.jsx(Un,{label:"Loading versions",rows:4})}const a2=(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)=>a2({name:n.definition.name||n.agent_id,id:n.agent_id},{name:s.definition.name||s.agent_id,id:s.agent_id}));function oL(e){return e.usd===null?{total:"Unknown"}:{total:to({usd:e.usd,basis:"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}const _v=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],Vi=864e5,tx=e=>Math.floor(e/Vi)*Vi;function Tv(e,n=Date.now()){var r;const s=(r=_v.find(o=>o.id===e))==null?void 0:r.days;return s?new Date(tx(n)-(s-1)*Vi).toISOString():void 0}const i2=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function aL(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 iL(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 l2=(e,n)=>oL({usd:e.cost_usd,unknownRuns:e.unknown_cost_runs}),Rv=e=>e.runs_with_metrics<e.runs?`tokens from ${e.runs_with_metrics} of ${e.runs} runs`:void 0;function Ba(e){return e===null?"Unknown":JS(e)}const zf=e=>e===null?"—":`${Math.round(e*100)}%`;function yk(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function lL(e,n,s=Date.now()){if(!e.length)return[];const r=tx(s),o=Math.max(r-29*Vi,n?tx(Date.parse(n)):r-29*Vi),i=new Map(e.map(d=>[d.day,d])),c=[];for(let d=o;d<=r;d+=Vi){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 cL(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)=>a2({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 c2({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(ld,{label:"Range",name:"mission-range",value:e,onChange:n,size:"sm",options:_v.map(i=>({value:i.id,label:i.label}))}),o&&r.length>0&&t.jsx(Et,{label:"Agent",value:s??"",onChange:i=>o(i||null),className:"h-control-sm w-56",options:[{value:"",label:"All agents"},...r.map(i=>({value:i.agentId,label:i.name}))]})]})}const xf=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function d2({a:e,basis:n,now:s=Date.now(),refreshing:r=!1}){const o=e.totals,i=iL(o),c=i2(o),d=l2(o),u=[{label:"Tokens",value:Ba(o.tokens),notes:[`${i===null?"":`${zf(i)} of input cached · `}${Ba(o.output)} output`,Rv(o),o.requests===null||o.unmetered===null?"Model request counts unavailable":o.unmetered?`${xf(o.unmetered,"request")} with no token count`:void 0]},{label:"Run time",value:yk(e.time.wall_ms),notes:[`wall time of ${xf(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${yk(e.time.active_ms)} active, over ${xf(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:zf(c),notes:[o.completed+o.failed?aL(o):"No run completed or failed yet"]},{label:"Cost",value:d.total,notes:[d.note]}];return t.jsxs("div",{className:ie("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(mL,{days:lL(e.by_day,e.filter.from,s)}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[t.jsx(dL,{rows:e.by_harness_effort,basis:n}),t.jsx(uL,{tools:e.tools})]}),t.jsx(fL,{groups:e.by_source})]})}function Fi({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 u2="px-4 py-2 text-left font-normal",kr="px-4 py-2.5 align-top";function dL({rows:e,basis:n}){return t.jsx(Fi,{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:u2,children:s},s))})}),t.jsx("tbody",{children:e.map(s=>{const r=l2(s),o=Rv(s);return t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:kr,children:s.harness}),t.jsx("td",{className:ie(kr,!s.effort&&"text-muted-foreground"),children:s.effort??"unset"}),t.jsx("td",{className:kr,children:s.runs}),t.jsx("td",{className:kr,children:zf(i2(s))}),t.jsxs("td",{className:kr,children:[t.jsx("span",{className:"whitespace-nowrap",children:Ba(s.tokens)}),o&&t.jsx("span",{className:"block text-label text-muted-foreground",children:o})]}),t.jsxs("td",{className:kr,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 uL({tools:e}){return t.jsx(Fi,{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:u2,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:kr,title:n.tool,children:n.label}),t.jsx("td",{className:kr,children:Ba(n.calls)}),t.jsx("td",{className:ie(kr,n.errors>0&&"text-destructive-text"),children:Ba(n.errors)}),t.jsx("td",{className:kr,children:zf(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 fL({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}`}: ${xf(n.runs,"run")}`).join(" · ")}):null}const cg=e=>Math.max(0,e.runs-e.completed-e.failed);function wk(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 dg=e=>e.slice(5);function mL({days:e}){const n=e.some(d=>d.runs>0),s=t.jsxs(t.Fragment,{children:[t.jsx(gT,{className:"size-4","aria-hidden":!0}),"Run activity"]}),r=t.jsxs(t.Fragment,{children:[t.jsx(kT,{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(Fi,{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(Fi,{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=wk(Math.max(...e.map(d=>d.runs))),i=wk(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:cg}];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(Fi,{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:ie("inline-block size-2.5 ",d.className),"aria-hidden":!0}),d.label]},d.key))]}),t.jsx(jk,{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 · ${cg(d)} other`]})]})}),t.jsx(Fi,{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(jk,{days:e,top:i,label:"Tokens per day",format:Ba,stack:d=>[{className:"bg-primary",value:d.tokens}],readout:d=>[`${Ba(d.tokens)} tokens`,Rv(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:cg(d)}),t.jsx("td",{className:"pr-4",children:d.tokens===null?"Unknown":d.tokens.toLocaleString("en-US")})]},d.day))})]})})]})]})}function jk({days:e,top:n,label:s,stack:r,readout:o,format:i=c=>c.toLocaleString("en-US")}){const[d,u]=p.useState(e.length-1),f=Math.min(d,e.length-1),g=j=>{var E;const k=j.key==="ArrowRight"?Math.min(f+1,e.length-1):j.key==="ArrowLeft"?Math.max(f-1,0):j.key==="Home"?0:j.key==="End"?e.length-1:-1;k<0||(j.preventDefault(),u(k),(E=j.currentTarget.querySelectorAll('[role="listitem"]')[k])==null||E.focus())},[y,x]=p.useState(null),[h,v]=p.useState(null),b=e.find(j=>j.day===(y??h));return t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"flex w-10 shrink-0 flex-col justify-between text-right font-mono text-micro text-muted-foreground",style:{height:140},"aria-hidden":!0,children:[t.jsx("span",{children:i(n)}),t.jsx("span",{children:i(n/2)}),t.jsx("span",{children:"0"})]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"relative flex items-end gap-px border-b border-border-strong",style:{height:140},role:"list","aria-label":s,onMouseLeave:()=>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:dg(e[0].day)}),e.length>2&&t.jsx("span",{children:dg(e[Math.floor(e.length/2)].day)}),t.jsx("span",{children:dg(e.at(-1).day)})]}),t.jsx("div",{"aria-label":`${s} readout`,className:"mt-2 min-h-16 break-words font-mono text-label text-muted-foreground",children:b?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block font-semibold text-foreground",children:o(b)[0]}),o(b).slice(1).map(j=>t.jsx("span",{className:"block",children:j},j)),t.jsx("span",{className:"block",children:b.day})]}):"Hover or focus a day for its figures."})]})]})}const ln=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),vf=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function hL(e){const n=new Map;let s=0;const r=d=>{throw Object.assign(new Error(d),{offset:s})},o=()=>{for(;s<e.length&&`
583
- \r`.includes(e[s]);)s++},i=()=>{const d=s;for(s++;s<e.length&&e[s]!=='"';)e[s]==="\\"?s++:e.charCodeAt(s)<32&&r("a string cannot hold a raw line break or control character"),s++;s>=e.length&&(s=d,r("this string is not closed")),s++;try{return JSON.parse(e.slice(d,s))}catch{return s=d,r("this string has a bad escape")}},c=d=>{o();const u=s;let f;const g=e[s];if(g==="{"){s++;const y={};if(o(),e[s]==="}")s++;else for(;;){o(),e[s]!=='"'&&r(e[s]==="}"?"a trailing comma before }":"expected a key in double quotes");const x=i();if(o(),e[s]!==":"&&r("expected : after the key"),s++,y[x]=c(`${d}/${vf(x)}`),o(),e[s]===","){s++;continue}if(e[s]==="}"){s++;break}r("expected , or } after the value")}f=y}else if(g==="["){s++;const y=[];if(o(),e[s]==="]")s++;else for(;;){if(y.push(c(`${d}/${y.length}`)),o(),e[s]===","){s++,o(),e[s]==="]"&&r("a trailing comma before ]");continue}if(e[s]==="]"){s++;break}r("expected , or ] after the value")}f=y}else if(g==='"')f=i();else{const y=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(e.slice(s,s+400));y||r(s>=e.length?"the text ends before the value":"expected a value"),s+=y[0].length,f=JSON.parse(y[0])}return n.set(d,{start:u,end:s}),f};try{const d=c("");return o(),s<e.length&&r("text after the end of the JSON"),{ok:!0,value:d,spans:n}}catch(d){return{ok:!1,error:{message:d.message,offset:d.offset??0}}}}function pL(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 f2(e,n){let s=e;for(const r of n.split("/").slice(1)){const o=r.replace(/~1/g,"/").replace(/~0/g,"~");if(Array.isArray(s))s=s[Number(o)];else if(ln(s))s=Object.prototype.hasOwnProperty.call(s,o)?s[o]:void 0;else return}return s}const m2=new Set(["judge","pick","sift","route"]),kk=["jev","parallel","openrouter"];function gL(e){return!ln(e)||!ln(e.properties)?[]:Object.entries(e.properties).flatMap(([n,s])=>{if(!ln(s))return[];const r=typeof s.description=="string"?s.description:n;return Array.isArray(s.enum)?[{id:n,type:"choice",text:r,options:s.enum.map(String)}]:s.type==="boolean"?[{id:n,type:"noul",text:r}]:s.type==="integer"?[{id:n,type:"score",text:r}]:[{id:n,type:"choice",text:r}]})}function Av(e,n,s){const r=f2(e,n);if(!ln(r))return{decision:!1};const o=r.node,i=s??{},c=o==="route"&&typeof r.valuePath=="string",d=typeof o=="string"&&m2.has(o)&&!c||Array.isArray(i.questions);if(!d)return{decision:!1,...o==="call"&&typeof r.tool=="string"?{tool:r.tool}:{}};const u=typeof i.provider=="string"?i.provider:typeof r.provider=="string"?r.provider:"jev",f=typeof i.model=="string"?i.model:typeof r.model=="string"?r.model:void 0,g=ln(e)&&ln(e.schemas)?e.schemas:{};let y=[];Array.isArray(i.questions)?y=i.questions.map(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"?y=typeof r.out=="string"?gL(g[r.out]):[]:o==="pick"?y=[{id:"pick",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Pick one"}]:o==="route"&&(y=[{id:"branch",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Which branch?",options:ln(r.branches)?Object.keys(r.branches):[]}]);const x=Array.isArray(i.images)?i.images.map(String):ln(r.images)?Object.keys(r.images):[],h=ln(r.unsure)&&typeof r.unsure.branch=="string"&&typeof r.unsure.gte=="number"?{branch:r.unsure.branch,gte:r.unsure.gte}:void 0;return{decision:d,provider:u,model:f,questions:y,...x.length?{images:x}:{},web:u==="parallel",...h?{unsure:h}:{}}}const xL=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function vL(e){const n=[],s=(d,u)=>n.push({path:d,message:u,severity:"error"}),r=(d,u)=>n.push({path:d,message:u,severity:"warning"});if(!ln(e))return s("","the workflow is a JSON object"),n;e.v!==2&&s("/v",'the workflow format is "v": 2'),(typeof e.name!="string"||!e.name)&&s("/name","the workflow needs a name");const o=ln(e.schemas)?e.schemas:{};ln(e.input)&&typeof e.input.schemaId=="string"&&!o[e.input.schemaId]&&s("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),ln(e.output)?typeof e.output.schemaId=="string"&&!o[e.output.schemaId]&&s("/output/schemaId",`no schema "${e.output.schemaId}" in schemas`):s("",'the workflow needs an output: { "schemaId": ..., "path": ... }');const i=new Map,c=(d,u)=>{if(!ln(d)){s(u,'expected a node (an object with a "node" kind)');return}const f=d.node;if(typeof f!="string"||!xL.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})`)},y=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":ln(d.workflow)?c(d.workflow.root,`${u}/workflow/root`):s(u,"a workflow node embeds its workflow");break;case"call":g("via","tool, executor or shell"),d.via==="tool"&&g("tool","the tool's name");break;case"code":typeof d.code!="string"&&s(u,"a code node needs code");break;case"escalate":g("when","the predicate that fires it"),g("kind","the review it asks for");break;case"judge":case"sift":g("out","the questions' schema"),y("out"),g("as","where the answers go");break;case"pick":g("itemsPath","the options' list"),g("as","where the pick goes");break;case"agent":case"decide":case"extract":y("out");break}if(f==="route"){if(!ln(d.branches)||!Object.keys(d.branches).length)s(u,"a route needs branches");else for(const[x,h]of Object.entries(d.branches))ln(h)?c(h.body,`${u}/branches/${vf(x)}/body`):s(`${u}/branches/${vf(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"),ln(d.unsure)&&ln(d.branches)&&typeof d.unsure.branch=="string"&&!(d.unsure.branch in d.branches)&&s(`${u}/unsure/branch`,`the unsure branch "${d.unsure.branch}" is not one of the branches`)}if(m2.has(f)&&!(f==="route"&&typeof d.valuePath=="string")&&(d.provider!==void 0&&!kk.includes(d.provider)&&r(`${u}/provider`,`provider "${String(d.provider)}" is not one of ${kk.join(", ")}`),d.provider==="openrouter"&&typeof d.model!="string"&&s(u,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),ln(d.images))){const 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/${vf(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 Nk(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 bL(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 yL(e){const n=il(e),r=n.nodes.map(i=>Av(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 Df=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,Sk=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),md=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function hd(e,n){return Object.fromEntries(n.nodes.map(s=>[s.path,Av(e,s.path,s)]))}const qu=e=>e>=.995?"1.00":e.toFixed(2);function ll(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?` ${qu(f)}`:""}`}const r=Object.keys(n);if(!r.length)return;const o=u=>{const f=n[u];return f.type==="choice"?`${h2(e,u,f.choice)} ${qu(f.probabilities[f.choice]??f.confidence)}`:f.type==="noul"?`${f.noul>=.5?"yes":"no"} ${qu(f.noul>=.5?f.noul:1-f.noul)}`:f.type==="score"?`${f.score} ${qu(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 h2(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 p2=(e,n)=>e.nodes.filter(s=>s.path.startsWith(`${n}/body`)).map(s=>s.path);function wL(e,n,s){var y,x;const r=(x=(y=e.nodes[n])==null?void 0:y.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=p2(e.graph,n).filter(h=>!i.has(c.get(h)??""));let u=-1;d.forEach((h,v)=>{const b=e.decisions.filter(k=>k.node===h&&k.item===s),j=e.effects.filter(k=>k.node===h&&k.item===s);!b.length&&!j.length||(u=v,b.some(k=>k.status==="failed")||j.some(k=>k.status==="failed")?o[h]="failed":b.some(k=>k.status==="cancelled")?o[h]="review":j.some(k=>!k.endedAt)?o[h]=j.some(k=>k.status==="stopped")?"stopped":"working":o[h]="done")});const f=Df(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 jL(e,n){var g,y,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 b=Df(v.status);b&&(s[h]=b),v.branch&&r.push(`${h}/branches/${Sk(v.branch)}/body`),v.items&&(o[h]=v.items.map(j=>({index:j.index,status:Df(j.status)??"pending",label:Wc(e,h,j.index),...Ov(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=ll(h);v&&(d[h.node]=v)}if(n&&n.item!=null&&c.get(n.path)==="map"){Object.assign(s,wL(e,n.path,n.item));const h=((x=(y=(g=e.nodes[n.path])==null?void 0:g.items)==null?void 0:y.find(v=>v.index===n.item))==null?void 0:x.branches)??{};for(const[v,b]of Object.entries(h)){const j=`${v}/branches/`,k=`${j}${Sk(b)}/body`;for(let E=r.length-1;E>=0;E--)r[E].startsWith(j)&&r.splice(E,1);r.push(k);for(const E of e.graph.nodes)E.path.startsWith(j)&&!(E.path===k||E.path.startsWith(`${k}/`))&&(s[E.path]="not-run")}for(const v of e.decisions)if(v.node&&v.item===n.item&&v.node.startsWith(`${n.path}/body`)){const b=ll(v);b&&(d[v.node]=b)}}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:hd(e.workflow,e.graph),selected:n,...Object.keys(f).length?{ran:f}:{}}}const ug={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"},kL=e=>{if(!e)return;const n=e.toLowerCase();return ug[n]??ug[n.split(/[_\s-]/)[0]]??ug[n.split(/[_\s-]/).at(-1)??""]};function NL(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 Ov(e,n,s){const r=p2(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?NL(f):void 0,y=s.status==="failed"?"bad":s.status==="needs_review"||s.status==="escalated"?"warn":kL(c);return{...c?{outcome:c}:{},...g?{p:g.p,pNote:g.note}:{},...y?{tone:y}:{}}}function Wc(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 g2(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 x2(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)}`,Yi=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function cl(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 SL=(e,n,s)=>{const r=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||n)-Date.parse(e.run.startedAt);return md(e.run.status)||e.run.paused?r:r+Math.max(0,s-n)};function CL(e,n,s){return e!=="input_required"||n!=="waiting"?null:s.findLast(r=>r.kind==="waiting")??null}function EL(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 v2(e){return e.split("/").slice(0,-1).some(n=>n.startsWith(".")||n==="__pycache__"||n==="node_modules")}const b2="The agent finished without writing an answer.",Ck=[0,250,1e3],$L=e=>new Promise(n=>setTimeout(n,e));function y2(){let e=0;return{begin:()=>++e,current:n=>n===e,cancel:()=>{e++}}}const w2="30d",Ek=10,_L=["queued","working","input_required","paused"];function TL({agent:e,v2:n,now:s=Date.now,stats:r}){const[o,i]=p.useState(w2),[c,d]=p.useState(r??null),[u,f]=p.useState(null),[g,y]=p.useState(!0),[x,h]=p.useState(0),v=p.useRef(0),b=p.useRef(!0);p.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]);const j=p.useRef(null),k=p.useRef(null);p.useEffect(()=>{const S=`${o}/${x}`;if(k.current===S)return;const N=++v.current;if(j.current===S){k.current=null,f(null),y(!1);return}k.current=S,y(!0),f(null),(async()=>{for(const[$,_]of Ck.entries()){if(_&&await $L(_),N!==v.current||!b.current)return;try{const P=await n.statsOver({from:Tv(o,s()),agent:e.agent_id});if(N!==v.current||!b.current)return;const O=!(P.runs.status_unknown>0);if(d(P),j.current=O||$===Ck.length-1?S:null,O)break}catch(P){N===v.current&&f(Wt(P));break}}N===v.current&&(k.current=null,y(!1))})()},[n,e.agent_id,o,x]),p.useEffect(()=>{const S=new AbortController,N=$=>({status:$,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(_L.map($=>n.listAgentRuns(e.agent_id,Ek,null,N($)))).then($=>{if(S.signal.aborted)return;const _=$.flatMap(P=>P.status==="fulfilled"?P.value.runs:[]).filter(P=>!md(P.status));for(const P of _.slice(0,Ek)){let O=`${P.status}/${P.state}`;t2(n,P.run_id,{signal:S.signal,onPage:M=>{const R=`${M.status}/${M.state}`;R!==O&&(O=R,h(A=>A+1))}}).catch(()=>{})}}),()=>S.abort()},[n,e.agent_id]);const E=c==null?void 0:c.analytics;return t.jsxs("div",{className:"space-y-6",children:[t.jsx(c2,{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(d2,{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 Pv=["codex","codex-cli","claude","claude-cli","cursor","other"],j2="agentrun.coding-agent.v1",fg="agentrun:coding-agent",mg={codex:"Codex app","codex-cli":"Codex CLI",claude:"Claude Code app","claude-cli":"Claude Code CLI",cursor:"Cursor",other:"Other / terminal"};function $k(){try{const e=localStorage.getItem(j2);return Pv.includes(e)?e:""}catch{return""}}function RL(e){try{localStorage.setItem(j2,e)}catch{}}function AL(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 OL="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=",PL="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=",LL="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",ML="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 _k({agent:e}){const n=e==="codex"?OL:e==="claude"?PL:e==="codex-cli"?LL:e==="claude-cli"?ML: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(FT,{className:"size-4 shrink-0","aria-hidden":!0}):t.jsx(Ka,{className:"size-4 shrink-0","aria-hidden":!0})}function IL(){const[e,n]=p.useState($k);return p.useEffect(()=>{const r=o=>{const i=o instanceof CustomEvent?o.detail:void 0;n(Pv.includes(i)?i:$k())};return window.addEventListener(fg,r),window.addEventListener("storage",r),()=>{window.removeEventListener(fg,r),window.removeEventListener("storage",r)}},[]),{agent:e,choose:r=>{RL(r),n(r),window.dispatchEvent(new CustomEvent(fg,{detail:r}))}}}function sn({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}=IL(),[g,y]=p.useState(!1),[x,h]=p.useState(!1),[v,b]=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),P=p.useRef(0),O=p.useId(),M=AL(u,n),R=u?M?`Open in ${mg[u]}`:`Copy prompt for ${mg[u]}`:"Choose your coding agent",A=()=>{var F;y(!1),(F=E.current)==null||F.focus()},L=async()=>{const F=++P.current;y(!1);try{if(await navigator.clipboard.writeText(n),F!==P.current)return;h(!0),b(!1)}catch{F===P.current&&b(!0)}};p.useEffect(()=>(h(!1),b(!1),()=>{P.current++}),[u,n]),p.useEffect(()=>{if(!x)return;const F=setTimeout(()=>h(!1),2e3);return()=>clearTimeout(F)},[x]),p.useEffect(()=>{o&&y(!1)},[o]),p.useEffect(()=>{if(!g){k(null);return}const F=()=>{var ye;const Y=E.current.getBoundingClientRect(),se=Math.min(240,window.innerWidth-16),Q=Math.min(((ye=N.current)==null?void 0:ye.scrollHeight)||340,window.innerHeight-16),re=window.innerHeight-Y.bottom-12,te=Y.top-12,he=re>=Q||re>=te,ge=Math.max(80,he?re:te);k({width:se,left:Math.max(8,Math.min(Y.right-se,window.innerWidth-se-8)),top:he?Y.bottom+4:Math.max(8,Y.top-Math.min(Q,ge)-4),maxHeight:ge})};F();const z=Y=>{var se,Q;!((se=S.current)!=null&&se.contains(Y.target))&&!((Q=N.current)!=null&&Q.contains(Y.target))&&y(!1)};return document.addEventListener("pointerdown",z),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("pointerdown",z),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[g]);const D=j!==null;p.useEffect(()=>{var F,z,Y;g&&D&&((Y=((F=N.current)==null?void 0:F.querySelector('[aria-checked="true"]'))??((z=N.current)==null?void 0:z.querySelector('[role="menuitemradio"]')))==null||Y.focus())},[g,D]),p.useEffect(()=>{var F,z;v&&((F=$.current)==null||F.focus(),(z=$.current)==null||z.select())},[v]);const W=F=>{var Q;if(F.key==="Escape"){F.preventDefault(),A();return}if(F.key==="Tab"){A();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(F.key))return;F.preventDefault();const z=[...N.current.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')],Y=z.indexOf(document.activeElement),se=F.key==="Home"?0:F.key==="End"?z.length-1:(Y+(F.key==="ArrowDown"?1:-1)+z.length)%z.length;(Q=z[se])==null||Q.focus()},q="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(_k,{agent:u}),i?t.jsx("span",{className:"sr-only",children:x?"Copied":e}):x?"Copied":e]}),K=i?`${e} · ${R}`:R,U=`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:ie(rl({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:[M&&!o?t.jsx("a",{href:M,title:K,"aria-label":i?e:void 0,className:ie(rl({variant:"ghost",size:"sm"}),U),children:H}):t.jsx(B,{variant:"ghost",size:"sm",className:U,disabled:o,title:K,"aria-label":i?e:void 0,onClick:()=>u?void L():y(!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:()=>y(F=>!F),onKeyDown:F=>{(F.key==="ArrowDown"||F.key==="ArrowUp")&&(F.preventDefault(),y(!0))},children:t.jsx(Ar,{"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:[Pv.map(F=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":u===F,tabIndex:-1,className:q,onClick:()=>{f(F),A()},children:[t.jsx(_k,{agent:F}),mg[F],u===F&&t.jsx(pl,{className:"ml-auto size-3.5","aria-hidden":!0})]},F)),t.jsx("div",{role:"separator",className:"my-1 border-t"}),s&&t.jsxs("a",{role:"menuitem",tabIndex:-1,href:s,className:q,onClick:()=>y(!1),children:[t.jsx(um,{className:"size-4","aria-hidden":!0}),r]}),t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,className:q,onClick:()=>{var F;(F=E.current)==null||F.focus(),L()},children:[t.jsx(Ka,{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:F=>{var z;F.target===F.currentTarget&&(b(!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:F=>{var z,Y,se;if(F.key==="Escape"&&(F.preventDefault(),b(!1),(z=E.current)==null||z.focus()),F.key==="Tab"){const Q=[..._.current.querySelectorAll("button, textarea")];F.shiftKey&&document.activeElement===Q[0]?(F.preventDefault(),(Y=Q.at(-1))==null||Y.focus()):!F.shiftKey&&document.activeElement===Q.at(-1)&&(F.preventDefault(),(se=Q[0])==null||se.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 F;b(!1),(F=E.current)==null||F.focus()},children:t.jsx(Qo,{"aria-hidden":!0})})]}),t.jsx("p",{className:"mb-3 text-body text-muted-foreground",children:"Clipboard access is unavailable. Copy this prompt into your coding agent."}),t.jsx(nn,{ref:$,readOnly:!0,"aria-label":"Prompt to copy",value:n,rows:9,className:"w-full resize-y border bg-card p-3 font-mono text-small",onFocus:F=>F.currentTarget.select()})]})}),document.body)]})}function ta(e){const n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("AgentRun needs an HTTP or HTTPS server address.");return new URL(n.origin)}function so(e){const n=ta(e).origin;return`First read this server's matching agentrun-serve skill from ${n}/skills/agentrun-serve/SKILL.md. Target this existing instance only: ${n}/v2; do not start a replacement server. Check its /capabilities and /openapi.json. Prefer configured MCP at ${n}/v2/mcp, verifying with whoami; otherwise use the documented API. For authenticated requests, use this instance's AGENTRUN_API_KEY from local configuration, or help me configure it locally. Never print credentials.`}function Mm(e,n="",s){return`${so(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 zL(e,n,s=""){return k2(e,n,s)}function nx(e,n,s){return k2(e,n,"",!0,s)}function k2(e,n,s="",r=!1,o){const i=ta(e).origin;return`${so(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 Wo(e,n,s=!1,r){const o=ta(e).origin;return r?`${so(e)}
606
-
607
- Help me edit the existing backend agent ${JSON.stringify(n)}, using ${Ko(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?`${so(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.`:`${so(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 Im(e,n){const s=ta(e).origin,r=n===void 0?"/runs":`/agents/${encodeURIComponent(n)}/runs`;return`${so(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 Lv(e,n,s){const r=ta(e).origin;return s?`${so(e)}
614
-
615
- Help me run the existing backend agent ${JSON.stringify(n)}, using ${Ko(s)}. Read ${r}/v2/agents/${encodeURIComponent(n)} and locate its application's existing job entrypoint. Ask where that source runs if needed, and clarify the task and any required inputs or spending limits. Preserve its SDK, tools, credentials and AgentRun learning wrapper; trigger the task through the backend's normal invocation after my approval. Do not launch it with AgentRun's managed run API or create a replacement agent. The wrapper reports this task and uses the currently enabled accepted learning; wait for flushLearning() before a fresh test run that must use its latest lessons. Report the backend result and the recorded AgentRun console link. Any stop, retry or follow-up must use the backend's own controls.`:`${so(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 DL(e,n,s){const r=ta(e).origin;return`${so(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 N2(e){const n=ta(e).origin;return`Read ${n}/skills/agentrun-serve/SKILL.md and follow Connect agent for ${n}/v2 with the matching reviewed CLI. Use this instance; do not start a replacement server.
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 FL(e,n){const s=ta(e).origin;return`Read ${s}/skills/agentrun-serve/SKILL.md for ${s}/v2 only. Use the existing AgentRun CLI and Node bridge from the same reviewed build; do not start a replacement server.
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 UL(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 zm={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},WL=new Set(["completed","failed","cancelled"]);function HL(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 S2=(e,n)=>e==="failed"&&(n==null?void 0:n.code)==="escalated",BL=(e,n)=>e==="completed"&&!!n;function Dm(e,n,s,r,o,i,c,d){const u=WL.has(e),f=s==="agentic",g=S2(e,i),y=BL(e,c),x=e==="queued"&&(d==null?void 0:d.state)==="starting"&&(d.kind==="desktop"||d.kind==="phone"),h=g?"Escalated":y?"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||y?"warning":e==="completed"?"success":e==="failed"?"error":e==="cancelled"?"muted":e==="input_required"||e==="paused"?"warning":"active",b=HL(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:b!==null,messageMode:b}}const GL={Queued:Hp,Starting:Hp,Working:Hp,Completed:pl,Failed:tl,Escalated:vT,"Needs review":fm,Cancelled:CN,"Input required":Bx,Stopped:nl,Paused:$N};function Cl({run:e}){const n=Dm(e.status,e.state,e.kind,zm,!0,e.error,e.review,e.computer),s=GL[n.label];return t.jsxs(Ne,{tone:n.tone,children:[t.jsx(s,{className:n.live?"size-3 animate-spin [animation-duration:2s]":"size-3","aria-hidden":!0}),n.label]})}const qL=["ready","unavailable"],bf=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),sx=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function pd(e){if(bf(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function Tk(e){const n=bf(e)?e.places:void 0;if(!bf(n)||!Array.isArray(n.modes)||!Array.isArray(n.boxes))return null;const s=n.boxes.filter(bf).filter(o=>typeof o.id=="string").map(o=>({id:o.id,available:o.available===!0,...typeof o.reason=="string"?{reason:o.reason}:{},...qL.includes(o.state)?{state:o.state}:{}})),r=pd(n.default_place);return r?{modes:n.modes.filter(o=>typeof o=="string"),boxes:s,defaultPlace:r}:null}const hg=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,KL=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",VL=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",YL={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."}]}},QL=["jev","parallel"];function JL(e="jev"){const n=structuredClone(YL);return e!=="jev"&&Object.assign(n.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),n}const XL={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`."}]}},ZL=()=>structuredClone(XL),dl=e=>e===!0||e==="notes"||typeof e=="object"&&e!==null&&!Array.isArray(e);function gd(e,n,s){const{name:r,description:o,...i}=n,c={...e.definition,...i},d={...e.definition};c.computer!==void 0&&(delete c.place,delete d.place),c.workflow!==null&&typeof c.workflow=="object"&&!Array.isArray(c.workflow)&&(delete c.thinking,delete c.instructions,delete c.model),c.model===""&&delete c.model,c.tool_settings&&!Object.keys(c.tool_settings).length&&delete c.tool_settings;for(const g of Object.keys(c))c[g]===void 0&&delete c[g];const u=g=>{const y={...g,version:0,approvals:g.approvals??"ask",max_cost_usd:g.max_cost_usd===0?void 0:g.max_cost_usd,checkout:g.checkout==="none"?void 0:g.checkout},x=pd(g.place),h=g.computer===void 0&&x?sx(x):g.computer;return h!==void 0&&(y.computer=h,delete y.place),y},f=Qi(u(c),u(d));return c.version=f?e.definition.version:e.revisions+1,{definition:c,...s.trim()?{note:s.trim()}:{},unchanged:f}}function Qi(e,n){if(e===n)return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null||Array.isArray(e)!==Array.isArray(n))return!1;const s=Object.keys(e).filter(o=>e[o]!==void 0),r=Object.keys(n).filter(o=>n[o]!==void 0);return s.length===r.length&&s.every(o=>Qi(e[o],n[o]))}const Mv="decision",C2="workflow",E2={[Mv]:JL,[C2]:ZL},$2=e=>e!==void 0&&Object.hasOwn(E2,e);function eM(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?QL.find(o=>n.some(i=>i.id===o&&i.available)):"jev"}const tM="You are a helpful agent. Do the task you're given and report what you found.";function nM(e){var n;return $2(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:E2[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 Rk(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 sM(e){return(Array.isArray(e)?e:[]).flatMap(n=>{if(!n||typeof n!="object"||typeof n.name!="string")return[];if(n.meta===!0)return[];const{name:s,available:r,summary:o,blurb:i,missing:c,reason:d,harnesses:u,call_only:f,sandbox_only:g,nodes:y}=n;return[{name:s,available:r!==!1,...typeof o=="string"&&o?{summary:o}:{},...typeof i=="string"&&i.trim()?{blurb:i.trim()}:{},...c!=null&&c.length?{missing:c}:{},...typeof d=="string"&&d?{reason:d}:{},harnesses:Array.isArray(u)?u:[],...f===!0?{call_only:!0}:{},...g===!0?{sandbox_only:!0}:{},...typeof y=="boolean"?{nodes:y}:{}}]})}function Fm(e,n){return n.filter(s=>!s.call_only&&s.harnesses.includes(e))}function rx(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:Fm(e,s).some(c=>c.name===n):!0}const Ff=e=>T2[e]??e,Ak=e=>e.map(Ff).join(" and ");function Ok(e,n,s,r){var i;if(n.startsWith("mcp:"))return`${Ff(e)} doesn't run MCP tools here${r!=null&&r.length?`: ${Ak(r)} do`:""}`;const o=((i=s.find(c=>c.name===n))==null?void 0:i.harnesses)??[];return o.length?`Runs on ${Ak(o)} here, not on ${Ff(e)}`:"No harness runs it here"}function rM(e,n,s,r,o={}){const i=[...n,...s.filter(c=>!n.includes(c))];return{tools:i.filter(c=>rx(e,c,r,o)),held:i.filter(c=>!rx(e,c,r,o))}}const oM=(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,Iv=new Set(["browser"]),zv=(e,n,s)=>e||n.some(r=>Iv.has(r))||!s?{mode:"runner"}:s.defaultPlace;function _2(e,n){const s=pd(e.definition.place);if(s)return{place:s,byDefault:!1};const r=e.kind==="workflow",o=e.definition.tools??[];if(!(!r&&!o.some(i=>Iv.has(i))&&!n))return{place:zv(r,o,n),byDefault:!0}}const pg=(e,n,s)=>Fm(e,n).filter(r=>r.available&&((s==null?void 0:s.mode)==="sandbox"?!Iv.has(r.name):!r.sandbox_only)).map(r=>r.name),aM=["web_fetch","web_search"],Pk=e=>e.some(n=>aM.includes(n)),T2={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},iM=["pi","claude-agent","codex","opencode"];function lM(e,n){const s=iM.flatMap(r=>{const o=e.find(i=>i.id===r);return o?[{id:r,label:T2[r],available:o.available,reason:o.reason}]:[]});return n&&(s.push({id:Mv,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:C2,label:"Workflow",available:!0,reason:void 0})),s}function cM(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 Um(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 dM(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 xd=e=>e==="claude-code"?"Claude Code":e==="codex"?"Codex":e,Dv=e=>e.kind==="project"?"Project default":`${e.kind==="profile"?"Profile":"Named agent"}: ${e.name}`;function Fv(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 Uv(e){const n=e==null?void 0:e.definition.native;return!n||!Fv(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 vd(e){return"connected"in e&&!e.connected?"Disconnected":e.state==="ready"?"Ready to run":e.state==="needs_attention"?"Needs attention":"Needs verification"}const Wv=p.createContext(null),Hv=p.createContext(void 0);function uM(e,n){const s=e==null?void 0:e.definition.native,r=Fv(s),o=`${(e==null?void 0:e.agent_id)??""}:${(e==null?void 0:e.revision)??""}:${(r==null?void 0:r.connector_id)??""}:${(r==null?void 0:r.target_id)??""}`,[i,c]=p.useState(null),[d,u]=p.useState(0),f=()=>u(y=>y+1);return p.useEffect(()=>{if(!e||!s||!r)return;let y=!0,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.");y&&c({key:o,native:j})}catch(j){y&&c({key:o,native:{...s,state:"needs_attention",capabilities:{...s.capabilities,launch:!1},issues:[`Connection status could not be read: ${Wt(j)}`]}})}finally{x=!1}}};h();const v=()=>{document.hidden||h()},b=setInterval(v,15e3);return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{y=!1,clearInterval(b),window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[n,o,d]),{native:!r||!s?s:(i==null?void 0:i.key)===o?i.native:Uv(e??void 0),refresh:f}}function Bv(){const e=p.useContext(Wv),[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 fM({children:e,native:n}){const s=Bv();return t.jsx(Hv.Provider,{value:n,children:t.jsx(Wv.Provider,{value:s,children:e})})}function R2({agent:e,v2:n,learning:s,onAgent:r}){const o=p.useContext(Hv)??e.definition.native,i=Bv(),c=dl(e.definition.learning),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[y,x]=p.useState(null),h=o.connected&&o.state==="ready"&&o.capabilities.notes&&o.capabilities.skills&&o.capabilities.launch,v=async b=>{if(i.begin()){g(!0),x(null);try{if(b){const{native:N}=await n.verifyNative(e.agent_id);if(!N.connected||N.state!=="ready"||!N.capabilities.notes||!N.capabilities.skills)throw new Error(`Native learning is not ready: ${N.issues.join("; ")||vd(N)}. Verify the connection and try again.`)}const{agent:j,etag:k}=await n.getAgent(e.agent_id),{unchanged:E,...S}=gd(j,{learning:b?"notes":!1},b?"Native self-improvement on":"Native self-improvement off");r==null||r(E?j:(await n.updateDefinition(e.agent_id,S,k)).agent),u(!1)}catch(j){x(Wt(j))}finally{g(!1),i.end()}}};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("h3",{id:`native-learning-${e.agent_id}`,className:"min-w-0 flex-1 text-body font-semibold",children:["Self-improving: ",c?"On":"Off"]}),t.jsx(cd,{labelledBy:`native-learning-${e.agent_id}`,checked:c,busy:f,disabled:i.busy||!!e.archived_at||!c&&(!h||s!=="on"),onChange:b=>b?u(!0):void 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."}),y&&!d&&t.jsx(vt,{tone:"error",children:y}),t.jsxs(Am,{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."}),y&&t.jsx(vt,{tone:"error",className:"mt-3",children:y})]})]})}function mM({agent:e,v2:n,learning:s,onAgent:r,onChanged:o}){const i=p.useContext(Hv)??e.definition.native,c=Fv(i),d=Bv(),u=d.busy,[f,g]=p.useState(null),y=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(Wt(h))}finally{d.end()}}};return t.jsx(Wv.Provider,{value:d,children:t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Native connection",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-body font-semibold",children:c?"Remote connection":"Native connection"}),t.jsx(Ne,{tone:i.connected&&i.state==="ready"?"success":"warning",children:vd(i)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"sm",disabled:u||!i.connected,"aria-busy":u,onClick:()=>void y("verify"),children:"Verify connection"}),t.jsx(B,{size:"sm",disabled:u||!i.connected,onClick:()=>void y("disconnect"),children:"Disconnect"})]}),f&&t.jsx(vt,{tone:"error",children:f}),t.jsx("div",{className:"border-y py-4",children:t.jsx(R2,{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",`${xd(i.runtime)} · ${i.version??"Version unknown"}`],["Project",i.project],["Selector",Dv(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 hM={browserbase:"Browserbase",kernel:"Kernel"},Ri=e=>hM[e]??e,Lk=e=>t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"font-mono underline underline-offset-2",children:e.slice(-8)}),pM=5e3,Mk=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function gM({agent:e,v2:n,onAgent:s,poll:r,refresh:o}){var S,N;const[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(null),y=p.useRef(e);y.current=e;const 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(),pM);return()=>clearInterval($)},[v,d]);const b=(N=(S=e.tools)==null?void 0:S.find($=>$.name==="browser"))==null?void 0:N.resolved;if(!h.length&&b!=="browserbase"&&b!=="kernel"&&!f)return null;const j=[...new Set(h.map($=>$.key))].map($=>({key:$,items:h.filter(_=>_.key===$)})),k=async $=>{var _,P;u(!0),g(null);try{const M=(await n.forgetSignIn(e.agent_id,$)).removed.filter(A=>A.at_vendor==="not_deleted"),R=M.length?{tone:"warn",text:M.map(A=>`Forgotten here, but ${Ri(A.provider)} didn't confirm the delete. ${A.message??""}`.trim()).join(" ")}:null;if(g(R),c(null),!await o()){const A=y.current;s({...A,sign_ins:(A.sign_ins??[]).filter(L=>L.key!==$)}),g({tone:"warn",text:`${R?`${R.text} `:"Forgotten. "}The agent couldn't be read again.`})}}catch(O){const M=O instanceof ze&&O.code==="sign_in_held"?((_=O.details)==null?void 0:_.held_by)??((P=O.details)==null?void 0:P.handed_to):void 0;g(O instanceof ze&&O.code==="sign_in_held"?{tone:"warn",text:"A run is using this sign-in; you can forget it when that run ends.",...M?{run:M}:{}}:{tone:"error",text:`Not forgotten: ${Wt(O)}`}),c(null)}finally{u(!1)}},E=({key:$,items:_})=>{const P=_.length===1?`Forget the ${Ri(_[0].provider)} sign-in`:`Forget the saved sign-ins for ${Mk(_.map(M=>Ri(M.provider)))}`,O=_.some(M=>M.state==="held");return t.jsx(B,{size:"sm",variant:"ghost",disabled:d||O,"aria-label":P,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(La,{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:Ri(_.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 ",Lk(_.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 ${Ri($.items[0].provider)} sign-in?`:`Forget the saved sign-ins for ${Mk($.items.map(_=>Ri(_.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: ",Lk(f.run)]})]})]})}const xM=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),vM=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function _r(e,n){var c,d;const s=`${xM(n)} could not be read.`;if(vM(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof ze))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=((d=(c=e.fields)==null?void 0:c[0])==null?void 0:d.message)??e.message,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 Ra=[{path:"agent",label:"By the agent",fill:"fill-chart-agent",stroke:"stroke-chart-agent"},{path:"handed_back",label:"Handed back",fill:"fill-chart-handed-back",stroke:"stroke-chart-handed-back"},{path:"workflow",label:"Learned workflow",fill:"fill-chart-workflow",stroke:"stroke-chart-workflow"},{path:"replay",label:"Replay",fill:"fill-muted-foreground",stroke:"stroke-muted-foreground"}],Ku=e=>Ra.find(n=>n.path===e),bM=e=>e.filter(n=>n.total_usd!==null),yM=e=>Math.min(25,Math.max(3,Math.round(e/15)));function wM(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 jM(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 kM(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 NM(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=jM(Math.max(o,...n,s??0)*1.08);return{top:i,above:e.filter(c=>c.total_usd>i).length}}function SM(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 CM(e,n){let s=0;for(let r=1;r<e.length;r++)Math.abs(e[r].n-n)<Math.abs(e[s].n-n)&&(s=r);return s}function To(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4).replace(/(\.\d\d\d?)0+$/,"$1").replace(/(\.\d\d)0$/,"$1")}`}function ir(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`}const EM=e=>e<=20?1:Math.max(5,Math.ceil(e/20));function $M(e,n){const s=[];for(let r=0;r<e.length;r+=n){const o=e.slice(r,r+n),i=Object.fromEntries(Ra.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 ox(e){const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`}const yf=(e,n)=>`${n?Math.round(e/n*100):0}%`,A2=20,_M=e=>{const n=typeof e=="object"&&e!==null?e.compile_after:void 0;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:A2},TM=20,Ac={revision:"New revision",promote:"Promoted",hold:"Held"},Gv={revision:"R",promote:"P",hold:"H"},O2=e=>e.decided==="replaying"?"revision":e.decided;function RM(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=O2(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 AM=e=>e.path!=="replay",P2=e=>{var n;return(n=e==null?void 0:e.summary.hand_backs)!=null&&n.ran?e.summary.hand_backs:null},qv=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>r.workflow===n&&r.digest===s);function OM(e,{serving:n=null,stopped:s=null}={}){if(!e)return{word:"Not decided",tone:"muted"};const r=PM(e),o=r?{proof:r}:{};return e.decided==="promote"?e.digest!==n?{word:"Served",tone:"muted",...o}:e.digest===s?{word:"Stopped",tone:"warning",...o}:{word:"Serving",tone:LM(e)?"success":"plain",...o}:e.decided==="hold"?{word:"Held",tone:"warning",...o}:{word:"Replaying",tone:"active"}}function Hc(...e){const n=OM(...e);return{...n,text:n.proof?`${n.word} · ${n.proof}`:n.word}}const Kv=(e,n)=>{var s;return((s=e==null?void 0:e.workflows.find(r=>r.workflow===n&&r.state==="needs_revision"))==null?void 0:s.digest)??null};function PM(e){const n=e.check;return!(n!=null&&n.n)||e.decided!=="promote"&&e.decided!=="hold"?null:`checked on ${n.n} ${n.n===1?"input":"inputs"} · ${n.alone??0} alone`}const LM=e=>{var n;return(((n=e.check)==null?void 0:n.n)??0)>0},Vu=e=>`${Math.round(e*100)}%`;function Aa(e){var o;const n=e.check;if(!(n!=null&&n.n))return e.reason;const s=n.alone??0,r=n.agreed??0;return`Checked on ${n.n} ${n.n===1?"input":"inputs"} of the agent's own runs: ${s} answered alone (${Vu(s/n.n)}, ${Vu(n.alone_min)} needed), ${r} of those said what the agent said (${s?Vu(r/s):"0%"}, ${Vu(n.agree_min)} needed)${(o=n.outcomes)!=null&&o.handed_back?`, ${n.outcomes.handed_back} handed back`:""}`}function L2(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 MM(e){var R,A;const{notes:n,compiledNotes:s,runs:r,workflows:o,cost:i,promotions:c,serving:d,loop:u,mode:f="full",execution:g="hosted",compileAfter:y=A2}=e,x=f==="notes",h=o.filter(L=>L.status==="active"),v=u==null?void 0:u.compiles.find(L=>L.digest===null&&(L.draft_errors.length>0||L.attempts.length>0)),b=u==null?void 0:u.compiles.find(L=>L.digest!==null),j=i==null?void 0:i.summary,k=P2(i),E=c.at(-1),S=E?d.find(L=>L.workflow===E.workflow):void 0,N=(S==null?void 0:S.digest)??null,$=S!=null&&S.replaying?`revision ${S.replaying.slice(0,7)} is checked on the inputs of its agent's own runs before it serves`:(E==null?void 0:E.decided)==="hold"&&E.digest!==N?`revision ${E.digest.slice(0,7)} was held: ${Aa(E)}`:null,_=N!==null&&E?Kv(i,E.workflow)===N:!1,P=_?`revision ${N.slice(0,7)} no longer runs first: it cost as much as the agent by hand; the agent takes its runs`:null,O=P?$?`${P}; ${$}`:P:N&&$?`revision ${N.slice(0,7)} serves; ${$}`:null,M=[];if(M.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 M.push({key:"compiled",title:"Learning",value:"Notes and skills",detail:"Native runs receive accepted notes and skills; learned workflows are unavailable.",state:"later"}),M;if(h.length||b&&b.digest){const L=((R=h[0])==null?void 0:R.name)??(b==null?void 0:b.workflow)??"a workflow";M.push({key:"compiled",title:"Compiled",value:L,detail:b?`from ${b.from_notes.length} ${b.from_notes.length===1?"note":"notes"}, ${b.attempts.length} ${b.attempts.length===1?"attempt":"attempts"}`:"a learned workflow",state:"done"})}else v?M.push({key:"compiled",title:"Compile",value:"Draft failed",detail:`${v.attempts.length} ${v.attempts.length===1?"attempt":"attempts"}, the checks refused it: it tries again on a later run`,state:"warn"}):x?M.push({key:"compiled",title:"Compile",value:"Notes only",detail:`this agent learns notes only: no workflow compiles from them. Full learning compiles one at ${y} completed runs`,state:"later"}):M.push({key:"compiled",title:"Compile",value:"Not yet",detail:g==="sdk"?`With workflow learning and backend tool bindings, compilation starts at ${y} completed runs`:`${Math.min(r,y)} of ${y} completed runs: a workflow compiles at ${y}, then is checked once on those runs' inputs against the agent's own answers`,state:r?"now":"later"});if(g==="sdk")return x||M.push({key:"took_over",title:"Use workflow",value:"Backend decides",detail:"Your backend keeps launching each run. The SDK can call accepted workflows through MCP with explicitly bound tools.",state:h.length?"now":"later"}),M;if(j!=null&&j.takeover)M.push({key:"took_over",title:"Took over",value:`Run ${j.takeover.n}`,detail:O??((A=E==null?void 0:E.check)!=null&&A.n?Aa(E):E?E.reason:"the first run a learned workflow finished alone"),state:_||(E==null?void 0:E.decided)==="hold"&&!N?"warn":"done"});else if(E)if(O)M.push({key:"took_over",title:"Take over",value:Hc(qv(c,E.workflow,N)??E,{serving:N,stopped:_?N:null}).word,detail:O,state:_?"warn":"done"});else{const L=Hc(E,{serving:N});M.push({key:"took_over",title:"Take over",value:L.word,detail:E.decided==="replaying"?"being checked on the inputs of the agent's own runs before it serves; the agent takes the runs meanwhile":Aa(E),state:E.decided==="hold"?"warn":"now"})}else x||M.push({key:"took_over",title:"Take over",value:"Not yet",detail:"a compiled workflow is checked once on the inputs of the agent's own runs, then serves first when it clears the check's bar",state:"later"});if(j!=null&&j.takeover&&j.withheld)M.push({key:"cheaper",title:"Cheaper",value:"No ratio yet",detail:`${M2(j.withheld)}: ${I2}`,state:"now"});else if(j!=null&&j.after&&j.before){const L=`${gg(j.before.mean_usd)} a run by the agent, ${gg(j.after.mean_usd)} all-in over the ${j.after.runs===1?"1 run":`${j.after.runs} runs`} it served since`,D=j.times_cheaper;D!==null&&D>1?M.push({key:"cheaper",title:"Cheaper",...IM(j,D),state:"done"}):D!==null?M.push({key:"cheaper",title:"Cheaper",value:D<1?j.before.mean_usd>0?`Not cheaper yet: ${zM(j.after.mean_usd/j.before.mean_usd)} the cost`:"Not cheaper yet":"Same cost",detail:L,state:"now"}):M.push({key:"cheaper",title:"Cheaper",value:`${j.after.runs} served ${j.after.runs===1?"run":"runs"} so far`,detail:`${L}; how many times cheaper shows after ${TM} runs`,state:"now"})}else j!=null&&j.takeover&&j.after_state==="cost_unknown"?M.push({key:"cheaper",title:"Cheaper",value:"No cost yet",detail:"no served run's cost is known yet",state:"now"}):j!=null&&j.after?M.push({key:"cheaper",title:"Cheaper",value:`${j.after.runs} served ${j.after.runs===1?"run":"runs"} so far`,detail:`${gg(j.after.mean_usd)} all-in over the ${j.after.runs===1?"1 run":`${j.after.runs} runs`} it served; no priced agent runs before takeover to compare with`,state:"now"}):x||M.push({key:"cheaper",title:"Cheaper",value:"Not yet",detail:"no served runs yet: once a workflow takes over, the all-in cost of the runs it serves against before (replays are checks, not served runs)",state:"later"});return k&&M.push({key:"unsure",title:"Unsure",value:`${Math.round(k.back/k.ran*100)}% handed back`,detail:`of ${k.ran} runs it ran first`,state:k.back/k.ran>.25?"warn":"watch"}),M}function M2(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 I2="how many times cheaper shows once every run's cost is known";function IM(e,n){const s=n>=1.5?`${Math.round(n)}x`:`${n.toFixed(1)}x`,r=e.replay,o=r?`workflow ${Math.round(r.workflow_pct)}% vs agent ${Math.round(r.agent_pct)}% on ${r.n} inputs`:"";if(r!=null&&r.cleared){const i=e.hand_backs?` · served ${e.hand_backs.ran} ${e.hand_backs.ran===1?"run":"runs"}, handed back ${e.hand_backs.back}`:"";return{value:`About ${s} cheaper`,detail:`Passed the agreement check: ${r.agreed} of ${r.alone} agreed (bar ${Math.round(r.agree_min*100)}%)${i}`}}return{value:`${s} cheaper`,detail:`accuracy not claimed: ${r?`its check was below the bar (${o})`:"no check yet"}`}}const gg=e=>e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`,zM=e=>{const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`},DM=1e3,z2="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.",D2=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.":z2,ax=e=>`${e} served ${e===1?"run":"runs"}`;function Ik({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([]),y=o??f,x=p.useRef(i);x.current=i;const[h,v]=p.useState(null),[b,j]=p.useState(0);return p.useEffect(()=>{let k=!0;return v(null),Promise.resolve().then(()=>e.learningCost(n,DM)).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,b,!o]),r&&(!d||d.runs.filter(k=>k.total_usd!==null).length<2)?null:h&&!d?t.jsx(ss,{problem:_r(h,"the cost per run"),onRetry:()=>j(k=>k+1),className:""}):d?t.jsx(UM,{data:d,on:s,promotions:y,execution:c}):t.jsx(gn,{className:"h-[320px] w-full"})}const Pt={top:30,right:16,bottom:30,left:60},Yu=17,FM=16,Gr=260;function UM({data:e,on:n,width:s,promotions:r=[],execution:o="hosted"}){var Ee;const i=p.useMemo(()=>bM(e.runs),[e.runs]),c=p.useMemo(()=>i.filter(AM),[i]),d=yM(c.length),u=p.useMemo(()=>wM(c,d),[c,d]),f=p.useMemo(()=>RM(e.runs,r),[e.runs,r]),{summary:g}=e,y=P2(e),x=p.useRef(null),[h,v]=p.useState(s??720);p.useEffect(()=>{const ae=x.current;if(s||!ae||typeof ResizeObserver>"u")return;const $e=new ResizeObserver(([ot])=>{ot&&ot.contentRect.width>0&&v(ot.contentRect.width)});return $e.observe(ae),()=>$e.disconnect()},[s]);const[b,j]=p.useState(null),[k,E]=p.useState(null),S=Ra.map(ae=>({...ae,runs:e.runs.filter($e=>$e.path===ae.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(ae=>ae.state==="needs_revision"&&ae.served&&ae.by_hand).map(ae=>`${ae.workflow} no longer runs first: ${ir(ae.served.mean_usd)} a run all-in over its newest ${ae.served.runs} priced runs, at or over ${ir(ae.by_hand.mean_usd)} a run by hand.${ae.unknown_cost_runs?` ${ae.unknown_cost_runs===1?"1 run":`${ae.unknown_cost_runs} runs`} of unknown cost left out.`:""} The agent takes its runs; a new version runs first again.`)].filter(ae=>!!ae);if(i.length<2)return t.jsxs(Fk,{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:D2(o)}),N.map(ae=>t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-small text-muted-foreground",children:ae},ae))]}),e.runs.length>0&&(()=>{var ot;const ae=Math.max(300,h),$e=(ae-Pt.left-Pt.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(Dk,{runs:e.runs,width:ae,x:me=>Pt.left+(me-e.runs[0].n+.5)*$e,step:$e,plot:[Pt.left,ae-Pt.right],takeover:((ot=g.takeover)==null?void 0:ot.n)??null})})})()]});const $=Math.max(300,h),_=$-Pt.left-Pt.right,P=e.runs[0].n,O=e.runs.at(-1).n,M=_/(O-P+1),R=ae=>Pt.left+(ae-P+.5)*M,A=g.before,{top:L,above:D}=NM(i,u,(A==null?void 0:A.mean_usd)??null),W=[],q=[];for(const ae of f){const $e=R(ae.n)-M/2;let ot=q.findIndex(me=>$e-me>=FM);ot<0?(ot=q.length,q.push($e)):q[ot]=$e,W.push(ot)}const H=q.length?q.length*Yu+8:0,K=Pt.top+H,U=ae=>K+Gr-Math.min(ae,L)/L*Gr,G=kM(L),F=SM(P,O,$<520?5:7),z=g.takeover&&g.takeover.n>=P?g.takeover:null,Y=g.takeover?Math.max(g.takeover.n,P):null,se=c.map((ae,$e)=>`${$e?"L":"M"}${R(ae.n).toFixed(1)},${U(u[$e]).toFixed(1)}`).join(""),Q=b===null?null:i[b],re=g.times_cheaper!==null?`${ox(g.times_cheaper)} cheaper`:null,te=y?`${yf(y.back,y.ran)} handed back since`:null,he=g.after?`${ir(g.after.mean_usd)} all-in over ${ax(g.after.runs)} after`:g.takeover&&g.after_state==="cost_unknown"?"no served run's cost known yet":null,ge=g.before&&he?`${ir(g.before.mean_usd)} a run before takeover, ${he}${re?`: ${re}`:""}${te?` · ${te}`:""}`:null,ye=e.unknown_cost_runs+e.unknown_path_runs,xe=ae=>{const $e=ae.currentTarget.getBoundingClientRect(),ot=(ae.clientX-$e.left)/$e.width*$,me=(ae.clientY-$e.top)/$e.height*(K+Gr+Pt.bottom);if(f.length&&me<K-2){j(null);const Me=f.map((Ze,bt)=>({i:bt,d:Math.abs(R(Ze.n)-M/2-ot)+Math.abs(Pt.top+W[bt]*Yu+8-me)})).sort((Ze,bt)=>Ze.d-bt.d)[0];E(Me&&Me.d<=12?Me.i:null);return}E(null),j(CM(i,P+(ot-Pt.left)/M-.5))},fe=ae=>{const ot={ArrowRight:me=>me+1,ArrowLeft:me=>me-1,Home:()=>0,End:()=>i.length-1,PageUp:me=>me+10,PageDown:me=>me-10}[ae.key];if(!ot){ae.key==="Escape"&&j(null);return}ae.preventDefault(),j(me=>Math.min(i.length-1,Math.max(0,ot(me??(ae.key==="ArrowLeft"?i.length:-1)))))},De=ae=>[`Run ${ae.n}`,`${To(ae.total_usd)} all-in${ae.learning_usd?` (${To(ae.cost_usd??0)} the run, ${To(ae.learning_usd)} learning)`:""}`,`${Ku(ae.path).label}${ae.workflow?`: ${ae.workflow}`:""}`,ae.learned_revision?`Learned revision ${ae.learned_revision.slice(0,7)}`:"Nothing learned yet",...ae.path==="replay"?["A replay: learning's spend, out of the line"]:[]],Fe=k===null?null:f[k]??null,Le=z?R(z.n)>Pt.left+_*.62:!1;return t.jsxs(Fk,{title:"Cost per run",headline:ge,unknown:ye,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(ae=>ae.runs>0).map(ae=>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:ae.fill})}),ae.label," ",t.jsx("span",{className:"text-foreground",children:ae.runs})]},ae.path)),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-foreground",strokeWidth:2})}),"Rolling mean of ",d," runs"]}),A&&t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"4 3"})}),"Before takeover, the agent alone"]}),Object.keys(Ac).filter(ae=>f.some($e=>$e.kind===ae)).map(ae=>t.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":`marker-key-${ae}`,children:[t.jsx("svg",{width:"14",height:"14","aria-hidden":!0,children:t.jsx(Uk,{x:0,y:0,kind:ae})}),Ac[ae]," ",t.jsx("span",{className:"text-foreground",children:f.filter($e=>$e.kind===ae).length})]},ae))]}),t.jsxs("div",{className:"relative shrink-0",tabIndex:0,onKeyDown:fe,onBlur:()=>j(null),"aria-label":`Cost per run, runs ${P} to ${O}. ${ge??""} Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:$,height:K+Gr+Pt.bottom,className:"block select-none font-mono",onPointerMove:xe,onPointerLeave:()=>{j(null),E(null)},"aria-hidden":!0,children:[G.map(ae=>t.jsxs("g",{children:[t.jsx("path",{d:`M${Pt.left},${U(ae)}H${Pt.left+_}`,className:ae===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:Pt.left-8,y:U(ae),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:To(ae)})]},ae)),F.map(ae=>t.jsx("text",{x:R(ae),y:K+Gr+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:ae},ae)),t.jsx("text",{x:Pt.left,y:H?Pt.top-10:K-16,className:"caps fill-muted-foreground text-label",children:"$ a run, all-in"}),t.jsx("text",{x:Pt.left-8,y:K+Gr+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),f.map((ae,$e)=>t.jsxs("g",{"data-testid":`marker-${ae.kind}`,opacity:k===null||k===$e?1:.55,children:[t.jsx("path",{d:`M${R(ae.n)-M/2},${Pt.top+W[$e]*Yu+15}V${K+Gr}`,className:F2[ae.kind],strokeWidth:1,strokeDasharray:"2 3"}),t.jsx(Uk,{x:R(ae.n)-M/2-7,y:Pt.top+W[$e]*Yu+1,kind:ae.kind})]},`${ae.kind}:${ae.n}:${ae.workflow}:${ae.digest}:${ae.at}`)),i.map((ae,$e)=>ae.path==="replay"?t.jsx("circle",{cx:R(ae.n),cy:U(ae.total_usd),r:$e===b?0:2.5,className:"fill-none stroke-muted-foreground",strokeWidth:1.25},ae.run_id):t.jsx("circle",{cx:R(ae.n),cy:U(ae.total_usd),r:$e===b?0:3,className:ie(Ku(ae.path).fill),fillOpacity:.65},ae.run_id)),A&&t.jsxs("g",{children:[t.jsx("path",{d:`M${Pt.left},${U(A.mean_usd)}H${Pt.left+_}`,className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"6 4"}),t.jsxs(xg,{x:Pt.left+_-4,y:U(A.mean_usd)-6,anchor:"end",children:["Before takeover ",ir(A.mean_usd)]})]}),z&&t.jsxs("g",{children:[t.jsx("path",{d:`M${R(z.n)},${K-4}V${K+Gr}`,className:"stroke-chart-workflow",strokeWidth:1.5}),t.jsxs(xg,{x:R(z.n)+(Le?-6:6),y:K+6,anchor:Le?"end":"start",children:["Workflow took over, run ",z.n]})]}),Y!==null&&g.after&&t.jsxs("g",{children:[t.jsx("path",{d:`M${R(Y)},${U(g.after.mean_usd)}H${Pt.left+_}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsxs(xg,{x:Pt.left+_-4,y:U(g.after.mean_usd)-8,anchor:"end",strong:!0,children:[$<520?"Served":`Served after takeover (${ax(g.after.runs)})`," ",ir(g.after.mean_usd),re?` · ${re}`:""]})]}),t.jsx("path",{d:se,fill:"none",className:"stroke-foreground",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),Q&&t.jsxs("g",{children:[t.jsx("path",{d:`M${R(Q.n)},${K}V${K+Gr}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("circle",{cx:R(Q.n),cy:U(Q.total_usd),r:5,className:ie(Ku(Q.path).fill,"stroke-card"),strokeWidth:2})]})]}),Fe&&!Q&&t.jsx("div",{className:ie("pointer-events-none absolute z-raised max-w-[22rem] border bg-card px-2 py-1 font-mono text-label shadow-float",R(Fe.n)>$*.6&&"-translate-x-full"),"data-testid":"marker-tip",style:{left:R(Fe.n)>$*.6?R(Fe.n)-M/2-12:R(Fe.n)-M/2+12,top:Pt.top},children:Wk(Fe).map((ae,$e)=>t.jsx("span",{className:ie("block",$e===0?"font-semibold":"text-muted-foreground"),children:ae},$e))}),Q&&t.jsxs("div",{className:ie("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",R(Q.n)>$*.6&&"-translate-x-full"),style:{left:R(Q.n)>$*.6?R(Q.n)-10:R(Q.n)+10,top:K},children:[De(Q).map((ae,$e)=>t.jsx("span",{className:ie("block",$e===0?"font-semibold":"text-muted-foreground"),children:ae},ae)),t.jsx("span",{className:"block text-muted-foreground",children:ht(Q.started_at)})]}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:Q?De(Q).join(", "):""}),f.length>0&&t.jsx("p",{className:"sr-only",children:`Markers: ${f.map(ae=>Wk(ae).join(", ")).join(". ")}.`})]}),t.jsx(Dk,{runs:e.runs,width:$,x:R,step:M,plot:[Pt.left,Pt.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(ae=>ae.path==="replay")?", replay runs (hollow) left out":"",".",D?` ${D===1?"1 run costs":`${D} runs cost`} more than ${To(L)} 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,...BM(e,n,o)].map(ae=>t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:ae},ae))]}),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(ae=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:ae},ae))})}),t.jsx("tbody",{children:e.runs.map(ae=>{var $e;return t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:ae.n}),t.jsx("td",{className:"pr-4",children:ht(ae.started_at)}),t.jsxs("td",{className:"pr-4",children:[Ku(ae.path).label,ae.workflow?`: ${ae.workflow}`:""]}),t.jsx("td",{className:"pr-4",children:(($e=ae.learned_revision)==null?void 0:$e.slice(0,7))??"-"}),t.jsx("td",{className:"pr-4",children:ae.cost_usd===null?"unknown":To(ae.cost_usd)}),t.jsx("td",{className:"pr-4",children:ae.learning_usd===null?"unknown":To(ae.learning_usd)}),t.jsx("td",{className:"pr-4",children:ae.total_usd===null?"unknown":To(ae.total_usd)})]},ae.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(ae=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:ae},ae))})}),t.jsx("tbody",{children:f.map(ae=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:ae.n}),t.jsxs("td",{className:"pr-4",children:[Gv[ae.kind]," ",Ac[ae.kind]]}),t.jsx("td",{className:"pr-4",children:ae.workflow}),t.jsx("td",{className:"pr-4",children:ae.digest.slice(0,7)}),t.jsx("td",{className:"pr-4 font-sans",children:Aa(ae.record)})]},`${ae.kind}:${ae.n}:${ae.workflow}:${ae.digest}:${ae.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 WM=64,Ro={top:4,bottom:6},HM=[...Ra].reverse(),zk=e=>e.from===e.to?`Run ${e.from}`:`Runs ${e.from} to ${e.to}`;function Dk({runs:e,width:n,x:s,step:r,plot:o,takeover:i}){const c=WM,d=EM(e.length),u=p.useMemo(()=>$M(e,d),[e,d]),[f,g]=p.useState(null);if(!u.length)return null;const[y,x]=o,h=O=>Math.min(x,Math.max(y,O)),v=O=>({from:h(s(O.from)-r/2),to:h(s(O.to)+r/2)}),b=O=>Ro.top+c*(1-O),j=u.at(-1),k=O=>{const{from:M,to:R}=v(O),A=R-M>4?1:0;return{x0:M+A,w:Math.max(1,R-M-2*A)}},E=O=>`${zk(O)}: ${Ra.filter(M=>O.counts[M.path]).map(M=>`${M.label.toLowerCase()} ${O.counts[M.path]}`).join(", ")}`,S=u.some(O=>O.counts.workflow)?`${yf(j.counts.workflow,j.runs)} by the learned workflow`:Ra.filter(O=>j.counts[O.path]).map(O=>`${yf(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,P=i!==null&&s(i)>=y&&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:y},children:[t.jsxs("span",{className:"caps block text-muted-foreground",children:["Who finished each run",d>1?`, by ${d}`:""]}),t.jsx("span",{className:"block text-foreground",children:N})]}),t.jsxs("svg",{width:n,height:Ro.top+c+Ro.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:y-6,y:b(O),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:[O*100,"%"]},O)),u.map((O,M)=>{const{x0:R,w:A}=k(O);let L=Ro.top+c;return t.jsxs("g",{onPointerEnter:()=>g(M),opacity:f===null||f===M?1:.55,children:[t.jsx("rect",{x:v(O).from,y:Ro.top,width:Math.max(1,v(O).to-v(O).from),height:c,className:"fill-card",fillOpacity:0}),HM.map(D=>{const W=O.counts[D.path]/O.runs*c;if(!W)return null;L-=W;const q=L>Ro.top+.5?Math.min(2,W):0;return t.jsx("rect",{x:R,y:L+q,width:A,height:W-q,className:D.fill,fillOpacity:.8},D.path)})]},O.from)}),P&&t.jsx("g",{"data-testid":"mix-takeover",children:t.jsx("path",{d:`M${s(i)-r/2},${Ro.top}V${Ro.top+c}`,className:"stroke-chart-workflow",strokeWidth:1.5})})]}),$&&t.jsxs("div",{className:ie("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:zk($)}),Ra.filter(O=>$.counts[O.path]).map(O=>t.jsxs("span",{className:"block text-muted-foreground",children:[O.label," ",$.counts[O.path]," (",yf($.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 BM(e,n,s){const r=e.summary;return!r.takeover&&s!=="hosted"?[D2(s)]:r.takeover?r.withheld?[`${M2(r.withheld)}: ${I2}.`]: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?[`${ax(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.":z2]}function Fk({title:e,headline:n,unknown:s=0,children:r}){return t.jsxs("section",{className:"min-w-0 border","aria-label":e,"data-testid":"cost-per-run",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[t.jsx("h3",{className:"caps text-small font-semibold",children:e}),n&&t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:n}),s>0&&t.jsx(Ne,{tone:"muted",className:"self-center",title:"Runs whose path or cost the server can't tell: left out of the chart, never drawn at $0.",children:s===1?"1 run unknown":`${s} runs unknown`})]}),r]})}const F2={promote:"stroke-chart-workflow",hold:"stroke-warning",revision:"stroke-muted-foreground"},GM={promote:"fill-foreground",hold:"fill-warning-text",revision:"fill-muted-foreground"};function Uk({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:ie("fill-card",F2[s]),strokeWidth:1.5,rx:2}),t.jsx("text",{x:e+7,y:n+7,dy:"0.35em",textAnchor:"middle",className:ie("text-micro font-semibold",GM[s]),children:Gv[s]})]})}const Wk=e=>[`${Ac[e.kind]} · run ${e.n}`,`${e.workflow} ${e.digest.slice(0,7)}`,Aa(e.record),ht(e.at)];function xg({x:e,y:n,anchor:s="start",strong:r=!1,children:o}){return t.jsx("text",{x:e,y:n,textAnchor:s,className:ie("stroke-card text-label [paint-order:stroke]",r?"fill-foreground font-semibold":"fill-muted-foreground"),strokeWidth:4,strokeLinejoin:"round",children:o})}function qM(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 KM(e){var i;const n=qM(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 Hk=500,VM=5,ix=e=>e.status==="running";function YM(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 QM={agent:"by hand",handed_back:"handed back",workflow:"workflow"},JM=2e3;function XM({v2:e,agentId:n,onFinished:s,pollMs:r=JM}){const[o,i]=p.useState(void 0),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,y]=p.useState(0),x=p.useRef(!1),h=p.useRef(s);if(h.current=s,p.useEffect(()=>{let b=!0,j;const k=async E=>{var S,N;try{const $=E??((S=(await e.learningBatches(n)).batches[0])==null?void 0:S.id),_=$?await e.learningBatch(n,$):null;if(!b)return;i(_),d(null),_&&ix(_)?(x.current=!0,j=setTimeout(()=>void k(_.id),r)):_&&x.current&&(x.current=!1,(N=h.current)==null||N.call(h))}catch($){if(!b)return;d($??new Error("unknown")),j=setTimeout(()=>void k(E),r*2)}};return k(),()=>{b=!1,clearTimeout(j)}},[e,n,r,g]),o===void 0&&!c)return t.jsx(gn,{className:"h-24 w-full"});if(o===void 0)return t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground",role:"status",children:["Learn from a CSV is not available right now: ",c instanceof Error?c.message:String(c),"."]}),t.jsx(B,{size:"sm",variant:"outline",onClick:()=>{d(null),y(b=>b+1)},children:"Read again"})]});const v=o&&ix(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(ZM,{v2:e,agentId:n,onStarted:b=>{x.current=!0,i(b),f(!1),y(j=>j+1)},onCancel:()=>f(!1)}),o&&!u&&t.jsx(nI,{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 ZM({v2:e,agentId:n,onStarted:s,onCancel:r}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[g,y]=p.useState(""),[x,h]=p.useState(String(VM)),[v,b]=p.useState(!1),[j,k]=p.useState(null),E=async _=>{var R;const P=(R=_.target.files)==null?void 0:R[0];if(!P)return;k(null);const O=KM(await P.text());if("error"in O){i(null),d(O.error);return}d(O.rows.length>Hk?`A batch takes at most ${Hk} rows: this file has ${O.rows.length}.`:null),i({name:P.name,columns:O.columns,rows:O.rows});const M=O.columns.at(-1);y(M),f(O.columns.filter(A=>A!==M))},S=Number(x),N=!!o&&!c&&u.length>0&&!!g&&!u.includes(g)&&Number.isFinite(S)&&S>0,$=async()=>{var _,P;if(!(!o||!N)){b(!0),k(null);try{s(await e.startLearningBatch(n,{inputs:u,answer:g,rows:o.rows,max_cost_usd:S}))}catch(O){k(O instanceof ze?((P=(_=O.fields)==null?void 0:_[0])==null?void 0:P.message)??O.message:O instanceof Error?O.message:String(O)),b(!1)}}};return t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsx(wt,{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(wt,{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(x5,{label:_,checked:u.includes(_),disabled:_===g,onChange:P=>f(O=>P.target.checked?o.columns.filter(M=>O.includes(M)||M===_):O.filter(M=>M!==_))},_))})}),t.jsx(wt,{label:"The answer column",note:"What the agent is told after each answer: the reference it should have given.",children:t.jsx(Et,{label:"The answer column",value:g,onChange:_=>{y(_),f(P=>P.filter(O=>O!==_))},options:o.columns.map(_=>({value:_,label:_}))})}),t.jsx(wt,{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 ${eo(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(eI,{columns:[...u,g].filter(Boolean),rows:o.rows.slice(0,3)})]}),j&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:j}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{variant:"primary",disabled:!N||v,onClick:()=>void $(),children:v?"Starting":"Learn"}),t.jsx(B,{variant:"ghost",onClick:r,disabled:v,children:"Cancel"})]})]})}function eI({columns:e,rows:n}){return t.jsx("div",{className:"overflow-x-auto","aria-label":"The first rows",children:t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{children:e.map(s=>t.jsx("th",{className:"caps border-b px-2 py-1 text-left font-semibold",children:s},s))})}),t.jsx("tbody",{children:n.map((s,r)=>t.jsx("tr",{children:e.map(o=>t.jsx("td",{className:"max-w-64 truncate border-b px-2 py-1",children:s[o]},o))},r))})]})})}const tI={running:"active",completed:"success",cancelled:"muted",stopped:"warning"};function nI({v2:e,agentId:n,batch:s,onBatch:r}){const[o,i]=p.useState(!1),[c,d]=p.useState(null),u=async()=>{i(!0),d(null);try{r(await e.cancelLearningBatch(n,s.id))}catch(y){d(y instanceof Error?y.message:String(y))}i(!1)},f=YM(s),g=s.cost_usd===null?"unknown":eo(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(Ne,{tone:tI[s.status],children:s.status}),t.jsxs("span",{className:"font-mono text-body",children:[s.finished," of ",s.total," rows"]})]}),ix(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(Ao,{label:"Right",value:`${s.right}`}),t.jsx(Ao,{label:"Wrong",value:`${s.wrong}`}),t.jsx(Ao,{label:"Failed",value:`${s.failed}`}),t.jsx(Ao,{label:"Cost so far",value:`${g} of ${eo(s.max_cost_usd)}`}),t.jsx(Ao,{label:"Notes learned",value:`${s.lessons.notes.length}`}),t.jsx(Ao,{label:"Skills learned",value:`${s.lessons.skills.length}`}),t.jsx(Ao,{label:"Workflow revisions",value:`${s.revisions.length}`}),t.jsx(Ao,{label:"Paths",value:`${s.paths.agent} by hand, ${s.paths.handed_back} handed back, ${s.paths.workflow} workflow`})]}),s.lessons.notes.length+s.lessons.skills.length+s.lessons.workflows.length>0&&t.jsxs("p",{className:"text-body text-muted-foreground",children:["Learned: ",[...s.lessons.notes,...s.lessons.skills.map(y=>`${y} (skill)`),...s.lessons.workflows.map(y=>`${y} (workflow)`)].join(", "),"."]}),t.jsx("div",{className:"max-h-96 overflow-auto",children:t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{children:["Row","Result","Path","Cost","Answer","Reference"].map(y=>t.jsx("th",{className:"caps sticky top-0 border-b bg-card px-2 py-1 text-left font-semibold",children:y},y))})}),t.jsx("tbody",{children:s.rows.map(y=>t.jsxs("tr",{"aria-current":s.current===y.n?"step":void 0,children:[t.jsx("td",{className:"border-b px-2 py-1",children:y.n}),t.jsx("td",{className:"border-b px-2 py-1",children:y.state==="done"?t.jsx(Ne,{tone:y.right?"success":"error",children:y.right?"right":"wrong"}):y.state==="failed"?t.jsx(Ne,{tone:"error",title:y.error,children:"failed"}):t.jsx(Ne,{tone:y.state==="running"?"active":"muted",children:y.state==="running"?"running":"waiting"})}),t.jsx("td",{className:"border-b px-2 py-1",children:y.path?QM[y.path]:""}),t.jsx("td",{className:"border-b px-2 py-1",children:y.total_usd==null?"":eo(y.total_usd)}),t.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:y.answer??void 0,children:y.answer??""}),t.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:y.reference,children:y.reference})]},y.n))})]})})]})}const Ao=({label:e,value:n})=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:e}),t.jsx("dd",{className:"break-words",children:n})]}),sI="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).",vg=e=>`${Math.round(e*1e3)/10}%`;function rI(e){const{cost_per_task_usd:n,baseline_cost_per_task_usd:s}=e,r=n!==null&&s!==null,o=r&&n>0?s/n:null,[i,c]=e.ci;return{accuracy:vg(e.accuracy),accuracyVs:`95% interval ${vg(i)} to ${vg(c)}, n=${e.n.toLocaleString("en-US")}`,cost:r?o===null||s===0?ir(n):o>=1?`${ox(o)} cheaper`:`${ox(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 Bk({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:_r(i,"the held-out test"),onRetry:()=>u(f=>f+1),className:""}):r?t.jsx(oI,{result:r.latest}):t.jsx(gn,{className:"h-[116px] w-full"})}function oI({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(aI,{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:sI})]})]})}function aI({result:e}){const n=rI(e),s=[{label:"Held-out accuracy",value:n.accuracy,lines:[n.accuracyVs]},{label:"Cost a task",value:n.cost,lines:[n.costVs]}];return t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"grid grid-cols-1 sm:grid-cols-2",children:s.map((r,o)=>t.jsxs("div",{className:o?"border-t px-4 py-3 sm:border-l sm:border-t-0":"px-4 py-3",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:r.label}),t.jsx("dd",{className:"mt-1 font-mono text-figure font-semibold tabular-nums",children:r.value}),r.lines.map(i=>t.jsx("dd",{className:"mt-0.5 font-mono text-small text-muted-foreground",children:i},i))]},r.label))}),e.label_source&&t.jsxs("p",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["Labels: ",e.label_source]})]})}const Uf="https://api.githubcopilot.com/mcp/",bd={composio:"Composio",github:"GitHub",url:"URL"},Gk=/^[a-z][a-z0-9-]{0,31}$/,Vv=[{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:Uf,readOnly:`${Uf}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."}],U2=e=>Vv.find(n=>n.id===e);function iI(e){const n=new URLSearchParams(e??""),s=n.get("add");if(!s||!Gk.test(s))return;const r=n.get("toolkit")??"",o=n.get("preset")??void 0;if(o==="composio"&&Gk.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=U2(o);return i?{name:s,preset:i.id}:{name:s,...n.get("auth")==="github_app"?{auth:"github_app"}:{}}}const lI="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.",W2=(e,n)=>`mcp:${e}/${n}`;function Ho(e){const n=/^mcp:([^/]+)\/(.+)$/.exec(e);return n?{server:n[1],tool:n[2]}:null}function cI(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 dI(e,n){return e.flatMap(s=>{const r=Ho(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 ro(e){var i,c,d,u,f,g,y,x;if(!(e instanceof ze))return{text:`The request didn't reach this server: ${e instanceof Error?e.message:String(e)}`};const n=(i=e.fields)==null?void 0:i.find(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.`}:{}}:(y=e.fields)!=null&&y.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 Kk={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"},uI="the sign-in didn't finish: try again",fI=e=>e&&Object.hasOwn(Kk,e)?Kk[e]:uI;function mI(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 yd=Ho;function hI(e){const n=Ho(e);return n?`${n.server} · ${n.tool}`:null}const pI="https://chatgpt.com/#settings",lx="chatgpt",Bc=e=>!!e&&e.startsWith(`${lx}/`)&&e.length>lx.length+1,H2="Codex and pi agents run on your ChatGPT plan. Claude Agent, OpenCode, Jev decisions and paid tools need their own keys.",gI="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.",xI="This sign-in is yours: don't let other people run agents on this server with it.",vI="Signed out. If ChatGPT still lists AgentRun under connected apps, disconnect it there.",bI="Signed out here. OpenAI didn't confirm the revocation: remove AgentRun in your ChatGPT settings.",yI="Your ChatGPT sign-in expired. Sign in again.",B2="Requests on your ChatGPT plan cost no dollars here; your plan's own limits apply.",wI=`Counts dollars. ${B2}`,jI=new Set(["signed_out","pending","signed_in","expired"]),Wf=e=>e&&typeof e=="object"&&jI.has(String(e.state))?e:null,kI=e=>e.charAt(0).toUpperCase()+e.slice(1),NI=e=>`Signed in as ${e.email??"your ChatGPT account"}${e.plan?` (${kI(e.plan)})`:""}`;function ul(e,n){return Bc(e)?{text:`${e.slice(lx.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 G2(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 SI(e,n,s,r){return!e||typeof r!="number"||Bc(e)?null:G2(n,s).has(e)?`free model: up to ${r} requests`:null}function CI(e){return e>=1e6?`${Math.round(e/1e6*10)/10}M`.replace(/\.0M$/,"M"):`${Math.round(e/1e3)}K`}function EI(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.models)??[]}function q2(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 $I="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",_I="none yet: add a model key in Settings → Model keys",K2=e=>ul(e,null).text,Yv=(e,n)=>[e,n!=null&&n.model?n.tier:void 0,n!=null&&n.model?K2(n.model):void 0].filter(Boolean).join(" · "),V2=e=>e!=null&&e.model?`ran on ${K2(e.model)}${e.tier?` (the ${e.tier} tier)`:""}`:"",TI="http://www.w3.org/2000/svg",Ai=16,cn=240,RI=40,AI=58,bg=16,yg=26,Qu=18,Oi=14,Vk=16,OI=26,PI=14,LI=22,Ds=14,Yk=16,Ju=16,MI=4,II=10,zI=18,DI=30,FI=5,Sc=124,cx=34,UI=4,wg=10*.6,WI=12.5*.6,Gc=10.5*.6,Qk=11*.6,Qv=9*.66,Jk=10.5*.6,HI={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"},Jv=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),Hf={review:"needs review","not-run":"",pending:""};function jt(e,n,...s){const r=document.createElementNS(TI,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 Cr=(e,n)=>e.length>n?`${e.slice(0,n-1)}…`:e,BI=(e,n)=>{const s=/^(.*) (\d\.\d\d)$/.exec(e);return!s||e.length<=n?Cr(e,n):`${Cr(s[1],Math.max(2,n-s[2].length-1))} ${s[2]}`},zo=(e,n)=>Math.max(2,Math.floor(e/n)),Bo=(e,n)=>Math.ceil(e.length*n),Ws=(e,n,s,r,o)=>jt("line",{x1:e,y1:n,x2:s,y2:r,class:o?`wire ${o}`:"wire"});function Y2(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 Xv(e,n){var u,f,g,y;const{diff:s={},status:r={},fired:o}=e.marks,i=n===o?"escalated":r[n],c=i&&Jv.has(i)?i:"",d=(u=s.added)!=null&&u.includes(n)?"NEW":(f=s.edited)!=null&&f.includes(n)?"EDITED":(g=s.moved)!=null&&g.includes(n)?"MOVED":"";return{state:c,tag:d,fired:n===o,selected:((y=e.marks.selected)==null?void 0:y.path)===n&&e.marks.selected.item==null}}function wd(e,n,s){var x,h,v;const r=Xv(e,n.path),o=(x=e.marks.meta)==null?void 0:x[n.path],i=o!=null&&o.tool?yd(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)?`, ${V2(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(b=>`• ${b.text}`).join(`
633
- `)}`);const f=o!=null&&o.decision&&o.provider?`who-${o.provider==="parallel"||o.provider==="openrouter"?o.provider:"jev"}`:n.kind==="route"&&o&&!o.decision?"who-control":`who-${HI[n.kind]??"code"}`;let g=`node ${s} ${f}`;r.state&&(g+=` ${r.state}`),r.fired&&(g+=" fired"),r.tag&&(g+=` ${r.tag.toLowerCase()}`),r.selected&&(g+=" selected");const y=jt("g",{class:g,"data-path":n.path},jt("title",null,u));return e.svg.appendChild(y),y}const Ji=e=>Bo(e,Qv)+10;function wf(e,n,s,r,o="tag"){const i=Ji(r);return ks(e,[jt("rect",{x:n,y:s,width:i,height:13,class:`${o}-box`}),jt("text",{x:n+i/2,y:s+9.5,class:o,"text-anchor":"middle"},r)]),i}const GI=(e,n)=>{var s,r;return!!((r=(s=e.marks.meta)==null?void 0:s[n.path])!=null&&r.decision)},Wm=(e,n)=>GI(e,n)?AI:RI;function Zv(e,n,s,r,o){var k,E,S,N,$;const i=Xv(e,s.path),c=(k=e.marks.meta)==null?void 0:k[s.path],d=Wm(e,s),u=(E=e.marks.verdict)==null?void 0:E[s.path],f=i.state in Hf?Hf[i.state]:i.state,g=((S=c==null?void 0:c.questions)==null?void 0:S.length)??0,y=c!=null&&c.tool?yd(c.tool):null,x=(N=e.marks.ran)==null?void 0:N[s.path],h=(x&&!(c!=null&&c.decision)?Yv(s.kind,x):s.kind)+(y?` · ${y.tool} on ${y.server}`:c!=null&&c.tool?` · ${c.tool}`:s.via?` · ${s.via}`:"")+(c!=null&&c.decision&&g?` · ${g} ${g===1?"question":"questions"}`:""),v=[($=c==null?void 0:c.images)!=null&&$.length?"IMG":"",c!=null&&c.web?"WEB":"",y?"MCP":""].filter(Boolean),b=v.reduce((_,P)=>_+Ji(P)+4,0);i.selected&&n.appendChild(jt("rect",{x:r-4,y:o-4,width:cn+8,height:d+8,class:"sel"})),ks(n,[jt("rect",{x:r,y:o,width:cn,height:d,class:"box"}),jt("rect",{x:r+10,y:o+9,width:8,height:8,class:"swatch"}),jt("text",{x:r+24,y:o+17,class:"label"},Cr(s.label,zo(cn-34-b,WI))),jt("text",{x:r+24,y:o+31,class:"kind"},Cr(h,zo(cn-34-(f?Bo(f,Qv)+8:0),Gc))),f?jt("text",{x:r+cn-10,y:o+31,class:"state","text-anchor":"end"},f):null]);let j=r+cn-8;for(const _ of v.reverse())j-=Ji(_),wf(n,j,o+7,_,"badge"),j-=4;if(c!=null&&c.decision&&c.provider){const _=wf(n,r+24,o+38,c.provider,"chip"),P=u?BI(u,zo(cn-44-_-20,Jk)):"",O=cn-40-_-(P?Bo(P,Jk)+10:0),M=(x==null?void 0:x.model)??c.model;M&&O>24&&n.appendChild(jt("text",{x:r+24+_+6,y:o+47.5,class:"model"},Cr(M,zo(O,Gc)))),P&&n.appendChild(jt("text",{x:r+cn-10,y:o+47.5,class:"verdict","text-anchor":"end"},P))}else u&&n.appendChild(jt("text",{x:r+cn-10,y:o+17,class:"verdict","text-anchor":"end"},u));i.tag&&wf(n,r+cn-Ji(i.tag),o-7,i.tag)}function qI(e,n){return{w:cn,h:Wm(e,n),cx:cn/2,place:(s,r)=>Zv(e,wd(e,n,"card"),n,s,r)}}function Q2(e,n,s){const r=Xv(e,n.path),o=r.state==="done"?"passed":r.state in Hf?Hf[r.state]:r.state,i=Cr(n.label===n.kind?"exit":`exit: ${n.label}`,40),c=Bo(i,Gc)+16;return{w:Oi+c+(r.tag?6+Ji(r.tag):0)+(o?6+Bo(o,Qv):0),h:yg,cx:0,exit:!0,place:(d,u)=>{const f=wd(e,n,"exit"),g=u+yg/2;let y=d+Oi+c;s&&f.appendChild(Ws(d,u,d,u+yg,"spine")),r.selected&&f.appendChild(jt("rect",{x:d+Oi-3,y:g-Qu/2-3,width:c+6,height:Qu+6,class:"sel"})),ks(f,[Ws(d,g,d+Oi,g,"exit-wire"),jt("rect",{x:d+Oi,y:g-Qu/2,width:c,height:Qu,class:"exit-box"}),jt("text",{x:d+Oi+8,y:g+3.5,class:"exit-text"},i)]),r.tag&&(wf(f,y+6,g-6.5,r.tag),y+=6+Ji(r.tag)),o&&f.appendChild(jt("text",{x:y+6,y:g+3.5,class:"state"},o))}}}function KI(e,n,s){const r=s.map(d=>d.node.kind==="escalate"?Q2(e,d.node,!1):Hm(e,d.node));let o=cn/2,i=cn/2,c=-bg;for(const d of r)o=Math.max(o,d.cx),i=Math.max(i,d.w-d.cx),c+=d.h+bg;return{w:o+i,h:c,cx:o,place:(d,u)=>{const f=wd(e,n,"chain"),g=d+o;let y=u,x=null;r.forEach((h,v)=>{v&&(y+=bg),h.exit?x===null&&(x=y):x!==null&&f.appendChild(Ws(g,x,g,y,"spine")),h.place(h.exit?g:g-h.cx,y),y+=h.h,h.exit||(x=y)}),r[r.length-1].exit&&x!==null&&f.appendChild(Ws(g,x,g,y,"spine"))}}}function VI(e,n,s){const r=Wm(e,n),o=s.map(h=>({kid:h,box:Hm(e,h.node),x:0,c:0}));let i=0,c=0;o.forEach((h,v)=>{v&&(i+=LI),h.x=i,h.c=i+h.box.cx,i+=h.box.w,c=Math.max(c,h.box.h)});const d=o.length-1,u=Math.round((o[0].c+o[d].c)/2),f=Math.min(0,u-cn/2),g=Math.max(i,u+cn/2),y=r+Vk+OI,x=y+c+PI;return{w:g-f,h:x,cx:u-f,place:(h,v)=>{const b=wd(e,n,"card"),j=h-f,k=v+r+Vk,E=v+x;Zv(e,b,n,j+u-cn/2,v),b.appendChild(Ws(j+u,v+r,j+u,k)),d&&ks(b,[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,P=e.taken.has(_);if(b.appendChild(jt("line",{x1:$,y1:k,x2:$,y2:v+y,class:P?"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,M=Cr(S.kid.name,zo(O,Gc)),R=jt("text",{x:$+6,y:k+15,class:P?"branch-name taken":"branch-name"},M);b.appendChild(M===S.kid.name?R:jt("g",null,jt("title",null,S.kid.name),R))}b.appendChild(Ws($,v+y+S.box.h,$,E,P?"taken":void 0)),S.box.place(j+S.x,v+y)})}}}const YI=e=>e.replace(/^.*\//,"").replace(/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,"");function QI(e,n,s,r,o,i){const c=Jv.has(s.status)?s.status:"pending",d=s.label?YI(s.label):`#${s.index+1}`,u=s.outcome??(c==="review"?"needs review":c==="not-run"?"not run":c),f=s.p!==void 0?s.p.toFixed(2):"",g=`#${s.index+1}${s.label?` ${s.label}`:""}: ${c==="review"?"needs review":c.replace("-"," ")}${s.outcome?`, ${s.outcome}`:""}${s.pNote?` (${s.pNote})`:""}`,y=jt("g",{class:`rcell ${c}${s.tone?` tone-${s.tone}`:""}${i?" picked":""}`,"data-path":n.path,"data-item":s.index},jt("title",null,g),jt("rect",{x:r,y:o,width:Sc,height:cx,class:"cell"}),jt("rect",{x:r,y:o,width:3,height:cx,class:"cell-edge"}),jt("text",{x:r+9,y:o+14,class:"cell-name"},Cr(d,zo(Sc-14,wg))),jt("text",{x:r+9,y:o+27,class:"cell-out"},Cr(u,zo(Sc-18-(f?Bo(f,wg)+6:0),wg))),f?jt("text",{x:r+Sc-6,y:o+27,class:"cell-p","text-anchor":"end"},f):null);e.appendChild(y)}function JI(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<=DI,[o,i,c]=r?[Sc,cx,UI]:[Ju,Ju,MI],d=Math.min(s.length,r?FI:II),u=Math.ceil(s.length/d),f=d*(o+c)-c,g=u*(i+c)-c+zI+(r?4:0),y={};for(const k of s)y[k.status]=(y[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}`),b=[`${y.done??0}/${s.length} done`,y.working?`${y.working} working`:"",y.held?`${y.held} held`:"",y.failed?`${y.failed} failed`:"",y.review?`${y.review} review`:"",...h].filter(Boolean).join(" · ");return{w:Math.max(f,Bo(b,Gc)),h:g,place:(k,E,S)=>{const N=E-f/2,$=e.marks.selected;s.forEach((_,P)=>{const O=N+P%d*(o+c),M=S+Math.floor(P/d)*(i+c),R=Jv.has(_.status)?_.status:"pending",A=($==null?void 0:$.path)===n.path&&$.item===_.index;if(r){QI(k,n,_,O,M,A);return}ks(k,jt("rect",{x:O,y:M,width:Ju,height:Ju,class:`cell ${R}${A?" picked":""}`,"data-path":n.path,"data-item":_.index},jt("title",null,`#${_.index+1}${_.label?` ${_.label}`:""}: ${R==="review"?"needs review":R.replace("-"," ")}`)))}),ks(k,jt("text",{x:E,y:S+g-4,class:"caption","text-anchor":"middle"},b))}}}function XI(e,n,s){const r=Hm(e,s),o=Wm(e,n),i=n.kind==="map"?JI(e,n):null,c=i?i.h+Ds:0,d=Math.max(cn/2,r.cx,i?i.w/2:0)+Ds,u=Math.max(cn/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,y)=>{const x=wd(e,n,"card"),h=g+d;if(ks(x,jt("rect",{x:g,y:y+o/2,width:d+u,height:f-o/2,class:"frame"})),i?(ks(x,Ws(h,y+o,h,y+o+Ds)),ks(x,Ws(h,y+o+Ds+i.h,h,y+o+Ds+c))):ks(x,Ws(h,y+o,h,y+o+Ds)),ks(x,Ws(h,y+o+Ds+c+r.h,h,y+f)),Zv(e,x,n,h-cn/2,y),i){const v=jt("g",{class:"items"});i.place(v,h,y+o+Ds),x.appendChild(v)}r.place(h-r.cx,y+o+Ds+c)}}}function J2(e,n){return e.kind==="escalate"?"exit":n.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function Hm(e,n){const s=e.kids[n.path]??[],r=J2(n,s);return r==="exit"?Q2(e,n,!0):r==="leaf"?qI(e,n):r==="chain"?KI(e,n,s):r==="fan"?VI(e,n,s):XI(e,n,s[0].node)}function eb(e){const{byPath:n,kids:s}=Y2(X2(e)),r=o=>{const i=s[o.path]??[],c=J2(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 Bm=e=>`${e} ${e===1?"node":"nodes"}`,X2=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 ZI(e,n,s={}){var g;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const r=Y2(X2(n)),o=(y,x)=>(e.setAttribute("viewBox",`0 0 ${y} ${x}`),e.setAttribute("width",String(y)),e.setAttribute("height",String(x)),e.style.setProperty("min-width",`${Math.min(y,480)}px`),{w:y,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=Hm(i,r.byPath["/root"]);c.place(Ai,Ai);let d=c.w,u=c.h;const f=(((g=s.diff)==null?void 0:g.removed)??[]).map(y=>`${y.label} (${y.kind})`);if(f.length){const y=["Removed:",...f.map(h=>Cr(h,zo(Math.max(d,300),Qk)))],x=jt("g",{class:"removed-list"},jt("title",null,`Removed: ${f.join(", ")}`));y.forEach((h,v)=>{x.appendChild(jt("text",{x:Ai,y:Ai+u+33+v*Yk,class:"removed"},h)),d=Math.max(d,Bo(h,Qk))}),e.appendChild(x),u+=22+y.length*Yk}return o(d+2*Ai,u+2*Ai)}function ez(e){var o,i;const n=e,s=(o=n==null?void 0:n.closest)==null?void 0:o.call(n,"[data-item]");if(s)return{path:s.getAttribute("data-path"),item:Number(s.getAttribute("data-item"))};const r=(i=n==null?void 0:n.closest)==null?void 0:i.call(n,"g[data-path]");return!r||r.classList.contains("chain")?null:{path:r.getAttribute("data-path"),item:null}}const tz=1600;function jd({graph:e,marks:n,onSelect:s,className:r,label:o="Workflow graph",minScale:i=.8,maxScale:c=1.3}){const d=p.useRef(null),[u,f]=p.useState({w:0,h:0}),[g,y]=p.useState(0),x=p.useMemo(()=>JSON.stringify([(e==null?void 0:e.nodes)??null,n??null]),[e,n]);p.useEffect(()=>{if(!d.current)return;const v=ZI(d.current,e,n);f(b=>b.w===v.w&&b.h===v.h?b:v),d.current.style.setProperty("--wf-phase",`-${Date.now()%tz}ms`)},[x]),p.useEffect(()=>{var j;const v=(j=d.current)==null?void 0:j.parentElement;if(!v||typeof ResizeObserver>"u")return;const b=new ResizeObserver(([k])=>y(k.contentRect.width));return b.observe(v),()=>b.disconnect()},[]);const h=u.w&&g?Math.min(c,Math.max(i,g/u.w)):1;return t.jsx("svg",{ref:d,role:"img","aria-label":o,className:ie("wf select-none",r),style:u.w?{width:u.w*h,height:u.h*h,maxWidth:"none",minWidth:0}:void 0,onClick:v=>{const b=ez(v.target);b&&s&&s(b)}})}function kd({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:ie("inline-block size-2.5 border",r)}),o]},o))]})}const nz=3e3,sz=e=>e.word==="Held"||e.word==="Not decided",Xk=e=>`${Math.round(e*100)}%`,Z2=e=>`${e} ${e===1?"input":"inputs"}`;function rz(e){if(!e)return"Replay started: its runs are queued.";const n=e.outcomes,s=n.answered+n.handed_back+n.failed+n.skipped_write;return`Checking on ${Z2(e.inputs)} of the agent's own runs: ${s} of ${e.inputs} ended (${n.answered} answered alone, ${n.handed_back} handed back${n.failed?`, ${n.failed} failed`:""}${n.skipped_write?`, ${n.skipped_write} skipped`:""}).`}function oz(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 ${Xk(r.wf_acc)} vs agent ${Xk(r.agent_acc)} on ${Z2(r.n)} of the agent's own runs, ${r.agree} said what the agent said, ${r.handed_back} handed back`:null}}function az({v2:e,agentId:n,workflow:s,digest:r,offered:o,resume:i=null,onStarted:c,onDecided:d,pollMs:u=nz}){const[f,g]=p.useState(i?{at:"running",replay:i,read:null}:{at:"idle"});p.useEffect(()=>{i&&g(j=>j.at==="idle"?{at:"running",replay:i,read:null}:j)},[i]);const y=p.useRef(d);y.current=d;const 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=y.current)==null||N.call(y)}},S=>{j&&g(N=>N.at==="running"?{...N,unread:S instanceof Error?S.message:String(S)}:N)})};return E(),()=>{j=!1,k&&clearTimeout(k)}},[e,n,s,r,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})})},b=f.at==="starting"||f.at==="running";return!o&&f.at==="idle"?null:t.jsxs("div",{className:"mt-2 space-y-1","data-testid":"replay-revision",children:[(f.at==="idle"||f.at==="starting"||(f.at==="refused"||f.at==="decided")&&o)&&t.jsx(B,{size:"sm",onClick:v,disabled:b,"aria-label":`Check revision ${r.slice(0,7)} on the inputs of the agent's own runs`,children:f.at==="starting"?"Starting…":f.at==="idle"?"Replay":"Replay again"}),f.at==="running"&&t.jsxs("p",{className:"break-words text-body",role:"status","data-testid":"replay-progress",children:[f.unread!==void 0?`Couldn't read the replay: ${f.unread} `:rz(f.read),f.unread!==void 0&&t.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:()=>g({at:"running",replay:f.replay,read:f.read}),children:"Check again"})]}),f.at==="refused"&&t.jsxs("p",{className:"break-words text-body",role:"alert","data-testid":"replay-refused",children:[f.message,f.code&&t.jsx("span",{className:"ml-2 font-mono text-label text-muted-foreground",children:f.code})]}),f.at==="decided"&&(()=>{const j=oz(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 jg=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},Zk=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function iz(e,n,s,r,o){const i=[e.length&&`added ${Zk(e.length,"node")} (${jg(e)})`,n.length&&`edited ${jg(n)}`,s.length&&`removed ${Zk(s.length,"node")} (${jg(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 lz(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:il(i)}catch{c=null}if(!(c!=null&&c.nodes.length)){r+=1;continue}const d=s?s2(s,c):null,u=d?d.added.map(b=>b.path):c.nodes.map(b=>b.path),f=b=>{var j;return((j=c.nodes.find(k=>k.path===b))==null?void 0:j.kind)!=="chain"},g=d?[...d.changed.map(b=>b.next),...d.rewritten.map(b=>b.next)]:[],y=d?d.moved.map(b=>b.next):[],x=new Map(c.nodes.map(b=>[b.path,b.label])),h=d?d.removed.filter(b=>b.kind!=="chain").map(b=>b.label):[],v=d?d.edges.added.length+d.edges.removed.length:0;n.push({digest:o.digest??null,commit:o.commit,at:o.at,run:"run"in o.by?o.by.run:null,reason:o.reason,graph:c,marks:{meta:hd(i,c),diff:{added:u,edited:g,moved:y,removed:d?d.removed.map(({label:b,kind:j})=>({label:b,kind:j})):[]}},added:u,edited:g,removed:h,line:d?iz(u.filter(f).map(b=>x.get(b)??b),g.filter(f).map(b=>x.get(b)??b),h,y.length,v):`First version: ${Bm(eb(c))}`}),s=c}return{steps:n,unreadable:r}}const cz=50,dz=1800;function uz({v2:e,agentId:n,workflows:s,promotions:r=[],serving:o=[],cost:i=null,onReplayed:c}){const d=s.filter(y=>y.status==="active").map(y=>y.name),[u,f]=p.useState(null),g=u!==null&&d.includes(u)?u:d[0]??null;return g===null?null:t.jsx(fz,{v2:e,agentId:n,name:g,choices:d,onPick:f,promotions:r,serving:o,stopped:Kv(i,g),onReplayed:c},g)}const Xu="Learned workflow";function fz({v2:e,agentId:n,name:s,choices:r,onPick:o,promotions:i,serving:c,stopped:d,onReplayed:u}){var j;const[f,g]=p.useState(null),[y,x]=p.useState(null),[h,v]=p.useState(0);p.useEffect(()=>{let k=!0;return x(null),Promise.resolve().then(()=>e.learnedWorkflowRevisions(n,s,cz)).then(E=>{k&&g(E)},E=>{k&&x(E??new Error("unknown"))}),()=>{k=!1}},[e,n,s,h]);const b=t.jsxs("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-4 py-3",children:[t.jsxs("h2",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"caps text-small font-semibold",children:Xu})," ",t.jsx("span",{className:"ml-1 break-all font-mono text-body font-semibold",children:s})]}),r.length>1&&t.jsx(Et,{small:!0,className:"w-56 max-w-full",label:"Learned workflow",value:s,onChange:o,options:r.map(k=>({value:k,label:k}))})]});return y&&!f?t.jsxs("section",{className:"border","aria-label":Xu,children:[b,t.jsx("div",{className:"p-4",children:t.jsx(ss,{problem:_r(y,"the learned workflow"),onRetry:()=>v(k=>k+1),className:""})})]}):f?t.jsxs("section",{className:"border","aria-label":Xu,children:[b,t.jsx(mz,{data:f,promotions:i,serving:((j=c.find(k=>k.workflow===f.name))==null?void 0:j.digest)??null,stopped:d,replay:{v2:e,agentId:n,onStarted:u,onDecided:()=>{v(k=>k+1),u==null||u()}}})]}):t.jsxs("section",{className:"border","aria-label":Xu,"aria-busy":!0,children:[b,t.jsx("div",{className:"p-4",children:t.jsx(gn,{className:"h-48 w-full"})})]})}function mz({data:e,stepMs:n=dz,promotions:s=[],serving:r=null,stopped:o=null,replay:i}){const{steps:c,unreadable:d}=p.useMemo(()=>lz(e.revisions),[e.revisions]),[u,f]=p.useState(Math.max(0,c.length-1)),[g,y]=p.useState(!1),x=p.useRef(u);x.current=u;const h=p.useRef(c);if(p.useEffect(()=>{var O;const $=h.current;h.current=c;const _=((O=$[x.current])==null?void 0:O.digest)??null,P=$===c||x.current>=$.length-1||_===null?-1:c.findIndex(M=>M.digest===_);f(P>=0?P:Math.max(0,c.length-1)),y(!1)},[c]),p.useEffect(()=>{if(!g)return;const $=setInterval(()=>f(_=>Math.min(_+1,c.length-1)),n);return()=>clearInterval($)},[g,c.length,n]),p.useEffect(()=>{g&&u>=c.length-1&&y(!1)},[g,u,c.length]),!e.revisions.length)return null;if(!c.length)return t.jsxs("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:["This workflow's revisions can't be read as a workflow",d?`: ${d} ${d===1?"revision":"revisions"} did not read`:"","."]});const v=c[Math.min(u,c.length-1)],b=c.length,j=$=>{y(!1),f(Math.max(0,Math.min(b-1,$)))},k=()=>{if(g)return y(!1);u>=b-1&&f(0),y(!0)},E=`Revision ${Math.min(u,b-1)+1} of ${b}, ${ht(v.at)}`,S=qv(s,e.name,v.digest),N=Hc(S,{serving:r,stopped:o});return t.jsxs("div",{className:"space-y-3 p-4",children:[b>1&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsxs(B,{size:"sm",onClick:k,"aria-label":g?"Pause the replay":"Play the replay","aria-pressed":g,children:[g?t.jsx(nl,{"aria-hidden":!0}):t.jsx(Vo,{"aria-hidden":!0}),g?"Pause":"Play"]}),t.jsx(B,{size:"icon",onClick:()=>j(u-1),disabled:u<=0,"aria-label":"Previous revision",children:t.jsx(xT,{"aria-hidden":!0})}),t.jsx(B,{size:"icon",onClick:()=>j(u+1),disabled:u>=b-1,"aria-label":"Next revision",children:t.jsx(Es,{"aria-hidden":!0})}),t.jsx(b5,{min:1,max:b,value:u+1,onChange:$=>j($-1),label:"Revision",valueText:E,className:"basis-full sm:min-w-[10rem] sm:flex-1 sm:basis-0"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{children:b>1?`Revision ${u+1} of ${b}`:"One revision"})," · ",t.jsx("time",{dateTime:v.at,children:ht(v.at)})," · ",v.run?t.jsxs("a",{href:`#/runs/${encodeURIComponent(v.run)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ea(v.run)]}):"a person"]}),t.jsx("p",{className:"mt-1 break-words text-lead",role:"status","data-testid":"replay-line",children:v.line}),v.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-body text-muted-foreground",children:v.reason}),t.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-body","data-testid":"standing",children:[t.jsx(Ne,{tone:N.tone,children:N.text}),t.jsx("span",{className:"min-w-0 break-words text-muted-foreground",children:S?Aa(S):v.digest?"No check yet: a new revision is checked on the inputs of the agent's own runs before it serves.":"Its file did not read: no standing."})]}),i&&v.digest&&t.jsx(az,{v2:i.v2,agentId:i.agentId,workflow:e.name,digest:v.digest,offered:sz(N),resume:(S==null?void 0:S.decided)==="replaying"?S.replay_id??null:null,onStarted:i.onStarted,onDecided:i.onDecided},v.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(jd,{graph:v.graph,marks:v.marks,label:`The workflow at revision ${u+1} of ${b}, as a graph`,minScale:.5,maxScale:1.6,className:"m-auto"})}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(kd,{}),t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:"NEW"})," first appears in this revision · ",t.jsx("span",{className:"font-semibold text-foreground",children:"EDITED"})," its prompt, code, inputs or tier changed"]})]}),(e.total>e.revisions.length||e.truncated||d>0)&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[e.total>e.revisions.length&&`The latest ${e.revisions.length} of ${e.total} revisions. `,e.truncated&&"Older changes are past the log this server keeps. ",d>0&&`${d} ${d===1?"revision":"revisions"} could not be read as a workflow and ${d===1?"is":"are"} left out.`]})]})}const e0=8,hz={promote:"success",hold:"warning",revision:"active"};function t0({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,e0);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(gz,{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?Kv(r,u.compile.workflow):null}):t.jsx(xz,{record:u.record})},u.key)})}),c.length>e0&&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 pz=({id:e})=>t.jsxs("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ea(e)]}),eC=({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(pz,{id:n})]}):null]});function gz({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:Hc(qv(n,e.workflow,e.digest),{serving:s,stopped:r});return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?t.jsx(Ne,{tone:"error",children:"Draft failed"}):t.jsx(Ne,{tone:"plain",children:"Compiled"}),e.workflow?t.jsx("span",{className:"min-w-0 break-all font-mono text-body font-semibold",children:e.workflow}):t.jsx("span",{className:"text-body text-muted-foreground",children:"no workflow kept"}),d&&t.jsx(Ne,{tone:d.tone,children:d.text})]}),e.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(eC,{at:e.at,run:e.run_id})]})}function xz({record:e}){var o;const n=O2(e),s=Hc(e,{serving:e.digest}),r=n==="promote"?s.tone:hz[n];return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(Ne,{tone:r,children:[Gv[n]," · ",Ac[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:Aa(e)}),(o=e.check)!=null&&o.n?e.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-small text-muted-foreground",children:e.reason}):null,t.jsx(eC,{at:e.at})]})}const vz={done:{icon:pl,word:"Done",ink:"text-success-text",edge:"border-t-success"},now:{icon:bT,word:"Next",ink:"text-run-active",edge:"border-t-run-active"},later:{icon:wT,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:fm,word:"Watch",ink:"text-foreground",edge:"border-t-border-strong"}};function n0({stages:e}){return e.length?t.jsx("section",{className:"border","aria-label":"The learning loop","data-testid":"loop-story",children:t.jsx("ol",{className:ie("grid grid-cols-1 gap-px bg-border sm:grid-cols-2",e.length===5?"lg:grid-cols-5":"lg:grid-cols-4"),children:e.map((n,s)=>{const r=vz[n.state],o=r.icon;return t.jsxs("li",{"data-testid":`stage-${n.key}`,"data-state":n.state,className:ie("min-w-0 border-t-2 bg-card px-4 py-3 sm:[&:last-child:nth-child(odd)]:col-span-2 lg:[&:last-child:nth-child(odd)]:col-span-1",r.edge),children:[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:ie("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 tC({id:e,checked:n,onChange:s,busy:r,disabled:o,quiet:i,server:c,problem:d,className:u}){return t.jsxs("div",{className:ie("space-y-2",u),children:[t.jsxs("div",{className:ie("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(cd,{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 bz({fields:e,onFields:n,saved:s,server:r,error:o,warning:i}){const c=e.learning??s,d=dl(c),u=typeof s=="object"?s:!0,f=y=>y==="notes"?"notes":dl(y)?"full":void 0,g=y=>n({learning:y===!1&&s===void 0?void 0:y});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Learning"})}),t.jsx(tC,{id:"learning-switch",className:"border px-4 py-3",checked:d,server:r,onChange:y=>g(y?s==="notes"?"notes":u:!1)}),d&&t.jsx("fieldset",{"aria-label":"What it learns",className:"mt-2 space-y-2",children:[["full","Notes, skills and workflows","Once a job repeats, it can learn it as a workflow and run it as one step."],["notes","Notes and skills only","It never runs a learned workflow, and is never asked to draft one."]].map(([y,x,h])=>t.jsxs("label",{className:ie("flex items-start gap-3 border px-3 py-2.5",f(c)===y&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"learning-kind",className:"mt-1 accent-primary",checked:f(c)===y,onChange:()=>g(y==="full"?u:"notes")}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:x}),t.jsx("span",{className:"block text-small text-muted-foreground",children:h})]})]},y))}),o&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:o}),i&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:i})]})}const yz="Not read: its front matter can't be read; fix the file to use it",wz={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned",superseded:"Replaced"},nC=(e,n)=>`${wz[e]} by ${n==="person"?"you":"a run"}`,dx=e=>e.readme??e.file,kg="Can't tell which version this is: reload.",Gm="It changed since you opened it.",jz=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.",kz=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.`,Nz="Making an agent from it takes your password sign-in in the console.",Sz="Restoring takes your password sign-in in the console.",sC=["feedback","project","reference","user"],Cz={user:"About you",feedback:"How to work",project:"About the work",reference:"Where to look"},rC=e=>Cz[e]??e,Ez={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"},$z=["seeded","reflecting","proposed"],qm=e=>!!e&&$z.includes(e.state),Nd=e=>Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&typeof n.file=="string"&&typeof n.name=="string"):[],oC=e=>Nd(e==null?void 0:e.given),aC=e=>Nd(e==null?void 0:e.read),qc=e=>(e==null?void 0:e.state)==="merged"?Nd(e.learned):[],tb=e=>Nd(e==null?void 0:e.pending),iC=e=>Nd(e),s0=e=>(e==null?void 0:e.state)==="merged"?iC(e.skills):[],r0=e=>(e==null?void 0:e.state)==="merged"?iC(e.workflows):[],_z=e=>tb(e).length>0,Bf=(e,n)=>`${e} ${n}${e===1?"":"s"}`,lC=e=>e.status==="pending",Gf=e=>{var n;return((n=e==null?void 0:e.learning)==null?void 0:n.pending)??0},nb=e=>`${e} learned ${e===1?"item waits":"items wait"} for your OK`;function Tz(e){const n=e&&typeof e=="object"?e.learning:void 0;return n&&typeof n=="object"&&n.approve===!0?"yes":"password"}const cC="Approving needs your password sign-in. Until then it stays out of every run.",Rz="It changes what this agent trusts or skips, so it waits for you.",Az="Runs that use bash on the host run as you. For untrusted tasks, use the sandbox.",dC="[redacted]",uC=e=>e===1?"1 note waits for your OK":e>1?`${e} notes wait for your OK`:"A note waits for your OK",Xi=e=>`${e} ${e===1?"note":"notes"}`,Ga=e=>`${e} ${e===1?"run":"runs"}`,Oz={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"},qf=e=>Oz[e??""]??"stopped",Pz={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 sb(e){return e.detail&&e.detail.trim()?e.detail.trim():Pz[e.reason??""]??"Not kept: learning stopped."}const Lz=e=>e==="seeded"?"Learns after the run":"Looking back",Kf=e=>cl(Math.round(e)*1e3),Oa=e=>to({usd:e,basis:"estimate",charge_state:null,cap_usd:null}),o0=(e,n)=>e>0?Math.round((n-e)/e*100):null,fC=e=>typeof e.before.median_cost_usd=="number"&&typeof e.after.median_cost_usd=="number",mC=e=>e.after.median_learning_usd;function Mz(e){const n=[`answers in ${Kf(e.after.median_duration_s)} instead of ${Kf(e.before.median_duration_s)}`];fC(e)&&n.push(`${Oa(e.after.median_cost_usd)} instead of ${Oa(e.before.median_cost_usd)} a run`);const s=mC(e);return s!==null&&n.push(`learning itself ${Oa(s)} a run`),`Since it learned (${hC(e)}): ${n.join(" · ")}`}function hC(e){return`medians of ${Ga(e.after.runs)} started from what it learned`}const Iz=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)},zz=/^---\n([\s\S]*?)\n?^---$\n?/m,ux=e=>/^"[^"]*"$|^'[^']*'$/.test(e)?e.slice(1,-1):e;function Vf(e){const n=e.replace(/\r\n/g,`
634
- `),s=n.startsWith(`---
635
- `)?zz.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]]=ux((d[2]??"").trim()):c.trim()&&o.push(c)}const i=sC.includes(r.type??"")?r.type:"project";return{name:r.name??"",description:r.description??"",type:i,body:n.slice(s[0].length),rest:o}}const a0=e=>{const n=e.replace(/\s*\n\s*/g," ").trim();return/^["'].*["']$/.test(n)?n.includes('"')?`'${n}'`:`"${n}"`:n},Dz=e=>`---
637
- name: ${a0(e.name)}
638
- description: ${a0(e.description)}
639
- type: ${e.type}
640
- ${e.rest.map(n=>`${n}
641
- `).join("")}---
642
- ${e.body.replace(/^\n*/,`
643
- `)}`;function Fz(e){const n=Vf(e).rest.find(r=>/^supersedes:/.test(r)),s=n?ux(n.replace(/^supersedes:\s*/,"").trim()).trim():"";return s?(/^\[.*\]$/.test(s)?s.slice(1,-1).split(","):[s]).map(r=>ux(r.trim())).filter(Boolean):[]}const Kc=e=>Vf(e).body.replace(/^\n+/,"");function i0(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 Km=(e,n=[])=>{const s=n.filter(o=>o!==dC),r=new URLSearchParams(s.map(o=>["note",o]));return`#/agents/${encodeURIComponent(e)}/learning${s.length?`?${r}`:""}`};function pC(e){return e.kind===qr?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===qr?{...e,kind:qr,agent_label:null}:e}const qr="learning",Uz={seeded:0,reflecting:1,proposed:2,merged:3,dropped:3},fx=e=>e?Uz[e.state]??0:-1,Wz=e=>{const n=e==null?void 0:e.learning;return n&&typeof n=="object"&&typeof n.state=="string"?n:void 0},l0=e=>e.charAt(0).toLowerCase()+e.slice(1);function Hz(e){var s,r;if(!e||fx(e)<2)return"Looking back on this run…";if(e.state==="proposed")return`Looking back: ${l0(((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=qc(e),i=tb(e),c=[...o.length?[`kept ${Xi(o.length)} (${n(o)})`]:[],...i.length?[`${l0(uC(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 qf(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${sb(e)}`}function Bz(e){var i;const n=pC(e),s=n.summary??"",r=e2(n)?`${s} (failed)`:s,o=(i=XS(n))==null?void 0:i.trimEnd();return o&&o.trim()!==s.trim()?`${r}
644
- ${o.replace(/^(?=.)/gm," ")}`:r}function Gz(e,n){const s=e.filter(u=>u.agent_label===qr&&u.kind!==qr);if(!s.length)return e.map(pC);const r=e.findLast(u=>u.kind===qr),o=Wz(r),i=fx(o)>fx(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:qr,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:Hz(i??void 0),text:[...s,...r?[r]:[]].map(Bz).join(`
645
- `)};return e.flatMap(u=>u===c?[d]:u.agent_label===qr||u.kind===qr?[]:[u])}const qz={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},c0=["Added","Replaced","Retired","Removed","Changed"];function Kz(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 Vz(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:Kz(d.patch)])),o=new Map([...oC(n),...aC(n),...qc(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(b=>b.mark==="added").map(b=>b.text.trim()),y=((h=g.find(b=>b.startsWith("superseded_by:")))==null?void 0:h.replace(/^superseded_by:\s*/,""))??((v=qc(n).find(b=>{var j;return(j=b.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&&y?`Replaced: ${f}${y?` → ${i(y)}`:""}`: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:qz[d.withheld??""]??"Not shown."}}).sort((d,u)=>c0.indexOf(d.said.split(":")[0])-c0.indexOf(u.said.split(":")[0]))}function Yz(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 Sd(){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=Sd){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 gC(e,n,s,r){const o=await r(n,s,e.keyFor(n,{content:s}));return e.done(),o}function Qz(e=Sd){const n=new Map;return s=>{let r=n.get(s);return r||(r=Ys(e),n.set(s,r)),r}}function mx(e,n){const s=new Set(e.map(r=>r.run_id));return[...e,...n.filter(r=>!s.has(r.run_id))]}const Za=(e,n,s)=>({..._r(e,n),title:s}),Jz=(e,n)=>{const s=e.get(n);return s!=null&&s.title?Cn(s):`run ${ea(n)}`},xC="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",Xz=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),d0=20,Zz=15e3;function Nr(e,n=!1){const[s,r]=p.useState(n),o=p.useRef(Symbol("learning interaction")).current;return p.useEffect(()=>()=>{e.items.delete(o),e.changed(e.items.size>0)},[e,o]),[s,c=>{c?e.items.add(o):e.items.delete(o),e.changed(e.items.size>0),r(c)}]}function eD(e){return t.jsx(tD,{...e},e.agent.agent_id)}function tD({agent:e,v2:n,focus:s=[],server:r,onAgent:o,places:i,onChanged:c}){var Ft;const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,x]=p.useState([]),[h,v]=p.useState([]),[b,j]=p.useState([]),[k,E]=p.useState(null),[S,N]=p.useState(null),[$,_]=p.useState({items:[],cursor:null,pages:0}),[P,O]=p.useState({items:[],cursor:null,pages:0}),[M,R]=p.useState(!1),A=p.useMemo(()=>({items:new Set,changed:R}),[]),[L,D]=Nr(A),[W,q]=p.useState(0),H=p.useRef(0),K=p.useRef(!1),U=p.useRef(!0),G=p.useRef(!1),[F,z]=p.useState(!1),Y=p.useRef(()=>!1);Y.current=()=>!L&&!A.items.size&&!K.current&&$.pages===0;const se=be=>{const de=be==="background";if(!U.current||de&&(G.current||!Y.current()))return Promise.resolve();const Ue=++H.current;G.current=!0,z(!0),K.current=!1,g(null);const Xe=()=>U.current&&Ue===H.current&&(be==="write"||!A.items.size)&&(!de||Y.current()),at=n.agentLearning(e.agent_id).then(J=>{Xe()&&(u(J),_({items:[],cursor:J.notes.next_cursor,pages:0}),O({items:[],cursor:J.log.next_cursor,pages:0}))},J=>{Xe()&&g(J??new Error("unknown"))});return n.listAgentRuns(e.agent_id,50,null,!!e.archived_at).then(J=>{Xe()&&x(J.runs)},()=>{}),Promise.resolve().then(()=>n.learningPromotions(e.agent_id)).then(J=>{Xe()&&(v(J.promotions),j(J.serving))},()=>{}),Promise.resolve().then(()=>n.learningLoop(e.agent_id)).then(J=>{Xe()&&E(J)},()=>{}),at.finally(()=>{Ue===H.current&&(G.current=!1,z(!1))})},Q=()=>se("manual"),re=p.useRef(()=>{});re.current=()=>{document.hidden||se("background")},p.useEffect(()=>{U.current=!0,Q();const be=()=>re.current();window.addEventListener("focus",be),document.addEventListener("visibilitychange",be);const de=window.setInterval(be,Zz);return()=>{U.current=!1,H.current++,window.removeEventListener("focus",be),document.removeEventListener("visibilitychange",be),window.clearInterval(de)}},[n,e.agent_id,e.archived_at]);const te=()=>(c==null||c(),se("write")),he=()=>{if(!$.cursor||K.current)return;const be=H.current;K.current=!0,n.learningNotes(e.agent_id,$.cursor).then(de=>{be===H.current&&(K.current=!1,_(Ue=>({items:[...Ue.items,...de.items.filter(Xe=>!Ue.items.some(at=>at.file===Xe.file))],cursor:de.next_cursor,pages:Ue.pages+1})))},de=>{be===H.current&&(K.current=!1,_(Ue=>({...Ue,error:de??new Error("unknown")})))})},ge=dl(e.definition.learning),ye=!!e.archived_at,xe=p.useMemo(()=>[...(d==null?void 0:d.notes.items)??[],...$.items],[d,$.items]),fe=xe.filter(be=>be.status==="active"),De=xe.filter(lC),Fe=(d==null?void 0:d.skills)??[],Le=(d==null?void 0:d.workflows)??[],[Ee,ae]=p.useState(void 0),ot=De.length>0||[...Fe,...Le].some(be=>be.status==="pending")||Le.some(be=>be.status==="active");p.useEffect(()=>{if(!ot||Ee!==void 0)return;let be=!0;return Promise.resolve().then(()=>n.capabilities()).then(de=>{be&&ae(Tz(de))},()=>{be&&ae("password")}),()=>{be=!1}},[ot]);const me=xe.filter(be=>be.status==="superseded"||be.status==="retired"),Me=p.useMemo(()=>{const be=new Map(xe.map(Ue=>[Ue.file,Ue])),de=new Map;for(const Ue of xe){if(Ue.status==="superseded")continue;const at=[...new Set([...Fz(Ue.text),...xe.filter(J=>J.status==="superseded"&&J.superseded_by===Ue.file).map(J=>J.file)])].flatMap(J=>{const ve=be.get(J);return ve?ve.status==="superseded"&&ve.superseded_by===Ue.file?[{file:J,name:ve.name}]:[]:[{file:J,name:null}]});at.length&&de.set(Ue.file,at)}return de},[xe]),Ze=p.useMemo(()=>new Map(y.map(be=>[be.run_id,be])),[y]),bt=p.useMemo(()=>Yz([...(d==null?void 0:d.log.items)??[],...P.items]),[d,P.items]),oe=s.filter(be=>!xe.some(de=>de.file===be)).length>0;p.useEffect(()=>{d&&oe&&$.cursor&&$.error===void 0&&$.pages<d0&&he()},[d,oe,$.cursor,$.pages]);const Se=xe.some(be=>!bt.has(be.file));p.useEffect(()=>{if(!d||!Se||!P.cursor||P.pages>=d0)return;const be=H.current;n.learningLog(e.agent_id,P.cursor).then(de=>{be===H.current&&O(Ue=>({items:[...Ue.items,...de.items],cursor:de.next_cursor,pages:Ue.pages+1}))},()=>{be===H.current&&O(de=>({...de,cursor:null}))})},[d,Se,P.cursor]);const tt=y.filter(be=>be.learning&&(be.learning.state==="merged"||be.learning.state==="dropped")).length,Ae=e.definition.native?"native":es(e.definition)?"sdk":"hosted",it=MM({notes:fe.length,compiledNotes:xe.filter(be=>be.status!=="retired"&&L2(be.text)!==null).length,runs:(k==null?void 0:k.completed_runs)??0,workflows:Le,cost:S,promotions:h,serving:b,loop:k,mode:e.definition.learning==="notes"?"notes":"full",execution:Ae,compileAfter:_M(e.definition.learning)}),$t=be=>t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Refresh learning",title:"Refresh learning",disabled:M||F,onClick:()=>{!A.items.size&&!G.current&&Q()},children:t.jsx(Yo,{className:ie(F&&"animate-spin"),"aria-hidden":!0})})}),be]});if(f&&!d)return $t(t.jsx(ss,{problem:_r(f,"what this agent learned"),onRetry:Q,className:""}));if(!d)return $t(t.jsx(sD,{}));const nt=f?t.jsx(nD,{error:f,onRetry:Q}):null,ft=be=>t.jsx(oD,{agent:e,v2:n,onAgent:o,server:r,disabled:ye,quiet:be}),Dt=ge&&!ye&&(Ae==="hosted"?t.jsx(XM,{v2:n,agentId:e.agent_id,onFinished:()=>{q(be=>be+1),Q()}}):t.jsxs(vt,{tone:"info",children:[Ae==="native"?"Run tasks with this agent’s original Claude Code or Codex setup.":"Start tasks in your backend using this agent’s SDK wrapper."," Accepted notes and skills remain available here. CSV learning batches require server-managed execution. ",t.jsx("a",{href:dn(e.agent_id,"runs"),className:"underline underline-offset-2",children:"Open the agent’s Run controls"}),"."]}));return!xe.length&&!Fe.length&&!Le.length&&!L?$t(t.jsxs("div",{className:"space-y-6",children:[nt,t.jsx(lD,{on:ge,lookedBack:tt,switchRow:ft(!0),onAdd:ye?void 0:()=>D(!0)}),ge&&t.jsx(n0,{stages:it}),t.jsx(Bk,{v2:n,agentId:e.agent_id,quiet:!0}),Dt,t.jsx(Ik,{v2:n,agentId:e.agent_id,on:ge,quiet:!0,promotions:h,onCost:N,execution:Ae},W),t.jsx(t0,{loop:k,promotions:h,serving:b,cost:S}),t.jsx(f0,{runs:y})]})):$t(t.jsxs("div",{className:"space-y-6",children:[De.length>0&&t.jsxs("section",{className:"border border-warning/50","aria-label":"Waiting for your OK",children:[t.jsxs("h2",{className:"caps flex items-baseline gap-2 border-b border-warning/50 px-4 py-3 text-small font-semibold",children:["Waiting for your OK",t.jsx("span",{className:"font-mono font-normal text-muted-foreground",children:De.length})]}),t.jsx("p",{className:"px-4 pt-3 text-body text-muted-foreground",children:Rz}),((Ft=_2(e,i))==null?void 0:Ft.place.mode)==="runner"&&(e.definition.tools??[]).includes("bash")&&t.jsx("p",{className:"px-4 pt-1 text-body text-muted-foreground",children:Az}),t.jsx("ul",{className:"space-y-3 p-4",children:De.map(be=>t.jsx("li",{children:t.jsx(u0,{note:be,v2:n,agentId:e.agent_id,readOnly:ye,focused:s.includes(be.file),from:bt.get(be.file),runs:Ze,onChanged:te,refreshHolds:A,approves:Ee,replaces:Me.get(be.file)})},be.file))})]}),t.jsx(n0,{stages:it}),t.jsx(Bk,{v2:n,agentId:e.agent_id}),Iz(d.impact)&&t.jsx(rD,{impact:d.impact}),Dt,t.jsx(Ik,{v2:n,agentId:e.agent_id,on:ge,promotions:h,onCost:N,execution:Ae},W),t.jsx(uz,{v2:n,agentId:e.agent_id,workflows:Le,promotions:h,serving:b,cost:S,onReplayed:()=>{Q()}}),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:fe.length?`${Xi(fe.length)} in use. Every later run reads ${fe.length===1?"it":"them"} before it starts.`:[...Fe,...Le].some(be=>be.status==="active")?"No note is in use.":"No note is in use: the next run starts with nothing learned."})]}),!ye&&!L&&t.jsxs(B,{size:"sm",onClick:()=>D(!0),children:[t.jsx(gl,{"aria-hidden":!0})," Add a note"]})]}),nt,!ge&&t.jsx(iD,{server:r}),L&&t.jsx(jC,{title:"New note",v2:n,agentId:e.agent_id,taken:xe.map(be=>be.file),onDone:be=>{D(!1),be&&te()}},"new"),t.jsx("ul",{className:"space-y-3",children:fe.map(be=>t.jsx("li",{children:t.jsx(u0,{note:be,v2:n,agentId:e.agent_id,readOnly:ye,focused:s.includes(be.file),from:bt.get(be.file),runs:Ze,onChanged:te,refreshHolds:A,replaces:Me.get(be.file)})},be.file))}),$.error!==void 0&&t.jsx(ss,{problem:_r($.error,"more notes"),onRetry:he,className:""}),$.cursor&&t.jsx("div",{className:"flex justify-center",children:t.jsx(B,{size:"sm",onClick:he,children:"Load more notes"})}),me.length>0&&t.jsx(mD,{notes:me,all:xe,from:bt,focus:s,runs:Ze,v2:n,agentId:e.agent_id,readOnly:ye,onChanged:te,refreshHolds:A})]}),["skill","workflow"].map(be=>{const de=be==="skill"?Fe:Le;if(!de.length)return null;const Ue=be==="skill"?"Skills it learned":"Workflows it learned",Xe=de.filter(J=>J.status!=="retired"),at=de.filter(J=>J.status==="retired");return t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":Ue,children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:Ue}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:Xe.length?be==="skill"?`${Bf(Xe.length,"skill")}: how to do a job it does again, given to every later run once active.`:`${Bf(Xe.length,"workflow")}: a job it does again, as steps a later run can call.`:`No ${be} is in use: the next run gets none.`})]}),Xe.length>0&&t.jsx("ul",{className:"space-y-3",children:Xe.map(J=>t.jsx("li",{children:t.jsx(cD,{item:J,kind:be,v2:n,agentId:e.agent_id,readOnly:ye,runs:Ze,approves:Ee,onChanged:te,refreshHolds:A})},J.file))}),at.length>0&&t.jsx(hD,{kind:be,items:at,v2:n,agentId:e.agent_id,runs:Ze,readOnly:ye,onChanged:te,refreshHolds:A})]},be)})]}),t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[t.jsx(vC,{title:"Learning",children:ft(!1)}),t.jsx(t0,{loop:k,promotions:h,serving:b,cost:S}),t.jsx(f0,{runs:y}),t.jsx(gD,{index:d.index,skills:Fe.filter(be=>be.status==="active").map(be=>be.name),off:!ge||r==="off"})]})]})]}))}function nD({error:e,onRetry:n}){const s=_r(e,"the notes"),r=[s.said,s.code].filter(Boolean).join(" · ");return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border border-destructive/40 px-3 py-2 text-body",role:"alert",title:r||void 0,children:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't refresh the notes: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)," What's shown may be out of date."]}),t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})]})}function vC({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 sD(){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:ie(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:ie(e,"h-4 w-1/3")}),t.jsx("span",{className:ie(e,"h-3 w-2/3 bg-muted/70")}),t.jsx("span",{className:ie(e,"h-3 w-1/2 bg-muted/70")})]},n)),t.jsx("span",{className:"sr-only",children:"Loading what it learned…"})]})}function rD({impact:e}){const{before:n,after:s}=e,r=[{label:"Answers in",now:Kf(s.median_duration_s),was:Kf(n.median_duration_s),delta:o0(n.median_duration_s,s.median_duration_s)},...fC(e)?[{label:"A run costs",now:Oa(s.median_cost_usd),was:Oa(n.median_cost_usd),delta:o0(n.median_cost_usd,s.median_cost_usd)}]:[]],o=mC(e),i=[`Medians of ${Ga(n.runs)} before it first learned and ${Ga(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":Mz(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:hC(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:ie("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:[Oa(o)," a run"]})]})]})]})})}function oD(e){return e.agent.definition.native?t.jsx("div",{className:"p-4",children:t.jsx(R2,{agent:e.agent,v2:e.v2,learning:e.server,onAgent:e.onAgent})}):t.jsx(aD,{...e})}function aD({agent:e,v2:n,onAgent:s,server:r,disabled:o,quiet:i}){const[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,y]=p.useState(null),x=async h=>{d(!0),f(null),y(h);try{const{agent:v,etag:b}=await n.getAgent(e.agent_id),j=gd(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,b)).agent)}}catch(v){f(v??new Error("unknown"))}y(null),d(!1)};return t.jsx(tC,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:i,checked:g??dl(e.definition.learning),onChange:h=>void x(h),busy:c,disabled:o,server:r,problem:u?t.jsx(ss,{problem:Za(u,"the agent","Learning was not changed."),className:"mt-2"}):null})}function iD({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 lD({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(Vx,{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:[Ga(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 u0({note:e,v2:n,agentId:s,readOnly:r,focused:o,from:i,runs:c,onChanged:d,approves:u,refreshHolds:f,replaces:g=[]}){const[y,x]=p.useState(!1),[h,v]=Nr(f),[b,j]=Nr(f),[k,E]=p.useState(o),[S,N]=p.useState(null),[$,_]=Nr(f),[P,O]=p.useState(null),M=p.useRef(null),R=lC(e),A=async()=>{const q=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 ze&&Um(H).kind==="conflict"?q(`${Gm} Reload the tab to see the newest version.`):t.jsx(ss,{problem:Za(H,"the note","The note was not approved."),className:""}));return}await d(),_(!1)};if(p.useEffect(()=>{var H,K;if(!o)return;E(!0),(K=(H=M.current)==null?void 0:H.scrollIntoView)==null||K.call(H,{block:"center",behavior:"smooth"});const q=setTimeout(()=>E(!1),2600);return()=>clearTimeout(q)},[o]),p.useEffect(()=>{if(!S)return;const q=setTimeout(()=>N(null),2400);return()=>clearTimeout(q)},[S]),h)return t.jsx(jC,{title:"Edit note",v2:n,agentId:s,file:e.file,seen:e,onDone:q=>{v(!1),q&&(N("Saved"),d())}});const L=Kc(e.text),D=hx(e.last_change),W=L2(e.text);return t.jsxs("article",{ref:M,id:`note-${e.file}`,tabIndex:-1,"aria-label":e.name,className:ie("border bg-card/40 outline-none focus-visible:border-primary transition-[border-color,box-shadow] duration-slow",k&&"border-primary ring-1 ring-primary"),children:[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(Ne,{children:rC(e.type)}),e.origin==="you"&&t.jsx(Ne,{tone:"muted",children:"From you"}),W&&t.jsxs(Ne,{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}),R&&u==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:cC})]}),!r&&!b&&t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[R?u==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void A(),disabled:$,"aria-label":`Approve ${e.name}`,children:$?"Approving":"Approve"}):t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>v(!0),"aria-label":`Edit ${e.name}`,children:[t.jsx(Gx,{"aria-hidden":!0})," Edit"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>j(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]})]}),P&&t.jsx("div",{className:"px-5 pt-3",children:P}),L.trim()&&t.jsx(Ym,{text:L}),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(Vm,{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(Yx,{className:"size-3","aria-hidden":!0}),D]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(kf,{className:"size-3","aria-hidden":!0}),"Given to ",Ga(e.runs.given)]}),e.runs.read>0&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(kf,{className:"size-3","aria-hidden":!0}),"Read in ",Ga(e.runs.read)]}),g.length>0&&t.jsxs("button",{type:"button",onClick:()=>x(q=>!q),"aria-expanded":y,className:"flex items-center gap-1.5 hover:text-foreground",children:[t.jsx(_T,{className:"size-3","aria-hidden":!0}),"Replaces ",g.length," older ",g.length===1?"note":"notes",t.jsx(Ar,{className:ie("size-3 transition-transform",y&&"rotate-180"),"aria-hidden":!0})]})]}),y&&g.length>0&&t.jsx("ul",{"aria-label":"Notes it replaces",className:"space-y-1 border-t px-5 py-2.5 text-body text-muted-foreground",children:g.map(q=>t.jsx("li",{className:ie("break-words",q.name===null&&"font-mono text-small"),children:q.name??q.file},q.file))}),b&&t.jsx(yC,{name:e.name,kind:"note",retire:()=>n.retireNote(s,e.file,e.etag),onDone:async q=>{q&&await d(),j(!1)}})]})}function cD({item:e,kind:n,v2:s,agentId:r,readOnly:o,runs:i,approves:c,onChanged:d,refreshHolds:u}){const[f,g]=Nr(u),[y,x]=p.useState(null),[h,v]=p.useState(null),[b,j]=p.useState(null),[k,E]=Nr(u),[S,N]=Nr(u),[$,_]=p.useState(null),P=e.status==="pending",[O,M]=Nr(u),R=p.useRef(Ys()).current,[A,L]=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"))}},q=async()=>{if(f)return g(!1);g(!0),y===null&&await W()};p.useEffect(()=>{y===null&&h===null||(f?W():(x(null),v(null)))},[e.etag]);const H=n==="skill"&&f&&h?h:e.etag,K=async()=>{E(!0),_(null);try{await s.approveNote(r,dx(e),H)}catch(G){E(!1),_(G instanceof ze&&Um(G).kind==="conflict"?t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${Gm} Reload the tab to see the newest version.`}):t.jsx(ss,{problem:Za(G,`the ${n}`,`The ${n} was not approved.`),className:""}));return}await d(),E(!1)},U=`the ${n} ${e.name}`;return t.jsxs("article",{"aria-label":e.name,className:"border bg-card/40",children:[t.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words font-mono text-lead font-semibold leading-snug",children:e.name}),P&&t.jsxs(Ne,{tone:"warning",children:[t.jsx(Wx,{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}),P&&c==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:cC})]}),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:[P&&c==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void K(),disabled:k,"aria-label":`Approve ${e.name}`,children:k?"Approving":"Approve"}),D&&t.jsx(B,{size:"sm",onClick:()=>{L(null),M(!0)},"aria-label":`Make ${e.name} an agent`,children:"Make this an agent"}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>N(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]}),t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>void q(),"aria-expanded":f,"aria-label":`${f?"Hide":"Show"} ${U}`,children:[t.jsx(Ar,{className:ie("transition-transform",f&&"rotate-180"),"aria-hidden":!0}),f?"Hide":"Show"]})]})]}),$&&t.jsx("div",{className:"px-5 pt-3",children:$}),A&&t.jsxs("p",{className:"px-5 pt-3 text-body",role:"status",children:["Made the agent ",t.jsx("a",{href:dn(A.agent_id),className:"font-mono underline underline-offset-2",children:A.definition.name}),". Open it to run it."]}),f&&(b!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(ss,{problem:_r(b,U),onRetry:()=>void W(),className:""})}):y===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${U}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):n==="skill"?t.jsx(Ym,{text:Kc(y)}):t.jsx(dD,{name:e.name,text:y})),t.jsxs("footer",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 border-t px-5 py-2.5 font-mono text-label text-muted-foreground",children:[e.run&&t.jsx(Vm,{run:e.run,runs:i}),hx(e.last_change)&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Yx,{className:"size-3","aria-hidden":!0}),hx(e.last_change)]}),t.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),S&&t.jsx(yC,{name:e.name,kind:n,retire:()=>s.retireNote(r,dx(e),H),onDone:async G=>{G&&await d(),N(!1)}}),O&&t.jsx(fD,{name:e.name,keys:R,promote:G=>s.promoteWorkflow(r,e.name,G),onDone:G=>{M(!1),G&&L(G)}})]})}function dD({name:e,text:n}){const{doc:s,graph:r}=p.useMemo(()=>{try{const c=JSON.parse(n);return{doc:c,graph:il(c)}}catch{return{doc:null,graph:null}}},[n]),o=p.useMemo(()=>r?{meta:hd(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(jd,{graph:r,marks:o,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),t.jsx(kd,{}),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 hx(e){return e&&e.kind!=="learned"?`${nC(e.kind,e.by)} · ${ht(e.at)}`:null}function bC(e){return(e==null?void 0:e.by)==="host"?yz:e?`${nC("retired",e.by)} · ${ht(e.at)}`:"Retired"}function Vm({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(Vx,{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:Jz(n,e),children:ea(e)}),s&&t.jsxs("span",{className:"shrink-0",children:["· ",ht(s)]})]})}function Ym({text:e}){const[n,s]=p.useState(!1),r=e.split(`
647
- `).length>8||e.length>520,o=p.useMemo(()=>no(e),[e]);return t.jsxs("div",{className:"px-5 pb-4 pt-3",children:[t.jsxs("div",{className:ie("relative",r&&!n&&"max-h-[9.5rem] overflow-hidden"),children:[t.jsx("div",{className:xC,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(Ar,{className:ie("size-3.5 transition-transform",n&&"rotate-180"),"aria-hidden":!0}),n?"Show less":"Show all"]})]})}const uD={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 yC({name:e,kind:n,retire:s,onDone:r}){const[o,i]=p.useState(!1),[c,d]=p.useState(null),u=p.useRef(null);p.useEffect(()=>{var y;(y=u.current)==null||y.focus()},[]);const f=y=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:y}),g=async()=>{i(!0),d(null);try{await s()}catch(y){i(!1),d(y instanceof ze&&Um(y).kind==="conflict"?f(`${Gm} Reload the tab to see the newest version.`):t.jsx(ss,{problem:Za(y,`the ${n}`,`The ${n} was not retired.`),className:""}));return}await r(!0)};return t.jsxs("div",{role:"alertdialog","aria-label":`Retire ${e}?`,onKeyDown:y=>{y.key==="Escape"&&(y.stopPropagation(),r(!1))},className:"flex flex-wrap items-center gap-3 border-t border-destructive/40 bg-destructive/5 px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Retire it?"})," ",uD[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 fD({name:e,keys:n,promote:s,onDone:r}){const[o,i]=p.useState(!1),[c,d]=p.useState(null),u=p.useRef(null);p.useEffect(()=>{var g;(g=u.current)==null||g.focus()},[]);const f=async()=>{var y;i(!0),d(null);let g;try{g=await s(n.keyFor("promote",e))}catch(x){return i(!1),x instanceof ze&&x.status<500&&n.done(),x instanceof ze&&x.status===403?void d(t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:Nz})):x instanceof ze&&((y=x.problems)!=null&&y.length)?void d(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["No agent was made: ",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:Za(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?"})," ",kz(e)]}),c&&t.jsx("div",{className:"w-full",children:c}),t.jsx(B,{ref:u,size:"sm",variant:"solid",onClick:()=>void f(),disabled:o,children:o?"Making the agent":"Yes, make the agent"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>r(null),disabled:o,children:"Cancel"})]})}function wC({name:e,kind:n,from:s,restore:r,onChanged:o,onDone:i}){const[c,d]=p.useState(!1),[u,f]=p.useState(null),g=p.useRef(null);p.useEffect(()=>{var h;(h=g.current)==null||h.focus()},[]);const y=h=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:h}),x=async()=>{var h;d(!0),f(null);try{await r()}catch(v){if(d(!1),v instanceof ze&&(v.status===412||v.code==="precondition_failed")){f(y(Gm)),await o();return}if(v instanceof ze&&v.status===403)return void f(y(Sz));if(v instanceof ze&&((h=v.problems)!=null&&h.length))return void f(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["Not restored: ",v.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:v.problems.map((b,j)=>t.jsx("li",{children:b.detail},j))})]}));if(v instanceof ze&&v.status===400){await o(),i();return}return void f(t.jsx(ss,{problem:Za(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?"})," ",jz(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 jC({title:e,v2:n,agentId:s,file:r,seen:o,taken:i=[],onDone:c}){const[d,u]=p.useState(o?Vf(o.text):{name:"",description:"",type:"feedback",body:`
648
- `,rest:[]}),[f,g]=p.useState((o==null?void 0:o.etag)??null),[y,x]=p.useState(null),[h,v]=p.useState(!1),[b,j]=p.useState([]),[k,E]=p.useState(null),[S,N]=p.useState(!1),[$,_]=p.useState(null),P=p.useRef(null),O=async()=>{if(r)try{const D=await n.readNote(s,r);u(Vf(D.note)),g(D.etag),x(null)}catch(D){x(D??new Error("unknown"))}};p.useEffect(()=>{var D;(D=P.current)==null||D.focus()},[]);const M=D=>u(W=>({...W,...D})),R=d.name.trim()!==""&&d.description.trim()!==""&&!h,A=async()=>{if(!R)return;if(E(null),j([]),N(!1),r&&!f){E(kg);return}v(!0);const D=Dz(d);try{await n.writeNote(s,r??i0(d.name,i),D,r?{etag:f??""}:{create:!0}),c(!0)}catch(W){v(!1);const q=W instanceof ze?Um(W,!r):null;(q==null?void 0:q.kind)==="conflict"?(_(D),await O()):(q==null?void 0:q.kind)==="refused"?j(q.problems):(q==null?void 0:q.kind)==="taken"?N(!0):E(W??new Error("unknown"))}},L=D=>{D.key==="Escape"?(D.preventDefault(),D.stopPropagation(),c(!1)):D.key==="Enter"&&(D.metaKey||D.ctrlKey||D.target.tagName==="INPUT")&&(D.preventDefault(),A())};return t.jsxs("section",{className:"border border-border-strong bg-card","aria-label":e,onKeyDown:L,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:[Xz?"⌘":"Ctrl","+Enter"]})," save · ",t.jsx("kbd",{children:"Esc"})," cancel"]})]}),y!==null&&t.jsx(ss,{problem:_r(y,"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:P,value:d.name,onChange:D=>M({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=>M({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:sC.map(D=>t.jsxs("label",{className:ie("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:()=>M({type:D})}),rC(D)]},D))}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:Ez[d.type]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Note"}),t.jsx(nn,{value:d.body.replace(/^\n/,""),onChange:D=>M({body:`
649
- ${D.target.value}`}),rows:7,placeholder:"What to do, and why. Markdown.",className:"resize-y leading-[1.65]"})]}),b.length>0&&t.jsxs("div",{className:"border border-destructive/50 bg-destructive/5 px-4 py-3 text-body",role:"alert",children:[t.jsx("p",{className:"font-semibold text-destructive-text",children:"Not saved: the note doesn't pass the checks."}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:b.map((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===kg?t.jsxs("p",{className:"text-body text-destructive-text",role:"alert",children:["Not saved: ",kg]}):k!==null&&t.jsx(ss,{problem:Za(k,"the note","The note was not saved."),className:""}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void A(),disabled:!R,children:h?"Saving":r?"Save":"Add note"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>c(!1),disabled:h,children:"Cancel"}),!r&&d.name.trim()&&t.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:i0(d.name,i)})]})]})]})}function mD({notes:e,all:n,from:s,focus:r,runs:o,v2:i,agentId:c,readOnly:d,onChanged:u,refreshHolds:f}){const[g,y]=Nr(f,null),[x,h]=p.useState(e.some(N=>r.includes(N.file))),[v,b]=p.useState(new Set),j=N=>b($=>{const _=new Set($);return _.has(N)?_.delete(N):_.add(N),_}),k=e.some(N=>r.includes(N.file));p.useEffect(()=>{k&&h(!0)},[k]);const E=N=>{var $;return(($=n.find(_=>_.file===N))==null?void 0:$.name)??N},S=N=>{var _;const $=document.getElementById(`note-${N}`);(_=$==null?void 0:$.scrollIntoView)==null||_.call($,{block:"center",behavior:"smooth"}),$==null||$.focus({preventScroll:!0})};return t.jsx(kC,{title:"Earlier notes",count:`${e.length} no longer read`,open:x,onToggle:()=>h(N=>!N),children:e.map(N=>{var O,M;const $=N.status==="retired",_=$&&v.has(N.file),P=(O=s.get(N.file))==null?void 0:O.run;return t.jsxs("li",{id:`note-${N.file}`,className:ie("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(Ne,{tone:"muted",children:$?"Retired":"Replaced"}),$&&t.jsx(NC,{open:_,label:`the note ${N.name}`,onClick:()=>j(N.file)}),$&&!d&&N.etag&&g!==N.file&&t.jsxs(B,{size:"sm",onClick:()=>y(N.file),"aria-label":`Restore ${N.name}`,children:[t.jsx(AN,{"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)})]}):$?bC(N.retired):null}),g===N.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(wC,{name:N.name,kind:"note",from:(M=N.retired)==null?void 0:M.from,restore:()=>i.restoreNote(c,N.file,N.etag),onChanged:u,onDone:()=>y(null)})}),_&&t.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[t.jsx("p",{className:"mt-2 px-5 text-body text-muted-foreground",children:N.description}),Kc(N.text).trim()&&t.jsx(Ym,{text:Kc(N.text)}),P&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(Vm,{run:P.id,runs:o,at:P.at,reason:P.reason})})]})]},N.file)})})}function kC({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(Ar,{className:ie("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 hD({kind:e,items:n,v2:s,agentId:r,runs:o,readOnly:i,onChanged:c,refreshHolds:d}){const[u,f]=p.useState(!1),[g,y]=Nr(d,null),[x,h]=p.useState(new Set),v=b=>h(j=>{const k=new Set(j);return k.has(b)?k.delete(b):k.add(b),k});return t.jsx(kC,{title:e==="skill"?"Earlier skills":"Earlier workflows",count:`${n.length} no longer given`,open:u,onToggle:()=>f(b=>!b),children:n.map(b=>{var j;return t.jsxs("li",{className:"border-b px-4 py-3 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-body text-muted-foreground line-through decoration-muted-foreground/40",children:b.name}),t.jsx(Ne,{tone:"muted",children:"Retired"}),t.jsx(NC,{open:x.has(b.file),label:`the ${e} ${b.name}`,onClick:()=>v(b.file)}),!i&&g!==b.file&&t.jsxs(B,{size:"sm",onClick:()=>y(b.file),"aria-label":`Restore ${b.name}`,children:[t.jsx(AN,{"aria-hidden":!0})," Restore"]})]}),b.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:b.description}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:bC(b.retired)}),g===b.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(wC,{name:b.name,kind:e,from:(j=b.retired)==null?void 0:j.from,restore:()=>s.restoreNote(r,dx(b),b.etag),onChanged:c,onDone:()=>y(null)})}),x.has(b.file)&&t.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[t.jsx(pD,{v2:s,agentId:r,file:b.file,etag:b.etag,kind:e,label:`the ${e} ${b.name}`}),b.run&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(Vm,{run:b.run,runs:o})})]})]},b.file)})})}function NC({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(Ar,{className:ie("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function pD({v2:e,agentId:n,file:s,etag:r,kind:o,label:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),g=p.useRef(0),y=async()=>{const 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(()=>{y()},[s,r]),u!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(ss,{problem:_r(u,i),onRetry:()=>void y(),className:""})}):c===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${i}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):o==="skill"?t.jsx(Ym,{text:Kc(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 f0({runs:e}){const n=e.filter(o=>{var i;return((i=o.learning)==null?void 0:i.state)==="dropped"}),s=n.filter(o=>qf(o.learning.reason)!=="nothing").slice(0,6),r=n.length-n.filter(o=>qf(o.learning.reason)!=="nothing").length;return n.length?t.jsxs(vC,{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:sb(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:Cn(o),children:Cn(o)}),t.jsxs("span",{className:"shrink-0",children:["· ",ht(o.created_at)]})]})]})},o.run_id))}),r>0&&t.jsxs("p",{className:ie("px-4 py-3 font-mono text-label text-muted-foreground",s.length>0&&"border-t"),children:[s.length?`${r} more ${r===1?"run":"runs"} had`:`${Ga(r)} had`," nothing new to remember."]})]}):null}function gD({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(()=>no(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(Ar,{className:ie("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?Xi(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:ie(xC,"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 rb({run:e,link:n=!1,className:s}){var y;const r=oC(e.learning),o=aC(e.learning),i=qc(e.learning),c=qm(e.learning)&&e.learning.state!=="seeded",d=tb(e.learning),u=_z(e.learning),f=[...s0(e.learning),...r0(e.learning)],g=((y=e.learning)==null?void 0:y.state)==="dropped"&&qf(e.learning.reason)!=="nothing"?sb(e.learning):null;return!r.length&&!o.length&&!i.length&&!c&&!u&&!f.length&&!g?null:t.jsxs("span",{className:ie("inline-flex flex-wrap items-center gap-2",s),"aria-label":"Learning",children:[r.length>0&&t.jsx(Zu,{agentId:e.agent_id,refs:r,link:n,kind:"given"}),o.length>0&&t.jsx(Zu,{agentId:e.agent_id,refs:o,link:n,kind:"read"}),i.length>0&&t.jsx(Zu,{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(Zu,{agentId:e.agent_id,refs:d,link:n,kind:"pending"}),g&&t.jsx(xD,{agentId:e.agent_id,said:g,link:n}),["skill","workflow"].flatMap(x=>{const h=(x==="skill"?s0:r0)(e.learning);return[!1,!0].map(v=>{const b=h.filter(j=>j.pending===!0===v);return b.length?t.jsx(vD,{agentId:e.agent_id,refs:b,link:n,kind:x,pending:v},`${x}-${v}`):null})}),c&&t.jsxs(Ne,{tone:"active",children:[t.jsxs("span",{className:"relative flex size-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inline-flex size-full animate-ping bg-run-active opacity-75"}),t.jsx("span",{className:"relative inline-flex size-1.5 bg-run-active"})]}),Lz(e.learning.state)]})]})}function xD({agentId:e,said:n,link:s}){const r=t.jsxs(Ne,{tone:"muted",className:ie(s&&"cursor-pointer"),children:[t.jsx(yT,{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:Km(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 vD({agentId:e,refs:n,link:s,kind:r,pending:o}){const i=o?`${Bf(n.length,r)} ${n.length===1?"waits":"wait"} for your OK`:`Learned ${Bf(n.length,r)}`,c=`${i}: ${n.map(f=>f.name).join(", ")}`,d=o?Wx:r==="skill"?Sf:Qa,u=t.jsxs(Ne,{tone:o?"warning":void 0,className:ie(!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:Km(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 Zu({agentId:e,refs:n,link:s,kind:r,replaces:o=0}){const i=r==="pending"?uC(n.length):r==="given"?`Started with: ${Xi(n.length)}`:r==="read"?`Read: ${Xi(n.length)}`:`Learned ${Xi(n.length)}`,c=n.map(h=>h.name).join(", "),d=r==="given"||r==="read",u=d?kf:r==="pending"?Wx:Vx,f=t.jsxs(Ne,{tone:r==="pending"?"warning":void 0,className:ie(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!==dC),y=`${i}${c?`: ${c}`:""}${o?` (replaces ${o===1?"1 older note":`${o} older notes`})`:""}`;if(!s||!g.length&&r!=="pending")return t.jsx("span",{title:y,"aria-label":y,className:"inline-flex",children:f});const 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(j5,{tip:x,children:t.jsx("a",{href:Km(e,g.map(h=>h.file)),"aria-label":y,className:"inline-flex",children:f})})}function bD({n:e,className:n}){return e<=0?null:t.jsx("span",{"aria-label":nb(e),className:ie("inline-flex min-w-[18px] items-center justify-center border border-warning/50 bg-warning/10 px-1 font-mono text-micro text-warning-text",n),children:e})}const yD=["pi","claude-agent","codex","opencode"];function wD(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 jD(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 kD(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 ob="Refused on this server for every agent, whatever the agent's own setting or Never ask.",ND="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.",SC=(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=Ho(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 SD(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 CD={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},CC={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."}}},Yf=(e,n)=>{var s;return(n&&((s=CC[n])==null?void 0:s.label[e]))??CD[e]??e},ED={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."},m0=(e,n)=>{var s;return(n&&((s=CC[n])==null?void 0:s.help[e]))??ED[e]};function EC(e,n){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:Yf(e,n),unavailable:!1}:{text:"not known",unavailable:!1}}function $C(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 $D=(e,n,s,r)=>$C(e,n,"provider",s,r),_D=(e,n,s,r)=>$C(e,n,"permission",s,r);function px(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 _C(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 TD=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),RD=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))]},AD=e=>typeof e=="string"?e:JSON.stringify(e);function OD(e){return Object.keys(e).sort().map(n=>{const s=e[n];if(TD(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=RD(s),o=r[0]===null,i=(o?r.slice(1):r).map(d=>AD(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 PD="Calls outside it are refused before they run or ask.",LD="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.",MD=[{id:"runs",label:"Runs",shows:()=>!0,Body:UD},{id:"versions",label:"Versions",shows:()=>!0,Body:rL},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:WD},{id:"learning",label:"Learning",shows:(e,n)=>e.kind==="agentic"&&n.learning!==!1,Body:e=>t.jsx(eD,{agent:e.agent,v2:e.v2,focus:e.focus,server:e.learning,onAgent:e.onAgent,places:e.places,onChanged:e.onChanged})},{id:"analytics",label:"Analytics",shows:(e,n)=>n.analytics,Body:TL}],dn=(e,n)=>`#/agents/${encodeURIComponent(e)}${n?`/${n}`:e==="new"||e==="connect"?"/runs":""}`;function ID({v2:e,agentId:n,routePrefix:s,harnesses:r,go:o,tab:i,learning:c,notes:d,places:u}){const[f,g]=p.useState(null),[y,x]=p.useState(null),[h,v]=p.useState(0),[b,j]=p.useState(void 0);p.useEffect(()=>{let L=!0;return g(null),x(null),j(void 0),$(!1),S.current=++k.current,e.getAgent(n).then(D=>{L&&g(D.agent)},D=>{L&&x({cause:D})}),e.statsOver({from:Tv(w2),agent:n}).then(D=>{L&&j(D)},()=>{L&&j(null)}),()=>{L=!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),_=(L=!1,D=!L)=>{const W=++k.current;return D&&(S.current=W),e.getAgent(n).then(q=>(W>E.current&&W>=S.current&&(E.current=W,g(H=>H&&H.agent_id===q.agent.agent_id?q.agent:H),$(!1)),E.current>=W),()=>(W===k.current&&!L&&$(!0),E.current>=W))},P=L=>{g(D=>({...L,tools:(D==null?void 0:D.tools)??L.tools})),_()},O=()=>void _(),M=()=>void _(!0,!1),R=()=>_(!0,!0),A=b===void 0?void 0:b!==null;return y?y.cause instanceof ze&&y.cause.status===404?t.jsx(r2,{what:"agent",id:n,list:{href:"#/agents",label:"Open the agents list"}}):t.jsx(Jt,{problem:Ht(y.cause,"the agent"),onRetry:()=>v(L=>L+1)}):f?t.jsx(zD,{agent:f,onAgent:P,onSignInsAgent:g,reread:_,onChanged:O,poll:M,afterForget:R,stale:N,v2:e,go:o,stats:b,analytics:A,places:u,routePrefix:s,harnesses:r,tab:i,learning:c,notes:d},f.agent_id):t.jsx(ZP,{})}function zD({agent:e,onAgent:n,onSignInsAgent:s,reread:r,onChanged:o,poll:i,afterForget:c,stale:d,v2:u,go:f,stats:g,analytics:y,routePrefix:x,harnesses:h,tab:v,learning:b,notes:j,places:k}){var te,he,ge,ye;const E=FD(e,u,r,()=>r(!1,!1)),[S,N]=p.useState(!1),$=Gf(e),_=e.definition,P=es(_),{native:O,refresh:M}=uM(e,u),R=e.kind==="workflow",A=R?Qa:Fx,L=q2(_.harness??"pi",h),D=_.model?ul(_.model,x):L?(({text:xe,title:fe})=>({text:`${xe} (default)`,title:fe}))(ul(L,x)):{text:_I},W=R||O||P||h==null?void 0:h.find(xe=>xe.id===(_.harness??"pi")&&xe.available===!1),q=W?`${W.id} doesn't run on this server${W.reason?`: ${W.reason}`:"."}`:void 0,H=_2(e,k),K=`${KL(H==null?void 0:H.place)}${H!=null&&H.byDefault?" (server default)":""}`,U=!P&&!O&&!R&&!W&&!_.model&&!L&&(h==null?void 0:h.some(xe=>xe.id===(_.harness??"pi")&&xe.default_model===null)),G=[...P?[["Runtime",Ko(P.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]]:R?[]:[["Harness",_.harness??"pi"],["Model",D.text,D.title],["Thinking",_.thinking??"default"],["Runs",K]],["Revision",`rev ${_.version} of ${e.revisions}`]],F=MD.filter(xe=>xe.shows(e,{analytics:y===!0,learning:b===void 0?v==="learning"?void 0:!1:!!b})),z=F.find(xe=>xe.id===v)??F[0],Y=v==="analytics"&&y===void 0,se=((te=E.runs)==null?void 0:te.filter(DD))??[],Q=((he=e.runs)==null?void 0:he.live)??(E.runs?`${se.length}${E.cursor?"+":""}`:"—"),re=[["Status",e.archived_at?"Archived":O?vd(O):"Active"],["Live jobs",String(Q)],...G];return t.jsx(fM,{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(An,{"aria-hidden":!0})}),t.jsx(A,{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(),M()},disabled:E.reading,children:t.jsx(Yo,{className:ie(E.reading&&"animate-spin"),"aria-hidden":!0})}),!O&&!P&&t.jsx(B,{size:"sm",onClick:()=>f(dn(e.agent_id,"edit")),children:"Detailed editor"}),t.jsx(sn,{label:"Edit agent",prompt:Wo(location.origin,e.agent_id,!!O,P==null?void 0:P.runtime),playgroundHref:O||P?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),!e.archived_at&&t.jsx(sn,{variant:"primary",label:"Run agent",disabled:!!O&&(!O.connected||O.state!=="ready"||!O.capabilities.launch),prompt:Lv(location.origin,e.agent_id,P==null?void 0:P.runtime),playgroundHref:P?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(Ne,{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:ie("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(xe=>!xe),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:ie("size-3.5 shrink-0 transition-transform",S&&"rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:re.map(([,xe])=>xe).join(" · ")})]}),t.jsxs("dl",{id:"agent-facts",className:ie("grid grid-cols-2 gap-3",!S&&"max-sm:hidden"),"aria-label":"Current revision",children:[re.map(([xe,fe,De])=>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:xe}),t.jsx("dd",{className:"break-words text-body font-semibold",title:De,children:fe})]},xe)),!R&&!O&&!P&&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:!R&&e.tools?e.tools.length?t.jsx("ul",{className:"space-y-2","aria-label":"Tools",children:e.tools.map(xe=>t.jsxs("li",{children:[t.jsx("span",{title:xe.blurb,children:xe.name}),xe.provider?` · ${Yf(xe.provider,xe.name)}`:"",xe.permission?` · ${xe.permission}`:"",EC(xe.resolved,xe.name).unavailable&&t.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:xe.resolved,children:" · unavailable"})]},xe.name))}):"none":_.tools.join(", ")||"None configured"})]})]}),q&&t.jsx(vt,{tone:"warning","aria-label":"Harness not available",children:q}),!e.archived_at&&U&&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"})]}),(ge=e.warnings)!=null&&ge.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((xe,fe)=>t.jsxs("li",{children:[t.jsx("span",{className:"text-muted-foreground",children:xe.field})," ",xe.message]},`${xe.field}:${fe}`))})]}):null,t.jsx(gM,{agent:e,v2:u,onAgent:s,poll:i,refresh:c}),O&&t.jsx(mM,{agent:e,v2:u,learning:b,onAgent:n,onChanged:async()=>{M(),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:P?"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"}),se.length?t.jsx("ul",{className:"space-y-3",children:se.map(xe=>t.jsx("li",{children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(xe.run_id)}`,className:"flex items-center gap-2 text-small hover:text-primary-text",children:[t.jsx(Cl,{run:xe}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:Cn(xe)}),t.jsx(fr,{className:"size-3 shrink-0","aria-hidden":!0})]})},xe.run_id))}):t.jsx("p",{className:"text-small leading-relaxed text-muted-foreground",children:E.runs?(ye=e.runs)!=null&&ye.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(TS,{id:"agent-views",label:"Agent views",value:z.id,onChange:xe=>f(dn(e.agent_id,xe)),tabs:F.map(xe=>({id:xe.id,label:t.jsxs(t.Fragment,{children:[xe.label,xe.id==="learning"&&t.jsx(bD,{n:$,className:"ml-1.5"})]})})),className:"mb-5 overflow-x-auto px-0 md:px-0"}),t.jsx("div",{...w5("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:b,onAgent:n,onChanged:o,places:k})})]})]})]})})}const DD=e=>!e.imported_from&&["queued","working","paused","input_required"].includes(e.status);function FD(e,n,s,r){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,y]=p.useState(!1),[x,h]=p.useState(null),[v,b]=p.useState(!1),j=p.useRef(0),k=p.useRef([]),E=p.useRef(0),S=p.useRef(!1),N=async($,_=!1,P=!1,O=!1)=>{if(S.current)return;S.current=!0;const M=++j.current;f(!0),y(!!$);const R=_?O?r():s():Promise.resolve();try{let A=$,L=[];const D=$||P?void 0:k.current.at(-1),W=D?Date.parse(D.created_at):NaN,q=E.current+1;let H=!1;const K=new Set;do{if(K.size>=q){b(!0),h({title:"Run history could not be refreshed.",why:"Previous runs are still shown. The run list changed too much to refresh them safely.",next:"Try again, or reload the latest runs to reset the loaded history."});return}if(K.has(A))throw new Error("The runs list repeated a page. Refresh to try again.");K.add(A);const U=await n.listAgentRuns(e.agent_id,50,A,!!e.archived_at);if(M!==j.current)return;L=mx(L,U.runs),A=U.next_cursor,H||(H=U.runs.some(G=>G.run_id===(D==null?void 0:D.run_id)||Date.parse(G.created_at)<W))}while(!$&&A&&D&&!H);M===j.current&&(k.current=$?mx(k.current,L):L,E.current=$?E.current+1:K.size,i(k.current),d(A),h(null),b(!1))}catch(A){M===j.current&&h(Ht(A,$?"more runs":"the runs"))}finally{await R,M===j.current&&(S.current=!1,f(!1),y(!1))}};return p.useEffect(()=>{S.current=!1,k.current=[],E.current=0,i(null),d(null),h(null),b(!1),N(null);const $=()=>{document.hidden||N(null,!0,!1,!0)};window.addEventListener("focus",$),document.addEventListener("visibilitychange",$);const _=window.setInterval($,1e4);return()=>{j.current++,S.current=!1,window.clearInterval(_),window.removeEventListener("focus",$),document.removeEventListener("visibilitychange",$)}},[n,e.agent_id,e.archived_at]),{runs:o,cursor:c,reading:u,more:g,error:x,refresh:()=>{N(null,!0)},loadMore:()=>{c&&N(c)},reloadLatest:v?()=>{N(null,!0,!0)}:null}}function UD({agent:e,history:n}){const[s,r]=p.useState(""),{runs:o,cursor:i,reading:c,more:d,error:u,refresh:f,loadMore:g,reloadLatest:y}=n;if(u&&!o)return t.jsx(Jt,{problem:u,onRetry:f,className:""});if(!o)return t.jsx(Un,{label:"Loading the runs",rows:5});const x=o.filter(h=>`${Cn(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(hm,{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(sn,{label:"Query",prompt:`${Im(location.origin,e.agent_id)}
651
- Current view: all statuses; ${e.archived_at?"archived runs":"non-archived runs"}.`,playgroundHref:$v(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:Cn(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(rb,{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:cl(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))?to(h.cost,{ended:Ha(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(Jt,{problem:u,onRetry:f,className:""}),y&&t.jsx(B,{size:"sm",onClick:y,disabled:c,children:"Reload latest runs"})]}),i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",onClick:g,disabled:c,children:d?"Loading":"Load more"})})]})}function WD({agent:e}){const n=e.definition.workflow,s=p.useMemo(()=>il(n),[n]),r=p.useMemo(()=>({meta:hd(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:[Bm(eb(s))," · rev ",e.definition.version]}),t.jsx("span",{className:"flex-1"}),t.jsx(sn,{label:"Edit workflow",prompt:Wo(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(jd,{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(kd,{})})]})}function TC({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 HD=20,BD=100,GD=4,Pi=(e,n)=>(e==null?void 0:e.filter(s=>s.status===n).length)??0,RC=e=>`#/agents/${encodeURIComponent(e.agent_id)}/learning`,gx=e=>e.toLocaleString("en-US"),AC=[{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 OC(e,n){if(!e.length)return"0";const s=e.map(n);return s.every(r=>r===null)?"—":`${gx(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 qD({v2:e,server:n}){const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),g=p.useRef(0),y=p.useRef(!1),x=p.useCallback(async()=>{if(n!=="on"&&n!=="off"||y.current)return;y.current=!0;const k=++g.current;d(!0),i(null),r(S=>(S==null?void 0:S.map(N=>N.view?{...N,stale:!0}:N))??null);const E=()=>g.current===k;try{let S=null;const N=new Set,$=await Kr(async R=>{if(!E())throw new Error("Read superseded");if(R&&N.has(R))throw new Error("The agent list repeated a page. Refresh to try again.");R&&N.add(R);const A=await e.listAgents({cursor:R});return S=A.next_cursor,A},R=>R.agents,BD);if(!E())return;if(S)throw new Error("The agent list is too large to read in one view. Open Connected agents to inspect an agent.");const _=[...new Map($.map(R=>[R.agent_id,R])).values()].map(R=>({agent:R}));r(R=>{const A=new Map(R==null?void 0:R.map(L=>[L.agent.agent_id,L]));return _.map(({agent:L})=>{const D=A.get(L.agent_id);return L.kind==="agentic"&&(D==null?void 0:D.agent.kind)==="agentic"&&D.view?{...D,agent:L,stale:!0,error:void 0,unavailable:void 0}:{agent:L}})});const P=_.filter(R=>R.agent.kind==="agentic");let O=0;const M=async()=>{for(;E()&&O<P.length;){const{agent:R}=P[O++];let A;try{const L=await e.agentLearning(R.agent_id);if(!E())return;const D=new Map(L.notes.items.map(K=>[K.file,K]));let W=L.notes.next_cursor,q;const H=new Set;for(let K=0;W&&K<HD&&E();K++){if(H.has(W)){q="The note list repeated a page.";break}H.add(W);try{const U=await e.learningNotes(R.agent_id,W);U.items.forEach(G=>D.set(G.file,G)),W=U.next_cursor}catch(U){q=Ht(U,"more notes").why;break}}A={agent:R,view:L,notes:[...D.values()],complete:!W,...W?{noteIssue:q??"More note pages are available in the agent's Learning tab."}:{}}}catch(L){A={agent:R,error:Ht(L,"Learning"),unavailable:L instanceof ze&&L.status===404}}if(!E())return;r(L=>(L==null?void 0:L.map(D=>D.agent.agent_id!==R.agent_id?D:A.error&&!A.unavailable&&D.view?{...D,...A,stale:!0}:A))??null)}};await Promise.all(Array.from({length:Math.min(GD,P.length)},M)),E()&&f(new Date().toISOString())}catch(S){E()&&i(Ht(S,"Learning Dojo"))}finally{E()&&(y.current=!1,d(!1))}},[e,n]);p.useEffect(()=>{r(null),f(null),i(null),x();const k=()=>{document.hidden||x()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{g.current++,y.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,b=h.some(k=>k.stale),j=h.flatMap(k=>{var E;return(((E=k.view)==null?void 0:E.log.items)??[]).map(S=>({agent:k.agent,change:S}))}).sort((k,E)=>E.change.at.localeCompare(k.change.at)).slice(0,8);return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 items-center gap-2 border-b px-5",children:[t.jsx(TC,{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(Yo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-7 p-5 md:p-8",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"What your agents learn"}),t.jsx("p",{className:"mt-2 max-w-3xl text-lead leading-relaxed text-muted-foreground",children:"Review the notes, skills and workflow drafts your current agents keep for later runs. Open an agent to enable learning, inspect its changes or review pending items."}),t.jsx("p",{className:"mt-2 max-w-3xl text-small leading-relaxed text-muted-foreground",children:"Imported sessions are history, not learning runs. Learning comes from agentic runs started through this server; notes you add yourself are included too."})]}),n===void 0?t.jsx("p",{role:"status",className:"text-lead text-muted-foreground",children:"Checking learning support…"}):n===null?t.jsxs("div",{className:"border bg-card p-5",children:[t.jsx("h3",{className:"font-semibold",children:"This server does not expose learning"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"Use a server version with learning support to inspect or enable it here."}),t.jsx("a",{href:"#/agents",className:"mt-4 inline-block text-lead text-primary-text underline underline-offset-4",children:"Connected agents"})]}):t.jsxs(t.Fragment,{children:[n==="off"&&t.jsx("p",{role:"status",className:"border border-warning/40 bg-warning/5 p-4 text-lead text-warning-text",children:"This server has learning turned off. Saved learning remains available; new runs will learn only after the server's learning setting is on."}),o&&t.jsxs(t.Fragment,{children:[t.jsx(Jt,{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:AC.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:OC(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.",b?" 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(KD,{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)}`:RC(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 KD({row:e,server:n}){const{agent:s,view:r,error:o}=e,i=s.kind==="agentic",c=dl(s.definition.learning);return t.jsxs("article",{className:"flex min-w-0 flex-col border bg-card p-5",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words text-lead font-semibold",children:s.definition.name||s.agent_id}),t.jsx(Ne,{tone:i&&c&&n==="on"?"success":"plain",children:i?n==="off"&&c?"Paused by server":c?"Learning on":"Learning off":"Workflow"})]}),i?t.jsxs(t.Fragment,{children:[o&&t.jsxs("div",{role:"alert",className:"mt-4 text-small text-destructive-text",children:[t.jsx("p",{children:e.unavailable?"Learning unavailable for this agent.":o.title}),t.jsxs("p",{className:"mt-1",children:[o.why," ",o.said]})]}),r?t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"mt-5 grid grid-cols-2 gap-x-4 gap-y-3",children:AC.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:OC([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:[gx(r.counts.merged)," runs kept learning · ",gx(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?RC(s):dn(s.agent_id),children:[i?"Open learning":"View agent",t.jsx(fr,{className:"size-3.5","aria-hidden":!0})]})]})}const VD=140,YD=32,QD=40,JD=60;function ab({value:e,name:n,note:s,blurb:r,description:o,tag:i,why:c,alert:d,on:u,disabled:f,warn:g,onToggle:y}){const[x,h]=p.useState(!1),v=p.useRef(null),b=p.useRef(null),j=p.useRef(null),k=p.useRef(null),E=ef(v,"width",x,n),S=ef(b,"height",x,o),N=ef(j,"width",x,i),$=ef(k,"width",x,d),_=E??n.length>YD,P=!!o&&(S??o.length>VD),O=!!i&&(N??i.length>QD),M=!!d&&($??d.length>JD),R=!!c&&(c!==i||O),A=!!o&&(!!r||P)||R||M||_,L=(W,q)=>!x&&W&&q?W:void 0,D=W=>{W.preventDefault(),W.stopPropagation(),h(q=>!q)};return t.jsxs("label",{"data-tool-card":e,className:ie("flex w-full min-w-0 flex-col border px-3 py-2.5 font-mono text-body",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:y,className:"shrink-0 accent-primary"}),t.jsx("span",{ref:v,title:L(n,_),className:ie("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:b,"data-line":!0,className:"mt-1 line-clamp-3 font-sans text-label text-muted-foreground [overflow-wrap:anywhere]",title:L(o,P),children:o}):null,i&&t.jsx("span",{ref:j,"data-tag":!0,title:L(c,R),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:L(d,M),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})]}),A&&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 ef(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 XD({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=>Ho(h)),u=!r||r.includes(s),f=(h,v,b,j,k,E)=>{const S=n.includes(h),N=(!u||!!k)&&!S,$=j??k??(S&&!u?`Won't run on ${s}.`:void 0);return t.jsx("li",{className:"min-w-0",children:t.jsx(ab,{value:h,name:v,note:E,description:b,alert:$,on:S,disabled:N,warn:!!j,onToggle:()=>c(h)})},h)},g=h=>t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:h}),y=!u&&t.jsxs("p",{className:"text-small text-warning-text",children:[s," doesn't run MCP tools on this server",r!=null&&r.length?`: ${r.join(" and ")} do`:"","."]});if(e==="failed")return t.jsxs("div",{className:"mt-4 space-y-2",children:[t.jsxs("p",{className:"font-mono text-small text-warning-text",role:"alert",children:["The MCP servers could not be read."," ",i&&t.jsx(B,{type:"button",onClick:i,size:"xs",className:"ml-1",children:"Retry"})]}),d.length>0&&g(d.map(h=>f(h,h,"Can't check right now whether its server still lists it.")))]});if(!e)return d.length?t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:"Reading the MCP servers..."}):null;const x=dI(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:[y,e.map(h=>t.jsxs("section",{"aria-label":`MCP server ${h.name}`,children:[t.jsxs("p",{className:"caps mb-2 text-label font-semibold text-muted-foreground",children:[h.name," · MCP server"]}),g(h.tools.map(v=>{var b;return f(W2(h.name,v.name),v.name,[v.title,v.description].filter(Boolean).join(": ")||void 0,void 0,cI(v,s)??(v.permission==="deny"?ob:void 0),(b=h.not_metered)!=null&&b.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 ZD="[a-z][a-z0-9-]{0,31}",PC="[A-Za-z0-9_-]{1,64}",eF="[a-z0-9][a-z0-9.-]{0,63}",tF="[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}",nF=`[a-z][a-z0-9_-]{0,63}(?:\\.${PC})?`,sF="mcp:",rF="monid:",h0="*",oF=new RegExp(`^mcp:(${ZD})/(\\*|${PC})$`),aF=new RegExp(`^monid:(${eF})/(\\*|${tF})$`),iF=new RegExp(`^${nF}$`);function lF(e){if(fl(e)){const s=aF.exec(e);return s?s[2]===h0?{kind:"monid-provider",provider:s[1]}:{kind:"monid",provider:s[1],endpoint:s[2]}:void 0}if(!dF(e))return iF.test(e)?{kind:"plain",name:e}:void 0;const n=oF.exec(e);if(n)return n[2]===h0?{kind:"mcp-server",server:n[1]}:{kind:"mcp",server:n[1],tool:n[2]}}const fl=e=>e.startsWith(rF),cF=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.`,dF=e=>e.startsWith(sF);function LC(e){const n=lF(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 uF=e=>LC(e)?void 0:cF(e);function fF(e){const n=e.trim();return!n||fl(n)?n:`monid:${n}`}function MC(e){return new Map(e.flatMap((n,s)=>fl(n)?[[`definition.tools[${s}]`,n]]:[]))}function mF(e,n){const s=MC(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 hF=e=>{const n=LC(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 pF({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]),y=()=>{const x=fF(i);if(!x)return;const h=uF(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(ab,{value:x,name:x,description:hF(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(),y()},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 gF=e=>e.offered&&(e.kind==="none"||e.providers.some(n=>n.ready)),xF=e=>{var n;return e.why??((n=e.providers.find(s=>!s.ready))==null?void 0:n.why)};function vF(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 bF=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},ib="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",lb=new Set(["sandbox","desktop","phone"]),yF=e=>e.charAt(0).toUpperCase()+e.slice(1);function wF({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=gF(c),u=d?void 0:xF(c),f=c.providers.filter(g=>g.ready).map(g=>g.name).join(", ");return t.jsxs("div",{"data-kind":c.kind,className:ie("border px-4 py-3",n.kind===c.kind?"border-foreground":"border-border",!d&&"opacity-60"),children:[t.jsxs("label",{className:ie("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(vF(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:yF(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:ie("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&&lb.has(i.kind)&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:ib}),!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 jF({value:e,saved:n,places:s,tools:r,picked:o,onChange:i,error:c,warning:d}){var N;const u=e??pd(n),f=(u??zv(!1,o,s)).mode,g=(N=s.boxes.find($=>$.available))==null?void 0:N.id,y=(u==null?void 0:u.mode)==="sandbox"?u.box:g,x=!g&&f!=="sandbox",h=new Set(r.filter($=>$.sandbox_only).map($=>$.name)),[v,b]=p.useState([]),j=()=>{const $=o.filter(_=>h.has(_));b($),i({place:{mode:"runner"},...$.length?{tools:o.filter(_=>!h.has(_))}:{}})},k=$=>{b([]),$&&i({place:{mode:"sandbox",box:$}})},E=$=>$.map(_=>_.charAt(0).toUpperCase()+_.slice(1)).join(" and "),S=($,_,P,O,M=!1)=>t.jsxs("label",{className:ie("flex items-start gap-3 border px-4 py-3",f===$?"border-foreground":"border-border",M?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsx("input",{type:"radio",name:"place",value:$,checked:f===$,disabled:M,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:P})]})]});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Where it runs"}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"radiogroup","aria-label":"Where it runs",children:[S("runner","On the server","No box and no shell: its files stay in the run's folder on the server.",j),S("sandbox","In a sandbox","Its file and shell tools run in a box; its keys stay on the server.",()=>k(y),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:ie("flex items-start gap-3 px-4 py-2.5",$.available?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"box",value:$.id,checked:y===$.id,disabled:!$.available&&y!==$.id,onChange:()=>k($.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-mono text-body",children:$.id}),!$.available&&$.reason&&t.jsx("span",{className:"mt-0.5 block text-small",children:$.reason})]})]})},$.id))}),f==="runner"&&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 IC(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 xx({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:LD}):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,":"]})," ",OD(e.pin),". ",PD,s?" This server pins it too; both hold.":""]}):null}const p0={read:["info","Read-only, its server says: under Allow reads it runs without asking."],write:["warning","Not read-only, and not marked destructive by its server: it keeps its permission."],destructive:["error","May delete or overwrite, its server says: allowing it takes a second click."]},kF=({effect:e})=>t.jsx("span",{"data-effect":e,children:t.jsx(Ne,{tone:p0[e][0],title:p0[e][1],children:e})}),NF="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function cb({label:e,rows:n,settings:s,fallbackOf:r,permissionFallbackOf:o=E=>E.default_permission,resolvesOf:i,issues:c,busy:d=!1,refused:u=()=>!1,locked:f=!1,unattended:g=!1,noteOf:y,labelOf:x,detailOf:h,effectOf:v,confirmAllowOf:b=()=>!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 L=`${N.current} permission`;N.current=null,(W=[...((D=$.current)==null?void 0:D.querySelectorAll("button[aria-label]"))??[]].find(q=>q.getAttribute("aria-label")===L))==null||W.focus()},[E,d]);const _=L=>{N.current=L,S(null)},P=n.some(L=>L.choice),O=n.some(L=>L.gate),M=n.some(L=>{var D;return((D=L.gate)==null?void 0:D.ask_needs)==="password"}),R=["Tool",...O?["Permission"]:[],...P?["Provider","Resolves to"]:[]],A=t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"—"});return t.jsxs(t.Fragment,{children:[M&&t.jsx("p",{className:"mb-2 text-small text-warning-text",children:NF}),t.jsx("div",{ref:$,className:"relative overflow-x-auto",children:t.jsxs("table",{"aria-label":e,className:"w-full border text-left",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b",children:[R.map(L=>t.jsx("th",{className:"caps px-3 py-2 text-label font-semibold text-muted-foreground",children:L},L)),t.jsx("th",{children:t.jsx("span",{className:"sr-only",children:"Reset"})})]})}),t.jsx("tbody",{children:n.map(({name:L,choice:D,gate:W})=>{var fe,De,Fe;const q=D?r(D):"",H=(fe=s[L])==null?void 0:fe.provider,K=D!==void 0&&H!==void 0&&H!==q,U=K?H:q,G=Le=>k(Ee=>$D(Ee,L,Le,q)),F=W?o(W):"allow",z=(De=s[L])==null?void 0:De.permission,Y=W!==void 0&&z!==void 0&&z!==F,se=Y?z:F,Q=W!==void 0&&u(L,se),re=Q&&f,te=re?"deny":se,he=Le=>k(Ee=>_D(Ee,L,Le,F)),ge=v==null?void 0:v(L),ye=(j==null?void 0:j(L))??"default",xe=h==null?void 0:h(L);return t.jsxs(p.Fragment,{children:[t.jsxs("tr",{"data-tool":L,"data-set":K||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(L))??L,ge&&t.jsx(kF,{effect:ge})]}),xe?t.jsx("span",{"data-tool-detail":!0,className:"mt-0.5 block text-small text-muted-foreground",children:xe}):null]}),O&&t.jsx("td",{className:"px-3 py-2",children:W?t.jsxs(t.Fragment,{children:[t.jsx(Et,{small:!0,label:`${L} permission`,value:te,disabled:d||re,onChange:Le=>{const Ee=Le;Ee==="allow"&&Ee!==te&&b(L)?S(L):he(Ee)},className:ie("w-48",Y&&"border-primary text-primary"),options:W.permissions.map(Le=>({value:Le,label:`${Le}${Le===F?` (${ye})`:""}`,...Le==="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&&!re&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",F,ye==="default"?"":` (${ye})`]}),Q&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:ob}),te==="deny"&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:ND}),te==="ask"&&g&&!Q&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),te==="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."})]}):A}),P&&t.jsx("td",{className:"px-3 py-2",children:D?t.jsxs(t.Fragment,{children:[t.jsx(Et,{small:!0,label:`${L} provider`,value:U,disabled:d,onChange:Le=>G(Le),className:ie("w-96 max-w-full",K&&"border-primary text-primary"),options:D.providers.map(Le=>({value:Le,label:`${Yf(Le,L)}${Le===q?" (default)":""}`}))}),m0(U,L)&&t.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:m0(U,L)}),K&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",Yf(q,L)]})]}):A}),P&&t.jsx("td",{className:"px-3 py-2.5",children:D?i(D,U):A}),t.jsx("td",{className:"px-2 py-2 text-right",children:K&&t.jsx(B,{size:"sm",variant:"ghost",disabled:d,"aria-label":`Reset ${L} to its default`,onClick:()=>G(void 0),children:"Reset"})})]}),E===L&&t.jsx("tr",{children:t.jsx("td",{colSpan:R.length+1,className:"px-3 pb-2.5",children:t.jsx(SF,{name:L,keep:te==="ask"?"Keep asking":"Cancel",busy:d,onAllow:()=>{d||(_(L),he("allow"))},onKeep:()=>_(L)})})}),y!=null&&y(L)?t.jsx("tr",{"data-note":L,children:t.jsx("td",{colSpan:R.length+1,className:"px-3 pb-2.5",children:y(L)})}):null,(Fe=c[L])!=null&&Fe.length?t.jsx("tr",{children:t.jsx("td",{colSpan:R.length+1,className:"px-3 pb-2.5",children:c[L].map(Le=>t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:Le},Le))})}):null]},L)})})]})})]})}function SF({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 vx({value:e,prefix:n,tool:s}){const r=EC(e,s);return t.jsxs("span",{className:ie("block font-mono text-small",r.unavailable?"text-warning-text":"text-muted-foreground"),children:[n,r.text]})}const CF=({choice:e,harnesses:n=[]})=>t.jsx(t.Fragment,{children:yD.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(vx,{value:e.resolves[s],prefix:`${s}: `,tool:e.name},s)})});function EF({agent:e,harness:n,model:s,tools:r,choices:o,gates:i=[],mcpServers:c,serverSettings:d,focus:u,callTools:f,value:g,issues:y,unattended:x=!1,onChange:h}){const v=new Set(r),b=o.filter(A=>v.has(A.name)||!A.available),j=i.some(A=>A.ask_needs==="password"),k=A=>{var L;return(L=e==null?void 0:e.tools)==null?void 0:L.find(D=>D.name===A)},E=A=>{var D;const L=Ho(A);return L?(D=c==null?void 0:c.find(W=>W.name===L.server))==null?void 0:D.tools.find(W=>W.name===L.tool):void 0},S=A=>{var D;const L=Ho(A);return L?(D=g[`mcp:${L.server}/*`])==null?void 0:D.permission:void 0},N=f?f.flatMap(A=>i.filter(L=>L.name===A)):[...new Set(r)].flatMap(A=>{var W;const L=i.find(q=>q.name===A);if(L)return[L];const D=k(A)??E(A);return!((W=D==null?void 0:D.permissions)!=null&&W.length)||!D.default_permission?[]:[{name:A,permission:D.permission??D.default_permission,default_permission:D.default_permission,permissions:D.permissions,...j&&D.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),$=IC(b,N,[...i.map(A=>A.name),...o.map(A=>A.name)]),_=p.useRef(null);if(p.useEffect(()=>{var D,W;if(!u)return;const A=`${u} permission`,L=[...((D=_.current)==null?void 0:D.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(q=>q.getAttribute("aria-label")===A);(W=L==null?void 0:L.scrollIntoView)==null||W.call(L,{block:"center"}),L==null||L.focus()},[]),!$.length)return null;const P=(e==null?void 0:e.definition.tool_settings)??{},O=x!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:M,rest:R}=_C(y,"definition.tool_settings",$.map(A=>A.name));return t.jsxs("section",{"aria-label":"Tool settings",ref:_,children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Tool settings"})}),t.jsxs("p",{className:"-mt-1 mb-2 text-small text-muted-foreground",children:["Each of these tools takes this server's setting (its default here) unless it is changed here. ",f?"A call node can't wait for an approval: a tool set to ask stops the run from starting. Set it to allow.":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(cb,{label:"This agent's tool settings",unattended:x,rows:$,settings:g,fallbackOf:A=>A.provider,issues:M,onEdit:A=>h(A(g)),effectOf:A=>{var L;return(L=E(A))==null?void 0:L.effect},confirmAllowOf:A=>{var L;return((L=E(A))==null?void 0:L.effect)==="destructive"},noteOf:A=>{const L=g[A],D=d==null?void 0:d[A],W=!!(L!=null&&L.pin||L!=null&&L.pin_broken);return!W&&!(D!=null&&D.pin)&&!(D!=null&&D.pin_broken)?null:t.jsxs(t.Fragment,{children:[W&&t.jsx(xx,{setting:L,label:"Pinned for this agent",also:!!(D!=null&&D.pin)}),(!W||(D==null?void 0:D.pin_broken))&&t.jsx(xx,{setting:D,label:"Pinned on this server"})]})},refused:A=>SC(A,i,e==null?void 0:e.tools,c),locked:!0,permissionFallbackOf:A=>{var L;return S(A.name)??((L=k(A.name))==null?void 0:L.default_permission)??A.permission},resolvesOf:A=>{var H,K,U,G,F,z;const L=(((H=g[A.name])==null?void 0:H.provider)??null)!==(((K=P[A.name])==null?void 0:K.provider)??null)||(((U=g[A.name])==null?void 0:U.permission)??null)!==(((G=P[A.name])==null?void 0:G.permission)??null)||O,D=(F=e==null?void 0:e.tools)==null?void 0:F.find(Y=>Y.name===A.name),W=D&&D.provider===(((z=g[A.name])==null?void 0:z.provider)??A.provider)?D.resolved:void 0,q=(s??"")===((e==null?void 0:e.definition.model)??"");return!L&&n===((e==null?void 0:e.definition.harness)??"pi")&&q&&W?t.jsx(vx,{value:W,prefix:`${n}: `,tool:A.name}):!L&&!P[A.name]&&!s?t.jsx(vx,{value:A.resolves[n],prefix:`${n}: `,tool:A.name}):t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),R.map(A=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:A},A))]})}const tf=20,$F=400;function _F(e,n,s,r,o){const[i,c]=p.useState(null),[d,u]=p.useState(0),f=(r??[]).join(",");p.useEffect(()=>{if(!o||!s||i==="unsupported")return;const y=new AbortController,x=setTimeout(()=>{o({workflow:n,...r?{tools:r}:{}},y.signal).then(h=>{y.signal.aborted||c({text:e,check:h})},h=>{y.signal.aborted||((h==null?void 0:h.status)===404||(h==null?void 0:h.status)===405?c("unsupported"):c({text:e,failed:(h==null?void 0:h.message)||`the server answered ${(h==null?void 0:h.status)??"nothing"}`}))})},$F);return()=>{clearTimeout(x),y.abort()}},[e,s,f,o,d]);const g=()=>{c(null),u(y=>y+1)};return i==="unsupported"||!o?{mode:"lint",retry:g}:i&&i.text===e?"failed"in i?{mode:"failed",failed:i.failed,retry:g}:{mode:"server",check:i.check,retry:g}:{mode:"pending",retry:g}}function g0({text:e,onText:n,base:s,baseLabel:r,serverIssues:o,readOnly:i=!1,validate:c,tools:d}){var q;const u=p.useRef(null),f=p.useRef(null),[g,y]=p.useState(0),x=p.useMemo(()=>hL(e),[e]),h=p.useRef(null);x.ok&&(h.current={value:x.value,spans:x.spans});const v=(q=h.current)==null?void 0:q.value,b=p.useMemo(()=>il(v),[v]),j=p.useMemo(()=>s===void 0?null:il(s),[s]),k=p.useMemo(()=>j?s2(j,b):null,[j,b]),E=_F(e,x.ok?x.value:void 0,x.ok,d,i?void 0:c),S=p.useMemo(()=>x.ok&&!i?vL(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?bL(x.spans,b.nodes.map(H=>H.path),g):null,_=p.useMemo(()=>({meta:hd(v,b),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:K})=>({label:H,kind:K}))}:void 0,selected:$?{path:$}:null}),[v,b,k,$]),P=e.split(`
652
- `).length,O=H=>pL(e,H),M=[];x.ok||M.push({...O(x.error.offset),message:`JSON: ${x.error.message}`,severity:"error",offset:x.error.offset});for(const H of N){const K=x.ok?Nk(x.spans,H.path):void 0,U=(K==null?void 0:K.start)??0;M.push({...O(U),message:H.message,severity:H.severity,offset:U,path:H.path})}for(const H of[...o??[]].reverse()){const K=H.path&&x.ok?Nk(x.spans,H.path):void 0;M.unshift({...K?O(K.start):{line:0,col:0},message:`Server: ${H.message}`,severity:"error",offset:(K==null?void 0:K.start)??-1})}const R=new Map;for(const H of M)H.line&&R.get(H.line)!=="error"&&R.set(H.line,H.severity);const A=(H,K=H)=>{const U=u.current;!U||H<0||(U.focus(),U.setSelectionRange(H,K),U.scrollTop=Math.max(0,(O(H).line-4)*tf),y(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)*tf))},[]);const L=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+L:0,W=M.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:[P," 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(tl,{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:`${tf}px`},children:Array.from({length:P},(H,K)=>t.jsx("div",{className:ie("pr-2",R.get(K+1)==="error"&&"bg-destructive/15 text-destructive-text",R.get(K+1)==="warning"&&"bg-warning/15 text-warning-text"),children:K+1},K))}),t.jsx(nn,{bare:!0,ref:u,value:e,readOnly:i,spellCheck:!1,wrap:"off","aria-label":"Workflow JSON",onChange:H=>{i||n(H.target.value),y(H.target.selectionStart)},onSelect:H=>y(H.target.selectionStart),onScroll:H=>{f.current&&(f.current.scrollTop=H.target.scrollTop)},onKeyDown:H=>{if(H.key!=="Tab"||i)return;H.preventDefault();const K=H.currentTarget,U=K.selectionStart,G=K.selectionEnd;n(`${e.slice(0,U)} ${e.slice(G)}`),requestAnimationFrame(()=>K.setSelectionRange(U+2,U+2))},className:"flex-1 resize-none overflow-auto bg-background px-3 py-3 text-small selection:bg-primary/[0.28] selection:text-foreground focus-visible:outline focus-visible:outline-focus focus-visible:-outline-offset-2 focus-visible:outline-ring",style:{lineHeight:`${tf}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:[M.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."}),M.map((H,K)=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>A(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(tl,{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})]})},K))]})]}),t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Bm(eb(b))}),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&&L&&`${L} ${L===1?"connection":"connections"} changed`].filter(Boolean).join(" · ")," ",t.jsxs("span",{className:"text-muted-foreground",children:["against ",r??"the current revision"]})]}):t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Same as ",r??"the current revision"]})),t.jsx("span",{className:"flex-1"}),!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:ie("min-h-[360px] flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-5 xl:h-[calc(100vh-330px)] xl:min-h-[480px]",!x.ok&&"opacity-60"),children:b.nodes.length?t.jsx(jd,{graph:b,marks:_,label:"The workflow's graph",minScale:.55,onSelect:H=>{const K=x.ok?x.spans.get(`${H.path}/label`)??x.spans.get(H.path):void 0;K&&A(K.start,K.end)}}):t.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"No root node to draw yet."})}),t.jsx("div",{className:"border-t px-4 py-2",children:t.jsx(kd,{})})]})]})}const TF="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function zC(){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:TF,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let Ui=null;function nf(e,n){return Ui?Ui({to:e,replay:n}):!1}function DC(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);Ui=o;const i=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",i),()=>{Ui===o&&(Ui=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(Ui=null,!n.replay){location.hash=n.to;return}location.hash!==r.current?window.addEventListener("hashchange",n.replay,{once:!0}):n.replay()}}}}const FC="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",Ng="custom",x0=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function RF(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 AF(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 OF=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:Va},{id:"workflow",label:"Workflow",note:"Its graph and its JSON",Icon:Qa},{id:"computer",label:"Computer",note:"Where it runs and what it drives",Icon:Ya},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:Sf},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:ON},{id:"history",label:"History",note:"Revisions and the current one",Icon:td}];function PF({agent:e,revisions:n=[],caps:s,onSave:r,onMakeCurrent:o,onArchive:i,onReload:c,onBack:d,step:u,problem:f=null,notice:g,draft:y,validate:x,providerChoices:h=[],permissionGates:v=[],focusTool:b,mcpServers:j=null,serverToolSettings:k,onRetryMcp:E}){var mn,Hn,_s,Bn,Ts,Rs,On;const S=!e,N=e==null?void 0:e.definition,$=es(N),_=!!(N!=null&&N.native)||!!$,[P,O]=p.useState(u??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),M=S?hg(s.places):void 0,[R,A]=p.useState({name:(N==null?void 0:N.name)??"",description:(N==null?void 0:N.description)??"",instructions:(N==null?void 0:N.instructions)??(S?tM:""),harness:(N==null?void 0:N.harness)??"pi",thinking:N==null?void 0:N.thinking,model:N==null?void 0:N.model,tools:S?pg("pi",s.tools,M):(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):"",...M?{place:M}:{},...(e==null?void 0:e.kind)==="workflow"?{workflowText:y??JSON.stringify(N.workflow,null,2)}:{}}),[L,D]=p.useState(!1),[W,q]=p.useState(!1),H=p.useRef(R);H.current=R;const[K,U]=p.useState(R),G=Z=>{const{maxCostText:Oe,workflowText:mt,...Ot}=Z,Xt=Rk(Oe),Be=x0(mt),ee={...Ot,maxCost:Xt.ok?Xt.value??0:Oe,...mt!==void 0?{workflowSent:Be!==void 0?Be:mt}:{}},we=e?{...gd(e,ee,"").definition}:{...ee};return delete we.version,we.tool_settings&&!Object.keys(we.tool_settings).length&&delete we.tool_settings,{...we,tools:[...we.tools??[]].sort(),approvals:Z.approvals??(N==null?void 0:N.approvals)??"ask"}},F=!Qi(G(R),G(K)),[z,Y]=p.useState([]),[se,Q]=p.useState(!1),re=s.tools.map(Z=>`${Z.name}:${Z.available}:${(Z.harnesses??[]).join("+")}`).join(","),te=JSON.stringify(hg(s.places)??null);p.useEffect(()=>{if(!S)return;const Z=Oe=>{const mt=Oe.place??hg(s.places);return{...Oe,...mt?{place:mt}:{},...se?{}:{tools:pg(Oe.harness??"pi",s.tools,mt)}}};A(Z),U(Z)},[re,te]);const[he,ge]=p.useState(""),[ye,xe]=p.useState(()=>((N==null?void 0:N.tools)??[]).filter(fl)),[fe,De]=p.useState(!1),[Fe,Le]=p.useState(!1),[Ee,ae]=p.useState(f),[$e,ot]=p.useState(null),me=Z=>{ot(null),O(Z)},Me=p.useRef(null),Ze=MC(Me.current??R.tools??[]),bt=(Ee==null?void 0:Ee.kind)==="invalid"?Object.entries(Ee.fields).flatMap(([Z,Oe])=>{const mt=Ze.get(Z);return mt?[{grant:mt,message:Oe}]:[]}):[],oe=Z=>(Ee==null?void 0:Ee.kind)==="invalid"&&Object.entries(Ee.fields).filter(([Oe])=>!Ze.has(Oe)&&(Oe===`definition.${Z}`||Oe.startsWith(`definition.${Z}[`)||Oe.startsWith(`definition.${Z}.`))).map(([,Oe])=>Oe).join(" ")||void 0,{monid:Se,rest:tt}=mF((e==null?void 0:e.warnings)??[],(N==null?void 0:N.tools)??[]),Ae=Z=>dM(tt,Z).map(Oe=>Oe.message).join(" ")||void 0,it=Z=>{S&&Fe||A(Oe=>({...Oe,...Z}))},$t=p.useRef(null);p.useEffect(()=>{var Z;((Ee==null?void 0:Ee.kind)==="invalid"||(Ee==null?void 0:Ee.kind)==="other")&&((Z=$t.current)==null||Z.focus())},[Ee]);const nt=(e==null?void 0:e.kind)==="workflow",ft=S&&$2(R.harness),Dt=[...(mn=R.name)!=null&&mn.trim()?[]:["Give the agent a name to create it."],...!nt&&!ft&&!((Hn=R.instructions)!=null&&Hn.trim())?["Write its instructions to create it."]:[]],Ft=R.approvals??(N==null?void 0:N.approvals)??"ask",be=lM(s.harnesses,S?{available:!!s.decisionProvider}:void 0),de={mcpHarnesses:s.mcpHarnesses,workflow:nt},Ue=Z=>{if(Z.mode==="sandbox")return;const Oe=new Set(s.tools.filter(mt=>mt.sandbox_only).map(mt=>mt.name));Y(mt=>mt.filter(Ot=>!Oe.has(Ot)))},Xe=Z=>{if(S&&!se){it({harness:Z,tools:pg(Z,s.tools,R.place)}),Y([]);return}const Oe=rM(Z,R.tools??[],z,s.tools,de);it({harness:Z,tools:Oe.tools}),Y(Oe.held)},at=n.find(Z=>Z.revision===(e==null?void 0:e.revision))??n.find(Z=>Z.current),J=OF.filter(Z=>!(S&&Z.id==="history")&&(Z.id!=="workflow"||nt)&&!(ft&&Z.id==="tools")&&(Z.id!=="computer"||!nt&&!ft&&!!(s.computers||s.places))),ve=J.some(Z=>Z.id===P)?P:J[0].id,We=J.findIndex(Z=>Z.id===ve),Ve=async()=>{if(!r)return;const Z=R;Me.current=R.tools??[],Le(!0);let Oe={...R,workflowText:void 0,maxCostText:void 0};if(!ft){const Xt=Rk(R.maxCostText);if(!Xt.ok){Le(!1),ae({kind:"invalid",message:Xt.message,fields:{"definition.max_cost_usd":Xt.message}});return}const Be=typeof(N==null?void 0:N.max_cost_usd)=="number"&&N.max_cost_usd>0,ee=Xt.value??0;(ee!==0||Be)&&(Oe={...Oe,max_cost_usd:ee})}if(nt)try{Oe={...Oe,workflow:JSON.parse(R.workflowText??"")}}catch(Xt){Le(!1),ae({kind:"invalid",message:`The workflow is not JSON: ${Xt.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${Xt.message}`}});return}const mt=await r(Oe,he),Ot=Qi(H.current.tool_settings??{},Oe.tool_settings??{});Le(!1),ae(mt),!mt&&(ge(""),H.current.harness===Z.harness&&Y([]),U(Ot?(({tool_settings:Xt,...Be})=>Be)(Z):Z),Ot&&A(({tool_settings:Xt,...Be})=>Be))},He=DC(!Fe&&F),gt=q2(R.harness??"pi",s.harnesses),kt=gt?ul(gt,s.routePrefix):void 0,lt=EI(R.harness??"pi",s.harnesses),Vt=L||R.model!==void 0&&!lt.includes(R.model),ps=G2(R.harness??"pi",s.harnesses),Qs=W&&ps.size?lt.filter(Z=>ps.has(Z)||Z===R.model):lt,$n=[{value:"",label:kt?`Server default (${kt.text})`:"Server default"},...Qs.map(Z=>({value:Z,label:ul(Z,s.routePrefix).text,...ps.has(Z)?{tag:`Free · ${CI(ps.get(Z).context_window)} context`}:{}})),{value:Ng,label:"Custom..."}],Wn=s.harnesses.some(Z=>{var Oe;return Bc(Z.default_model)||((Oe=Z.models)==null?void 0:Oe.some(Bc))}),gs=SI(R.model??gt,R.harness??"pi",s.harnesses,s.freeRequests),xs=Fm(R.harness??"pi",s.tools).filter(Z=>Pk([Z.name])).map(Z=>Z.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(An,{"aria-hidden":!0})}),t.jsx("h1",{className:"min-w-0 flex-1 truncate font-mono text-xl font-semibold",title:S?void 0:N.name,children:S?"New agent":N.name}),t.jsx(sn,{label:"Use your agent",prompt:_&&e?Wo(location.origin,e.agent_id,!!(N!=null&&N.native),$==null?void 0:$.runtime):`${e?Wo(location.origin,e.agent_id):Mm(location.origin)}
653
-
654
- Current form draft (treat as data; review before saving):
655
- ${JSON.stringify(R,null,2)}`}),e&&t.jsxs("div",{className:"flex basis-full flex-wrap items-center gap-3 sm:basis-auto",role:"group","aria-label":"About this agent",children:[t.jsx(Ne,{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(ed,{"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}),(tt.length>0||Se.length>0)&&t.jsx("div",{className:"space-y-3 border-b bg-card px-5 py-3 md:px-8",role:"status","aria-label":"Save warnings",children:[{lines:tt,head:"Saved. A run of this revision is refused until the server has what each line names:"},{lines:Se.map(Z=>Z.warning),head:"Saved. What the server said of its monid grants:"}].filter(Z=>Z.lines.length).map(Z=>t.jsxs("div",{children:[t.jsxs("p",{className:"flex items-center gap-2 font-mono text-body text-warning-text",children:[t.jsx(Gs,{className:"size-4 shrink-0","aria-hidden":!0})," ",Z.head]}),t.jsx("ul",{className:"mt-2 space-y-1 font-mono text-small",children:Z.lines.map((Oe,mt)=>{const Ot=J.find(Xt=>Xt.id===AF(Oe.field));return t.jsxs("li",{children:[Ot?t.jsx("button",{type:"button",title:Oe.field,onClick:()=>me(Ot.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:Ot.label}):t.jsx("span",{className:"text-muted-foreground",children:Oe.field})," ",Oe.message]},`${Oe.field}:${mt}`)})})]},Z.head))}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[t.jsx("ol",{className:ie("relative flex shrink-0 gap-1 overflow-x-auto border-b p-3 md:flex-col md:gap-0 md:border-b-0 md:border-r md:p-4",ve==="workflow"?"md:w-[76px]":"md:w-[240px]"),children:J.map((Z,Oe)=>t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","aria-current":ve===Z.id?"step":void 0,onClick:()=>me(Z.id),className:ie("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",ve===Z.id?"border-l-foreground bg-foreground/5":"border-l-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{className:ie("inline-flex size-6 shrink-0 items-center justify-center border text-label font-semibold",ve===Z.id?"border-foreground bg-foreground text-background":Oe<We?"border-border-strong":"border-border"),children:Oe<We?t.jsx(pl,{className:"size-3","aria-hidden":!0}):Oe+1}),t.jsxs("span",{className:ie("hidden min-w-0",ve!=="workflow"&&"md:block"),title:ve==="workflow"?Z.label:void 0,children:[t.jsxs("span",{className:"caps flex items-center gap-1.5 text-small",children:[t.jsx(Z.Icon,{className:"size-3.5","aria-hidden":!0})," ",Z.label]}),t.jsx("span",{className:"mt-0.5 block text-label text-muted-foreground",children:Z.note})]}),t.jsx("span",{className:"sr-only md:hidden",children:Z.label})]})},Z.id))}),t.jsxs("section",{className:"min-h-0 flex-1 overflow-auto px-5 py-6 md:px-10",children:[t.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Step ",We+1]}),t.jsx("h2",{className:"mb-6 border-b pb-4 text-lg font-semibold",children:J[We].label}),t.jsxs("fieldset",{disabled:S&&Fe,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(wt,{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:Ae("name"),children:t.jsx(Pe,{id:"agent-name",value:R.name,readOnly:!S,onChange:Z=>it({name:Z.target.value}),placeholder:"e.g., Invoice checker"})}),t.jsx(wt,{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:Ae("description"),children:t.jsx(Pe,{id:"agent-description",value:R.description,readOnly:!S,onChange:Z=>it({description:Z.target.value}),placeholder:S?"Short summary for the agent list":"No description"})})]}),ft?t.jsx(wt,{group:!0,label:"Workflow",children:t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:R.harness===Mv?"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(wt,{group:!0,label:"Workflow",note:"This agent is a workflow. Edit its nodes in the Workflow step: the graph redraws as you type and the server checks it.",warning:Ae("workflow"),children:t.jsxs(B,{size:"sm",onClick:()=>O("workflow"),children:[t.jsx(Qa,{"aria-hidden":!0})," Open the workflow"]})}):t.jsxs(wt,{group:fe?"heading":void 0,label:"Instructions",id:fe?void 0:"agent-instructions",required:!0,error:oe("instructions"),warning:Ae("instructions"),aside:t.jsx("span",{className:"flex",children:["Preview","Edit"].map(Z=>t.jsx(B,{size:"xs",type:"button",onClick:()=>De(Z==="Preview"),className:ie("caps border px-2.5 py-1 text-label",Z==="Preview"===fe?"border-foreground bg-foreground text-background":"text-muted-foreground"),children:Z},Z))}),children:[fe?t.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:no(R.instructions||"")}}):t.jsx(nn,{id:"agent-instructions",value:R.instructions,onChange:Z=>it({instructions:Z.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:ie(LF,"resize-y leading-[1.7]")}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(R.instructions??"").length," characters"]})]})]}),ve==="workflow"&&t.jsx(g0,{text:R.workflowText??"",onText:Z=>it({workflowText:Z}),base:nt?N.workflow:void 0,baseLabel:at?`rev ${at.version}`:void 0,validate:x,tools:R.tools,serverIssues:RF(Ee,nt)}),ve==="computer"&&!nt&&!ft&&s.computers&&t.jsx("div",{className:"space-y-8",children:t.jsx(wF,{kinds:s.computers,value:R.computer??(N==null?void 0:N.computer)??sx(R.place??{mode:"runner"}),onChange:Z=>{const Oe=bF(Z),mt=new Set(s.tools.filter(Ot=>Ot.sandbox_only).map(Ot=>Ot.name));it({computer:Z,place:Oe,...Oe.mode==="runner"?{tools:(R.tools??[]).filter(Ot=>!mt.has(Ot))}:{}}),Ue(Oe)},error:oe("computer")??oe("place"),warning:Ae("computer")??Ae("place")})}),ve==="computer"&&!nt&&!ft&&!s.computers&&s.places&&t.jsx("div",{className:"space-y-8",children:t.jsx(jF,{value:R.place,saved:N==null?void 0:N.place,places:s.places,tools:s.tools,picked:R.tools??[],onChange:Z=>{it({...Z,...Z.place?{computer:sx(Z.place)}:{}}),Z.place&&Ue(Z.place)},error:oe("computer")??oe("place"),warning:Ae("computer")??Ae("place")})}),ve==="tools"&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs(wt,{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:Ae("tools"),children:[t.jsxs("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:[s.tools.filter(Z=>{var Oe;return nt||!Z.call_only||((Oe=R.tools)==null?void 0:Oe.includes(Z.name))}).map(Z=>{var St,It;const Oe=rx(R.harness??"pi",Z.name,s.tools,de),mt=((St=R.tools)==null?void 0:St.includes(Z.name))??!1,Ot=h.find(ct=>ct.name===Z.name),Xt=(It=(R.tool_settings??(N==null?void 0:N.tool_settings)??{})[Z.name])==null?void 0:It.provider,Be=!!Ot&&Xt!==void 0&&Xt!==Ot.provider,ee=oM(Z,R.place??pd(N==null?void 0:N.place)??zv(nt,R.tools??[],s.places)),we=SC(Z.name,v,e==null?void 0:e.tools)?ob:Z.call_only&&!nt?"Workflow-only: a workflow's call node runs it, not an agent":Oe?ee??(!Z.available&&!Be?(Ot==null?void 0:Ot.reason)??Z.reason??`Needs ${(Z.missing??[]).join(", ")}`:void 0):Ok(R.harness??"pi",Z.name,s.tools),qe=we?Z.call_only&&!nt?"Workflow only":ee&&Oe&&we===ee?"Sandbox-only":we:void 0;return t.jsx("li",{className:"min-w-0",children:t.jsx(ab,{value:Z.name,name:Z.name,blurb:Z.blurb,description:Z.summary,why:we,tag:qe,on:mt,disabled:!!we&&!mt,onToggle:()=>{Q(!0),it({tools:mt?R.tools.filter(ct=>ct!==Z.name):[...R.tools??[],Z.name]})}})},Z.name)}),s.mcp&&!nt&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(XD,{servers:j,tools:R.tools??[],harness:R.harness??"pi",harnesses:s.mcpHarnesses,onRetry:E,onChange:Z=>{Q(!0),it({tools:Z})}})}),!nt&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(pF,{tools:R.tools??[],listed:ye,notes:Se.map(({grant:Z,warning:Oe})=>({grant:Z,message:Oe.message})),refused:bt,onChange:Z=>{xe(Oe=>[...new Set([...Oe,...Z.filter(fl)])]),Q(!0),it({tools:Z})}})})]}),!nt&&!Pk(R.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.`:`${R.harness??"pi"} runs no web tool on this server.`]})]}),t.jsx(EF,{agent:e,unattended:!nt&&Ft==="never",harness:R.harness??"pi",model:R.model,tools:R.tools??[],choices:nt?[]:h,gates:v,mcpServers:Array.isArray(j)?j:void 0,serverSettings:k,focus:b,callTools:nt?wD(x0(R.workflowText)??(N==null?void 0:N.workflow)):void 0,value:R.tool_settings??(N==null?void 0:N.tool_settings)??{},issues:(Ee==null?void 0:Ee.kind)==="invalid"?Ee.fields:{},onChange:Z=>!Fe&&Qi(Z,(N==null?void 0:N.tool_settings)??{})?A(({tool_settings:Oe,...mt})=>mt):it({tool_settings:Z})}),!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(([Z,Oe,mt])=>t.jsxs("label",{className:ie("flex items-start gap-3 border px-3 py-2.5",Ft===Z&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"approvals",value:Z,className:"mt-1 accent-primary",checked:Ft===Z,disabled:Fe,onChange:()=>it({approvals:Z})}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:Oe}),t.jsx("span",{className:"block text-small text-muted-foreground",children:mt})]})]},Z)),Ft==="never"&&t.jsx("p",{className:"text-small text-warning-text",children:FC})]}),t.jsx(wt,{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(Z=>t.jsx("li",{className:"border-b px-3 py-2 font-mono text-body last:border-b-0",children:Z},Z))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No skills."})})]}),ve==="settings"&&t.jsxs("div",{className:"2xl:columns-2 2xl:gap-x-10 [&>*]:mb-8 [&>*]:mt-0 [&>*]:break-inside-avoid",children:[!nt&&t.jsxs(wt,{group:"heading",label:"Harness",note:"What runtime runs this agent.",error:oe("harness"),warning:Ae("harness"),children:[t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,9rem),1fr))] gap-3",role:"radiogroup","aria-label":"Harness",children:be.map(Z=>{const Oe=t.jsxs(t.Fragment,{children:[t.jsx("input",{type:"radio",name:"harness",value:Z.id,checked:R.harness===Z.id,disabled:!Z.available&&R.harness!==Z.id,onChange:()=>Xe(Z.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block break-words font-mono text-body font-semibold",children:Z.label}),t.jsx("span",{className:"mt-0.5 block font-mono text-label text-muted-foreground",children:Z.available?Z.id:"Not available here"})]})]}),mt=ie("min-w-0 border px-4 py-3",R.harness===Z.id?"border-foreground":"border-border");return Z.available?t.jsx("label",{className:ie(mt,"flex cursor-pointer items-start gap-3"),children:Oe},Z.id):t.jsxs("div",{className:ie(mt,"opacity-60"),children:[t.jsx("label",{className:"flex cursor-not-allowed items-start gap-3",children:Oe}),Z.reason&&t.jsxs("details",{className:"mt-2 font-mono text-label text-muted-foreground",children:[t.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Why, and what to do"}),t.jsx("p",{className:"mt-1 break-words leading-[1.6]",children:Z.reason})]})]},Z.id)})}),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=be.find(Z=>Z.id===R.harness))==null?void 0:Bn.label)??R.harness," doesn't run ",z.length===1?"this tool":"these tools"," here, so ",z.length===1?"it's":"they're"," unticked. Switching back ticks ",z.length===1?"it":"them"," again."]}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:z.map(Z=>t.jsxs("li",{children:[Z,": ",t.jsx("span",{className:"text-muted-foreground",children:Ok(R.harness??"pi",Z,s.tools,s.mcpHarnesses)})]},Z))})]})]}),!nt&&!ft&&t.jsx(wt,{group:"heading",label:"Thinking",note:"How hard the model thinks before it answers.",error:oe("thinking"),warning:Ae("thinking"),children:t.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Thinking",children:s.thinking.map(Z=>t.jsxs("label",{className:ie("caps cursor-pointer border px-3 py-2 text-small",R.thinking===Z?"border-foreground":"text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:R.thinking===Z,onChange:()=>it({thinking:Z})}),Z]},Z))})}),!ft&&t.jsxs(wt,{label:"Model",id:"agent-model",optional:!0,note:kt?t.jsxs(t.Fragment,{children:["Empty uses the server's default (",t.jsx("span",{title:kt.title,children:kt.text}),")."]}):$I,error:oe("model"),warning:Ae("model"),children:[t.jsx(Et,{id:"agent-model",label:"Model",className:"w-full",value:Vt?Ng:R.model??"",options:$n,onChange:Z=>{if(Z===Ng){D(!0);return}D(!1),it({model:Z||void 0})}}),Vt&&t.jsx(Pe,{id:"agent-model-custom","aria-label":"Custom model",className:"mt-2",value:R.model??"",onChange:Z=>{D(!0),it({model:Z.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(cd,{checked:W,onChange:q,label:"Free models only"})," Free models only (",ps.size,"): $0 a request; the provider limits requests per day."]})]}),!ft&&t.jsx(wt,{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:wI}),gs&&t.jsx("span",{className:"mt-1 block","data-note":"free-requests",children:gs})]}),hint:t.jsx(zC,{}),error:oe("max_cost_usd"),warning:Ae("max_cost_usd"),children:t.jsx(Pe,{id:"agent-max-cost",inputMode:"decimal",value:R.maxCostText??"",onChange:Z=>it({maxCostText:Z.target.value}),placeholder:"e.g., 2.50"})}),!nt&&!ft&&s.learning&&t.jsx(bz,{fields:R,onFields:it,saved:N==null?void 0:N.learning,server:s.learning,error:oe("learning"),warning:Ae("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:()=>ot(null),children:[t.jsx(An,{"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(g0,{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(Z=>{var Oe;return t.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsxs("span",{className:"caps w-14 text-small",children:["rev ",Z.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:Z.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(Z.created_at)}),nt&&!Z.current&&((Oe=Z.definition)==null?void 0:Oe.workflow)!==void 0&&t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>ot(Z),"aria-label":`View rev ${Z.version}`,children:[t.jsx(fm,{"aria-hidden":!0})," View"]}),Z.current?t.jsx(Ne,{tone:"success",children:"Current"}):t.jsx(B,{size:"sm",onClick:()=>o==null?void 0:o(Z.revision),disabled:!o,children:"Make current"})]},Z.revision)})})]})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center gap-3 border-t px-5 py-3 md:px-8",children:[t.jsxs(B,{size:"sm",variant:"ghost",disabled:We===0,onClick:()=>me(J[We-1].id),children:[t.jsx(An,{"aria-hidden":!0})," Previous"]}),ve!=="history"&&t.jsx(Pe,{value:he,onChange:Z=>ge(Z.target.value),placeholder:S?"":"What changed (a note on this revision)","aria-label":"Revision note",className:ie("h-9 min-w-0 flex-1",S&&"invisible")}),ve==="history"&&t.jsx("span",{className:"flex-1"}),We<J.length-1&&t.jsxs(B,{size:"sm",onClick:()=>me(J[We+1].id),children:["Next ",t.jsx(Dx,{"aria-hidden":!0})]}),!$e&&t.jsx(B,{ref:$t,size:"sm",variant:"solid",onClick:Ve,disabled:!r||Fe||!S&&!F||!((Rs=R.name)!=null&&Rs.trim())||!nt&&!ft&&!((On=R.instructions)!=null&&On.trim()),children:S?Fe?"Creating…":"Create":Fe?"Saving…":F?"Save revision":at?`Saved · rev ${at.version}`:"Saved"}),S&&!Fe&&!$e&&Dt.map(Z=>t.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:Z},Z)),(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(hv,{open:He.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:He.leave,onCancel:He.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 LF="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 MF({agents:e,archived:n=!1,onArchivedChange:s,actions:r={},error:o,handoff:i,observations:c}){var g;const[d,u]=p.useState(""),f=(e??[]).filter(y=>`${y.definition.name} ${y.definition.description??""}`.toLowerCase().includes(d.toLowerCase()));return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:"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(Fx,{className:"size-4","aria-hidden":!0}),n?"Archived agents":"Connected agents"]}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:[i,!n&&t.jsx(sn,{variant:"primary",label:"Build an agent",prompt:Mm(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:ie(Uc,"flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3"),children:[t.jsx(hm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,value:d,onChange:y=>u(y.target.value),placeholder:"Search agents by name or description...","aria-label":"Search agents",className:"h-full flex-1 max-sm:portrait:placeholder:text-transparent"})]}),t.jsxs(B,{size:"lg",variant:n?"primary":"outline","aria-pressed":n,onClick:()=>s==null?void 0:s(!n),children:[t.jsx(ed,{"aria-hidden":!0})," Archived"]})]}),o?t.jsx("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:o}):e?!f.length&&!((g=c==null?void 0:c.data)!=null&&g.sessions.length)?t.jsxs("div",{className:"border px-4 py-16 text-center",children:[t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:d?"No agent matches.":n?"No archived agents.":"No agents yet."}),!d&&!n&&t.jsx("a",{className:"mt-4 inline-block text-lead text-primary-text hover:underline",href:"#/agents/new",children:"Describe your agent or start from a template"})]}):t.jsxs(t.Fragment,{children:[!!f.length&&t.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[f.length," ",f.length===1?"agent":"agents"]}),t.jsx("ul",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 2xl:grid-cols-3",children:f.map(y=>t.jsx(IF,{agent:y,actions:r},y.agent_id))})]}):t.jsx(Un,{label:"Loading the agents",rows:6}),c&&t.jsx("div",{className:"mt-6",children:t.jsx(Ev,{read:c,view:"cards",query:d})})]})]})}function IF({agent:e,actions:n}){var d;const s=e.kind==="workflow"?Qa:Fx,r=!!e.archived_at,o=Uv(e),i=es(e.definition),c=Gf(e);return t.jsxs("li",{className:ie("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(Ne,{children:e.kind}),e.kind==="agentic"&&t.jsx(Ne,{children:i?Ko(i.runtime):o?xd(o.runtime):e.definition.harness??"pi"}),o&&t.jsx(Ne,{tone:o.connected&&o.state==="ready"?"success":"warning",children:vd(o)}),r&&t.jsx(Ne,{tone:"muted",children:"Archived"})]}),t.jsx("span",{className:"mt-2 line-clamp-2 block text-lead leading-relaxed text-muted-foreground",children:e.definition.description||(e.kind==="workflow"?yL(e.definition.workflow):"No description.")})]})]}),o&&t.jsxs("p",{className:"mt-3 break-all font-mono text-small text-muted-foreground",children:[o.project," · ",o.machine_id]}),t.jsxs("div",{"data-testid":"agent-card-footer",className:"mt-auto flex min-w-0 flex-wrap items-start gap-x-2 gap-y-1 pt-5",children:[t.jsxs("div",{"data-testid":"agent-card-chips",className:"flex min-w-0 flex-auto flex-wrap items-center gap-x-2 gap-y-1.5 py-1.5",children:[t.jsxs(Ne,{className:"shrink-0 whitespace-nowrap",children:[e.revisions," ",e.revisions===1?"revision":"revisions"]}),e.runs&&t.jsxs(Ne,{className:"shrink-0 whitespace-nowrap",children:[e.runs.count," ",e.runs.count===1?"run":"runs",e.runs.live?` · ${e.runs.live} live`:""]}),c>0&&t.jsxs(B,{size:"xs",type:"button","aria-label":nb(c),onClick:()=>{var u;return(u=n.onLearning)==null?void 0:u.call(n,e.agent_id)},className:"h-5 shrink-0 whitespace-nowrap border-warning/50 bg-warning/10 px-1.5 text-micro text-warning-text hover:bg-warning/20",children:["Learning · ",c]})]}),t.jsxs("div",{"data-testid":"agent-card-actions",className:"ml-auto flex min-w-0 max-w-full flex-wrap items-center justify-end gap-2",children:[!r&&t.jsx(sn,{compact:!0,compactIcon:t.jsx(Vo,{className:"size-3.5","aria-hidden":!0}),label:`Run ${e.definition.name}`,disabled:!!o&&(!o.connected||o.state!=="ready"||!o.capabilities.launch),prompt:Lv(location.origin,e.agent_id,i==null?void 0:i.runtime),playgroundHref:i?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`}),t.jsx(sn,{compact:!0,compactIcon:t.jsx(Gx,{className:"size-3.5","aria-hidden":!0}),label:`Edit ${e.definition.name}`,prompt:Wo(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(td,{"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(SN,{"aria-hidden":!0}):t.jsx(ed,{"aria-hidden":!0})})]})]})]})}function zF({v2:e}){const[n,s]=p.useState(null),[r,o]=p.useState(!1),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(""),[y,x]=p.useState("live"),[h,v]=p.useState(null),[b,j]=p.useState(!1),[k,E]=p.useState(!1),[S,N]=p.useState(null),$=p.useRef(!1),_=p.useRef(!1),P=p.useRef(0),O=p.useRef(!0),M=S5(),R=p.useCallback(async()=>{if(_.current)return;_.current=!0,o(!0);const W=P.current;try{const q=await e.listConnectors();O.current&&W===P.current&&(s(q.connectors),c(null))}catch(q){O.current&&W===P.current&&c(Wt(q))}finally{_.current=!1,O.current&&o(!1)}},[e]);p.useEffect(()=>{O.current=!0,queueMicrotask(()=>{O.current&&R()});const W=()=>{!document.hidden&&!$.current&&R()},q=setInterval(W,15e3);return window.addEventListener("focus",W),document.addEventListener("visibilitychange",W),()=>{O.current=!1,P.current++,clearInterval(q),window.removeEventListener("focus",W),document.removeEventListener("visibilitychange",W)}},[R]),p.useEffect(()=>{if(!h)return;const W=new Date(h.expires_at).getTime()-Date.now();if(W<=0){v(null),j(!0);return}const q=setTimeout(()=>{v(null),j(!0)},W);return()=>clearTimeout(q)},[h]);const A=async()=>{if(!$.current){$.current=!0,E(!0),u(null),j(!1);try{const W=await e.enrollConnector(f,{native_execution:y!=="history",history_import:y!=="live"});O.current&&v(W)}catch(W){O.current&&u(Wt(W))}finally{$.current=!1,O.current&&E(!1)}}},L=async()=>{if(!($.current||!S)){$.current=!0,E(!0),u(null),P.current++;try{const{connector:W}=await e.revokeConnector(S.connector_id);O.current&&(s(q=>(q==null?void 0:q.map(H=>H.connector_id===W.connector_id?W:H))??null),N(null))}catch(W){O.current&&u(Wt(W))}finally{$.current=!1,O.current&&E(!1)}}},D=async()=>{if(h)try{await navigator.clipboard.writeText(h.enrollment_token),M({title:"Connection code copied"})}catch{M({title:"Select and copy the connection code below",tone:"error"})}};return t.jsxs("div",{className:"space-y-6","aria-label":"Remote connections",children:[t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Connect another machine",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-lg font-semibold",children:"Connect remote agents"}),t.jsx(sn,{label:"Connect agent",prompt:FL(location.origin,y)})]}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect a Claude Code or Codex setup on your laptop, VM or container. Its files and native sign-in stay there."}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label",children:"Allow this connection to"}),t.jsx(ld,{name:"remote-connection-intent",label:"Connection scope",size:"sm",value:y,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:[y==="live"?"Run future jobs with your existing setup. Past conversations are not shared.":y==="history"?"Upload completed conversations from one selected project and runtime. No executing worker or self-improvement is enabled.":"Connect for future jobs and upload completed conversations from the selected project and runtime."," ",y!=="live"&&" Preview and approve the history on the source machine before upload. History is not used as learning."]})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(wt,{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 A(),children:k&&!S?"Creating code…":"Create connection code"})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Use the code only in the connector's secure terminal prompt. It expires after ten minutes and can pair one machine. The coding-agent prompt contains no credentials."}),b&&t.jsx(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 R(),"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 R(),children:"Try again"}),children:i}),n===null&&!i&&t.jsx("p",{className:"text-body text-muted-foreground",role:"status",children:"Loading remote machines…"}),(n==null?void 0:n.length)===0&&t.jsxs("div",{className:"border p-6",children:[t.jsx("h3",{className:"text-body font-semibold",children:"No remote machines connected"}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Use your coding agent to connect a source machine. It appears here once the connector has paired."})]}),n==null?void 0:n.map(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(Ne,{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(q=>t.jsxs("li",{className:"space-y-2 pt-3 [&+li]:mt-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("span",{className:"min-w-0 flex-1 break-words text-body font-semibold",children:q.name}),q.agent_id?t.jsx("a",{href:dn(q.agent_id),className:"text-small underline underline-offset-2",children:"Open agent"}):t.jsx(Ne,{children:"Not imported"})]}),t.jsxs("p",{className:"break-words text-small text-muted-foreground",children:[xd(q.runtime)," · ",q.machine_id," · ",q.history_only?"Imported history":W.status==="online"?q.state==="ready"&&q.capabilities.launch?"Ready to run":q.state==="needs_attention"?"Needs attention":"Needs verification":"Worker unavailable"]}),q.issues.length>0&&t.jsx("p",{className:"text-small text-warning-text",children:q.issues.join("; ")})]},q.target_id))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No native targets imported. Choose a project or agent with the source connector."})]},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(Am,{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(wt,{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(hv,{open:S!==null,title:"Revoke this machine's access?",confirm:k?"Revoking…":"Revoke access",busy:k,onCancel:()=>{N(null),u(null)},onConfirm:()=>void L(),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 Qm({variant:e}){return t.jsx(sn,{variant:e,label:"Connect agent",prompt:N2(location.origin),playgroundHref:"#/agents/connect",playgroundLabel:"Connection setup"})}function DF({v2:e,go:n,initialSource:s="server"}){const[r,o]=p.useState(s),[i,c]=p.useState(""),[d,u]=p.useState(null),[f,g]=p.useState([]),[y,x]=p.useState({}),[h,v]=p.useState(!1),[b,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(Wt(S))}finally{v(!1)}},E=async()=>{v(!0),j(null);try{for(const S of f){if(y[S])continue;const{project:N,runtime:$,selector:_}=d[S],P=await e.connectNative({project:N,runtime:$,selector:_});x(O=>({...O,[S]:P.agent.agent_id}))}}catch(S){j(Wt(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(ld,{name:"native-source",label:"Connection method",value:r,onChange:o,options:[{value:"server",label:"This server",disabled:h},{value:"remote",label:"Another machine",disabled:h},{value:"observe",label:"Existing application",disabled:h}]}),r==="observe"?t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Observe an existing application",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Observe your existing agent"}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect Claude Code or Codex running locally, in Docker, or on another server. Your application continues to start and control its jobs; AgentRun receives session activity, model and token usage."}),t.jsx("p",{className:"max-w-prose text-small text-muted-foreground",children:"The setup skill configures the existing CLI and telemetry collector for this server. Adding self-improvement requires the backend SDK integration."}),t.jsx(sn,{variant:"primary",label:"Connect agent",prompt:`${N2(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(zF,{v2:e}):t.jsxs(t.Fragment,{children:[t.jsx(Qm,{}),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(wt,{label:"Project on server host",hint:"Enter the absolute path on the machine running AgentRun.",children:t.jsx(Pe,{"aria-label":"Project on server host",value:i,onChange:S=>{c(S.target.value),u(null)},placeholder:"/path/to/project",disabled:h})}),t.jsx(B,{variant:d?"outline":"solid",size:"sm",disabled:h||!i.trim().startsWith("/"),"aria-busy":h,onClick:()=>void k(),children:h&&!d?"Discovering…":"Discover"})]}),b&&t.jsx(vt,{tone:"error",title:"Connection request failed",children:b}),d&&t.jsxs("section",{className:"space-y-4","aria-label":"Native targets",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Choose what to connect"}),!d.length&&t.jsx(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||!!y[N],checked:f.includes(N),onChange:$=>g(_=>$.target.checked?[..._,N]:_.filter(P=>P!==N))}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("strong",{className:"break-words text-body",children:Dv(S.selector)}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:[xd(S.runtime)," · ",S.version??"Version unknown"]})]})]}),t.jsx(Ne,{tone:S.state==="ready"?"success":"warning",children:vd(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:$},$))})}),y[N]&&t.jsxs("p",{role:"status",className:"text-body",children:["Connected. ",t.jsx("a",{href:dn(y[N]),className:"underline underline-offset-2",children:"Open connected agent"})]})]},`${S.runtime}:${S.selector.kind}:${S.selector.name??""}`)),!!d.length&&t.jsx(B,{variant:"solid",size:"sm",onClick:()=>void E(),disabled:h||!f.some(S=>!y[S]),"aria-busy":h,children:h?"Connecting…":"Connect selected"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Connecting saves a reference and starts no run. Authentication and approval compatibility are checked separately on the connected agent's page."})]})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Your coding agent can also help import selected history. Past conversations stay historical; they do not become live jobs or AgentRun learning."})]})}const Ea=e=>e instanceof ze?cM(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function FF({v2:e,archived:n,go:s}){const r=Cv(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),Kr(y=>e.listAgents({archived:n,cursor:y}),y=>y.agents).then(y=>{g===u.current&&i(y)}).catch(y=>{g===u.current&&d(Ea(y).message)})};return p.useEffect(()=>{f();const g=()=>{document.hidden||f()};return window.addEventListener("focus",g),document.addEventListener("visibilitychange",g),()=>{window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",g)}},[e,n]),t.jsx(MF,{observations:r,agents:o,archived:n,onArchivedChange:g=>s(g?"#/agents?archived=true":"#/agents"),error:c,handoff:t.jsx(Qm,{}),actions:{onOpen:g=>s(dn(g)),onEdit:g=>s(dn(g,"edit")),onNew:()=>s("#/agents/new"),onRuns:g=>s(dn(g,"runs")),onLearning:g=>s(dn(g,"learning")),onArchive:async(g,y)=>{try{await(y?e.archiveAgent(g):e.unarchiveAgent(g)),f()}catch(x){d(Ea(x).message)}}}})}function UF({v2:e,caps:n,choices:s=[],gates:r=[],focusTool:o,agentId:i,go:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,x]=p.useState([]),[h,v]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(0),[S,N]=p.useState(null),$=p.useRef(!0);p.useEffect(()=>($.current=!0,()=>{$.current=!1}),[]);const _=U=>Kr(G=>e.listRevisions(U,G),G=>G.revisions),P=async()=>{if(i)try{const[{agent:U,etag:G},F]=await Promise.all([e.getAgent(i),_(i)]);u(U),g(G),x(F),N(U.revision),E(z=>z+1),j(null),v(null)}catch(U){d?j(`The agent could not be reloaded: ${Ea(U).message}`):v(Ea(U).message)}};p.useEffect(()=>{P()},[i]);const[O,M]=p.useState(null),R=p.useRef(0);p.useEffect(()=>{const U=++R.current;e.computers().then(G=>{U===R.current&&M(G.kinds)},()=>{U===R.current&&M(null)})},[e]);const[A,L]=p.useState(void 0);p.useEffect(()=>{let U=!0;return Promise.resolve().then(()=>e.toolSettings()).then(G=>{U&&L(G)},()=>{}),()=>{U=!1}},[e]);const[D,W]=p.useState(null),q=p.useRef(0),H=()=>{if(!n.mcp)return;const U=++q.current;W(null),e.listMcpServers().then(G=>{U===q.current&&W(G.servers)},()=>{U===q.current&&W("failed")})};p.useEffect(H,[e,n.mcp]);const K=async(U,G)=>{let F;try{F=await G()}catch(z){j(`${U} did not finish: ${Ea(z).message}`);return}u(F);try{const{agent:z,etag:Y}=await e.getAgent(F.agent_id),se=await _(F.agent_id).catch(()=>y);u(z),g(Y),x(se),z.revision!==S?(N(z.revision),E(Q=>Q+1),j(U==="Make current"?null:`${U} done. This agent changed since you opened it: the form now shows its current revision.`)):j(null)}catch(z){j(`${U} done. The page could not be refreshed: ${Ea(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(sn,{label:"Edit agent",prompt:Wo(location.origin,d.agent_id,!1,es(d.definition).runtime)}),t.jsx("a",{href:dn(d.agent_id),className:"block text-body underline underline-offset-2",children:"Back to agent"})]}):t.jsx(PF,{agent:d,revisions:y,caps:{...n,computers:O},providerChoices:s,permissionGates:r,mcpServers:D,serverToolSettings:A,onRetryMcp:H,...o?{focusTool:o,step:"tools"}:{},notice:b,validate:e.validateWorkflow,onBack:()=>c("#/agents"),onReload:()=>{P(),H()},onSave:async(U,G)=>{let F;try{if(!d){const Q=await e.createAgent(nM({name:U.name??"",description:U.description??"",instructions:U.instructions??"",harness:U.harness??"pi",tools:U.tools??[],approvals:U.approvals,tool_settings:U.tool_settings,thinking:U.thinking,model:U.model,computer:U.computer,learning:U.learning,max_cost_usd:U.max_cost_usd,decisionProvider:n.decisionProvider}));return $.current&&c(dn(Q.agent_id,Q.kind==="workflow"?"workflow":void 0)),null}const z=gd(d,U,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,...se}=z;F=await e.updateDefinition(d.agent_id,se,f)}catch(z){return Ea(z)}return u(F.agent),g(F.etag),N(F.agent.revision),e.getAgent(F.agent.agent_id).then(z=>u(Y=>Y&&Y.revision===z.agent.revision?{...Y,tools:z.agent.tools}:Y)).catch(()=>{}),_(F.agent.agent_id).then(x).catch(()=>j("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:U=>{d&&K("Make current",()=>e.setCurrent(d.agent_id,U))},onArchive:U=>{d&&K(U?"Archive":"Unarchive",()=>U?e.archiveAgent(d.agent_id):e.unarchiveAgent(d.agent_id))}},`${(d==null?void 0:d.agent_id)??"new"}:${k}`)}function 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 WF={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},HF={tool:1,model:1,mcp:2,computer:2,source:2};function Qf(e,n){const s=e.split(":"),r=HF[s[0]];return(r===void 0?"":s.slice(r).join(":"))||n||s.slice(1).join(":")}const BF="Sign in with your password to change secrets.",GF="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",qF="Open the console from the server's link to change secrets.",ei={sign_in:BF,no_accounts:GF,token:qF},UC=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,KF=e=>{var n;return((n=UC(e))==null?void 0:n.secrets_writable)===!0};function VF(e){const n=UC(e);return n!=null&&n.secrets_reason?n.secrets_reason:(n==null?void 0:n.accounts)===!1?"no_accounts":"sign_in"}function YF(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:KF(o),whyNot:VF(o)})},()=>{}),()=>{r=!1}},[e]),n}const QF=2e3,bx=e=>e instanceof ze||e instanceof Error?e.message:String(e),db=({children:e="Manage usage"})=>t.jsx("a",{href:pI,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:e});function JF(){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(db,{})," in your ChatGPT settings."]}),t.jsx("p",{children:xI})]})}function yx({v2:e,view:n,onView:s,writable:r=!0,whyNot:o="sign_in",beside:i}){const[c,d]=p.useState(n),[u,f]=p.useState(null),[g,y]=p.useState(!1),[x,h]=p.useState(!1),[v,b]=p.useState(!1),j=p.useRef(null),k=p.useRef(0);p.useEffect(()=>{d(n)},[n]);const E=M=>{d(M),s==null||s(M)},S=c.state==="pending";p.useEffect(()=>{if(!S)return;let M=!1;const R=()=>{if(M||document.visibilityState!=="visible")return;M=!0;const D=++k.current;e.chatGPT().then(W=>{const q=Wf(W);D===k.current&&q&&q.state!=="pending"&&E(q)},()=>{}).finally(()=>{M=!1})},A=setInterval(R,QF),L=()=>{document.visibilityState==="visible"&&R()};return document.addEventListener("visibilitychange",L),()=>{clearInterval(A),document.removeEventListener("visibilitychange",L)}},[e,S]);const N=async()=>{f(null),y(!0);const M=window.open("","_blank");k.current++;try{const R=await e.startChatGPT();M&&(M.opener=null,M.location.href=R.authorize_url),E({state:"pending",authorize_url:R.authorize_url,expires_at:R.expires_at})}catch(R){M==null||M.close(),f(bx(R))}finally{y(!1)}},$=async M=>{var L;M.preventDefault();const R=(L=j.current)==null?void 0:L.value.trim();if(!R)return;f(null),y(!0),h(!0),k.current++;const A=D=>{j.current&&(j.current.value=""),b(!1),E(D)};try{A(await e.finishChatGPT(R))}catch(D){const W=await e.chatGPT().then(Wf,()=>null);(W==null?void 0:W.state)==="signed_in"?A(W):f(bx(D))}finally{y(!1),h(!1)}},_=u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u});if(c.state==="signed_in")return t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-body font-semibold",children:NI(c)}),t.jsx(JF,{})]});if(!r)return t.jsx("p",{className:"text-body",role:"status",children:ei[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 P=dr(c.authorize_url),O=c.expires_at;return t.jsxs("form",{onSubmit:M=>void $(M),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:gI}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[P&&t.jsxs(t.Fragment,{children:[t.jsx("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Open the sign-in page"})," (a new tab)"]}),P&&O&&" · ",O&&`Waits until ${ud(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 M;return b(!!((M=j.current)!=null&&M.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 XF={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 ZF({v2:e,writable:n,whyNot:s,onChange:r}){var b;const[o,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,y]=p.useState(null);if(p.useEffect(()=>{let j=!0;return e.chatGPT().then(k=>{j&&i(Wf(k))},()=>{j&&i(null)}),()=>{j=!1}},[e]),!o)return null;const x=async()=>{y(null);let j;try{j=await e.signOutChatGPT()}catch(k){y(bx(k));return}d(!1),i({state:"signed_out"}),f(typeof j=="object"&&(j==null?void 0:j.revoked)===!1?{words:j.message||bI,settings:!0}:{words:vI}),r==null||r()},h=j=>{i(j),j.state!=="pending"&&f(null),j.state==="signed_in"&&(r==null||r())},v=XF[o.state];return t.jsxs("li",{"aria-label":"ChatGPT plan",className:"border-b p-4 last:border-b-0",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:"ChatGPT plan"}),t.jsx(Ne,{tone:v.tone,children:v.words})]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:H2}),t.jsxs("div",{className:"mt-3 space-y-3",children:[o.state==="expired"&&t.jsx("p",{className:"text-body text-warning-text",children:yI}),o.state==="signed_in"&&((b=o.models)!=null&&b.length)?t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Models: ",o.models.join(" · ")]}):null,t.jsx(yx,{v2:e,view:o,onView:h,writable:n,whyNot:s}),o.state==="signed_in"&&n&&!c&&t.jsx(B,{size:"sm",onClick:()=>{d(!0),y(null)},children:"Sign out"}),c&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Sign out of ChatGPT on this server? Codex and pi agents then need a key to run here."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void 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(db,{children:"ChatGPT settings"})]})]})]})]})}function e6(e){var n,s;return(n=e.needs)!=null&&n.includes("chatgpt")?{tone:"warning",text:"runs after Continue with ChatGPT"}:(s=e.needs)!=null&&s.includes("key")?{tone:"warning",text:"needs a key"}:e.available?{tone:"success",text:"ready"}:{tone:"warning",text:"not here"}}function WC({harnesses:e,routePrefix:n}){return e.length?t.jsxs("section",{"aria-label":"What runs here",children:[t.jsx("h2",{className:"caps mb-2 text-small font-semibold text-muted-foreground",children:"What runs here"}),t.jsx("ul",{className:"border",children:e.map(s=>{var o;const r=e6(s);return t.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-4 py-2.5 last:border-b-0",children:[t.jsx("span",{className:"font-mono text-body font-semibold",children:Ff(s.id)}),t.jsx(Ne,{tone:r.tone,children:r.text}),s.available&&!((o=s.needs)!=null&&o.length)?s.default_model&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:ul(s.default_model,n).text}):s.reason&&t.jsx("span",{className:"text-small text-muted-foreground",children:s.reason})]},s.id)})})]}):null}const sf=(e,n,s)=>{if(!/^\d{1,2}$/.test(e))return null;const r=Number(e);return r>=n&&r<=s?r:null};function t6(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const[s,r,o,i,c]=n,d=sf(s,0,59);if(d===null||i!=="*")return null;if(r==="*")return o==="*"&&c==="*"?{kind:"hourly",minute:d}:null;const u=sf(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=sf(c,0,6);return g===null?null:{kind:"weekly",day:g,at:f}}if(c==="*"){const g=sf(o,1,31);return g===null?null:{kind:"monthly",date:g,at:f}}return null}function n6(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 s6(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 v0=e=>String(e).padStart(2,"0"),r6=e=>`${v0(e.hour)}:${v0(e.minute)}`;function o6(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 Sg={exports:{}},b0;function a6(){return b0||(b0=1,(function(e,n){(function(r,o){e.exports=o()})(globalThis,()=>(()=>{var s={6949(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.CronParser=void 0;var f=u(9515),g=(function(){function y(x,h,v){h===void 0&&(h=!0),v===void 0&&(v=!1),this.expression=x,this.dayOfWeekStartIndexZero=h,this.monthStartIndexZero=v}return y.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 b=this.parseSpecial(this.expression);h=this.extractParts(b)}else h=this.extractParts(this.expression);return this.normalize(h),this.validate(h),h},y.prototype.parseSpecial=function(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},y.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 b=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!==""});b.length===0&&b.push("*"),b.sort(function(k,E){return k!==null&&E!==null?k-E:0}),h[v]=b.map(function(k){return k!==null?k.toString():""}).join(",")}if(h.length<5)throw new Error("Expression has only ".concat(h.length," part").concat(h.length==1?"":"s",". At least 5 parts are required."));if(h.length==5)h.unshift(""),h.push("");else if(h.length==6){var j=/\d{4}$/.test(h[5])||h[4]=="?"||h[2]=="?";j?h.unshift(""):h.push("")}else if(h.length>7)throw new Error("Expression has ".concat(h.length," parts; too many!"));return h},y.prototype.normalize=function(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 P=_.replace(/\D/,""),O=P;return h.dayOfWeekStartIndexZero?P=="7"&&(O="0"):O=(parseInt(P)-1).toString(),_.replace(P,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 b={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var j in b)x[5]=x[5].replace(new RegExp(j,"gi"),b[j].toString());x[4]=x[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,function(_){var P=_.replace(/\D/,""),O=P;return h.monthStartIndexZero&&(O=(parseInt(P)+1).toString()),_.replace(P,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])}}},y.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)},y.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)},y.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(),"'"))},y})();d.CronParser=g},8333(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.ExpressionDescriptor=void 0;var f=u(1823),g=u(6949),y=(function(){function 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 b=Object.keys(x.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(b,"'.")),this.options.locale=b}this.i18n=x.locales[this.options.locale],v.use24HourTimeFormat===void 0&&(v.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return x.toString=function(h,v){var b=v===void 0?{}:v,j=b.throwExceptionOnParseError,k=j===void 0?!0:j,E=b.verbose,S=E===void 0?!1:E,N=b.dayOfWeekStartIndexZero,$=N===void 0?!0:N,_=b.monthStartIndexZero,P=_===void 0?!1:_,O=b.use24HourTimeFormat,M=b.trimHoursLeadingZero,R=M===void 0?!1:M,A=b.locale,L=A===void 0?null:A,D=b.logicalAndDayFields,W=D===void 0?!1:D,q={throwExceptionOnParseError:k,verbose:S,dayOfWeekStartIndexZero:$,monthStartIndexZero:P,use24HourTimeFormat:O,trimHoursLeadingZero:R,locale:L,logicalAndDayFields:W};q.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var H=new x(h,q);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,b="";try{var j=new g.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=j.parse(),this.expressionParts[0]==="@reboot")return((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();b+=k+E+N+S+$,b=this.transformVerbosity(b,!!this.options.verbose),b=b.charAt(0).toLocaleUpperCase()+b.substr(1)}catch(_){if(!this.options.throwExceptionOnParseError)b=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(_)}return b},x.prototype.getTimeOfDayDescription=function(){var h=this.expressionParts[0],v=this.expressionParts[1],b=this.expressionParts[2],j="";if(!f.StringUtilities.containsAny(v,x.specialCharacters)&&!f.StringUtilities.containsAny(b,x.specialCharacters)&&!f.StringUtilities.containsAny(h,x.specialCharacters))j+=this.i18n.atSpace()+this.formatTime(b,v,h);else if(!h&&v.indexOf("-")>-1&&!(v.indexOf(",")>-1)&&!(v.indexOf("/")>-1)&&!f.StringUtilities.containsAny(b,x.specialCharacters)){var k=v.split("-");j+=f.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(b,k[0],""),this.formatTime(b,k[1],""))}else if(!h&&b.indexOf(",")>-1&&b.indexOf("-")==-1&&b.indexOf("/")==-1&&!f.StringUtilities.containsAny(v,x.specialCharacters)){var E=b.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(b){return b},function(b){return f.StringUtilities.format(h.i18n.everyX0Seconds(b),b)},function(b){return h.i18n.secondsX0ThroughX1PastTheMinute()},function(b){return b=="0"?"":parseInt(b)<20?h.i18n.atX0SecondsPastTheMinute(b):h.i18n.atX0SecondsPastTheMinuteGt20()||h.i18n.atX0SecondsPastTheMinute(b)},{min:0,max:59});return v},x.prototype.getMinutesDescription=function(){var h=this,v=this.expressionParts[0],b=this.expressionParts[2],j=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(k){return k},function(k){return f.StringUtilities.format(h.i18n.everyX0Minutes(k),k)},function(k){return h.i18n.minutesX0ThroughX1PastTheHour()},function(k){var E,S;try{return k=="0"&&b.indexOf("/")==-1&&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],b=0,j=[];v.split("/")[0].split(",").forEach(function(S){var N=S.split("-");N.length===2&&j.push({value:N[1],index:b+1}),b+=N.length});var k=0,E=this.getSegmentDescription(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(),b=null;return this.expressionParts[5]=="*"?b="":b=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(j,k){var E=j;j.indexOf("#")>-1?E=j.substring(0,j.indexOf("#")):j.indexOf("L")>-1&&(E=E.replace("L",""));var S=parseInt(E),N=h.i18n.daysOfTheWeekInCase?h.i18n.daysOfTheWeekInCase(k)[S]:v[S];if(j.indexOf("#")>-1){var $=null,_=j.substring(j.indexOf("#")+1),P=j.substring(0,j.indexOf("#"));switch(_){case"1":$=h.i18n.first(P);break;case"2":$=h.i18n.second(P);break;case"3":$=h.i18n.third(P);break;case"4":$=h.i18n.fourth(P);break;case"5":$=h.i18n.fifth(P);break}N=$+" "+N}return N},function(j){return parseInt(j)==1?"":f.StringUtilities.format(h.i18n.commaEveryX0DaysOfTheWeek(j),j)},function(j){var k=j.substring(0,j.indexOf("-")),E=h.expressionParts[3]!="*";return E?h.i18n.commaAndX0ThroughX1(k):h.i18n.commaX0ThroughX1(k)},function(j){var k=null;if(j.indexOf("#")>-1){var E=j.substring(j.indexOf("#")+1),S=j.substring(0,j.indexOf("#"));k=h.i18n.commaOnThe(E,S).trim()+h.i18n.spaceX0OfTheMonth()}else if(j.indexOf("L")>-1)k=h.i18n.commaOnTheLastX0OfTheMonth(j.replace("L",""));else{var N=h.expressionParts[3]!="*";N?h.options.logicalAndDayFields?k=h.i18n.commaOnlyOnX0(j):k=h.i18n.commaAndOnX0():k=h.i18n.commaOnlyOnX0(j)}return k}),b},x.prototype.getMonthDescription=function(){var h=this,v=this.i18n.monthsOfTheYear(),b=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 b},x.prototype.getDayOfMonthDescription=function(){var h=this,v,b,j,k,E=null,S=this.expressionParts[3];switch(S){case"L":E=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":E=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var N=S.match(/^(?:(\d{1,2})W|W(\d{1,2}))(?:([+-])(\d{1,2}))?$/);if(N){var $=parseInt(N[1]||N[2]),_=$==1?this.i18n.firstWeekday():f.StringUtilities.format(this.i18n.weekdayNearestDayX0(),$.toString()),P=N[4];P?N[3]=="-"?E=f.StringUtilities.format(((b=(v=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||b===void 0?void 0:b.call(v,P))||", %s days before the %s of the month",P,_):E=f.StringUtilities.format(((k=(j=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||k===void 0?void 0:k.call(j,P))||", %s days after the %s of the month",P,_):E=f.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),_);break}else{var O=S.match(/L-(\d{1,2})/);if(O){var M=O[1];E=f.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(M),M);break}else{if(S=="*"&&this.expressionParts[5]!="*")return"";E=this.getSegmentDescription(S,this.i18n.commaEveryDay(),function(R){return R=="L"?h.i18n.lastDay():h.i18n.dayX0?f.StringUtilities.format(h.i18n.dayX0(),R):R},function(R){return R=="1"?h.i18n.commaEveryDay():h.i18n.commaEveryX0Days(R)},function(R){return h.i18n.commaBetweenDayX0AndX1OfTheMonth(R)},function(R){return h.i18n.commaOnDayX0OfTheMonth(R)})}break}}return E},x.prototype.getYearDescription=function(){var h=this,v=this.getSegmentDescription(this.expressionParts[6],"",function(b){return/^\d+$/.test(b)?new Date(parseInt(b),1).getFullYear().toString():b},function(b){return f.StringUtilities.format(h.i18n.commaEveryX0Years(b),b)},function(b){return h.i18n.commaYearX0ThroughYearX1()||h.i18n.commaX0ThroughX1()},function(b){return h.i18n.commaOnlyInYearX0?h.i18n.commaOnlyInYearX0():h.i18n.commaOnlyInX0()});return v},x.prototype.getSegmentDescription=function(h,v,b,j,k,E,S){var N=null,$=h.indexOf("/")>-1,_=h.indexOf("-")>-1,P=h.indexOf(",")>-1;if(!h)N="";else if(h==="*")N=v;else if(!$&&!_&&!P)N=f.StringUtilities.format(E(h),b(h));else if(P){for(var O=h.split(","),M="",R=this.i18n.spaceAnd(),A=0;A<O.length;A++)if(A>0&&O.length>2&&(M+=",",A<O.length-1&&(M+=" ")),A>0&&O.length>1&&(A==O.length-1||O.length==2)&&(M+=R==","&&O.length>2?" ":"".concat(R," ")),O[A].indexOf("/")>-1||O[A].indexOf("-")>-1){var L=O[A].indexOf("-")>-1&&O[A].indexOf("/")==-1,D=this.getSegmentDescription(O[A],v,b,j,L?this.i18n.commaX0ThroughX1:k,E);L?D=D.replace(", ",""):A>0&&D.startsWith(", ")&&(D=D.substring(2)),M+=D}else if(!$)M+=b(O[A]);else{var W=this.getSegmentDescription(O[A],v,b,j,k,E);A>0&&W&&W.startsWith(", ")&&(W=W.substring(2)),M+=W}$?N=M:N=f.StringUtilities.format(E(h),M)}else if($){var O=h.split("/");if(N=f.StringUtilities.format(j(O[1]),O[1]),O[0].indexOf("-")>-1){var q=this.generateRangeSegmentDescription(O[0],k,b);q.indexOf(", ")!=0&&(N+=", "),N+=q}else if(O[0].indexOf("*")==-1){var H=f.StringUtilities.format(E(O[0]),b(O[0]));H=H.replace(", ",""),N+=f.StringUtilities.format(this.i18n.commaStartingX0(),H)}N+=this.getWrappingIncrementDescription(h,S,v,b,j,k,E)}else _&&(N=this.generateRangeSegmentDescription(h,k,b));return N},x.prototype.getWrappingIncrementDescription=function(h,v,b,j,k,E,S){if(!this.options.verbose||!v)return"";var N=h.split("/"),$=N[0],_=N[1],P=parseInt(_),O=v.max-v.min+1,M=$==="*",R=Number.isInteger(P)&&P>1,A=R&&O%P===0;if(!M||!R||A)return"";for(var L=[],D=v.min;D<=v.max;D+=P)L.push(D);if(L.length<2)return"";var W=this.getSegmentDescription(L.join(","),b,j,k,E,S);return W?", ".concat(W):""},x.prototype.generateRangeSegmentDescription=function(h,v,b){var j="",k=h.split("-"),E=b(k[0],1),S=b(k[1],2),N=v(h);return j+=f.StringUtilities.format(N,E,S),j},x.prototype.formatTime=function(h,v,b){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 _="";b&&(_=":".concat(("00"+b).substring(b.length)));var P=E.toString(),O=("00"+P).substring(P.length),M=S.toString(),R=("00"+M).substring(M.length),A=this.options.trimHoursLeadingZero?P:O;return"".concat($?N:"").concat(A,":").concat(R).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 b=0,j=Object.entries(this.i18n.conciseVerbosityReplacements());b<j.length;b++){var k=j[b],E=k[0],S=k[1];h=h.replace(new RegExp(E,"g"),S)}return h},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=y},3747(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.enLocaleLoader=void 0;var f=u(9486),g=(function(){function y(){}return y.prototype.load=function(x){x.en=new f.en},y})();d.enLocaleLoader=g},9486(c,d){Object.defineProperty(d,"__esModule",{value:!0}),d.en=void 0;var u=function(g){return Number(g)===1},f=(function(){function g(){}return g.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},g.prototype.atX0MinutesPastTheHourGt20=function(){return null},g.prototype.commaMonthX0ThroughMonthX1=function(){return null},g.prototype.commaYearX0ThroughYearX1=function(){return null},g.prototype.use24HourTimeFormatByDefault=function(){return!1},g.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},g.prototype.everyMinute=function(){return"every minute"},g.prototype.everyHour=function(){return"every hour"},g.prototype.atSpace=function(){return"At "},g.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},g.prototype.at=function(){return"At"},g.prototype.spaceAnd=function(){return" and"},g.prototype.everySecond=function(){return"every second"},g.prototype.everyX0Seconds=function(y){return u(y)?"every %s second":"every %s seconds"},g.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},g.prototype.atX0SecondsPastTheMinute=function(y){return u(y)?"at %s second past the minute":"at %s seconds past the minute"},g.prototype.everyX0Minutes=function(y){return u(y)?"every %s minute":"every %s minutes"},g.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},g.prototype.atX0MinutesPastTheHour=function(y){return u(y)?"at %s minute past the hour":"at %s minutes past the hour"},g.prototype.everyX0Hours=function(y){return u(y)?"every %s hour":"every %s hours"},g.prototype.betweenX0AndX1=function(){return"between %s and %s"},g.prototype.atX0=function(){return"at %s"},g.prototype.commaEveryDay=function(){return", every day"},g.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},g.prototype.commaX0ThroughX1=function(){return", %s through %s"},g.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},g.prototype.first=function(){return"first"},g.prototype.second=function(){return"second"},g.prototype.third=function(){return"third"},g.prototype.fourth=function(){return"fourth"},g.prototype.fifth=function(){return"fifth"},g.prototype.commaOnThe=function(){return", on the "},g.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},g.prototype.lastDay=function(){return"the last day"},g.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},g.prototype.commaOnlyOnX0=function(){return", only on %s"},g.prototype.commaAndOnX0=function(){return", and on %s"},g.prototype.commaEveryX0Months=function(){return", every %s months"},g.prototype.commaOnlyInX0=function(){return", only in %s"},g.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},g.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},g.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(y){return u(y)?", %s day before the last day of the month":", %s days before the last day of the month"},g.prototype.firstWeekday=function(){return"first weekday"},g.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},g.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},g.prototype.commaDaysBeforeTheX0OfTheMonth=function(y){return u(y)?", %s day before the %s of the month":", %s days before the %s of the month"},g.prototype.commaDaysAfterTheX0OfTheMonth=function(y){return u(y)?", %s day after the %s of the month":", %s days after the %s of the month"},g.prototype.commaEveryX0Days=function(){return", every %s days in a month"},g.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},g.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},g.prototype.commaEveryHour=function(){return", every hour"},g.prototype.commaEveryX0Years=function(y){return u(y)?", every %s year":", every %s years"},g.prototype.commaStartingX0=function(){return", starting %s"},g.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},g.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},g.prototype.atReboot=function(){return"Run once, at startup"},g.prototype.onTheHour=function(){return"on the hour"},g})();d.en=f},9515(c,d){Object.defineProperty(d,"__esModule",{value:!0});function u(y,x){if(!y)throw new Error(x)}function f(y){var x=[];if(!isNaN(parseInt(y,10))){x.push(parseInt(y,10));var h=y.match(/^\d+-(-?\d+)/);h&&x.push(parseInt(h[1],10))}return x}var g=(function(){function y(){}return y.stepRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++){var b=h[v].split("/")[1];u(b===void 0||!/^0+$/.test(b),"step value must be greater than 0")}},y.secondRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var b=0,j=f(h[v]);b<j.length;b++){var k=j[b];u(k>=0&&k<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var b=0,j=f(h[v]);b<j.length;b++){var k=j[b];u(k>=0&&k<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var b=0,j=f(h[v]);b<j.length;b++){var k=j[b];u(k>=0&&k<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var b=0,j=f(h[v]);b<j.length;b++){var k=j[b];u(k>=1&&k<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(x,h){for(var v=x.split(","),b=0;b<v.length;b++)for(var j=0,k=f(v[b]);j<k.length;j++){var E=k[j];u(E>=1&&E<=12,h?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(x,h){for(var v=x.split(","),b=0;b<v.length;b++){if(v[b].indexOf("#")>-1){var j=v[b].substring(v[b].indexOf("#")+1);u(/^[1-5]$/.test(j),"DOW nth weekday must be >= 1 and <= 5")}for(var k=0,E=f(v[b]);k<E.length;k++){var S=E[k];u(S>=0&&S<=6,h?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}}},y})();d.default=g},1823(c,d){Object.defineProperty(d,"__esModule",{value:!0}),d.StringUtilities=void 0;var u=(function(){function f(){}return f.format=function(g){for(var y=[],x=1;x<arguments.length;x++)y[x-1]=arguments[x];return g.replace(/%s/g,function(h){return y.shift()})},f.containsAny=function(g,y){return y.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})())})(Sg)),Sg.exports}var i6=a6();const l6=jN(i6),Cd={rules:20,conditions:20,list:20,pointer:512,text:200,value:1024},Sn=Cd,HC={in:"is one of",prefix:"starts with",exists:"exists",missing:"is missing"},c6=Object.keys(HC);let d6=0;const Jm=()=>`r${++d6}`,u6=()=>({key:Jm(),pointer:"",op:"in",value:""}),BC=()=>({key:Jm(),event:"",actions:"",where:[]});function GC(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)&&GC(e)===e?e:JSON.stringify(e)}const f6=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)}`,Do=(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(f6).join(" and ")}`:""}`};function KC(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 VC=e=>({key:Jm(),...KC(e),was:e}),YC=e=>{if(!e.was)return!1;const n=KC(e.was);return n.pointer===e.pointer&&n.op===e.op&&n.value===e.value},QC=e=>(e??[]).join(", "),Jf=e=>({key:Jm(),event:e.event,actions:QC(e.actions),where:(e.where??[]).map(VC),was:e}),m6=(e,n)=>e.length===n.length&&e.every((s,r)=>s===n[r]),h6=e=>e.split(/[\s,]+/).filter(Boolean),y0=/^[!-~]+$/,Oc=e=>[...e].length,p6=/^(\/([^~]|~[01])*)?$/;function g6(e,n,s){return e.length>Sn.conditions&&(s[`${n}.where`]=`At most ${Sn.conditions} conditions a rule.`),e.map((r,o)=>{if(YC(r))return r.was;const i=`${n}.where[${o}]`,c=r.pointer;if(c?c.startsWith("/")?p6.test(c)?Oc(c)>Sn.pointer&&(s[`${i}.pointer`]=`At most ${Sn.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?Oc(u)>Sn.text&&(s[`${i}.prefix`]=`At most ${Sn.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(GC);return d.length?d.length>Sn.list?s[`${i}.in`]=`At most ${Sn.list} values.`:d.some(u=>Oc(JSON.stringify(u))>Sn.value)&&(s[`${i}.in`]=`Each value is at most ${Sn.value} characters.`):s[`${i}.in`]="Give at least one value, one a line.",{pointer:c,in:d}})}function x6(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)&&(!y0.test(i)||Oc(i)>Sn.text)&&(s[`${r}.event`]=`An event's name has no spaces: printable characters only, at most ${Sn.text}.`):s[`${r}.event`]="Name the event.";const c=o&&(typeof e.actions=="string"?e.actions===QC(o.actions):m6(e.actions,o.actions??[])),d=c?[...o.actions??[]]:typeof e.actions=="string"?h6(e.actions):e.actions;if(o&&c&&i===o.event&&e.where.length===(((g=o.where)==null?void 0:g.length)??0)&&e.where.every((y,x)=>YC(y)&&y.was===o.where[x]))return o;d.length>Sn.list?s[`${r}.actions`]=`At most ${Sn.list} actions.`:d.some(y=>!y0.test(y)||Oc(y)>Sn.text)&&(s[`${r}.actions`]=`An action's name is printable characters, at most ${Sn.text}.`);const f=g6(e.where,r,s);return{event:i,...d.length?{actions:d}:{},...f.length?{where:f}:{}}}function ub(e){const n={};return e.length>Sn.rules&&(n["source.accept"]=`At most ${Sn.rules} rules.`),{accept:e.map((s,r)=>x6(s,r,n)),issues:n}}function Ed(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 Wi=(e,n)=>n&&e===jx(n)?n:$6(e),El=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",JC=(e="")=>({name:"",kind:"cron",cron:"",timezone:El(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),Xm={seconds:1,minutes:60,hours:3600};function fb(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 XC(e){try{return l6.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const $a=e=>String(e).padStart(2,"0"),Xf=(e,n)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:n});function ZC(e,n){const s=i=>{var c;return((c=new Intl.DateTimeFormat(i,{timeZone:n,timeZoneName:"short"}).formatToParts(e).find(d=>d.type==="timeZoneName"))==null?void 0:c.value)??n},r=s("en-US");if(!/^GMT[+-]/.test(r))return r;const o=s("en-GB");return/^GMT[+-]/.test(o)?r:o}const w0=(e,n)=>{const s=new Date(e);return`${s.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:n}).replace(",","")}, ${Xf(s,n)} ${ZC(s,n)}`};function j0(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))?`${Xf(r,n)} today`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:n})}, ${Xf(r,n)} ${ZC(r,n)}`} has already passed.`}function Zf(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 v6(e,n,s,r){const o=new Date(Zf(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-Zf(new Date(c),n);return new Date(c)}const b6=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 y6(e,n,s,r,o){const i=XC(e),c=n!==s,d=b6(e),u=d&&`At ${$a(d.hour)}:${$a(d.minute)}`;if(d&&u&&i.startsWith(u))try{const f=r??v6(o,n,d.hour,d.minute),g=d.days?Math.floor(Zf(f,s)/864e5)-Math.floor(Zf(f,n)/864e5):0,y=g>0?" the next day":g<0?" the day before":"";return`At ${Xf(f,s)} your time${y}${c?` (${u.slice(3)} ${n})`:""}${i.slice(u.length)}`}catch{}return`${i}${c?` (${n})`:""}`}function mb(e,n,{zone:s=El(),instead:r,now:o=Date.now()}={}){const i=r?` · ${r}`:n?` · next ${w0(n,s)}`:" · no next time";return"cron"in e?`${y6(e.cron,e.timezone,s,n?new Date(n):null,new Date(o))}${i}`:"at"in e?`Once, ${w0(e.at,s)}${!r&&n&&Date.parse(n)===Date.parse(e.at)?"":i}`:`Every ${fb(e.every_s)}${i}`}const na=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,w6=e=>`${na(e)} a run`,j6=(e,n)=>typeof e=="number"?w6(e):typeof n=="number"&&n>0?`Agent's default (${na(n)})`:"Agent's default";function hb(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 pb=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",gb=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",eE=e=>e.source.kind==="github"&&e.target.kind==="start_run",Zm=[{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"}],Vc=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,xb="This server's address as this page sees it: behind a proxy, use its public address.",wx={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)"},tE=e=>{var n;return(n=e.accept)!=null&&n.length?`Only signed requests for ${e.accept.map(s=>Do(s,!1)).join(" or ")}`:"On each signed request"},k6={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"},nE=e=>`On ${e.event} from ${e.server}`,N6=e=>{var n;return(n=e.accept)!=null&&n.length?`On email in ${e.mailbox} for ${e.accept.map(s=>Do(s,!1)).join(" or ")}`:`On each email in ${e.mailbox}`},sE=e=>{var s;const n=e.urls.length===1?S6(e.urls[0]):`${e.urls.length} feeds`;return(s=e.accept)!=null&&s.length?`On items in ${n} for ${e.accept.map(r=>Do(r,!1)).join(" or ")}`:`On each new item in ${n}`},S6=e=>{try{return new URL(e).host}catch{return e}},rE=e=>`On GitHub ${e.accept.map(n=>Do(n,!1)).join(" or ")}`;function em(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 oE(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 ${ud(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const C6={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},E6=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function $6(e){if(!E6.test(e))return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toISOString().replace(/\.\d{3}Z$/,"Z")}function jx(e){const n=new Date(e);return`${n.getFullYear()}-${$a(n.getMonth()+1)}-${$a(n.getDate())}T${$a(n.getHours())}:${$a(n.getMinutes())}${n.getSeconds()?`:${$a(n.getSeconds())}`:""}`}const k0=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function vb(e){const n=fb(e);return/^\d/.test(n)?`At least ${n}.`:`At least ${n==="hour"?"an":"a"} ${n}.`}const Yc="A number is needed.",Qc=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function N0(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=Wi(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=Qc(e.every);e.every.trim()?d===void 0&&(s["source.every_s"]=Yc):s["source.every_s"]="A number is needed.";const u=e.startAt?Wi(e.startAt,(c=e.read)==null?void 0:c.startAt):null;r={kind:"schedule",every_s:Math.round((d??0)*Xm[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=Qc(e.maxCost);return e.maxCost.trim()?o===void 0&&(s["target.max_cost_usd"]=Yc):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 _6=()=>({name:"",signature:"standard",accept:[],agentId:"",content:"",maxCost:""});function aE(e,n){const{accept:s,issues:r}=ub(n);return{source:{kind:"webhook",...e.signature!==void 0?{signature:e.signature}:{},...s.length?{accept:s}:{}},issues:r}}function T6(e,n=!1){const{source:s,issues:r}=aE({signature:e.signature},e.accept);return th(e,s,r,n,"a webhook")}const R6=()=>({name:"",events:["pull_request:opened"],where:{},other:[],agentId:"",content:"",maxCost:""}),iE=[...new Set(Zm.map(e=>e.event))],A6=(e,n)=>e.length===n.length&&e.every(s=>n.includes(s));function eh(e){var i;const s=[...iE.flatMap(c=>{var f;const d=Zm.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&&A6(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 lE(e){const{accept:n,issues:s}=ub(eh(e));return n.length||(s["source.accept"]="Pick at least one event."),{source:{kind:"github",accept:n},issues:s}}function O6(e){var s;const n={events:[],where:{},other:[],read:{order:[],rules:{}}};for(const r of e){const o=Zm.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=Jf(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(VC),n.read.order.push(`event:${r.event}`),n.read.rules[r.event]=r}return n}const bb=e=>e.source.kind==="composio"&&e.target.kind==="start_run";function P6(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 L6(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=Qc(i);d===void 0||o.type==="integer"&&!Number.isInteger(d)?s[c]=o.type==="integer"?"A whole number is needed.":Yc: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 M6=()=>({name:"",server:"",event:"",config:{},where:[],agentId:"",content:"",maxCost:""});function yb(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 ub([...o,...s])}function I6(e,n,s=[],r){const{accept:o,...i}=e,{accept:c,issues:d}=yb(e.event,n,s,r);return{source:{...i,...c.length?{accept:c}:{}},issues:d}}function z6(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?L6(n,e.config,r):{},{accept:i,issues:c}=yb(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 th(e,d,r,s,"a trigger")}const cE=e=>e.source.kind==="feed"&&e.target.kind==="start_run",kx=20,dE=900,D6="item",uE=()=>({name:"",urls:"",every:"15",everyUnit:"minutes",items:"",id:"",where:[],others:[],agentId:"",content:"",maxCost:""});function F6(e){const n=e.source,s=n.every_s??dE,r=s%3600===0?"hours":s%60===0?"minutes":"seconds",o=(n.accept??[]).map(Jf),i=o[0]&&!o[0].actions.trim()?o[0]:null;return{...uE(),urls:n.urls.join(`
659
- `),every:String(s/Xm[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 U6=e=>{try{return new URL(e)}catch{return null}};function fE(e){const n=e.split(/\r\n|\r|\n/).map(r=>r.trim()).filter(Boolean),s={};return n.length?n.length>kx?s["source.urls"]=`${kx} feeds at most: this has ${n.length}.`:n.forEach((r,o)=>{const i=U6(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 mE(e,n){var f,g,y,x,h;const{urls:s,issues:r}=fE(e.urls),o=Qc(e.every),i=Math.round((o??0)*Xm[e.everyUnit]);o===void 0?r["source.every_s"]=Yc:n&&i<n&&(r["source.every_s"]=vb(n));const c=v=>{var j;const b=e[v];return b||((j=e.read)==null?void 0:j[v])===""?{[v]:b}:{}},{accept:d,issues:u}=yb(D6,e.where,e.others,(g=(f=e.read)==null?void 0:f.accept)!=null&&g[0]&&!((y=e.read.accept[0].actions)!=null&&y.length)?e.read.accept[0]:void 0);return Object.assign(r,u),{source:{kind:"feed",urls:s,every_s:i,...c("items"),...c("id"),...((x=e.read)==null?void 0:x.updated)!==void 0?{updated:e.read.updated}:{},...(h=e.read)!=null&&h.fields?{fields:e.read.fields}:{},...d.length?{accept:d}:{}},issues:r}}function W6(e,n,s=!1){const{source:r,issues:o}=mE(e,n);return th(e,r,o,s,"a feed trigger")}function H6(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",...Ed(n)])}function B6(e,n=!1){const{source:s,issues:r}=lE(e);return th(e,s,r,n,"a GitHub trigger")}function th(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=Qc(e.maxCost);return e.maxCost.trim()?i===void 0&&(s["target.max_cost_usd"]=Yc):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 G6(e){const n=e.source,s="cron"in n?n.timezone:El(),r={...JC(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:jx(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/Xm[o]),everyUnit:o,startAt:jx(n.start_at),read:{startAt:n.start_at}}}const Jc=(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=>Jc(e[o],n[o]))};function S0(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&&!Jc(s,e.source)?{source:s}:{},...r&&!Jc(r,e.target)?{target:r}:{}}}const q6=["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 ze))return{fields:{},rest:[e instanceof Error?e.message:String(e)]};if(e.status!==422||!((r=e.fields)!=null&&r.length))return{fields:{},rest:[`${e.code}: ${e.message}`]};const n={},s=[];for(const o of e.fields){const i=o.field.startsWith("target.input")?"target.input":o.field;(q6.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 K6=[{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"}],V6=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),Y6=Array.from({length:31},(e,n)=>({value:String(n+1),label:String(n+1)})),Q6=Array.from({length:60},(e,n)=>({value:String(n),label:`:${String(n).padStart(2,"0")}`}));function hE({value:e,onChange:n,label:s,name:r}){const o=t6(e),[i,c]=p.useState(()=>e.trim()!==""&&!o),d=p.useId(),u=i||e.trim()!==""&&!o,f=x=>n(n6(x)),g=x=>{if(x==="custom"){c(!0);return}c(!1),f(s6(x,o))},y=o&&"at"in o?o.at:null;return t.jsxs("div",{className:"space-y-2","data-schedule-when":!0,children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Et,{label:s,className:"min-w-56 flex-1",value:u?"custom":(o==null?void 0:o.kind)??"",onChange:g,placeholder:"Pick when it runs",options:K6}),!u&&(o==null?void 0:o.kind)==="weekly"&&t.jsx(Et,{id:`${d}-day`,label:"Day of the week",className:"w-40",value:String(o.day),onChange:x=>f({...o,day:Number(x)}),options:V6}),!u&&(o==null?void 0:o.kind)==="monthly"&&t.jsx(Et,{id:`${d}-date`,label:"Day of the month",className:"w-24",value:String(o.date),onChange:x=>f({...o,date:Number(x)}),options:Y6}),!u&&(o==null?void 0:o.kind)==="hourly"&&t.jsx(Et,{id:`${d}-minute`,label:"Minutes past the hour",className:"w-24",value:String(o.minute),onChange:x=>f({...o,minute:Number(x)}),options:Q6}),!u&&o&&y&&t.jsx(Pe,{id:`${d}-at`,type:"time","aria-label":"At",className:"w-32",value:r6(y),onChange:x=>{const h=o6(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()?XC(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const C0=Intl.supportedValuesOf,rf=typeof C0=="function"?C0("timeZone"):[],of=rf.length&&!rf.includes("UTC")?["UTC",...rf]:rf;function pE({value:e,onChange:n,label:s,name:r,id:o,className:i}){if(!of.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&&!of.includes(e)?[e,...of]:of;return t.jsx(Et,{id:o,name:r,label:s,className:i,value:e,onChange:n,placeholder:"Pick a time zone",options:c.map(d=>({value:d,label:d.replace(/_/g," ")}))})}function J6(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 X6(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 Z6(e,n,s="workflow"){if(e.from==="example")return`The ${s}'s example input. Edit it, then ${n}.`;const r=e.optional.length?` It also takes ${e.optional.join(", ")}, if you add ${e.optional.length===1?"it":"them"}.`:"";return`The ${s}'s input, its required fields empty. Fill them in, then ${n}.${r}`}function e8(e){var r,o;const n=e,s=(r=n==null?void 0:n.input)!=null&&r.schemaId?(o=n.schemas)==null?void 0:o[n.input.schemaId]:void 0;return s?gE(s,(n==null?void 0:n.schemas)??{}):null}function gE(e,n={}){var u;const s=X6(e,n),r=s(e),o=Object.entries(r.properties??{}).map(([f,g])=>{const y=s(g);return{name:f,...y!=null&&y.description?{note:y.description}:{}}}),i=((u=r.examples)==null?void 0:u[0])??r.default;if(i!==void 0)return{text:JSON.stringify(i,null,2),from:"example",fields:o,optional:[]};const c=(f,g=0)=>{var h,v;const y=s(f);if(!y||g>4)return null;if((h=y.examples)!=null&&h.length)return y.examples[0];if(y.default!==void 0)return y.default;if((v=y.enum)!=null&&v.length)return y.enum[0];const x=Array.isArray(y.type)?y.type[0]:y.type;return x==="object"||y.properties?Object.fromEntries(Object.entries(y.properties??{}).filter(([b])=>(y.required??[]).includes(b)).map(([b,j])=>[b,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 Cg=e=>`'${e.replace(/'/g,"'\\''")}'`;function t8(e,n,s,r){return[`curl -X POST ${Cg(`${e}/v2/agents/${n?encodeURIComponent(n):"{agent_id}"}/runs`)} \\`,' -H "Authorization: Bearer $AGENTRUN_API_KEY" \\'," -H 'Content-Type: application/json' \\",` -H ${Cg(`Idempotency-Key: ${r}`)} \\`,` -d ${Cg(JSON.stringify(s))}`].join(`
660
- `)}const n8=e=>e>=200&&e<300;async function s8(e,n,s,r){const o=await r(n,s,e.keyFor(n,s));return n8(o.status)&&e.done(),o}const Fo=(e,n={})=>(e.display_name||e.name).replace(/\$\{parameters\.([A-Za-z0-9_]+)\}/g,(s,r)=>(Object.hasOwn(n,r)?jb(n[r]).join(", "):"")||"…"),xE=e=>`#/templates/${encodeURIComponent(e)}`;function Zi(e,n){return`#/playground?${new URLSearchParams({operation:"apply-template",template:e.id,...n?{draft:JSON.stringify({template:e.id,version:e.version,...e.sha?{sha:e.sha}:{},body:n})}:{}})}`}function r8(e,n){var r,o;if(e===void 0)return{};const s={error:"This prepared template request is invalid. Open a fresh request to review its settings."};try{const i=JSON.parse(e),c=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=nh(n.parameters);if(!f)return s;const g=new Map(f),y=[];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 b=Array.isArray(h)?h.map(String).join(`
661
- `):String(h),j=rh({fields:[[x,v]],contentRequired:!1},{[x]:b})[x];if(JSON.stringify(j)!==JSON.stringify(h))return s;y.push([x,h])}return{body:{...d,parameters:Object.fromEntries(y)}}}catch{return s}}const o8=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function wb(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} (${bd[c.source]}${c.required?"":", optional"})`).join(", ")]),e.triggers.length&&r.push(["Triggers",o8(e.triggers.length,"trigger")]),(o=e.budget)!=null&&o.per_run_usd&&r.push(["Budget",`${eo(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 $d(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 a8(e){return Object.fromEntries(Object.entries(e).flatMap(([n,s])=>s.array?[]:s.type==="boolean"?typeof s.default=="boolean"?[[n,String(s.default)]]:[]:$d(s)?[]:s.format==="timezone"?[[n,El()]]:s.format==="cron"?typeof s.default=="string"?[[n,s.default]]:[]:[]))}const i8=(e,n)=>n.filter(s=>s.source===e.source&&s.toolkit===e.toolkit).map(s=>s.name).sort();function l8(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=Vv.find(r=>r.name===e.toolkit);return`#/settings/mcp?add=${n}${s?`&preset=${s.id}`:""}`}const tm=e=>e.mcp.length===0&&e.secrets.length===0,c8=e=>{const n=e.source;return typeof n=="object"&&n!==null&&"kind"in n?n.kind:void 0},E0=[{id:"email",what:"the email account",needs:e=>(e.tools??[]).some(n=>n.startsWith("email_"))||e.triggers.some(n=>c8(n)==="email"),met:async e=>(await e.emailAccount()).configured,unmet:{before:"Connect your mailbox under ",link:"Settings → Email",href:"#/settings/email",after:" first."}}],d8=(e,n)=>e.mcp.flatMap(s=>s.tools.map(r=>r.tool)).filter(s=>n.has(s)),u8=(e,n)=>e.filter(s=>s.field===n);function nm(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 f8(e){const n=$d(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 m8(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: ${vE(s).join(", ")}.`;case"bad_format":return`${r} isn't in the form its description asks for.`;default:return e.message}}const vE=e=>{var n;return(n=e.enum)!=null&&n.length?e.enum.map(String):$d(e)??[]};function bE(e,n){var c;if(e.array){const d=jb(n);return d.length?d.every(u=>bE({...e,array:!1,required:!0},u)):!e.required}if(n==="")return!e.required;const s=$d(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)||vE(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 jb=e=>(e??"").split(`
662
- `).map(n=>n.trim()).filter(n=>n!==""),yE=bE,Pa=e=>!!e&&typeof e=="object"&&!Array.isArray(e),h8=new Set(["string","number","integer","boolean"]),p8=["oneOf","anyOf","allOf","not","if","$ref","const"],Nx=e=>p8.some(n=>n in e),af=e=>typeof e=="string"?e:void 0,lf=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,g8=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0));function x8(e,n){if(!Pa(e)||Nx(e))return null;const s=e.type==="array",r=s?e.items:e;if(!Pa(r)||Nx(r)||typeof r.type!="string"||!h8.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 g8({type:r.type,...s?{array:!0}:{},required:n,title:af(e.title),description:af(e.description),examples:Array.isArray(e.examples)?e.examples:void 0,default:e.default,enum:o,pattern:af(r.pattern),format:af(r.format),minimum:lf(r.minimum),maximum:lf(r.maximum),minLength:lf(r.minLength),maxLength:lf(r.maxLength)})}function nh(e,n){const s=Pa(e)&&Pa(e.properties)?e.properties:{},r=Pa(e)&&Array.isArray(e.required)?e.required:[],o=[];for(const[i,c]of Object.entries(s)){if(i===n)continue;const d=x8(c,r.includes(i));if(!d)return null;o.push([i,d])}return o}function v8(e){if(!Pa(e))return{kind:"message"};const n=()=>({kind:"json",example:gE(e)});if(Nx(e))return n();const s=Pa(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=nh(e,"content");return o?o.length?{kind:"fields",form:{fields:o,contentRequired:r.includes("content")||!r.some(i=>i!=="content")}}:{kind:"message"}:n()}const sh=(e,n)=>n.title||e;function b8(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 y8(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=jb(n);return r.length?r.map(s):e.required?[]:void 0}return e.type==="boolean"?n==="true"||n==="false"?n==="true":e.required?!1:void 0:n===void 0||n===""?e.required&&e.type==="string"?"":void 0:s(n)}function wE(e){const n=a8(Object.fromEntries(e.fields));for(const[s,r]of e.fields){const o=r.array?null:$d(r);o&&r.default!==void 0&&o.includes(String(r.default))&&(n[s]=String(r.default))}return n}function rh(e,n){const s={};for(const[r,o]of e.fields){const i=y8(o,n[r]);i!==void 0&&(s[r]=i)}return s}const w8=(e,n,s)=>({...n.trim()?{content:n}:{},...rh(e,s)}),Sx=(e,n="input")=>e.startsWith(`${n}.`)?e.slice(n.length+1).split(".")[0]:null,jE=e=>e.type==="integer"?"a whole number":e.type==="number"?"a number":e.type==="boolean"?"true or false":"text",j8={string:"text",integer:"whole numbers",number:"numbers",boolean:"true or false"},k8=e=>e.array?`a list of ${j8[e.type]}`:jE(e);function kE(e,n,s){var o;const r=sh(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 ${jE(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(", ")}.`:m8(e,n,s,r)}const N8={date:"date",email:"email",uri:"url"};function NE({field:e,label:n,help:s,value:r,onChange:o}){const i=b8(e),c=f8(e);return t.jsxs("label",{className:"block",children:[t.jsxs("span",{className:"caps text-small font-semibold",children:[n,e.required&&t.jsx("span",{className:"text-destructive-text",children:" *"})]}),t.jsxs("span",{className:"mb-1.5 block text-small text-muted-foreground",children:[s,e.array&&t.jsxs(t.Fragment,{children:[s?" ":"","One a line."]})]}),c?t.jsx(Et,{label:n,className:"w-full",value:r,onChange:o,options:c}):e.array?t.jsx(nn,{rows:3,value:r,required:e.required,placeholder:i,onChange:d=>o(d.target.value),className:"resize-y leading-[1.6]"}):e.format==="cron"&&e.type==="string"?t.jsx(hE,{label:n,value:r,onChange:o}):e.format==="timezone"&&e.type==="string"?t.jsx(pE,{label:n,className:"w-full",value:r,onChange:o}):e.type==="boolean"?t.jsx("input",{type:"checkbox",className:"size-4 accent-primary",checked:r==="true",onChange:d=>o(d.target.checked?"true":"false")}):t.jsx(Pe,{type:e.type==="string"?N8[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 Oo({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 SE={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."},S8='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 oh({name:e,at:n,where:s,onChange:r,issues:o,label:i}){const c=(f,g)=>r(s.map((y,x)=>x===f?{...y,...g}:y)),d=(f,g)=>c(f,g==="prefix"?{op:g,value:s[f].value.split(/\r\n|\r|\n/).find(y=>y.trim())??""}:{op:g}),u=s.length>=Cd.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 y=`${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(wt,{label:"Field",className:"min-w-40 flex-1",error:Pc(o,`${y}.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(ld,{name:`${x}-op`,label:`Condition ${g+1}'s test`,value:f.op,onChange:h=>d(g,h),options:c6.map(h=>({value:h,label:HC[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(Qo,{"aria-hidden":!0})})]}),f.op==="in"&&t.jsx(wt,{label:"Values",hint:S8,error:Pc(o,`${y}.in`),children:t.jsx(nn,{name:`${x}-value`,rows:3,value:f.value,onChange:h=>c(g,{value:h.target.value}),spellCheck:!1})}),f.op==="prefix"&&t.jsx(wt,{label:"Text",hint:"Its first line, trimmed, starts with this, in any case.",error:Pc(o,`${y}.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:y}),t.jsx(ur,{issues:o,field:`${y}.exists`})]},f.key)}),t.jsxs(B,{type:"button",size:"sm",onClick:()=>r([...s,u6()]),disabled:u,children:[t.jsx(gl,{"aria-hidden":!0})," Add a condition"]})]})}function CE({name:e,rules:n,onChange:s,issues:r,indexOf:o=g=>g,room:i,eventHint:c,eventPlaceholder:d,addLabel:u="Add a rule",empty:f}){const g=(y,x)=>s(n.map((h,v)=>v===y?{...h,...x}:h));return t.jsxs("div",{className:"min-w-0 space-y-3",children:[!n.length&&f,n.map((y,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((b,j)=>j!==x)),children:[t.jsx(MN,{"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(wt,{label:"Event",hint:c,error:Pc(r,`${h}.event`),children:t.jsx(Pe,{name:`${v}-event`,value:y.event,onChange:b=>g(x,{event:b.target.value}),placeholder:d,autoComplete:"off",spellCheck:!1})}),t.jsx(wt,{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:y.actions,onChange:b=>g(x,{actions:b.target.value}),placeholder:"opened, edited",autoComplete:"off",spellCheck:!1})})]}),t.jsx(oh,{name:v,at:h,where:y.where,onChange:b=>g(x,{where:b}),issues:r,label:"Only when"})]},y.key)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>s([...n,BC()]),disabled:i<=0,children:[t.jsx(gl,{"aria-hidden":!0})," ",u]}),i<=0&&t.jsxs("span",{className:"text-small text-muted-foreground",children:[Cd.rules," rules, the most a trigger takes."]})]})]})}const Dn=e=>`#/triggers/${encodeURIComponent(e)}`,ml=e=>ht(e),C8={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function E8({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(R8,{v2:e,go:s,agentName:r,every:d*2,now:u,failuresToPause:i,noAddress:f}):n.trigger===null?n.kind==="webhook"?t.jsx(D8,{v2:e,go:s}):n.kind==="github"?t.jsx(F8,{v2:e,go:s}):n.kind==="composio"?t.jsx(U8,{v2:e,go:s,noAddress:f}):n.kind==="feed"?t.jsx(IE,{v2:e,go:s,minEvery:o}):t.jsx(AE,{v2:e,go:s,minEvery:o,now:u}):n.edit?t.jsx(I8,{v2:e,go:s,id:n.trigger,minEvery:o,now:u},n.trigger):t.jsx(M8,{v2:e,go:s,agentName:r,id:n.trigger,every:d,now:u,failuresToPause:i},n.trigger)}function EE(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 $E=e=>e?"ran"in e?`Done · ran ${ml(e.ran.nominal_at)}`:`Its time passed · ${ml(e.passed)}`:null,$8=/has already passed\.?$/;function _E({trigger:e}){return e.disabled?t.jsx(Ne,{tone:"warning",children:"Turned off"}):t.jsx(Ne,{tone:"muted",children:"Paused"})}const _8=e=>e.last_firing?`${oE(e.last_firing)}${e.last_firing.catch_up?" · caught up late":""} · ${ml(e.last_firing.nominal_at)}`:"Not fired yet",T8=e=>`${e.ok?"Checked":"Check failed"} ${ml(e.at)}: ${e.message}`,kb="App triggers need this server's public address: set AGENTRUN_PUBLIC_URL and restart.";function R8({v2:e,go:n,agentName:s,every:r,now:o,failuresToPause:i,noAddress:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,x]=p.useState(0),h=p.useRef(!1),v=p.useRef(!0);p.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const b=()=>{h.current||(h.current=!0,e.listTriggers().then(j=>{v.current&&(u(j.triggers),g(null))},j=>{v.current&&g(Ht(j,"the triggers"))}).finally(()=>{h.current=!1}))};return p.useEffect(b,[e,y]),EE(b,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(cm,{"aria-hidden":!0})," New app trigger"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-github"),children:[t.jsx(mm,{"aria-hidden":!0})," New GitHub trigger"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-webhook"),children:[t.jsx(sl,{"aria-hidden":!0})," New webhook"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-feed"),children:[t.jsx(Kx,{"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:kb}),f&&!d?t.jsx(Jt,{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(Ne,{children:O8[j.source.kind]}),!j.enabled&&!hb(j,o())&&t.jsx(_E,{trigger:j})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:TE(j),children:P8(j,s,o())}),em(j,i)&&t.jsx("p",{className:"mt-1 break-words text-small text-warning-text",children:em(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:_8(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:T8(j.last_check)})]})]},j.id))}):t.jsx(A8,{go:n,noAddress:c}):t.jsx(Un,{label:"Loading the triggers",rows:4}),d&&f&&t.jsx(Jt,{problem:f,className:"mt-4"})]})}function A8({go:e,noAddress:n}){const s=[{Icon:dm,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:sl,name:"Webhook",what:"On each signed request another system sends to its URL.",action:"New webhook",to:"#/triggers/new-webhook"},{Icon:mm,name:"GitHub",what:"On the events you pick from this server's GitHub App. Connect GitHub in Settings first.",action:"New GitHub trigger",to:"#/triggers/new-github"},{Icon:cm,name:"From an app",what:"On an event in an app a saved Composio server connects, such as a new issue in a GitHub repository. Save the server in Settings first.",action:"New app trigger",to:"#/triggers/new-composio"},{Icon:Kx,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:kb}),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 O8={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"},TE=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function P8(e,n,s){return`${e.source.kind==="schedule"?mb(e.source,e.next_at,{instead:$E(hb(e,s)),now:s}):e.source.kind==="github"?rE(e.source):e.source.kind==="composio"?nE(e.source):e.source.kind==="email"?N6(e.source):e.source.kind==="feed"?sE(e.source):tE(e.source)} · ${e.target.kind==="start_run"?n(e.target.agent_id)||e.target.agent_id:`messages run ${ea(e.target.run_id)}`}`}const L8={on:"On",off:"Off",missing:"Composio no longer has it: delete this trigger and make it again.",unknown:"Composio didn't say"};function RE(){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(An,{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 M8({v2:e,go:n,agentName:s,id:r,every:o,now:i,failuresToPause:c}){var ot,me,Me,Ze,bt;const[d,u]=p.useState(null),[f,g]=p.useState([]),[y,x]=p.useState(null),[h,v]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),[$,_]=p.useState(null),P=p.useRef(!1),[O,M]=p.useState(!1),[R,A]=p.useState(null),[L,D]=p.useState(null),[W,q]=p.useState(null),[H,K]=p.useState(0),U=p.useRef(!1),G=p.useRef(!1),F=p.useRef(0),z=()=>{G.current=!0;const oe=F.current;return Promise.all([e.getTrigger(r),e.triggerFirings(r)]).then(([Se,tt])=>{oe===F.current&&(u(Se),g(tt.firings),x(null))}).finally(()=>{G.current=!1})};p.useEffect(()=>{z().catch(oe=>x(Ht(oe,"the trigger")))},[e,r,H]),EE(()=>{!G.current&&!U.current&&W===null&&z().catch(()=>{})},o,[e,r]);const[Y,se]=p.useState(void 0),Q=d&&d.target.kind==="start_run"&&typeof d.target.max_cost_usd!="number"?d.target.agent_id:null;p.useEffect(()=>{if(!Q)return;let oe=!0;return e.getAgent(Q).then(Se=>{oe&&se(typeof Se.agent.definition.max_cost_usd=="number"?Se.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{oe=!1}},[e,Q]);const re=(d==null?void 0:d.source.kind)==="composio"?d.source.server:null;if(p.useEffect(()=>{if(!re)return;let oe=!0;return e.composioTriggers(re).then(Se=>{var tt;oe&&A(((tt=Se.triggers.find(Ae=>Ae.id===r))==null?void 0:tt.on_composio)??"unknown")},()=>{oe&&A(null)}),()=>{oe=!1}},[e,re,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(An,{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 y?t.jsx(Jt,{problem:y,onRetry:()=>K(oe=>oe+1),link:{href:"#/triggers",label:"All triggers"}}):t.jsx(Un,{label:"Loading the trigger",rows:4});const te=gb(d)?d:null,he=eE(d)?d:null,ge=bb(d)?d:null,ye=cE(d)?d:null;if(!te&&!he&&!ge&&!ye&&!pb(d))return t.jsx(RE,{});const xe=d,fe=hb(d,i(),f),De=async(oe,Se,tt)=>{j(oe),v(null);try{await Se()}catch(Ae){v(Ht(Ae,tt))}finally{j(null)}},Fe=()=>De("pause",async()=>{F.current++,D(null);const{composio:oe,...Se}=await e.updateTrigger(r,{enabled:!d.enabled});F.current++,u(Se),D((oe==null?void 0:oe.note)??null)},d.enabled?"the pause":"the resume"),Le=()=>De("delete",async()=>{const oe=await e.deleteTrigger(r);oe!=null&&oe.composio?q(oe.composio.note):n("#/triggers")},"the delete"),Ee=async()=>{if(!P.current){P.current=!0,M(!0),v(null),_(null);try{_((await e.rotateTriggerSecret(r)).signing_secret??null)}catch(oe){v(Ht(oe,"the new secret"))}finally{P.current=!1,M(!1)}}},ae=async()=>{if(!U.current){U.current=!0,j("fire"),v(null),F.current++;try{const oe=await e.fireTrigger(r,Sd());F.current++,g(Se=>[oe,...Se.filter(tt=>tt.key!==oe.key)]),await z().catch(()=>{})}catch(oe){v(Ht(oe,"the run now"))}finally{U.current=!1,j(null)}}},$e=typeof xe.target.input.content=="string"?xe.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(An,{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&&!fe&&t.jsx(_E,{trigger:d})]}),t.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:te?`Webhook · ${tE(te.source)}`:he?`GitHub · ${rE(he.source)}`:ge?`App · ${nE(ge.source)}`:ye?`Feed · ${sE(ye.source)}`:t.jsx("span",{title:TE(d),children:mb(xe.source,d.next_at,{instead:$E(fe),now:i()})})})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 self-stretch sm:self-auto",children:[!(fe&&"ran"in fe)&&t.jsx(B,{size:"sm",onClick:()=>void Fe(),disabled:b!==null,children:d.enabled?t.jsxs(t.Fragment,{children:[t.jsx(nl,{"aria-hidden":!0})," Pause"]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{"aria-hidden":!0})," Resume"]})}),t.jsxs(B,{size:"sm",onClick:()=>n(`${Dn(r)}/edit`),children:[t.jsx(Gx,{"aria-hidden":!0})," ",te||he||ge?"Edit filter":ye?"Edit feed":"Edit"]}),te&&(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:b!==null||O,children:[t.jsx(La,{"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),Le()},children:"Yes, delete"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>E(!1),children:"Keep"})]}):t.jsxs(B,{size:"sm",variant:"destructive",onClick:()=>E(!0),disabled:b!==null,children:[t.jsx(MN,{"aria-hidden":!0})," Delete"]}),t.jsxs(B,{size:"sm",variant:"solid",onClick:()=>void ae(),disabled:b==="fire",children:[t.jsx(YT,{"aria-hidden":!0})," ",b==="fire"?"Starting":"Run now"]})]})]}),em(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:[em(d,c)," ",((ot=d.disabled)==null?void 0:ot.reason)==="source_unreadable"?ye?"Edit its feeds, then Resume.":"Edit its when, then Resume.":((me=d.disabled)==null?void 0:me.reason)==="auto_paused"?fe&&"passed"in fe?"Its time has passed: edit its time first, then Resume.":fe?"":"Resume turns it on again.":""]}),h&&t.jsx(Jt,{problem:h,className:"mt-4"}),L&&t.jsx("p",{role:"status","data-composio-note":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:L}),te&&$&&t.jsx(Nb,{label:"The webhook's new secret",secret:$}),ye&&t.jsx(G8,{check:ye.last_check??null,newest:f[0]}),t.jsxs("dl",{className:"mt-5 grid grid-cols-1 gap-x-6 gap-y-3 border p-4 text-body sm:grid-cols-[max-content_minmax(0,1fr)]",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Agent"}),t.jsx("dd",{className:"min-w-0 break-words",children:t.jsx("a",{href:dn(xe.target.agent_id),className:"hover:underline",children:s(xe.target.agent_id)||xe.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(xe.target.input)}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),t.jsx("dd",{className:"font-mono",children:j6(xe.target.max_cost_usd,Y)}),te?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:Vc(te)}),t.jsx(OE,{text:Vc(te),label:"Copy URL"}),t.jsx("span",{className:"basis-full text-small text-muted-foreground",children:xb})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("dd",{children:wx[te.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:(Me=te.source.accept)!=null&&Me.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:te.source.accept.map((oe,Se)=>t.jsx("li",{children:Do(oe)},Se))}):"Every signed request"})]}):ge?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:ge.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:ge.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(ge.source.config).length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:Object.entries(ge.source.config).map(([oe,Se])=>t.jsxs("li",{children:[oe,": ",typeof Se=="string"?Se:JSON.stringify(Se)]},oe))}):"None"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(Ze=ge.source.accept)!=null&&Ze.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ge.source.accept.map((oe,Se)=>t.jsx("li",{children:Do(oe)},Se))}):"Every event of its instance"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"At Composio"}),t.jsx("dd",{className:"min-w-0 break-words",children:R?t.jsx("span",{"data-on-composio":R,className:R==="missing"?"text-warning-text":void 0,children:L8[R]}):t.jsx("span",{className:"text-muted-foreground",children:"Not read"})})]}):he?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:he.source.accept.map((oe,Se)=>t.jsx("li",{children:Do(oe)},Se))}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):ye?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:ye.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 ",fb(ye.source.every_s??dE)]}),(ye.source.items!==void 0||ye.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 ",ye.source.items?ye.source.items:"the whole document"," · Id at ",ye.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:(bt=ye.source.accept)!=null&&bt.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ye.source.accept.map((oe,Se)=>t.jsx("li",{children:Do(oe)},Se))}):"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(Ne,{tone:C8[oe.status],children:C6[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"?`${k6[oe.by]}${oe.catch_up?", caught up late":""}`:`${oE(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 ",ea(oe.run_id)]})]},oe.key))}):t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function I8({v2:e,go:n,id:s,minEvery:r,now:o}){const[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(0);return p.useEffect(()=>{e.getTrigger(s).then(c,y=>u(Ht(y,"the trigger")))},[e,s,f]),i?gb(i)||eE(i)||bb(i)?t.jsx(B8,{v2:e,go:n,trigger:i}):cE(i)?t.jsx(IE,{v2:e,go:n,trigger:i,minEvery:r}):pb(i)?t.jsx(AE,{v2:e,go:n,trigger:i,minEvery:r,now:o}):t.jsx(RE,{}):d?t.jsx(Jt,{problem:d,onRetry:()=>g(y=>y+1)}):t.jsx(Un,{label:"Loading the trigger",rows:4})}function Lt({label:e,field:n,issue:s,hint:r,children:o}){return t.jsx(wt,{className:"min-w-0",label:e,hint:r,error:s?t.jsx("span",{"data-issue":n,children:s}):void 0,children:o})}const _d=e=>e!==void 0?`${na(e)}, the agent's default`:void 0;async function Td(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 AE({v2:e,go:n,trigger:s,minEvery:r,now:o=Date.now}){var D,W,q;const[i,c]=p.useState(()=>s?G6(s):JC()),[d,u]=p.useState(null),[f,g]=p.useState({}),[y,x]=p.useState([]),[h,v]=p.useState(!1),b=p.useRef(Ys()).current;p.useEffect(()=>{Td(e).then(u,()=>u([]))},[e]);const j=H=>K=>c(U=>({...U,[H]:K})),k=H=>{var U;j("at")(H);const K=Wi(H,(U=i.read)==null?void 0:U.at);K!==null&&Date.parse(K)>o()?g(({"source.at":G,...F})=>F):K!==null&&g(G=>G["source.at"]?{...G,"source.at":j0(K,{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:K,issues:U}=N0(i,$);if(x([]),!K){g(U??{});return}g({}),v(!0);try{if(s){const F=S0(s,K);Object.keys(F).length&&await e.updateTrigger(s.id,F),n(Dn(s.id))}else{const F=await e.createTrigger(K,b.keyFor("createTrigger",K));n(Dn(F.id))}}catch(F){const z=$l(F),Y=i.kind==="at"?Wi(i.at,(G=i.read)==null?void 0:G.at):null,se=z.fields["source.at"];se&&Y!==null&&(Date.parse(Y)<=o()||$8.test(se))&&(z.fields["source.at"]=j0(Y,{now:o()})),g(Object.fromEntries(Object.entries(z.fields).filter(([Q])=>E.has(Q)))),x([...z.rest,...Object.entries(z.fields).filter(([Q])=>!E.has(Q)).map(([,Q])=>Q)]),v(!1)}},P=s?N0(i,$).body:void 0,O=!!(s&&P&&S0(s,P).source),M=i.kind==="at"?Wi(i.at,(W=i.read)==null?void 0:W.at):null,R=i.startAt?Wi(i.startAt,(q=i.read)==null?void 0:q.startAt):null,A=Nl((d??[]).filter(H=>!H.archived_at||H.agent_id===i.agentId)),L=[{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(An,{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(dm,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit schedule":"New schedule"]}),y.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:y.map((H,K)=>t.jsx("p",{children:H},K))}),t.jsxs("div",{className:`mt-5 ${id}`,children:[t.jsx(Lt,{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:L.map(({kind:H,label:K})=>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"}),K]},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(Lt,{label:"Runs",field:"source.cron",issue:f["source.cron"],children:t.jsx(hE,{label:"Runs",name:"cron",value:i.cron,onChange:j("cron")})}),i.kind==="at"&&t.jsx(Lt,{label:"At, your time",field:"source.at",issue:f["source.at"],hint:M?`= ${k0(M)}`: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(Lt,{label:"Every",field:"source.every_s",issue:f["source.every_s"],hint:r?vb(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(Et,{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(Lt,{label:"Time zone",field:"source.timezone",issue:f["source.timezone"],hint:"The time zone this schedule runs in.",children:t.jsx(pE,{name:"timezone",label:"Time zone",className:"w-full",value:i.timezone,onChange:j("timezone")})}),i.kind==="every"&&t.jsx(Lt,{label:"Starting, your time (optional)",field:"source.start_at",issue:f["source.start_at"],hint:R?`= ${k0(R)}`: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(Lt,{label:"Agent",field:"target.agent_id",issue:f["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:i.agentId,onChange:H=>j("agentId")(H),options:[{value:"",label:d?"Pick an agent":"Loading the agents"},...A.map(H=>({value:H.agent_id,label:`${H.definition.name||H.agent_id}${H.kind==="workflow"?" (workflow)":""}`})),...i.agentId&&d&&!A.some(H=>H.agent_id===i.agentId)?[{value:i.agentId,label:i.agentId}]:[]]})}),t.jsx(Lt,{label:"Each run is asked",field:"target.input",issue:f["target.input"],children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:i.content,onChange:H=>j("content")(H.target.value)})}),t.jsx(Lt,{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 (${na(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:_d(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 OE({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(Ka,{"aria-hidden":!0})," ",n]}),s&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:s})]})}function Nb({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(Cx,{title:"URL",text:s,label:"Copy URL",hint:xb}),t.jsx(Cx,{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 Cx({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(OE,{text:n,label:s})]}),r&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:r})]})}const z8=["standard","github"];function D8({v2:e,go:n}){var $;const[s,r]=p.useState(_6),[o,i]=p.useState(null),[c,d]=p.useState({}),[u,f]=p.useState([]),[g,y]=p.useState(!1),[x,h]=p.useState(null),v=p.useRef(Ys()).current;p.useEffect(()=>{Td(e).then(i,()=>i([]))},[e]);const b=_=>P=>r(O=>({...O,[_]:P})),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 P=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd",...Ed(s.accept.map(R=>R.where.length))]),{body:O,issues:M}=T6(s,k!==void 0);if(f([]),!O){d(M??{});return}d({}),y(!0);try{h(await e.createTrigger(O,v.keyFor("createTrigger",O)))}catch(R){const A=$l(R);d(Object.fromEntries(Object.entries(A.fields).filter(([L])=>P.has(L)))),f([...A.rest,...Object.entries(A.fields).filter(([L])=>!P.has(L)).map(([,L])=>L)])}finally{y(!1)}},S=t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(An,{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(sl,{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 (${wx[x.source.kind==="webhook"?x.source.signature??"standard":"standard"]}). Each one starts a run.`}),x.signing_secret?t.jsx(Nb,{label:"The webhook's URL and secret",url:Vc(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(Cx,{title:"URL",text:Vc(x),label:"Copy URL",hint:xb}),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(sl,{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((_,P)=>t.jsx("p",{children:_},P))}),t.jsxs("div",{className:`mt-5 ${id}`,children:[t.jsx(Lt,{label:"Name",field:"name",issue:c.name,children:t.jsx(Pe,{name:"name",value:s.name,onChange:_=>b("name")(_.target.value),placeholder:"on deploy"})}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:z8.map(_=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${s.signature===_?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"signature",value:_,checked:s.signature===_,onChange:()=>b("signature")(_),className:"accent-primary"}),wx[_]]},_))}),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(PE,{signature:s.signature,rules:s.accept,onChange:b("accept"),issues:c,cap:null}),t.jsx(Lt,{label:"Agent",field:"target.agent_id",issue:c["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:s.agentId,onChange:_=>b("agentId")(_),options:[{value:"",label:o?"Pick an agent":"Loading the agents"},...N.map(_=>({value:_.agent_id,label:`${_.definition.name||_.agent_id}${_.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Lt,{label:"Each run is asked",field:"target.input",issue:c["target.input"],children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:s.content,onChange:_=>b("content")(_.target.value)})}),t.jsx(Lt,{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 (${na(k)}) if empty.`:"Required: each run this webhook starts stops at this spend.",children:t.jsx(Pe,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:s.maxCost,onChange:_=>b("maxCost")(_.target.value),placeholder:_d(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 F8({v2:e,go:n}){var A;const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(0),[u,f]=p.useState(R6),[g,y]=p.useState(null),[x,h]=p.useState({}),[v,b]=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 L=!0;return i(null),e.githubConnection().then(D=>{L&&r(!!D&&"app_id"in D&&!!D.app_id)},D=>{L&&(D instanceof ze&&D.status===404?r(!1):i(Ht(D,"GitHub's connection")))}),()=>{L=!1}},[e,c]),p.useEffect(()=>{Td(e).then(y,()=>y([]))},[e]);const N=L=>D=>f(W=>({...W,[L]:D})),$=(A=(g??[]).find(L=>L.agent_id===u.agentId))==null?void 0:A.definition.max_cost_usd,_=typeof $=="number"&&$>0?$:void 0,P=async L=>{L.preventDefault();const D=new Set(["name","target.agent_id","target.input","target.max_cost_usd",...Ed(eh(u).map(H=>H.where.length))]),{body:W,issues:q}=B6(u,_!==void 0);if(b([]),!W){h(q??{});return}h({}),k(!0);try{const H=await e.createTrigger(W,E.keyFor("createTrigger",W));S.current&&n(Dn(H.id))}catch(H){const K=$l(H);h(Object.fromEntries(Object.entries(K.fields).filter(([U])=>D.has(U)))),b([...K.rest,...Object.entries(K.fields).filter(([U])=>!D.has(U)).map(([,U])=>U)]),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(An,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),M=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(mm,{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,M,t.jsx(Jt,{problem:o,onRetry:()=>d(L=>L+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,M,t.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Connect GitHub first: ",t.jsx("a",{href:"#/settings/github",className:"underline underline-offset-2",children:"Settings → GitHub"}),". A GitHub trigger takes events from this server's GitHub App."]})]});const R=Nl((g??[]).filter(L=>!L.archived_at));return t.jsxs("form",{onSubmit:L=>void P(L),className:"p-5 md:p-8",noValidate:!0,children:[O,M,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((L,D)=>t.jsx("p",{children:L},D))}),t.jsxs("div",{className:`mt-5 ${id}`,children:[t.jsx(Lt,{label:"Name",field:"name",issue:x.name,children:t.jsx(Pe,{name:"name",value:u.name,onChange:L=>N("name")(L.target.value),placeholder:"review PRs"})}),t.jsx(LE,{picks:u,onChange:L=>f(D=>({...D,...L})),issues:x}),t.jsx(Lt,{label:"Agent",field:"target.agent_id",issue:x["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:u.agentId,onChange:L=>N("agentId")(L),options:[{value:"",label:g?"Pick an agent":"Loading the agents"},...R.map(L=>({value:L.agent_id,label:`${L.definition.name||L.agent_id}${L.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Lt,{label:"Each run is asked",field:"target.input",issue:x["target.input"],hint:"The event's payload comes with it.",children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:u.content,onChange:L=>N("content")(L.target.value)})}),t.jsx(Lt,{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 (${na(_)}) 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:L=>N("maxCost")(L.target.value),placeholder:_d(_)})})]}),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 U8({v2:e,go:n,noAddress:s}){var xe;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(0),[f,g]=p.useState(null),[y,x]=p.useState(null),[h,v]=p.useState(0),[b,j]=p.useState(M6),[k,E]=p.useState(null),[S,N]=p.useState({}),[$,_]=p.useState([]),[P,O]=p.useState(null),[M,R]=p.useState(null),[A,L]=p.useState(!1),D=p.useRef(Ys()).current,W=p.useRef(!0);p.useEffect(()=>(W.current=!0,()=>{W.current=!1}),[]),p.useEffect(()=>{let fe=!0;return c(null),e.listMcpServers().then(De=>{if(!fe)return;const Fe=De.servers.filter(Le=>Le.source==="composio");o(Fe),Fe.length===1&&j(Le=>Le.server?Le:{...Le,server:Fe[0].name})},De=>{fe&&c(Ht(De,"the saved MCP servers"))}),()=>{fe=!1}},[e,d]),p.useEffect(()=>{if(!b.server)return;let fe=!0;const De=b.server;return g(null),x(null),e.composioEvents(De).then(Fe=>{fe&&g({server:De,events:Fe.events})},Fe=>{fe&&x(Ht(Fe,`${De}'s events`))}),()=>{fe=!1}},[e,b.server,h]),p.useEffect(()=>{Td(e).then(E,()=>E([]))},[e]);const q=fe=>{R(null),j(fe)},H=fe=>De=>q(Fe=>({...Fe,[fe]:De})),K=fe=>q(De=>De.server===fe?De:{...De,server:fe,event:"",config:{},where:[]}),U=fe=>{q(De=>De.event===fe?De:{...De,event:fe,config:{},where:[]}),N({})},G=(f==null?void 0:f.server)===b.server?f.events.find(fe=>fe.slug===b.event):void 0,F=P6(G==null?void 0:G.config),z=(xe=(k??[]).find(fe=>fe.agent_id===b.agentId))==null?void 0:xe.definition.max_cost_usd,Y=typeof z=="number"&&z>0?z:void 0,se=async fe=>{var Fe,Le;const De=new Set(["name","source.server","source.event","source.config",...F.map(Ee=>`source.config.${Ee.name}`),"target.agent_id","target.input","target.max_cost_usd",...b.where.length?Ed([b.where.length]):[]]);N({}),_([]),O(null),R(null),L(!0);try{const Ee=await e.createTrigger(fe,D.keyFor("createTrigger",fe));W.current&&n(Dn(Ee.id));return}catch(Ee){if(Ee instanceof ze&&Ee.code==="composio_subscription_elsewhere")R({url:typeof((Fe=Ee.details)==null?void 0:Fe.webhook_url)=="string"?Ee.details.webhook_url:"another address",body:fe});else if(Ee instanceof ze&&Ee.code.startsWith("composio_"))_([Ee.message]),Ee.code==="composio_not_connected"&&O(dr(typeof((Le=Ee.details)==null?void 0:Le.connect_url)=="string"?Ee.details.connect_url:null)??null);else{const ae=$l(Ee);N(Object.fromEntries(Object.entries(ae.fields).filter(([$e])=>De.has($e)))),_([...ae.rest,...Object.entries(ae.fields).filter(([$e])=>!De.has($e)).map(([,$e])=>$e)])}}L(!1)},Q=()=>z6(b,F,Y!==void 0),re=fe=>{fe.preventDefault();const{body:De,issues:Fe}=Q();if(_([]),O(null),!De){N(Fe??{});return}se(De)},te=()=>{const fe=M;R(null),fe&&se({...fe.body,source:{...fe.body.source,move_subscription:!0}})},he=t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(An,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),ge=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(cm,{className:"size-5 text-primary-text","aria-hidden":!0}),"New app trigger"]});if(i)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[he,ge,t.jsx(Jt,{problem:i,onRetry:()=>u(fe=>fe+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:[he,ge,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 ye=Nl((k??[]).filter(fe=>!fe.archived_at));return t.jsxs("form",{onSubmit:re,className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[he,ge,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:kb}),$.length>0&&t.jsxs("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:[$.map((fe,De)=>t.jsx("p",{className:"break-words",children:fe},De)),P&&t.jsx("a",{href:P,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(Lt,{label:"Name",field:"name",issue:S.name,children:t.jsx(Pe,{name:"name",value:b.name,onChange:fe=>H("name")(fe.target.value),placeholder:"new issues"})}),t.jsx(Lt,{label:"Composio server",field:"source.server",issue:S["source.server"],children:t.jsx(Et,{name:"server",label:"Composio server",className:"w-full",value:b.server,onChange:K,options:[{value:"",label:"Pick a server"},...r.map(fe=>({value:fe.name,label:fe.toolkit?`${fe.name} (${fe.toolkit})`:fe.name}))]})}),b.server&&(y?t.jsx(Jt,{problem:y,onRetry:()=>v(fe=>fe+1),className:""}):t.jsx(Lt,{label:"Event",field:"source.event",issue:S["source.event"],hint:G==null?void 0:G.description,children:t.jsx(Et,{name:"event",label:"Event",className:"w-full",value:b.event,onChange:U,disabled:!f,options:[{value:"",label:f?f.events.length?"Pick an event":"Composio offers no event for this toolkit":"Loading the events"},...((f==null?void 0:f.events)??[]).map(fe=>({value:fe.slug,label:fe.name||fe.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"}),F.length?t.jsx("div",{className:"space-y-4",children:F.map(fe=>t.jsx(W8,{field:fe,value:b.config[fe.name]??fe.initial,issue:S[`source.config.${fe.name}`],onChange:De=>q(Fe=>({...Fe,config:{...Fe.config,[fe.name]:De}}))},`${G.slug}:${fe.name}`))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"This event takes no config."})]}),t.jsx(ME,{where:b.where,onChange:H("where"),issues:S})]}),t.jsx(Lt,{label:"Agent",field:"target.agent_id",issue:S["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:b.agentId,onChange:fe=>H("agentId")(fe),options:[{value:"",label:k?"Pick an agent":"Loading the agents"},...ye.map(fe=>({value:fe.agent_id,label:`${fe.definition.name||fe.agent_id}${fe.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Lt,{label:"Each run is asked",field:"target.input",issue:S["target.input"],hint:"What Composio delivered comes with it.",children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:b.content,onChange:fe=>H("content")(fe.target.value)})}),t.jsx(Lt,{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 (${na(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:b.maxCost,onChange:fe=>H("maxCost")(fe.target.value),placeholder:_d(Y)})})]}),M&&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:M.url})," now. Moving them here stops them arriving there: anything listening at ",t.jsx("code",{className:"break-all font-mono text-small",children:M.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:te,children:"Move it here"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>R(null),children:"Keep it there"})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:A||!!M||s,children:A?"Creating":"Create app trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function W8({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(wt,{className:"min-w-0",label:e.title,required:e.required,optional:!e.required,hint:e.description,error:i,children:e.options?t.jsx(Et,{name:o,label:e.title,className:"w-full",value:n,onChange:r,options:[...e.required?[]:[{value:"",label:"None"}],...e.options.map(c=>({value:c,label:c}))],placeholder:"Pick one"}):e.type==="json"?t.jsx(nn,{name:o,rows:3,className:"p-3 font-mono",value:n,onChange:c=>r(c.target.value),spellCheck:!1}):t.jsx(Pe,{name:o,inputMode:e.type==="string"?void 0:"decimal",value:n,onChange:c=>r(c.target.value),autoComplete:"off",spellCheck:!1})})})}function H8(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 PE({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(CE,{name:"accept",rules:n,onChange:s,issues:r,room:Cd.rules-n.length,eventHint:SE[e],eventPlaceholder:e==="github"?"issues":"issue.opened"}),t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:H8(n.length>0,o)})]})]})}function LE({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=eh(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:iE.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:[Zm.filter(u=>u.event===i).map(({event:u,action:f,label:g})=>{const y=`${u}:${f}`;return t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"event",value:y,checked:e.events.includes(y),onChange:()=>r(y),className:"accent-primary"}),g," ",t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[u," ",f]})]},y)}),c>=0&&t.jsxs("div",{className:"ml-6 space-y-1 pt-1",children:[[d,`${d}.event`,`${d}.actions`].map(u=>t.jsx(ur,{issues:s,field:u},u)),t.jsx(oh,{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(CE,{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:Cd.rules-o.length,eventHint:SE.github,eventPlaceholder:"issues",addLabel:"Add another event"})]})]})}function B8({v2:e,go:n,trigger:s}){const r=gb(s)?s:null,o=bb(s)?s:null,[i,c]=p.useState(()=>r?(r.source.accept??[]).map(Jf):o?(o.source.accept??[]).map(Jf):[]),[d,u]=p.useState(()=>r||o?{events:[],where:{},other:[]}:O6(s.source.accept)),f=o&&i[0]&&!i[0].actions.trim()?i[0]:null,g=o?i.slice(f?1:0):[],[y,x]=p.useState({}),[h,v]=p.useState([]),[b,j]=p.useState(!1),k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const E=async $=>{$.preventDefault();const{source:_,issues:P}=r?aE(r.source,i):o?I6(o.source,(f==null?void 0:f.where)??[],g,f==null?void 0:f.was):lE(d);if(v([]),Object.keys(P).length){x(P);return}x({}),j(!0);try{Jc(_,s.source)||await e.updateTrigger(s.id,{source:_}),k.current&&n(Dn(s.id))}catch(O){if(!k.current)return;const M=$l(O),R=Ed(r||o?i.map(A=>A.where.length):eh(d).map(A=>A.where.length));x(Object.fromEntries(Object.entries(M.fields).filter(([A])=>R.has(A)))),v([...M.rest,...Object.entries(M.fields).filter(([A])=>!R.has(A)).map(([,A])=>A)]),j(!1)}},S=r?sl:o?cm:mm,N=$=>c(f?$.length?[{...f,where:$},...g]:g:$.length?[{...BC(),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(An,{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(PE,{signature:r.source.signature??"standard",rules:i,onChange:c,issues:y,cap:s.max_active_runs??null}):o?t.jsx(ME,{where:(f==null?void 0:f.where)??[],onChange:N,issues:y,others:g.map($=>$.event+($.actions.trim()?` (${$.actions.trim()})`:""))}):t.jsx(LE,{picks:d,onChange:u,issues:y})}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:b,children:b?"Saving":"Save filter"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(Dn(s.id)),children:"Cancel"})]})]})}function ME({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(oh,{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 G8({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 IE({v2:e,go:n,trigger:s,minEvery:r}){var M;const[o,i]=p.useState(()=>s?F6(s):uE()),[c,d]=p.useState(null),[u,f]=p.useState({}),[g,y]=p.useState([]),[x,h]=p.useState(!1),[v,b]=p.useState(()=>!!s&&(s.source.items!==void 0||s.source.id!==void 0));p.useEffect(()=>{(u["source.items"]||u["source.id"])&&b(!0)},[u]);const j=p.useRef(Ys()).current,k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]),p.useEffect(()=>{s||Td(e).then(d,()=>d([]))},[e,s]);const E=R=>A=>i(L=>({...L,[R]:A})),S=(M=(c??[]).find(R=>R.agent_id===o.agentId))==null?void 0:M.definition.max_cost_usd,N=typeof S=="number"&&S>0?S:void 0,$=async R=>{R.preventDefault();const A=H6(fE(o.urls).urls.length,[o.where.length,...o.others.map(q=>q.where.length)]);y([]);const L=q=>{if(!k.current)return;const H=$l(q);f(Object.fromEntries(Object.entries(H.fields).filter(([K])=>A.has(K)))),y([...H.rest,...Object.entries(H.fields).filter(([K])=>!A.has(K)).map(([,K])=>K)]),h(!1)};if(s){const{source:q,issues:H}=mE(o,r);if(Object.keys(H).length){f(H);return}f({}),h(!0);try{Jc(q,s.source)||await e.updateTrigger(s.id,{source:q}),k.current&&n(Dn(s.id))}catch(K){L(K)}return}const{body:D,issues:W}=W6(o,r,N!==void 0);if(!D){f(W??{});return}f({}),h(!0);try{const q=await e.createTrigger(D,j.keyFor("createTrigger",D));k.current&&n(Dn(q.id))}catch(q){L(q)}},_=Object.entries(u).filter(([R])=>/^source\.urls(\[\d+\])?$/.test(R)),P=Nl((c??[]).filter(R=>!R.archived_at)),O=o.others.map(R=>R.event+(R.actions.trim()?` (${R.actions.trim()})`:""));return t.jsxs("form",{onSubmit:R=>void $(R),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?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(An,{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(Kx,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit feed":"New feed trigger"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:s?"The feeds it reads, how often, and which items start a run. Its name, its agent and what each run is asked stay as they are.":"Each new or updated item in its feeds starts a capped run of the agent. The items already there when it is made start none: its first check, on its page once it is made, says how many."}),g.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:g.map((R,A)=>t.jsx("p",{children:R},A))}),t.jsxs("div",{className:`mt-5 ${id}`,children:[!s&&t.jsx(Lt,{label:"Name",field:"name",issue:u.name,children:t.jsx(Pe,{name:"name",value:o.name,onChange:R=>E("name")(R.target.value),placeholder:"vendor outages"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(wt,{className:"min-w-0",label:"Feed URLs",hint:`One a line, 1 to ${kx}: RSS, Atom, JSON Feed, or an API's JSON list. Plain http is read on a public address alone.`,error:_.length?t.jsx(t.Fragment,{children:_.map(([R,A])=>t.jsx("span",{"data-issue":R,className:"block",children:A},R))}):void 0,children:t.jsx(nn,{name:"urls",rows:4,className:"p-3 font-mono text-small",value:o.urls,onChange:R=>E("urls")(R.target.value),placeholder:"https://www.githubstatus.com/history.atom",spellCheck:!1})}),s&&t.jsx("p",{className:"mt-2 text-small text-warning-text",role:"note",children:"A feed you add starts from now: what's in it already won't start runs."})]}),t.jsx(Lt,{label:"Every",field:"source.every_s",issue:u["source.every_s"],hint:r?vb(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Pe,{name:"every",inputMode:"decimal",value:o.every,onChange:R=>E("every")(R.target.value),placeholder:"15"}),t.jsx(Et,{id:"feed-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:o.everyUnit,onChange:R=>E("everyUnit")(R),options:["seconds","minutes","hours"].map(R=>({value:R,label:R}))})]})}),t.jsxs("details",{"data-json-list":!0,open:v,onToggle:R=>b(R.currentTarget.open),className:"min-w-0 border p-3",children:[t.jsxs("summary",{className:"cursor-pointer text-body font-semibold",children:["JSON list ",t.jsx("span",{className:"font-normal text-small text-muted-foreground",children:"(optional: a feed that is an API's JSON, such as GitHub's pull requests)"})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(Lt,{label:"Items at",field:"source.items",issue:u["source.items"],hint:"A JSON Pointer to the array of items: empty for the whole document, /data/items for one inside it.",children:t.jsx(Pe,{name:"items",value:o.items,onChange:R=>E("items")(R.target.value),placeholder:"/data/items",autoComplete:"off",spellCheck:!1})}),t.jsx(Lt,{label:"Each item's id at",field:"source.id",issue:u["source.id"],hint:"A JSON Pointer into an item to what names it: empty for /id, /number for a pull request.",children:t.jsx(Pe,{name:"id",value:o.id,onChange:R=>E("id")(R.target.value),placeholder:"/id",autoComplete:"off",spellCheck:!1})})]})]}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(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(oh,{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(Lt,{label:"Agent",field:"target.agent_id",issue:u["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:o.agentId,onChange:R=>E("agentId")(R),options:[{value:"",label:c?"Pick an agent":"Loading the agents"},...P.map(R=>({value:R.agent_id,label:`${R.definition.name||R.agent_id}${R.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Lt,{label:"Each run is asked",field:"target.input",issue:u["target.input"],hint:"The item comes with it: its title, link, summary and feed.",children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:o.content,onChange:R=>E("content")(R.target.value)})}),t.jsx(Lt,{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 (${na(N)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(Pe,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:o.maxCost,onChange:R=>E("maxCost")(R.target.value),placeholder:_d(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 zE=e=>e?"#/playground?operation=apply-template":"#/templates";function $0({v2:e,name:n,install:s,go:r,playground:o=!1,draft:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),[g,y]=p.useState(0);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(Ht(v,"the templates"))}),()=>{h=!1}},[e,g,s]),s!==void 0)return t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(K8,{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(Jt,{problem:u,onRetry:()=>y(h=>h+1),className:""}):c?n===void 0?t.jsx(q8,{v2:e,templates:c,go:r,playground:o,onRemoved:()=>y(h=>h+1)}):x?t.jsx(J8,{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:zE(o),className:"underline",children:"See its templates"}),"."]}):t.jsx(Un,{label:"Loading the templates",rows:3})})}function Sb({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 q8({v2:e,templates:n,go:s,playground:r,onRemoved:o}){const i=r?"h2":"h1",c=r?"h3":"h2",[d,u]=p.useState(""),[f,g]=p.useState(null),[y,x]=p.useState(null),h=async v=>{g(v.id),x(null);try{await e.deleteTemplate(v.id),o()}catch(b){x(b instanceof Error?b.message:String(b))}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(V8(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"})]}),y&&t.jsx("p",{className:"mb-3 text-body text-destructive-text",role:"alert",children:y}),n.length?t.jsx("ul",{className:"grid gap-3 md:grid-cols-2",children:n.map(v=>t.jsx("li",{children:t.jsxs("article",{"aria-label":Fo(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(Hx,{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:Fo(v)}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:v.version}),v.category&&t.jsx(Ne,{tone:"muted",children:v.category}),!v.bundled&&t.jsx(Ne,{tone:"muted",children:"Imported"})]}),t.jsx(Sb,{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:wb(v).map(([b,j])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0",children:b}),t.jsx("dd",{className:"min-w-0 break-words text-foreground/80",children:j})]},b))}),t.jsxs("div",{className:"mt-auto flex flex-wrap items-center justify-end gap-2 pt-4",children:[!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(Zi(v)),children:"Configure"}):t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:tm(v)?"primary":"outline",onClick:()=>s(xE(v.id)),children:"Configure"}),t.jsx(sn,{variant:tm(v)?"outline":"primary",label:"Run",prompt:nx(location.origin,v),playgroundHref:Zi(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 K8({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),[y,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(_0(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(xE(S.template.id))}catch(S){x(_0(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(An,{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 b=r.template,j=b.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:[Fo(b)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:b.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:b.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:b.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:[b.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:b.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:wb(b,{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))})}),b.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:b.mcp.map(S=>t.jsxs("div",{"data-mcp":S.toolkit,className:"px-4 py-3",children:[t.jsx(DE,{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(FE,{t:b}),t.jsx(UE,{t:b}),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=b.output)==null?void 0:E.json_schema)&&t.jsx(cr,{title:"Output schema",note:`What the agent is told to answer in (${b.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(b.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."}),y&&t.jsx("p",{className:"w-full text-body text-destructive-text",role:"alert",children:y})]})]})}function _0(e){var n;return e instanceof ze&&((n=e.fields)!=null&&n.length)?[...new Set([e.message,...e.fields.map(s=>s.message)])].join(" "):e instanceof Error?e.message:String(e)}const V8=e=>`#/templates/install?src=${encodeURIComponent(e)}`,Y8=3e3;function Q8(e,n){let s;const r=new Promise(o=>s=setTimeout(()=>o(void 0),n));return Promise.race([e,r]).finally(()=>clearTimeout(s))}function J8({v2:e,template:n,go:s,playground:r=!1,draft:o}){var $t,nt,ft,Dt,Ft,be,de,Ue,Xe,at;const i=r?"h2":"h1",c={fields:nh(n.parameters)??[]},d=r8(o,n),[u,f]=p.useState(()=>{var J;return{...Object.fromEntries(c.fields.filter(([,ve])=>ve.type==="boolean"&&!ve.array).map(([ve])=>[ve,"false"])),...wE(c),...Object.fromEntries(Object.entries(((J=d.body)==null?void 0:J.parameters)??{}).map(([ve,We])=>[ve,Array.isArray(We)?We.map(String).join(`
664
- `):String(We)]))}}),[g,y]=p.useState(()=>{var J;return new Set(((J=d.body)==null?void 0:J.grants)??[])}),[x,h]=p.useState(((nt=($t=d.body)==null?void 0:$t.overrides)==null?void 0:nt.approvals)??n.approvals_default??"ask"),[v,b]=p.useState(((Dt=(ft=d.body)==null?void 0:ft.overrides)==null?void 0:Dt.choice)??""),[j,k]=p.useState(null),[E,S]=p.useState(null),[N,$]=p.useState(0),[_,P]=p.useState(()=>{var J;return((J=d.body)==null?void 0:J.servers)??{}}),[O,M]=p.useState(!1),[R,A]=p.useState([]),[L,D]=p.useState(null),[W,q]=p.useState(null),[H,K]=p.useState([]),[U,G]=p.useState({}),F=p.useRef(Ys()).current,z=p.useRef(!0);p.useEffect(()=>(z.current=!0,()=>{z.current=!1}),[]),p.useEffect(()=>{let J=!0;return S(null),e.listMcpServers().then(ve=>{J&&k(ve.servers)},ve=>{J&&S(Ht(ve,"the saved MCP servers"))}),()=>{J=!1}},[e,N]);const Y=d8(n,g),se=n.mcp.map(J=>{const ve=j?i8(J,j):[];return{m:J,matches:ve,uses:ve.length===1?ve[0]:ve.includes(_[J.toolkit]??"")?_[J.toolkit]:void 0}}),Q=Object.fromEntries(se.flatMap(({m:J,uses:ve})=>ve?[[J.toolkit,ve]]:[])),re=se.filter(({matches:J,uses:ve})=>J.length>1&&!ve).map(({m:J})=>J.toolkit),te=n.mcp.length>0&&j===null,he=j&&se.some(({m:J,matches:ve})=>{var We,Ve;return((Ve=(We=d.body)==null?void 0:We.servers)==null?void 0:Ve[J.toolkit])!==void 0&&!ve.includes(d.body.servers[J.toolkit])}),ge=d.error??(he?"This prepared server choice no longer matches the saved MCP servers. Open a fresh request to review the current accounts.":void 0),ye=!!ge||te||re.length>0,xe=r||tm(n),fe=!r&&tm(n)?E0.filter(J=>J.needs(n)):[],[De,Fe]=p.useState({}),[Le,Ee]=p.useState(0),ae=fe.map(J=>J.id).join(" ");p.useEffect(()=>{let J=!0;for(const ve of E0.filter(We=>ae.split(" ").includes(We.id)))ve.met(e).then(We=>{J&&Fe(Ve=>({...Ve,[ve.id]:We?"met":"unmet"}))},()=>{J&&Fe(We=>({...We,[ve.id]:"unread"}))});return()=>{J=!1}},[e,ae,Le]);const $e=fe.filter(J=>De[J.id]!=="met"),ot=$e.find(J=>De[J.id]===void 0),me=$e.length>0;p.useEffect(()=>{if(!me)return;const J=()=>Ee(ve=>ve+1);return window.addEventListener("focus",J),()=>window.removeEventListener("focus",J)},[me]);const Me={parameters:rh(c,u),...Y.length?{grants:Y}:{},...Object.keys(Q).length?{servers:Q}:{},overrides:{approvals:x,...v?{choice:v}:{}}},Ze=J=>u8(R,J),bt=(J,ve,We)=>{f(Ve=>({...Ve,[J]:We})),yE(ve,We)&&A(Ve=>Ve.filter(He=>Sx(He.field,"parameters")!==J))},oe=async()=>{var ve,We;if(!xe||ye||$e.length)return;M(!0),A([]),D(null);const J=u;try{const Ve=await e.applyTemplate(n.id,Me,F.keyFor(n.id,Me));F.done();const He=async()=>(await Promise.all(Ve.trigger_ids.map(lt=>Q8(e.getTrigger(lt),Y8).catch(()=>null)))).filter(lt=>lt!=null&&pb(lt));if(Ve.warnings.length||(ve=Ve.webhook_secrets)!=null&&ve.length){G(J),q(Ve),He().then(K,()=>{});return}const gt=Ve.trigger_ids.length?await He():[];if(!z.current)return;if(!gt.length){s(dn(Ve.agent_id));return}G(J),K(gt),q(Ve)}catch(Ve){Ve instanceof ze&&((We=Ve.fields)!=null&&We.length)?(A(Ve.fields),D({text:Ve.message,withIssues:!0}),Ve.fields.some(He=>He.field.startsWith("servers.")||He.field.startsWith("mcp."))&&$(He=>He+1)):D({text:Ve instanceof Error?Ve.message:String(Ve),withIssues:!1})}finally{M(!1)}},Se=c.fields,tt=J=>J.filter(ve=>!n.secrets.includes(ve)),Ae=(be=(Ft=n.model)==null?void 0:Ft.choices)==null?void 0:be.find(J=>J.id===v),it=J=>{var ve,We;return/^(parameters|mcp|servers)\./.test(J.field)||/^grants\.\d+$/.test(J.field)||J.field==="overrides.choice"&&!!((We=(ve=n.model)==null?void 0:ve.choices)!=null&&We.length)||J.field.startsWith("secrets.")&&[...n.secrets,...tt((Ae==null?void 0:Ae.secrets)??[])].includes(J.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})," ",Fo(n,U)," 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((J,ve)=>{var gt,kt;const We=/^triggers\.(\d+)\.secret$/.exec(J.field),Ve=We?W.trigger_ids[Number(We[1])]:void 0,He=We?(gt=n.triggers[Number(We[1])])==null?void 0:gt.name:void 0;return Ve&&((kt=W.webhook_secrets)!=null&&kt.some(lt=>lt.trigger_id===Ve))?t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:J.field})," ",J.message]},`${J.field}:${ve}`):t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:J.field})," ",J.message,J.fix?t.jsx("span",{className:"block text-muted-foreground",children:J.fix}):null,Ve&&t.jsxs("a",{href:`#/triggers/${encodeURIComponent(Ve)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",typeof He=="string"&&He?He:Ve," to get its signing secret (Rotate)"]})]},`${J.field}:${ve}`)})})]}),(de=W.webhook_secrets)==null?void 0:de.map(J=>{var He;const ve=W.trigger_ids.indexOf(J.trigger_id),We=ve>=0?(He=n.triggers[ve])==null?void 0:He.name:void 0,Ve=typeof We=="string"&&We?We:J.trigger_id;return J.signing_secret?t.jsx(Nb,{label:`The webhook's URL and secret (${Ve})`,url:Vc({id:J.trigger_id}),secret:J.signing_secret},J.trigger_id):t.jsxs("div",{className:"mt-4 border px-4 py-3 text-body",children:[J.note&&t.jsx("p",{className:"text-muted-foreground",role:"note",children:J.note}),t.jsxs("a",{href:`#/triggers/${encodeURIComponent(J.trigger_id)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",Ve," to get its signing secret (Rotate)"]})]},J.trigger_id)}),H.length>0&&t.jsx("ul",{className:"mt-4 divide-y border","aria-label":"Schedules",children:H.map(J=>t.jsxs("li",{"data-trigger":J.id,className:"px-4 py-3",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(J.id)}`,className:"break-words text-prose font-semibold hover:underline",children:J.name}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",children:mb(J.source,J.next_at)})]},J.id))}),t.jsx("div",{className:"mt-5"}),t.jsx("a",{href:dn(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:zE(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(An,{className:"size-3.5","aria-hidden":!0})," Templates"]}),t.jsxs(i,{className:"text-2xl font-semibold",children:[Fo(n,u)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:n.version})]}),t.jsx(Sb,{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.":xe?"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."}),ge&&t.jsxs("p",{className:"mt-3 text-body text-destructive-text",role:"alert",children:[ge," ",t.jsx("a",{href:Zi(n),className:"underline",children:"Open a fresh request"}),"."]}),t.jsxs("div",{className:`mt-6 ${id}`,children:[Se.length>0&&t.jsx(cr,{title:"Parameters",children:Se.map(([J,ve])=>t.jsxs("div",{"data-field":`parameters.${J}`,className:"px-4 py-3",children:[t.jsx(NE,{field:ve,label:sh(J,ve),help:nm(ve),value:u[J]??"",onChange:We=>bt(J,ve,We)}),t.jsx(Oo,{issues:R.filter(We=>Sx(We.field,"parameters")===J),words:We=>kE(We,J,ve)})]},J))}),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(Jt,{problem:E,onRetry:()=>$(J=>J+1),className:""})}),se.map(({m:J,matches:ve,uses:We})=>t.jsxs("div",{"data-mcp":J.toolkit,className:"px-4 py-3",children:[t.jsx(DE,{m:J,children:j&&ve.length<2&&t.jsx("span",{className:"text-small text-muted-foreground",children:We?`Uses ${We}`:"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(Et,{small:!0,label:`Server for ${J.toolkit}`,value:We??"",placeholder:"Pick one",onChange:Ve=>P(He=>({...He,[J.toolkit]:Ve})),options:ve.map(Ve=>({value:Ve,label:Ve}))}),!We&&t.jsxs("span",{"data-unpicked":J.toolkit,children:[ve.length," saved servers are ",bd[J.source]," ",J.toolkit,": pick the one the agent uses."]})]}),j&&ve.length===0&&t.jsxs("p",{role:"status","data-missing-mcp":J.toolkit,className:"mt-2 border border-warning/50 px-3 py-2 text-small text-warning-text",children:[J.required?`${J.toolkit} is required and not set up here: Apply is refused until it is.`:`${J.toolkit} is not set up here: Apply makes the agent without its tools (${J.tools.map(Ve=>Ve.name).join(", ")}).`," ",t.jsx("a",{href:l8(J),className:"font-mono text-primary-text underline-offset-2 hover:underline",children:J.source==="github"?"Set up GitHub App access":J.source==="composio"?`Add ${J.toolkit} from Composio`:`Set up ${J.toolkit}`})]}),t.jsx(Oo,{issues:[...Ze(`mcp.${J.toolkit}`),...Ze(`servers.${J.toolkit}`)]}),t.jsx("ul",{className:"mt-2 space-y-2",children:J.tools.map(Ve=>{const He=Y.indexOf(Ve.tool);return t.jsxs("li",{"data-tool":Ve.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(Ve.tool),onChange:()=>y(gt=>{const kt=new Set(gt);return kt.has(Ve.tool)?kt.delete(Ve.tool):kt.add(Ve.tool),kt})}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body",children:Ve.name})," ",t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Ve.tool}),t.jsx("span",{className:"block text-small text-muted-foreground",children:Ve.asks==="allow"?"The template asks you to grant this.":"The template does not ask for this; unticked, the agent doesn't get it."})]})]}),He>=0&&t.jsx(Oo,{issues:Ze(`grants.${He}`)})]},Ve.tool)})})]},J.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(J=>t.jsxs("div",{"data-secret":J,className:"px-4 py-3 font-mono text-body",children:[J,t.jsx(Oo,{issues:Ze(`secrets.${J}`)})]},J))}),(Xe=(Ue=n.model)==null?void 0:Ue.choices)!=null&&Xe.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(J=>t.jsxs("label",{"data-choice":J.id||"(default)",className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"model-choice",value:J.id,className:"mt-1 accent-primary",checked:v===J.id,onChange:()=>{b(J.id),A(ve=>ve.filter(We=>We.field!=="overrides.choice"&&!(We.field.startsWith("secrets.")&&!n.secrets.includes(We.field.slice(8)))))}}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body","data-choice-label":!0,children:J.label}),"model"in J&&t.jsxs("span",{className:"block font-mono text-label text-muted-foreground",children:[J.model," on ",J.harness]}),J.warning&&t.jsx("span",{className:"mt-1 block text-small text-warning-text","data-choice-warning":J.id,children:J.warning}),J.note&&t.jsx("span",{className:"mt-1 block text-small text-muted-foreground","data-choice-note":J.id,children:J.note}),"secrets"in J&&v===J.id&&t.jsx("span",{"data-choice-keys":J.id,children:t.jsx(Oo,{issues:tt(J.secrets).flatMap(ve=>Ze(`secrets.${ve}`))})})]})]},J.id||"(default)"))}),t.jsx(Oo,{issues:Ze("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(([J,ve,We])=>t.jsxs("label",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"approvals",value:J,className:"mt-1 accent-primary",checked:x===J,onChange:()=>h(J)}),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:We})]})]},J))}),x==="never"&&t.jsx("p",{className:"mt-2 text-small text-warning-text",children:FC})]}),t.jsx(FE,{t:n}),t.jsx(UE,{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:wb(n,{secrets:!1,mcp:!1}).map(([J,ve])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:J}),t.jsx("dd",{className:"min-w-0 break-words",children:ve})]},J))})})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[xe?t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void oe(),disabled:O||ye||$e.length>0,title:te?E?"The saved MCP servers couldn't be read: try again first":"Reading the saved MCP servers…":re.length?`Pick the server for ${re.join(", ")} first`:ot?`Reading ${ot.what}…`:void 0,children:O?"Applying…":"Apply"}),!r&&t.jsx(sn,{variant:"outline",label:"Set it up with an agent",disabled:ye,prompt:nx(location.origin,n,Me),playgroundHref:Zi(n,Me)}),$e.map(J=>De[J.id]==="unmet"?t.jsxs("p",{role:"status","data-requirement":J.id,className:"min-w-0 text-body text-warning-text",children:[J.unmet.before,t.jsx("a",{href:J.unmet.href,className:"font-mono text-primary-text underline-offset-2 hover:underline",children:J.unmet.link}),J.unmet.after]},J.id):De[J.id]==="unread"?t.jsxs("p",{role:"alert","data-requirement-unread":J.id,className:"flex min-w-0 flex-wrap items-center gap-2 text-body text-destructive-text",children:[`${J.what[0].toUpperCase()}${J.what.slice(1)} couldn't be read.`,t.jsx(B,{size:"sm",onClick:()=>Ee(ve=>ve+1),children:"Try again"})]},J.id):null)]}):t.jsx(sn,{variant:"primary",label:"Run",disabled:ye,prompt:nx(location.origin,n,Me),playgroundHref:Zi(n,Me)}),L&&(!L.withIssues||R.length>0)&&t.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:L.text})]}),R.filter(J=>!it(J)).length>0&&t.jsx("div",{className:"mt-2",children:t.jsx(Oo,{issues:R.filter(J=>!it(J)),named:!0})})]})}function DE({m:e,children:n}){return t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"font-semibold",children:e.toolkit}),t.jsx(Ne,{tone:"muted",children:bd[e.source]}),t.jsx(Ne,{tone:e.required?"plain":"muted",children:e.required?"Required":"Optional"}),n]}),e.reason&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground","data-reason":!0,children:e.reason})]})}function FE({t:e}){if(!e.input_schema)return null;const n=nh(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:sh(s,r)}),r.title&&t.jsx("span",{className:"text-small text-muted-foreground",children:s}),t.jsx(Ne,{tone:"muted",children:k8(r)}),t.jsx(Ne,{tone:r.required?"plain":"muted",children:r.required?"Required":"Optional"})]}),nm(r)&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:nm(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 UE({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 sm(e){return{definition:{version:1,name:"New agent",instructions:e.trim(),harness:"pi",tools:[],skills:[]}}}function T0(e){return`#/playground?${new URLSearchParams({operation:"create-agent",draft:JSON.stringify(e)})}`}function X8(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 Z8={"code-review":um,"inbound-lead":hm,kyb:GT,"market-monitor":HT,"release-notes":Va};function eU({origin:e,v2:n}){const[s,r]=p.useState(""),[o,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(null),[g,y]=p.useState(null),[x,h]=p.useState(0),v=p.useId(),b=Mm(e,s),j=sm(s);p.useEffect(()=>{let S=!0;return y(null),n.listTemplates().then(N=>{S&&f(N.templates)},N=>{S&&y(Ht(N,"the template catalog"))}),()=>{S=!1}},[n,x]);const k=c.trim().toLocaleLowerCase(),E=(u??[]).filter(S=>`${Fo(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:ie(Uc,"!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(nn,{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(sn,{variant:"primary",label:"Build an agent",prompt:b,playgroundHref:T0(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(nn,{id:`${v}-prompt`,value:b,readOnly:!0,rows:8,spellCheck:!1,className:"mt-3 w-full border bg-card p-4 font-mono text-small leading-relaxed text-foreground"})]})]}),t.jsxs("section",{className:"mt-10 md:mt-12","aria-labelledby":`${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:ie(Uc,"flex w-full items-center gap-2 px-3 sm:w-72"),children:[t.jsx(hm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,type:"search","aria-label":"Search templates",value:c,onChange:S=>d(S.target.value),placeholder:"Search templates…",className:"h-control-md w-full font-sans"})]})]}),g&&t.jsx(Jt,{problem:g,onRetry:()=>h(S=>S+1),className:"mb-5"}),(u==null?void 0:u.length)===0&&t.jsx("p",{className:"border border-border px-5 py-10 text-center text-lead text-muted-foreground",children:"This server has no template packages yet. Describe the agent you want to build above."}),u&&u.length>0&&!E.length&&t.jsxs("p",{role:"status",className:"border border-border px-5 py-10 text-center text-muted-foreground",children:["No templates match “",c,"”."]}),t.jsx("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3",children:E.map(S=>{const N=o===S.id,$=Z8[S.name]??Hx,_=`${v}-${encodeURIComponent(S.id)}-actions`,P=[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 ${Fo(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:Fo(S)}),t.jsx(Sb,{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}),P,t.jsx(Dx,{className:"ml-auto size-3.5","aria-hidden":!0})]})]}),N&&t.jsxs("div",{id:_,className:"flex flex-wrap items-center justify-end gap-2 border-t px-4 py-4",children:[t.jsxs("span",{className:"mr-auto font-mono text-small text-muted-foreground",children:["v",S.version]}),t.jsx(sn,{variant:"primary",label:"Use this template",prompt:zL(e,S,s),playgroundHref:Zi(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:T0(sm("")),children:"start from a blank agent"}),"."]})]})}const WE=p.createContext(new Map),tU={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"};function HE({run:e}){const n=p.useContext(WE);if(!e.trigger)return null;const{id:s}=e.trigger,r=n.get(s),o=r?`${tU[r.kind]??"Trigger"}: ${r.name}`:`Trigger: ${s}`;return t.jsx("a",{href:`#/triggers/${encodeURIComponent(s)}`,onClick:i=>i.stopPropagation(),className:"inline-flex max-w-full",title:o,children:t.jsxs(Ne,{className:"max-w-full",children:[t.jsx(dm,{className:"size-3 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"truncate",children:o})]})})}const rm=["queued","working","paused","input_required","completed","failed","cancelled"],nU={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function sU({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 y=!!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(td,{className:"size-4","aria-hidden":!0}),y?"Archived runs":"Runs"]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Et,{label:"Runs in one state",value:d.status??"",onChange:v=>u({...d,status:v||void 0}),className:"h-control-sm w-48",options:[{value:"",label:"Any state"},...rm.map(v=>({value:v,label:nU[v]}))]}),t.jsxs(B,{size:"sm",variant:y?"primary":"outline","aria-pressed":y,onClick:()=>u({...d,archived:!y}),children:[t.jsx(ed,{"aria-hidden":!0})," Archived"]})]}),t.jsx(sn,{label:"Query",prompt:`${Im(location.origin,f)}
665
- Current view: ${d.status?`status ${d.status}`:"all statuses"}; ${y?"archived runs":"non-archived runs"}.`,playgroundHref:$v(f,d)})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[r&&!e?t.jsx(Jt,{problem:r,onRetry:o,className:""}):e?!e.length&&!((x=g==null?void 0:g.data)!=null&&x.sessions.length)&&!d.status&&!y?t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(rU,{})}):!e.length&&((h=g==null?void 0:g.data)!=null&&h.sessions.length)?null:e.length?t.jsx(oU,{runs:e,agentName:n,onOpen:s}):t.jsx("p",{className:"px-4 py-16 text-center text-body text-muted-foreground",children:d.status?"No run matches.":y?"No archived runs.":"No runs yet."}):t.jsx(Un,{label:"Loading the runs"}),g&&t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Ev,{read:g})}),e&&r&&t.jsx(Jt,{problem:r,className:"mt-4"}),e&&i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{type:"button",size:"sm",onClick:i,disabled:c,children:c?"Loading":"Load more"})})]})]})}function rU(){return t.jsxs("section",{"aria-labelledby":"first-run",className:"border border-primary/50 bg-primary/5 p-5",children:[t.jsx("p",{className:"caps text-label text-primary-text",children:"No runs yet"}),t.jsx("h2",{id:"first-run",className:"mt-2 text-xl font-semibold",children:"Start your first run"}),t.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A run is one piece of work an agent does: a question answered, a page researched, a file written. Each one is listed here with its state, when it started and what it cost."}),t.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[t.jsxs("a",{href:"#/playground",className:rl({variant:"solid",size:"lg"}),children:[t.jsx(Vo,{"aria-hidden":!0})," Start a run"]}),t.jsx("a",{href:"#/templates",className:rl({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function oU({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:Cn(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(HE,{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:to(r.cost,{ended:Ha(r.status)})})]},r.run_id))})]})}function aU({agentId:e,details:n}){const{denied:s,asks:r}=jD(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 iU(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 ze(0,"aborted","The upload was stopped."));const d=o();d.open("POST",`${n}/files?path=${encodeURIComponent(e.name)}`),d.setRequestHeader("accept","application/json"),e.type&&d.setRequestHeader("content-type",e.type),d.upload.onprogress=u=>{u.lengthComputable&&u.total>0&&(s==null||s(Math.min(1,u.loaded/u.total)))},d.onload=()=>{let u=null;try{u=JSON.parse(d.responseText)}catch{}if(d.status===201||d.status===200){const y=u==null?void 0:u.file;return y!=null&&y.file_id?(s==null||s(1),i(y)):c(new ze(d.status,"bad_answer","The server's answer named no file."))}const f=u==null?void 0:u.error,g=new ze(d.status,(f==null?void 0:f.code)??"http_error",(f==null?void 0:f.message)??`The server answered ${d.status}.`,(f==null?void 0:f.retryable)??!1,f==null?void 0:f.request_id);f!=null&&f.fields&&(g.fields=f.fields),c(g)},d.onerror=()=>c(new ze(0,"network","The upload did not reach the server.")),d.onabort=()=>c(new ze(0,"aborted","The upload was stopped.")),r==null||r.addEventListener("abort",()=>d.abort(),{once:!0}),d.send(e)})}const lU=(e,n,s)=>iU(e,{onProgress:n,signal:s});function Eg(e){if(!(e instanceof ze))return e instanceof Error?e.message:String(e);const n=(e.fields??[]).filter(s=>s.message!==e.message).map(s=>s.message);return[e.message,...n].join(" ")}function cU({upload:e,remove:n,limits:s,frozen:r=!1}){const[o,i]=p.useState([]),[c,d]=p.useState([]),u=p.useRef(new Map),f=p.useRef(0),g=p.useRef(0);g.current=o.length;const y=p.useRef({items:o,frozen:r,remove:n});y.current={items:o,frozen:r,remove:n};const 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}=y.current;if(!S)for(const _ of E)_.file&&!_.removing&&(($=N==null?void 0:N(_.file.file_id))==null||$.catch(()=>{}))}},[]);const h=p.useCallback(k=>{if(y.current.frozen)return;const E=[],S=s?s.max_files_per_run-g.current:1/0,N=(s==null?void 0:s.max_upload_bytes)??null,$=[];for(const P of k)N!==null&&P.size>N?E.push({text:`${P.name} is ${Wa(P.size)}: this server takes files up to ${Wa(N)}.`}):$.length>=S?E.push({text:`${P.name} is not added: a run names at most ${s==null?void 0:s.max_files_per_run} files here.`}):$.push(P);d(E);const _=$.map(P=>({key:`f${f.current++}`,name:P.name,size:P.size,progress:0}));g.current+=_.length,i(P=>[...P,..._]),_.forEach((P,O)=>{const M=new AbortController;u.current.set(P.key,M);const R=A=>{x.current&&i(L=>L.map(D=>D.key===P.key?{...D,...A}:D))};e($[O],A=>R({progress:A}),M.signal).then(A=>{var L,D,W;if(u.current.delete(P.key),M.signal.aborted){(W=(D=(L=y.current).remove)==null?void 0:D.call(L,A.file_id))==null||W.catch(q=>{x.current&&d(H=>[...H,{text:`${P.name} was sent before it was stopped, and was not removed: ${Eg(q)}`}])});return}R({file:A,progress:1})},A=>{u.current.delete(P.key),!(M.signal.aborted||!x.current)&&(i(L=>L.filter(D=>D.key!==P.key)),d(L=>[...L,{text:`${P.name}: ${Eg(A)}`}]))})})},[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}=y.current,$=E.find(P=>P.key===k);if(!(S||!$||$.removing)){if(!$.file||!N){(_=u.current.get(k))==null||_.abort(),u.current.delete(k),i(P=>P.filter(O=>O.key!==k));return}i(P=>P.map(O=>O.key===k?{...O,removing:!0}:O)),d(P=>P.filter(O=>O.about!==k)),N($.file.file_id).then(()=>{x.current&&i(P=>P.filter(O=>O.key!==k))},P=>{x.current&&(i(O=>O.map(M=>M.key===k?{...M,removing:!1}:M)),d(O=>[...O,{about:k,text:`${$.name} was not removed: ${Eg(P)}`}]))})}},[]),b=p.useCallback(()=>{y.current={...y.current,items:[]},i([]),d([])},[]),j=o.flatMap(k=>k.file&&!k.removing?[k.file.file_id]:[]);return{items:o,refusals:c.map(k=>k.text),add:h,drop:v,clear:b,fileIds:j,frozen:r,busy:o.some(k=>!k.file||k.removing)}}function R0({attachments:e,limits:n,disabled:s,compact:r=!1}){const o=p.useRef(null),[i,c]=p.useState(!1),{items:d,refusals:u,add:f,drop:g}=e,y=s||e.frozen,x=n?[`up to ${n.max_files_per_run} files`,...n.max_upload_bytes!==null?[`${Wa(n.max_upload_bytes)} each`]:[]].join(", "):"";return t.jsxs("div",{className:ie("border border-dashed px-3 py-2.5",i?"border-primary bg-primary/5":"border-border",r&&"max-sm:border-0 max-sm:p-0"),onDragOver:h=>{y||(h.preventDefault(),c(!0))},onDragLeave:()=>c(!1),onDrop:h=>{h.preventDefault(),c(!1),y||f([...h.dataTransfer.files])},role:"group","aria-label":"Files for the run",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>{var h;return(h=o.current)==null?void 0:h.click()},disabled:y,title:r?`Attach files${x?` (${x})`:""}`:void 0,className:ie(r&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[t.jsx(UT,{"aria-hidden":!0})," ",t.jsx("span",{className:ie(r&&"max-sm:sr-only"),children:"Attach files"})]}),t.jsxs("span",{className:ie("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:Wa(h.size)}),!h.file&&t.jsxs("span",{className:"text-muted-foreground","aria-label":`${h.name} sent ${Math.round(h.progress*100)}%`,children:[Math.round(h.progress*100),"%"]}),h.removing&&t.jsx("span",{className:"text-muted-foreground",children:"removing"}),t.jsx("button",{type:"button",onClick:()=>g(h.key),disabled:y||h.removing,"aria-label":`Remove ${h.name}`,className:"text-muted-foreground hover:text-foreground disabled:opacity-45",children:t.jsx(Qo,{className:"size-3.5","aria-hidden":!0})})]},h.key))}),d.some(h=>!h.file)&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:"The run can start once every file is sent."}),u.length>0&&t.jsx("ul",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:u.map((h,v)=>t.jsx("li",{children:h},`${v}:${h}`))})]})}const cf={"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."},Cb=(e,n)=>e instanceof ze?{status:e.status,ms:n,body:{error:{...e.toApiError(),...e.fields?{fields:e.fields}:{}}}}:{status:0,ms:n,body:{error:{code:"network",message:String(e)}}};function dU({agents:e,revisions:n=[],efforts:s,origin:r,agentId:o,onAgent:i,onSend:c,onOpenRun:d,result:u=null,live:f,limits:g,upload:y=lU,removeUpload:x}){var Dt,Ft,be;const[h,v]=p.useState(o??((Dt=e[0])==null?void 0:Dt.agent_id)??"");p.useEffect(()=>{var de;o&&o!==h&&e.some(Ue=>Ue.agent_id===o)?v(o):e.some(Ue=>Ue.agent_id===h)||v(((de=e[0])==null?void 0:de.agent_id)??"")},[e,o]);const b=e.find(de=>de.agent_id===h),j=Uv(b),k=es(b==null?void 0:b.definition),E=(b==null?void 0:b.kind)??"agentic",[S,N]=p.useState(""),[$,_]=p.useState(""),P=$?(Ft=n.find(de=>de.revision===$))==null?void 0:Ft.definition:void 0,O=E==="agentic"?JSON.stringify(((be=P??(b==null?void 0:b.definition))==null?void 0:be.input_schema)??null):"null",M=p.useMemo(()=>E==="agentic"?v8(JSON.parse(O)):null,[E,O]),R=(M==null?void 0:M.kind)==="fields"?M.form:null,A=E==="workflow"||(M==null?void 0:M.kind)==="json",[L,D]=p.useState({});p.useEffect(()=>{D(R?wE(R):{})},[h,O]);const W=E==="workflow"?e8(b==null?void 0:b.definition.workflow):(M==null?void 0:M.kind)==="json"?M.example:null,q=p.useRef("");p.useEffect(()=>{if(S.trim()&&S!==q.current)return;const de=(W==null?void 0:W.text)??"";q.current=de,N(de)},[h,W==null?void 0:W.text]);const[H,K]=p.useState(""),[U,G]=p.useState(""),[F,z]=p.useState(""),[Y,se]=p.useState("form"),[Q,re]=p.useState(u?"response":"code"),[te,he]=p.useState("curl"),[ge,ye]=p.useState(()=>!(typeof window<"u"&&typeof window.matchMedia=="function")||window.matchMedia("(min-width: 1024px) and (min-height: 501px)").matches),xe=p.useId(),[fe,De]=p.useState(u),Fe=new Set((R==null?void 0:R.fields.map(([de])=>de))??[]),Le=de=>{const Ue=Sx(de);return Ue!==null&&Fe.has(Ue)?Ue:null},Ee=p.useMemo(()=>{var at,J;const de=fe&&fe.status>=400?(at=fe.body)==null?void 0:at.error:void 0;if(!de||typeof de.message!="string")return;const Ue=Array.isArray(de.fields)?de.fields.filter(ve=>!!ve&&typeof ve.field=="string"&&typeof ve.message=="string"):[],Xe=Ue.filter(ve=>ve.message!==de.message&&Le(ve.field)===null);return{message:de.message,more:Xe,issues:Ue,box:typeof((J=de.details)==null?void 0:J.box)=="string"?de.details.box:void 0,details:de.code==="agent_not_runnable"?de.details:void 0}},[fe,O]),[ae,$e]=p.useState(new Set);p.useEffect(()=>{$e(new Set)},[fe]);const ot=(de,Ue,Xe)=>{D(at=>({...at,[de]:Xe})),$e(at=>{const J=new Set(at);return yE(Ue,Xe)?J.add(de):J.delete(de),J})},me=de=>ae.has(de)?[]:((Ee==null?void 0:Ee.issues)??[]).filter(Ue=>Le(Ue.field)===de),[Me,Ze]=p.useState(!1),bt=p.useMemo(()=>Ys(),[]),oe=cU({upload:y,remove:x,limits:g,frozen:Me}),Se=J6(E,{text:S,revision:$,effort:H,maxCostUsd:U,fileIds:oe.fileIds,repo:F,...R?{typed:{fields:rh(R,L),contentRequired:R.contentRequired}}:{},...(M==null?void 0:M.kind)==="json"?{json:!0}:{}}),tt=Se.ok?Se.body:{input:A?S:R?w8(R,S,L):{content:S},...oe.fileIds.length?{file_ids:oe.fileIds}:{}},Ae=h?bt.keyFor(h,tt):"",it=te==="curl"?t8(r,h,tt,Ae):`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(Ae)},
671
- },
672
- body: JSON.stringify(${JSON.stringify(tt,null,2).replace(/\n/g,`
673
- `)}),
674
- });
675
- console.log(res.status, await res.json());`,$t=!!j&&(!j.connected||j.state!=="ready"||!j.capabilities.launch||!!U.trim()||!!H||!!F.trim()||oe.fileIds.length>0||oe.busy),nt=async()=>{if(k||$t||!Se.ok||!c||oe.busy)return;Ze(!0);const de=await s8(bt,h,Se.body,c);Ze(!1),De(de),re("response"),ye(!0),de.status>=200&&de.status<300&&oe.clear()},ft=A?E==="workflow"?'{ "subject": "...", "body": "..." }':"The agent's input, as JSON":`The run's ${R?"message":"first message"}, e.g. Summarize the standup: we ship Friday.`;return e.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-hidden",children:[t.jsxs("div",{"aria-label":"Playground agent",className:"flex shrink-0 flex-wrap items-center gap-3 border-b px-5 py-3 md:px-6",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-small",children:[t.jsx("label",{htmlFor:"playground-agent",className:"caps text-muted-foreground",children:"Agent"}),t.jsx(Et,{id:"playground-agent",label:"Agent",value:h,onChange: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:[Ko(k.runtime)," · Your backend"]}):t.jsxs("span",{className:"font-mono text-small",children:[t.jsx("span",{className:"text-primary-text",children:"POST"})," ",t.jsxs("span",{className:"text-muted-foreground",children:["/v2/agents/",h||"{agent_id}","/runs"]})]})]}),k?t.jsxs("section",{className:"space-y-4 p-5 md:p-8",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Run through your backend"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"This agent keeps its existing SDK, tools and job entrypoint. Your coding agent can run it there; AgentRun records its progress and learning."}),t.jsx(sn,{variant:"primary",label:"Run agent",prompt:Lv(r,h,k.runtime)})]}):t.jsxs("div",{className:ie("relative grid min-h-0 flex-1 grid-cols-1",ge?"lg:[@media(min-height:501px)]:grid-cols-2":"grid-rows-[minmax(0,1fr)_auto]"),children:[t.jsxs("section",{"aria-label":"Request",className:ie("flex min-h-0 flex-col border-b",ge?"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:ie("flex items-center justify-between border-b px-5 py-3 md:px-6",!ge&&"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:()=>se(de),className:ie("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."]}),$t&&t.jsx("p",{className:"text-warning-text",children:F.trim()?"This request selects a repository. Native execution uses its source project.":U.trim()?"This request has a spend cap. Native execution cannot enforce it.":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."}),!!F.trim()&&t.jsx(B,{size:"sm",onClick:()=>z(""),children:"Use native source repository"}),!!H&&t.jsx(B,{size:"sm",onClick:()=>K(""),children:"Use native configured effort"}),oe.fileIds.length>0&&t.jsx(B,{size:"sm",onClick:()=>oe.clear(),children:"Remove uploaded attachments"}),!!U.trim()&&t.jsx(B,{size:"sm",onClick:()=>G(""),children:"Remove cap for native execution"}),t.jsx("a",{href:dn(h),className:"underline underline-offset-2",children:"Open native connection"})]}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Start a run"}),t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:[b?`${b.definition.name}: ${E==="agentic"?"an":"a"} ${E} agent.`:"Pick an agent."," The server answers 202 with the run; follow it on its page."]})]}),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(tt,null,2)}),!j&&t.jsx(ja,{name:"file_ids",note:cf.file_ids,children:t.jsx(R0,{attachments:oe,limits:g})})]}):t.jsxs(t.Fragment,{children:[t.jsxs(ja,{htmlFor:"playground-input",name:A?"input":"input.content",required:!R||R.contentRequired,optional:!!R&&!R.contentRequired,error:!Se.ok&&Se.field==="input"&&S?Se.message:void 0,children:[t.jsx(nn,{id:"playground-input",value:S,onChange:de=>N(de.target.value),rows:A?7:4,placeholder:ft,className:A0}),W&&t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[Z6(W,"start",E==="workflow"?"workflow":"agent"),W.fields.length>0&&t.jsxs(t.Fragment,{children:[" Fields: ",W.fields.map((de,Ue)=>t.jsxs("span",{title:de.note,children:[Ue?", ":"",t.jsx("span",{className:"text-foreground",children:de.name})]},de.name)),"."]})]})]}),R==null?void 0:R.fields.map(([de,Ue])=>t.jsxs("div",{"data-field":`input.${de}`,children:[t.jsx(NE,{field:Ue,label:sh(de,Ue),help:nm(Ue),value:L[de]??"",onChange:Xe=>ot(de,Ue,Xe)}),t.jsx(Oo,{issues:me(de),words:Xe=>kE(Xe,de,Ue)})]},de)),!j&&t.jsx(ja,{name:"file_ids",note:cf.file_ids,children:t.jsx(R0,{attachments:oe,limits:g})}),t.jsx(ja,{name:"revision",note:"Empty runs the current revision.",children:t.jsx(Et,{label:"Revision",value:$,onChange:_,className:"w-full",options:[{value:"",label:"The current revision"},...n.map(de=>({value:de.revision,label:`rev ${de.version}${de.current?" (current)":""}${de.note?`: ${de.note}`:""}`}))]})}),!j&&t.jsx(ja,{name:"effort",note:"How hard the model thinks. Empty uses the agent's own.",children:t.jsx(Et,{label:"Effort",value:H,onChange:K,className:"w-full",options:["",...s].map(de=>({value:de,label:de||"Agent default"}))})}),E==="agentic"&&!j&&t.jsx(ja,{htmlFor:"playground-repo",name:"repo",note:cf.repo,error:!Se.ok&&Se.field==="repo"?Se.message:void 0,children:t.jsx(Pe,{id:"playground-repo",value:F,onChange:de=>z(de.target.value),placeholder:"owner/name"})}),E==="agentic"&&!j&&t.jsxs(ja,{htmlFor:"playground-cap",name:"max_cost_usd",note:"A spend cap in dollars; empty means none.",error:!Se.ok&&Se.field==="max_cost_usd"?Se.message:void 0,children:[t.jsx(Pe,{id:"playground-cap",value:U,onChange:de=>G(de.target.value),inputMode:"decimal",placeholder:"e.g. 0.50",className:A0}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:t.jsx(zC,{})})]})]})]}),t.jsxs("footer",{className:"flex shrink-0 flex-wrap items-center justify-between gap-3 border-t px-5 py-3 md:px-6",children:[t.jsx("span",{className:"text-small text-muted-foreground",children:"Sends a real request to this server."}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[t.jsx(sn,{label:"Use your agent",prompt:DL(r,h,tt),disabled:$t||!Se.ok||!h||oe.busy}),t.jsxs(B,{variant:"primary",size:"lg",onClick:nt,disabled:$t||!Se.ok||!c||Me||!h||oe.busy,title:oe.busy?"Waiting for the files to be sent":void 0,children:[t.jsx(Vo,{"aria-hidden":!0})," ",Me?"Sending":"Send request"]})]})]})]}),t.jsxs("section",{"aria-label":"Code and response",className:ie("flex min-h-0 flex-col",!ge&&"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:ie("flex flex-wrap items-center justify-between gap-x-3 gap-y-2 px-5 md:px-6",ge?"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:ie("flex gap-4 text-body",!ge&&"hidden"),children:[t.jsx("button",{type:"button","aria-pressed":Q==="code",onClick:()=>re("code"),className:ie("border-b pb-1",Q==="code"?"border-primary":"border-transparent text-muted-foreground"),children:"Code"}),t.jsxs("button",{type:"button","aria-pressed":Q==="response",onClick:()=>re("response"),disabled:!fe,className:ie("border-b pb-1 disabled:opacity-45",Q==="response"?"border-primary":"border-transparent text-muted-foreground"),children:["Response",fe&&t.jsx("span",{className:ie("ml-2 font-mono max-sm:hidden",fe.status<300?"text-success-text":"text-destructive-text"),children:fe.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":ge,"aria-controls":xe,onClick:()=>ye(de=>!de),children:[ge?t.jsx(ST,{"aria-hidden":!0}):t.jsx(fm,{"aria-hidden":!0})," ",ge?"Hide code and response":"Show code and response"]})})]}),t.jsx("div",{id:xe,className:ie("flex min-h-0 flex-1 flex-col",!ge&&"hidden"),children:Q==="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":te===de,onClick:()=>he(de),className:ie("-mb-px border-b-2 py-2.5",te===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(it))},children:t.jsx(Ka,{"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:it}),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."})]}):fe&&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:fe.status<300?"text-success-text":"text-destructive-text",children:fe.status})," ",t.jsxs("span",{className:"text-muted-foreground",children:[fe.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(aU,{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}`))})]}),fe.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(fe.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(fe.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(fe.body,null,2)}),fe.runId&&t.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(fe.runId),className:"caps flex items-center justify-between border-t px-5 py-4 text-small text-primary-text hover:bg-accent md:px-6",children:["Open this run ",t.jsx(Dx,{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(cf).map(([de,Ue])=>t.jsxs("div",{children:[t.jsx("dt",{className:"font-mono text-body",children:de}),t.jsx("dd",{className:"text-small text-muted-foreground",children:Ue})]},de))}),t.jsxs("code",{className:"text-small",children:["/v2/agents/","{agent_id}","/runs"]})]})}const A0="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 ja({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 O0="h-11 w-full border bg-card px-3 text-lead outline-none focus:border-primary",uU=e=>`'${e.replaceAll("'","'\\''")}'`;function fU({v2:e,origin:n,agentId:s,filter:r={}}){const[o,i]=p.useState(r.status??""),[c,d]=p.useState(!!r.archived),[u,f]=p.useState(50),[g,y]=p.useState(""),[x,h]=p.useState("code"),[v,b]=p.useState("curl"),[j,k]=p.useState(null),[E,S]=p.useState(null),[N,$]=p.useState(!1),[_,P]=p.useState(!1),O=p.useRef(0);p.useEffect(()=>(O.current++,i(r.status??""),d(!!r.archived),y(""),S(null),k(null),$(!1),()=>{O.current++}),[s,r.status,r.archived]);const M={...o?{status:o}:{},...c?{archived:!0}:{}},R=s?`/v2/agents/${encodeURIComponent(s)}/runs`:"/v2/runs",A=new URLSearchParams({limit:String(u)});g&&A.set("cursor",g),o&&A.set("status",o),c&&A.set("archived","true");const L=`${n}${R}?${A}`,D=v==="curl"?`curl -X GET ${uU(L)} \\
676
- -H "Authorization: Bearer $AGENTRUN_API_KEY"`:`const response = await fetch(${JSON.stringify(L)}, {
677
- method: "GET",
678
- headers: { Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\` },
679
- });
680
- console.log(response.status, await response.json());`,W=`${Im(n,s)}
681
-
682
- Prepared read-only request: GET ${L}
683
- Use exactly this agent scope, status, archive selection, page size and cursor. Do not broaden the query or issue writes. Show the results and links to relevant runs. Follow next_cursor only when more results are needed, keeping the same filters.`,q=()=>{O.current++,y(""),S(null),k(null),P(!1)},H=async(K=g)=>{if(N)return;const U=++O.current;$(!0),S(null),k(null),y(K),P(!1);const G=performance.now();try{const F=s?await e.listAgentRuns(s,u,K||void 0,M):await e.listRuns(u,K||void 0,M);if(O.current!==U)return;S(F),k({status:200,ms:performance.now()-G,body:F})}catch(F){if(O.current!==U)return;k(Cb(F,performance.now()-G))}finally{O.current===U&&($(!1),h("response"))}};return t.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-2",children:[t.jsxs("section",{className:"flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",children:[t.jsx("header",{className:"flex h-12 shrink-0 items-center border-b px-6",children:t.jsx("span",{className:"text-lead font-semibold",children:"Request"})}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto p-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"List runs"}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:"Inspect server-run sessions and imported history. This request only reads data."})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Agent"}),t.jsx(Pe,{className:O0,value:s??"All agents",readOnly:!0})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Status"}),t.jsx(Et,{label:"Run status",value:o,disabled:N,onChange:K=>{i(K),q()},options:[{value:"",label:"All statuses"},...rm.map(K=>({value:K,label:K.replaceAll("_"," ")}))]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Archive"}),t.jsx(Et,{label:"Archived runs",value:String(c),disabled:N,onChange:K=>{d(K==="true"),q()},options:[{value:"false",label:"Current runs"},{value:"true",label:"Archived runs"}]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Page size"}),t.jsx(Et,{label:"Page size",value:String(u),disabled:N,onChange:K=>{f(Number(K)),q()},options:[10,25,50,100].map(K=>({value:String(K),label:String(K)}))})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Cursor"}),t.jsx(Pe,{"aria-label":"Cursor",className:`${O0} font-mono text-small`,value:g,disabled:N,placeholder:"First page",onChange:K=>{O.current++,y(K.target.value),S(null),k(null)}})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t p-4",children:[t.jsx(sn,{label:"Use your agent",prompt:W}),t.jsxs(B,{variant:"primary",disabled:N,onClick:()=>void H(),children:[t.jsx(Vo,{"aria-hidden":!0}),N?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(K=>t.jsx("button",{onClick:()=>h(K),className:ie("h-12 border-b text-small capitalize",x===K?"border-primary":"border-transparent text-muted-foreground"),children:K},K)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{var K;(K=navigator.clipboard)==null||K.writeText(D).then(()=>P(!0),()=>P(!1))},children:t.jsx(Ka,{"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(K=>t.jsx("button",{onClick:()=>b(K),className:ie("border-b text-small",v===K?"border-primary":"border-transparent text-muted-foreground"),children:K==="curl"?"cURL":"JavaScript"},K))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children: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(K=>t.jsx("li",{children:t.jsxs("a",{className:"flex items-center gap-3 p-3 text-lead hover:bg-accent",href:`#/runs/${encodeURIComponent(K.run_id)}`,children:[t.jsx(Cl,{run:K}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:K.title||K.run_id}),t.jsx(fr,{className:"size-3.5 shrink-0","aria-hidden":!0})]})},K.run_id))}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"No runs match this request."}),E.next_cursor&&t.jsx(B,{size:"sm",disabled:N,onClick:()=>void 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 mU({v2:e,origin:n,operation:s,agentId:r,draft:o,harnesses:i=[]}){const c=s==="edit-agent",d=X8(o??null),[u,f]=p.useState(null),[g,y]=p.useState(null),[x,h]=p.useState(void 0),[v,b]=p.useState(d??sm("")),[j,k]=p.useState(JSON.stringify(d??sm(""),null,2)),[E,S]=p.useState(j),N=DC(j!==E),[$,_]=p.useState("form"),[P,O]=p.useState("code"),[M,R]=p.useState("curl"),[A,L]=p.useState(null),[D,W]=p.useState(null),[q,H]=p.useState(null),[K,U]=p.useState(!1),[G,F]=p.useState(!1),[z,Y]=p.useState(0),[se,Q]=p.useState(!1);p.useEffect(()=>{if(!c)return;if(!r){L("Choose an agent from Connected agents to edit its definition.");return}let oe=!0;return f(null),h(void 0),L(null),e.getAgent(r).then(({agent:Se,etag:tt})=>{if(!oe)return;f(Se),y(tt);const Ae={definition:{...Se.definition,version:Se.revisions+1}},it=JSON.stringify(Ae,null,2);b(Ae),k(it),S(it),W(null),F(!1)}).catch(Se=>{oe&&L(String(Se instanceof Error?Se.message:Se))}),()=>{oe=!1}},[e,c,r,z]);const re=(oe,Se)=>{const tt={...v.definition,[oe]:oe==="model"?Se.trim():Se};oe==="model"&&!Se.trim()&&!c&&delete tt.model;const Ae={...v,definition:tt};b(Ae),k(JSON.stringify(Ae,null,2))};let te=v,he=null;if($==="json")try{const oe=JSON.parse(j);!bc(oe)||!bc(oe.definition)?he="Include a definition object in the request.":te=oe}catch{he="Enter valid JSON before sending the request."}!he&&te.note!==void 0&&typeof te.note!="string"&&(he="note must be a string.");for(const oe of["description","instructions","harness","model"])!he&&te.definition[oe]!==void 0&&typeof te.definition[oe]!="string"&&(he=`definition.${oe} must be a string.`);!he&&typeof te.definition.name!="string"&&(he="Give this agent a name.");const ge=!he;!he&&!te.definition.name.trim()&&(he="Give this agent a name."),!he&&!te.definition.workflow&&(typeof te.definition.instructions!="string"||!te.definition.instructions.trim())&&(he="Add instructions for this agent.");const ye=te;if(!he&&c&&u){const oe=bc(te.definition.workflow),Se=Object.keys(u.definition).filter(Ae=>!Object.hasOwn(te.definition,Ae));for(const Ae of["id","name","description"])!he&&te.definition[Ae]!==u.definition[Ae]&&(he=`definition.${Ae} is fixed when the agent is created. Restore its current value.`);for(const Ae of["native","sdk"])!he&&u.definition[Ae]!==void 0&&Se.includes(Ae)&&(he=`Cannot remove definition.${Ae} here. Edit the original source configuration with your agent.`);if(!he&&!oe)for(const Ae of["input_schema","output_schema"])Se.includes(Ae)&&(he=`Cannot remove definition.${Ae}: the API keeps an omitted schema. Restore it or supply a replacement schema.`);!he&&Se.includes("harness")&&(he='Cannot remove definition.harness: the API keeps it. Select an explicit harness, such as "pi" for the default.'),!he&&(u.definition.computer!==void 0||u.definition.place!==void 0)&&!Object.hasOwn(te.definition,"computer")&&!Object.hasOwn(te.definition,"place")&&(he='Cannot remove definition.computer and definition.place together: the API keeps the setting. Set computer to {"kind":"none"} or place to {"mode":"runner"} explicitly.');const tt=bc(te.skills)&&Object.keys(te.skills).length===0;if(!he&&!Object.hasOwn(te.definition,"skills")&&!tt&&(u.definition.skills.length>0||bc(te.skills)&&Object.keys(te.skills).length>0)&&(he="Cannot remove definition.skills while skill files are retained or supplied. Give their skill names, or use definition.skills: [] with skills: {} to clear them."),!he){const Ae=Object.fromEntries(Se.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:it,...$t}=gd(u,{...Ae,...te.definition},te.note??""),nt=te.skills!==void 0&&!Qi(te.skills,x);it&&!nt&&(he="Change the definition before saving a revision."),nt&&($t.definition.version=u.revisions+1),te={...te,...$t}}}c&&u&&!g&&(he="This server did not provide a revision ETag. Reload the current revision before editing.");const xe=c?"PUT":"POST",fe=c?`/v2/agents/${encodeURIComponent(r??"")}/definition`:"/v2/agents",De=`${n}${fe}`,Fe=JSON.stringify(te,null,2),Le=oe=>`'${oe.replaceAll("'","'\\''")}'`,Ee={"Content-Type":"application/json",...c&&g?{"If-Match":g}:{}},ae=M==="curl"?`curl -X ${xe} ${Le(De)} \\
684
- -H "Authorization: Bearer $AGENTRUN_API_KEY" \\
685
- ${Object.entries(Ee).map(([oe,Se])=>` -H ${Le(`${oe}: ${Se}`)} \\
686
- `).join("")} -d ${Le(Fe)}`:`const response = await fetch(${JSON.stringify(De)}, {
687
- method: ${JSON.stringify(xe)},
688
- headers: {
689
- Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
690
- ${Object.entries(Ee).map(([oe,Se])=>` ${JSON.stringify(oe)}: ${JSON.stringify(Se)},`).join(`
691
- `)}
692
- },
693
- body: JSON.stringify(${Fe}),
694
- });
695
- console.log(response.status, await response.json());`,$e=es(u==null?void 0:u.definition),ot=c&&(!!(u!=null&&u.definition.native)||!!$e),me=ot&&u?Wo(n,u.agent_id,!!u.definition.native,$e==null?void 0:$e.runtime):`${c?Wo(n,r??""):Mm(n)}
696
-
697
- Prepared request: ${xe} ${De}${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
- ${Fe}`,Me=!he&&!A&&(!c||!!u)&&!K&&!G,Ze=async()=>{if(!Me)return;U(!0),H(null);const oe=performance.now();try{const Se=c?await e.updateDefinition(r,te,g):{agent:await e.createAgent(te),etag:null};H(Se.agent.agent_id),S(j),W({status:c?200:201,ms:performance.now()-oe,body:Se.agent}),c?(f(Se.agent),y(Se.etag),te.skills!==void 0&&h(te.skills)):F(!0)}catch(Se){const tt=Cb(Se,performance.now()-oe);W(tt),!c&&(tt.status===0||tt.status>=500)&&F(!0)}finally{U(!1),O("response")}},bt=t.jsxs(hv,{open:N.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:N.leave,onCancel:N.stay,children:[c?"Your changes to this agent are not saved.":"This new agent is not saved yet."," Leave drops them; Stay keeps them here."]});return A?t.jsxs(t.Fragment,{children:[bt,t.jsxs("div",{className:"m-6 border p-5",role:"alert",children:[t.jsx("p",{children:A}),r&&t.jsx(B,{className:"mt-3",onClick:()=>Y(oe=>oe+1),children:"Reload agent"})]})]}):c&&!u?t.jsxs(t.Fragment,{children:[bt,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(!ge)return;b(ye)}_(oe)},className:ie("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(nn,{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(Mi,{name:"Name",children:t.jsx(Pe,{value:v.definition.name,readOnly:c,onChange:oe=>re("name",oe.target.value),className:Li})}),t.jsx(Mi,{name:"Description",children:t.jsx(Pe,{value:v.definition.description??"",readOnly:c,onChange:oe=>re("description",oe.target.value),className:Li})}),v.definition.workflow?t.jsx(Mi,{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(Mi,{name:"Instructions",children:t.jsx(nn,{value:v.definition.instructions??"",rows:5,onChange:oe=>re("instructions",oe.target.value),className:Li})}),t.jsx(Mi,{name:"Harness",children:t.jsx(Et,{label:"Harness",value:v.definition.harness??"pi",onChange:oe=>re("harness",oe),options:[...new Set([v.definition.harness??"pi",...i.map(oe=>oe.id)])].map(oe=>{var Se;return{value:oe,label:`${oe}${((Se=i.find(tt=>tt.id===oe))==null?void 0:Se.available)===!1?" (not set up)":""}`}})})}),t.jsx(Mi,{name:"Model",children:t.jsx(Pe,{value:v.definition.model??"",onChange:oe=>re("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 →"})]}),he&&t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:he}),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(sn,{label:"Use your agent",prompt:me,disabled:!ot&&!!he}),t.jsxs(B,{variant:"primary",onClick:()=>void Ze(),disabled:!Me,children:[t.jsx(Vo,{"aria-hidden":!0}),K?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(oe=>t.jsx("button",{onClick:()=>O(oe),className:ie("h-12 border-b text-small capitalize",P===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(ae).then(()=>Q(!0),()=>Q(!1))},children:t.jsx(Ka,{"aria-hidden":!0})}),t.jsx("span",{role:"status",className:"sr-only",children:se?"Code copied":""})]}),P==="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:()=>R(oe),className:ie("border-b text-small",M===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:ae})]}):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)}),q&&t.jsxs("a",{className:"inline-flex items-center gap-2 text-lead text-primary-text",href:dn(q),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&&!q&&t.jsxs("p",{role:"alert",className:"text-lead",children:["The creation request may have succeeded. Check ",t.jsx("a",{href:"#/agents",className:"text-primary-text underline",children:"Connected agents"})," before sending another creation request."]})]}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"Send a request to see its response."})})]}),bt]})}function Mi({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 hU=[{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"}],Go="p-5 md:p-8",ti="mb-6 max-w-prose",ni="[&>:not(section)]:mb-6";function Tr({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 pU({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:$S,children:hU.filter(r=>n.includes(r.id)).map(r=>t.jsx("a",{href:`#/settings/${r.id}`,"aria-current":e===r.id?"page":void 0,className:_S(e===r.id),children:r.label},r.id))}),t.jsx("div",{className:"min-h-0 flex-1",children:s})]})}async function ah(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 sa({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 gU={anthropic:"claude.ai",openai:"chatgpt.com",openrouter:"openrouter.ai",parallel:"parallel.ai",monid:"monid.ai",browserbase:"browserbase.com",kernel:"kernel.sh",typesafe:"typesafe.ai"},xU={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"},vU=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function bU({id:e,className:n}){const[s,r]=p.useState(!1),o=gU[e],i=xU[e];return o&&!s?t.jsx("img",{"data-provider-icon":e,src:vU(o),alt:"",width:16,height:16,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0),className:ie("size-4 shrink-0 object-contain",n)}):i?t.jsx("svg",{"data-provider-mark":e,viewBox:"0 0 24 24",fill:"currentColor",className:ie("size-4 shrink-0",n),"aria-hidden":!0,children:t.jsx("path",{d:i})}):t.jsx(La,{className:ie("size-4 shrink-0 text-muted-foreground",n),"aria-hidden":!0})}const yU=/^(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,wU=40;function jU(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&&yU.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>wU)?[]:i.map(c=>/\s/.test(c)?c[0].toUpperCase()+c.slice(1):c)}function kU(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 BE=e=>e.filter(n=>!n.imported_from).length,NU=864e5;function SU(e,n){return e.some(s=>!s.imported_from)||n.some(s=>s.source==="live"&&s.runs>0)}function Rd(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 CU(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 EU(e,n){let s=!1,r;const o=()=>{s||e().catch(()=>{}).finally(()=>{s||(r=setTimeout(o,n))})};return o(),()=>{s=!0,clearTimeout(r)}}const GE=e=>e.pending!=null&&e.pending.kind!=="stopped",$U=e=>e.status==="input_required"&&e.state!=="waiting"&&!GE(e),_U=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function P0(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 _U.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 ih({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:ie("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",f&&"opacity-60"),children:[t.jsxs("span",{children:[Qf(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:WF[e.source]}),e.changed_at&&t.jsxs("span",{className:"text-muted-foreground",children:["Changed ",Rd(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 L0={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-…"}},TU=e=>Object.prototype.hasOwnProperty.call(L0,e)?L0[e]:void 0,RU={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."},M0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function I0(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 AU="can't be opened: paste it again",OU=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],Ex="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function PU({v2:e,onChange:n,writable:s,whyNot:r="sign_in",plan:o,harnesses:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),[g,y]=p.useState(null),[x,h]=p.useState(null),v=p.useRef(0),b=()=>{const _=++v.current;e.listToolKeys().then(P=>{_===v.current&&(d(P),f(null))}).catch(P=>{_===v.current&&f(M0(P))})};p.useEffect(b,[e]);const j=_=>y(P=>P===_?null:P),k=_=>{j(_),b(),n==null||n()},E=(_,P,O,M)=>{h({id:_,title:P,error:M0(O)}),O instanceof ze&&O.code==="key_set_by_server"&&(j(M),b())};if(!c)return u?t.jsx(z0,{error:u,onRetry:b}):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=OU.map(_=>({..._,keys:c.keys.filter(P=>P.kind==="model"==(_.kind==="model"))})).filter(_=>_.keys.length),$=_=>t.jsx(LU,{tool:_,writable:s,again:!!S&&_.fields.some(P=>P.stored_unreadable||S.fields.includes(P.name)),open:(g==null?void 0:g.id)===_.id?g.mode:null,problem:(x==null?void 0:x.id)===_.id?x:null,onOpen:P=>{y(P?{id:_.id,mode:P}:null),h(null)},onSave:async P=>{const O=g;try{await e.saveToolKey(_.id,P)}catch(M){return M instanceof ze&&M.status===422?M:(E(_.id,"The key was not saved",M,O),null)}return k(O),null},onRemove:async()=>{const P=g;try{await e.removeToolKey(_.id)}catch(O){E(_.id,"The key was not removed",O,P);return}k(P)}},_.id);return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Go,children:[t.jsxs("div",{className:ti,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:ni,children:[!s&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:ei[r]}),u&&t.jsx(z0,{inline:!0,error:u,onRetry:b}),S&&t.jsxs(vt,{tone:"warning",role:"alert","aria-label":"Keys to enter again",title:"Enter these keys again",children:[t.jsx("p",{children:RU[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(Tr,{label:_.label,title:_.label,note:_.kind==="model"?t.jsx("p",{children:Ex}):void 0,children:t.jsxs("ul",{className:"border",children:[_.kind==="model"&&o,_.keys.map($)]})},_.label)),i&&t.jsx(WC,{harnesses:i})]})]})})}function z0({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 LU({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(b=>Qf(b.name)===v.name),g=v=>e.fields.find(b=>b.name===Qf(v.name)),y=e.fields.filter(v=>{var b;return((b=f(v))==null?void 0:b.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(bU,{id:e.id,className:"mt-1"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:e.label}),t.jsx(Ne,{tone:x===e.secrets.length?"success":"plain",children:x===e.secrets.length?"set":x?`${x} of ${e.secrets.length} set`:"not set"}),s&&t.jsx(Ne,{tone:"warning",children:"enter again"})]}),t.jsxs("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:[e.kind==="model"?"Model provider":`Unlocks ${e.unlocks.join(", ")}`,e.harnesses.length>0&&` · Harnesses ${e.harnesses.length===1?`${e.harnesses[0]} only`:e.harnesses.join(", ")}`]}),I0(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:I0(e.label,e.check)}),t.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(v=>{var b;return t.jsx(ih,{field:v,stateSaid:e.secrets.length===1,writable:n&&r===null,note:(b=g(v))!=null&&b.stored_unreadable?AU:void 0,onPaste:()=>void ah(()=>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)})}),!y.length&&t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"Set when the server starts, and that one wins: change it where the server is started."})]})]}),r==="edit"&&t.jsx(qE,{tool:e,fields:y,onSave:c,onCancel:()=>i(null)}),r==="remove"&&t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove the ",e.label," key saved here?",e.secrets.some(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(sa,{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),y=()=>n.some(b=>{var j,k;return(k=(j=o.current)==null?void 0:j.elements.namedItem(b.name))==null?void 0:k.value}),x=()=>{var b;(b=o.current)==null||b.reset(),c(!1)},h=async b=>{var N,$;b.preventDefault();const j={};for(const _ of n){const P=($=(N=o.current)==null?void 0:N.elements.namedItem(_.name))==null?void 0:$.value;P&&(j[_.name]=P)}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 P=_.field.startsWith("values.")?_.field.slice(7):null;P&&n.some(O=>O.name===P)?E[P]=_.message:S.push(_.message)}g({fields:E,message:S.length?S.join(" "):Object.keys(E).length?null:k.message})},v=TU(e.id);return t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:b=>void h(b),onInput:()=>c(!!y()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e.label} key`,children:[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(b=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:b.name}),b.set&&t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"Saved already. A new value replaces it; leave it empty to keep it."}),t.jsx(Pe,{type:"password",name:b.name,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:v&&n.length===1?v.placeholder:void 0}),(f==null?void 0:f.fields[b.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[b.name]})]},b.name)),(f==null?void 0:f.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f.message}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!i||d,children:d?"Saving":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{x(),r()},children:"Cancel"})]})]})}const Ad=p.createContext(null);function D0({connection:e,children:n}){return t.jsx(Ad.Provider,{value:e,children:n})}const MU={state:"online"},IU=()=>()=>{},F0=()=>MU;function Eb(){const e=p.useContext(Ad);return p.useSyncExternalStore(e?e.subscribe:IU,e?e.link:F0,F0)}function KE(e){const n=p.useContext(Ad),s=p.useRef(e);s.current=e,p.useEffect(()=>n==null?void 0:n.onResume(()=>s.current()),[n])}function VE(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 zU(){const e=p.useContext(Ad),n=Eb(),s=VE(n.state==="offline"?n.retryAt:null);return!e||n.state==="online"?null:n.state==="resumed"?t.jsxs(vt,{bar:!0,tone:"success",icon:Yo,"data-connection":"resumed",children:[t.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):t.jsxs(vt,{bar:!0,tone:"warning",icon:IN,"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 DU(){const e=p.useContext(Ad),n=Eb(),s=VE(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(IN,{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 FU=(e,n)=>e.flatMap(s=>s.tools.flatMap(r=>{var o;return(o=r.permissions)!=null&&o.length&&r.default_permission?[{name:W2(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"}:{}}]:[]})),U0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function UU({v2:e,choices:n,gates:s=[],harnesses:r,mcp:o=!1,onSaved:i,onOpen:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),y=()=>{o&&(g(null),e.listMcpServers().then(G=>g(G.servers),()=>g("failed")))};p.useEffect(y,[e,o]);const[x,h]=p.useState(null),[v,b]=p.useState(null),[j,k]=p.useState(!1),[E,S]=p.useState(null),N=p.useRef(0),$=()=>{const G=++N.current;e.toolSettings().then(F=>{G===N.current&&(u(F),h(null))},F=>{G===N.current&&h(U0(F))})};p.useEffect($,[e]);const[_,P]=p.useState("reading"),O=()=>{P("reading"),Promise.resolve(c==null?void 0:c()).then(G=>P(G===!1?"failed":"landed"))},M=()=>{$(),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 R=px(d,n),A=E?E(R):R,L=IC(n,[...s,...Array.isArray(f)?FU(f,s.some(G=>G.ask_needs==="password")):[]]),D=G=>{var z;const F=Ho(G);return F?(z=A[`mcp:${F.server}/*`])==null?void 0:z.permission:void 0},W=Object.entries(A).filter(([,G])=>(G==null?void 0:G.pin)||(G==null?void 0:G.pin_broken)),q=G=>{var z;const F=s.find(Y=>Y.name===G);return!F||(((z=A[G])==null?void 0:z.permission)??F.default_permission)===F.permission},{byTool:H,rest:K}=_C((v==null?void 0:v.fields)??{},"",L.map(G=>G.name)),U=async G=>{var se;const F=E?Q=>G(E(Q)):G;k(!0),b(null);const z=++N.current;let Y;try{Y=await e.toolSettings()}catch{S(()=>F),b({fields:{},error:null,unread:!0}),k(!1);return}try{const Q=await e.saveToolSettings(F(px(Y,n)));S(null),z===N.current&&(u(Q),h(null)),i()}catch(Q){b(Q instanceof ze&&Q.status===422&&((se=Q.fields)!=null&&se.length)?{fields:Object.fromEntries(Q.fields.map(re=>[re.field,re.message])),error:null}:{fields:{},error:U0(Q)})}k(!1)};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Tools"}),t.jsxs("div",{className:"mt-2 grid gap-x-10 gap-y-2 xl:grid-cols-2",children:[t.jsx("p",{className:"text-lead text-muted-foreground",children:"This server's provider for each tool that has a choice, and what it resolves to on each harness. A change is saved at once and applies to every run launched from then on. An agent with a provider of its own keeps it."}),s.length>0&&t.jsxs("p",{className:"text-lead text-muted-foreground",children:["Each tool's permission: ",t.jsx("span",{className:"font-mono text-body",children:"allow"})," runs it, ",t.jsx("span",{className:"font-mono text-body",children:"ask"})," makes the run wait for your approval at each call, ",t.jsx("span",{className:"font-mono text-body",children:"deny"})," refuses it and tells the agent why. A permission applies at the next call, in runs already going too. An agent's own allow or ask takes the place of this server's; deny here refuses it for every agent."]})]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("section",{"aria-label":"This server's providers",children:[L.length?t.jsx(cb,{label:"This server's tool settings",rows:L,settings:A,fallbackOf:G=>G.default_provider,issues:H,busy:j,onEdit:G=>void U(G),permissionFallbackOf:G=>D(G.name)??G.default_permission,refused:(G,F)=>F==="deny",resolvesOf:(G,F)=>F===G.provider&&q(G.name)?t.jsx(CF,{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:M,disabled:j,size:"xs",className:"ml-1",children:"Retry"})]})}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"This server offers no tool with a choice of provider."}),f==="failed"&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"alert",children:["The MCP servers' tools could not be read, so they are not listed. ",t.jsx(B,{type:"button",size:"xs",className:"ml-1",onClick:y,disabled:j,children:"Retry"})]}),K.map(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(sa,{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 U(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:M,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,F])=>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(xx,{setting:F})]},G))})]})]})]})})}function WU(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 W0={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."},HU=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(W0,e.reason)?W0[e.reason]:"The connection didn't finish. Try again.";function BU(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 GU({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 qU({v2:e,returned:n}){const[s,r]=p.useState(void 0),[o,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(!1),[g,y]=p.useState(null),[x,h]=p.useState(null),[v,b]=p.useState(null),[j,k]=p.useState(!1),[E,S]=p.useState(null),N=p.useRef(!1),$=p.useRef(null),_=p.useCallback(async()=>{try{const R=await e.githubConnection();r(R.connected?R:null),i(null)}catch(R){i(R instanceof Error?R.message:String(R))}},[e]);p.useEffect(()=>{_()},[_]),p.useEffect(()=>{n&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),p.useEffect(()=>{var R;g&&((R=$.current)==null||R.submit())},[g]);const P=async()=>{var R;if(!N.current){N.current=!0,f(!0),h(null),b(null),S(null);try{const A=await e.connectGitHub(c.trim()||void 0),L=BU(A.action,dr);if(!L){h("GitHub's address didn't look right, so nothing was sent."),N.current=!1,f(!1);return}y({action:L,manifest:JSON.stringify(A.manifest)})}catch(A){if(N.current=!1,f(!1),h(A instanceof Error?A.message:String(A)),A instanceof ze&&A.code==="github_wrong_origin"){const L=(R=A.details)==null?void 0:R.public_url;b(typeof L=="string"&&dr(L)||null)}A instanceof ze&&A.code==="github_already_connected"&&_()}}},O=async()=>{k(!1),f(!0),h(null),b(null);try{S(await e.disconnectGitHub()),r(null)}catch(R){R instanceof ze&&(R.status===404||R.code==="github_not_connected")?await _():h(R instanceof Error?R.message:String(R))}finally{f(!1)}},M=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:Go,children:[t.jsxs("div",{className:ti,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:ni,children:[n&&t.jsx("p",{"aria-label":"From GitHub",role:"status",className:ie("border p-4 text-lead",n.ok?"border-success/50 bg-success/5":"border-warning/50 bg-warning/5 text-warning-text"),children:HU(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(GU,{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(Tr,{title:"Connection",children:[s===void 0&&!o&&t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading..."}),s===null&&t.jsxs("section",{"aria-label":"Connect GitHub",className:"border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[t.jsxs("label",{className:"flex min-w-[240px] flex-1 flex-col gap-1 text-body",children:[t.jsx("span",{className:"text-muted-foreground",children:"Organization (optional): the App is made under it"}),t.jsx(Pe,{name:"org",value:c,onChange:R=>d(R.target.value),disabled:u,placeholder:"your-org",className:"h-9 w-auto"})]}),t.jsxs(B,{type:"button",variant:"solid",onClick:()=>void P(),disabled:u,children:[t.jsx(aj,{"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(aj,{className:"size-4 text-muted-foreground","aria-hidden":!0}),M?t.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"font-mono underline underline-offset-2",children:s.slug}):t.jsx("span",{className:"font-mono",children:s.slug}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["App ",s.app_id]})]}),s.installations.length?t.jsx("ul",{"aria-label":"Installations",className:"mt-3 space-y-1 font-mono text-body",children:s.installations.map(R=>t.jsx("li",{children:R.account},R.id))}):t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"Not installed on any account yet."}),j?t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2 text-body",role:"alertdialog","aria-label":"Disconnect GitHub?",children:[t.jsx("span",{children:"Disconnect GitHub? Every GitHub trigger turns off."}),t.jsx(B,{type:"button",variant:"destructive",disabled:u,onClick:()=>void 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 KU=8,VU={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function YU({v2:e,signIn:n,add:s,writable:r,whyNot:o="sign_in",open:i=d=>location.assign(d),choices:c=[]}){var G,F,z,Y,se;const[d,u]=p.useState(null),[f,g]=p.useState(null),[y,x]=p.useState(!1),[h,v]=p.useState(null),[b,j]=p.useState(null),k=(s==null?void 0:s.preset)==="composio"?s:void 0,[E,S]=p.useState(s&&!k?{add:s}:null),[N,$]=p.useState(k&&r?k:!1),[_,P]=p.useState(null),O=s?JSON.stringify(s):"",M=p.useRef(O);p.useEffect(()=>{if(O===M.current)return;M.current=O;const Q=O?JSON.parse(O):void 0;S(Q&&Q.preset!=="composio"?{add:Q}:null),$((Q==null?void 0:Q.preset)==="composio"&&r?Q:!1)},[O]);const R=p.useRef(0),A=p.useRef(null),L=()=>{const Q=++R.current;e.listMcpServers().then(re=>{Q===R.current&&(u(re.servers),j(null))},re=>{Q===R.current&&j(ro(re))})};p.useEffect(L,[e]),p.useEffect(()=>{e.toolSettings().then(g,()=>g(null))},[e]);const D=p.useRef(!1),W=async(Q,re)=>{if(!D.current){D.current=!0,x(!0),v(null);try{const te=await e.toolSettings();g(await e.saveToolSettings(re(px(te,c)))),L()}catch(te){v({server:Q,problem:ro(te)})}D.current=!1,x(!1)}},q=p.useRef(null);s&&d&&((G=q.current)==null?void 0:G.key)!==O&&(q.current={key:O,name:YE(s.name,d)});const H=Q=>{var re;return((re=q.current)==null?void 0:re.key)===JSON.stringify(Q)&&q.current.name!==Q.name?{...Q,toolkit:Q.toolkit??Q.name,name:q.current.name}:Q},K=d!==null||b!==null;p.useEffect(()=>{n&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[n]);const U=async(Q,re)=>i((await e.startMcpSignIn(Q,re)).authorization_url);return t.jsx("div",{ref:A,className:"h-full overflow-auto",children:t.jsxs("div",{className:Go,children:[t.jsxs("div",{className:ti,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:ni,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: ${fI(n.error)}.`}),!r&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:ei[o]}),_&&t.jsx("p",{className:`border p-4 text-body ${_.removed?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:_.note}),b&&t.jsx(vt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:L,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The MCP servers could not be read. ",b.text]})}),t.jsxs(Tr,{title:"Servers",aside:!E&&!N&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",disabled:!r,onClick:()=>$(!0),children:"Add from Composio"}),t.jsx(B,{size:"sm",variant:"primary",onClick:()=>S({}),children:"Add server"})]}),children:[E&&(!E.add||K)&&t.jsx(lW,{v2:e,saved:E.saved,add:E.add&&H(E.add),given:E.problem,writable:r,taken:d,signIn:U,onCancel:()=>S(null),onSaved:(Q=>re=>{re&&P(re),S(te=>te===Q?null:te),L()})(E)},`${((F=E.saved)==null?void 0:F.name)??"new"}|${((z=E.add)==null?void 0:z.name)??""}|${((Y=E.add)==null?void 0:Y.auth)??""}|${((se=E.add)==null?void 0:se.preset)??""}`),N&&(typeof N!="object"||K)&&t.jsx(rW,{v2:e,add:typeof N=="object"?H(N):void 0,onClose:()=>$(!1),onSaved:L},typeof N=="object"?O:"new"),d&&(d.length?t.jsx("ul",{className:"border",children:d.map(Q=>t.jsx(JU,{v2:e,server:Q,settings:f,settingsBusy:y,settingsProblem:(h==null?void 0:h.server)===Q.name?h.problem:null,onSettings:re=>void W(Q.name,re),writable:r&&!E,signIn:U,onChange:re=>S({saved:Q,...re?{problem:re}:{}}),onPaste:()=>void ah(()=>S({saved:Q}),()=>{var re;return((re=A.current)==null?void 0:re.querySelector('input[name="mcp-token"], input[name="mcp-header-value-0"]'))??null}),onChanged:L,onDeleted:re=>{P(re??null),L()}},Q.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(nW,{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})]}),Cc=(e,n)=>`mcp:${e}/${n}`,QU=["allow","ask","deny"];function JU({v2:e,server:n,settings:s,settingsBusy:r,settingsProblem:o,onSettings:i,writable:c,signIn:d,onChange:u,onPaste:f,onChanged:g,onDeleted:y}){var M,R;const[x,h]=p.useState(!1),[v,b]=p.useState(!1),[j,k]=p.useState(null),[E,S]=p.useState(null),N=async A=>{h(!0),S(null);try{await A()}catch(L){S(ro(L))}h(!1)},[$,_]=n.credential?VU[n.credential]??[n.credential,"plain"]:["no credential","plain"],P=n.auth.type==="oauth",O=j&&[["Added",j.added],["Removed",j.removed],["Changed",j.changed]].filter(([,A])=>A.length).map(([A,L])=>`${A} ${L.join(", ")}`);return t.jsxs("li",{"data-server":n.name,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(WT,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:n.name}),t.jsx(Ne,{tone:_,children:$}),!!((M=n.not_metered)!=null&&M.length)&&t.jsx(Ne,{tone:"plain",children:"not metered"}),n.source&&t.jsxs(t.Fragment,{children:[t.jsx(Ne,{tone:"muted",children:bd[n.source]}),t.jsx("span",{"data-toolkit":!0,className:"font-mono text-small text-muted-foreground",children:n.toolkit?`toolkit ${n.toolkit}`:"no toolkit"})]})]}),t.jsx("p",{className:"mt-1.5 break-all font-mono text-small text-muted-foreground",children:n.url}),n.auth.type==="github_app"&&t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed with this server's GitHub App: a token narrowed to the run's repository is made for each run",(R=n.auth.headers)!=null&&R.length?` · headers ${n.auth.headers.join(", ")}`:""]}),P&&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(eW,{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(tW,{server:n,settings:s,busy:r,onSettings:i})})]}),n.secret&&t.jsx("ul",{className:"mt-2",children:t.jsx(ih,{field:n.secret,label:iW[n.auth.type],writable:c,onPaste:P?void 0:f})}),n.source==="composio"&&t.jsx(ZU,{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:[P&&n.credential!=="sealed"&&c&&t.jsx(B,{size:"sm",variant:"primary",disabled:x,onClick:()=>void N(()=>{var A;return d(n.name,{url:n.url,...(A=n.oauth)!=null&&A.scopes.length?{scopes:n.oauth.scopes}:{}})}),children:"Sign in again"}),t.jsx(B,{size:"sm",disabled: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:()=>b(!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 A;y((A=await e.deleteMcpServer(n.name))==null?void 0:A.composio)}),children:"Delete"}),t.jsx(B,{size:"sm",onClick:()=>b(!1),children:"Keep"})]}),E&&t.jsxs("div",{className:"mt-3",children:[t.jsx(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 XU={on:"on at Composio",off:"off at Composio",missing:"Composio no longer has it",unknown:"Composio didn't say"};function ZU({v2:e,server:n,writable:s}){const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[y,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 ze&&E.status===404?u(!0):c(ro(E)))}),()=>{k=!1}},[e,n]),d)return null;const b=async()=>{g(!1),x(!0),c(null),v(!1);try{await e.rotateComposioSecret(n),v(!0)}catch(k){c(ro(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:["· ",XU[k.on_composio],k.enabled?"":" · paused here"]})]},k.id))}):t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["No trigger uses it yet. ",t.jsx("a",{href:"#/triggers/new-composio",className:"underline underline-offset-2",children:"New app trigger"})]}),r.composio_error&&t.jsxs("p",{className:"mt-2 text-small text-warning-text",children:["Composio didn't answer: ",r.composio_error]}),j&&(j.ours?t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"The project's webhook subscription sends its events here."}):t.jsxs("p",{className:"mt-2 break-all text-small text-muted-foreground",children:["The project's webhook subscription sends its events to ",t.jsx("span",{className:"font-mono",children:j.webhook_url}),", not here: a new trigger asks before it moves it."]})),(j==null?void 0:j.ours)&&s&&!f&&t.jsx(B,{className:"mt-2",size:"sm",disabled:y,onClick:()=>g(!0),children:"Rotate secret"}),f&&t.jsxs("div",{role:"alertdialog","aria-label":"Rotate the subscription's secret?",className:"mt-2 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Rotate the subscription's secret? Composio makes a new one and this server keeps it; a delivery signed with the old one is refused from then on."}),t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void b(),children:"Yes, rotate"}),t.jsx(B,{size:"sm",onClick:()=>g(!1),children:"Keep"})]}),h&&t.jsx("p",{className:"mt-2 text-small text-success-text",role:"status",children:"Rotated: Composio signs with the new secret from now on."})]}):!i&&t.jsx("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:"Reading its triggers"}),i&&t.jsx("div",{className:"mt-2",children:t.jsx(hl,{problem:i})})]})}function eW({server:e,settings:n,busy:s,onSettings:r}){var g;const o=Cc(e.name,"*"),i=((g=n[o])==null?void 0:g.allow_reads)===!0,c=e.tools.filter(y=>y.effect==="read").length,d=`allow-reads-${e.name}`,u=`${d}-words`,f=y=>r(x=>{const{[o]:h,...v}=x,{allow_reads:b,...j}=h??{},k=y?{...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(cd,{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 tW({server:e,settings:n,busy:s,onSettings:r}){const o=n==null?void 0:n[Cc(e.name,"*")],i=new Map(e.tools.map(u=>[Cc(e.name,u.name),u])),c=e.tools.map(u=>{var f;return{name:Cc(e.name,u.name),...n?{gate:{name:Cc(e.name,u.name),permission:u.permission??"ask",default_permission:u.default_permission??"ask",permissions:(f=u.permissions)!=null&&f.length?u.permissions:QU}}:{}}}),d=u=>{var g,y;const f=(g=e.prices)==null?void 0:g[u];return f!==void 0?`$${f} a call`:(y=e.not_metered)!=null&&y.includes(u)?"not metered":null};return t.jsx(cb,{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 nW({v2:e}){const[n,s]=p.useState(null),[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(""),y=()=>void e.mcpPrivateHosts().then(v=>{s(v.hosts),o(null)},v=>o(ro(v)));p.useEffect(y,[e]);const x=async v=>{u(!0),c(null);try{return s((await e.saveMcpPrivateHosts(v)).hosts),!0}catch(b){return c(ro(b)),!1}finally{u(!1)}},h=async v=>{v.preventDefault(),n&&f.trim()&&await x([...n,f.trim()])&&g("")};return t.jsxs(Tr,{titleId:"mcp-private-hosts",title:"Private network hosts",note:t.jsx("p",{children:"Off by default. A host listed here may run an MCP server's sign-in on your private network (10.x, 172.16–31.x, 192.168.x, 100.64–127.x, fc00::/7), over https only; never this machine, loopback or a link-local address such as cloud metadata."}),children:[r&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The private network hosts could not be read. ",r.text]}),t.jsx(B,{size:"sm",onClick:y,className:"mt-3",children:"Try again"})]}),n&&(n.length?t.jsx("ul",{"aria-label":"Allowed private network hosts",className:"border",children:n.map(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(b=>b!==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 sW=32;function YE(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,sW-o.length).replace(/-+$/,"")}${o}`;if(!s.has(i))return i}}function rW({v2:e,add:n,onClose:s,onSaved:r}){var R;const o=p.useRef(null),[i,c]=p.useState((n==null?void 0:n.toolkit)??""),[d,u]=p.useState((n==null?void 0:n.name)??""),[f,g]=p.useState(null),[y,x]=p.useState([]),[h,v]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(!1),S=()=>{var A,L;return(((L=(A=o.current)==null?void 0:A.elements.namedItem("composio-key"))==null?void 0:L.value)??"").trim()},N=async A=>{E(!0),j(null);try{await A()}catch(L){j(ro(L))}E(!1)},$=p.useRef(0),_=()=>{$.current++,g(null)},P=()=>N(async()=>{const A=++$.current;g(null),x([]);const L=await e.composioTools(S(),i.trim().toLowerCase());A===$.current&&(g(L),n!=null&&n.tools&&L.toolkit===n.toolkit&&x(L.tools.map(D=>D.slug).filter(D=>n.tools.includes(D))))}),O=()=>N(async()=>{var L,D;const A=await e.saveComposioServer(d.trim(),S(),f.toolkit,y);(L=o.current)==null||L.reset(),r(),A.connect_url||(D=A.not_served)!=null&&D.length||A.composio?v({connect:A.connect_url,notServed:A.not_served,composio:A.composio}):s()}),M=A=>x(L=>L.includes(A)?L.filter(D=>D!==A):[...L,A]);return h?t.jsxs("section",{"aria-label":"Composio server saved",className:"space-y-3 border bg-card p-4",children:[t.jsxs("p",{className:"text-body",children:["Saved.",h.connect?` Its tools need your ${f==null?void 0:f.toolkit} account: connect it on Composio, then refresh the server.`:""]}),h.connect&&t.jsx("p",{children:t.jsxs("a",{href:h.connect,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-body underline",children:["Connect your ",f==null?void 0:f.toolkit," account"]})}),(R=h.notServed)!=null&&R.length?t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:["Composio's server doesn't list ",h.notServed.join(", "),": a run can't call ",h.notServed.length===1?"it":"them","."]}):null,h.composio&&t.jsx("p",{className:`border p-4 text-body ${h.composio.removed?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:h.composio.note}),t.jsx(B,{size:"sm",onClick:s,children:"Done"})]}):t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:A=>{A.preventDefault(),f&&y.length&&d.trim()&&O()},"aria-label":"Add from Composio",className:"space-y-4 border bg-card p-4",onInput:A=>{A.target.name==="composio-key"&&_()},children:[t.jsx("p",{className:"text-small text-muted-foreground",children:"Composio runs the toolkit's actions for you. This saves an MCP server that grants only the actions you tick, with your Composio key sealed like any credential."}),(n==null?void 0:n.tools)&&t.jsxs("p",{role:"note",className:"text-small text-muted-foreground",children:["A template uses ",n.tools.join(", "),": enter your key and load the actions, and those are ticked."]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Composio API key"}),t.jsx(Pe,{name:"composio-key",...jf})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),t.jsx(Pe,{name:"composio-toolkit",value:i,onChange:A=>{c(A.target.value),_()},placeholder:"github",spellCheck:!1})]}),b&&t.jsx(hl,{problem:b}),f&&t.jsxs("fieldset",{className:"space-y-2",children:[t.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Actions to grant"}),f.tools.length?t.jsx("ul",{className:"divide-y border",children:f.tools.map(A=>t.jsx("li",{className:"px-3 py-2",children:t.jsxs("label",{className:"flex items-start gap-2 text-body",children:[t.jsx("input",{type:"checkbox",value:A.slug,checked:y.includes(A.slug),onChange:()=>M(A.slug),className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono",children:A.name}),t.jsx("span",{className:"ml-2 font-mono text-small text-muted-foreground",children:A.slug}),A.description&&t.jsx("span",{className:"block text-small text-muted-foreground",children:A.description})]})]})},A.slug))}):t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This toolkit lists no actions."}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",d.trim()||"<name>","/<tool>."]}),t.jsx(Pe,{name:"composio-name",value:d,onChange:A=>u(A.target.value),spellCheck:!1})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:k||!i.trim(),onClick:()=>void P(),children:"Load actions"}),f&&t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:k||!y.length||!d.trim(),children:k?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",disabled:k,onClick:()=>{var A;(A=o.current)==null||A.reset(),s()},children:"Cancel"})]})]})}const oW=/^mcp-(token|scopes|client-id|client-secret|header-(name|value)-\d+)$/,jf={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},aW=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"],["github_app","GitHub App"]],iW={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in",github_app:"Headers"};function lW({v2:e,saved:n,add:s,given:r,writable:o,taken:i,signIn:c,onCancel:d,onSaved:u}){var Le,Ee,ae,$e,ot;const f=p.useRef(null),g=n?void 0:U2(s==null?void 0:s.preset),[y,x]=p.useState(g),[h,v]=p.useState((n==null?void 0:n.name)??(s==null?void 0:s.name)??""),[b,j]=p.useState((n==null?void 0:n.url)??((s==null?void 0:s.auth)==="github_app"?Uf:(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,((Le=n==null?void 0:n.auth.headers)==null?void 0:Le.length)??0)),$=k==="github_app"?"github":(n==null?void 0:n.source)==="composio"?"composio":"url",[_,P]=p.useState((n==null?void 0:n.toolkit)??(g?g.name:s&&!s.auth?s.toolkit??s.name:"")),O=$==="github"?"github":_.trim(),M=()=>{if(k==="github_app")return{};const me=O||null;return n?me!==n.toolkit?{toolkit:me}:{}:me?{toolkit:me}:{}},R=!n&&!!(i!=null&&i.some(me=>me.name===h.trim())),A=!!n||!!i&&!R,[L,D]=p.useState(null),[W,q]=p.useState(r??null),[H,K]=p.useState(!1),U=p.useRef(0),G=()=>{U.current++,D(null)},F=me=>{var Me,Ze;return(((Ze=(Me=f.current)==null?void 0:Me.elements.namedItem(me))==null?void 0:Ze.value)??"").trim()},[z,Y]=p.useState(!1),se=me=>{try{return new URL(me).origin}catch{return me}},Q=(me=k)=>{var Me;return Y(!!n&&me==="oauth"&&(n.auth.type!=="oauth"||F("mcp-scopes")!==(((Me=n.oauth)==null?void 0:Me.scopes.join(" "))??"")||!!F("mcp-client-id")||!!F("mcp-client-secret")||se(F("mcp-url"))!==se(n.url)))};p.useEffect(()=>Q(),[k]);const re=()=>{if(k==="bearer")return F("mcp-token")?{type:k,token:F("mcp-token")}:{type:k};if(k!=="headers"&&k!=="github_app")return{type:k};const me=Object.fromEntries(Array.from({length:S},(Me,Ze)=>[F(`mcp-header-name-${Ze}`),F(`mcp-header-value-${Ze}`)]).filter(([Me,Ze])=>Me&&Ze));return Object.keys(me).length?{type:k,headers:me}:{type:k}},te=async me=>{K(!0),q(null);try{await me()}catch(Me){q(ro(Me))}K(!1)},he=!!(W!=null&&W.needsClient);p.useEffect(()=>{he&&E("oauth")},[he]),p.useEffect(()=>{var me,Me;he&&k==="oauth"&&((Me=(me=f.current)==null?void 0:me.elements.namedItem("mcp-client-id"))==null||Me.focus())},[he,k]);const ge=()=>A&&te(()=>{const me=F("mcp-scopes").split(/\s+/).filter(Boolean),Me=F("mcp-client-id");return c(h.trim(),{url:b.trim(),...me.length?{scopes:me}:{},...Me?{client_id:Me,...F("mcp-client-secret")?{client_secret:F("mcp-client-secret")}:{}}:{},...M()})}),ye=()=>{const me=U.current;te(async()=>{try{const Me=await e.previewMcpServer(b.trim(),re(),n==null?void 0:n.name);me===U.current&&D(Me)}catch(Me){if(me===U.current)throw Me}})},xe=me=>{if(me.preventDefault(),!!A){if(k==="oauth"&&(!n||z))return void ge();te(async()=>{var Ze;const Me=await e.saveMcpServer(h.trim(),b.trim(),re(),M());(Ze=f.current)==null||Ze.reset(),u(Me.composio)})}},fe=!H&&A&&!!h.trim()&&!!b.trim()&&(!!n||!!L),De=me=>{var Me;if(i){for(const Ze of Array.from(((Me=f.current)==null?void 0:Me.elements)??[]))Ze instanceof HTMLInputElement&&oW.test(Ze.name)&&(Ze.value="");N(1),x(me),v(YE(me.name,i)),j(me.url),E(me.auth),P(me.name),q(null),G()}},Fe=me=>(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. ",me]});return t.jsxs("form",{ref:f,autoComplete:"off",onSubmit:xe,"aria-label":n?`Change ${n.name}`:"Add an MCP server",className:"space-y-4 border bg-card p-4",onInput:me=>{["mcp-name","mcp-toolkit"].includes(me.target.name)||G(),Q()},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:Vv.map(me=>t.jsx(B,{type:"button",size:"sm",variant:(y==null?void 0:y.id)===me.id?"solid":"outline","aria-pressed":(y==null?void 0:y.id)===me.id,disabled:H||!i||!o&&me.auth!=="none",onClick:()=>De(me),children:me.label},me.id))}),!i&&t.jsx("p",{className:"text-small text-muted-foreground",children:"The presets wait for the saved servers to be read, so the name one picks is free."}),y&&t.jsx("p",{role:"note","data-mcp-preset":y.id,className:"text-small text-muted-foreground",children:y.note}),(y==null?void 0:y.readOnly)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(cd,{checked:b===y.readOnly,label:"Read-only",disabled:H,onChange:me=>{j(me?y.readOnly:y.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:me=>v(me.target.value),spellCheck:!1}),R&&t.jsxs("span",{role:"alert",className:"mt-1 block text-small text-destructive-text",children:[h.trim()," is saved already: saving would replace it. Change it from its row, or choose another name."]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Address"}),t.jsx(Pe,{name:"mcp-url",value:b,onChange:me=>{j(me.target.value),W!=null&&W.needsClient&&q(null)},placeholder:"https://mcp.example.com/mcp",spellCheck:!1})]}),t.jsxs("div",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Source"}),t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"What made it: GitHub App access is GitHub, the Composio preset is Composio, anything else is URL."}),t.jsx("span",{"data-mcp-source":$,className:"font-mono text-body",children:bd[$]})]}),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:me=>P(me.target.value),placeholder:"hubspot",spellCheck:!1})]}),t.jsxs("fieldset",{children:[t.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Credential"}),t.jsx("div",{className:"flex flex-wrap gap-4",children:aW.map(([me,Me])=>t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"radio",name:"mcp-auth",value:me,checked:k===me,disabled:!o&&me!=="none",onChange:()=>{E(me),me==="github_app"&&!b.trim()&&j(Uf),G()},className:"accent-primary"}),Me]},me))})]}),k==="bearer"&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),Fe("A new token replaces it; leave this empty to keep it."),t.jsx(Pe,{name:"mcp-token",...jf})]}),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:[Fe(`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},(me,Me)=>{var Ze;return t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Pe,{name:`mcp-header-name-${Me}`,"aria-label":`Header ${Me+1} name`,placeholder:"X-Api-Key",defaultValue:(Ze=n==null?void 0:n.auth.headers)==null?void 0:Ze[Me],spellCheck:!1}),t.jsx(Pe,{name:`mcp-header-value-${Me}`,"aria-label":`Header ${Me+1} value`,...jf})]},Me)}),S<KU&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>N(me=>me+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."}),((ae=n==null?void 0:n.oauth)==null?void 0:ae.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:he?"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:he?"Client secret (if its app has one)":"Client secret (optional)"}),t.jsx(Pe,{name:"mcp-client-secret",...jf})]})]})]}),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||!A||!h.trim(),onClick:()=>void ge(),children:"Sign in"})]}),L&&t.jsxs("section",{"aria-label":"Preview",className:"border bg-background p-3",children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["MCP ",L.protocol,(ot=L.server_info)!=null&&ot.name?` · ${L.server_info.name}${L.server_info.version?` ${L.server_info.version}`:""}`:""," · ",L.tools.length," tool",L.tools.length===1?"":"s"]}),L.instructions&&t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:L.instructions}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:lI}),t.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:L.tools.map(me=>t.jsxs("li",{className:"px-3 py-2",children:[t.jsx("span",{className:"font-mono text-body",children:me.name}),me.title&&t.jsx("span",{className:"ml-2 text-small",children:me.title}),me.description&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:me.description})]},me.name))})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[k==="oauth"&&!o?null:k==="oauth"&&z?t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:H||!b.trim(),children:"Sign in again with these settings"}):k==="oauth"?t.jsx(B,{type:"button",size:"sm",variant:n?"outline":"primary",disabled:H||!A||!h.trim()||!b.trim(),onClick:()=>void ge(),children:n?"Sign in again":"Sign in"}):t.jsx(B,{type:"button",size:"sm",disabled:H||!b.trim(),onClick:ye,children:"Preview"}),(k!=="oauth"||n&&!z)&&t.jsx(B,{type:"submit",size:"sm",variant:W!=null&&W.signIn&&k!=="oauth"&&o?"outline":"primary",disabled:!fe,children:H?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{var me;(me=f.current)==null||me.reset(),d()},children:"Cancel"})]})]})}const H0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function cW({v2:e,needs:n,model:s,onSaved:r,writable:o,whyNot:i="sign_in",plan:c,onPlan:d,onDone:u,harnesses:f}){const[g,y]=p.useState(null),[x,h]=p.useState(null),[v,b]=p.useState(null),[j,k]=p.useState(null),[E,S]=p.useState(c??null);p.useEffect(()=>{S(c??null)},[c]);const[N,$]=p.useState(!1),_=p.useRef(0),P=()=>{const K=++_.current;e.listToolKeys().then(U=>{K===_.current&&(y(U.keys.filter(G=>G.kind==="model")),h(null))}).catch(U=>{K===_.current&&h(H0(U))})};p.useEffect(()=>{n!=="model"&&P()},[e,n]);const O=s!=null&&s.includes("/")&&!Bc(s)?s.slice(0,s.indexOf("/")):void 0,M=g==null?void 0:g.find(K=>K.id===O),R=M?[M]:g,A=g==null?void 0:g.find(K=>K.id===v),L=(A==null?void 0:A.fields.filter(K=>{var U;return((U=A.secrets.find(G=>Qf(G.name)===K.name))==null?void 0:U.source)!=="env"}))??[],D=!!E&&n!=="model"&&!O,W=n!=="model"&&(!D||N),q=K=>{S(K),d==null||d(K)},H=f&&t.jsx(WC,{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(La,{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(yx,{v2:e,view:E,onView:q}),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(La,{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."}):M?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 ",M.label," key is set, so an agent that names no model can't run. Save the ",M.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(yx,{v2:e,view:E,onView:q,writable:o,whyNot:i,beside:t.jsx(B,{type:"button",size:"sm","aria-expanded":N,onClick:()=>$(K=>!K),children:"Add a key"})}),t.jsx("p",{className:"text-body text-muted-foreground",children:H2}),N&&t.jsx("p",{className:"text-body text-muted-foreground",children:Ex})]}):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:Ex})]}),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:P,size:"sm",className:"mt-2",children:"Try again"})]}),W&&g&&!o&&t.jsx("p",{className:"text-body",role:"status",children:ei[i]}),W&&g&&o&&t.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:R.map(K=>t.jsx(B,{size:"sm",variant:v===K.id?"solid":"primary","aria-pressed":v===K.id,onClick:()=>{b(v===K.id?null:K.id),k(null)},children:K.label},K.id))}),W&&A&&o&&(L.length?t.jsx(qE,{tool:A,fields:L,onCancel:()=>b(null),onSave:async K=>{k(null);try{await e.saveToolKey(A.id,K)}catch(U){return U instanceof ze&&U.status===422?U:(k(H0(U)),null)}return b(null),P(),r==null||r(),null}},A.id):t.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",A.label," key when it starts: change it there."]})),j&&t.jsx("div",{className:"border",children:t.jsx(sa,{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 dW({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 B0=[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"icloud",label:"iCloud"},{value:"other",label:"Other"}],uW={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."})},fW="Outlook needs Microsoft sign-in, which this server doesn't do yet.";function mW(e){return e==="other"?"Password":"App password"}const hW={configured:!1,preset:null,address:null,user:null,imap:null,smtp:null,password_unreadable:!1},G0=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"}},q0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},pW=e=>Object.fromEntries((e instanceof ze?e.fields??[]:[]).map(n=>[n.field,n.message]));function gW({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(G0(null)),[f,g]=p.useState(""),[y,x]=p.useState(null),[h,v]=p.useState({}),[b,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),$=p.useRef(0),_=F=>{o(F),u(G0(F))},P=()=>{const F=++$.current;e.emailAccount().then(z=>{F===$.current&&(_(z),c(null))}).catch(z=>{F===$.current&&c(q0(z))})};p.useEffect(()=>{n&&P()},[e,n]);const O=F=>{u(F),j(null)},M=F=>z=>O(Y=>({...Y,[F]:z.target.value})),R=()=>{const F=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(),...F?{user:F}:{},...f?{password:f}:{},...d.preset==="other"?{imap:{host:d.imapHost.trim(),port:Number(d.imapPort)},smtp:{host:d.smtpHost.trim(),port:Number(d.smtpPort)}}:z}},A=async(F,z)=>{x(null),v({}),N(!0);try{await z()}catch(Y){const se=pW(Y);Object.keys(se).length?v(se):x({title:F,error:q0(Y)})}finally{N(!1)}},L=F=>{F.preventDefault(),A("The account was not saved",async()=>{_(await e.saveEmailAccount(R())),g(""),j(null)})},D=()=>A("The account was not tested",async()=>{j(null),j(await e.testEmailAccount(R()))}),W=()=>A("The account was not removed",async()=>{E(!1),await e.removeEmailAccount(),_(hW),g(""),j(null)}),q=t.jsxs("div",{className:ti,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:Go,children:[q,t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:ei[s]})]})});if(!r)return i?t.jsx(vt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:P,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,K=d.preset==="other",U=(F,z,Y)=>t.jsxs("div",{className:"grid grid-cols-[1fr_7rem] gap-2",children:[t.jsx(wt,{label:`${z} server`,error:h[`${F}.host`],children:t.jsx(Pe,{name:`${F}_host`,value:F==="imap"?d.imapHost:d.smtpHost,onChange:M(F==="imap"?"imapHost":"smtpHost"),placeholder:Y,spellCheck:!1,autoCapitalize:"off"})}),t.jsx(wt,{label:"Port",error:h[`${F}.port`],children:t.jsx(Pe,{name:`${F}_port`,inputMode:"numeric",value:F==="imap"?d.imapPort:d.smtpPort,onChange:M(F==="imap"?"imapPort":"smtpPort")})})]});return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Go,children:[q,t.jsxs("div",{className:ni,children:[y&&t.jsx(sa,{error:y.error,title:y.title}),i&&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 email account could not be read: ",i.code,": ",i.message,". What is shown may be out of date."]})}),t.jsxs(Tr,{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(PT,{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(Ne,{tone:"success",children:"saved"}),H&&r.preset&&t.jsx(Ne,{children:((G=B0.find(F=>F.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:L,children:[t.jsxs("fieldset",{disabled:S,className:"min-w-0 space-y-4",children:[t.jsx(wt,{label:"Provider",group:"heading",note:fW,error:h.preset,children:t.jsx(ld,{name:"email-preset",label:"Provider",value:d.preset,onChange:F=>O(z=>({...z,preset:F})),options:B0})}),t.jsx("p",{className:"text-small text-muted-foreground",children:uW[d.preset]}),t.jsx(wt,{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:M("address")})}),t.jsx(wt,{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:M("user")})}),t.jsx(wt,{label:mW(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:F=>{g(F.target.value),j(null)}})}),K&&U("imap","IMAP","imap.example.com"),K&&U("smtp","SMTP","smtp.example.com")]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",variant:"solid",disabled:S||!d.address.trim()||!f,children:"Save"}),t.jsx(B,{type:"button",variant:"outline",disabled:S||!d.address.trim()||!f&&!r.configured,onClick:()=>void 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"})]}),b&&t.jsxs("div",{"aria-label":"Test",className:"space-y-1 font-mono text-body",children:[["imap","smtp"].map(F=>t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Ne,{tone:b[F].ok?"success":"error",children:F==="imap"?"IMAP":"SMTP"}),t.jsx("span",{className:b[F].ok?"":"text-destructive-text",children:b[F].message})]},F)),t.jsx("p",{className:"text-small text-muted-foreground",children:b.ok?"Both signed in. Nothing was sent, and nothing was saved by the test.":"Nothing was sent, and nothing was saved by the test."})]})]})]})]})]})})}const K0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},xW={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 vW({v2:e}){const[n,s]=p.useState(null),[r,o]=p.useState([]),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(null),[y,x]=p.useState(null),[h,v]=p.useState(!1),[b,j]=p.useState(!1),[k,E]=p.useState(""),S=p.useRef(0),N=()=>{const P=++S.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([O,M])=>{P===S.current&&(s(O),o(M.attempts),c(null))}).catch(O=>{P===S.current&&c(K0(O))})};p.useEffect(N,[e]);const $=async(P,O)=>{g(null),j(!0);try{await O()}catch(M){g({title:P,error:K0(M)})}finally{j(!1)}N()},_=P=>{P.preventDefault(),$("The webhook was not saved",async()=>{const O=await e.saveWebhook(k.trim());O.signing_secret&&u(O.signing_secret);const{signing_secret:M,...R}=O;s(R)})};return n?t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Go,children:[t.jsxs("div",{className:ti,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:ni,children:[f&&t.jsx(sa,{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(Tr,{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(sl,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.configured?t.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:n.url}):t.jsx("span",{className:"text-body text-muted-foreground",children:"No webhook is set."}),n.configured&&(n.disabled?t.jsx(Ne,{tone:"error",children:"off"}):n.signing==="sealed"?t.jsx(Ne,{tone:"success",children:"on"}):t.jsx(Ne,{tone:"warning",children:"not signing"}))]}),n.configured&&n.disabled&&t.jsxs("p",{className:"mt-2 text-body text-destructive-text",children:["Off: ",n.disabled.reason,", ",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}),xW[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:P=>E(P.target.value),className:"h-9 min-w-[280px] flex-1","aria-label":"Webhook URL"}),t.jsx(B,{type:"submit",variant:"solid",disabled:b||!k.trim(),children:"Save"}),n.configured&&t.jsx(B,{type:"button",variant:"outline",disabled:b,onClick:()=>$("The test was not sent",async()=>x(await e.testWebhook())),children:"Send a test"}),n.configured&&!h&&t.jsx(B,{type:"button",variant:"outline",disabled:b,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:b,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"})]}),y&&t.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",V0(y)]})]})}),t.jsx(Tr,{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((P,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(P.at)}),t.jsx("span",{className:"w-[130px] shrink-0 font-mono",children:P.type}),t.jsx("span",{className:P.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:V0(P)}),P.redelivery&&t.jsx(Ne,{children:"redelivery"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:P.webhook_id,children:[P.webhook_id.slice(0,12),"…"]}),t.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:b,onClick:()=>$("The message was not sent again",()=>e.redeliverWebhook(P.webhook_id)),children:"Redeliver"})]},`${P.webhook_id}:${P.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 V0(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 bW={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."}},$x=e=>bW[e]??{label:e,gives:""},yW=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},_x=e=>e.slice(e.lastIndexOf(":")+1),wW=2e3;function jW({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(null),[y,x]=p.useState({}),[h,v]=p.useState(new Set),b=p.useRef(0),j=p.useCallback(()=>{const $=++b.current;c(null),e.computers().then(_=>{$===b.current&&o(_)},_=>{$===b.current&&c(yW(_))})},[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(P=>P.id===$)).map(_=>_.kind),S=async($,_,P)=>{g(null);try{await e.saveComputerKeys(_.id,P)}catch(O){return O instanceof ze&&O.status===422?O:(g({at:$,words:Wt(O)}),null)}return u(null),j(),null},N=async $=>{v(P=>new Set(P).add($.id));let _;try{const P=await e.testComputer($.id);_=P.ok?{ok:!0,words:P.detail,at:new Date().toISOString()}:{ok:!1,words:P.why,at:new Date().toISOString()}}catch(P){_={ok:!1,words:Wt(P),at:new Date().toISOString()}}x(P=>({...P,[$.id]:_})),v(P=>{const O=new Set(P);return O.delete($.id),O})};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Go,children:[t.jsxs("div",{className:ti,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:ni,children:[t.jsx(SW,{v2:e,paired:r.paired,reload:j}),!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:ei[s]}),r.kinds.map($=>t.jsx(CW,{kind:$,providers:$.providers.filter(_=>!k.has(_.id)),own:$.providers.filter(_=>k.has(_.id)).map(_=>_.name),children:$.providers.filter(_=>!k.has(_.id)).map(_=>{const P=`${$.kind}/${_.id}`;return t.jsx(EW,{v2:e,kind:$.kind,provider:_,writable:n,serves:E(_.id),tested:y[_.id],testing:h.has(_.id),open:(d==null?void 0:d.at)===P?d.mode:null,problem:(f==null?void 0:f.at)===P?f.words:null,onOpen:O=>{u(O?{at:P,mode:O}:null),g(null)},onSave:O=>S(P,_,O),onRemove:async O=>{var R;const M=await S(P,_,{[O]:null});M&&g({at:P,words:((R=M.fields)==null?void 0:R.map(A=>A.message).join(" "))||M.message})},onTest:()=>void N(_)},_.id)})},$.kind))]})]})})}function kW(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=>$x(o).label).join(", ")||$x(e.kind).label,n,s,e.arch,r].filter(Boolean).join(" · ")}function NW(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 SW({v2:e,paired:n,reload:s}){const[r,o]=p.useState(null),[i,c]=p.useState(!1),[d,u]=p.useState(()=>Date.now()),[f,g]=p.useState(null),[y,x]=p.useState(null),[h,v]=p.useState(null),b=r?Date.parse(r.code.expires_at)-d:0,j=r!==null&&b>0;p.useEffect(()=>{if(!j)return;const N=setInterval(()=>u(Date.now()),1e3),$=setInterval(s,wW);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(Wt(N))}c(!1)},E=async N=>{v(null);try{await e.removeComputer(N)}catch($){v(Wt($));return}x(null),s()},S=`${Math.floor(Math.max(0,b)/6e4)}:${String(Math.floor(Math.max(0,b)%6e4/1e3)).padStart(2,"0")}`;return t.jsxs(Tr,{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(LN,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}):t.jsx(Ya,{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(Ne,{tone:"success",children:"Online"}):t.jsx(Ne,{tone:"muted",children:"Offline"}),N.held_by_run&&t.jsxs(Ne,{tone:"active",children:["In use by run ",ea(N.held_by_run)]}),N.unserved&&t.jsx(Ne,{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:kW(N)}),N.groups.length>0&&t.jsx("p",{"data-offers":!0,className:"mt-1 text-small text-muted-foreground",children:NW(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:y!==null,children:"Remove"})]}),y===N.id&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",N.name,"? Its driver stops dialing and asks for a new code",N.held_by_run?", and the run using it loses it":"","."]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void E(N.id),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>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 CW({kind:e,providers:n,own:s,children:r}){const{label:o,gives:i}=$x(e.kind);return t.jsx(Tr,{label:o,title:o,note:(i||!e.offered||s.length>0)&&t.jsxs(t.Fragment,{children:[i&&t.jsx("p",{children:i}),!e.offered&&t.jsx("p",{children:t.jsx(Ne,{tone:"muted",children:"Not offered here"})}),!e.offered&&e.why&&t.jsx("p",{className:"font-mono text-small",children:e.why}),s.length>0&&t.jsxs("p",{className:"text-small",children:["Also served by your computers: ",s.join(", "),"."]})]}),children:n.length?t.jsx("ul",{className:"border",children:r}):t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:e.kind==="none"?"Nothing to set up.":s.length?"No other provider serves it on this server.":"No provider serves it on this server."})})}function EW({v2:e,kind:n,provider:s,writable:r,serves:o,tested:i,testing:c,open:d,problem:u,onOpen:f,onSave:g,onRemove:y,onTest:x}){const h=p.useRef(null),v=d&&"paste"in d?d.paste:null,b=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(Ya,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:s.name}),s.ready?t.jsx(Ne,{tone:"success",children:"Ready"}):t.jsx(Ne,{children:"Not ready"}),s.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&&lb.has(n)&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:ib}),s.secrets.length>0&&t.jsx("ul",{className:"mt-3 space-y-1.5",children:s.secrets.map(j=>{var S;const k=_x(j.name),E=((S=s.picked)==null?void 0:S.includes(j.name))??!1;return t.jsx(ih,{field:j,required:s.required.includes(j.name),writable:r&&!d,onPaste:E?void 0:()=>void ah(()=>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($W,{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"} · ${ud(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(_W,{provider:s.name,name:v,set:s.secrets.some(j=>_x(j.name)===v&&j.set),onSave:g,onCancel:()=>f(null)}),r&&b&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",b," saved on this server?"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void y(b),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>f(null),children:"Cancel"})]}),u&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:u})]})}function $W({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(Wt(h))}),()=>{x=!1}},[e,n.id,g]);const y=async(x,h)=>{var b;f({key:x.key,value:h}),d(null);const v=await r({[x.key]:h});f(null),v&&d(((b=v.fields)==null?void 0:b.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(b=>_x(b.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(Et,{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(b=>({value:b.value,label:b.label})),placeholder:"Pick one",onChange:b=>void y(x,b),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 _W({provider:e,name:n,set:s,onSave:r,onCancel:o}){const i=p.useRef(null),[c,d]=p.useState(!1),[u,f]=p.useState(!1),[g,y]=p.useState(null),x=()=>{var b,j;return((j=(b=i.current)==null?void 0:b.elements.namedItem(n))==null?void 0:j.value)??""},h=()=>{var b;(b=i.current)==null||b.reset(),d(!1)},v=async b=>{var N;b.preventDefault();const j=x();if(!j)return;f(!0),y(null);const k=await r({[n]:j});if(f(!1),!k){h();return}const E=(N=k.fields)==null?void 0:N.find($=>$.field===n),S=(k.fields??[]).filter($=>$.field!==n).map($=>$.message);y(E?{field:E.message,message:S.join(" ")}:{field:null,message:S.join(" ")||k.message})};return t.jsxs("form",{ref:i,autoComplete:"off",onSubmit:b=>void v(b),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 TW="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.",Y0=[{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)"}],RW=e=>({region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),yr="ARCHIL_API_KEY",AW=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function OW({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState({region:"",s3Url:"",image:""}),[f,g]=p.useState(null),[y,x]=p.useState(null),[h,v]=p.useState(!1),[b,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),[$,_]=p.useState(!1),[P,O]=p.useState(!1),M=p.useRef(null),R=p.useRef(0),A=p.useCallback(U=>{o(U),u(RW(U))},[]),L=p.useCallback(()=>{const U=++R.current;c(null),e.archil().then(G=>{U===R.current&&A(G)},G=>{U===R.current&&c(AW(G))})},[e,A]);if(p.useEffect(L,[L]),!r)return i?t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["Archil's settings could not be read: ",i.code,": ",i.message]}),t.jsx(B,{size:"sm",onClick:L,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Un,{label:"Loading Archil's settings",rows:2})});const D=()=>{var U,G;return((G=(U=M.current)==null?void 0:U.elements.namedItem(yr))==null?void 0:G.value)??""},W=async U=>{const G={region:d.region,s3Url:d.s3Url,...d.image?{image:d.image}:{},...U!==void 0?{keys:{[yr]:U}}:{}};v(!0),g(null),x(null);try{const F=await e.saveArchil(G);_(!1),O(!1),A(F)}catch(F){if(F instanceof ze&&F.status===422){const z={},Y=[];for(const se of F.fields??[]){const Q=se.field.startsWith("keys.")?se.field.slice(5):se.field;Y0.some(re=>re.name===Q)||Q===yr?z[Q]=se.message:Y.push(se.message)}g({fields:z,message:Y.length?Y.join(" "):Object.keys(z).length?null:F.message})}else x(Wt(F))}finally{v(!1)}},q=U=>{U.preventDefault(),W($&&D()?D():void 0)},H=async()=>{E(!0);try{const U=await e.testArchil();j(U.ok?{ok:!0,words:U.detail,at:new Date().toISOString()}:{ok:!1,words:U.why,at:new Date().toISOString()})}catch(U){j({ok:!1,words:Wt(U),at:new Date().toISOString()})}finally{E(!1)}},K=async()=>{x(null);try{A(await e.archilOff()),N(!1)}catch(U){x(Wt(U))}};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Go,children:[t.jsxs("div",{className:ti,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:TW})]}),t.jsxs("div",{className:ni,children:[!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:ei[s]}),t.jsx(Tr,{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($T,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"font-mono text-prose font-semibold",children:"Archil"}),t.jsx("span",{"data-archil-state":!0,children:r.on?t.jsx(Ne,{tone:"success",children:"On"}):t.jsx(Ne,{children:"Off"})}),r.on&&t.jsx("span",{"data-disk":!0,className:"font-mono text-small text-muted-foreground",children:r.region??""}),t.jsx("span",{className:"flex-1"}),t.jsx(B,{size:"sm",onClick:()=>void H(),disabled:k,children:k?"Testing…":"Test"}),r.on&&t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Turn off"})]}),b&&t.jsx("p",{"data-test":!0,className:`mt-3 text-small ${b.ok?"text-success-text":"text-destructive-text"}`,children:`${b.ok?"Passed":"Failed"} · ${ud(b.at)} · ${b.words}`}),S&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Turn Archil off? Its keys are kept, for turning it on again."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void K(),children:"Turn off"}),t.jsx(B,{size:"sm",onClick:()=>N(!1),children:"Cancel"})]}),y&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:y}),t.jsxs("form",{ref:M,autoComplete:"off",onSubmit:q,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[Y0.map(U=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:U.label}),t.jsx(Pe,{name:U.name,value:d[U.name],placeholder:U.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:G=>{const F=G.currentTarget.value;u(z=>({...z,[U.name]:F}))}}),(f==null?void 0:f.fields[U.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[U.name]})]},U.name)),t.jsx("ul",{children:t.jsx(ih,{field:r.secret,label:yr,writable:n&&!$&&!P,onPaste:()=>void ah(()=>_(!0),()=>{var U;return(U=M.current)==null?void 0:U.elements.namedItem(yr)}),onRemove:()=>O(!0)})}),n&&P&&t.jsxs("div",{"data-confirm-key":!0,className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",yr," saved on this server?"]}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:()=>void W(null),children:"Remove"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>O(!1),children:"Cancel"})]}),n&&$&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:yr}),t.jsx(Pe,{type:"password",name:yr,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(f==null?void 0:f.fields[yr])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[yr]})]}),n&&$&&t.jsx(B,{type:"button",size:"sm",onClick:()=>_(!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 QE="tool_approval_requested";function PW(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 LW(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 ${eo(e)} per call`:null}function MW(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 IW={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 JE(e){var n;if(e instanceof ze){const s=((n=e.details)==null?void 0:n.reason)==="already_answered"&&typeof e.details.decision=="string"?IW[e.details.decision]:void 0;if(e.status===409&&s)return s;if(e.status===403)return"Only the owner, signed in with the password on this page, can answer an approval.";if(e.status===401)return"Your sign-in ended. Sign in again to answer.";if(e.status===404)return"This run no longer waits on that call."}return Wt(e)}const zW=2e3;function XE({pending:e,onAnswer:n,compact:s=!1,heading:r}){const[o,i]=p.useState(""),[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,y]=p.useState(null),[x,h]=p.useState(!1),v=e.destructive===!0,b=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=LW(e.price),S=async(N,$)=>{if(b.current)return;b.current=!0,d(!0),f(null),h(!1);const _=o.trim(),P=await($?n(N,void 0,$):n(N,N==="deny"&&_?_:void 0));b.current=!1,d(!1),P?f(P):y(N)};return t.jsxs("section",{"aria-label":"Approval required",className:ie("min-w-0 border border-warning/50 bg-warning/5",s?"p-4":"p-4 md:p-5"),children:[r,t.jsxs("p",{className:ie("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-2"),children:[t.jsx(PN,{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(Ne,{tone:"error",title:"Its server marks this tool destructive: it may delete or overwrite.",children:"Destructive"})]})]}),t.jsx("pre",{"aria-label":`${e.tool} arguments`,title:e.args_preview,className:ie("mt-2 overflow-auto whitespace-pre-wrap break-all border bg-card p-3 font-mono text-small leading-[1.6]",s?"max-h-28":"max-h-64"),children:MW(e.args_preview)}),E&&t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:E}),g?t.jsx("p",{className:"mt-3 font-mono text-body text-success-text",role:"status",children:g==="allow"?"Allowed. The run goes on.":"Denied. The agent reads why and goes on."}):t.jsxs("div",{className:"mt-3 space-y-2",children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-small text-muted-foreground",children:"Tell the agent why (optional, sent with Deny)"}),t.jsx(nn,{value:o,onChange:N=>i(N.target.value),maxLength:zW,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(DW,{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 DW({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 FW={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 UW({mode:e,onSend:n,sending:s,sent:r,purpose:o}){const i=o??FW[e],[c,d]=p.useState(""),[u,f]=p.useState(!1),g=s||u,y=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(),y()},children:[t.jsx(nn,{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(),y())},className:"block w-full resize-none px-4 pt-3"}),t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 pb-3",children:[t.jsxs("span",{className:"min-w-0 text-label text-muted-foreground",children:[t.jsx("label",{htmlFor:"composer",className:"font-semibold text-foreground",children:i.label})," · ",r?"Sent. It appears on the timeline when the run takes it.":i.does]}),t.jsxs(B,{type:"submit",size:"sm",disabled:!c.trim()||!n||g,children:[g?"Sending":"Send"," ",t.jsx(jT,{"aria-hidden":!0})]})]})]})}function Qr(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 ZE=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${Qr(e.cap_usd)} `:""}spend cap`;function WW({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(Ux,{className:"size-3.5","aria-hidden":!0})," ",ZE(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 e$=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,t$=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function HW(e){var n,s;return e instanceof ze?e.status===422?((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message:e.status===409?"This run has ended, so its cap can't be raised.":e.status===404?"This run is no longer on the server.":e.message:e instanceof Error?e.message:String(e)}function n$({cap:e,suggested:n,least:s=null,paused:r,onRaise:o}){const[i,c]=p.useState(n===null?"":String(n)),[d,u]=p.useState(!1),[f,g]=p.useState(null),[y,x]=p.useState(null),h=p.useRef(!1),v=Number(i),b=i.trim()!==""&&Number.isFinite(v)&&v>0,j=async k=>{if(k==null||k.preventDefault(),!(!b||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(HW(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 ${Qr(e)}`,className:"h-9 w-32"})]}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:d||!b,children:d?"Raising":r?"Raise the cap and continue":"Raise the cap"})]}),(s!==null||n!==null)&&t.jsxs("ul",{className:"mt-2 space-y-0.5 font-mono text-small","aria-label":"Cap figures",children:[s!==null&&t.jsxs("li",{"data-cap-figure":"least",children:["Least to continue: ",Qr(s)]}),n!==null&&t.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",Qr(n)]})]}),n!==null&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The suggestion is prefilled; change it before you raise, if you like."}),f&&t.jsx("p",{className:"mt-2 text-body text-destructive-text",role:"alert",children:f}),y&&t.jsx("p",{className:"mt-2 text-body text-muted-foreground",role:"status",children:y})]})}function BW({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(Bx,{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(nl,{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 el=0;const Tx=()=>{var n;const e=(n=history.state)==null?void 0:n.console_at;return typeof e=="number"?e:void 0},Q0=e=>{el=e,history.replaceState({...history.state??{},console_at:e},"")};function GW(){const e=Tx();e===void 0?Q0(0):el=e;const n=()=>{const s=Tx();s===void 0?Q0(el+1):el=s};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)}function qW(){const e=Tx();return e===void 0?-1:el-e}function KW(e){el>0?history.back():location.hash=e}const VW=(e,n)=>{const s=kl(e),r=fd(e)?B2:void 0;return s?r?`${mk(s,{ended:n})} ${r}`:mk(s,{ended:n}):e&&e.usd!==null&&VS(e)?r?`A local estimate, not a bill. ${r}`:"A local estimate, not a bill":r};function YW({run:e,agentName:n,actions:s={},costText:r}){var E,S,N;const o=es(e),i=o?"your backend":VL(e.place),c=Dm(e.status,e.state,e.kind,zm,!0,e.error,e.review,e.computer),d=o?{...c,canStop:!1,canCancel:!1}:c,[u,f]=p.useState(!1),g=!!e.archived_at,y=(E=e.cost)==null?void 0:E.cap_usd,x=!!e.pending&&e.pending.kind!=="budget"&&e.pending.kind!=="stopped",h=!o&&!!s.onRaiseCap&&!d.final&&typeof y=="number"&&!x,[v,b]=p.useState(!1),j=((S=e.pending)==null?void 0:S.kind)==="budget"?e.pending:null,k=!!fd(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:()=>KW(dn(e.agent_id)),className:"-m-1.5 shrink-0 p-1.5 hover:text-foreground",children:t.jsx(An,{className:"size-3.5","aria-hidden":!0})}),t.jsx("a",{href:dn(e.agent_id),className:"-my-1 truncate py-1 hover:text-foreground hover:underline",children:n}),t.jsx("span",{"aria-hidden":!0,children:"/"}),t.jsxs("span",{className:"truncate",children:["Run ",ea(e.run_id)]})]}),t.jsxs("div",{"data-phone-row":!0,className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 max-sm:mt-2 max-sm:flex-row max-sm:flex-wrap max-sm:items-center max-sm:gap-x-3 max-sm:gap-y-2 sm:flex-row sm:flex-wrap",children:[t.jsxs("div",{className:"min-w-0 flex-1 self-stretch max-sm:contents sm:basis-64",children:[t.jsx("h1",{className:"line-clamp-2 break-words text-2xl font-semibold leading-tight max-sm:basis-full max-sm:text-lg",title:Cn(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?n:Cn(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(Ne,{tone:"muted",children:"Archived"}),e.approvals==="never"&&t.jsx(Ne,{tone:"warning",title:"This run's agent never asks: no call of it waits for you.",children:"Unattended"}),t.jsxs("span",{className:"font-mono",children:[e.kind," · rev ",e.agent_version,i&&` · ${i}`]}),o&&t.jsxs("span",{className:"font-mono",children:[Ko(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:hk(e.cost,y,{text:r})}):t.jsxs("span",{className:"font-mono",title:VW(e.cost,Ha(e.status)),children:[hk(e.cost,y,{ended:Ha(e.status)}),k&&t.jsxs(t.Fragment,{children:[" · ",t.jsx(db,{})]})]}),t.jsx(rb,{run:e,link:!0}),t.jsx(HE,{run:e})]}),e.status==="completed"&&e.review&&t.jsxs("p",{className:"mt-2 text-body text-warning-text max-sm:mt-0 max-sm:basis-full",children:["Needs review: ",e.review.reason]})]}),(d.canStop||d.canCancel||s.onArchive||h)&&t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[h&&t.jsxs(B,{size:"sm",onClick:()=>b($=>!$),"aria-expanded":v,title:`Raise its ${Qr(y)} spend cap.`,children:[t.jsx(Ux,{"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(qT,{"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(CN,{"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(SN,{"aria-hidden":!0}):t.jsx(ed,{"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(n$,{cap:y,suggested:e$(j),least:t$(j),paused:!!j,onRaise:s.onRaiseCap},j?`${e.run_id}:${j.at}`:`${e.run_id}:working`)})]})}const QW=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function JW({view:e,onView:n}){return t.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:QW.map(s=>t.jsxs("label",{className:ie("caps -ml-px cursor-pointer border px-3 py-1.5 text-label first:ml-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-1 has-[:focus-visible]:outline-offset-2",e===s.id?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[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 s$=(e,n)=>n?e:e.filter(s=>!v2(s.path));function XW({files:e,onOpen:n,showHidden:s,onShowHidden:r}){const o=e.filter(d=>v2(d.path)).length,i=s$(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(CT,{className:"size-3.5","aria-hidden":!0})," Files · ",i.length," ",i.length===1?"file":"files"," (",Wa(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(Va,{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:Wa(d.size_bytes)})]})},d.path))})]})}function ZW({file:e,text:n,onClose:s,files:r=[],onOpen:o}){const[i,c]=p.useState(!1),d=p.useRef(null);p.useEffect(()=>{var k;const b=document.activeElement,j=d.current;return j&&!j.open&&((k=j.showModal)==null||k.call(j)),()=>{var E;j!=null&&j.open&&j.close(),(E=b==null?void 0:b.focus)==null||E.call(b)}},[]),p.useEffect(()=>c(!1),[e.path]);const u=p.useRef(!1),f=p.useRef(!1),g=EL(e),[y,x]=p.useState(g==="markdown"?"rendered":"raw");p.useEffect(()=>x(g==="markdown"?"rendered":"raw"),[e.path]);const h=Sv(b=>{const j=r.find(k=>k.path===b);j&&(o==null||o(j))}),v=()=>{if(n===null)return;const b=URL.createObjectURL(new Blob([n],{type:e.content_type??"application/octet-stream"}));Object.assign(document.createElement("a"),{href:b,download:e.path.split("/").pop()}).click(),URL.revokeObjectURL(b)};return t.jsx("dialog",{ref:d,"aria-label":e.path,onCancel:b=>{b.preventDefault(),s()},onMouseDown:b=>{u.current=b.target===b.currentTarget},onMouseUp:b=>{f.current=b.target===b.currentTarget},onClick:b=>{u.current&&f.current&&b.target===b.currentTarget&&s(),u.current=f.current=!1},className:"m-0 h-full max-h-none w-full max-w-none border-0 bg-transparent p-0 text-foreground backdrop:bg-overlay/60 md:p-8",children:t.jsxs("div",{className:"mx-auto flex h-full w-full max-w-5xl flex-col border bg-background",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2.5",children:[t.jsx(B,{size:"icon",variant:"ghost",onClick:s,"aria-label":"Close",children:t.jsx(Qo,{"aria-hidden":!0})}),t.jsx(Va,{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(JW,{view:y,onView:x})}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:async()=>{var b;n!==null&&(await((b=navigator.clipboard)==null?void 0:b.writeText(n)),c(!0))},children:[t.jsx(Ka,{"aria-hidden":!0})," ",i?"Copied":"Copy"]}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:v,children:[t.jsx(_N,{"aria-hidden":!0})," Download"]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 py-8 md:px-16",children:n===null?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading the file..."}):g==="download"?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This file type is not shown here. Download it to open it."}):y==="rendered"?t.jsx("article",{className:"report mx-auto max-w-3xl",onClick:h,dangerouslySetInnerHTML:{__html:no(n,o&&{paths:r.map(b=>b.path),from:e.path.split("/").slice(0,-1).join("/")})}}):t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-small leading-[1.8]",children:n})}),t.jsxs("footer",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["File · ",n===null?"...":`${n.length.toLocaleString("en-US")} characters`," · ",e.content_type??"unknown type"]})]})})}function e9(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 y=d[2].trim().toLowerCase();o=y==="json"||y===""?{open:c,end:g}:void 0,c=g}if(o&&o.end===r.length-1){const c=s(r.slice(o.open+1,o.end).join(`
704
- `));return c?{words:r.slice(0,o.open).join(`
705
- `).trim(),record:c}:null}const i=s(n);if(i)return{words:"",record:i};for(let c=n.lastIndexOf(`
706
- {`);c>=0;c=n.lastIndexOf(`
707
- {`,c-1)){const d=s(n.slice(c+1));if(d)return{words:n.slice(0,c).trim(),record:d};if(c===0)break}return null}const t9=e=>e.replace(/[_-]+/g," ").trim()||e,yc=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;function om(e,n){let s=yc(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=yc(o.reduce((f,g)=>{var y;return(y=yc(f))==null?void 0:y[g]},n))??{},u=d.properties||c.properties?{...yc(d.properties),...yc(c.properties)}:void 0;s={...d,...c,...u?{properties:u}:{}}}return s}const n9=(e,n)=>{var s;return((s=om(e,n))==null?void 0:s.contentMediaType)==="text/markdown"};function $b({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=om(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($b,{value:c,schema:i,root:s,linked:r})},d))})}return typeof e=="object"?t.jsx(r$,{record:e,schema:n,root:s,linked:r}):typeof e=="string"&&n9(n,s)?t.jsx("article",{"data-json-markdown":!0,className:"report max-w-none",dangerouslySetInnerHTML:{__html:no(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 r$({record:e,schema:n,root:s,linked:r}){var i;const o=(i=om(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=om(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:t9(c)}),t.jsx("dd",{className:"mt-1 min-w-0 text-prose leading-relaxed",children:t.jsx($b,{value:d,schema:u,root:s,linked:r})})]},c)})})}function J0({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(r$,{record:e,schema:n,root:n,linked:s})})]})}function s9({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($b,{value:e,schema:n,root:n,linked:s})})}function r9({run:e,rows:n,files:s=[],onOpen:r,schema:o}){var y,x,h,v,b;const i=((y=e.result)==null?void 0:y.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=Sv(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(J0,{record:u,schema:o,linked:c}):t.jsx(s9,{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=e9(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:no(j.words,c)}}),t.jsx(J0,{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:no(i,c)}})]})}if(g)return g;if(((b=e.result)==null?void 0:b.output)!==void 0&&e.result.output!==null){const j=e.result.output,k=j&&typeof j=="object"&&!Array.isArray(j)?Object.entries(j).filter(S=>typeof S[1]=="string"&&S[1].includes(`
708
- `)&&S[1].length>80):[],E=k.length?Object.fromEntries(Object.entries(j).filter(([S])=>!k.some(([N])=>N===S))):j;return t.jsxs("div",{className:"space-y-8",children:[k.map(([S,N])=>t.jsxs("section",{children:[t.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:S.replace(/_/g," ")}),t.jsx("article",{className:"report max-w-none border bg-card p-5",onClick:d,dangerouslySetInnerHTML:{__html:no(N,c)}})]},S)),(!k.length||Object.keys(E).length>0)&&t.jsxs("section",{children:[t.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:k.length?"The rest of the output":"Output"}),t.jsx("pre",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(E,null,2)})]})]})}return null}function o9({native:e,agentId:n}){const s=[{label:"Task usage",usage:e.usage.task},...e.usage.reflection.length?e.usage.reflection.map((r,o)=>({label:`Reflection usage · turn ${o+1}`,usage:r})):[{label:"Reflection usage",usage:null}]];return t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Native run details",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Native run"}),t.jsx("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[["Runtime",xd(e.runtime)],["Project",e.project],["Selector",Dv(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":eo(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 a9={seeded:"Prepared",reflecting:"Reflecting",proposed:"Under review",merged:"Saved",dropped:"Not saved",pending:"Awaiting approval"},df=e=>typeof e=="number"&&Number.isFinite(e)?e.toLocaleString("en-US"):"Not reported";function i9({run:e,read:n,onViewChanges:s}){var b,j,k,E,S,N,$,_,P,O,M;const[r,o]=p.useState({data:void 0,reading:!0}),[i,c]=p.useState(0),d=p.useRef(n);d.current=n;const u=!!n,f=e.run_id,g=(b=e.learning)==null?void 0:b.state,y=(j=e.learning)==null?void 0:j.at;p.useEffect(()=>{let R=!0;if(!u){o({data:void 0,reading:!1});return}return o(A=>({...A,error:void 0,reading:!0})),Promise.resolve().then(()=>d.current()).then(A=>{if(A&&A.run!==f)throw new Error("The learning result belongs to a different run. Refresh to try again.");R&&o({data:A,reading:!1})}).catch(A=>{R&&o(L=>({...L,error:A??new Error("The learning result could not be read."),reading:!1}))}),()=>{R=!1}},[f,g,y,u,i]),p.useEffect(()=>{const R=()=>{document.hidden||c(A=>A+1)};return window.addEventListener("focus",R),document.addEventListener("visibilitychange",R),()=>{window.removeEventListener("focus",R),document.removeEventListener("visibilitychange",R)}},[]);const x=r.data,h=()=>c(R=>R+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(Ne,{children:a9[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(Yo,{"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(Jt,{problem:Ht(r.error,"the learning result"),onRetry:h,className:""})]}),!u&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"Detailed learning results are unavailable in this view."}),u&&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(R=>!R.keep)?"Recommended keeping some changes.":"Recommended keeping these changes.":"Did not recommend keeping these changes."}),t.jsx("p",{className:"mt-2 break-words text-body leading-relaxed",children:x.verdict.reason}),(S=x.verdict.items)!=null&&S.length?t.jsx("ul",{className:"mt-3 divide-y border",children:x.verdict.items.map((R,A)=>t.jsxs("li",{className:"space-y-2 p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("code",{className:"min-w-0 break-all text-small",children:R.file}),t.jsx(Ne,{tone:R.pending?"warning":R.keep?"success":"muted",children:R.pending?"Needs approval":R.keep?"Keep":"Do not keep"})]}),t.jsx("p",{className:"break-words text-body leading-relaxed text-muted-foreground",children:R.why}),R.question&&t.jsx("p",{className:"text-small",children:R.question}),R.origin&&t.jsx("p",{className:"text-label text-muted-foreground",children:R.origin==="you"?"From your instruction":`Origin: ${R.origin}`})]},`${R.file}-${A}`))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"No item decisions reported."})]}):t.jsx("p",{className:"text-body text-muted-foreground",children:qm(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(R=>R.name).join(", "),". These changes required approval when recorded. Check their current status in Agent learning."]})]}),t.jsxs("section",{"aria-label":"Learning validation",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"Validation"}),($=x.problems)!=null&&$.length||(_=x.draft_errors)!=null&&_.length?t.jsxs("ul",{className:"space-y-3",children:[(P=x.problems)==null?void 0:P.map((R,A)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"text-body",children:R.detail}),t.jsx("p",{className:"mt-1 break-all font-mono text-label text-muted-foreground",children:[R.rule,R.path].filter(Boolean).join(" · ")})]},`problem-${A}`)),(O=x.draft_errors)==null?void 0:O.map((R,A)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"mb-1 font-mono text-label text-muted-foreground",children:"Workflow draft"}),t.jsx("p",{className:"break-words text-body",children:R})]},`draft-${A}`))]}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No validation problems reported."})]}),t.jsxs("section",{"aria-label":"Grading usage",children:[t.jsx("h3",{className:"mb-3 text-body font-semibold",children:"Grading usage"}),t.jsx("dl",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[["Grading cost",typeof((M=x.cost_usd)==null?void 0:M.grade)=="number"?Oa(x.cost_usd.grade):"Not reported"],["Input",df(v==null?void 0:v.input)],["Output",df(v==null?void 0:v.output)],["Cache reads",df(v==null?void 0:v.cache_read)],["Cache writes",df(v==null?void 0:v.cache_write)]].map(([R,A])=>t.jsxs("div",{className:"border p-3",children:[t.jsx("dt",{className:"mb-1 text-label text-muted-foreground",children:R}),t.jsx("dd",{className:"font-mono text-body",children:A})]},R))}),t.jsx("p",{className:"mt-3 text-label leading-relaxed text-muted-foreground",children:"Input excludes cache reads and writes. Reflection usage is included in the run's totals. These figures cover grading only."})]}),t.jsxs("section",{"aria-label":"Learning provenance",className:"border-t pt-4",children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h3",{className:"text-body font-semibold",children:"Provenance"}),s&&t.jsxs(B,{size:"sm",onClick:s,children:["View changes",t.jsx(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 X0=32,l9=360,c9=.7;function d9(e,n){const s=e.getBoundingClientRect().top;if(!n)return window.innerHeight-(s+window.scrollY)-X0;const r=s-n.getBoundingClientRect().top+n.scrollTop;return n.clientHeight-r-X0}const u9=(e,n)=>Math.round(Math.max(l9,Math.min(e,n*c9)));function f9(e,n,s=3e3,r=Math.min(s,m9),o=!1){const[i,c]=p.useState(null),[d,u]=p.useState(!1),f=p.useRef(e);f.current=e;const g=p.useRef(!1),y=p.useRef(!1),x=p.useRef(0),h=p.useRef(null),v=p.useRef(null),b=p.useRef(o);b.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&&!y.current){c(P=>P&&Z0(P));return}let E=!0,S;const N=P=>{clearTimeout(S),S=setTimeout(()=>{h.current=null,_()},P),h.current=()=>N(r)};let $=!1;const _=async()=>{try{const P=await f.current();if(!E)return;g.current=!0,P.state==="live"&&!b.current&&(v.current=P.kind);const O=P.state==="none"&&P.session==="opening"&&P.kind!=="browser"&&P.kind===v.current?{...P,session:"closed"}:P;y.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?M=>p9(M,O)?M:O:Z0(O))}catch(P){if(!E)return;if(P instanceof ze&&P.status===401){u(!0),c(O=>O?{state:"signed_out"}:null);return}if(P instanceof ze&&P.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()+h9,(S=h.current)==null||S.call(h)},[]);return{view:i,held:k}}const m9=400,h9=4e3,p9=(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))},Z0=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"},g9={browser:RN,desktop:Ya,phone:LN,sandbox:VT},x9={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},v9={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function b9({runId:e,screen:n,machine:s,opens:r,followUp:o,metered:i,waitsFor:c,keptUntil:d,onTake:u,onHand:f,recordings:g=[],fileUrl:y}){const x=p.useRef({viewer:"",n:0});(n==null?void 0:n.state)==="live"&&n.viewer!==x.current.viewer&&(x.current={viewer:n.viewer,n:x.current.n+1});const h=n&&n.state!=="signed_out"?n.kind:(s==null?void 0:s.kind)??"browser",v=(n==null?void 0:n.state)==="live"?N9(n.viewer,e):void 0,b=v&&h!=="browser"?`${v}${v.includes("#")?"&":"#"}hands=page`:v,j=g9[h],k=(n==null?void 0:n.state)==="live"?n:null,[E,S]=p.useState(!1),[N,$]=p.useState(null),_=async F=>{if(!(!F||E)){S(!0),$(null);try{$(await F())}finally{S(!1)}}},P=k&&b&&h!=="browser"?k:null,[O,M]=p.useState(!1),R=p.useRef(null),A=p.useRef(null),L=p.useRef(null),D=p.useRef(!1),W=!!(k&&b);p.useEffect(()=>{W||M(!1)},[W]);const[q,H]=p.useState(void 0);p.useLayoutEffect(()=>{const F=R.current;if(h!=="phone"||O||!W||!F)return;const z=F.closest("[data-scroll-pane]"),Y=()=>H(u9(d9(F,z),window.innerHeight));Y();const se=typeof ResizeObserver=="function"&&z?new ResizeObserver(Y):void 0;if(z)for(const Q of[z,...z.children])se==null||se.observe(Q);return window.addEventListener("resize",Y),()=>{se==null||se.disconnect(),window.removeEventListener("resize",Y)}},[h,O,W,N,i,x.current.n]),p.useEffect(()=>{var F,z,Y;if(O){D.current=!0,(z=(F=A.current)==null?void 0:F.querySelector("button"))==null||z.focus();return}D.current&&(D.current=!1,(Y=L.current)==null||Y.focus())},[O]),p.useEffect(()=>{if(!O)return;const F=re=>{if(re.key==="Escape"){M(!1);return}if(re.key!=="Tab"||!A.current)return;const te=[...A.current.querySelectorAll("button:not([disabled]), iframe")];if(!te.length)return;const he=te[0],ge=te[te.length-1],ye=document.activeElement;A.current.contains(ye)?re.shiftKey&&ye===he?(re.preventDefault(),ge.focus()):!re.shiftKey&&ye===ge&&(re.preventDefault(),he.focus()):(re.preventDefault(),he.focus())},z=re=>{re.key==="Escape"&&M(!1)};document.addEventListener("keydown",F);const Y=R.current;let se=null;const Q=()=>{try{se==null||se.removeEventListener("keydown",z,!0)}catch{}try{se=(Y==null?void 0:Y.contentWindow)??null,se==null||se.addEventListener("keydown",z,!0)}catch{se=null}};return Q(),Y==null||Y.addEventListener("load",Q),()=>{document.removeEventListener("keydown",F),Y==null||Y.removeEventListener("load",Q);try{se==null||se.removeEventListener("keydown",z,!0)}catch{}}},[O,x.current.n]);const K=k?h==="browser"?"browser · take over in the view below":`${v9[k.hold]} · ${h}`:"",U=P&&(P.hold==="person"?t.jsx(B,{size:"sm",variant:"solid",disabled:E,onClick:()=>void _(f),children:"Hand back"}):t.jsx(B,{size:"sm",variant:"solid",disabled:E||P.hold==="pending",onClick:()=>void _(u),children:P.hold==="pending"?"Taking over":"Take over"})),G=W&&t.jsx(B,{ref:O?void 0:L,size:"sm",variant:"ghost",onClick:()=>M(F=>!F),"aria-label":O?"Exit full window (Esc)":"Fill the window",title:O?"Exit full window (Esc)":"Fill the window","aria-pressed":O,children:O?t.jsx(zT,{className:"size-4","aria-hidden":!0}):t.jsx(LT,{className:"size-4","aria-hidden":!0})});return t.jsxs("section",{"aria-label":"Screen",className:"border",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2.5",children:[t.jsx(j,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:k?"Live":x9[h]}),t.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:K}),g.some(F=>!F.finished)&&t.jsx(Ne,{tone:"active",title:"A video of this screen is being recorded",children:"Recording"}),y&&g.filter(F=>F.finished).map((F,z,Y)=>t.jsxs("a",{href:`${y(F.path)}?download=1`,download:!0,className:rl({variant:"ghost",size:"sm"}),"aria-label":`Export ${F.path} (${Wa(F.bytes)})`,children:[t.jsx(_N,{"aria-hidden":!0})," Export",Y.length>1?` ${z+1}`:""]},F.path)),!O&&G,!O&&U]}),i&&h!=="browser"&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:ib}),!O&&N&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:N}),k&&b?t.jsxs("div",{ref:A,"data-testid":"screen-frame",className:O?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:O?"dialog":void 0,"aria-modal":O?!0:void 0,"aria-label":O?"The run's screen, filling the window":void 0,children:[O&&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}),G,U]}),O&&N&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:N}),t.jsx("iframe",{ref:R,src:b,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:O?"block min-h-0 w-full flex-1 bg-background":h==="phone"?ie("mx-auto block aspect-[9/19] max-w-full bg-background",q===void 0&&"h-[70vh]"):"block aspect-[16/10] w-full bg-background",style:!O&&h==="phone"&&q!==void 0?{height:`${q}px`}:void 0},x.current.n)]}):t.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:k9(h,n,s,r,o,c,d)})]})}const y9={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."},w9=/^The (desktop|phone) is kept for (\d+) minutes while you decide\.$/;function j9(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=w9.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 k9(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`${y9[i]} The ${e} is kept until ${eN(c).replace(/^at /,"")}.`;if(r&&(n==null?void 0:n.state)==="none"&&n.ended)return e==="browser"?`${n.ended.why} (${eN(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 eN(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:`at ${n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function N9(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 Hi=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},o$=e=>e.kind==="computer"?e.computer:"browser";function Rx(e,n){var s;if(e instanceof ze&&e.code==="handoff_answered"){const r=(s=e.details)==null?void 0:s.outcome;return r==="expired"?"The ask expired before your answer: the agent was told.":r==="done"||r==="cancelled"?`It was already answered: ${r}.`:e.message}return e instanceof ze&&e.code==="computer_not_live"?e.message:e instanceof ze&&e.status===404?n==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof ze&&e.status===403?"Sign in with your password to do this from here.":`${n==="hand"?"Not answered":"Not taken"}: ${Wt(e)}`}function a$({ask:e,onAnswer:n,open:s,heading:r,compact:o=!1}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),f=p.useRef(!1),g=async y=>{if(!n||f.current)return;f.current=!0,c(!0),u(null);let x=!1;try{const h=await n(y);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:ie("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-1"),children:[t.jsx(Ya,{className:"size-3.5","aria-hidden":!0})," Waiting for you · ",o$(e)]}),t.jsxs("div",{"data-agent-request":!0,className:ie("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 S9(e,n){const s=!!n&&qc(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:Vz(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 C9({got:e,retry:n}){if(e.state==="read"&&!e.changes.length)return null;const s=e.state==="failed"?Ht(e.error,"what it changed"):null;return t.jsxs("section",{className:"border","aria-label":"What it changed",children:[t.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"What it changed"}),e.state==="reading"&&t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:"Reading what it changed…"}),s&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 text-body",role:"alert",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't read what it changed: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)]}),t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})]}),e.state==="read"&&t.jsx("ul",{className:"divide-y",children:e.changes.map(r=>t.jsx("li",{children:t.jsx(E9,{change:r})},r.file))})]})}function E9({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:ie("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(tN,{name:"before",lines:e.before,none:"Not there before."}),t.jsx(tN,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function tN({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:ie("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:ie("min-w-0 whitespace-pre-wrap break-words",r.mark==="gap"&&"text-muted-foreground"),children:r.text})]},o))})]})}const $9=4e3,_9=e=>!!e.learning&&e.learning.reason!=="use",T9="The agent looks back on your words: what was wrong, and what a right answer does.",R9="A look-back needs words. Without them the grade is still kept.",A9='A JSON object of the fields a right answer holds, like {"total": 42}. Replays of a learned workflow are scored against it.',nN='Write it as a JSON object, like {"total": 42}, or leave it empty.';function O9(e){if(!e.trim())return{};try{const n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{value:n}:{error:nN}}catch{return{error:nN}}}function P9(e){const n=Ht(e,"the grade");return e instanceof ze&&e.status<500&&n.said?n.said:`${n.why} ${n.next}`}const L9="The review could not run.";function M9(e,n){return e.feedback&&e.feedback_status==="not_run"?L9:e.feedback==="look_back"?n?"The agent is looking back on your words.":"The agent looked back on your words.":"Kept for this agent."}function I9({run:e,graded:n,onGrade:s,onOpenTimeline:r}){const[o,i]=p.useState("auto"),[c,d]=p.useState(""),[u,f]=p.useState(""),[g,y]=p.useState(!1),[x,h]=p.useState(!1),[v,b]=p.useState(null),j=p.useRef(!1),k=Ha(e.status),E=n!=null&&n.feedback?n.feedback_status:null,S=E==="running"||E==="ended"&&qm(e.learning??void 0);if(!_9(e)||!k&&!n)return null;const N=o==="auto"?n?"closed":"choose":o,$=k&&!S,_=O9(u),P=n?M9(n,S):null,O=async M=>{if(j.current||!s)return;const R=M?"":c.trim();if(!M&&_.error){y(!0);return}j.current=!0,h(!0),b(null);try{await s({correct:M,...R?{label:R}:{},...!M&&_.value?{expected:_.value}:{}}),i("auto"),d(""),f(""),y(!1)}catch(A){b(P9(A))}j.current=!1,h(!1)};return t.jsxs("section",{className:"border","aria-label":"Grade",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Grade"}),n&&t.jsxs(Ne,{tone:n.correct?"success":"error",children:["Graded ",n.correct?"right":"wrong"]}),S&&t.jsx(Ne,{tone:"active",children:"Reviewing"}),t.jsx("span",{className:"flex-1"}),n&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(n.graded_at)})]}),t.jsxs("div",{className:"space-y-3 px-4 py-3",children:[P&&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:P}),r&&!!(n!=null&&n.feedback)&&t.jsx(B,{type:"button",size:"xs",variant:"ghost",onClick:r,children:"Open the Timeline"})]}),$&&N==="closed"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:!s,onClick:()=>{i("choose"),b(null)},children:"Grade again"}),t.jsx("span",{className:"text-small text-muted-foreground",children:"A new grade replaces this one."})]}),$&&N==="choose"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"Was the answer right? Your grade teaches the agent."}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:x||!s,onClick:()=>void O(!0),children:"Right"}),t.jsx(B,{type:"button",size:"sm",disabled:x||!s,onClick:()=>{i("wrong"),b(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:M=>{M.preventDefault(),O(!1)},children:[t.jsx(wt,{label:"What was wrong?",note:T9,warning:c.trim()?void 0:R9,children:t.jsx(nn,{value:c,onChange:M=>d(M.target.value),maxLength:$9,rows:3,disabled:x,className:"resize-y font-sans text-lead"})}),t.jsx(wt,{label:"Correct answer",optional:!0,note:A9,error:g?_.error:void 0,children:t.jsx(nn,{value:u,onChange:M=>{f(M.target.value),y(!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"),y(!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 z9=(e,n)=>n&&(!e||Date.parse(n.graded_at)>Date.parse(e.graded_at))?n:e;function D9(e,n,s){const r=!!s&&!!e.learning,[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,y]=p.useState(0);p.useEffect(()=>{if(!r)return;let j=!0;return Promise.resolve().then(()=>s()).then(k=>{j&&(i(k??null),f(0))},()=>{j&&(i(null),f(k=>k+1))}),()=>{j=!1}},[e.run_id,r,n,e.ended_at,g]);const x=p.useCallback(({expected:j,...k})=>{d({run:k.run_id,grade:{...k,feedback_status:k.feedback?"running":null}})},[]),h=r?o:null,v=z9((h==null?void 0:h.graded)??null,(c==null?void 0:c.run)===e.run_id?c.grade:null),b=r&&(v==null?void 0:v.feedback_status)==="running";return p.useEffect(()=>{if(!b||u===0||u>F9)return;const j=setTimeout(()=>y(k=>k+1),ex(u-1));return()=>clearTimeout(j)},[b,u]),{read:h,grade:v,graded:x}}const F9=8,U9=e=>e===1?"once":e===2?"twice":`${e} times`;function W9({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:Km(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(kf,{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(Ne,{tone:"success",children:"Read"}):t.jsx(Ne,{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(Qa,{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 ",U9(s.calls)]}),s.failed>0&&t.jsxs(Ne,{tone:"error",children:[s.failed," failed"]})]},`workflow:${s.name}`))]})]})}const Ii=(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}),Rr=(e,n=[])=>({type:"object",additionalProperties:!1,properties:e,...n.length?{required:n}:{}}),H9={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:Rr({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},B9=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."}),G9=e=>`Browse and automate websites in the persistent browser. ${B9.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"}]}.`,q9={name:"run",label:"Browser: run",description:G9(),parameters:Rr({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},Ii("click"),Ii("hover"),Ii("fill",{value:{type:"string"}}),Ii("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),Ii("press",{key:{type:"string"}}),Ii("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},K9={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:Rr({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:{...Rr({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"},V9={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:Rr({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},Y9={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:Rr({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},Q9={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:Rr({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"},J9={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:Rr({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"},X9={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:Rr({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},Z9={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:Rr({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"},eH=Object.freeze([H9,q9,K9,V9,Y9,Q9,J9,X9,Z9]),tH=Object.freeze(eH.map(e=>e.name)),nH={"com.apple.systempreferences":"System Settings","com.apple.iCal":"Calendar","com.apple.finder":"Finder","com.android.settings":"Settings","com.android.chrome":"Chrome","com.android.deskclock":"Clock","com.android.contacts":"Contacts","com.android.documentsui":"Files","org.wikipedia":"Wikipedia","xfce4-terminal":"Terminal","org.xfce.terminal":"Terminal",xterm:"XTerm","firefox-esr":"Firefox","google-chrome":"Chrome"};function sH(e){const n=e.split(".").at(-1)||e;return nH[e]??(n?n[0].toUpperCase()+n.slice(1):e)}const rH=new Set(["enter","tab","space","backspace","delete","escape","insert","up","down","left","right","home","end","pageup","pagedown","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12","shift","ctrl","alt","super","capslock"]),oH=new Set(["ctrl","alt","super"]);function aH(e){if(typeof e!="string"||!e)return;const s=(e.endsWith("++")?[...e.slice(0,-2).split("+"),"+"]:e.split("+")).map(r=>r.toLowerCase());return s.some(r=>oH.has(r))||s.every(r=>rH.has(r))?e:void 0}const iH=["press","set","perform","click","type","key","nav","scroll","drag"];function lH(e,n){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=iH.find(u=>u in s)??"step",o=r==="type"?s.into:s[r],i=typeof o=="string"?n(o):void 0,c=r==="key"?aH(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 cH={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"},dH=new Set(["button","link","menuitem","tab","listitem","row","cell","radio","generic","text","heading"]);function uH(e){if(!e)return;const n=cH[e.role]??(e.role==="generic"?"element":e.role);return e.name?dH.has(e.role)?`“${e.name}”`:`the ${n} “${e.name}”`:`the ${n}`}const fH={s:["Saved","save"],a:["Selected all","select all"],c:["Copied","copy"],v:["Pasted","paste"],x:["Cut","cut"],z:["Undid","undo"],w:["Closed the window","close the window"],q:["Quit","quit"],t:["Opened a new tab","open a new tab"]},mH={super:"⌘",shift:"⇧",alt:"⌥",ctrl:"⌃"},$g={enter:"Return",escape:"Esc",tab:"Tab",space:"Space",backspace:"Delete",delete:"Forward Delete",up:"↑",down:"↓",left:"←",right:"→"},pn=(e,n,s="")=>({did:`${e}${s}`,tried:`${n}${s}`});function hH(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&&$g[s.toLowerCase()]?$g[s.toLowerCase()]:`${r.map(c=>mH[c]??`${c}+`).join("")}${$g[s.toLowerCase()]??(s.length===1?s.toUpperCase():s)}`,i=r.length===1&&r[0]==="super"?fH[s.toLowerCase()]:void 0;return i?pn(i[0],i[1],` (${o})`):pn("Pressed","press",` ${o}`)}const pH={back:["Went","go"," back"],home:["Went","go"," home"],app_switch:["Opened","open"," the recent apps"]};function gH(e){const n=uH(e.on),s=r=>` ${n??r}`;switch(e.do){case"press":return pn("Pressed","press",s("an element"));case"click":return pn("Clicked","click",n?` ${n}`:" at a point");case"set":return pn("Set","set",s("an element"));case"perform":return pn("Acted on","act on",s("an element"));case"type":return n?pn("Typed into","type into",` ${n}`):pn("Typed text","type text");case"key":return e.keys?hH(e.keys):pn("Pressed a key","press a key");case"nav":{const[r,o,i]=e.nav&&pH[e.nav]||["Navigated","navigate",""];return pn(r,o,i)}case"scroll":return n?pn("Scrolled","scroll",` ${n}`):pn("Scrolled","scroll");case"drag":return pn("Dragged","drag"," across the screen");default:return pn("Acted","act")}}function sN(e){const n=gH(e);return e.error===void 0?n.did:`Could not ${n.tried}`}const rN=3,Ax=e=>e[0].toLowerCase()+e.slice(1);function xH(e){const n=e.slice(0,rN).map(sN),s=e.slice(rN),r=s.findIndex(i=>i.error!==void 0),o=r<0?s.length:s.length-1;return[n[0],...n.slice(1).map(Ax),...o>0?[`+${o} more`]:[],...r<0?[]:[Ax(sN(s[r]))]].join(", ")}const vH={"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 Er(e){const n=e.app?sH(e.app):void 0,s=(()=>{var r;switch(e.method){case"apps.launch":return pn("Opened","open",` ${n??"an app"}`);case"apps.terminate":return pn("Quit","quit",` ${n??"an app"}`);case"ui.observe":return pn("Looked at","look at",` ${n??"the window"}`);case"ui.act":return e.ok&&((r=e.steps)!=null&&r.length)?{did:xH(e.steps),tried:""}:e.ok?pn("Waited for","wait for",` ${n??"the window"}${e.expect==="unmet"?" (not seen)":""}`):pn("Acted on","act on",` ${n??"the computer"}`);default:{const[o,i]=vH[e.method]??[e.method,e.method];return pn(o,i)}}})();return e.ok?s.did:`Could not ${s.tried}`}const bH=e=>e.map((n,s)=>s===0?Er(n):Ax(Er(n))).join(", "),i$='\\s"`<>\\\\',yH=new RegExp(`https?://[^${i$}|]+`,"gi"),wH=new RegExp(`https?://[^${i$}]+`,"gi"),jH=".,;:!?*)]}'",kH={")":"(","]":"[","}":"{"};function NH(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&&jH.includes(e[s-1]);s--){const r=e[s-1],o=kH[r];if(o&&n[o]>=n[r])break;o&&(n[r]-=1)}return e.slice(0,s)}new RegExp(`\\]\\(|${yH.source}`,"gi");const qo=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,un=e=>typeof e=="string"?e:void 0,qa=(e,n)=>e.length>n?`${e.slice(0,n-3)}...`:e,l$=e=>e.split(`
709
- `).map(n=>n.trim()).find(Boolean)??"";function am(e){try{return qo(JSON.parse(e))}catch{return}}const SH=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function Xc(e){const n=SH.exec(e.trim());return qa(n?`${n[1]}${n[2]==="/"?"":n[2]}`:e.split(/[?#]/)[0]??"",80)}const CH="…",EH=/https?:\/\//gi,$H=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i,_H=/(https?:\/\/)[^@/?#\s]*@/gi,TH=/[A-Za-z0-9]/;function _b(e){return e.replace(wH,n=>{const s=[0];let[r,o]=[0,!1];for(const i of n.matchAll(EH)){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)&&!TH.test(n[d]);d--)c||(c=n[d]==="'");c&&s.push(i.index)}return s.map((i,c)=>RH(n.slice(i,s[c+1]??n.length))).join("")})}function RH(e){const n=NH(e).length,s=$H.exec(e.slice(0,n));if(!s)return e;const r=i=>i.replace(_H,"$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}=${CH}`).join("&")}`:""}${e.slice(n)}`}const AH=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),OH=new Map,PH=new Map,c$=new Map,LH=new Set;function fn(e,n,s,{name:r,saysFailure:o}={}){OH.set(e,n),s&&PH.set(e,s),r&&c$.set(e,r),o&&LH.add(e)}const MH=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,IH=/^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/,zH=e=>{const n=IH.exec(e)??MH.exec(e);return n&&n[1]!=="hands"?`${n[1]} · ${n[2]}`:void 0},DH=e=>c$.get(e)??zH(e)??e,FH=new Map;function Tb(e,n){FH.set(e,n)}const UH=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...UH];const Rb=e=>un(e.path)??un(e.file_path),WH=/page\.goto\(\s*["'`]([^"'`]+)/;fn("read",e=>`Read ${Rb(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});fn("write",e=>`Wrote ${Rb(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});fn("edit",e=>`Edited ${Rb(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});fn("bash",e=>`Ran \`${qa(_b(l$(un(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const d$=e=>{const n=e&&qo(am(e.text)??am(l$(e.text)));if((n==null?void 0:n.ok)!==!1)return;const s=un(n.refused);return s!==void 0?{refused:!0,detail:s.replace(/^refused:\s*/,"")}:{refused:!1,detail:un(n.error)??un(n.message)??"no detail"}},HH=(e,n)=>`${d$(n)?"Tried to fetch":"Fetched"} ${Xc(un(e.url)??"a page")}`,BH={many:e=>`Fetched ${e} pages`,subject:e=>e?Xc(e):void 0},GH=e=>{const n=d$(e);return n&&{failed:!0,text:`${n.refused?"refused":"failed"}: ${n.detail}`}};fn("web_fetch",HH,BH,{name:"Fetch web pages"});Tb("web_fetch",GH);fn("web_search",e=>{const n=un(e.query);return n?`Searched the web for "${qa(_b(n),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${qa(e,40)}"`:void 0},{name:"Search the web"});Tb("web_search",e=>{var s;const n=un((s=qo(am(e.text)))==null?void 0:s.error);return n!==void 0?{failed:!0,text:`failed: ${n}`}:void 0});fn("browser_read",(e,n)=>{var r;const s=n&&((r=/^title: (.+)$/m.exec(n.text))==null?void 0:r[1]);return s?`Read the page "${qa(_b(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?Xc(s):void 0}},{name:"Read the browser's page"});fn("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});fn("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});fn("run",(e,n)=>{var i,c;const s=(i=WH.exec(un(e.code)??""))==null?void 0:i[1];if(s)return`Opened ${Xc(s)}`;const r=(c=qo(n==null?void 0:n.details))==null?void 0:c.sent,o=Array.isArray(r)?r.flatMap(d=>{const u=qo(d),[f,g]=[un(u==null?void 0:u.method),un(u==null?void 0:u.url)];return f&&g?`${f} ${Xc(g)}`:[]}):[];return o.length?`Acted on the page (${o.length} request${o.length===1?"":"s"} sent: ${AH(o)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});fn("browser_downloads",(e,n)=>{var o;const s=n&&((o=am(n.text))==null?void 0:o.fetched),r=Array.isArray(s)?s.flatMap(i=>{var c;return un((c=qo(i))==null?void 0:c.name)??[]}):[];return r.length===1?`Downloaded ${r[0]}`:r.length?`Downloaded ${r.length} files`:"Downloaded files"},{many:e=>`Downloaded files ${e} times`},{name:"Download files in the browser"});fn("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});fn("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});fn("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});fn("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});fn("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const qH=/^(\d+)\. [a-z_.]+(?: into)?(?: @\S+ ([a-z]+)(?: ("(?:[^"\\]|\\.)*"))?)?(?: \[secure\])?: (.*)$/,KH=e=>{if(e!==void 0)try{return un(JSON.parse(e))}catch{return}};function u$(e){var s;const n=new Map;for(const r of(e??"").split(`
710
- `)){const o=qH.exec(r);if(!o)continue;const i=KH(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 VH(e,n){return{...lH(e,()=>n==null?void 0:n.on),...(n==null?void 0:n.refused)!==void 0?{error:"refused"}:{}}}fn("computer_act",(e,n)=>{var d;const s=Array.isArray(e.steps)?e.steps.flatMap(u=>{const f=qo(u);return f?[f]:[]}):[],r={method:"ui.act",started_at:"",ms:0,...un(e.app)?{app:un(e.app)}:{}};if(n!=null&&n.isError)return Er({...r,ok:!1});const o=n===void 0?void 0:u$(n.text),i=o===void 0?s:s.filter((u,f)=>o.has(f+1));if(s.length>0&&i.length===0)return Er({...r,ok:!1});const c=n&&((d=/^expect: (met|unmet)$/m.exec(n.text))==null?void 0:d[1]);return Er({...r,ok:!0,steps:i.map((u,f)=>VH(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});Tb("computer_act",e=>{for(const[n,s]of u$(e.text))if(s.refused!==void 0)return{failed:!0,text:`step ${n} refused: ${s.refused}`}});const oN=/^state \S+ · (\S+)/,YH=/^screen \S+ px · (?:\S+ in front|no app in front)/;fn("computer_observe",(e,n)=>{var r;if(n&&!n.isError&&!oN.test(n.text)){const o=YH.test(n.text),i=(d,u)=>({method:d,started_at:"",ms:0,ok:!0,...u?{app:u}:{}}),c=o?un(e.app):void 0;return bH([...c?[i("apps.launch",c)]:[],i("screen.shot"),...o?[i("apps.list")]:[]])}const s=un(e.app)??(n&&((r=oN.exec(n.text))==null?void 0:r[1]));return Er({method:"ui.observe",ok:(n==null?void 0:n.isError)!==!0,...s?{app:s}:{}})},{many:e=>`Looked at the screen ${e} times`},{name:"Look at the computer",saysFailure:!0});fn("computer_screenshot",(e,n)=>Er({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 aN={"input.act":"input.actions","apps.list":"apps.list","apps.open":"apps.launch","shell.run":"exec.run","processes.start":"process.start","files.read":"files.read","files.write":"files.write","files.list":"files.list","files.stat":"files.stat"};fn("computer_op",(e,n)=>{var i;const s=un(e.op),r=s!==void 0&&Object.hasOwn(aN,s)?aN[s]:void 0;if(!r)return n!=null&&n.isError?"Could not act on the computer":"Acted on the computer";const o=r==="apps.launch"?un((i=qo(e.args))==null?void 0:i.id):void 0;return Er({method:r,ok:(n==null?void 0:n.isError)!==!0,...o?{app:o}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Use the computer's apps, shell and files",saysFailure:!0});fn("computer_script",(e,n)=>{var r;const s=(r=un(e.title))==null?void 0:r.replace(/\s+/g," ").trim();return n!=null&&n.isError?s?`Could not run the script “${qa(s,120)}”`:"Could not run a script on the computer":s?qa(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 QH=["schedule","webhook","slack","github","composio","email","feed"];new Set(QH);const JH=":feedback",XH=e=>{var n;return e.kind==="user_message"&&((n=e.id)==null?void 0:n.endsWith(JH))===!0},ZH={user_message:Yx,thinking:Nf,tool_use:Sf,tool_result:Sf,waiting:Bx,usage:Ux,final_answer:Va,phase:TN,error:tl,decision:BT,text_block:IT,tool_approval_requested:PN},iN=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},lN=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),Ab=e=>e.origin==="server",f$=e=>e.origin==="trigger",m$=e=>{var i;const n=e.summary??"",s=(i=e.trigger)==null?void 0:i.name,r=s?n.indexOf(` ${s}: `):-1;if(s&&r>0&&!n.slice(0,r).includes(" "))return{who:n.slice(0,r+1+s.length),said:n.slice(r+s.length+3).trimStart()};const o=/^([^:]+):\s*/.exec(n);return o?{who:o[1],said:n.slice(o[0].length)}:{who:null,said:n}};function h$(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:h$(s.slice(2,-2))},r))}const e7=e=>{var r;const n=f$(e)?m$(e).said:(e.summary??"").replace(Ab(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())?b2:`${n.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${s}`:e.kind==="user_message"?`${n}${s}`:n},Zc=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,t7=new Set(tH),n7=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 s7(e){const n=n7.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 cN=e=>e&&(hI(e)??(t7.has(e)?DH(e):s7(e))),dN=e=>Ab(e)?"AgentRun":f$(e)?m$(e).who??"Trigger":XH(e)?"Your grade":{user_message:"You",thinking:"Thinking",tool_use:cN(e.tool_name)??"Tool",tool_result:cN(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,r7={budget:"Paused at cap"};function o7({step:e,last:n,ended:s,waitingChip:r,files:o,onOpen:i}){var b,j;const c=e.row,[d,u]=p.useState(!1),g=DP(c)?$N:ZH[c.kind]??TN,y=e.above?c.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":e7(c),x=e.above?null:e.detail??XS(c),h=x&&x.trim()!==y.trim()?x:null,v=e2(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:ie("mt-3 flex size-7 items-center justify-center border bg-background",(c.kind==="waiting"||lN(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:dN(c),children:dN(c)}),(c.kind==="tool_use"||c.kind==="tool_result")&&c.usage&&t.jsxs("span",{className:"font-mono text-label",children:["· ",OP(c.usage,{ended:s})]}),c.kind==="waiting"&&t.jsx(Ne,{tone:"warning",children:r??"Input required"}),lN(c)&&t.jsx(Ne,{tone:"warning",children:"Approval required"}),v&&t.jsx(Ne,{tone:"error",children:"Error"}),ZS(c)&&t.jsx(Ne,{tone:"muted",title:"Not run: refused before it ran",children:"Refused"}),c.agent_label&&t.jsx(Ne,{label:!0,title:c.agent_label,children:c.agent_label}),e.ms!==void 0&&t.jsx("span",{className:"font-mono text-label",children:Zc(e.ms)}),e.times&&t.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${Zc(Math.max(0,Date.parse(e.until)-Date.parse(c.timestamp)))}`:""]})]}),t.jsx("span",{className:ie("mt-0.5 block break-words text-prose leading-snug",Ab(c)&&"text-muted-foreground"),children:h$(y)}),e.saved&&t.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),iN(c)&&t.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:iN(c)})]}),t.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:ud(c.timestamp)}),h&&t.jsx(Es,{className:ie("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:Sv(k=>{const E=o==null?void 0:o.find(S=>S.path===k);E&&(i==null||i(E))}),dangerouslySetInnerHTML:{__html:no(h,i&&o?{paths:o.map(k=>k.path)}:void 0)}}),d&&h&&c.kind!=="final_answer"&&t.jsx("pre",{className:"mt-3 max-h-80 overflow-auto whitespace-pre-wrap break-words border bg-card p-3 font-mono text-small leading-[1.7]",children:h}),(b=c.learned_nodes)!=null&&b.length?t.jsx(l7,{nodes:c.learned_nodes}):null,(j=c.computer_calls)!=null&&j.length?t.jsx(a7,{calls:c.computer_calls,dropped:c.computer_calls_dropped??0}):null]})]})}function a7({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:ie("size-3 transition-transform",s&&"rotate-90"),"aria-hidden":!0}),t.jsx(Ya,{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:["+",Zc(Math.max(0,Date.parse(u.started_at)-d))]}),t.jsx("span",{className:ie("min-w-0 flex-1 truncate text-body",!u.ok&&"text-destructive-text"),title:Er(u),children:Er(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:Zc(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 i7={ok:"success",failed:"error",escalated:"warning"};function l7({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:ie("size-3 transition-transform",n&&"rotate-90"),"aria-hidden":!0}),t.jsx(Qa,{className:"size-3","aria-hidden":!0}),o]}),n&&t.jsx("ol",{"aria-label":"The workflow's nodes",className:"mt-2 divide-y border bg-card",children:e.map((i,c)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[t.jsx("span",{"data-status":i.status,className:"contents",children:t.jsx(Ne,{tone:i7[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:V2(i)||void 0,children:Yv(i.kind,i)}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:Zc(i.duration_ms)})]},c))})]})}function c7({rows:e,live:n,fold:s=6,asking:r,waitingOn:o,files:i,onOpen:c,ended:d=!1}){var b;const u=o==="budget"?e.findLastIndex(j=>j.paused===!0):-1,f=u>=0?(b=e.slice(u+1).findLast(j=>j.kind==="waiting"))==null?void 0:b.id:void 0,[g,y]=p.useState(!1),x=FP(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:()=>y(!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(o7,{step:j,last:k===v.length-1&&!n,ended:d,waitingChip:j.row.id===f&&o?r7[o]:void 0,files:i,onOpen:c},j.row.id))}),n&&t.jsx(Ox,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):t.jsx(Ox,{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 Ox({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(y5,{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 d7={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."},u7={steer:{label:"Steer the run",placeholder:"Steer the run...",does:"A message steers the run; it doesn't answer the ask. Do it on the screen, then Done or Cancel above."},follow_up:{label:"Message the run",placeholder:"Message the run...",does:"A message goes to the run after its turn; it doesn't answer the ask. Do it on the screen, then Done or Cancel above."}};function f7(e,n){var r,o;if(e.status==="input_required"&&((r=e.pending)==null?void 0:r.kind)==="budget"){const{cap_usd:i,spent_usd:c,held_usd:d}=e.pending,u=typeof i=="number"&&Number.isFinite(i),f=typeof d=="number"&&d>0?`, and holds ${Qr(d)} for steps still running`:"";return{title:"Paused at its spend cap",note:`${u&&typeof c=="number"?`It has spent ${Qr(c)} of its ${Qr(i)} cap${f}.`:u?`Its ${Qr(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=Hi(e);return s?{title:`Waiting for you at the ${o$(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 m7({run:e,agentName:n,messages:s,harnessSteers:r,rows:o,files:i,outputSchema:c,readFile:d,fileUrl:u,openFile:f=null,actions:g,onMessage:y,onApprove:x,tab:h,graphView:v,costText:b,readLearningDiff:j,readLearning:k,readLearningResult:E,readComputer:S,computerEvery:N,onTakeOver:$,onHandBack:_,readComputers:P,onGrade:O}){var Ue,Xe,at,J,ve,We,Ve;const M=e.native,R=es(e),A=((Ue=e.pending)==null?void 0:Ue.kind)==="budget"?e.pending:null,L=Hi(e),D=!R&&!M&&L?r&&s.steer?"steer":s.follow_up?"follow_up":null:null,W=Dm(e.status,e.state,e.kind,s,r,e.error,e.review,e.computer),q=R||M||A?{...W,canMessage:!1,messageMode:null}:L?{...W,canMessage:D!==null,messageMode:D}:W,H=v?"graph":q.final&&e.status==="completed"?"report":"timeline",[K,U]=p.useState(h??H),G=K==="graph"&&!v?H:K,[F,z]=p.useState(!1),[Y,se]=p.useState(f?{file:f,text:null}:null),Q=PW(e),re=Q||L?null:CL(e.status,e.state,o),te=Q?o.findLast(He=>He.kind===QE&&He.tool_use_id===Q.call_id):void 0,[he,ge]=p.useState(null),ye=async(He,gt,kt,lt)=>{const Vt=x?await(lt?x(He,gt,kt,lt):x(He,gt,kt)):"This page can't answer an approval.";return ge(Vt?{id:He,text:Vt}:null),Vt},xe=p.useRef(y2()).current,fe=async He=>{const gt=xe.begin();if(se({file:He,text:null}),!d)return;const kt=await d(He);xe.current(gt)&&se({file:He,text:kt})},De=()=>{xe.cancel(),se(null)},Fe=S9(e,j),{read:Le,grade:Ee,graded:ae}=D9(e,q.final,k),$e=O&&(async He=>{const gt=await O(He);return ae(gt),gt}),ot=q.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",me=e.computer,Me=me?j9(o,me.kind):void 0,{view:Ze,held:bt}=f9(S,!q.final,N,void 0,e.status==="queued"||Me!==void 0),oe=!!Ze||!!me||!!L,Se=p.useRef(!1);p.useEffect(()=>{if(oe){Se.current=!0;return}Se.current&&G==="screen"&&U(H),Se.current=!1},[oe,G,H]);const[tt,Ae]=p.useState(!1);p.useEffect(()=>{if(!me||!lb.has(me.kind)||!P)return;let He=!0;return P().then(gt=>{var kt,lt;He&&Ae(!!((lt=(kt=gt.kinds.find(Vt=>Vt.kind===me.kind))==null?void 0:kt.providers.find(Vt=>Vt.id===me.provider))!=null&&lt.metered))}).catch(()=>{}),()=>{He=!1}},[me==null?void 0:me.kind,me==null?void 0:me.provider]);const it=L?`${L.kind}:${L.asked_at}`:null,$t=p.useRef(null);p.useEffect(()=>{!it||$t.current===it||!oe||($t.current=it,U("screen"))},[it,oe]);const nt=async()=>{if(!$)return"This page can't take the computer over.";try{return bt((await $()).hold),null}catch(He){return Rx(He,"take")}},ft=async He=>{if(!_)return"This page can't hand the computer back.";try{return bt((await _(He)).hold),null}catch(gt){return Rx(gt,"hand")}},[Dt,Ft]=p.useState(null),be=async He=>{const gt=(L==null?void 0:L.asked_at)??"",kt=await ft(He);return Ft(kt?{at:gt,text:kt}:null),kt};p.useEffect(()=>{f&&d&&fe(f)},[f]);const de=[...v?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],...e.learning?[["learning","Learning"]]:[],["files",`Files ${s$(i,F).length}`],...oe?[["screen","Screen"]]:[]];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[t.jsx(YW,{run:e,agentName:n,actions:g,costText:b}),t.jsx(TS,{id:"run-views",label:"Run views",value:G,onChange:He=>U(He),tabs:de.map(([He,gt])=>({id:He,label:gt}))}),G==="graph"?t.jsx("div",{className:"min-h-0 flex-1 short:min-h-96",children:v}):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:[M&&t.jsx(o9,{native:M,agentId:e.agent_id}),e.status==="failed"&&e.error&&t.jsx(sa,{error:e.error,title:S2(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."]})]}),he&&he.id!==(Q==null?void 0:Q.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: ",he.text]}),Dt&&Dt.at!==(L==null?void 0:L.asked_at)&&t.jsxs("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:["Your answer wasn't taken: ",Dt.text]}),Q?t.jsx(XE,{pending:Q,onAnswer:(He,gt,kt)=>kt?ye(Q.id,He,gt,kt):ye(Q.id,He,gt)},Q.id):L?t.jsx(a$,{ask:L,onAnswer:_?be:void 0,open:G!=="screen"?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>U("screen"),children:"Open the screen"}):null},it):!M&&q.needsYou&&(A?t.jsx(WW,{pending:A}):t.jsx(BW,{waiting:re})),q.needsYou&&A&&typeof A.cap_usd=="number"&&(g==null?void 0:g.onRaiseCap)&&t.jsx(n$,{cap:A.cap_usd,suggested:e$(A),least:t$(A),paused:!0,onRaise:g.onRaiseCap},`${e.run_id}:${A.at}`),G==="report"&&t.jsx(r9,{run:e,rows:o,files:i,onOpen:fe,schema:c}),G==="report"&&!e.result&&!q.final&&t.jsx(Ox,{...f7(e,q)}),G==="report"&&q.final&&!((at=(Xe=e.result)==null?void 0:Xe.final_answer)!=null&&at.trim())&&!((J=e.result)!=null&&J.output)&&!o.some(He=>{var gt;return He.kind==="final_answer"&&((gt=He.text)==null?void 0:gt.trim())})&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:[b2,q.canMessage?" Send a follow-up below to ask for one.":""]}),G==="timeline"&&t.jsx(c7,{rows:Gz(o,e.learning),live:q.live,ended:Ha(e.status),asking:(te==null?void 0:te.id)??(q.needsYou&&!A?re==null?void 0:re.id:void 0),waitingOn:e.status==="input_required"?(ve=e.pending)==null?void 0:ve.kind:void 0,files:i,onOpen:fe}),(G==="report"||G==="timeline")&&t.jsx(I9,{run:e,graded:Ee,onGrade:$e,onOpenTimeline:G==="timeline"?void 0:()=>U("timeline")}),(G==="report"||G==="timeline")&&t.jsx(W9,{used:(Le==null?void 0:Le.used)??null,agentId:e.agent_id}),(G==="report"||G==="timeline")&&Fe&&t.jsx(C9,{got:Fe.got,retry:Fe.retry}),G==="learning"&&t.jsx(i9,{run:e,read:E,onViewChanges:Fe?()=>U("report"):void 0},e.run_id),G==="files"&&t.jsx(XW,{files:i,onOpen:fe,showHidden:F,onShowHidden:z}),G==="screen"&&oe&&t.jsx(b9,{runId:e.run_id,screen:Ze,machine:me,opens:ot,followUp:q.canMessage&&q.messageMode==="follow_up",metered:tt,waitsFor:e.status==="input_required"&&((We=e.pending)==null?void 0:We.kind)!=="stopped"?(Ve=e.pending)==null?void 0:Ve.kind:void 0,keptUntil:e.status==="input_required"?Me:void 0,onTake:$?nt:void 0,onHand:_?()=>ft():void 0,recordings:e.recordings,fileUrl:u})]})}),M&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:["Native sessions cannot receive steering or follow-up messages. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(e.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," for another task."]}),R&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:[Ko(R.runtime)," runs in your backend. Start, stop and follow up through that application's controls. AgentRun records the result and checked learning."]}),q.canMessage&&t.jsx("div",{className:"border-t px-5 py-4 md:px-8",children:t.jsx("div",{className:"mx-auto max-w-4xl",children:t.jsx(UW,{mode:q.messageMode,onSend:y,purpose:Q?d7:L&&D?u7[D]:void 0})})}),Y&&t.jsx(ZW,{file:Y.file,text:Y.text,onClose:De,files:i,onOpen:fe})]})}const p$=new Set(["chain","parallel","route","map","loop","workflow"]),h7={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},p7=e=>e==="review"?"needs review":e.replace("-"," ");function Ob({state:e}){const n=Df(e)??"pending";return t.jsx(Ne,{tone:h7[n]??"plain",className:"whitespace-nowrap",children:p7(n)})}function Pb({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 g$={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},Lb=(e,n)=>e&&n?Date.parse(n)-Date.parse(e):void 0;function g7({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=Av(e.workflow,i.path,i),g=i.kind==="map"?i.path:(j=e.graph.nodes.find(_=>_.kind==="map"&&i.path.startsWith(`${_.path}/body/`)))==null?void 0:j.path,y=n.item!=null&&g?(E=(k=e.nodes[g])==null?void 0:k.items)==null?void 0:E.find(_=>_.index===n.item):void 0,x=e.decisions.filter(_=>_.node===i.path),h=e.effects.filter(_=>_.node===i.path),v=!!g&&i.kind!=="map",b=Lb(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:Yv(i.kind,u),f.tool?` · ${b$(f.tool)}`:i.via?` · ${i.via}`:"",f.tool&&yd(f.tool)&&t.jsx(y$,{}),y&&t.jsxs(t.Fragment,{children:[t.jsx(Es,{className:"size-3","aria-hidden":!0})," item ",y.index+1]})]}),t.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:y?Wc(e,g,y.index)??`Item ${y.index+1}`:i.label}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t.jsx(Ob,{state:y?y.status:u==null?void 0:u.status}),y&&(()=>{const _=Ov(e,g,y);return _.outcome?t.jsxs("span",{className:"font-mono text-label",title:_.pNote,children:["outcome ",t.jsx("b",{className:g$[_.tone??""],children:_.outcome}),_.p!==void 0&&t.jsxs("span",{className:"text-muted-foreground",children:[" · ",Bs(_.p)]})]}):null})(),f.decision&&t.jsx(Pb,{provider:f.provider}),f.decision&&((u==null?void 0:u.model)??f.model)&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:(u==null?void 0:u.model)??f.model}),(u==null?void 0:u.branch)&&t.jsxs("span",{className:"font-mono text-label",children:["took ",t.jsx("b",{children:u.branch})]}),!y&&b!==void 0&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Yi(b)})]})]}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:r,children:t.jsx(Qo,{"aria-hidden":!0})})]}),y&&t.jsxs("button",{type:"button",className:"caps mt-3 text-label text-muted-foreground hover:text-foreground",onClick:()=>s({path:g,item:null}),children:["All ",(N=(S=e.nodes[g])==null?void 0:S.items)==null?void 0:N.length," items of ",($=e.graph.nodes.find(_=>_.path===g))==null?void 0:$.label]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[y?t.jsx(y7,{data:e,mapPath:g,index:y.index,status:y.status,fileUrl:o,zoom:d}):i.kind==="map"?t.jsx(x7,{data:e,mapPath:i.path,onSelect:s}):v&&(x.length||h.length)?t.jsx(v7,{data:e,path:i.path,mapPath:g,onSelect:s}):t.jsxs(t.Fragment,{children:[i.kind==="parallel"&&t.jsx(b7,{data:e,path:i.path,onSelect:s}),x.map((_,P)=>t.jsx(v$,{d:_,fileUrl:o,zoom:d},_.id??P)),h.map((_,P)=>t.jsx(w$,{e:_,fileUrl:o,zoom:d},P)),!x.length&&!h.length&&i.kind!=="parallel"&&t.jsx(x$,{kind:i.kind,status:u==null?void 0:u.status,meta:f})]}),t.jsx(S7,{workflow:e.workflow,path:i.path,kind:i.kind})]}),c&&t.jsx(C7,{src:c,onClose:()=>d(null)})]})}function x$({kind:e,status:n,meta:s}){const r=s.decision?n==="working"?"Asking now. The verdict shows here when the answer comes back.":"Not asked yet.":e==="code"?"A code node: a pure transform of the run's state. It calls nothing, so it leaves no record of its own.":e==="route"?"Routed by a value already in the state: no model was asked.":p$.has(e)?"Its nodes are drawn inside it. Pick one to see what it did.":"Nothing recorded yet.";return t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:r})}function x7({data:e,mapPath:n,onSelect:s}){var i;const r=((i=e.nodes[n])==null?void 0:i.items)??[],o=g2(r);return t.jsxs("section",{children:[t.jsx("div",{className:"mb-3 grid grid-cols-5 border",children:[["Items",o.total],["Done",o.done],["Working",o.working],["Review",o.review],["Failed",o.failed]].map(([c,d])=>t.jsxs("div",{className:"border-r px-3 py-2 last:border-r-0",children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:c}),t.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:d})]},c))}),t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"caps text-left text-micro text-muted-foreground",children:[t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"#"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Item"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"State"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Verdict"}),t.jsx("th",{className:"border-b py-1.5 text-right font-normal",children:"Cost"})]})}),t.jsx("tbody",{children:r.map(c=>{const d=e.decisions.filter(g=>{var y;return g.item===c.index&&!!((y=g.node)!=null&&y.startsWith(`${n}/body`))}),u=Ov(e,n,c),f=d.length?d.some(g=>g.cost_usd===null)?null:d.reduce((g,y)=>g+(y.cost_usd??0),0):void 0;return t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>s({path:n,item:c.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:c.index+1}),t.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:Wc(e,n,c.index),children:Wc(e,n,c.index)??"—"}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:t.jsx(Ob,{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=>ll(g))].filter(Boolean).join(", "),children:u.outcome?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:ie("font-semibold",g$[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=>ll(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 v7({data:e,path:n,mapPath:s,onSelect:r}){var g;const o=e.decisions.filter(y=>y.node===n),i=e.effects.filter(y=>y.node===n),c=(((g=e.nodes[s])==null?void 0:g.items)??[]).map(y=>({it:y,d:o.find(x=>x.item===y.index),e:i.find(x=>x.item===y.index)})).filter(y=>y.d||y.e),d=o.filter(y=>y.cost_usd!==null),u=o.filter(y=>y.latency_ms!==null),f=u.length?u.reduce((y,x)=>y+(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((y,x)=>y+(x.cost_usd??0),0)),d.length<o.length?` + ${o.length-d.length} unknown`:""," · mean ",Yi(f)]}),t.jsx("table",{className:"w-full border-collapse font-mono text-small",children:t.jsx("tbody",{children:c.map(({it:y,d:x,e:h})=>t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>r({path:s,item:y.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:y.index+1}),t.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:Wc(e,s,y.index)}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:x?ll(x):h?t.jsx(Ob,{state:h.status}):null}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:x?Yi(x.latency_ms):h?Yi(Lb(h.startedAt,h.endedAt)):""})]},y.index))})})]})}function b7({data:e,path:n,onSelect:s}){var x,h;const r=`${n}/branches/`,o=e.decisions.filter(v=>{var b;return((b=v.node)==null?void 0:b.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 b;return{d:v,a:(b=v.answers)==null?void 0:b[c]}}).filter(v=>{var b;return((b=v.a)==null?void 0:b.type)==="noul"});if(i.size!==1||d.length<2)return t.jsx(x$,{kind:"parallel",meta:{decision:!1}});const u=d.map(v=>v.a.noul),f=u.reduce((v,b)=>v+b,0)/u.length,g=Math.max(...u)-Math.min(...u),y=v=>{var b;return((b=e.graph.nodes.find(j=>j.path===v.node))==null?void 0:b.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:b})=>t.jsx("li",{children:t.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-2 text-left font-mono text-small hover:bg-accent",onClick:()=>s({path:v.node,item:null}),children:[t.jsx("span",{className:"w-[92px] shrink-0",children:t.jsx(Pb,{provider:v.provider})}),t.jsx("span",{className:"w-[132px] shrink-0 truncate",title:v.model??"",children:v.model??y(v)}),t.jsx(Px,{p:b.noul,strong:!0,tick:.5,tone:b.noul>=.5?"fg":"muted"}),t.jsx("span",{className:"w-10 text-right tabular-nums",children:Bs(b.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:ie("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,b)=>v+(b.d.cost_usd??0),0))})]})]})]})}function y7({data:e,mapPath:n,index:s,status:r,fileUrl:o,zoom:i}){const d=e.graph.nodes.filter(u=>u.path.startsWith(`${n}/body`)).map(u=>({n:u,ds:e.decisions.filter(f=>f.node===u.path&&f.item===s),es:e.effects.filter(f=>f.node===u.path&&f.item===s)})).filter(u=>!p$.has(u.n.kind)||u.ds.length||u.es.length);return r==="pending"?t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"Not started: this item waits for a free slot in the map."}):t.jsxs("div",{className:"space-y-5",children:[d.map(({n:u,ds:f,es:g})=>f.length||g.length?t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:u.label}),g.map((y,x)=>t.jsx(w$,{e:y,fileUrl:o,zoom:i,compact:!0},x)),f.map((y,x)=>t.jsx(v$,{d:y,fileUrl:o,zoom:i},y.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 uN=e=>`${Math.round(e*100)}%`,Bs=e=>e.toFixed(2);function Px({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:ie("absolute inset-y-0 left-0 transition-[width] duration-slow",n?o:"bg-muted-foreground/45"),style:{width:uN(Math.max(0,Math.min(1,e)))}}),s!==void 0&&t.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:uN(s)},title:`threshold ${Bs(s)}`})]})}function w7({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:ie("w-8 font-semibold",s.noul>=.5?"text-foreground":"text-muted-foreground"),children:s.noul>=.5?"YES":"NO"}),t.jsx(Px,{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:ie("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(Px,{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 j7(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 k7(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?`"${h2(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 v$({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(Pb,{provider:e.provider}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:e.model??"default model"}),t.jsx(Ne,{tone:o,children:e.status==="cancelled"?"outcome unknown":e.status})]}),t.jsxs("dl",{className:"grid grid-cols-[minmax(0,1fr)_100px_92px] border-b font-mono text-small",children:[t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:Object.keys(e.answers??{}).length>1&&((i=e.rule)==null?void 0:i.kind)!=="route"?"Least sure answer":"Verdict"}),t.jsx("dd",{className:"break-words font-semibold",children:ll(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:Yi(e.latency_ms)})]})]}),e.error&&t.jsx("p",{className:ie("border-b px-4 py-2.5 font-mono text-small",e.status==="cancelled"?"text-warning-text":"text-destructive-text"),children:e.error}),!!((c=e.images)!=null&&c.length)&&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(w7,{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:j7(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:k7(e)})]})]}),!!((d=e.evidence)!=null&&d.length)&&t.jsx(N7,{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(im,{value:e.state})]})]})}function N7({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(NT,{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 b$=e=>{const n=yd(e);return n?`${n.tool} on ${n.server}`:e},y$=()=>t.jsx(Ne,{tone:"muted",title:"An MCP server's tool",children:t.jsx("span",{"data-mcp":!0,children:"MCP"})});function w$({e,fileUrl:n,zoom:s,compact:r=!1}){var g;const o=e.output,i=o!=null,c=o&&typeof o=="object"?o:null,d=!e.endedAt&&!["done","ok","failed","stopped"].includes(e.status),u=e.error??(c!=null&&c.error?`${c.error.code?`${c.error.code}: `:""}${c.error.message??""}`:null),f=e.status==="done"||e.status==="ok"?"success":e.status==="failed"?"error":e.status==="stopped"?"muted":"active";return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"flex items-center gap-2 border-b px-4 py-2.5",children:[t.jsx("span",{className:"caps inline-flex h-5 items-center border border-wf-tool/[.6] bg-wf-tool/[.12] px-1.5 text-micro leading-none text-wf-tool",children:"tool"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",title:e.tool,children:b$(e.tool)}),yd(e.tool)&&t.jsx(y$,{}),t.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?Yi(Lb(e.startedAt,e.endedAt)):""}),t.jsx(Ne,{tone:f,children:e.status})]}),t.jsxs("div",{className:"space-y-3 px-4 py-3",children:[r?t.jsxs("p",{className:"break-all font-mono text-label",children:[t.jsx("span",{className:"caps mr-2 text-micro text-muted-foreground",children:"Input"}),JSON.stringify(e.input)]}):t.jsxs("div",{children:[t.jsx("p",{className:"caps mb-1 text-micro text-muted-foreground",children:"Input"}),t.jsx(im,{value:e.input,small:!0})]}),u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",children:u}),!!((g=c==null?void 0:c.pages)!=null&&g.length)&&t.jsx("div",{className:"flex flex-wrap gap-3",children:c.pages.map(y=>t.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>s(n(y.image)),"aria-label":`Open page ${y.page}`,children:t.jsx("img",{src:n(y.image),alt:`Page ${y.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},y.page))}),i&&!u&&t.jsxs("details",{className:"group",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[t.jsx(Es,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),t.jsx(im,{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 S7({workflow:e,path:n,kind:s}){const r=f2(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)?`… ${Bm(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(im,{value:o})]})}function im({value:e,small:n}){return t.jsx("pre",{className:ie("overflow-auto whitespace-pre-wrap break-words border-t bg-background px-4 py-3 font-mono leading-[1.6]",n?"max-h-48 border text-label":"max-h-80 text-small"),children:JSON.stringify(e,null,2)})}function C7({src:e,onClose:n}){return t.jsx(Am,{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 j$=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function E7(e,{everyMs:n=1e3,key:s="",enabled:r=!0}={}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,y]=p.useState(0),x=p.useRef(e);return x.current=e,p.useEffect(()=>{if(!r)return;const h=new AbortController;let v;const b=async()=>{try{const j=Date.now(),k=await x.current(h.signal);if(h.signal.aborted||(i(k),d(null),f(j),md(k.run.status)))return}catch(j){if(h.signal.aborted)return;d(j);const k=j;if(k.retryable){v=setTimeout(b,Math.min(n,k.retryAfterMs??500));return}if(j$(j))return}v=setTimeout(b,n)};return b(),()=>{h.abort(),clearTimeout(v)}},[s,n,g,r]),{data:o,error:c,readAt:u,reload:()=>y(h=>h+1)}}function $7({data:e,actions:n={},fileUrl:s,initial:r=null,lastRead:o}){const[i,c]=p.useState(r),d=p.useMemo(()=>jL(e,i),[e,i]),u=md(e.run.status),[f,g]=p.useState(()=>Date.now()),y=p.useMemo(()=>Date.now(),[e]);return p.useEffect(()=>{if(u||e.run.paused)return;const 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(_7,{data:e,readAt:y,now:f,actions:n,stale:!u&&o&&f-o>5e3?Math.max(1e3,f-o):0}),e.run.paused&&t.jsx("p",{className:"border-b border-warning/40 bg-warning/10 px-5 py-2 font-mono text-small text-warning-text md:px-8",role:"status",children:"Paused. Calls already in flight finish; no new node starts until you resume. The run keeps its place across a restart."}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[t.jsx("div",{className:"min-h-[320px] min-w-0 flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px]",children:t.jsx("div",{className:"px-5 py-6 md:px-8",children:t.jsx(jd,{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(g7,{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(kd,{run:!0})})]})}function _7({data:e,readAt:n,now:s,actions:r,stale:o}){const i=md(e.run.status),c=e.graph.nodes.find(y=>{var x,h;return y.kind==="map"&&((h=(x=e.nodes[y.path])==null?void 0:x.items)==null?void 0:h.length)}),d=c?g2(e.nodes[c.path].items):null,{usd:u,unknown:f}=x2(e),g=[["Elapsed",cl(SL(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",R7(e),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return d&&g.push(["Items",t.jsxs(t.Fragment,{children:[t.jsx("span",{children:d.done}),t.jsxs("span",{className:"text-muted-foreground",children:["/",d.total]}),d.failed>0&&t.jsxs("span",{className:"ml-2 text-label text-destructive-text",children:[d.failed," failed"]}),d.review>0&&t.jsxs("span",{className:"ml-2 text-label text-warning-text",children:[d.review," review"]})]})]),t.jsxs("div",{className:"flex flex-wrap items-stretch border-b",children:[e.run.paused&&t.jsx("div",{className:"flex items-center pl-5 md:pl-8",children:t.jsxs(Ne,{tone:"warning",children:[t.jsx(nl,{className:"size-3","aria-hidden":!0})," Paused"]})}),g.map(([y,x,h],v)=>t.jsxs("div",{className:ie("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:y}),t.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:x})]},y)),t.jsxs("div",{className:"flex flex-1 items-center justify-end gap-3 px-5 py-2 md:px-8",children:[o>0&&t.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",cl(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(Vo,{"aria-hidden":!0})," ",r.busy==="resume"?"Resuming":"Resume"]}):t.jsxs(B,{size:"sm",onClick:r.onPause,disabled:!r.onPause||!!r.busy,title:"Calls in flight finish; no new node starts.",children:[t.jsx(nl,{"aria-hidden":!0})," ",r.busy==="pause"?"Pausing":"Pause"]}))]})]})}const T7=new Set(["agent","decide","extract","report","artifact"]),R7=e=>e.graph.nodes.filter(n=>{var s;return T7.has(n.kind)&&!["pending","not_run"].includes(((s=e.nodes[n.path])==null?void 0:s.status)??"pending")}).length;function A7({error:e}){const n=e==null?void 0:e.status;return t.jsx("p",{className:ie("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 O7(e,n){return!n||e.state==="loading"?{messages:zm,steers:!1}:e.state==="failed"?{messages:n.features.messages,steers:!1}:{messages:n.features.messages,steers:UL(e.id,n.harnesses)}}async function P7(e,n){try{let s=null;do{const r=await e.listRevisions(n.agent_id,s),o=r.revisions.find(c=>c.revision===n.revision),i=o==null?void 0:o.definition.output_schema;if(o)return{state:"read",id:o.definition.harness,...i?{outputSchema:i}:{}};s=r.next_cursor}while(s)}catch{}return{state:"failed"}}const fN=new Set(["completed","failed","cancelled"]),L7={firstMs:2e3,maxMs:16e3,totalMs:12e4};function M7(e,n,s,r=L7){var g;const o=!!e&&fN.has(e.status)&&qm(e.learning),i=p.useRef(n);i.current=n;const c=p.useRef(s);c.current=s;const d=(g=e==null?void 0:e.learning)==null?void 0:g.state,u=!!e&&fN.has(e.status),f=p.useRef(d);p.useEffect(()=>{var x;const y=f.current;f.current=d,y!==void 0&&y!==d&&u&&((x=c.current)==null||x.call(c))},[d,u]),p.useEffect(()=>{if(!o)return;let y,x=0,h=r.firstMs,v=!1,b=!1;const j=()=>{b||x+h>r.totalMs||(y=setTimeout(k,h))},k=()=>{if(y=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(),()=>{b=!0,y&&clearTimeout(y),document.removeEventListener("visibilitychange",E)}},[o])}const mN=new Set(["completed","failed","cancelled"]),I7=e=>{const n=x2(e);return`${Sl(n.usd)}${n.unknown?` + ${n.unknown} unknown`:""}`},z7=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},zi=e=>({api:z7(e),title:sL(e),cause:e}),D7=3e3;function hN({v2:e,runId:n,caps:s,agentName:r}){var se;const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[g,y]=p.useState([]),[x,h]=p.useState(null),[v,b]=p.useState(null),[j,k]=p.useState(0),E=p.useRef(""),S=p.useRef(y2()).current,N=p.useRef(Ys()).current,$=p.useRef(0),_=p.useRef(""),[P,O]=p.useState({state:"loading"});p.useEffect(()=>{o&&P.state==="loading"&&P7(e,o).then(O)},[o==null?void 0:o.revision]);const M=O7(P,s);M7(o,()=>R(),()=>k(Q=>Q+1));const R=async()=>{const Q=S.begin();try{const[re,te]=await Promise.all([e.getRun(n),e.listFiles(n)]);S.current(Q)&&(i(re),y(te.files))}catch(re){S.current(Q)&&h(zi(re))}};p.useEffect(()=>{R()},[n]),KE(()=>{R()});const A=((se=o==null?void 0:o.recordings)==null?void 0:se.some(Q=>!Q.finished))===!0;p.useEffect(()=>{if(!A)return;const Q=setInterval(()=>{R()},D7);return()=>clearInterval(Q)},[A,n]),p.useEffect(()=>{const Q=new AbortController;return d(null),t2(e,n,{signal:Q.signal,onRows:re=>{f(re);const te=re.filter(ge=>ge.kind===QE).map(ge=>`${ge.id}\0${ge.summary}`).join("");te!==_.current&&(_.current=te,R());const he=re.filter(ge=>ge.kind==="tool_result").length;he>$.current&&($.current=he,R())},onPage:re=>{re.cost&&d(re.cost);const te=`${re.status}/${re.state}`;(te!==E.current||re.status==="input_required"&&!re.unchanged)&&(E.current=te,R())}}).catch(re=>{Q.signal.aborted||h(zi(re))}),()=>Q.abort()},[n,j]);const L=async Q=>{b(Q);try{await e[Q](n),h(null)}catch(re){h(zi(re))}b(null),await R(),k(re=>re+1)},D=async()=>{if(o){b("archive");try{const Q=await(o.archived_at?e.unarchiveRun(n):e.archiveRun(n));i(re=>re?{...re,archived_at:Q.archived_at}:Q),h(null)}catch(Q){h(zi(Q))}b(null),R()}},W=async Q=>{const re=await Q();return await R(),k(te=>te+1),re},q=Q=>W(()=>e.raiseCap(n,Q)),H=Q=>W(()=>e.gradeRun(n,Q)),K=async Q=>{let re=!0;try{await gC(N,n,Q,e.sendMessage),h(null)}catch(te){h(zi(te)),re=!1}return await R(),k(te=>te+1),re},U=async(Q,re,te,he)=>{let ge=null;try{await e.answerApproval(n,Q,re,te,he)}catch(ye){ge=JE(ye)}return await R(),k(ye=>ye+1),ge},G=async Q=>{try{return await Q()}finally{R(),k(re=>re+1)}},F=E7(Q=>e.getRunGraph(n,Q),{key:n,enabled:(o==null?void 0:o.kind)==="workflow"}),z=!F.data&&j$(F.error);if(!o)return x?x.cause instanceof ze&&x.cause.status===404?t.jsx(r2,{what:"run",id:n,list:{href:"#/runs",label:"Open the runs list"}}):t.jsx(Jt,{problem:Ht(x.cause,"the run"),onRetry:()=>{h(null),R(),k(Q=>Q+1)}}):t.jsx(XP,{});const Y=c&&!mN.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(sa,{title:x.title,error:x.api})}),t.jsx(m7,{run:Y,agentName:r(o.agent_id),messages:M.messages,harnessSteers:M.steers,graphView:o.kind==="workflow"&&!z?t.jsx(F7,{v2:e,runId:n,graph:F,onMoved:()=>{R()}}):void 0,costText:o.kind==="workflow"&&!mN.has(o.status)&&F.data?I7(F.data):void 0,outputSchema:P.state==="read"?P.outputSchema:void 0,rows:u,files:g,readFile:Q=>e.readFile(n,Q.path),fileUrl:Q=>e.fileUrl(n,Q),readLearningDiff:()=>e.runLearningDiff(n),readLearning:()=>e.runLearning(n),readLearningResult:()=>e.runLearningResult(n),readComputer:()=>e.runComputer(n),onTakeOver:()=>G(()=>e.takeOverComputer(n)),onHandBack:Q=>G(()=>e.handBackComputer(n,Q)),readComputers:()=>e.computers(),onMessage:K,onApprove:U,onGrade:H,actions:{onStop:()=>void L("stop"),onCancel:()=>void L("cancel"),onArchive:()=>void D(),onRaiseCap:q,busy:v}},o.run_id)]})}function F7({v2:e,runId:n,graph:s,onMoved:r}){const{data:o,error:i,readAt:c,reload:d}=s,[u,f]=p.useState(null),[g,y]=p.useState(null),[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()}),y(null)}catch(k){y(zi(k))}f(null),d(),r()},b=o&&x&&c<x.at?{...o,run:{...o.run,paused:x.paused,...x.status?{status:x.status}:{}}}:o;return b?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[g&&t.jsx("div",{className:"border-b p-3",children:t.jsx(sa,{title:g.title,error:g.api})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx($7,{data:b,lastRead:c,fileUrl:j=>e.fileUrl(n,j),actions:{onPause:()=>void v("pause"),onResume:()=>void v("resume"),busy:u}})})]}):t.jsx(A7,{error:i})}function pN({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(qx,{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 U7({view:e,error:n,onRetry:s,scope:r,needsYou:o,asking:i,failed:c,live:d,startHere:u,actions:f,observations:g,hasObservedSessions:y=!1}){if(!e)return t.jsx(pN,{actions:f,children:t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-8 px-5 pb-16 pt-8 md:px-8 md:pt-10",children:[n?t.jsx(Jt,{problem:n,onRetry:s}):t.jsx(JP,{}),g]})});const x=b=>{var j;return((j=e.perAgent.find(k=>k.agentId===b))==null?void 0:j.name)??b},h=r!=null&&r.agent?e.perAgent.filter(b=>b.agentId===r.agent):e.perAgent,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,gN(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}`,gN(e.runs.needsReview)??""].filter(Boolean).join(" · ")]];return t.jsx(pN,{actions:f,children:t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-8 px-5 pb-16 pt-8 md:px-8 md:pt-10",children:[n&&t.jsx(Jt,{problem:n,onRetry:s,className:""}),u,o,t.jsxs("section",{className:"space-y-4","aria-label":y?"Registered agents and runs":void 0,children:[y&&t.jsx("h2",{className:"text-lead font-semibold",children:"Registered agents & runs"}),t.jsx("ul",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:v.map(([b,j,k,E,S])=>{const N=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:b}),t.jsx("p",{className:ie("mt-3 font-mono text-display leading-none",E),children:j}),S&&t.jsx("p",{className:"mt-2 text-label text-muted-foreground",children:S})]});return t.jsx("li",{children:k?t.jsx("a",{href:k,className:"block h-full border bg-card p-5 transition-colors hover:border-border-strong hover:bg-accent",children:N}):t.jsx("div",{className:"h-full border bg-card p-5",children:N})},b)})})]}),g,t.jsxs("section",{className:"space-y-4","aria-label":"Analytics",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-6 gap-y-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Activity & usage"}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:W7(e)})]}),r&&t.jsx(c2,{range:r.range,onRange:r.onRange,agent:r.agent,agents:e.perAgent,onAgent:r.onAgent})]}),t.jsx(d2,{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(Nf,{className:"size-4","aria-hidden":!0}),"Runs per agent"]}),h.length?t.jsx("ul",{children:h.map(b=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:dn(b.agentId,"runs"),className:"flex items-center justify-between gap-3 px-4 py-3 text-lead hover:bg-accent",children:[t.jsx("span",{className:"min-w-0 truncate",children:b.name}),t.jsx("span",{className:"font-mono text-body text-muted-foreground",children:b.runs})]})},b.agentId))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No agents yet."})]}),t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsxs("h2",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:[t.jsx(td,{className:"size-4","aria-hidden":!0}),"Recent runs"]}),e.recent.length?t.jsx("ul",{children:e.recent.map(b=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(b.run_id)}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-accent",children:[t.jsx(Cl,{run:b}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-lead",children:Cn(b)}),t.jsx(rb,{run:b,className:"hidden sm:inline-flex"}),$U(b)&&t.jsx("span",{className:"shrink-0 text-small text-muted-foreground",children:"send a message to continue"})]}),t.jsx("span",{className:"hidden shrink-0 text-body text-muted-foreground md:inline",children:x(b.agent_id)}),b.ended_at&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",title:"How long it ran",children:cl(Date.parse(b.ended_at)-Date.parse(b.created_at))}),b.cost&&(b.cost.usd!==null||kl(b.cost))&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:to(b.cost,{ended:Ha(b.status)})}),t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:ht(b.created_at)})]})},b.run_id))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs yet."})]})]})]})})}const gN=e=>e?`${e} ${e===1?"needs":"need"} review`:void 0;function W7(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?_v.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 H7({asking:e,failed:n,failedAll:s,live:r,learning:o=[],agentName:i,onAnswer:c,onApprove:d,onHandBack:u,onRunAgain:f,onStop:g,problem:y,now:x=Date.now}){const h=kU(n.filter(A=>!es(A))),v=n.filter(A=>!A.imported_from&&es(A)),[,b]=p.useState(0);p.useEffect(()=>{if(!r.length)return;const A=setInterval(()=>b(L=>L+1),1e3);return()=>clearInterval(A)},[r.length]);const[j,k]=p.useState([]),E=(A,L,D)=>{const W=e.find(H=>H.run_id===A),q=W?Cn(W):A;k(H=>[...H.filter(K=>K.runId!==A),...D?[{runId:A,what:L,title:q,text:D}]:[]])},S=d&&(async(A,L,D,W,q)=>{const H=await(q?d(A,L,D,W,q):d(A,L,D,W));return E(A,L,H),H}),N=u&&(async(A,L,D)=>{const W=await u(A,D);return E(A,`ask:${L.asked_at}`,W),W}),$=A=>{var D;const L=Hi(A);return((D=A.pending)==null?void 0:D.kind)==="approval"?A.pending.id:L?`ask:${L.asked_at}`:null},_=BE(n),P=o.filter(A=>A.pending>0),O=P.reduce((A,L)=>A+L.pending,0),M=e.length+_+O;if(!M&&!r.length&&!y&&!j.length)return null;const R=x();return t.jsxs("section",{"aria-label":"Needs you",className:"space-y-3",children:[M>0&&t.jsxs("h2",{className:"caps text-small font-semibold",children:["Needs you ",t.jsxs("span",{className:"text-warning-text",children:["· ",M]})]}),y&&t.jsx("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:y}),j.filter(A=>!e.some(L=>L.run_id===A.runId&&$(L)===A.what)).map(A=>t.jsxs("p",{className:"flex items-start gap-3 border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("a",{href:hs(A.runId),className:"underline-offset-4 hover:underline",children:A.title}),": your answer wasn't taken. ",A.text]}),t.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>k(L=>L.filter(D=>D.runId!==A.runId)),children:"Dismiss"})]},A.runId)),e.length>0&&t.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(A=>{var L,D,W;return A.native?t.jsxs("li",{className:"space-y-2 border p-4",children:[t.jsx("a",{href:hs(A.run_id),className:"text-body underline underline-offset-2",children:Cn(A)}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native sessions cannot receive another message. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(A.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," to continue."]})]},A.run_id):((L=A.pending)==null?void 0:L.kind)==="approval"?t.jsx(B7,{run:A,pending:A.pending,agentName:i(A.agent_id),at:R,onApprove:S},`${A.run_id}:${A.pending.id}`):Hi(A)?t.jsx(G7,{run:A,ask:Hi(A),agentName:i(A.agent_id),at:R,onHandBack:N},`${A.run_id}:${Hi(A).asked_at}`):t.jsx(q7,{run:A,agentName:i(A.agent_id),at:R,onAnswer:c},`${A.run_id}:${((D=A.pending)==null?void 0:D.kind)==="question"?A.pending.asked_at:((W=A.pending)==null?void 0:W.kind)==="budget"?A.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(A=>t.jsx(Y7,{message:A.message,runs:A.runs,agentName:i,at:R,onRunAgain:f},A.message)),v.map(A=>t.jsx(xN,{run:A,agentName:i(A.agent_id)},A.run_id))]})]}),P.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:P.map(A=>t.jsxs("li",{className:"flex min-w-0 items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:A.name}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:nb(A.pending)}),t.jsx("a",{href:`#/agents/${encodeURIComponent(A.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},A.agent_id))})]}),r.length>0&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Running now · ",r.length]}),t.jsx("ul",{children:r.map(A=>es(A)?t.jsx(xN,{run:A,agentName:i(A.agent_id)},A.run_id):t.jsx(Q7,{run:A,agentName:i(A.agent_id),at:R,onStop:g},A.run_id))})]})]})}function B7({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(XE,{compact:!0,pending:n,heading:t.jsx(Mb,{run:e,agentName:s,since:`asked ${Rd(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 G7({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(a$,{compact:!0,ask:n,heading:t.jsx(Mb,{run:e,agentName:s,since:`asked ${Rd(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 q7(e){var n;return((n=e.run.pending)==null?void 0:n.kind)==="budget"?t.jsx(K7,{run:e.run,pending:e.run.pending,agentName:e.agentName}):t.jsx(V7,{...e})}function K7({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:Cn(e)})]}),t.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:ZE(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 Mb({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:Cn(e)}),s&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:s})]})}function V7({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=jU(i),[d,u]=p.useState(""),[f,g]=p.useState(!1),[y,x]=p.useState(null),[h,v]=p.useState(null),b=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(Mb,{run:e,agentName:n,since:o!=null&&o.asked_at?`asked ${Rd(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 b(k),className:"mt-3 flex flex-wrap items-center gap-2",children:[c.map(k=>t.jsx("button",{type:"button",onClick:()=>u(k),className:ie("border px-3 py-1.5 text-body hover:border-border-strong",d===k?"border-warning text-warning-text":"border-border"),children:k},k)),t.jsx(Pe,{value:d,onChange:k=>u(k.target.value),"aria-label":`Answer ${n}`,placeholder:c.length?"Or type an answer…":"Type an answer…",className:"h-9 min-w-[9rem] flex-1 font-sans text-lead"}),t.jsx(B,{type:"submit",variant:"solid",size:"sm",disabled:f||!d.trim(),children:f?"Sending…":"Send"}),y&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:y})]})]})}function Y7({message:e,runs:n,agentName:s,at:r,onRunAgain:o}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),[f,g]=p.useState(new Set),y=n.filter(k=>!f.has(k.run_id)),x=n.length-y.length,h=async()=>{c(!0),u(null);const{started:k,problem:E}=await o(y);c(!1),u(E),g(S=>new Set([...S,...k]))},v=x>0&&t.jsxs("span",{className:"font-mono text-small text-success-text",children:["Started again: ",x===1?"1 run":`${x} runs`]});if(!y.length)return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-border-strong","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 truncate font-mono text-small text-muted-foreground",children:e}),v]});const b=y[0],j=y.length===1;return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-destructive","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[j?t.jsxs("p",{className:"flex min-w-0 gap-3 text-lead",children:[t.jsx("span",{className:"shrink-0 font-mono text-small leading-5",children:s(b.agent_id)}),t.jsx("a",{href:hs(b.run_id),className:"min-w-0 truncate hover:underline",children:Cn(b)})]}):t.jsxs("p",{className:"text-lead",children:[y.length," runs failed ",t.jsxs("span",{className:"text-muted-foreground",children:["· ",[...new Set(y.map(k=>s(k.agent_id)))].join(", ")]})]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-small text-destructive-text",children:e}),!j&&t.jsxs("details",{className:"mt-1 text-body",children:[t.jsx("summary",{className:"cursor-pointer font-mono text-small text-muted-foreground",children:"The runs"}),t.jsx("ul",{className:"mt-1 space-y-1",children:y.map(k=>t.jsxs("li",{children:[t.jsx("a",{href:hs(k.run_id),className:"hover:underline",children:Cn(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:[Rd(b.ended_at??b.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 xN({run:e,agentName:n}){var s;return t.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-small text-muted-foreground",children:[n," · ",Ko(es(e).runtime)]}),t.jsx("a",{href:hs(e.run_id),className:"text-lead hover:underline",children:Cn(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 Q7({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=fd(e.cost)?`${to(e.cost)} so far`:u===0?"nothing spent yet":typeof u=="number"?`${to(e.cost)} so far`:kl(e.cost)?to(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:Cn(e)}),t.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",cl(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"}),Dm(e.status,e.state,e.kind,zm,!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 J7=[{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 k$(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 X7(e,n,s){const r=Fm(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 Z7(e,n,s,r=Ys()){const i=(await Kr(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 N$="agentrun.console.start-here.dismissed",eB={hello:Va,web:RN,plan:RT};function tB(){try{return localStorage.getItem(N$)==="true"}catch{return!1}}function nB({harnesses:e,tools:n,onTry:s,imported:r=0,keySettings:o=!1,importAction:i,modelSetup:c}){const[d,u]=p.useState(tB),[f,g]=p.useState(!1),[y,x]=p.useState(!1),[h,v]=p.useState(null),[b,j]=p.useState(null),k=k$(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(N$,"true")}catch{}},children:t.jsx(Qo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[t.jsx(Qm,{}),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(Ar,{className:`size-3.5 transition-transform ${f?"rotate-180":""}`,"aria-hidden":!0})]})]}),y&&t.jsxs("div",{hidden:!f,className:"mt-4 border-t pt-4",children:[c,k?t.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:J7.map(S=>{const N=X7(S,k,n),$=eB[S.id]??Va;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."]}),b&&t.jsx("p",{className:"mt-3 font-mono text-body text-destructive-text",role:"alert",children:b})]})]})}const sB=["system","light","dark"],Lx="agentrun.theme",rB="(prefers-color-scheme: dark)",lh=()=>{try{return globalThis.localStorage??null}catch{return null}},S$=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(rB):null;let Mx=null;function oB(e=lh()){try{const n=e==null?void 0:e.getItem(Lx);return n==="light"||n==="dark"?n:"system"}catch{return"system"}}const Ix=(e=lh())=>Mx??oB(e);function aB(e,n=lh()){Mx=null;try{e==="system"?n==null||n.removeItem(Lx):n==null||n.setItem(Lx,e)}catch{Mx=e}}function zx(e,n=document.documentElement,s=S$()){const r=e==="dark"||e==="system"&&!!(s!=null&&s.matches);n.classList.toggle("dark",r),n.classList.toggle("light",!r)}function iB(e=document.documentElement,n=S$(),s=lh()){zx(Ix(s),e,n);const r=()=>{Ix(s)==="system"&&zx("system",e,n)};return n==null||n.addEventListener("change",r),()=>n==null?void 0:n.removeEventListener("change",r)}const lB={mission:"Mission Control",playground:"Playground",agents:"Agents",runs:"Runs",dojo:"Dojo",templates:"Templates",triggers:"Triggers",settings:"Settings"},cB={mission:"#/",playground:"#/playground",agents:"#/agents",runs:"#/runs",dojo:"#/dojo",templates:"#/templates",triggers:"#/triggers",settings:"#/settings/keys"},dB={system:["System",Ya],light:["Light",KT],dark:["Dark",DT]};function uB(){const[e,n]=p.useState(()=>Ix()),s=r=>{aB(r),zx(r),n(r)};return t.jsx("div",{role:"group","aria-label":"Theme",className:"flex gap-1 border p-1",children:sB.map(r=>{const[o,i]=dB[r];return t.jsx(B,{variant:"ghost",size:"sm","aria-label":o,title:o,"aria-pressed":e===r,onClick:()=>s(r),className:ie("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 vN(){return t.jsxs("span",{className:"inline-flex items-center whitespace-nowrap text-lg font-semibold font-mono","aria-label":"AgentRun",children:[t.jsx("svg",{viewBox:"0 0 64 64",className:"mr-1 size-4 text-primary-text","aria-hidden":!0,children:t.jsx("path",{d:"M18 12L42 32L18 52",fill:"none",stroke:"currentColor",strokeWidth:"8",strokeLinecap:"square",strokeLinejoin:"miter"})}),"agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})}function fB({active:e,settings:n=!1,triggers:s=!1,banners:r,building:o=!1,onBuild:i,onNavigate:c,onSignOut:d,onSignOutEverywhere:u,children:f}){const[g,y]=p.useState(!1),[x,h]=p.useState(!1),v=p.useRef(null),b=p.useRef(null),j=p.useRef(!1);p.useEffect(()=>{var M,R;x?(M=b.current)==null||M.focus():j.current&&((R=v.current)==null||R.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 $=M=>{c?c(M):location.hash=cB[M],y(!1)},_=()=>{i?i():location.hash="#/agents/new",y(!1)},P=lB[e];p.useEffect(()=>{document.title=P?`${P} · AgentRun`:"AgentRun"},[P]);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 M;return(M=O.current)==null?void 0:M.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(vN,{})}),t.jsx(B,{size:"icon","aria-label":"Navigation","aria-expanded":g,onClick:()=>y(M=>!M),children:t.jsx(MT,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("aside",{className:ie("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(vN,{})})}),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(br,{className:"w-full",active:e==="mission",onClick:()=>$("mission"),children:[t.jsx(TT,{className:"size-4 shrink-0","aria-hidden":!0}),"Mission Control"]}),t.jsxs(br,{className:"w-full",active:e==="playground",onClick:()=>$("playground"),children:[t.jsx(um,{className:"size-4 shrink-0","aria-hidden":!0}),"API playground"]}),t.jsxs("div",{children:[t.jsxs(br,{className:ie("w-full",N&&"text-primary-text"),"aria-expanded":E,"aria-controls":"agent-navigation",onClick:()=>S(M=>!M),children:[t.jsx(Nf,{className:"size-4 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"flex-1",children:"Agents"}),t.jsx(Ar,{className:ie("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(br,{className:"w-full pl-8",active:o,onClick:_,children:[t.jsx(ET,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Build"]}),t.jsxs(br,{className:"w-full pl-8",active:e==="agents"&&!o,onClick:()=>$("agents"),children:[t.jsx(Nf,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Connected agents"]}),t.jsxs(br,{className:"w-full pl-8",active:e==="templates",onClick:()=>$("templates"),children:[t.jsx(Hx,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Templates"]}),t.jsxs(br,{className:"w-full pl-8",active:e==="runs",onClick:()=>$("runs"),children:[t.jsx(td,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Runs"]})]})]}),s&&t.jsxs(br,{className:"w-full",active:e==="triggers",onClick:()=>$("triggers"),children:[t.jsx(dm,{className:"size-4 shrink-0","aria-hidden":!0}),"Triggers"]}),t.jsxs(br,{className:"w-full",active:e==="dojo",onClick:()=>$("dojo"),children:[t.jsx(TC,{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(br,{className:"w-full",active:e==="settings",onClick:()=>$("settings"),children:[t.jsx(ON,{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(uB,{}),t.jsxs(B,{onClick:d,className:"w-full justify-start",children:[t.jsx(OT,{"aria-hidden":!0}),"Sign out"]}),u&&(x?t.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:M=>{M.key==="Escape"&&k()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[t.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"xs",variant:"destructive",onClick:()=>{h(!1),u()},children:"Sign out everywhere"}),t.jsx(B,{size:"xs",ref:b,onClick:k,children:"Cancel"})]})]}):t.jsx(B,{size:"sm",variant:"ghost",ref: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(zU,{}),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 _g={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},bN={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 mB({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,y]=p.useState(""),[x,h]=p.useState(n??"");p.useEffect(()=>{n!==null&&h(n)},[n]);const[v,b]=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 P=await r(c,N&&x.trim()?x.trim():void 0,E&&S&&u);k(!1),b(P)};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:bN[e].title}),t.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:bN[e].body}),e!=="token_link"&&t.jsxs("form",{className:"space-y-5",onSubmit:P=>{P.preventDefault(),_()},children:[N&&t.jsx(wt,{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:P=>h(P.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),t.jsx(wt,{label:_g[e].label,note:E?"12 characters or more.":void 0,children:t.jsxs("span",{className:ie(Uc,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(La,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,type:"password",value:c,onChange:P=>d(P.target.value),autoComplete:_g[e].autocomplete,autoFocus:!0,"aria-label":_g[e].label,className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),E&&t.jsx(wt,{label:"Again",note:g&&g!==c?"The two passwords differ.":void 0,children:t.jsxs("span",{className:ie(Uc,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(La,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Pe,{bare:!0,type:"password",value:g,onChange:P=>y(P.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:P=>f(P.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:hB(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 yN=(e,n)=>`${e.toLocaleString("en-US")} ${n}${e===1?"":"s"}`,Tg="Each project becomes an agent, each session a run you can read.";function hB(e){return"counting"in e?`Counting sessions… ${Tg}`:e.sessions===null||e.projects===null?`The count isn't known. ${Tg}`:`${yN(e.sessions,"session")} in ${yN(e.projects,"project")}. ${Tg}`}function pB({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 C$=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.accounts)===!1};function gB(e,n){if(C$(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 xB=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.setup_code)===!0};function vB(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 E$(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 bB=1e4;function wN(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"&&rm.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=iI(s[1]);return{section:"settings",settings:"mcp",signIn:mI(s[1]),...c?{add:c}:{}}}if(s=e.match(/^#\/settings\/github(?:\?(.*))?$/),s){const c=WU(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&&rm.includes(i)?{status:i}:{},...r.get("archived")==="true"?{archived:!0}:{}}}function yB({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 Rg;function wB(){if(!Rg){const{code:e,rest:n}=E$(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${n}`),Rg={code:e}}return Rg.code}const jB=e=>Math.min(1e3*2**e,3e4),$$=1e3,kB=30;function NB(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 SB(){const[e]=p.useState(tL),[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(()=>WP({fetch:e.fetch,onSignedOut:()=>void d.current()}),[e]),[f,g]=p.useState(wB);p.useEffect(()=>{if(n!=="setup")return;const _=()=>{const{code:P,rest:O}=E$(location.hash);P!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${O}`),g(P))};return window.addEventListener("hashchange",_),_(),()=>window.removeEventListener("hashchange",_)},[n]);const[y,x]=p.useState(!1),h=async()=>{const _=await u.session(),P=C$(_)?await u.listAgents().then(()=>200,O=>O instanceof ze?O.status:0):void 0;return{mode:gB(_,P),codeNeeded:xB(_)}},v=async()=>{const _=await h();return x(_.codeNeeded),_.mode},b=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,P;return h().then(O=>{!_||i.current!==null||(x(O.codeNeeded),s(O.mode),k(null))},O=>{if(!_||i.current!==null)return;const M=jB(E),R=O instanceof ze?O:null,A=(R==null?void 0:R.code)==="http_error",L=A&&[502,503,504].includes(R.status);k({problem:R===null?Wt(O):L?`Its address answered ${R.status}, not the server.`:`GET /v2/auth/session answered ${R.status}${A?", not as this server answers":`: ${R.message}`}`,starting:L}),P=setTimeout(()=>S(D=>D+1),M)}),()=>{_=!1,clearTimeout(P)}},[u,E]);const[N,$]=p.useState(null);return p.useEffect(()=>{if(n!=="setup")return;let _=!0;return(async()=>{for(let P=!1;_;){const O=await u.setupImport().then(M=>M,()=>{});if(!_)return;if(O===void 0&&P)return void $({projects:null,sessions:null});if(O!==void 0&&(!O||!("counting"in O||"sessions"in O)||($(O),P=!0,!("counting"in O))))return;await new Promise(M=>setTimeout(M,$$))}})(),()=>{_=!1}},[u,n]),n===null&&j!==null?t.jsx(pB,{problem:j.problem,starting:j.starting,onRetry:()=>S(_=>_+1)}):n===null?t.jsx(D0,{connection:e,children:t.jsx(CB,{})}):n!=="signed_in"?t.jsx(mB,{mode:n,code:f,codeNeeded:y,offer:N,problem:r&&n==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async(_,P,O)=>{try{return await(n==="setup"?u.setup(_,P,O):u.signIn(_)),o(!1),s("signed_in"),null}catch(M){return M instanceof ze&&M.status===403&&n==="setup"&&await b().catch(()=>{}),M instanceof ze?vB(M):M instanceof Error?M.message:String(M)}}},n):t.jsx(D0,{connection:e,children:t.jsx(EB,{v2:u,onSignedOut:()=>{o(!1),s("sign_in")}})})}function CB(){return Eb().state==="offline"?t.jsx(DU,{}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function EB(e){const n=p.useMemo(Sd,[e.v2]);return t.jsx($B,{...e},n)}function $B({v2:e,onSignedOut:n}){var ra,vs,Od,rs,Pd,Ld,Md,oa,aa,io,ia,Id,zd,ri,_l,oi,lo,Dd,ai,_t,Tl,Rl,ii,Al,Ol,Pl,li,la,Js,Xs,Zs;const{writable:s,whyNot:r}=YF(e),[o,i]=p.useState(null),[c,d]=p.useState(()=>wN()),[u,f]=p.useState(null),g=((vs=(ra=u==null?void 0:u.features)==null?void 0:ra.triggers)==null?void 0:vs.routes)===!0,[y,x]=p.useState(new Map);p.useEffect(()=>{if(!g)return;let pe=!0;return e.listTriggers().then(_e=>{pe&&x(new Map(_e.triggers.map(Ie=>[Ie.id,{name:Ie.name,kind:Ie.source.kind}])))},()=>{}),()=>{pe=!1}},[e,g,c.section,c.trigger]);const[h,v]=p.useState(null),[b,j]=p.useState(null),[k,E]=p.useState(0),[S,N]=p.useState("30d"),$=S==="7d"?7:30,_=Cv(e,{active:c.section==="mission"||c.section==="runs"&&!c.run&&!c.runsOf&&!c.archived&&!c.status,days:$}),[P,O]=p.useState(null),[M,R]=p.useState(!1),A=p.useRef(!1),[L,D]=p.useState(null),[W,q]=p.useState(null),[H,K]=p.useState(null),[U,G]=p.useState(0),F=p.useRef(null),[z,Y]=p.useState(!1),[se,Q]=p.useState(!1),[re,te]=p.useState(!1),[he,ge]=p.useState(null),[ye,xe]=p.useState(null),[fe,De]=p.useState(!1),[Fe,Le]=p.useState({}),[Ee,ae]=p.useState(!1),$e=p.useRef(0),[ot,me]=p.useState([]),Me=p.useRef(-1),[Ze,bt]=p.useState(null),[oe,Se]=p.useState(0),tt=p.useRef(0),Ae=pe=>{nf(pe)||(location.hash=pe)},[it,$t]=p.useState(null),[nt,ft]=p.useState(0);p.useEffect(()=>{let pe=!0;return(async()=>{let _e=!1;for(let Ie=0;pe&&Ie<kB;){const Tt=await e.setupImport().then(Nt=>Nt,()=>{});if(!pe)return;if(Tt===void 0)Ie+=1;else{if(Ie=0,!Tt||!("state"in Tt))return;if($t(Tt),Tt.state!=="running")return void(_e&&ft(Nt=>Nt+1));_e=!0}await new Promise(Nt=>setTimeout(Nt,$$))}})(),()=>{pe=!1}},[e]),p.useEffect(()=>{const pe=()=>{const _e=qW();nf(location.hash,()=>{_e&&history.go(-_e)})?_e&&history.go(_e):d(wN())};return window.addEventListener("hashchange",pe),()=>window.removeEventListener("hashchange",pe)},[]),p.useEffect(()=>GW(),[]);const Dt=p.useRef(0),Ft=p.useRef(!1),be=()=>{const pe=++Dt.current;return e.capabilities().then(_e=>(pe===Dt.current&&f(_e),!0),()=>!1)};p.useEffect(()=>{be()},[e]),p.useEffect(()=>{if($e.current&&c.section!=="runs"&&c.section!=="mission"&&Me.current===nt)return;Me.current=nt;const pe=++$e.current;ae(!1),Promise.allSettled([!1,!0].map(_e=>Kr(Ie=>e.listAgents({archived:_e,cursor:Ie}),Ie=>Ie.agents))).then(_e=>{if(pe!==$e.current)return;const Ie=Object.fromEntries(_e.flatMap(Nt=>Nt.status==="fulfilled"?Nt.value:[]).map(Nt=>[Nt.agent_id,Nt.definition.name??Nt.agent_id])),Tt=_e.every(Nt=>Nt.status==="fulfilled");Le(Nt=>Tt?Ie:{...Nt,...Ie}),ae(Tt)})},[e,c,nt]);const de={status:c.status,archived:c.archived};p.useEffect(()=>{if(c.section!=="runs"||c.run)return;const pe=++tt.current;ge(null),bt(null),(c.runsOf?e.listAgentRuns(c.runsOf,50,null,de):e.listRuns(50,null,de)).then(_e=>{pe===tt.current&&(ge(_e.runs),xe(_e.next_cursor))}).catch(_e=>{pe===tt.current&&bt(Ht(_e,"the runs"))})},[e,c,nt,oe]);const Ue=pe=>{var _e;return Fe[pe]??((_e=lt==null?void 0:lt.find(Ie=>Ie.agent_id===pe))==null?void 0:_e.definition.name)??(Ee?pe:"")},Xe=u,at={harnesses:(Xe==null?void 0:Xe.harnesses)??[],tools:sM(Xe==null?void 0:Xe.tools),thinking:((Od=Xe==null?void 0:Xe.features)==null?void 0:Od.thinking)??[],...typeof((rs=u==null?void 0:u.limits)==null?void 0:rs.free_model_requests)=="number"?{freeRequests:u.limits.free_model_requests}:{}},J=kD(Xe==null?void 0:Xe.tools),ve=SD(Xe==null?void 0:Xe.tools),We=[...(Ld=(Pd=u==null?void 0:u.features)==null?void 0:Pd.tool_keys)!=null&&Ld.routes?["keys"]:[],...J.length||ve.length?["tools"]:[],"mcp","github","email","computers","workspace",...(oa=(Md=u==null?void 0:u.features)==null?void 0:Md.webhooks)!=null&&oa.routes?["webhook"]:[]],Ve=pe=>Ae({runs:"#/runs",agents:"#/agents",playground:"#/playground",dojo:"#/dojo",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${We[0]??"keys"}`}[pe]),He=p.useRef(Ys()).current,gt=async pe=>{const _e=k$(at.harnesses);if(!_e)return"This server has no model to run it on yet.";try{const Ie=await Z7(e,pe,_e,He);return Ae(`#/runs/${encodeURIComponent(Ie)}`),null}catch(Ie){return Wt(Ie)}},kt=((h==null?void 0:h.analytics.by_source)??[]).filter(pe=>pe.source!=="live").reduce((pe,_e)=>pe+_e.runs,0),[lt,Vt]=p.useState(null),[ps,Qs]=p.useState([]),[$n,Wn]=p.useState(null),gs=p.useRef($n);gs.current=$n;const[xs,mn]=p.useState(null),[Hn,_s]=p.useState(0),Bn=p.useRef(0);p.useEffect(()=>{Vt(null),mn(null),Wn(null),gs.current=null},[e,c.section,c.operation,c.playgroundAgent]),p.useEffect(()=>{if(c.section!=="playground"||c.operation)return;mn(null);const pe=++Bn.current;return Kr(_e=>e.listAgents({cursor:_e}),_e=>_e.agents).then(_e=>{var Nt;if(pe!==Bn.current)return;const Ie=_e.filter(os=>!os.archived_at),Tt=gs.current??c.playgroundAgent;if(Tt&&!Ie.some(os=>os.agent_id===Tt)){Vt(null),Wn(null),mn("The selected agent is unavailable or archived. Choose another agent from Agents.");return}Vt(_e),Wn(Tt??((Nt=Ie[0])==null?void 0:Nt.agent_id)??null)}).catch(_e=>{if(pe===Bn.current){const Ie=Ht(_e,"the agents");mn(`${Ie.why} ${Ie.next}${Ie.said?` (${Ie.said})`:""}`)}}),()=>{Bn.current++}},[e,c.section,c.operation,c.playgroundAgent,Hn,nt]),p.useEffect(()=>{if(c.section!=="mission")return;let pe=!0;A.current=!0,j(null),R(!0);const _e=Tv(S);return Promise.all([e.statsOver({..._e?{from:_e}:{},...P?{agent:P}:{}}),P?e.listAgentRuns(P,10):e.listRuns(10)]).then(([Ie,Tt])=>{pe&&(v(cL(Ie,Tt.runs)),P||K(Nt=>Nt||SU(Tt.runs,Ie.analytics.by_source)))}).catch(Ie=>{pe&&j(Ht(Ie,"Mission Control"))}).finally(()=>{pe&&(A.current=!1,R(!1))}),()=>{pe=!1,A.current=!1}},[e,c.section,k,S,P,nt]),KE(()=>E(pe=>pe+1)),p.useEffect(()=>{if(c.section!=="mission")return;const pe=()=>{!document.hidden&&!A.current&&E(Ie=>Ie+1)};window.addEventListener("focus",pe),document.addEventListener("visibilitychange",pe);const _e=setInterval(pe,15e3);return()=>{window.removeEventListener("focus",pe),document.removeEventListener("visibilitychange",pe),clearInterval(_e)}},[c.section]),p.useEffect(()=>{if(c.section!=="mission"){F.current=null;return}let pe=!0;const _e=F,Ie=Gn=>Kr(qn=>e.listRuns(50,qn,{status:Gn}),qn=>qn.runs,2),Tt=()=>Kr(Gn=>e.listAgents({archived:!1,cursor:Gn}),Gn=>Gn.agents).then(Gn=>{pe&&me(Gn.filter(qn=>Gf(qn)>0).map(qn=>({agent_id:qn.agent_id,name:qn.definition.name??qn.agent_id,pending:Gf(qn)})))},()=>{}),os=EU(()=>Promise.allSettled([Ie("input_required"),Ie("failed"),Ie("working"),Tt()]).then(([Gn,qn,ci])=>{var co,uo,Pr;if(!pe)return;const Or=[Gn,qn,ci],ch=Date.now()-NU;if(q(P0(null,Or).problem),((co=Or[0])==null?void 0:co.status)==="fulfilled"&&Y(!0),((uo=Or[1])==null?void 0:uo.status)==="fulfilled"){Q(!0);const Lr=Or[1].value.map(hr=>hr.run_id),fo=_e.current;fo&&Lr.some(hr=>!fo.has(hr))&&E(hr=>hr+1),_e.current=new Set(Lr)}((Pr=Or[2])==null?void 0:Pr.status)==="fulfilled"&&te(!0),D(Lr=>{const{needs:fo}=P0(Lr,Or);return{asking:fo.asking.filter(GE),failed:fo.failed.filter(hr=>Date.parse(hr.ended_at??hr.created_at)>ch),live:fo.live}})}),1e4);return()=>{pe=!1,os()}},[e,c.section,U]);const Ts=p.useRef(Qz()).current,Rs=()=>setTimeout(()=>G(pe=>pe+1),2500),On=async(pe,_e)=>{try{return await gC(Ts(pe),pe,_e,e.sendMessage),Rs(),null}catch(Ie){return Wt(Ie)}},Z=p.useRef(new Map).current,Oe=async pe=>{const _e=[];try{for(const Ie of pe){const Tt=CU(Ie.kind==="workflow"?Ie:await e.getRun(Ie.run_id));if("refusal"in Tt)throw new Error(Tt.refusal);const Nt=Z.get(Ie.run_id)??Sd();Z.set(Ie.run_id,Nt),await e.startRun(Ie.agent_id,Tt.body,Nt),_e.push(Ie.run_id)}return Rs(),{started:_e,problem:null}}catch(Ie){return _e.length&&Rs(),{started:_e,problem:Wt(Ie)}}},mt=async pe=>{try{return await e.stop(pe),Rs(),null}catch(_e){return Wt(_e)}},Ot=async(pe,_e,Ie,Tt,Nt)=>{let os=null;try{await e.answerApproval(pe,_e,Ie,Tt,Nt)}catch(Gn){os=JE(Gn)}return G(Gn=>Gn+1),os},Xt=async(pe,_e)=>{let Ie=null;try{await e.handBackComputer(pe,_e)}catch(Tt){Ie=Rx(Tt,"hand")}return G(Tt=>Tt+1),Ie},Be=p.useRef(0);p.useEffect(()=>{const pe=++Be.current;Qs([]),$n&&Kr(_e=>e.listRevisions($n,_e),_e=>_e.revisions).then(_e=>{pe===Be.current&&Qs(_e)}).catch(()=>{})},[e,$n]);const ee=async(pe,_e,Ie)=>{const Tt=performance.now();try{const Nt=await e.startRun(pe,_e,Ie);return{status:Nt.status,ms:Math.round(performance.now()-Tt),body:Nt.run,runId:Nt.run.run_id}}catch(Nt){return Cb(Nt,Math.round(performance.now()-Tt))}},we=((aa=u==null?void 0:u.features)==null?void 0:aa.efforts)??[],qe=u?((io=u.features)==null?void 0:io.learning)??null:void 0;at.learning=qe??void 0;const St=(ia=u==null?void 0:u.models)==null?void 0:ia.ready;p.useEffect(()=>{if(St!==!1)return;const pe=()=>{Ft.current||(Ft.current=!0,be().finally(()=>{Ft.current=!1}))},_e=()=>be(),Ie=setInterval(pe,bB);return window.addEventListener("focus",_e),()=>{clearInterval(Ie),window.removeEventListener("focus",_e)}},[e,St]);const[It,ct]=p.useState(null);p.useEffect(()=>{if(St!==!1)return;let pe=!0;return e.chatGPT().then(_e=>{pe&&ct(Wf(_e))},()=>{pe&&ct(null)}),()=>{pe=!1}},[e,St]);const[wn,_n]=p.useState(!1),mr=pe=>{ct(pe),(pe.state==="pending"||pe.state==="signed_in")&&_n(!0),pe.state==="signed_in"&&be()},Bt=(Id=lt==null?void 0:lt.find(pe=>pe.agent_id===$n))==null?void 0:Id.definition,si=(Bt==null?void 0:Bt.native)||es(Bt),ao=c.operation?c.playgroundAgent:$n??c.playgroundAgent;return t.jsx(WE.Provider,{value:y,children:t.jsx(fB,{active:c.section,building:c.section==="agents"&&c.agent===null,onBuild:()=>Ae("#/agents/new"),settings:We.length>0,triggers:g,onNavigate:Ve,onSignOut:()=>{const pe=()=>void e.signOut().then(n,_e=>i(_e instanceof ze?_e.message:"The sign-out did not reach the server. Try again."));nf(null,pe)||pe()},onSignOutEverywhere:()=>{const pe=()=>void e.signOutEverywhere().then(n,_e=>i(_e instanceof ze?_e.message:"The sign-out did not reach the server. Try again."));nf(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]}),it&&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:NB(it)}),it.state!=="running"&&t.jsx(B,{size:"xs",type:"button",onClick:()=>$t(null),children:"Dismiss"})]})]}),children:c.section==="settings"?t.jsx(pU,{active:c.settings??"keys",offered:We,children:c.settings==="tools"?t.jsx(UU,{v2:e,choices:J,gates:ve,harnesses:at.harnesses,mcp:!!((zd=u==null?void 0:u.features)!=null&&zd.mcp_client),onSaved:be,onOpen:be}):c.settings==="mcp"?t.jsx(YU,{v2:e,signIn:c.signIn,add:c.add,writable:s,whyNot:r,choices:J}):c.settings==="github"?t.jsx(qU,{v2:e,returned:c.github}):c.settings==="email"?t.jsx(gW,{v2:e,writable:s,whyNot:r}):c.settings==="computers"?t.jsx(jW,{v2:e,writable:s,whyNot:r}):c.settings==="workspace"?t.jsx(OW,{v2:e,writable:s,whyNot:r}):c.settings==="webhook"?t.jsx(vW,{v2:e}):t.jsx(PU,{v2:e,onChange:be,writable:s,whyNot:r,harnesses:at.harnesses,plan:t.jsx(ZF,{v2:e,writable:s,whyNot:r,onChange:()=>void be()})})}):c.section==="dojo"?t.jsx(qD,{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(U7,{hasObservedSessions:!!((ri=_.data)!=null&&ri.sessions.length),observations:t.jsx(Ev,{read:_,view:"summary",days:$}),view:h,error:b,onRetry:()=>E(pe=>pe+1),actions:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"icon","aria-label":"Refresh Mission Control",disabled:M,onClick:()=>{E(pe=>pe+1),G(pe=>pe+1)},children:t.jsx(Yo,{className:"size-4","aria-hidden":!0})}),t.jsx(sn,{label:"Query",prompt:Im(location.origin,P??void 0),playgroundHref:$v(P??void 0)}),t.jsx(Qm,{variant:"primary"})]}),scope:{range:S,onRange:N,agent:P,onAgent:O,refreshing:M&&h!==null},asking:L&&z?L.asking.length:null,failed:L&&se?BE(L.failed):null,live:L&&re?L.live.length:null,needsYou:L&&t.jsx(H7,{asking:L.asking,failed:L.failed,failedAll:h==null?void 0:h.runs.failed,live:L.live,learning:ot,problem:W,agentName:Ue,onAnswer:On,onApprove:Ot,onHandBack:Xt,onRunAgain:Oe,onStop:mt}),startHere:H===!1&&!((_l=_.data)!=null&&_l.sessions.length)?t.jsx(nB,{harnesses:at.harnesses,tools:at.tools,onTry:gt,imported:kt,keySettings:((lo=(oi=u==null?void 0:u.features)==null?void 0:oi.tool_keys)==null?void 0:lo.routes)===!0&&u.features.tool_keys.at_rest==="sealed",modelSetup:u&&(u.models.ready===!1||wn)?t.jsx(cW,{v2:e,needs:u.models.needs,model:u.models.default,onSaved:be,writable:s,whyNot:r,plan:It,harnesses:at.harnesses,onPlan:mr,onDone:()=>_n(!1)}):void 0}):void 0})})}):c.section==="templates"?t.jsx($0,{v2:e,name:c.template,install:c.install,go:Ae},c.install!==void 0?`install:${c.install}`:c.template??""):c.section==="triggers"?t.jsx(E8,{v2:e,view:{trigger:c.trigger,kind:c.kind,edit:c.edit},go:Ae,agentName:Ue,minEvery:(ai=(Dd=u==null?void 0:u.features)==null?void 0:Dd.triggers)==null?void 0:ai.min_every_s,failuresToPause:(Tl=(_t=u==null?void 0:u.features)==null?void 0:_t.triggers)==null?void 0:Tl.failures_to_pause,publicUrl:(ii=(Rl=u==null?void 0:u.features)==null?void 0:Rl.triggers)==null?void 0:ii.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(um,{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(Et,{id:"api-operation",label:"API operation",value:c.operation??"run",onChange:pe=>{const _e=ao,Ie=new URLSearchParams;pe!=="run"&&Ie.set("operation",pe),pe!=="create-agent"&&pe!=="apply-template"&&_e&&Ie.set("agent",_e),Ae(`#/playground${Ie.size?`?${Ie}`:""}`)},options:[{value:"create-agent",label:"POST · Create an agent"},{value:"apply-template",label:"POST · Apply a template"},{value:"run",label:"POST · Start a run"},{value:"list-runs",label:"GET · Query runs"},{value:"edit-agent",label:"PUT · Edit agent",disabled:!ao}]}),t.jsx("span",{className:"min-w-0 break-all font-mono text-small text-muted-foreground",children:c.operation==="apply-template"?`/v2/templates/${c.template?encodeURIComponent(c.template):"{template}"}/apply`:c.operation==="list-runs"?c.playgroundAgent?`/v2/agents/${c.playgroundAgent}/runs`:"/v2/runs":c.operation==="create-agent"?"/v2/agents":c.operation==="edit-agent"?`/v2/agents/${c.playgroundAgent??"{agent_id}"}/definition`:"/v2/agents/{agent_id}/runs"})]}),c.operation==="apply-template"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx($0,{v2:e,name:c.template,go:Ae,playground:!0,draft:c.draft},c.template??"")}):c.operation==="list-runs"?t.jsx(fU,{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(mU,{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:[!si&&((Al=u==null?void 0:u.models)==null?void 0:Al.ready)===!1&&t.jsx(dW,{needs:u.models.needs,source:u.models.source,model:u.models.default,settings:((Pl=(Ol=u.features)==null?void 0:Ol.tool_keys)==null?void 0:Pl.routes)===!0&&u.features.tool_keys.at_rest==="sealed",chatgpt:(It==null?void 0:It.state)==="signed_out"||(It==null?void 0:It.state)==="expired"}),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"})]}),lt&&t.jsx(dU,{agents:lt.filter(pe=>!pe.archived_at),revisions:ps,efforts:we,origin:location.origin,agentId:$n??void 0,onAgent:Wn,onSend:ee,limits:u==null?void 0:u.limits,removeUpload:e.deleteUpload,onOpenRun:pe=>Ae(`#/runs/${encodeURIComponent(pe)}`),live:pe=>t.jsx(hN,{v2:e,runId:pe,caps:u,agentName:Ue},pe)})]})]}):c.section==="agents"?c.observation?t.jsx(BP,{v2:e,sessionId:c.observation,go:Ae}):c.nativeConnect?t.jsx(DF,{v2:e,go:Ae,initialSource:c.connectionSource}):c.agent===void 0?t.jsx(FF,{v2:e,archived:!!c.archived,go:Ae},nt):c.agent===null?t.jsx(eU,{origin:location.origin,v2:e}):c.agent!==null&&!c.edit?t.jsx(ID,{v2:e,agentId:c.agent,tab:c.tab,notes:c.notes,learning:qe,routePrefix:(li=Xe==null?void 0:Xe.models)==null?void 0:li.route_prefix,harnesses:at.harnesses,efforts:we,limits:u==null?void 0:u.limits,places:Tk(u),go:Ae},c.agent):t.jsx(UF,{v2:e,choices:J,gates:ve,focusTool:c.tool,caps:{...at,routePrefix:(la=Xe==null?void 0:Xe.models)==null?void 0:la.route_prefix,decisionProvider:eM(u==null?void 0:u.workflows),places:Tk(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:Ae},`${c.agent??"new"}:${c.tool??""}`):c.run?t.jsx(hN,{v2:e,runId:c.run,caps:u,agentName:Ue},c.run):t.jsx(sU,{observations:!c.runsOf&&!c.archived&&!c.status?_:void 0,runs:he,agentName:Ue,agentId:c.runsOf,error:Ze,onRetry:()=>Se(pe=>pe+1),onOpen:pe=>Ae(`#/runs/${encodeURIComponent(pe)}`),loadingMore:fe,filter:de,onFilter:pe=>Ae(yB({runsOf:c.runsOf,...pe})),onMore:ye?()=>{const pe=tt.current;De(!0),(c.runsOf?e.listAgentRuns(c.runsOf,50,ye,de):e.listRuns(50,ye,de)).then(_e=>{pe===tt.current&&(ge(Ie=>mx(Ie??[],_e.runs)),xe(_e.next_cursor),bt(null))}).catch(_e=>bt(Ht(_e,"more runs"))).finally(()=>De(!1))}:void 0})})})}iB();fT.createRoot(document.getElementById("root")).render(t.jsx(p.StrictMode,{children:t.jsx($5,{children:t.jsx(SB,{})})}));