@workerdeck/web 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{dist-BYhO38VS.js → dist-DhMqnScS.js} +1 -1
- package/dist/assets/{freemarker2-BMT3npoL.js → freemarker2-zFVf97MD.js} +1 -1
- package/dist/assets/{handlebars-C1HjVIxf.js → handlebars-B8scoqcx.js} +1 -1
- package/dist/assets/{highlighted-body-KPVGNVTW-eviACFLs.js → highlighted-body-KPVGNVTW-CfDzUpBA.js} +1 -1
- package/dist/assets/{html-DyxqjCNt.js → html-r8YB5NoX.js} +1 -1
- package/dist/assets/{index-CSnoypph.js → index-CysUAY4-.js} +6 -6
- package/dist/assets/{javascript-wde8K2s8.js → javascript-BrwnmKss.js} +1 -1
- package/dist/assets/{liquid-CA6dtEyS.js → liquid-CluXZO9r.js} +1 -1
- package/dist/assets/{mdx-B4s_jSh_.js → mdx-YRvX8kXm.js} +1 -1
- package/dist/assets/mermaid-HWGCJPDP-CeY4jgtW.js +1 -0
- package/dist/assets/{python-na-LRwxf.js → python-BilEbWwD.js} +1 -1
- package/dist/assets/{razor-B_lApyZT.js → razor-CP6hGRPv.js} +1 -1
- package/dist/assets/{src-BcRpl0IM.js → src-Dj2YGQOH.js} +1 -1
- package/dist/assets/{typescript-CA04tTHG.js → typescript-DOYv7AcG.js} +1 -1
- package/dist/assets/{vs-CdkLmTlg.js → vs-DeKW9hVr.js} +3 -3
- package/dist/assets/{xml-N04DsKm8.js → xml-DvRrJ7fn.js} +1 -1
- package/dist/assets/{yaml-D1nD9xzN.js → yaml-BkanU-h3.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +5 -5
- package/dist/assets/mermaid-HWGCJPDP-BRHSVJqI.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vs-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vs-DeKW9hVr.js","assets/vs-DWxI6Y27.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function P(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=P(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=P(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return P(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function F(e,t,n){if(e==null)return e;var r=[],i=0;return P(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function I(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var L=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function R(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,L)}catch(e){L(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function z(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else R(z.bind(null,e))}var ee={map:F,forEach:function(e,t,n){F(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return F(e,function(){t++}),t},toArray:function(e){return F(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ee,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=z,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:I}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=R,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.0`})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}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(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.0`})),h=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}function m(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&m(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),P=Symbol.for(`react.consumer`),F=Symbol.for(`react.context`),I=Symbol.for(`react.forward_ref`),L=Symbol.for(`react.suspense`),R=Symbol.for(`react.suspense_list`),z=Symbol.for(`react.memo`),ee=Symbol.for(`react.lazy`),B=Symbol.for(`react.activity`),V=Symbol.for(`react.legacy_hidden`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.for(`react.view_transition`),H=Symbol.for(`react.recoverable`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function oe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case L:return`Suspense`;case R:return`SuspenseList`;case B:return`Activity`;case ne:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case F:return e.displayName||`Context`;case P:return(e._context.displayName||`Context`)+`.Consumer`;case I:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case z:return t=e.displayName||null,t===null?oe(e.type)||`Memo`:t;case ee:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var se=Array.isArray,ce=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},de=[],fe=-1;function pe(e){return{current:e}}function me(e){0>fe||(e.current=de[fe],de[fe]=null,fe--)}function he(e,t){fe++,de[fe]=e.current,e.current=t}var ge=pe(null),_e=pe(null),ve=pe(null),ye=pe(null);function be(e,t){switch(he(ve,t),he(_e,e),he(ge,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?yp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=yp(t),e=bp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}me(ge),he(ge,e)}function xe(){me(ge),me(_e),me(ve)}function Se(e){var t=e.memoizedState;t!==null&&(gh._currentValue=t.memoizedState,he(ye,e)),t=ge.current;var n=bp(t,e.type);t!==n&&(he(_e,e),he(ge,n))}function Ce(e){_e.current===e&&(me(ge),me(_e)),ye.current===e&&(me(ye),gh._currentValue=ue)}var we,Te;function Ee(e){if(we===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);we=t&&t[1]||``,Te=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+we+e+Te}var De=!1;function Oe(e,t){if(!e||De)return``;De=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -41,12 +41,12 @@ Error generating stack: `+e.message+`
|
|
|
41
41
|
`),x=document.createDocumentFragment();for(let e=0;e<b.length;e++)b[e]&&x.appendChild(document.createTextNode(b[e])),e<b.length-1&&x.appendChild(document.createElement(`br`));v.insertNode(x),v.collapse(!1);let S=window.getSelection();S?.removeAllRanges(),S?.addRange(v),rD(o);let C=n(),w=lE(C,s);if(w!==C){r(w),i(w);for(let e of w)e.type===`chip`&&!C.some(t=>t.type===`chip`&&t.trigger===e.trigger&&t.value===e.value&&t.displayText===e.displayText)&&p?.(e)}else r(C);u?.({segments:w,source:`external`}),a()},[t,n,r,y,a,i,s,c,l,u,p,m,h]),S=(0,v.useCallback)(e=>{e.preventDefault();let t=lD();if(!t)return;let n=t.cloneContents(),r=xD(n);e.clipboardData.setData(`text/plain`,r);let i=SD(n);if(i.some(e=>e.type===`chip`)){let t=WE(i);t&&e.clipboardData.setData(`text/prompt-area-segments`,t)}},[]),C=(0,v.useCallback)(e=>{S(e);let i=lD();if(!i)return;let o=n();y(o),i.deleteContents();let s=t.current;s&&rD(s);let c=n();r(c),a()},[S,t,n,r,y,a]),w=(0,v.useCallback)(e=>{e.preventDefault()},[]),T=(0,v.useCallback)(e=>{e.preventDefault()},[]),E=(0,v.useCallback)(()=>{g.current=!0},[]),D=(0,v.useCallback)(()=>{g.current=!1,a()},[a]),O=(0,v.useCallback)(()=>{setTimeout(()=>{let e=t.current;if(!e)return;let n=document.activeElement;n&&e.parentElement?.contains(n)||o()},150)},[t,o]),k=(0,v.useCallback)(e=>{if(!(e.metaKey||e.ctrlKey)||e.key!==`z`)return!1;e.preventDefault();let t=_.current;if(e.shiftKey){if(t.redoStack.length===0)return!0;let e=t.redoStack.pop();if(!e)return!0;let a=n();t.undoStack.push(a),r(e),i(e),f?.(e)}else{if(t.undoStack.length===0)return!0;let e=t.undoStack.pop();if(!e)return!0;let a=n();t.redoStack.push(a),r(e),i(e),d?.(e)}return!0},[n,r,i,d,f]);return(0,v.useMemo)(()=>({handlePaste:x,handleCopy:S,handleCut:C,handleDrop:w,handleDragOver:T,handleCompositionStart:E,handleCompositionEnd:D,handleBlur:O,handleKeyDownForUndoRedo:k,pushUndo:y,resetUndoHistory:b,isComposing:g}),[x,S,C,w,T,E,D,O,k,y,b])}function GD({editorRef:e,triggers:t,markdownEnabled:n,submitOnEnter:r,onSubmit:i,onEscape:a,onChange:o,onChipAdd:s,onChipDelete:c,readSegmentsFromDOM:l,renderSegmentsToDOM:u,runTriggerDetection:d,dismissTrigger:f,buildInsertChip:p,selectSuggestionInternal:m,activeTrigger:h,suggestions:g,suggestionsLoading:_,suggestionsError:y,selectedSuggestionIndex:b,setSelectedSuggestionIndex:x,pushUndo:S,handleKeyDownForUndoRedo:C,lastRenderedValue:w,undoTimer:T,undoBaseState:E}){let D=(0,v.useCallback)((e,t)=>{let n=l(),r=QE(e,t);if(r===-1)return!1;let i=eD(e,r),a=n[i],s=sE(n,i);return o(s),u(s),a?.type===`chip`&&c?.(a),!0},[l,o,u,c]),O=(0,v.useCallback)((e,t)=>{let n=l(),r=QE(e,t);if(r===-1)return!1;let i=eD(e,r),a=n[i],s=cE(n,i);if(!s)return!1;let d=0;for(let e=0;e<i;e++){let t=n[e];t.type===`text`?d+=t.text.length:d+=ZT(t).length}return d+=s.revertedText.length,o(s.segments),u(s.segments),mD(e,d),a?.type===`chip`&&c?.(a),!0},[l,o,u,c]),k=(0,v.useCallback)(()=>{let t=e.current;if(!t)return!1;let n=lD();if(!n||!n.collapsed)return!1;let r=n.startContainer,i=n.startOffset;if(r===t&&i>0){let e=t.childNodes[i-1];if(e&&RE(e))return VE(e)?O(t,e):D(t,e)}if(r.nodeType===Node.TEXT_NODE&&i===0){let e=tD(t,r);if(!e)return!1;let n=e.previousSibling;for(;n&&n.nodeType===Node.TEXT_NODE&&n.textContent===``;)n=n.previousSibling;if(n&&RE(n))return VE(n)?O(t,n):D(t,n)}return!1},[D,O]),A=(0,v.useCallback)(()=>{let t=e.current;if(!t)return!1;let n=lD();if(!n||!n.collapsed)return!1;let r=n.startContainer,i=n.startOffset;if(r===t&&i<t.childNodes.length){let e=t.childNodes[i];if(e&&RE(e))return D(t,e)}if(r.nodeType===Node.TEXT_NODE&&i===(r.textContent??``).length){let e=tD(t,r);if(!e)return!1;let n=e.nextSibling;for(;n&&n.nodeType===Node.TEXT_NODE&&n.textContent===``;)n=n.nextSibling;if(n&&RE(n))return D(t,n)}return!1},[D]),j=(0,v.useCallback)(t=>{let n=l(),r=t.query,i={value:r,label:r},a={value:r,displayText:(t.config.onSelect?.(i)??r)||r,autoResolved:!0},c=aE(n,t,a);o(c.segments),u(c.segments),s?.({type:`chip`,trigger:t.config.char,...a});let d=e.current;d&&mD(d,c.cursorOffset),f()},[l,o,u,f,s]);return(0,v.useCallback)(s=>{let c=(e,t)=>{let{segments:r,cursorOffset:i}=t;if(n){let e=ME(r);r=e.segments,i=jE(i,e.edits)}w.current=r,o(r),u(r),mD(e,i)},v=e=>{if(!n)return!1;let t=l(),r=uD(e);if(r===null||!_E(QT(t),r))return!1;let i=yE(t,r);return i&&c(e,i),!0};if((s.metaKey||s.ctrlKey)&&s.key===`z`&&E.current&&(T.current&&=(clearTimeout(T.current),null),S(E.current),E.current=null),C(s))return;if(n&&(s.metaKey||s.ctrlKey)&&!s.shiftKey&&(s.key===`b`||s.key===`i`)){s.preventDefault();let t=e.current;if(!t)return;let n=gD(t);if(!n||n.start===n.end)return;let r=s.key===`b`?`**`:`*`,i=l();S(i);let a=fE(i,n.start,n.end,r);if(!a)return;w.current=a.segments,o(a.segments),u(a.segments),_D(t,a.selectionStart,a.selectionEnd);return}if(!s.metaKey&&!s.ctrlKey&&!s.altKey&&!s.nativeEvent.isComposing&&s.key.length===1){let n=t.find(e=>e.mode===`launch`&&e.char===s.key),r=e.current;if(n?.onActivate&&r){let e=uD(r);if(e!==null){let t=l(),r=QT(t);if(rE(r,e,n.position)){s.preventDefault(),n.onActivate({text:r,cursorPosition:e,insertChip:p(dE(t,e,e,n.char),{config:n,startOffset:e,query:``})});return}}}}if(h&&h.config.mode===`dropdown`&&(g.length>0||_||y!==null||h.config.emptyMessage)){if(s.key===`ArrowDown`){s.preventDefault(),g.length>0&&x(e=>Math.min(e+1,g.length-1));return}if(s.key===`ArrowUp`){s.preventDefault(),g.length>0&&x(e=>Math.max(e-1,0));return}if(s.key===`Enter`||s.key===`Tab`){s.preventDefault();let e=g[b];e&&m(e);return}if(s.key===`Escape`){s.preventDefault(),f();return}}if(s.key===` `&&h&&h.config.resolveOnSpace&&h.query.trim().length>0){s.preventDefault(),j(h);return}if(n&&s.key===`Tab`&&!h){let t=e.current;if(t){let e=l(),n=QT(e),r=uD(t);if(r!==null&&_E(n,r)){s.preventDefault();let n=s.shiftKey?SE(e,r):xE(e,r);n&&c(t,n);return}}}let D=e=>{let t=gD(e);if(!t)return;let n=l();S(n);let r=dE(n,t.start,t.end,`
|
|
42
42
|
`);c(e,{segments:r,cursorOffset:t.start+1})};if(s.key===`Enter`&&s.shiftKey&&!s.nativeEvent.isComposing){s.preventDefault();let t=e.current;t&&!v(t)&&D(t);return}if(s.key===`Enter`&&!s.shiftKey&&!s.nativeEvent.isComposing){if(s.preventDefault(),r){i?.(l());return}let t=e.current;t&&!v(t)&&D(t);return}if(s.key===`Escape`&&a){a();return}if((s.key===`Backspace`||s.key===`Delete`)&&!s.nativeEvent.isComposing){let t=e.current;if(t){let e=gD(t);if(e&&e.start!==e.end){s.preventDefault();let n=l();S(n),c(t,{segments:dE(n,e.start,e.end,``),cursorOffset:e.start}),d();return}}}if(s.key===`Backspace`){let t=e.current;if(t){let e=l(),r=uD(t);if(n&&r!==null){let n=CE(e,r);if(n){s.preventDefault(),c(t,n),d();return}}}if(k()){s.preventDefault(),d();return}}if(s.key===`Delete`&&A()){s.preventDefault(),d();return}},[h,g,_,y,b,i,r,a,l,o,u,n,f,k,A,j,d,m,S,C,t,p])}function KD({editorRef:e,triggers:t,disabled:n,onChange:r,renderSegmentsToDOM:i,onChipClick:a,onChipAdd:o,onChipDelete:s,onLinkClick:c,setActiveTrigger:l,setSelectedSuggestionIndex:u,setTriggerRect:d,runSearch:f,activeTrigger:p,suggestions:m}){let h=(0,v.useRef)(null),g=(0,v.useRef)(null),_=(0,v.useRef)(null),y=(0,v.useCallback)(r=>{let i=r.target;if(!(i instanceof Node))return;let o=e.current;if(!o)return;let s=i;for(;s&&s!==o;){if(HE(s)){if(r.metaKey||r.ctrlKey){r.preventDefault(),c?.(s.href),window.open(s.href,`_blank`,`noopener,noreferrer`);return}break}if(RE(s)){let e=s.getBoundingClientRect(),i=document.createElement(`span`);i.className=`prompt-area-chip-ripple`;let c=Math.max(e.width,e.height);i.style.width=`${c}px`,i.style.height=`${c}px`,i.style.left=`${r.clientX-e.left-c/2}px`,i.style.top=`${r.clientY-e.top-c/2}px`,s.appendChild(i),i.addEventListener(`animationend`,()=>i.remove());let p=ZE(s);if(p){let r=t.find(e=>e.char===p.trigger),i=_.current===s;if(_.current=null,!n&&!i&&r?.reopenOnChipClick&&r.mode===`dropdown`&&r.onSearch){let t=QE(o,s);h.current={chip:p,segIndex:eD(o,t)},g.current=s,l({config:r,startOffset:0,query:``}),u(0),d(e),f(``,r)}a?.(p)}return}s=s.parentNode}},[a,c,t,f,n]),b=(0,v.useCallback)(t=>{let n=t.target,r=e.current;if(!r||!(n instanceof Node)){_.current=null;return}let i=n;for(;i&&i!==r;){if(RE(i)){_.current=g.current===i?i:null;return}i=i.parentNode}_.current=null},[]),x=(0,v.useCallback)(()=>{h.current=null,g.current=null},[]),S=(0,v.useCallback)((t,a,c,l)=>{let u=h.current;if(!u)return!1;let d=e.current;if(d&&!n){let e=t[u.segIndex],n=e?.type===`chip`&&e.trigger===u.chip.trigger&&e.value===u.chip.value?u.segIndex:(()=>{let e=[];return t.forEach((t,n)=>{t.type===`chip`&&t.trigger===u.chip.trigger&&t.value===u.chip.value&&e.push(n)}),e.length===1?e[0]:-1})(),f=n===-1?void 0:t[n];if(f?.type===`chip`){let e={type:`chip`,trigger:c,...a},u=t.map((t,r)=>r===n?e:t),p=u[n+1],m=!p||p.type!==`text`||p.text.length===0;m&&(u=[...u.slice(0,n+1),{type:`text`,text:` `},...u.slice(n+1)]),l(t),r(u),i(u),(f.value!==e.value||f.displayText!==e.displayText||WE(f.data)!==WE(e.data))&&(s?.(f),o?.(e)),mD(d,QT(u.slice(0,n+1)).length+ +!!m)}}return!0},[n,r,i,o,s]);return(0,v.useEffect)(()=>{let e=h.current;if(!e||!p?.config.reopenOnChipClick)return;let t=m.findIndex(t=>t.value===e.chip.value);t>0&&u(t)},[m,p]),(0,v.useMemo)(()=>({handleClick:y,handleMouseDown:b,clear:x,trySelectEditingChip:S}),[y,b,x,S])}function qD(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(null),o=(0,v.useRef)(0),s=(0,v.useRef)(null),c=(0,v.useRef)(null),l=(0,v.useCallback)(()=>{s.current?.abort(),c.current&&clearTimeout(c.current),t([]),r(!1),a(null)},[]),u=(0,v.useCallback)((e,n)=>{if(!n.onSearch)return;s.current?.abort(),c.current&&clearTimeout(c.current),r(!0),a(null),o.current++;let i=o.current,l=new AbortController;s.current=l;let{onSearch:u,onSearchError:d,searchDebounceMs:f}=n,p=()=>{let n=u(e,{signal:l.signal});n instanceof Promise?n.then(e=>{l.signal.aborted||o.current!==i||(t(e),r(!1))},e=>{l.signal.aborted||o.current!==i||e instanceof DOMException&&e.name===`AbortError`||(a(e instanceof Error?e.message:`Search failed`),r(!1),d?.(e))}):(t(n),r(!1))};f&&f>0&&e.length>0?c.current=setTimeout(p,f):p()},[]);return(0,v.useEffect)(()=>()=>{s.current?.abort(),c.current&&clearTimeout(c.current)},[]),{suggestions:e,suggestionsLoading:n,suggestionsError:i,search:u,reset:l}}var JD=300,YD=[];function XD({value:e,onChange:t,triggers:n=YD,disabled:r=!1,onSubmit:i,onEscape:a,onChipClick:o,onChipAdd:s,onChipDelete:c,onLinkClick:l,onPaste:u,onRawPaste:d,onUndo:f,onRedo:p,onImagePaste:m,markdown:h=!0,normalizeBullets:g=!0,submitOnEnter:_=!0,maxLength:y}){let b=(0,v.useRef)(null),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(0),[T,E]=(0,v.useState)(null),{suggestions:D,suggestionsLoading:O,suggestionsError:k,search:A,reset:j}=qD(),M=(0,v.useRef)(!1),N=(0,v.useRef)([]),P=(0,v.useRef)(null),F=(0,v.useRef)(null),I=(0,v.useCallback)(()=>{let e=b.current;if(!e)return[];let t=[],n=!1,r=!1;for(let i=0;i<e.childNodes.length;i++){let a=e.childNodes[i];if(a.nodeType===Node.TEXT_NODE){let e=a.textContent??``;e&&(t.push({type:`text`,text:e}),n=!0)}else if(RE(a)){let e=ZE(a);e&&(t.push(e),n=!0)}else if(zE(a)){if(a.dataset.sentinel){r=!0;continue}t.push({type:`text`,text:`
|
|
43
43
|
`})}else if(LE(a)){let e=a.textContent??``;e&&(t.push({type:`text`,text:e}),n=!0)}}return!n&&!r?[]:t},[]),L=(0,v.useCallback)(e=>{let t=b.current;if(!t)return;M.current=!0;let r=uD(t);for(;t.firstChild;)t.removeChild(t.firstChild);for(let r of e)if(r.type===`text`){let e=r.text.split(`
|
|
44
|
-
`);for(let n=0;n<e.length;n++)e[n]&&t.appendChild(document.createTextNode(e[n])),n<e.length-1&&t.appendChild(document.createElement(`br`))}else{let e=document.createElement(`span`);if(e.contentEditable=`false`,e.dataset.chipTrigger=r.trigger,e.dataset.chipValue=r.value,e.dataset.chipDisplay=r.displayText,r.sigil!==void 0&&(e.dataset.chipSigil=r.sigil),r.data!==void 0){let t=WE(r.data);t&&(e.dataset.chipData=t)}r.autoResolved&&(e.dataset.chipAutoResolved=`true`);let i=n.find(e=>e.char===r.trigger),a=i?.chipStyle??`pill`;e.dataset.chipStyle=a,e.className=W(`prompt-area-chip`,a===`inline`&&`prompt-area-chip--inline`,i?.chipClassName),e.textContent=ZT(r),e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`-1`),t.appendChild(e)}if(t.lastChild&&zE(t.lastChild)){let e=document.createElement(`br`);e.dataset.sentinel=`true`,t.appendChild(e)}cD(t,h),r!==null&&mD(t,r),N.current=e,M.current=!1},[n,h]),R=KD({editorRef:b,triggers:n,disabled:r,onChange:t,renderSegmentsToDOM:L,onChipClick:o,onChipAdd:s,onChipDelete:c,onLinkClick:l,setActiveTrigger:S,setSelectedSuggestionIndex:w,setTriggerRect:E,runSearch:A,activeTrigger:x,suggestions:D}),z=(0,v.useCallback)((e,n)=>r=>{let i=aE(e,n,{value:r.value,displayText:r.displayText,data:r.data});t(i.segments),L(i.segments),s?.({type:`chip`,trigger:n.config.char,value:r.value,displayText:r.displayText,...r.data===void 0?{}:{data:r.data}});let a=b.current;a&&mD(a,i.cursorOffset)},[t,L,s]),ee=(0,v.useCallback)(()=>{let e=b.current;if(!e)return;let t=I(),r=QT(t),i=uD(e);if(i===null)return;let a=iE(r,i,n);if(R.clear(),a){S(a),w(0);let n=dD(e,a.startOffset);if(n){let e=n.getBoundingClientRect();(e.height>0||e.left>0||e.top>0)&&E(e)}a.config.mode===`dropdown`&&a.config.onSearch&&A(a.query,a.config),a.config.mode===`callback`&&a.config.onActivate&&a.config.onActivate({text:r,cursorPosition:i,insertChip:z(t,a)})}else S(null),j()},[n,I,z,j,A,R]),B=(0,v.useCallback)(()=>{R.clear(),S(null),w(0),j()},[j,R]),V=WD({editorRef:b,readSegmentsFromDOM:I,onChange:t,renderSegmentsToDOM:L,runTriggerDetection:ee,dismissTrigger:B,triggers:n,markdownEnabled:h,normalizeBullets:g,onPaste:u,onRawPaste:d,onUndo:f,onRedo:p,onChipAdd:s,onImagePaste:m});(0,v.useLayoutEffect)(()=>{if(!M.current&&!pE(e,N.current)){if(h&&g){let n=OE(e,!0);if(n!==e){t(n);return}}if(mE(I(),e)){N.current=e;return}L(e)}},[e,I,L,h,g,t]);let te=(0,v.useRef)(h);(0,v.useLayoutEffect)(()=>{if(te.current===h)return;te.current=h;let n=g?OE(e,h):e;n===e?L(e):t(n)},[h,g,L,e,t]),(0,v.useEffect)(()=>()=>{P.current&&clearTimeout(P.current)},[]);let ne=(0,v.useCallback)(()=>{if(M.current)return;if(V.isComposing.current){let e=I();N.current=e,t(e);return}let e=b.current,n=e?uD(e):null;e&&rD(e);let r=I();if(y!=null&&e&&QT(r).length>y){let n=uD(e),i=eE(r,y);N.current=i,t(i),L(i),mD(e,n==null?y:Math.min(n,y)),ee();return}if(h&&g&&e&&n!==null){let i=vE(r,n);if(i){N.current=i.segments,t(i.segments),L(i.segments),mD(e,i.cursorOffset),ee();return}}let i=r,a=null;if(h&&n!==null&&kE(QT(r))){let e=ME(r);e.edits.length>0&&(i=e.segments,a=jE(n,e.edits))}F.current||=N.current,N.current=i,t(i),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{F.current&&=(V.pushUndo(F.current),null),P.current=null},JD),e&&(a===null?(cD(e,h),n!==null&&mD(e,n)):(L(i),mD(e,a))),ee()},[t,I,ee,L,h,g,y,V]),H=(0,v.useCallback)(e=>{if(!x)return;let n=I(),r=x.config.insertAsText?.(e);if(r!==void 0){let e=oE(n,x,r);V.pushUndo(n),t(e.segments),L(e.segments);let i=b.current;i&&mD(i,e.cursorOffset),B(),setTimeout(()=>{b.current?.focus()},0);return}let i=x.config.onSelect?.(e)??e.label,a=x.config.chipOptions?.(e),o={value:e.value,displayText:i||e.label,...a?.sigil===void 0?{}:{sigil:a.sigil},data:e.data};if(R.trySelectEditingChip(n,o,x.config.char,V.pushUndo)){B(),setTimeout(()=>{b.current?.focus()},0);return}let c=aE(n,x,o,a?.trailingText);t(c.segments),L(c.segments),s?.({type:`chip`,trigger:x.config.char,...o});let l=b.current;l&&mD(l,c.cursorOffset),B(),setTimeout(()=>{b.current?.focus()},0)},[x,I,t,L,B,s,V,R]),re=H,ie=GD({editorRef:b,triggers:n,markdownEnabled:h,submitOnEnter:_,onSubmit:i,onEscape:a,onChange:t,onChipAdd:s,onChipDelete:c,readSegmentsFromDOM:I,renderSegmentsToDOM:L,runTriggerDetection:ee,dismissTrigger:B,buildInsertChip:z,selectSuggestionInternal:H,activeTrigger:x,suggestions:D,suggestionsLoading:O,suggestionsError:k,selectedSuggestionIndex:C,setSelectedSuggestionIndex:w,pushUndo:V.pushUndo,handleKeyDownForUndoRedo:V.handleKeyDownForUndoRedo,lastRenderedValue:N,undoTimer:P,undoBaseState:F}),ae=(0,v.useMemo)(()=>({focus:()=>b.current?.focus(),blur:()=>b.current?.blur(),insertChip:e=>{let n=I(),r={type:`chip`,...e},i=[...n,r,{type:`text`,text:` `}];t(i),L(i),s?.(r)},getPlainText:()=>QT(I()),clear:()=>{t([]);let e=b.current;if(e)for(;e.firstChild;)e.removeChild(e.firstChild);V.resetUndoHistory(),P.current&&=(clearTimeout(P.current),null),F.current=null},setText:e=>{V.pushUndo(I());let n=$T(e);t(n),L(n);let r=b.current;r&&mD(r,e.length)},appendText:e=>{let n=I();V.pushUndo(n);let r=n[n.length-1],i=r?.type===`text`?[...n.slice(0,-1),{type:`text`,text:r.text+e}]:[...n,{type:`text`,text:e}];t(i),L(i);let a=b.current;a&&mD(a,QT(i).length)},getCursorPosition:()=>{let e=b.current;return e?uD(e):null},setCursorPosition:e=>{let t=b.current;t&&mD(t,e)},setCursorToEnd:()=>{let e=b.current;e&&mD(e,QT(I()).length)},getSelection:()=>{let e=b.current;return e?gD(e):null},setSelection:(e,t)=>{let n=b.current;n&&_D(n,e,t)}}),[I,t,L,s,V]),oe=(0,v.useMemo)(()=>({onPaste:V.handlePaste,onCopy:V.handleCopy,onCut:V.handleCut,onDrop:V.handleDrop,onDragOver:V.handleDragOver,onCompositionStart:V.handleCompositionStart,onCompositionEnd:V.handleCompositionEnd,onBlur:V.handleBlur}),[V.handlePaste,V.handleCopy,V.handleCut,V.handleDrop,V.handleDragOver,V.handleCompositionStart,V.handleCompositionEnd,V.handleBlur]);return{editorRef:b,activeTrigger:x,suggestions:D,suggestionsLoading:O,suggestionsError:k,selectedSuggestionIndex:C,handleInput:ne,handleKeyDown:ie,handleClick:R.handleClick,handleMouseDown:R.handleMouseDown,selectSuggestion:re,dismissTrigger:B,handle:ae,triggerRect:T,eventHandlers:oe}}var ZD=240;function QD({suggestions:e,loading:t,error:n,emptyMessage:r,selectedIndex:i,onSelect:a,onDismiss:o,triggerRect:s,triggerChar:c}){let l=(0,v.useRef)(null),u=(0,v.useRef)(null);if((0,v.useEffect)(()=>{u.current?.scrollIntoView({block:`nearest`})},[i]),(0,v.useEffect)(()=>{let e=e=>{let t=e.target;l.current&&t instanceof Node&&!l.current.contains(t)&&o()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]),!s||e.length===0&&!t&&!n&&!r)return null;let d=Math.min(320,window.innerWidth-16),f=Math.min(s.left,window.innerWidth-d-8),p=window.innerHeight-s.bottom,m=p<ZD&&s.top>p,h={position:`fixed`,left:`${Math.max(8,f)}px`,zIndex:50,maxWidth:`${d}px`,maxHeight:`${ZD}px`,...m?{bottom:`${window.innerHeight-s.top+4}px`}:{top:`${s.bottom+4}px`}};return(0,U.jsx)(`div`,{ref:l,className:W(`min-w-[200px] overflow-y-auto`,`bg-surface rounded-xl border p-2 shadow-md`,`animate-in fade-in-0 zoom-in-95`),style:h,role:`listbox`,"aria-label":`${c} suggestions`,children:t?(0,U.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-muted-foreground px-3 py-2 text-sm`,children:`Loading suggestions...`}):n?(0,U.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-destructive px-3 py-2 text-sm`,children:n}):e.length===0&&r?(0,U.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-muted-foreground px-3 py-2 text-sm`,children:r}):e.map((e,t)=>(0,U.jsxs)(`button`,{ref:t===i?u:void 0,type:`button`,role:`option`,"aria-selected":t===i,className:W(`text-foreground flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-sm`,`hover:bg-surface-hover cursor-pointer transition-colors`,t===i&&`bg-surface-hover`),onMouseDown:t=>{t.preventDefault(),a(e)},children:[e.icon&&(0,U.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.icon}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate font-medium`,children:e.label}),e.description&&(0,U.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:e.description})]})]},e.value))})}function $D({texts:e,interval:t=3e3}){let[n,r]=(0,v.useState)(0);return(0,v.useEffect)(()=>{if(e.length<=1)return;let n=setInterval(()=>{r(t=>(t+1)%e.length)},t);return()=>clearInterval(n)},[e.length,t]),(0,U.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-0 overflow-hidden select-none`,style:{color:`var(--prompt-area-placeholder, var(--muted-foreground))`},"aria-hidden":`true`,children:(0,U.jsx)(`div`,{className:`animate-in fade-in-0 slide-in-from-top-4 duration-300 ease-in-out`,children:e[n]},n)})}function eO({onClick:e,label:t,className:n}){return(0,U.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},className:W(`absolute top-0.5 right-0.5 grid h-3.5 w-3.5 cursor-pointer place-items-center`,`rounded-full bg-black/60 text-white hover:bg-black/80 dark:bg-white/60 dark:text-black dark:hover:bg-white/80`,`transition-colors`,n),"aria-label":t,children:(0,U.jsxs)(`svg`,{width:`8`,height:`8`,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,U.jsx)(`line`,{x1:`2.75`,y1:`2.75`,x2:`7.25`,y2:`7.25`}),(0,U.jsx)(`line`,{x1:`7.25`,y1:`2.75`,x2:`2.75`,y2:`7.25`})]})})}function tO({images:e,onRemove:t,onClick:n,className:r}){return e.length===0?null:(0,U.jsx)(`div`,{className:W(`flex flex-wrap gap-2`,r),role:`list`,"aria-label":`Attached images`,children:e.map(e=>(0,U.jsxs)(`div`,{role:`listitem`,className:W(`border-border relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border`,n&&`cursor-pointer`),onClick:()=>n?.(e),children:[(0,U.jsx)(`img`,{src:e.url,alt:e.alt??`Attached image`,className:`h-full w-full object-cover`}),e.loading&&(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,U.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent`})}),t&&(0,U.jsx)(eO,{onClick:()=>t(e),label:`Remove ${e.alt??`image`}`})]},e.id))})}function nO({className:e,children:t}){return(0,U.jsx)(`svg`,{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`,"aria-hidden":`true`,className:e,children:t})}var rO=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}),(0,U.jsx)(`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`})]});function iO({className:e}){return(0,U.jsx)(nO,{className:e,children:rO})}function aO({className:e}){return(0,U.jsxs)(nO,{className:e,children:[rO,(0,U.jsx)(`path`,{d:`M10 9H8`}),(0,U.jsx)(`path`,{d:`M16 13H8`}),(0,U.jsx)(`path`,{d:`M16 17H8`})]})}function oO({className:e}){return(0,U.jsxs)(nO,{className:e,children:[rO,(0,U.jsx)(`path`,{d:`M8 13h2`}),(0,U.jsx)(`path`,{d:`M14 13h2`}),(0,U.jsx)(`path`,{d:`M8 17h2`}),(0,U.jsx)(`path`,{d:`M14 17h2`})]})}function sO({className:e}){return(0,U.jsxs)(nO,{className:e,children:[rO,(0,U.jsx)(`path`,{d:`M10 12.5 8 15l2 2.5`}),(0,U.jsx)(`path`,{d:`m14 12.5 2 2.5-2 2.5`})]})}function cO({className:e}){return(0,U.jsxs)(nO,{className:e,children:[(0,U.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`}),(0,U.jsx)(`circle`,{cx:`9`,cy:`9`,r:`2`}),(0,U.jsx)(`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`})]})}var lO=3;function uO(e){return e?e===`application/pdf`?`pdf`:e.includes(`spreadsheet`)||e===`text/csv`?`spreadsheet`:e.startsWith(`text/`)||e.includes(`javascript`)||e.includes(`json`)||e.includes(`xml`)?`code`:e.startsWith(`image/`)?`image`:`default`:`default`}var dO={pdf:aO,spreadsheet:oO,code:sO,image:cO,default:iO};function fO(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}function pO(e){let t=e.lastIndexOf(`.`);return t===-1||t===e.length-1?null:e.slice(t+1).toUpperCase()}function mO({file:e,compact:t,onRemove:n,onClick:r}){let i=[pO(e.name),e.size==null?null:fO(e.size)].filter(Boolean).join(` · `);return(0,U.jsxs)(`div`,{role:`listitem`,className:W(`border-border relative flex flex-shrink-0 items-center gap-2 overflow-hidden rounded-lg border transition-colors`,`hover:bg-surface-hover`,t?`h-10 w-36 px-2`:`h-14 w-48 px-3`,r&&`cursor-pointer`),onClick:()=>r?.(e),children:[(()=>{let n=dO[uO(e.type)];return(0,U.jsx)(n,{className:W(`text-muted-foreground flex-shrink-0`,t?`h-4 w-4`:`h-5 w-5`)})})(),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:W(`truncate font-medium`,t?`text-xs`:`text-sm`),title:e.name,children:e.name}),!t&&i&&(0,U.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:i})]}),e.loading&&(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,U.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent`})}),n&&(0,U.jsx)(eO,{onClick:()=>n(e),label:`Remove ${e.name}`})]})}function hO({files:e,onRemove:t,onClick:n,className:r}){let[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(null),s=(0,v.useRef)(null);if((0,v.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;t instanceof Node&&o.current&&!o.current.contains(t)&&!s.current?.contains(t)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]),e.length===0)return null;let c=e.length>lO,l=c,u=e.length-lO,d=e.slice(0,lO);return(0,U.jsxs)(`div`,{className:W(`relative`,r),children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`list`,"aria-label":`Attached files`,children:[(c?d:e).map(e=>(0,U.jsx)(mO,{file:e,compact:l,onRemove:t,onClick:n},e.id)),c&&(0,U.jsx)(`div`,{role:`listitem`,children:(0,U.jsx)(`button`,{ref:s,type:`button`,onClick:()=>a(e=>!e),className:W(`border-border text-muted-foreground hover:bg-surface-hover flex flex-shrink-0 cursor-pointer items-center justify-center rounded-lg border transition-colors`,l?`h-10 px-3 text-xs`:`h-14 px-4 text-sm`),children:i?`Show less`:`+${u} more`})})]}),i&&(0,U.jsx)(`div`,{ref:o,className:W(`bg-surface border-border absolute bottom-full left-0 z-10 mb-2 max-h-48 overflow-y-auto rounded-lg border p-2 shadow-lg`),children:(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`list`,"aria-label":`More attached files`,children:e.slice(lO).map(e=>(0,U.jsx)(mO,{file:e,compact:l,onRemove:t,onClick:n},e.id))})})]})}function gO({value:e,onChange:t,triggers:n,placeholder:r,className:i,disabled:a=!1,markdown:o,normalizeBullets:s,onSubmit:c,onEscape:l,onChipClick:u,onChipAdd:d,onChipDelete:f,onLinkClick:p,onPaste:m,onUndo:h,onRedo:g,minHeight:_=80,maxHeight:y,autoFocus:b=!1,autoGrow:x=!1,"aria-label":S,"data-test-id":C,images:w=[],imagePosition:T=`above`,onImagePaste:E,onImageRemove:D,onImageClick:O,files:k=[],filePosition:A=`above`,onFileRemove:j,onFileClick:M,onKeyDown:N,onBlur:P,onRawPaste:F,submitOnEnter:I,spellCheck:L,maxLength:R,"aria-describedby":z,ref:ee}){let{editorRef:B,activeTrigger:V,suggestions:te,suggestionsLoading:ne,suggestionsError:H,selectedSuggestionIndex:re,handleInput:ie,handleKeyDown:ae,handleClick:oe,handleMouseDown:se,selectSuggestion:ce,dismissTrigger:le,handle:ue,triggerRect:de,eventHandlers:fe}=XD({value:e,onChange:t,triggers:n,disabled:a,onSubmit:c,onEscape:l,onChipClick:u,onChipAdd:d,onChipDelete:f,onLinkClick:p,onPaste:m,onRawPaste:F,onUndo:h,onRedo:g,onImagePaste:E,markdown:o,normalizeBullets:s,submitOnEnter:I,maxLength:R});(0,v.useImperativeHandle)(ee,()=>ue,[ue]),(0,v.useEffect)(()=>{b&&B.current?.focus()},[b,B]);let[pe,me]=(0,v.useState)(!1),[he,ge]=(0,v.useState)(void 0),_e=(0,v.useCallback)(()=>{let e=B.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight;e.style.height=`${t}px`,ge(t)},[B]),ve=(0,v.useCallback)(()=>{x&&(me(!0),_e())},[x,_e]),ye=(0,v.useCallback)(()=>{fe.onBlur(),x&&setTimeout(()=>{let e=B.current;if(!e)return;let t=document.activeElement;t&&e.parentElement?.contains(t)||(me(!1),ge(void 0))},150)},[fe,x,B]),be=(0,v.useCallback)(()=>{ie(),x&&pe&&_e()},[ie,x,pe,_e]);(0,v.useEffect)(()=>{x&&pe&&requestAnimationFrame(()=>_e())},[e,x,pe,_e]);let[xe,Se]=(0,v.useState)(!1),Ce=(0,v.useRef)(null);(0,v.useEffect)(()=>x?(Ce.current=setTimeout(()=>{if(pe){Se(!1);return}let e=B.current;e&&Se(e.scrollHeight>e.clientHeight)},pe?0:160),()=>{Ce.current!==null&&clearTimeout(Ce.current)}):void 0,[x,pe,e,B]);let we=(0,v.useMemo)(()=>{if(!x){let e={minHeight:`${_}px`};return y&&(e.maxHeight=`${y}px`,e.overflowY=`auto`),e}return{height:pe&&he?`${he}px`:`${_}px`,minHeight:`${_}px`,maxHeight:y?`${y}px`:`70dvh`,overflowY:pe?`auto`:`hidden`,transition:`height 150ms ease-out, min-height 240ms cubic-bezier(0.33, 1, 0.68, 1)`}},[x,_,y,pe,he]),Te=(0,v.useCallback)(e=>{N?.(e),!e.defaultPrevented&&ae(e)},[N,ae]),Ee=(0,v.useCallback)(e=>{P?.(e),ye()},[P,ye]),De=e.length===0||e.length===1&&e[0].type===`text`&&e[0].text===``,Oe=w.length>0?(0,U.jsx)(tO,{images:w,onRemove:D,onClick:O,className:T===`above`?`pb-2`:`pt-2`}):null,ke=k.length>0?(0,U.jsx)(hO,{files:k,onRemove:j,onClick:M,className:A===`above`?`pb-2`:`pt-2`}):null;return(0,U.jsxs)(`div`,{className:W(`prompt-area-container relative text-sm leading-relaxed`,i),children:[T===`above`&&Oe,A===`above`&&ke,(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{ref:B,contentEditable:!a,suppressContentEditableWarning:!0,role:`textbox`,"aria-label":S??`Text input`,"aria-multiline":`true`,"aria-disabled":a||void 0,"aria-describedby":z,"data-test-id":C,spellCheck:L,className:W(`prompt-area-editor`,`w-full min-w-0 break-words whitespace-pre-wrap outline-none`,a&&`cursor-not-allowed opacity-50`),style:we,onFocus:ve,onInput:x?be:ie,onKeyDown:Te,onMouseDown:se,onClick:oe,onPaste:fe.onPaste,onCopy:fe.onCopy,onCut:fe.onCut,onDrop:fe.onDrop,onDragOver:fe.onDragOver,onCompositionStart:fe.onCompositionStart,onCompositionEnd:fe.onCompositionEnd,onBlur:Ee}),x&&xe&&!pe&&(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-auto absolute right-0 bottom-0 left-0 cursor-pointer`,style:{height:`32px`},onClick:()=>B.current?.focus(),children:(0,U.jsx)(`div`,{className:`h-full w-full`,style:{background:`linear-gradient(to bottom, transparent, color-mix(in srgb, var(--prompt-area-surface, var(--background)) 80%, transparent), var(--prompt-area-surface, var(--background)))`}})}),De&&r&&(Array.isArray(r)?(0,U.jsx)($D,{texts:r}):(0,U.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-0 select-none`,style:{color:`var(--prompt-area-placeholder, var(--muted-foreground))`},"aria-hidden":`true`,children:r}))]}),A===`below`&&ke,T===`below`&&Oe,V&&V.config.mode===`dropdown`&&(0,U.jsx)(QD,{suggestions:te,loading:ne,error:H,emptyMessage:V.config.emptyMessage,selectedIndex:re,onSelect:ce,onDismiss:le,triggerRect:de,triggerChar:V.config.char})]})}function _O(e={}){let{initialValue:t=[]}=e,[n,r]=(0,v.useState)(t),i=(0,v.useRef)(null),a=(0,v.useMemo)(()=>QT(n),[n]),o=(0,v.useMemo)(()=>n.length===0||n.every(e=>e.type===`text`&&e.text.trim()===``),[n]),s=(0,v.useMemo)(()=>n.some(e=>e.type===`chip`),[n]),c=(0,v.useMemo)(()=>n.filter(e=>e.type===`chip`),[n]);return{bind:(0,v.useMemo)(()=>({ref:i,value:n,onChange:r}),[n]),plainText:a,isEmpty:o,hasChips:s,chips:c,clear:(0,v.useCallback)(()=>{i.current?i.current.clear():r([])},[]),focus:(0,v.useCallback)(()=>i.current?.focus(),[]),blur:(0,v.useCallback)(()=>i.current?.blur(),[]),insertChip:(0,v.useCallback)(e=>i.current?.insertChip(e),[])}}function vO(e={}){let{char:t=`@`,...n}=e;return{char:t,position:`any`,mode:`dropdown`,chipStyle:`pill`,accessibilityLabel:`mention`,...n}}function yO(e={}){let{char:t=`/`,position:n=`any`,...r}=e;return{char:t,position:n,mode:`dropdown`,chipStyle:`inline`,accessibilityLabel:`command`,...r}}function bO(e={}){let{char:t=`#`,...n}=e;return{char:t,position:`any`,mode:`dropdown`,chipStyle:`pill`,resolveOnSpace:!0,accessibilityLabel:`tag`,...n}}function xO(e){let{char:t,...n}=e;return{char:t,position:`start`,mode:`launch`,...n}}var SO=[`attention`,`working`,`idle`,`ended`],CO={attention:`Needs attention`,working:`Working`,idle:`Idle`,ended:`Ended`};function wO(e){return e.pendingPermissionCount>0||e.status===`awaiting_approval`?`attention`:e.status===`failed`||e.status===`closed`?`ended`:e.status===`running`||e.status===`starting`||TO(e).length>0?`working`:`idle`}function TO(e){return(e.subagents??[]).filter(e=>e.status===`running`)}function EO(e,t){if(t===`none`)return[];let n=e.subagents??[];return t===`all`?[...n]:n.filter(e=>e.status!==`done`)}function DO(e){return e.isAgent===!0||(e.agentType?.trim()??``)!==``}function OO(e){let t=e.agentType?.trim(),n=e.description?.trim();return t&&n?`${t} · ${n}`:t||n||`Sub-agent`}var kO={search:``,gateways:[],adapters:[],states:[],projects:[],scoped:!0,groupBy:`state`,sortBy:`recent`,subagents:`active`};function AO(e){return[...new Set(e.map(e=>e.adapter))].sort()}function jO(e){let t=new Map;for(let n of e)t.set(NO(n),PO(n));return[...t].map(([e,t])=>({key:e,label:t})).sort((e,t)=>e.label.toLowerCase().localeCompare(t.label.toLowerCase()))}function MO(e){return e.title??e.id.slice(0,8)}function NO(e){return`${e.hostId}:${BO(e.info.project?.root??e.info.cwd)}`}function PO(e){return e.info.project?.shortcode||FO(e)}function FO(e){let t=e.info.project?.name;if(t)return t;let n=BO(e.info.cwd);return n.slice(n.lastIndexOf(`/`)+1)||`No project`}function IO(e){let t=e.info.project?.root;if(t===void 0||!e.info.cwd)return;let n=BO(t),r=BO(e.info.cwd);if(r!==n&&r.startsWith(`${n}/`))return r.slice(n.length+1)||void 0}function LO(e){return typeof e.meta?.jobId==`string`}function RO(e,t){return(e.shells??[]).filter(e=>e.status===`running`?t-e.startedAt>=Rk:e.endedAt===void 0||typeof e.exitCode!=`number`||e.exitCode===0?!1:e.endedAt-e.startedAt>=3e3&&t-e.endedAt<6e4)}function zO(e,t){return!t||MO(e.info).toLowerCase().includes(t)||e.info.cwd.toLowerCase().includes(t)||(e.info.project?.name.toLowerCase().includes(t)??!1)||(e.info.project?.shortcode?.toLowerCase().includes(t)??!1)||e.hostName.toLowerCase().includes(t)||e.adapter.toLowerCase().includes(t)||e.info.id.startsWith(t)}function BO(e){return e.replace(/\\/g,`/`).replace(/\/+$/,``)}function VO(e,t){let n=BO(e),r=BO(t);return r===n||r.startsWith(`${n}/`)}function HO(e,t){return t.roots.some(t=>(t.hostId?t.hostId.toLowerCase()===e.hostId.toLowerCase():e.local)&&VO(t.path,e.info.cwd))}function UO(e,t){return e.scoped&&t!==void 0}function WO(e,t,n){let r=t.search.trim().toLowerCase(),i=UO(t,n)?n:void 0;return e.filter(e=>(t.gateways.length===0||t.gateways.includes(e.hostId))&&(t.adapters.length===0||t.adapters.includes(e.adapter))&&(t.states.length===0||t.states.includes(e.state))&&(!t.projects?.length||t.projects.includes(NO(e)))&&(!i||HO(e,i))&&zO(e,r))}function GO(e,t){return t===`gateway`?e.hostId:t===`adapter`?e.adapter:t===`project`?NO(e):e.state}function KO(e,t){return t===`gateway`?e.hostName:t===`adapter`?e.adapter:t===`project`?PO(e):CO[e.state]}function qO(e,t){return t===`state`?String(SO.indexOf(e.state)):KO(e,t).toLowerCase()}function JO(e,t){return(t.info.lastActivityAt??t.info.createdAt)-(e.info.lastActivityAt??e.info.createdAt)}function Dee(e,t,n){return n===`recent`?JO(e,t):n===`name`?MO(e.info).localeCompare(MO(t.info),void 0,{sensitivity:`base`})||JO(e,t):qO(e,n).localeCompare(qO(t,n))||JO(e,t)}function Oee(e,t){let n=[...e].sort((e,n)=>Dee(e,n,t.sortBy));if(t.groupBy===`none`)return n.length?[{key:`all`,rows:n}]:[];let r=t.groupBy,i=new Map;for(let e of n){let t=GO(e,r),n=i.get(t);n?n.rows.push(e):i.set(t,{key:t,label:KO(e,r),rank:qO(e,r),rows:[e]})}return[...i.values()].sort((e,t)=>e.rank.localeCompare(t.rank))}function kee(e,t,n,r){if(n>=r)return;let i=[];t&&UO(e,t)&&i.push(t.label);let a=+!!e.gateways.length+ +!!e.adapters.length+ +!!e.states.length+ +!!e.projects?.length;return a>0&&i.push(`${a} filter${a===1?``:`s`}`),e.search.trim()&&i.push(`search`),{shown:n,total:r,causes:i}}function Aee(e){return e.search.trim().length>0||e.gateways.length>0||e.adapters.length>0||e.states.length>0||(e.projects?.length??0)>0}function YO(e){return{...kO,scoped:!1,groupBy:e.groupBy,sortBy:e.sortBy,subagents:e.subagents}}function jee(e){if(typeof e!=`object`||!e)return;let t=e,n=t.status;if(n!==`pending`&&n!==`in_progress`&&n!==`completed`)return;let r=typeof t.content==`string`?t.content.trim():``;if(r===``)return;let i=typeof t.activeForm==`string`?t.activeForm.trim():``;return{status:n,text:n===`in_progress`&&i!==``?i:r}}function Mee(e){let t=e?.todos;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=jee(e);if(t===void 0)return;n.push(t)}return n}function Nee(e){switch(e){case`in_progress`:return`running`;case`completed`:return`done`;default:return`pending`}}function Pee(e){let t=(e.checklist??[]).map((e,t)=>({key:`checklist:${t}`,label:e.text,source:`checklist`,state:Nee(e.status)})),n=(e.subagents??[]).filter(e=>!DO(e)).map(e=>({key:`spawn:${e.toolUseId}`,label:e.description?.trim()||`Task`,source:`spawn`,state:e.status,detail:e.toolCount>0?String(e.toolCount):void 0,toolUseId:e.toolUseId}));return[...t,...n]}function XO(e){let t=0,n=0,r=0;for(let i of e)i.state===`done`?t+=1:i.state===`running`?n+=1:i.state===`failed`&&(r+=1);return{total:e.length,done:t,running:n,failed:r}}function Fee(e){return e.total===0?void 0:`${e.done}/${e.total}`}function Iee(e,t){return t?[...e]:e.filter(e=>e.state!==`done`)}var ZO=`2026-09-19`,QO=`List rates as of ${ZO}. A subscription is a flat fee, so this is what the same tokens would have cost on the pay-as-you-go API, not a bill.`,Lee=.005,$O=1e6,Ree=864e5,ek=[`input`,`output`,`cacheWrite5m`,`cacheWrite1h`,`cacheRead`];function tk(e,t,n){return{input:e,output:t,cacheWrite5m:e*1.25,cacheWrite1h:e*2,cacheRead:n??e*.1}}function nk(e,t,n){return{input:e,output:t,cacheWrite5m:e,cacheWrite1h:e,cacheRead:n}}var rk={"claude-fable-5-1":tk(10,50,.25),"claude-fable-5":tk(10,50),"claude-mythos-5-1":tk(10,50,.25),"claude-mythos-5":tk(10,50),"claude-opus-5":tk(5,25),"claude-opus-4-8":tk(5,25),"claude-opus-4-7":tk(5,25),"claude-opus-4-6":tk(5,25),"claude-opus-4-5":tk(5,25),"claude-sonnet-5":tk(2,10),"claude-sonnet-4-6":tk(3,15),"claude-sonnet-4-5":tk(3,15),"claude-haiku-4-5":tk(1,5),"gpt-6-astra":nk(10,50,1),"gpt-5.6-sol":nk(4,20,.4),"gpt-5.6-terra":nk(2,12,.2),"gpt-5.6-luna":nk(.2,1.2,.02),"gpt-5.5":nk(5,30,.5),"gpt-5.4":nk(2.5,15,.25),"gpt-5.2":nk(1.75,14,.175),"gpt-5.1":nk(1.25,10,.125),"gpt-5":nk(1.25,10,.125)},ik=rk;function ak(e){if(typeof e!=`object`||!e)return;let t=e,n={input:0,output:0,cacheWrite5m:0,cacheWrite1h:0,cacheRead:0};for(let e of ek){let r=t[e];if(typeof r!=`number`||!Number.isFinite(r)||r<0)return;n[e]=r}return n}function ok(e,t=rk){let n={},r=[];if(typeof e==`object`&&e)for(let[t,i]of Object.entries(e)){let e=ak(i),a=uk(t);if(!e||a===``){r.push(t);continue}n[a]=e}return{pricing:{...t,...n},overrides:n,dropped:r}}function sk(){return ik}function ck(e,t=ZO){let n=Date.parse(t);return Number.isFinite(n)?Math.floor((e-n)/Ree):0}function lk(e,t=ZO){let n=ck(e,t);if(!(n<=90))return`This rate table is ${n} days old, so check the vendor's current list prices before you trust the total.`}function uk(e){let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase().replace(/\[[^\]]*\]$/,``).replace(/^(?:[a-z]+\.)*anthropic\./,``).replace(/[@-]\d{8}$/,``).replace(/-v\d+:\d+$/,``)}function dk(e,t=sk()){return e?t[uk(e)]:void 0}function fk(e){return e.input+e.output+e.cacheWrite5m+e.cacheWrite1h+e.cacheRead}function pk(e){return Object.entries(e).filter(([,e])=>e.costBasis===`unknown`).map(([e])=>uk(e))}function mk(e){return{input:0,output:0,cacheWrite:0,cacheRead:0,total:0,unpriced:!0,unpricedTokens:e,unpricedShare:+(e>0)}}function hk(e,t,n=sk()){let r=dk(t,n);if(!r)return mk(fk(e));let i=e.input/$O*r.input,a=e.output/$O*r.output,o=e.cacheWrite5m/$O*r.cacheWrite5m+e.cacheWrite1h/$O*r.cacheWrite1h,s=e.cacheRead/$O*r.cacheRead;return{input:i,output:a,cacheWrite:o,cacheRead:s,total:i+a+o+s,unpriced:!1,unpricedTokens:0,unpricedShare:0}}function gk(e,t=sk()){let n={input:0,output:0,cacheWrite:0,cacheRead:0,total:0,unpriced:!1,unpricedTokens:0,unpricedShare:0},r=Object.entries(e),i=!1,a=0;for(let[e,o]of r){a+=fk(o);let r=hk(o,e,t);if(r.unpriced){n.unpricedTokens+=r.unpricedTokens;continue}i=!0,n.input+=r.input,n.output+=r.output,n.cacheWrite+=r.cacheWrite,n.cacheRead+=r.cacheRead,n.total+=r.total}return n.unpriced=!i&&r.length>0,n.unpricedShare=a>0?n.unpricedTokens/a:0,n}var _k=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`)`,`]`,`}`,`"`,`'`]),vk=/^[\p{L}\p{N}][\p{L}\p{N}\-_]*$/u;function yk(e,t){return(e??``).normalize(`NFKC`).replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/^-+|-+$/g,``)||t.slice(0,8)}function bk(e){return e.normalize(`NFKC`).toLowerCase().replace(/[_\s]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function xk(e){return e.length>0&&e.length<=64&&vk.test(e)}var Sk={fs_read:`Reading a file`,fs_write:`Writing a file`,fs_list:`Listing files`,eval_script:`Running a script`,web_fetch:`Fetching a web page`,web_search:`Searching the web`,deliver_file:`Delivering a file`,download:`Downloading a file`,CodexCommand:`Running a command`,CodexFileChange:`Editing a file`,CodexWebSearch:`Searching the web`,CodexImageGeneration:`Generating an image`,CodexImageView:`Viewing an image`,peers_list:`Listing peer sessions`,peers_peek:`Peeking at a peer session`,peers_send:`Messaging a peer session`,mcp__workerdeck__peers_list:`Listing peer sessions`,mcp__workerdeck__peers_peek:`Peeking at a peer session`,mcp__workerdeck__peers_send:`Messaging a peer session`};function Ck(e,t){return wk(t?.[e]??Sk[e],e)}function wk(e,t){if(typeof e!=`string`)return;let n=[...e].map(e=>e<` `||e===``?` `:e).join(``).replace(/\s+/g,` `).trim();if(n===``||n===t)return;let r=[...n];return r.length>64?r.slice(0,63).join(``)+`…`:n}var Tk=[`peers_send`,`mcp__workerdeck__peers_send`];function Ek(e){return Tk.includes(e)}function Dk(e,t){let n={};for(let[t,r]of Object.entries(e.rateLimits??{}))n[t]={info:r,updatedAt:e.updatedAt??0};for(let[e,r]of Object.entries(t??{}))n[e]=r;return n}var Ok=9e5;function kk(e,t){return e.inferredReset||e.updatedAt===void 0?!1:t-e.updatedAt>Ok}function Ak(e){let t=Object.entries(e??{}).filter(([,e])=>e.info.utilization!==void 0).map(([e,t])=>({key:e,info:t.info,updatedAt:t.updatedAt,inferredReset:t.inferredReset})),n=[`five_hour`,`seven_day`].flatMap(e=>t.filter(t=>t.key===e)),r=t.filter(e=>e.key.startsWith(`seven_day_`)).sort((e,t)=>e.key.localeCompare(t.key));return[...n,...r]}function jk(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))t[n]=r.info;return t}var Mk=2592e6,Nk=6e4;function Pk(e,t){return`${e}:${t}`}var Fk=class{#e;#t;constructor(e){this.#e=e,this.#t={...e.read()}}get(e,t){return this.#t[Pk(e,t)]}all(){return this.#t}mark(e,t,n,r=Date.now()){let i=Pk(e,t),a=this.#t[i],o={itemCount:Math.max(a?.itemCount??0,n.itemCount??0),activity:Math.max(a?.activity??0,n.activity??0),prose:n.prose===void 0?a?.prose:Math.max(a?.prose??0,n.prose),turns:Math.max(a?.turns??0,n.turns??0),seenAt:r};return a&&a.itemCount===o.itemCount&&a.activity===o.activity&&a.prose===o.prose&&a.turns===o.turns&&o.seenAt-a.seenAt<Nk?!1:(this.#t[i]=o,this.#e.write(this.#n(r)),!0)}forget(e,t){let n=Pk(e,t);n in this.#t&&(delete this.#t[n],this.#e.write(this.#t))}#n(e){let t=e-Mk;for(let[e,n]of Object.entries(this.#t))n.seenAt<t&&delete this.#t[e];return this.#t}};function Ik(e,t){return e?t.proseCount===void 0?t.activityCount===void 0?Math.max(0,(t.turns??0)-e.turns):Math.max(0,t.activityCount-e.activity):Math.max(0,t.proseCount-(e.prose??t.proseCount)):0}function Lk(e){return(Array.isArray(e.questions)?e.questions:[]).flatMap(e=>{let t=e;if(typeof t.question!=`string`||!Array.isArray(t.options))return[];let n=t.options.filter(e=>typeof e?.label==`string`);return n.length===0?[]:[{question:t.question,header:typeof t.header==`string`?t.header:``,options:n,multiSelect:t.multiSelect===!0}]})}var Rk=3e3,zk={claude:{interactiveApprovals:!0,permissionModes:[`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`],defaultPermissionMode:`default`,resume:!0,resumeBackfill:!0,listSessions:!0,contextUsage:!0,rateLimits:!0,mcpStatus:!0,mcpServerActions:!0,sessionMcpServers:!0,slashCommands:!0,clearContext:!0,skillsList:!1,settingSources:!0,budgets:!0,attachments:[`image`,`pdf`,`text`],reasoningEfforts:[`low`,`medium`,`high`,`xhigh`,`max`],vfs:!1,hostCwd:!0,systemInstructions:!0,streaming:`token`},codex:{interactiveApprovals:!0,permissionModes:[`default`,`acceptEdits`,`bypassPermissions`,`auto`],defaultPermissionMode:`default`,resume:!0,resumeBackfill:!0,listSessions:!0,contextUsage:!0,rateLimits:!0,mcpStatus:!0,mcpServerActions:!1,sessionMcpServers:!1,slashCommands:!1,clearContext:!0,skillsList:!0,settingSources:!1,budgets:!1,attachments:[`image`,`text`],reasoningEfforts:[`minimal`,`low`,`medium`,`high`,`xhigh`],vfs:!1,hostCwd:!0,systemInstructions:!0,streaming:`token`},provider:{interactiveApprovals:!1,permissionModes:[`default`,`bypassPermissions`,`dontAsk`],defaultPermissionMode:`default`,resume:!1,resumeBackfill:!1,listSessions:!1,contextUsage:!1,rateLimits:!1,mcpStatus:!0,mcpServerActions:!1,sessionMcpServers:!1,slashCommands:!1,clearContext:!0,skillsList:!1,settingSources:!1,budgets:!1,attachments:[`image`,`pdf`,`text`],vfs:!0,hostCwd:!1,systemInstructions:!0,streaming:`token`}};function Bk(e){let t=/^Delivered to (.+) \(([^()]+)\);/.exec(e);if(t)return{sessionId:t[2],name:t[1]};let n=/^Delivered to ([^()\s]+);/.exec(e);return n?{sessionId:n[1]}:void 0}var Vk={status:`starting`,capabilities:zk.claude,items:[],pendingApprovals:[],totalCostUsd:0,lastSeq:0},Hk=`streaming`,Uk=`streaming-thinking`,Wk=/^<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>$/,Gk=/<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>/g,Kk=`<local-command-caveat>`,qk=/^\[\.\.\. more output \.\.\.\]$/,Jk=/^\[(exit -?\d+|killed|timed out|ended|failed to start)[^\]]*\]$/;function Yk(e,t){let n=(Wk.exec(t.trim())?.[2]??t).split(`
|
|
44
|
+
`);for(let n=0;n<e.length;n++)e[n]&&t.appendChild(document.createTextNode(e[n])),n<e.length-1&&t.appendChild(document.createElement(`br`))}else{let e=document.createElement(`span`);if(e.contentEditable=`false`,e.dataset.chipTrigger=r.trigger,e.dataset.chipValue=r.value,e.dataset.chipDisplay=r.displayText,r.sigil!==void 0&&(e.dataset.chipSigil=r.sigil),r.data!==void 0){let t=WE(r.data);t&&(e.dataset.chipData=t)}r.autoResolved&&(e.dataset.chipAutoResolved=`true`);let i=n.find(e=>e.char===r.trigger),a=i?.chipStyle??`pill`;e.dataset.chipStyle=a,e.className=W(`prompt-area-chip`,a===`inline`&&`prompt-area-chip--inline`,i?.chipClassName),e.textContent=ZT(r),e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`-1`),t.appendChild(e)}if(t.lastChild&&zE(t.lastChild)){let e=document.createElement(`br`);e.dataset.sentinel=`true`,t.appendChild(e)}cD(t,h),r!==null&&mD(t,r),N.current=e,M.current=!1},[n,h]),R=KD({editorRef:b,triggers:n,disabled:r,onChange:t,renderSegmentsToDOM:L,onChipClick:o,onChipAdd:s,onChipDelete:c,onLinkClick:l,setActiveTrigger:S,setSelectedSuggestionIndex:w,setTriggerRect:E,runSearch:A,activeTrigger:x,suggestions:D}),z=(0,v.useCallback)((e,n)=>r=>{let i=aE(e,n,{value:r.value,displayText:r.displayText,data:r.data});t(i.segments),L(i.segments),s?.({type:`chip`,trigger:n.config.char,value:r.value,displayText:r.displayText,...r.data===void 0?{}:{data:r.data}});let a=b.current;a&&mD(a,i.cursorOffset)},[t,L,s]),ee=(0,v.useCallback)(()=>{let e=b.current;if(!e)return;let t=I(),r=QT(t),i=uD(e);if(i===null)return;let a=iE(r,i,n);if(R.clear(),a){S(a),w(0);let n=dD(e,a.startOffset);if(n){let e=n.getBoundingClientRect();(e.height>0||e.left>0||e.top>0)&&E(e)}a.config.mode===`dropdown`&&a.config.onSearch&&A(a.query,a.config),a.config.mode===`callback`&&a.config.onActivate&&a.config.onActivate({text:r,cursorPosition:i,insertChip:z(t,a)})}else S(null),j()},[n,I,z,j,A,R]),B=(0,v.useCallback)(()=>{R.clear(),S(null),w(0),j()},[j,R]),V=WD({editorRef:b,readSegmentsFromDOM:I,onChange:t,renderSegmentsToDOM:L,runTriggerDetection:ee,dismissTrigger:B,triggers:n,markdownEnabled:h,normalizeBullets:g,onPaste:u,onRawPaste:d,onUndo:f,onRedo:p,onChipAdd:s,onImagePaste:m});(0,v.useLayoutEffect)(()=>{if(!M.current&&!pE(e,N.current)){if(h&&g){let n=OE(e,!0);if(n!==e){t(n);return}}if(mE(I(),e)){N.current=e;return}L(e)}},[e,I,L,h,g,t]);let te=(0,v.useRef)(h);(0,v.useLayoutEffect)(()=>{if(te.current===h)return;te.current=h;let n=g?OE(e,h):e;n===e?L(e):t(n)},[h,g,L,e,t]),(0,v.useEffect)(()=>()=>{P.current&&clearTimeout(P.current)},[]);let ne=(0,v.useCallback)(()=>{if(M.current)return;if(V.isComposing.current){let e=I();N.current=e,t(e);return}let e=b.current,n=e?uD(e):null;e&&rD(e);let r=I();if(y!=null&&e&&QT(r).length>y){let n=uD(e),i=eE(r,y);N.current=i,t(i),L(i),mD(e,n==null?y:Math.min(n,y)),ee();return}if(h&&g&&e&&n!==null){let i=vE(r,n);if(i){N.current=i.segments,t(i.segments),L(i.segments),mD(e,i.cursorOffset),ee();return}}let i=r,a=null;if(h&&n!==null&&kE(QT(r))){let e=ME(r);e.edits.length>0&&(i=e.segments,a=jE(n,e.edits))}F.current||=N.current,N.current=i,t(i),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{F.current&&=(V.pushUndo(F.current),null),P.current=null},JD),e&&(a===null?(cD(e,h),n!==null&&mD(e,n)):(L(i),mD(e,a))),ee()},[t,I,ee,L,h,g,y,V]),H=(0,v.useCallback)(e=>{if(!x)return;let n=I(),r=x.config.insertAsText?.(e);if(r!==void 0){let e=oE(n,x,r);V.pushUndo(n),t(e.segments),L(e.segments);let i=b.current;i&&mD(i,e.cursorOffset),B(),setTimeout(()=>{b.current?.focus()},0);return}let i=x.config.onSelect?.(e)??e.label,a=x.config.chipOptions?.(e),o={value:e.value,displayText:i||e.label,...a?.sigil===void 0?{}:{sigil:a.sigil},data:e.data};if(R.trySelectEditingChip(n,o,x.config.char,V.pushUndo)){B(),setTimeout(()=>{b.current?.focus()},0);return}let c=aE(n,x,o,a?.trailingText);t(c.segments),L(c.segments),s?.({type:`chip`,trigger:x.config.char,...o});let l=b.current;l&&mD(l,c.cursorOffset),B(),setTimeout(()=>{b.current?.focus()},0)},[x,I,t,L,B,s,V,R]),re=H,ie=GD({editorRef:b,triggers:n,markdownEnabled:h,submitOnEnter:_,onSubmit:i,onEscape:a,onChange:t,onChipAdd:s,onChipDelete:c,readSegmentsFromDOM:I,renderSegmentsToDOM:L,runTriggerDetection:ee,dismissTrigger:B,buildInsertChip:z,selectSuggestionInternal:H,activeTrigger:x,suggestions:D,suggestionsLoading:O,suggestionsError:k,selectedSuggestionIndex:C,setSelectedSuggestionIndex:w,pushUndo:V.pushUndo,handleKeyDownForUndoRedo:V.handleKeyDownForUndoRedo,lastRenderedValue:N,undoTimer:P,undoBaseState:F}),ae=(0,v.useMemo)(()=>({focus:()=>b.current?.focus(),blur:()=>b.current?.blur(),insertChip:e=>{let n=I(),r={type:`chip`,...e},i=[...n,r,{type:`text`,text:` `}];t(i),L(i),s?.(r)},getPlainText:()=>QT(I()),clear:()=>{t([]);let e=b.current;if(e)for(;e.firstChild;)e.removeChild(e.firstChild);V.resetUndoHistory(),P.current&&=(clearTimeout(P.current),null),F.current=null},setText:e=>{V.pushUndo(I());let n=$T(e);t(n),L(n);let r=b.current;r&&mD(r,e.length)},appendText:e=>{let n=I();V.pushUndo(n);let r=n[n.length-1],i=r?.type===`text`?[...n.slice(0,-1),{type:`text`,text:r.text+e}]:[...n,{type:`text`,text:e}];t(i),L(i);let a=b.current;a&&mD(a,QT(i).length)},getCursorPosition:()=>{let e=b.current;return e?uD(e):null},setCursorPosition:e=>{let t=b.current;t&&mD(t,e)},setCursorToEnd:()=>{let e=b.current;e&&mD(e,QT(I()).length)},getSelection:()=>{let e=b.current;return e?gD(e):null},setSelection:(e,t)=>{let n=b.current;n&&_D(n,e,t)}}),[I,t,L,s,V]),oe=(0,v.useMemo)(()=>({onPaste:V.handlePaste,onCopy:V.handleCopy,onCut:V.handleCut,onDrop:V.handleDrop,onDragOver:V.handleDragOver,onCompositionStart:V.handleCompositionStart,onCompositionEnd:V.handleCompositionEnd,onBlur:V.handleBlur}),[V.handlePaste,V.handleCopy,V.handleCut,V.handleDrop,V.handleDragOver,V.handleCompositionStart,V.handleCompositionEnd,V.handleBlur]);return{editorRef:b,activeTrigger:x,suggestions:D,suggestionsLoading:O,suggestionsError:k,selectedSuggestionIndex:C,handleInput:ne,handleKeyDown:ie,handleClick:R.handleClick,handleMouseDown:R.handleMouseDown,selectSuggestion:re,dismissTrigger:B,handle:ae,triggerRect:T,eventHandlers:oe}}var ZD=240;function QD({suggestions:e,loading:t,error:n,emptyMessage:r,selectedIndex:i,onSelect:a,onDismiss:o,triggerRect:s,triggerChar:c}){let l=(0,v.useRef)(null),u=(0,v.useRef)(null);if((0,v.useEffect)(()=>{u.current?.scrollIntoView({block:`nearest`})},[i]),(0,v.useEffect)(()=>{let e=e=>{let t=e.target;l.current&&t instanceof Node&&!l.current.contains(t)&&o()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]),!s||e.length===0&&!t&&!n&&!r)return null;let d=Math.min(320,window.innerWidth-16),f=Math.min(s.left,window.innerWidth-d-8),p=window.innerHeight-s.bottom,m=p<ZD&&s.top>p,h={position:`fixed`,left:`${Math.max(8,f)}px`,zIndex:50,maxWidth:`${d}px`,maxHeight:`${ZD}px`,...m?{bottom:`${window.innerHeight-s.top+4}px`}:{top:`${s.bottom+4}px`}};return(0,U.jsx)(`div`,{ref:l,className:W(`min-w-[200px] overflow-y-auto`,`bg-surface rounded-xl border p-2 shadow-md`,`animate-in fade-in-0 zoom-in-95`),style:h,role:`listbox`,"aria-label":`${c} suggestions`,children:t?(0,U.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-muted-foreground px-3 py-2 text-sm`,children:`Loading suggestions...`}):n?(0,U.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-destructive px-3 py-2 text-sm`,children:n}):e.length===0&&r?(0,U.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-muted-foreground px-3 py-2 text-sm`,children:r}):e.map((e,t)=>(0,U.jsxs)(`button`,{ref:t===i?u:void 0,type:`button`,role:`option`,"aria-selected":t===i,className:W(`text-foreground flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-sm`,`hover:bg-surface-hover cursor-pointer transition-colors`,t===i&&`bg-surface-hover`),onMouseDown:t=>{t.preventDefault(),a(e)},children:[e.icon&&(0,U.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.icon}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate font-medium`,children:e.label}),e.description&&(0,U.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:e.description})]})]},e.value))})}function $D({texts:e,interval:t=3e3}){let[n,r]=(0,v.useState)(0);return(0,v.useEffect)(()=>{if(e.length<=1)return;let n=setInterval(()=>{r(t=>(t+1)%e.length)},t);return()=>clearInterval(n)},[e.length,t]),(0,U.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-0 overflow-hidden select-none`,style:{color:`var(--prompt-area-placeholder, var(--muted-foreground))`},"aria-hidden":`true`,children:(0,U.jsx)(`div`,{className:`animate-in fade-in-0 slide-in-from-top-4 duration-300 ease-in-out`,children:e[n]},n)})}function eO({onClick:e,label:t,className:n}){return(0,U.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},className:W(`absolute top-0.5 right-0.5 grid h-3.5 w-3.5 cursor-pointer place-items-center`,`rounded-full bg-black/60 text-white hover:bg-black/80 dark:bg-white/60 dark:text-black dark:hover:bg-white/80`,`transition-colors`,n),"aria-label":t,children:(0,U.jsxs)(`svg`,{width:`8`,height:`8`,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,U.jsx)(`line`,{x1:`2.75`,y1:`2.75`,x2:`7.25`,y2:`7.25`}),(0,U.jsx)(`line`,{x1:`7.25`,y1:`2.75`,x2:`2.75`,y2:`7.25`})]})})}function tO({images:e,onRemove:t,onClick:n,className:r}){return e.length===0?null:(0,U.jsx)(`div`,{className:W(`flex flex-wrap gap-2`,r),role:`list`,"aria-label":`Attached images`,children:e.map(e=>(0,U.jsxs)(`div`,{role:`listitem`,className:W(`border-border relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border`,n&&`cursor-pointer`),onClick:()=>n?.(e),children:[(0,U.jsx)(`img`,{src:e.url,alt:e.alt??`Attached image`,className:`h-full w-full object-cover`}),e.loading&&(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,U.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent`})}),t&&(0,U.jsx)(eO,{onClick:()=>t(e),label:`Remove ${e.alt??`image`}`})]},e.id))})}function nO({className:e,children:t}){return(0,U.jsx)(`svg`,{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`,"aria-hidden":`true`,className:e,children:t})}var rO=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}),(0,U.jsx)(`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`})]});function iO({className:e}){return(0,U.jsx)(nO,{className:e,children:rO})}function aO({className:e}){return(0,U.jsxs)(nO,{className:e,children:[rO,(0,U.jsx)(`path`,{d:`M10 9H8`}),(0,U.jsx)(`path`,{d:`M16 13H8`}),(0,U.jsx)(`path`,{d:`M16 17H8`})]})}function oO({className:e}){return(0,U.jsxs)(nO,{className:e,children:[rO,(0,U.jsx)(`path`,{d:`M8 13h2`}),(0,U.jsx)(`path`,{d:`M14 13h2`}),(0,U.jsx)(`path`,{d:`M8 17h2`}),(0,U.jsx)(`path`,{d:`M14 17h2`})]})}function sO({className:e}){return(0,U.jsxs)(nO,{className:e,children:[rO,(0,U.jsx)(`path`,{d:`M10 12.5 8 15l2 2.5`}),(0,U.jsx)(`path`,{d:`m14 12.5 2 2.5-2 2.5`})]})}function cO({className:e}){return(0,U.jsxs)(nO,{className:e,children:[(0,U.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`}),(0,U.jsx)(`circle`,{cx:`9`,cy:`9`,r:`2`}),(0,U.jsx)(`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`})]})}var lO=3;function uO(e){return e?e===`application/pdf`?`pdf`:e.includes(`spreadsheet`)||e===`text/csv`?`spreadsheet`:e.startsWith(`text/`)||e.includes(`javascript`)||e.includes(`json`)||e.includes(`xml`)?`code`:e.startsWith(`image/`)?`image`:`default`:`default`}var dO={pdf:aO,spreadsheet:oO,code:sO,image:cO,default:iO};function fO(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}function pO(e){let t=e.lastIndexOf(`.`);return t===-1||t===e.length-1?null:e.slice(t+1).toUpperCase()}function mO({file:e,compact:t,onRemove:n,onClick:r}){let i=[pO(e.name),e.size==null?null:fO(e.size)].filter(Boolean).join(` · `);return(0,U.jsxs)(`div`,{role:`listitem`,className:W(`border-border relative flex flex-shrink-0 items-center gap-2 overflow-hidden rounded-lg border transition-colors`,`hover:bg-surface-hover`,t?`h-10 w-36 px-2`:`h-14 w-48 px-3`,r&&`cursor-pointer`),onClick:()=>r?.(e),children:[(()=>{let n=dO[uO(e.type)];return(0,U.jsx)(n,{className:W(`text-muted-foreground flex-shrink-0`,t?`h-4 w-4`:`h-5 w-5`)})})(),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:W(`truncate font-medium`,t?`text-xs`:`text-sm`),title:e.name,children:e.name}),!t&&i&&(0,U.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:i})]}),e.loading&&(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,U.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent`})}),n&&(0,U.jsx)(eO,{onClick:()=>n(e),label:`Remove ${e.name}`})]})}function hO({files:e,onRemove:t,onClick:n,className:r}){let[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(null),s=(0,v.useRef)(null);if((0,v.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;t instanceof Node&&o.current&&!o.current.contains(t)&&!s.current?.contains(t)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]),e.length===0)return null;let c=e.length>lO,l=c,u=e.length-lO,d=e.slice(0,lO);return(0,U.jsxs)(`div`,{className:W(`relative`,r),children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`list`,"aria-label":`Attached files`,children:[(c?d:e).map(e=>(0,U.jsx)(mO,{file:e,compact:l,onRemove:t,onClick:n},e.id)),c&&(0,U.jsx)(`div`,{role:`listitem`,children:(0,U.jsx)(`button`,{ref:s,type:`button`,onClick:()=>a(e=>!e),className:W(`border-border text-muted-foreground hover:bg-surface-hover flex flex-shrink-0 cursor-pointer items-center justify-center rounded-lg border transition-colors`,l?`h-10 px-3 text-xs`:`h-14 px-4 text-sm`),children:i?`Show less`:`+${u} more`})})]}),i&&(0,U.jsx)(`div`,{ref:o,className:W(`bg-surface border-border absolute bottom-full left-0 z-10 mb-2 max-h-48 overflow-y-auto rounded-lg border p-2 shadow-lg`),children:(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`list`,"aria-label":`More attached files`,children:e.slice(lO).map(e=>(0,U.jsx)(mO,{file:e,compact:l,onRemove:t,onClick:n},e.id))})})]})}function gO({value:e,onChange:t,triggers:n,placeholder:r,className:i,disabled:a=!1,markdown:o,normalizeBullets:s,onSubmit:c,onEscape:l,onChipClick:u,onChipAdd:d,onChipDelete:f,onLinkClick:p,onPaste:m,onUndo:h,onRedo:g,minHeight:_=80,maxHeight:y,autoFocus:b=!1,autoGrow:x=!1,"aria-label":S,"data-test-id":C,images:w=[],imagePosition:T=`above`,onImagePaste:E,onImageRemove:D,onImageClick:O,files:k=[],filePosition:A=`above`,onFileRemove:j,onFileClick:M,onKeyDown:N,onBlur:P,onRawPaste:F,submitOnEnter:I,spellCheck:L,maxLength:R,"aria-describedby":z,ref:ee}){let{editorRef:B,activeTrigger:V,suggestions:te,suggestionsLoading:ne,suggestionsError:H,selectedSuggestionIndex:re,handleInput:ie,handleKeyDown:ae,handleClick:oe,handleMouseDown:se,selectSuggestion:ce,dismissTrigger:le,handle:ue,triggerRect:de,eventHandlers:fe}=XD({value:e,onChange:t,triggers:n,disabled:a,onSubmit:c,onEscape:l,onChipClick:u,onChipAdd:d,onChipDelete:f,onLinkClick:p,onPaste:m,onRawPaste:F,onUndo:h,onRedo:g,onImagePaste:E,markdown:o,normalizeBullets:s,submitOnEnter:I,maxLength:R});(0,v.useImperativeHandle)(ee,()=>ue,[ue]),(0,v.useEffect)(()=>{b&&B.current?.focus()},[b,B]);let[pe,me]=(0,v.useState)(!1),[he,ge]=(0,v.useState)(void 0),_e=(0,v.useCallback)(()=>{let e=B.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight;e.style.height=`${t}px`,ge(t)},[B]),ve=(0,v.useCallback)(()=>{x&&(me(!0),_e())},[x,_e]),ye=(0,v.useCallback)(()=>{fe.onBlur(),x&&setTimeout(()=>{let e=B.current;if(!e)return;let t=document.activeElement;t&&e.parentElement?.contains(t)||(me(!1),ge(void 0))},150)},[fe,x,B]),be=(0,v.useCallback)(()=>{ie(),x&&pe&&_e()},[ie,x,pe,_e]);(0,v.useEffect)(()=>{x&&pe&&requestAnimationFrame(()=>_e())},[e,x,pe,_e]);let[xe,Se]=(0,v.useState)(!1),Ce=(0,v.useRef)(null);(0,v.useEffect)(()=>x?(Ce.current=setTimeout(()=>{if(pe){Se(!1);return}let e=B.current;e&&Se(e.scrollHeight>e.clientHeight)},pe?0:160),()=>{Ce.current!==null&&clearTimeout(Ce.current)}):void 0,[x,pe,e,B]);let we=(0,v.useMemo)(()=>{if(!x){let e={minHeight:`${_}px`};return y&&(e.maxHeight=`${y}px`,e.overflowY=`auto`),e}return{height:pe&&he?`${he}px`:`${_}px`,minHeight:`${_}px`,maxHeight:y?`${y}px`:`70dvh`,overflowY:pe?`auto`:`hidden`,transition:`height 150ms ease-out, min-height 240ms cubic-bezier(0.33, 1, 0.68, 1)`}},[x,_,y,pe,he]),Te=(0,v.useCallback)(e=>{N?.(e),!e.defaultPrevented&&ae(e)},[N,ae]),Ee=(0,v.useCallback)(e=>{P?.(e),ye()},[P,ye]),De=e.length===0||e.length===1&&e[0].type===`text`&&e[0].text===``,Oe=w.length>0?(0,U.jsx)(tO,{images:w,onRemove:D,onClick:O,className:T===`above`?`pb-2`:`pt-2`}):null,ke=k.length>0?(0,U.jsx)(hO,{files:k,onRemove:j,onClick:M,className:A===`above`?`pb-2`:`pt-2`}):null;return(0,U.jsxs)(`div`,{className:W(`prompt-area-container relative text-sm leading-relaxed`,i),children:[T===`above`&&Oe,A===`above`&&ke,(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{ref:B,contentEditable:!a,suppressContentEditableWarning:!0,role:`textbox`,"aria-label":S??`Text input`,"aria-multiline":`true`,"aria-disabled":a||void 0,"aria-describedby":z,"data-test-id":C,spellCheck:L,className:W(`prompt-area-editor`,`w-full min-w-0 break-words whitespace-pre-wrap outline-none`,a&&`cursor-not-allowed opacity-50`),style:we,onFocus:ve,onInput:x?be:ie,onKeyDown:Te,onMouseDown:se,onClick:oe,onPaste:fe.onPaste,onCopy:fe.onCopy,onCut:fe.onCut,onDrop:fe.onDrop,onDragOver:fe.onDragOver,onCompositionStart:fe.onCompositionStart,onCompositionEnd:fe.onCompositionEnd,onBlur:Ee}),x&&xe&&!pe&&(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-auto absolute right-0 bottom-0 left-0 cursor-pointer`,style:{height:`32px`},onClick:()=>B.current?.focus(),children:(0,U.jsx)(`div`,{className:`h-full w-full`,style:{background:`linear-gradient(to bottom, transparent, color-mix(in srgb, var(--prompt-area-surface, var(--background)) 80%, transparent), var(--prompt-area-surface, var(--background)))`}})}),De&&r&&(Array.isArray(r)?(0,U.jsx)($D,{texts:r}):(0,U.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-0 select-none`,style:{color:`var(--prompt-area-placeholder, var(--muted-foreground))`},"aria-hidden":`true`,children:r}))]}),A===`below`&&ke,T===`below`&&Oe,V&&V.config.mode===`dropdown`&&(0,U.jsx)(QD,{suggestions:te,loading:ne,error:H,emptyMessage:V.config.emptyMessage,selectedIndex:re,onSelect:ce,onDismiss:le,triggerRect:de,triggerChar:V.config.char})]})}function _O(e={}){let{initialValue:t=[]}=e,[n,r]=(0,v.useState)(t),i=(0,v.useRef)(null),a=(0,v.useMemo)(()=>QT(n),[n]),o=(0,v.useMemo)(()=>n.length===0||n.every(e=>e.type===`text`&&e.text.trim()===``),[n]),s=(0,v.useMemo)(()=>n.some(e=>e.type===`chip`),[n]),c=(0,v.useMemo)(()=>n.filter(e=>e.type===`chip`),[n]);return{bind:(0,v.useMemo)(()=>({ref:i,value:n,onChange:r}),[n]),plainText:a,isEmpty:o,hasChips:s,chips:c,clear:(0,v.useCallback)(()=>{i.current?i.current.clear():r([])},[]),focus:(0,v.useCallback)(()=>i.current?.focus(),[]),blur:(0,v.useCallback)(()=>i.current?.blur(),[]),insertChip:(0,v.useCallback)(e=>i.current?.insertChip(e),[])}}function vO(e={}){let{char:t=`@`,...n}=e;return{char:t,position:`any`,mode:`dropdown`,chipStyle:`pill`,accessibilityLabel:`mention`,...n}}function yO(e={}){let{char:t=`/`,position:n=`any`,...r}=e;return{char:t,position:n,mode:`dropdown`,chipStyle:`inline`,accessibilityLabel:`command`,...r}}function bO(e={}){let{char:t=`#`,...n}=e;return{char:t,position:`any`,mode:`dropdown`,chipStyle:`pill`,resolveOnSpace:!0,accessibilityLabel:`tag`,...n}}function xO(e){let{char:t,...n}=e;return{char:t,position:`start`,mode:`launch`,...n}}var SO=[`attention`,`working`,`idle`,`ended`],CO={attention:`Needs attention`,working:`Working`,idle:`Idle`,ended:`Ended`};function wO(e){return e.pendingPermissionCount>0||e.status===`awaiting_approval`?`attention`:e.status===`failed`||e.status===`closed`?`ended`:e.status===`running`||e.status===`starting`||TO(e).length>0?`working`:`idle`}function TO(e){return(e.subagents??[]).filter(e=>e.status===`running`)}function EO(e,t){if(t===`none`)return[];let n=e.subagents??[];return t===`all`?[...n]:n.filter(e=>e.status!==`done`)}function DO(e){return e.isAgent===!0||(e.agentType?.trim()??``)!==``}function OO(e){let t=e.agentType?.trim(),n=e.description?.trim();return t&&n?`${t} · ${n}`:t||n||`Sub-agent`}var kO={search:``,gateways:[],adapters:[],states:[],projects:[],scoped:!0,groupBy:`state`,sortBy:`recent`,subagents:`active`};function AO(e){return[...new Set(e.map(e=>e.adapter))].sort()}function jO(e){let t=new Map;for(let n of e)t.set(NO(n),PO(n));return[...t].map(([e,t])=>({key:e,label:t})).sort((e,t)=>e.label.toLowerCase().localeCompare(t.label.toLowerCase()))}function MO(e){return e.title??e.id.slice(0,8)}function NO(e){return`${e.hostId}:${BO(e.info.project?.root??e.info.cwd)}`}function PO(e){return e.info.project?.shortcode||FO(e)}function FO(e){let t=e.info.project?.name;if(t)return t;let n=BO(e.info.cwd);return n.slice(n.lastIndexOf(`/`)+1)||`No project`}function IO(e){let t=e.info.project?.root;if(t===void 0||!e.info.cwd)return;let n=BO(t),r=BO(e.info.cwd);if(r!==n&&r.startsWith(`${n}/`))return r.slice(n.length+1)||void 0}function LO(e){return typeof e.meta?.jobId==`string`}function RO(e,t){return(e.shells??[]).filter(e=>e.status===`running`?t-e.startedAt>=Rk:e.endedAt===void 0||typeof e.exitCode!=`number`||e.exitCode===0?!1:e.endedAt-e.startedAt>=3e3&&t-e.endedAt<6e4)}function zO(e,t){return!t||MO(e.info).toLowerCase().includes(t)||e.info.cwd.toLowerCase().includes(t)||(e.info.project?.name.toLowerCase().includes(t)??!1)||(e.info.project?.shortcode?.toLowerCase().includes(t)??!1)||e.hostName.toLowerCase().includes(t)||e.adapter.toLowerCase().includes(t)||e.info.id.startsWith(t)}function BO(e){return e.replace(/\\/g,`/`).replace(/\/+$/,``)}function VO(e,t){let n=BO(e),r=BO(t);return r===n||r.startsWith(`${n}/`)}function HO(e,t){return t.roots.some(t=>(t.hostId?t.hostId.toLowerCase()===e.hostId.toLowerCase():e.local)&&VO(t.path,e.info.cwd))}function UO(e,t){return e.scoped&&t!==void 0}function WO(e,t,n){let r=t.search.trim().toLowerCase(),i=UO(t,n)?n:void 0;return e.filter(e=>(t.gateways.length===0||t.gateways.includes(e.hostId))&&(t.adapters.length===0||t.adapters.includes(e.adapter))&&(t.states.length===0||t.states.includes(e.state))&&(!t.projects?.length||t.projects.includes(NO(e)))&&(!i||HO(e,i))&&zO(e,r))}function GO(e,t){return t===`gateway`?e.hostId:t===`adapter`?e.adapter:t===`project`?NO(e):e.state}function KO(e,t){return t===`gateway`?e.hostName:t===`adapter`?e.adapter:t===`project`?PO(e):CO[e.state]}function qO(e,t){return t===`state`?String(SO.indexOf(e.state)):KO(e,t).toLowerCase()}function JO(e,t){return(t.info.lastActivityAt??t.info.createdAt)-(e.info.lastActivityAt??e.info.createdAt)}function Dee(e,t,n){return n===`recent`?JO(e,t):n===`name`?MO(e.info).localeCompare(MO(t.info),void 0,{sensitivity:`base`})||JO(e,t):qO(e,n).localeCompare(qO(t,n))||JO(e,t)}function Oee(e,t){let n=[...e].sort((e,n)=>Dee(e,n,t.sortBy));if(t.groupBy===`none`)return n.length?[{key:`all`,rows:n}]:[];let r=t.groupBy,i=new Map;for(let e of n){let t=GO(e,r),n=i.get(t);n?n.rows.push(e):i.set(t,{key:t,label:KO(e,r),rank:qO(e,r),rows:[e]})}return[...i.values()].sort((e,t)=>e.rank.localeCompare(t.rank))}function kee(e,t,n,r){if(n>=r)return;let i=[];t&&UO(e,t)&&i.push(t.label);let a=+!!e.gateways.length+ +!!e.adapters.length+ +!!e.states.length+ +!!e.projects?.length;return a>0&&i.push(`${a} filter${a===1?``:`s`}`),e.search.trim()&&i.push(`search`),{shown:n,total:r,causes:i}}function Aee(e){return e.search.trim().length>0||e.gateways.length>0||e.adapters.length>0||e.states.length>0||(e.projects?.length??0)>0}function YO(e){return{...kO,scoped:!1,groupBy:e.groupBy,sortBy:e.sortBy,subagents:e.subagents}}function jee(e){if(typeof e!=`object`||!e)return;let t=e,n=t.status;if(n!==`pending`&&n!==`in_progress`&&n!==`completed`)return;let r=typeof t.content==`string`?t.content.trim():``;if(r===``)return;let i=typeof t.activeForm==`string`?t.activeForm.trim():``;return{status:n,text:n===`in_progress`&&i!==``?i:r}}function Mee(e){let t=e?.todos;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=jee(e);if(t===void 0)return;n.push(t)}return n}function Nee(e){switch(e){case`in_progress`:return`running`;case`completed`:return`done`;default:return`pending`}}function Pee(e){let t=(e.checklist??[]).map((e,t)=>({key:`checklist:${t}`,label:e.text,source:`checklist`,state:Nee(e.status)})),n=(e.subagents??[]).filter(e=>!DO(e)).map(e=>({key:`spawn:${e.toolUseId}`,label:e.description?.trim()||`Task`,source:`spawn`,state:e.status,detail:e.toolCount>0?String(e.toolCount):void 0,toolUseId:e.toolUseId}));return[...t,...n]}function XO(e){let t=0,n=0,r=0;for(let i of e)i.state===`done`?t+=1:i.state===`running`?n+=1:i.state===`failed`&&(r+=1);return{total:e.length,done:t,running:n,failed:r}}function Fee(e){return e.total===0?void 0:`${e.done}/${e.total}`}function Iee(e,t){return t?[...e]:e.filter(e=>e.state!==`done`)}var ZO=`2026-09-23`,QO=`List rates as of ${ZO}. A subscription is a flat fee, so this is what the same tokens would have cost on the pay-as-you-go API, not a bill.`,Lee=.005,$O=1e6,Ree=864e5,ek=[`input`,`output`,`cacheWrite5m`,`cacheWrite1h`,`cacheRead`];function tk(e,t,n){return{input:e,output:t,cacheWrite5m:e*1.25,cacheWrite1h:e*2,cacheRead:n??e*.1}}function nk(e,t,n){return{input:e,output:t,cacheWrite5m:e,cacheWrite1h:e,cacheRead:n}}var rk={"claude-fable-5-1":tk(10,50,.25),"claude-fable-5":tk(10,50),"claude-mythos-5-1":tk(10,50,.25),"claude-mythos-5":tk(10,50),"claude-opus-5-5":tk(4,20,.2),"claude-opus-5":tk(5,25),"claude-opus-4-8":tk(5,25),"claude-opus-4-7":tk(5,25),"claude-opus-4-6":tk(5,25),"claude-opus-4-5":tk(5,25),"claude-sonnet-5":tk(2,10),"claude-sonnet-4-6":tk(3,15),"claude-sonnet-4-5":tk(3,15),"claude-haiku-4-5":tk(1,5),"gpt-6-astra":nk(10,50,1),"gpt-5.6-sol":nk(4,20,.4),"gpt-5.6-terra":nk(2,12,.2),"gpt-5.6-luna":nk(.2,1.2,.02),"gpt-5.5":nk(5,30,.5),"gpt-5.4":nk(2.5,15,.25),"gpt-5.2":nk(1.75,14,.175),"gpt-5.1":nk(1.25,10,.125),"gpt-5":nk(1.25,10,.125)},ik=rk;function ak(e){if(typeof e!=`object`||!e)return;let t=e,n={input:0,output:0,cacheWrite5m:0,cacheWrite1h:0,cacheRead:0};for(let e of ek){let r=t[e];if(typeof r!=`number`||!Number.isFinite(r)||r<0)return;n[e]=r}return n}function ok(e,t=rk){let n={},r=[];if(typeof e==`object`&&e)for(let[t,i]of Object.entries(e)){let e=ak(i),a=uk(t);if(!e||a===``){r.push(t);continue}n[a]=e}return{pricing:{...t,...n},overrides:n,dropped:r}}function sk(){return ik}function ck(e,t=ZO){let n=Date.parse(t);return Number.isFinite(n)?Math.floor((e-n)/Ree):0}function lk(e,t=ZO){let n=ck(e,t);if(!(n<=90))return`This rate table is ${n} days old, so check the vendor's current list prices before you trust the total.`}function uk(e){let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase().replace(/\[[^\]]*\]$/,``).replace(/^(?:[a-z]+\.)*anthropic\./,``).replace(/[@-]\d{8}$/,``).replace(/-v\d+:\d+$/,``)}function dk(e,t=sk()){return e?t[uk(e)]:void 0}function fk(e){return e.input+e.output+e.cacheWrite5m+e.cacheWrite1h+e.cacheRead}function pk(e){return Object.entries(e).filter(([,e])=>e.costBasis===`unknown`).map(([e])=>uk(e))}function mk(e){return{input:0,output:0,cacheWrite:0,cacheRead:0,total:0,unpriced:!0,unpricedTokens:e,unpricedShare:+(e>0)}}function hk(e,t,n=sk()){let r=dk(t,n);if(!r)return mk(fk(e));let i=e.input/$O*r.input,a=e.output/$O*r.output,o=e.cacheWrite5m/$O*r.cacheWrite5m+e.cacheWrite1h/$O*r.cacheWrite1h,s=e.cacheRead/$O*r.cacheRead;return{input:i,output:a,cacheWrite:o,cacheRead:s,total:i+a+o+s,unpriced:!1,unpricedTokens:0,unpricedShare:0}}function gk(e,t=sk()){let n={input:0,output:0,cacheWrite:0,cacheRead:0,total:0,unpriced:!1,unpricedTokens:0,unpricedShare:0},r=Object.entries(e),i=!1,a=0;for(let[e,o]of r){a+=fk(o);let r=hk(o,e,t);if(r.unpriced){n.unpricedTokens+=r.unpricedTokens;continue}i=!0,n.input+=r.input,n.output+=r.output,n.cacheWrite+=r.cacheWrite,n.cacheRead+=r.cacheRead,n.total+=r.total}return n.unpriced=!i&&r.length>0,n.unpricedShare=a>0?n.unpricedTokens/a:0,n}var _k=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`)`,`]`,`}`,`"`,`'`]),vk=/^[\p{L}\p{N}][\p{L}\p{N}\-_]*$/u;function yk(e,t){return(e??``).normalize(`NFKC`).replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/^-+|-+$/g,``)||t.slice(0,8)}function bk(e){return e.normalize(`NFKC`).toLowerCase().replace(/[_\s]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function xk(e){return e.length>0&&e.length<=64&&vk.test(e)}var Sk={fs_read:`Reading a file`,fs_write:`Writing a file`,fs_list:`Listing files`,eval_script:`Running a script`,web_fetch:`Fetching a web page`,web_search:`Searching the web`,deliver_file:`Delivering a file`,download:`Downloading a file`,CodexCommand:`Running a command`,CodexFileChange:`Editing a file`,CodexWebSearch:`Searching the web`,CodexImageGeneration:`Generating an image`,CodexImageView:`Viewing an image`,peers_list:`Listing peer sessions`,peers_peek:`Peeking at a peer session`,peers_send:`Messaging a peer session`,mcp__workerdeck__peers_list:`Listing peer sessions`,mcp__workerdeck__peers_peek:`Peeking at a peer session`,mcp__workerdeck__peers_send:`Messaging a peer session`};function Ck(e,t){return wk(t?.[e]??Sk[e],e)}function wk(e,t){if(typeof e!=`string`)return;let n=[...e].map(e=>e<` `||e===``?` `:e).join(``).replace(/\s+/g,` `).trim();if(n===``||n===t)return;let r=[...n];return r.length>64?r.slice(0,63).join(``)+`…`:n}var Tk=[`peers_send`,`mcp__workerdeck__peers_send`];function Ek(e){return Tk.includes(e)}function Dk(e,t){let n={};for(let[t,r]of Object.entries(e.rateLimits??{}))n[t]={info:r,updatedAt:e.updatedAt??0};for(let[e,r]of Object.entries(t??{}))n[e]=r;return n}var Ok=9e5;function kk(e,t){return e.inferredReset||e.updatedAt===void 0?!1:t-e.updatedAt>Ok}function Ak(e){let t=Object.entries(e??{}).filter(([,e])=>e.info.utilization!==void 0).map(([e,t])=>({key:e,info:t.info,updatedAt:t.updatedAt,inferredReset:t.inferredReset})),n=[`five_hour`,`seven_day`].flatMap(e=>t.filter(t=>t.key===e)),r=t.filter(e=>e.key.startsWith(`seven_day_`)).sort((e,t)=>e.key.localeCompare(t.key));return[...n,...r]}function jk(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))t[n]=r.info;return t}var Mk=2592e6,Nk=6e4;function Pk(e,t){return`${e}:${t}`}var Fk=class{#e;#t;constructor(e){this.#e=e,this.#t={...e.read()}}get(e,t){return this.#t[Pk(e,t)]}all(){return this.#t}mark(e,t,n,r=Date.now()){let i=Pk(e,t),a=this.#t[i],o={itemCount:Math.max(a?.itemCount??0,n.itemCount??0),activity:Math.max(a?.activity??0,n.activity??0),prose:n.prose===void 0?a?.prose:Math.max(a?.prose??0,n.prose),turns:Math.max(a?.turns??0,n.turns??0),seenAt:r};return a&&a.itemCount===o.itemCount&&a.activity===o.activity&&a.prose===o.prose&&a.turns===o.turns&&o.seenAt-a.seenAt<Nk?!1:(this.#t[i]=o,this.#e.write(this.#n(r)),!0)}forget(e,t){let n=Pk(e,t);n in this.#t&&(delete this.#t[n],this.#e.write(this.#t))}#n(e){let t=e-Mk;for(let[e,n]of Object.entries(this.#t))n.seenAt<t&&delete this.#t[e];return this.#t}};function Ik(e,t){return e?t.proseCount===void 0?t.activityCount===void 0?Math.max(0,(t.turns??0)-e.turns):Math.max(0,t.activityCount-e.activity):Math.max(0,t.proseCount-(e.prose??t.proseCount)):0}function Lk(e){return(Array.isArray(e.questions)?e.questions:[]).flatMap(e=>{let t=e;if(typeof t.question!=`string`||!Array.isArray(t.options))return[];let n=t.options.filter(e=>typeof e?.label==`string`);return n.length===0?[]:[{question:t.question,header:typeof t.header==`string`?t.header:``,options:n,multiSelect:t.multiSelect===!0}]})}var Rk=3e3,zk={claude:{interactiveApprovals:!0,permissionModes:[`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`],defaultPermissionMode:`default`,resume:!0,resumeBackfill:!0,listSessions:!0,contextUsage:!0,rateLimits:!0,mcpStatus:!0,mcpServerActions:!0,sessionMcpServers:!0,slashCommands:!0,clearContext:!0,skillsList:!1,settingSources:!0,budgets:!0,attachments:[`image`,`pdf`,`text`],reasoningEfforts:[`low`,`medium`,`high`,`xhigh`,`max`],vfs:!1,hostCwd:!0,systemInstructions:!0,streaming:`token`},codex:{interactiveApprovals:!0,permissionModes:[`default`,`acceptEdits`,`bypassPermissions`,`auto`],defaultPermissionMode:`default`,resume:!0,resumeBackfill:!0,listSessions:!0,contextUsage:!0,rateLimits:!0,mcpStatus:!0,mcpServerActions:!1,sessionMcpServers:!1,slashCommands:!1,clearContext:!0,skillsList:!0,settingSources:!1,budgets:!1,attachments:[`image`,`text`],reasoningEfforts:[`minimal`,`low`,`medium`,`high`,`xhigh`],vfs:!1,hostCwd:!0,systemInstructions:!0,streaming:`token`},provider:{interactiveApprovals:!1,permissionModes:[`default`,`bypassPermissions`,`dontAsk`],defaultPermissionMode:`default`,resume:!1,resumeBackfill:!1,listSessions:!1,contextUsage:!1,rateLimits:!1,mcpStatus:!0,mcpServerActions:!1,sessionMcpServers:!1,slashCommands:!1,clearContext:!0,skillsList:!1,settingSources:!1,budgets:!1,attachments:[`image`,`pdf`,`text`],vfs:!0,hostCwd:!1,systemInstructions:!0,streaming:`token`}};function Bk(e){let t=/^Delivered to (.+) \(([^()]+)\);/.exec(e);if(t)return{sessionId:t[2],name:t[1]};let n=/^Delivered to ([^()\s]+);/.exec(e);return n?{sessionId:n[1]}:void 0}var Vk={status:`starting`,capabilities:zk.claude,items:[],pendingApprovals:[],totalCostUsd:0,lastSeq:0},Hk=`streaming`,Uk=`streaming-thinking`,Wk=/^<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>$/,Gk=/<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>/g,Kk=`<local-command-caveat>`,qk=/^\[\.\.\. more output \.\.\.\]$/,Jk=/^\[(exit -?\d+|killed|timed out|ended|failed to start)[^\]]*\]$/;function Yk(e,t){let n=(Wk.exec(t.trim())?.[2]??t).split(`
|
|
45
45
|
`);n[0]?.startsWith(`$ `)&&n.shift(),e.status===`exited`&&n.length>0&&Jk.test(n[n.length-1])&&n.pop();let r=!1;return{text:n.filter(e=>!qk.test(e)||(r=!0,!1)).join(`
|
|
46
46
|
`).trimEnd(),truncated:r}}function Xk(e,t,n,r){let i=Yk(t,n);return{kind:`shell`,id:e,shell:t,text:i.text,truncated:i.truncated,...r?.expanded!==void 0&&{expanded:r.expanded}}}function Zk(e,t){return e.find(e=>e.kind===`shell`&&e.shell.id===t)}var Qk=/<command-name>([\s\S]*?)<\/command-name>/,$k=/<command-args>([\s\S]*?)<\/command-args>/;function eA(e){return oA(e).some(e=>e.type===`text`&&e.text.trimStart().startsWith(Kk))}function tA(e){return e==null?Hk:`${Hk}:${e}`}function nA(e){return e==null?Uk:`${Uk}:${e}`}function rA(e){return e.kind===`assistant_text`&&e.id.startsWith(Hk)||e.kind===`thinking`&&e.id.startsWith(Uk)}function iA(e){return e===void 0?``:typeof e==`string`?e:e.map(e=>typeof e.text==`string`?e.text:``).filter(Boolean).join(`
|
|
47
47
|
`)}function aA(e,t){if(!Array.isArray(e))return;let n=e.flatMap(e=>e.type===`image_ref`?[{partIndex:Number(e.part_index),mediaType:String(e.media_type??`application/octet-stream`),bytes:Number(e.bytes??0),sourceSeq:t}]:[]);return n.length>0?n:void 0}function oA(e){return typeof e==`string`?[{type:`text`,text:e}]:e}function sA(e){if(e.type===`text`)return e.value;try{return JSON.stringify(e.value)}catch{return String(e.value)}}function cA(e){let t=Qk.exec(e)?.[1]?.trim();if(!t)return;let n=$k.exec(e)?.[1]?.trim();return n?`${t} ${n}`:t}function lA(e,t){let n=e.findIndex(e=>e.id===t.id&&e.kind===t.kind);if(n===-1)return[...e,t];let r=[...e];return r[n]=t,r}function uA(e,t){let n=t.engine??e.engine;return{...e,status:e.lastSeq===0?t.status:e.status,model:e.model??t.model,permissionMode:e.permissionMode??t.permissionMode,cwd:e.cwd??t.cwd,sdkSessionId:e.sdkSessionId??t.sdkSessionId,engine:n,capabilities:t.capabilities??zk[n??`claude`],totalCostUsd:e.totalCostUsd||(t.totalCostUsd??0),costUsd:e.costUsd??t.costUsd,usageByModel:e.usageByModel??t.usageByModel,session:t}}function dA(e,t,n){let r=!1,i=e.items.map(e=>e.kind!==`tool_call`||e.id!==t||!e.result?.truncated?e:(r=!0,{...e,result:{text:n,isError:e.result.isError,...e.result.images&&{images:e.result.images}}}));return r?{...e,items:i}:e}function fA(e,t,n){let r=Zk(e.items,t);if(!r)return e;let i=n===void 0?{...r,missing:!0}:{...r,shell:n,missing:void 0};return{...e,items:e.items.map(e=>e===r?i:e)}}function pA(e,t,n){let r=Zk(e.items,t);return r?{...e,items:e.items.map(e=>e===r?{...r,expanded:n,missing:void 0}:e)}:e}function mA(e,t){if(t.seq<=e.lastSeq)return e;let n={...e,lastSeq:t.seq};switch(t.type){case`system_init`:return{...n,model:t.model,cwd:t.cwd,sdkSessionId:t.sdkSessionId,permissionMode:t.permissionMode};case`status_changed`:return{...n,status:t.status,statusDetail:t.detail};case`capabilities`:return{...n,models:t.models,commands:t.commands,defaultModel:t.defaultModel??n.defaultModel};case`skills`:return{...n,skills:t.skills};case`checklist`:return{...n,checklist:t.items.length>0?t.items:void 0};case`tool_titles`:return{...n,toolTitles:{...n.toolTitles,...t.titles}};case`file_produced`:return{...n,producedFiles:{...n.producedFiles,[t.path]:{fileId:t.fileId,...t.mediaType?{mediaType:t.mediaType}:{},...t.bytes===void 0?{}:{bytes:t.bytes}}}};case`model_changed`:return t.model===void 0?n:{...n,model:t.model};case`permission_mode_changed`:return{...n,permissionMode:t.mode};case`context_usage`:return{...n,contextUsage:t.usage};case`rate_limit`:{let e=t.info.rateLimitType;return e?{...n,rateLimits:{...n.rateLimits,[e]:t.info},rateLimitsUpdatedAt:t.ts}:n}case`plan_info`:return{...n,subscriptionType:t.subscriptionType};case`conversation_reset`:return{...n,items:[],contextUsage:void 0,checklist:void 0,sdkSessionId:t.sdkSessionId??n.sdkSessionId};case`context_compacted`:return{...n,items:lA(n.items,{kind:`compaction`,id:t.uuid,parentToolUseId:t.parentToolUseId??null,pending:t.pending,trigger:t.trigger,preTokens:t.preTokens,postTokens:t.postTokens,error:t.error})};case`user_message`:{let e=n.items;for(let n of oA(t.message.content))if(n.type===`tool_result`){let r=n,i=r.is_error===!0;e=e.map(e=>e.kind===`tool_call`&&e.id===r.tool_use_id?{...e,status:i?`failed`:`settled`,result:{text:iA(r.content),isError:i,...r.truncated&&{truncated:!0,totalChars:r.total_chars,sourceSeq:t.seq},...aA(r.content,t.seq)&&{images:aA(r.content,t.seq)}},...t.patch&&{patch:t.patch}}:e)}else if(n.type===`text`){let r=n.text,i=t.uuid??`user-${t.seq}`,a=Wk.exec(r.trim());if(t.shell){let n=e.find(e=>e.kind===`shell`&&e.id===i);e=lA(e,Xk(i,t.shell,r,n))}else if(a)e=lA(e,{kind:`notice`,id:i,level:a[1]===`stderr`?`error`:`info`,text:a[2].trim()});else if(r.trimStart().startsWith(Kk)){let t=0;for(let n of r.matchAll(Gk))e=lA(e,{kind:`notice`,id:`${i}#${t++}`,level:n[1]===`stderr`?`error`:`info`,text:n[2].trim()})}else(!t.synthetic||eA(t.message.content))&&(e=lA(e,{kind:`user`,id:t.uuid??`user-${t.seq}`,text:cA(r)??r,attachments:t.attachments,...t.origin&&{origin:t.origin},...t.parentToolUseId!=null&&{parentToolUseId:t.parentToolUseId}}))}return{...n,items:e}}case`assistant_message`:{let e=tA(t.parentToolUseId),r=nA(t.parentToolUseId),i=n.items.find(e=>e.kind===`thinking`&&e.id===r)?.text??``,a=n.items.filter(t=>(t.kind!==`assistant_text`||t.id!==e)&&(t.kind!==`thinking`||t.id!==r));return oA(t.message.content).forEach((e,n)=>{let r=`${t.uuid}-${n}`;if(e.type===`text`)a=lA(a,{kind:`assistant_text`,id:r,text:e.text,streaming:!1,parentToolUseId:t.parentToolUseId});else if(e.type===`thinking`){let n=e.thinking||i;if(i=``,n.trim()===``)return;a=lA(a,{kind:`thinking`,id:r,text:n,parentToolUseId:t.parentToolUseId})}else if(e.type===`tool_use`){let n=e;a=lA(a,{kind:`tool_call`,id:n.id,name:n.name,input:n.input,parentToolUseId:t.parentToolUseId,status:`running`,ts:t.ts})}}),{...n,items:a}}case`stream_delta`:{let e=t.event;if(e.type!==`content_block_delta`)return n;if(e.delta?.type===`text_delta`){let r=tA(t.parentToolUseId),i={kind:`assistant_text`,id:r,text:(n.items.find(e=>e.kind===`assistant_text`&&e.id===r)?.text??``)+(e.delta.text??``),streaming:!0,parentToolUseId:t.parentToolUseId};return{...n,items:lA(n.items,i)}}if(e.delta?.type===`thinking_delta`){let r=nA(t.parentToolUseId),i=(n.items.find(e=>e.kind===`thinking`&&e.id===r)?.text??``)+(e.delta.thinking??``);if(i.trim()===``)return n;let a={kind:`thinking`,id:r,text:i,parentToolUseId:t.parentToolUseId};return{...n,items:lA(n.items,a)}}return n}case`turn_result`:return{...n,totalCostUsd:t.totalCostUsd,costUsd:t.costUsd??n.costUsd,usageByModel:t.usageByModel??n.usageByModel,items:[...n.items.map(e=>{if(!rA(e))return e;let n=`parentToolUseId`in e&&e.parentToolUseId?`-${e.parentToolUseId}`:``;return e.kind===`assistant_text`?{...e,id:`text-${t.seq}${n}`,streaming:!1}:{...e,id:`thinking-${t.seq}${n}`}}),{kind:`turn_result`,id:`turn-${t.seq}`,subtype:t.subtype,isError:t.isError,durationMs:t.durationMs,totalCostUsd:t.totalCostUsd,costUsd:t.costUsd,errors:t.errors}]};case`permission_requested`:return{...n,pendingApprovals:[...n.pendingApprovals,t.request]};case`permission_resolved`:return{...n,pendingApprovals:n.pendingApprovals.filter(e=>e.id!==t.requestId)};case`execution_dispatched`:return{...n,items:n.items.map(e=>e.kind===`tool_call`&&e.id===t.executionId?{...e,status:t.deferred?`deferred`:`pending`,executionId:t.executionId,backend:t.backend}:e)};case`execution_result`:return{...n,items:n.items.map(e=>e.kind===`tool_call`&&e.id===t.executionId?{...e,status:`settled`,executionId:t.executionId,result:{text:sA(t.output),isError:!1},logs:t.logs??e.logs}:e)};case`execution_failed`:return{...n,items:n.items.map(e=>e.kind===`tool_call`&&e.id===t.executionId?{...e,status:`failed`,executionId:t.executionId,result:{text:`${t.reason}: ${t.error}`,isError:!0},logs:t.logs??e.logs}:e)};case`file_delivered`:return{...n,items:[...n.items,{kind:`file_delivered`,id:`file-${t.seq}`,path:t.path,bytes:t.bytes,description:t.description}]};case`session_error`:return{...n,items:[...n.items,{kind:`notice`,id:`err-${t.seq}`,level:`error`,text:t.message}]};case`session_closed`:return{...n,items:[...n.items,{kind:`notice`,id:`closed-${t.seq}`,level:`info`,text:`Session closed (${t.reason})`}]};default:return n}}var hA=5,gA=new Map;function _A(e,t){return`${e.identityKey}\u0000${t}`}function vA(e){return gA.get(e)}function yA(e,t){if(gA.delete(e),gA.set(e,t),gA.size>hA){let e=gA.keys().next().value;e!==void 0&&gA.delete(e)}}function bA(e){gA.delete(e)}function xA(e,t){return`${e}:${t}`}function SA(e){let t=xA(e.resyncSeq,e.key),n=e.cacheEnabled&&!e.skipCache?e.warm:void 0,r=e.seededFor!==t,i=r?n??Vk:e.current;return{held:i,seed:r,seedToken:t,...i.lastSeq>0?{afterSeq:i.lastSeq}:{}}}function CA(e){return e.cacheEnabled&&!e.skipCache&&e.parting.lastSeq>0&&e.parting.session!==void 0}function wA(e,t){return t.type===`transcript_seed`?t.state:t.type===`transcript_hydrate_result`?dA(e,t.toolUseId,t.text):t.type===`transcript_hydrate_shell`?fA(e,t.shellId,t.shell):t.type===`transcript_hydrate_shell_output`?pA(e,t.shellId,t.text):t.type===`attached`?uA(e,t.session):mA(e,t)}var TA=3;function EA(e){return e.replayingFrom===0&&e.session.lastSeq>0?e.session.lastSeq:void 0}function DA(e,t){return e.replayingFrom===0||t.lastSeq===0?!1:e.session.lastSeq<t.lastSeq||t.session!==void 0&&e.session.createdAt!==t.session.createdAt}var OA=1500;function kA(e,t,n){let[r,i]=(0,v.useReducer)(wA,void 0,()=>(n?.cacheTranscript!==!1&&t!==void 0?vA(_A(e,t)):void 0)??Vk),[a,o]=(0,v.useState)(`reconnecting`),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(rk),[p,m]=(0,v.useState)(),[h,g]=(0,v.useState)(0),[_,y]=(0,v.useState)(),b=(0,v.useRef)(null),x=(0,v.useRef)(n);x.current=n;let S=(0,v.useRef)(r);S.current=r;let C=(0,v.useRef)(xA(0,t===void 0?``:_A(e,t))),w=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!t)return;let n=x.current?.cacheTranscript!==!1,r=_A(e,t),a=SA({resyncSeq:h,key:r,seededFor:C.current,current:S.current,cacheEnabled:n,skipCache:w.current,warm:vA(r)});w.current=!1,a.seed&&(i({type:`transcript_seed`,state:a.held}),C.current=a.seedToken);let s=e.attach(t,{truncateResults:!0,imageRefs:!0,...a.afterSeq===void 0?{}:{afterSeq:a.afterSeq}});b.current=s,y(s);let l=s.on(`event`,e=>i(e)),d=s.on(`attached`,e=>{if(DA(e,S.current)){l(),bA(r),w.current=!0,g(e=>e+1);return}i(e),m(EA(e)),c(e.protocolVersion===1?void 0:e.protocolVersion),u(e.shell===!0),f(ok(e.pricingOverrides).pricing)}),p=s.on(`connectionChange`,e=>o(e?`live`:`reconnecting`)),_=s.on(`reconnectAttempt`,e=>o(e>=TA?`offline`:`reconnecting`)),v=s.on(`protocolError`,e=>{x.current?.onProtocolError?.(e)});return()=>{l(),d(),p(),_(),v(),s.detach(),b.current=null,y(void 0),o(`reconnecting`),c(void 0),u(!1),m(void 0);let e=S.current;CA({cacheEnabled:n,skipCache:w.current,parting:e})&&yA(r,e)}},[e,t,h]),(0,v.useEffect)(()=>{if(p===void 0)return;let e=setTimeout(()=>m(void 0),OA);return()=>clearTimeout(e)},[p]),(0,v.useEffect)(()=>{p!==void 0&&r.lastSeq>=p&&m(void 0)},[p,r.lastSeq]);let T=AA(e,t,r),E=a===`live`,D=p!==void 0&&r.lastSeq<p,O=(0,v.useCallback)(()=>b.current?.reconnectNow(),[]),k=(0,v.useCallback)(async n=>{if(!t)return!1;let r=S.current.items.find(e=>e.kind===`tool_call`&&e.id===n),a=r?.kind===`tool_call`?r.result:void 0;if(!a?.truncated||a.sourceSeq===void 0)return!1;try{let r=await e.toolResult(t,a.sourceSeq,n);return i({type:`transcript_hydrate_result`,toolUseId:n,text:iA(r.content)}),!0}catch{return!1}},[e,t]),A=(0,v.useRef)(new Set);(0,v.useEffect)(()=>{A.current=new Set},[t]);let j=(0,v.useCallback)(async n=>{if(!t)return!1;try{let r=await e.shellOutput(t,n,{view:`text`});return i({type:`transcript_hydrate_shell_output`,shellId:n,text:r}),!0}catch{return i({type:`transcript_hydrate_shell`,shellId:n,shell:void 0}),!1}},[e,t]),M=(0,v.useCallback)(async n=>{if(!t||A.current.has(n))return!1;A.current.add(n);try{let r=await e.getShell(t,n);return i({type:`transcript_hydrate_shell`,shellId:n,shell:r}),!0}catch{return i({type:`transcript_hydrate_shell`,shellId:n,shell:void 0}),!1}},[e,t]),N=(0,v.useCallback)(async n=>{if(!t)return!1;try{let r=await e.killShell(t,n);return i({type:`transcript_hydrate_shell`,shellId:n,shell:r}),!0}catch{return!1}},[e,t]);return(0,v.useMemo)(()=>({state:r,connected:E,connection:a,replaying:D,protocolMismatch:s,shell:l,pricing:d,models:T,effectiveModel:r.model??r.defaultModel,handle:_,send:(e,t)=>b.current?.send(e,t),approve:(e,t)=>b.current?.approve(e,t),deny:(e,t,n)=>b.current?.deny(e,t,n),interrupt:()=>b.current?.interrupt(),clearContext:()=>b.current?.clearContext(),runShell:e=>b.current?.runShell(e),setPermissionMode:e=>b.current?.setPermissionMode(e),setModel:e=>b.current?.setModel(e),closeSession:()=>b.current?.closeSession(),reconnectNow:O,loadFullResult:k,loadShellOutput:j,verifyShell:M,killShell:N}),[r,E,a,D,s,l,d,T,_,O,k,j,M,N])}function AA(e,t,n){let[r,i]=(0,v.useState)([]),a=n.session?.profile,o=n.models,s=!!o?.length;return(0,v.useEffect)(()=>i([]),[t]),(0,v.useEffect)(()=>{if(!a||s)return;let t=!1;return e.listProfiles().then(e=>{t||i(e.profiles.find(e=>e.name===a)?.models??[])}).catch(()=>{}),()=>{t=!0}},[e,a,s]),s?o:r}var jA=new Map;function MA(e,t){return`${e.identityKey}\u0000${t}`}function NA(e){return jA.get(e)}function PA(e,t){t!==void 0&&jA.set(e,t)}var FA=`workerdeck.drafts.v1`,IA=20,LA;function RA(){try{return globalThis.localStorage}catch{return}}function zA(){if(LA)return LA;LA={};let e=RA()?.getItem(FA);if(e)try{let t=JSON.parse(e);for(let[e,n]of Object.entries(t))typeof n?.text==`string`&&typeof n.savedAt==`number`&&(LA[e]=n)}catch{}return LA}function BA(e){let t=Object.entries(e);if(t.length>IA){t.sort((e,t)=>t[1].savedAt-e[1].savedAt);for(let[n]of t.slice(IA))delete e[n]}try{RA()?.setItem(FA,JSON.stringify(e))}catch{}}function VA(e,t){return`${e.identityKey}\u0000${t}`}function HA(e){return zA()[e]?.text??``}function UA(e,t,n=Date.now()){let r=zA();if(t.trim()===``){if(r[e]===void 0)return;delete r[e]}else r[e]={text:t,savedAt:n};BA(r)}var WA=new Set([`application/json`,`application/xml`,`application/yaml`,`application/x-yaml`,`application/toml`,`application/javascript`,`application/typescript`,`application/x-sh`,`application/sql`]),GA=1568;function KA(e){let t=e.split(`;`)[0].trim().toLowerCase();if(t.startsWith(`image/`))return`image`;if(t===`application/pdf`)return`pdf`;if(t.startsWith(`text/`)||WA.has(t))return`text`}function qA(e,t,{capabilities:n,engine:r}){let[i,a]=(0,v.useState)([]),[o,s]=(0,v.useState)(),c=(0,v.useRef)(0),l=(0,v.useRef)(new Map),u=(0,v.useRef)([]);u.current=i.flatMap(e=>e.previewUrl?[e.previewUrl]:[]);let d=n.attachments;(0,v.useEffect)(()=>()=>{for(let e of u.current)URL.revokeObjectURL(e)},[]);let f=(0,v.useCallback)((e,t)=>{a(n=>n.map(n=>n.key===e?{...n,...t}:n))},[]),p=(0,v.useCallback)((n,r)=>{t&&(f(n,{status:`uploading`,error:void 0}),(async()=>{try{let i=await XA(r),a=await e.uploadAttachment(t,{name:r.name,mediaType:i.mediaType,data:i.body});f(n,{status:`ready`,id:a.id,bytes:a.bytes??r.size})}catch(e){f(n,{status:`failed`,error:e instanceof Error?e.message:`Upload failed`})}})())},[e,f,t]),m=(0,v.useCallback)(e=>{let t=[],n=[];for(let i of e){let e=i.type||`application/octet-stream`,a=KA(e);if(a&&!d.includes(a)){s(`The ${r??`claude`} engine does not take ${a} attachments.`);continue}let o=`att-${++c.current}`;t.push({key:o,name:i.name,mediaType:e,bytes:i.size,previewUrl:a===`image`?URL.createObjectURL(i):void 0,status:`uploading`}),n.push({key:o,file:i})}if(t.length!==0){a(e=>[...e,...t]),l.current=new Map([...l.current,...n.map(({key:e,file:t})=>[e,t])]);for(let{key:e,file:t}of n)p(e,t)}},[d,r,p]),h=(0,v.useCallback)(e=>{a(t=>{for(let n of t)e.includes(n.key)&&n.previewUrl&&URL.revokeObjectURL(n.previewUrl);return t.filter(t=>!e.includes(t.key))});for(let t of e)l.current.delete(t)},[]),g=(0,v.useCallback)(e=>h([e]),[h]),_=(0,v.useCallback)(()=>{a(e=>{for(let t of e)t.previewUrl&&URL.revokeObjectURL(t.previewUrl);return[]}),l.current.clear()},[]),y=(0,v.useCallback)(e=>{let t=l.current.get(e);t&&p(e,t)},[p]);return(0,v.useMemo)(()=>({items:i,readyIds:i.flatMap(e=>e.id?[e.id]:[]),uploading:i.some(e=>e.status===`uploading`),hasFailure:i.some(e=>e.status===`failed`),accept:JA(d),disabled:d.length===0||!t,add:m,retry:y,remove:g,clear:_,error:o,dismissError:()=>s(void 0)}),[i,d,t,m,y,g,_,o])}function JA(e){if(e.length===0)return``;let t=[];return e.includes(`image`)&&t.push(`image/*`),e.includes(`pdf`)&&t.push(`application/pdf`),e.includes(`text`)&&t.push(`text/*`,`.md`,`.json`,`.yaml`,`.yml`,`.toml`),e.length===3?``:t.join(`,`)}var YA=globalThis;async function XA(e){let t=e.type||`application/octet-stream`,{createImageBitmap:n,document:r}=YA;if(!n||!r||!t.startsWith(`image/`)||t===`image/gif`)return{body:e,mediaType:t};try{let i=await n(e),a=Math.max(i.width,i.height);if(a<=GA)return i.close(),{body:e,mediaType:t};let o=GA/a,s=r.createElement(`canvas`);s.width=Math.round(i.width*o),s.height=Math.round(i.height*o);let c=s.getContext(`2d`);if(!c)return i.close(),{body:e,mediaType:t};c.drawImage(i,0,0,s.width,s.height),i.close();let l=await new Promise(e=>s.toBlob(e,`image/jpeg`,.85));return l?{body:l,mediaType:`image/jpeg`}:{body:e,mediaType:t}}catch{return{body:e,mediaType:t}}}var ZA=/^[A-Za-z0-9\-_.:]+$/,QA=_k;function $A(e,t){let n=[],r=t?.skills?.length?new Set(t.skills):void 0,i=t?.sessions?.length?new Set(t.sessions):void 0,a=/\S+/g,o;for(;(o=a.exec(e))!==null;){let t=o[0],a=t[0]===`@`?`file`:t[0]===`/`?`command`:t[0]===`$`&&r?`skill`:t[0]===`#`&&i?`session`:void 0;if(!a)continue;let s=o.index+t.length;for(;s>o.index&&QA.has(e[s-1]);)s--;let c=e.slice(o.index+1,s);c&&(a!==`command`||ZA.test(c))&&(a!==`skill`||r.has(c))&&(a!==`session`||xk(c)&&i.has(bk(c)))&&n.push({kind:a,start:o.index,end:s,text:e.slice(o.index,s)})}return n}var ej=class{#e=new Map;on(e,t){let n=this.#e.get(e);return n||(n=new Set,this.#e.set(e,n)),n.add(t),()=>n.delete(t)}emit(e,t){let n=this.#e.get(e);if(n)for(let e of n)try{e(t)}catch{}}};function tj(e){return Math.min(500*2**e,1e4)}var nj=class{sessionId;#e;#t;#n;#r=new ej;#i;#a=!1;#o=0;#s=[];#c;constructor(e,t,n={}){this.#e=e,this.sessionId=t,this.#t={reconnect:!0,...n},this.#i=n.afterSeq??0,this.#c=setTimeout(()=>this.#u(),0)}get lastSeq(){return this.#i}on(e,t){return this.#r.on(e,t)}send(e,t){this.#l({type:`user_message`,text:e,attachmentIds:t?.length?t:void 0})}approve(e,t){this.#l({type:`permission_decision`,requestId:e,behavior:`allow`,updatedInput:t})}deny(e,t,n){this.#l({type:`permission_decision`,requestId:e,behavior:`deny`,message:t,interrupt:n})}interrupt(){this.#l({type:`interrupt`})}runShell(e){this.#l({type:`shell_command`,command:e})}attachShell(e,t){this.#l({type:`shell_attach`,shellId:e,cols:t.cols,rows:t.rows})}writeShell(e,t){this.#l({type:`shell_input`,shellId:e,data:t})}resizeShell(e,t){this.#l({type:`shell_resize`,shellId:e,cols:t.cols,rows:t.rows})}detachShell(e){this.#l({type:`shell_detach`,shellId:e})}clearContext(){this.#l({type:`clear_context`})}setPermissionMode(e){this.#l({type:`set_permission_mode`,mode:e})}setModel(e){this.#l({type:`set_model`,model:e})}sendToolCallResult(e,t,n){this.#l({type:`tool_call_result`,executionId:e,output:t,logs:n})}sendToolCallError(e,t,n,r){this.#l({type:`tool_call_error`,executionId:e,reason:t,error:n,logs:r})}closeSession(){this.#l({type:`close`}),this.detach()}reconnectNow(){this.#a||this.#n&&this.#n.readyState===1||(clearTimeout(this.#c),this.#o=0,this.#u())}detach(){this.#a=!0,clearTimeout(this.#c),this.#n?.close(),this.#n=void 0}#l(e){let t=JSON.stringify(e);this.#n&&this.#n.readyState===1?this.#n.send(t):this.#s.push(t)}#u(){if(this.#a)return;let e=this.#e.openSocket(this.sessionId,this.#i,this.#t.truncateResults,this.#t.imageRefs);this.#n=e,e.onopen=()=>{this.#o=0,this.#r.emit(`connectionChange`,!0);for(let t of this.#s.splice(0))e.send(t)},e.onmessage=e=>{let t=JSON.parse(String(e.data));if(t.type===`attached`)this.#r.emit(`attached`,t);else if(t.type===`event`){if(t.event.seq<=this.#i)return;this.#i=t.event.seq,this.#r.emit(`event`,t.event)}else t.type===`tool_call_request`?this.#r.emit(`toolCallRequest`,t):t.type===`tool_call_canceled`?this.#r.emit(`toolCallCanceled`,{executionId:t.executionId,reason:t.reason}):t.type===`shell_attached`?this.#r.emit(`shellAttached`,{shellId:t.shellId,shell:t.shell,cols:t.cols,rows:t.rows,scrollback:t.scrollback}):t.type===`shell_output`?this.#r.emit(`shellOutput`,{shellId:t.shellId,data:t.data}):t.type===`shell_detached`?this.#r.emit(`shellDetached`,{shellId:t.shellId,reason:t.reason}):t.type===`protocol_error`&&this.#r.emit(`protocolError`,t.message)},e.onclose=()=>{if(this.#r.emit(`connectionChange`,!1),this.#a||!this.#t.reconnect)return;let e=tj(this.#o++);this.#r.emit(`reconnectAttempt`,this.#o),this.#c=setTimeout(()=>this.#u(),e)},e.onerror=()=>{}}},rj=class{#e;#t;#n;#r=new ej;#i=!1;#a=0;#o;constructor(e,t={}){this.#e=e,this.#t=t.reconnect??!0,this.#o=setTimeout(()=>this.#s(),0)}on(e,t){return this.#r.on(e,t)}detach(){this.#i=!0,clearTimeout(this.#o),this.#n?.close(),this.#n=void 0}#s(){if(this.#i)return;let e=this.#e.openQueueSocket();this.#n=e,e.onopen=()=>{this.#a=0,this.#r.emit(`connectionChange`,!0)},e.onmessage=e=>{let t=JSON.parse(String(e.data));t.type===`queue_attached`?(this.#r.emit(`attached`,t.stats),this.#r.emit(`stats`,t.stats)):t.type===`job_event`?this.#r.emit(`event`,t.event):t.type===`queue_stats`&&this.#r.emit(`stats`,t.stats)},e.onclose=()=>{if(this.#r.emit(`connectionChange`,!1),this.#i||!this.#t)return;let e=tj(this.#a++);this.#o=setTimeout(()=>this.#s(),e)},e.onerror=()=>{}}};function ij(e){let t=e.baseUrl.trim();for(;t.endsWith(`/`);)t=t.slice(0,-1);if(t!==``){t.includes(`://`)||(t=`http://`+t),t.endsWith(`/v1`)||(t+=`/v1`);try{new URL(t)}catch{return}return t}}function aj(e){let t=ij(e);if(!t)return!1;try{let{hostname:e}=new URL(t);return e===`127.0.0.1`||e===`localhost`||e===`::1`||e===`[::1]`}catch{return!1}}function oj(e){let{baseUrl:t,key:n}=e;if(n===``)return{};let r=t.replace(/^http/,`ws`),i=e=>`${e}${e.includes(`?`)?`&`:`?`}key=${encodeURIComponent(n)}`;return{headers:{authorization:`Bearer ${n}`},buildWsUrl:(e,t)=>i(`${r}/sessions/${encodeURIComponent(e)}/ws?afterSeq=${t}`),buildQueueWsUrl:()=>i(`${r}/queue/ws`)}}var sj=class extends Error{status;constructor(e,t){super(e),this.name=`WorkerDeckError`,this.status=t}},cj=class{#e;#t;#n;constructor(e){this.#e=e,this.#t=e.fetchImpl??fetch.bind(globalThis),this.#n=e.WebSocketImpl??WebSocket}get identityKey(){let e=Object.entries(this.#e.headers??{}).map(([e,t])=>[e.toLowerCase(),t]);return e.sort(([e],[t])=>e<t?-1:+(e>t)),JSON.stringify([this.#e.baseUrl,e])}async createSession(e){return(await this.#i(`POST`,`/sessions`,e)).session}async listSessions(){return(await this.#i(`GET`,`/sessions`)).sessions}async getSession(e){return(await this.#i(`GET`,`/sessions/${encodeURIComponent(e)}`)).session}async updateSession(e,t){return(await this.#i(`PATCH`,`/sessions/${encodeURIComponent(e)}`,t)).session}async deleteSession(e){return(await this.#i(`DELETE`,`/sessions/${encodeURIComponent(e)}`)).session}async listSessionFiles(e){return(await this.#i(`GET`,`/sessions/${encodeURIComponent(e)}/files`)).files}async fetchSessionFile(e,t){return await(await this.#r(this.sessionFileUrl(e,t),{headers:this.#e.headers},`GET file failed`)).text()}async uploadAttachment(e,t){let n=`${this.#e.baseUrl}/sessions/${encodeURIComponent(e)}/attachments?name=${encodeURIComponent(t.name)}`;return(await(await this.#r(n,{method:`POST`,headers:{...this.#e.headers,"content-type":t.mediaType},body:t.data},`upload failed`)).json()).attachment}attachmentUrl(e,t){return`${this.#e.baseUrl}/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}`}producedFileUrl(e,t){return`${this.#e.baseUrl}/sessions/${encodeURIComponent(e)}/produced/${encodeURIComponent(t)}`}async readProducedFile(e,t){return await(await this.#r(this.producedFileUrl(e,t),{headers:{...this.#e.headers}},`produced file request failed`)).blob()}projectIconUrl(e){return`${this.#e.baseUrl}/sessions/${encodeURIComponent(e)}/project/icon`}async projectIcon(e){return await(await this.#r(this.projectIconUrl(e),{headers:{...this.#e.headers}},`project icon request failed`)).blob()}async listMcpServers(e){return(await this.#i(`GET`,`/sessions/${encodeURIComponent(e)}/mcp`)).servers}async mcpServerAction(e,t,n){return(await this.#i(`POST`,`/sessions/${encodeURIComponent(e)}/mcp/${encodeURIComponent(t)}`,{action:n})).servers}sessionFileUrl(e,t){let n=t.split(`/`).filter(Boolean).map(encodeURIComponent).join(`/`);return`${this.#e.baseUrl}/sessions/${encodeURIComponent(e)}/files/${n}`}async resolvePermission(e,t,n){await this.#i(`POST`,`/sessions/${encodeURIComponent(e)}/permissions/${encodeURIComponent(t)}`,n)}async submitExecutionResult(e,t){return await this.#i(`POST`,`/executions/${encodeURIComponent(e)}/result`,t)}async listProfiles(){return await this.#i(`GET`,`/profiles`)}async getProfile(e){return await this.#i(`GET`,`/profiles/${encodeURIComponent(e)}`)}async createProfile(e){return(await this.#i(`POST`,`/profiles`,e)).profile}async updateProfile(e,t){return(await this.#i(`PATCH`,`/profiles/${encodeURIComponent(e)}`,t)).profile}async deleteProfile(e){await this.#i(`DELETE`,`/profiles/${encodeURIComponent(e)}`)}async listSdkSessions(e){let t=new URLSearchParams;e?.dir&&t.set(`dir`,e.dir),e?.limit!==void 0&&t.set(`limit`,String(e.limit)),e?.offset!==void 0&&t.set(`offset`,String(e.offset)),e?.profile&&t.set(`profile`,e.profile);let n=t.size>0?`?${t.toString()}`:``;return(await this.#i(`GET`,`/sdk-sessions${n}`)).sdkSessions}async listHostRoots(){return await this.#i(`GET`,`/fs/roots`)}async meta(){return await this.#i(`GET`,`/meta`)}async listHostDir(e){let t=`?path=${encodeURIComponent(e)}`;return await this.#i(`GET`,`/fs/list${t}`)}async findHostFiles(e,t=``,n){let r=new URLSearchParams({path:e,q:t});return n!==void 0&&r.set(`limit`,String(n)),await this.#i(`GET`,`/fs/find?${r.toString()}`)}async readHostFile(e){let t=`?path=${encodeURIComponent(e)}`;return await this.#i(`GET`,`/fs/read${t}`)}async writeHostFile(e){return await this.#i(`PUT`,`/fs/write`,e)}async createJob(e){return(await this.#i(`POST`,`/jobs`,e)).job}async listJobs(){return(await this.#i(`GET`,`/jobs`)).jobs}async getJob(e){return(await this.#i(`GET`,`/jobs/${encodeURIComponent(e)}`)).job}async cancelJob(e){return(await this.#i(`DELETE`,`/jobs/${encodeURIComponent(e)}`)).job}async queueStats(){return(await this.#i(`GET`,`/queue`)).stats}async listShells(e){return(await this.#i(`GET`,`/sessions/${encodeURIComponent(e)}/shells`)).shells}async getShell(e,t){return(await this.#i(`GET`,`/sessions/${encodeURIComponent(e)}/shells/${encodeURIComponent(t)}`)).shell}async shellOutput(e,t,n){let r=new URLSearchParams;n?.view&&r.set(`view`,n.view),n?.tail!==void 0&&r.set(`tail`,String(n.tail));let i=r.size>0?`?${r.toString()}`:``,a=`/sessions/${encodeURIComponent(e)}/shells/${encodeURIComponent(t)}/output${i}`;return await(await this.#r(`${this.#e.baseUrl}${a}`,{headers:{...this.#e.headers}},`shell output request failed`)).text()}async killShell(e,t){return(await this.#i(`POST`,`/sessions/${encodeURIComponent(e)}/shells/${encodeURIComponent(t)}/kill`)).shell}attach(e,t){return new nj(this,e,t)}attachQueue(e){return new rj(this,e)}openSocket(e,t,n=!1,r=!1){let i=`afterSeq=${t}`+(n?`&truncateResults=1`:``)+(r?`&imageRefs=1`:``),a=this.#e.buildWsUrl?.(e,t,n,r)??`${this.#e.baseUrl.replace(/^http/,`ws`)}/sessions/${encodeURIComponent(e)}/ws?${i}`;return new this.#n(a)}async toolResult(e,t,n,r){return await this.#i(`GET`,`/sessions/${encodeURIComponent(e)}/events/${t}/result?toolUseId=${encodeURIComponent(n)}`+(r?.imageRefs?`&imageRefs=1`:``))}async toolResultImage(e,t,n,r){let i=`/sessions/${encodeURIComponent(e)}/events/${t}/result?toolUseId=${encodeURIComponent(n)}&part=${r}`;return await(await this.#r(`${this.#e.baseUrl}${i}`,{headers:{...this.#e.headers}},`image part request failed`)).blob()}openQueueSocket(){let e=this.#e.buildQueueWsUrl?.()??`${this.#e.baseUrl.replace(/^http/,`ws`)}/queue/ws`;return new this.#n(e)}async#r(e,t,n){let r=await this.#t(e,t);if(!r.ok)throw new sj((await r.json().catch(()=>({}))).error??`${n} with ${r.status}`,r.status);return r}async#i(e,t,n){let r=await this.#t(`${this.#e.baseUrl}${t}`,{method:e,headers:{...n===void 0?{}:{"content-type":`application/json`},...this.#e.headers},body:n===void 0?void 0:JSON.stringify(n)}),i=await r.json().catch(()=>({}));if(!r.ok)throw new sj(i.error??`${e} ${t} failed with ${r.status}`,r.status);return i}};function lj(){let e=(0,v.useRef)(!0);return(0,v.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function uj(e){return e instanceof sj&&e.status===404}function dj(e,t,n){let r=[],i=t.get(e);if(!i)return r;let a=[{entries:i.entries,index:0,depth:0}];for(;a.length>0;){let e=a[a.length-1],i=e.entries[e.index];if(i===void 0){a.pop();continue}e.index+=1;let o=e.depth;if(i.type!==`dir`){r.push({entry:i,depth:o});continue}let s=n.has(i.path),c=t.get(i.path);r.push({entry:i,depth:o,expanded:s,loading:s&&!c,truncated:s?c?.truncated:void 0}),s&&c&&a.push({entries:c.entries,index:0,depth:o+1})}return r}function fj(e,t){let n=e.endsWith(`/`)?e.slice(0,-1):e;if(t===n||!t.startsWith(`${n}/`))return[];let r=t.slice(n.length+1).split(`/`),i=[],a=n;for(let e of r.slice(0,-1))a=`${a}/${e}`,i.push(a);return i}function pj(e,t){let[n,r]=(0,v.useState)(!1),i=(0,v.useRef)(t);(0,v.useEffect)(()=>{i.current!==t&&(i.current=t,r(!1))},[t]);let a=(0,v.useCallback)(async(i,a)=>{if(!t||n)return[];try{let n=await e.findHostFiles(t,i,a?.limit??8);return a?.signal?.aborted?[]:n.matches}catch(e){return uj(e)&&r(!0),[]}},[e,t,n]);return{available:!!t&&!n,search:a}}function mj(e){let[t,n]=(0,v.useState)({available:!1,canWrite:!1});return(0,v.useEffect)(()=>{let t=!1;return e.listHostRoots().then(e=>{t||n({available:!0,canWrite:e.canWrite})}).catch(()=>{t||n({available:!1,canWrite:!1})}),()=>{t=!0}},[e]),t}function hj(e,t){let[n,r]=(0,v.useState)(()=>new Map),[i,a]=(0,v.useState)(()=>new Set),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(),u=(0,v.useRef)(t);(0,v.useEffect)(()=>{u.current!==t&&(u.current=t,r(new Map),a(new Set),s(!1),l(void 0))},[t]);let d=lj(),f=(0,v.useRef)(new Set),p=(0,v.useCallback)((t,{force:n=!1}={})=>{o||(n||!f.current.has(t))&&(f.current.add(t),e.listHostDir(t).then(e=>{d.current&&r(n=>{let r=new Map(n);return r.set(t,{entries:e.entries,truncated:e.truncated}),r})}).catch(e=>{if(d.current){if(f.current.delete(t),uj(e)){s(!0);return}l(e instanceof Error?e.message:`Could not read that directory`)}}))},[e,o]);(0,v.useEffect)(()=>{t&&p(t)},[t,p]);let m=(0,v.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),p(e)},[p]),h=(0,v.useCallback)(e=>{if(!t)return;let n=fj(t,e);if(n.length!==0){for(let e of n)p(e);a(e=>{let t=new Set(e);for(let e of n)t.add(e);return t})}},[t,p]),g=(0,v.useCallback)(e=>{let n=e??t;n&&(l(void 0),p(n,{force:!0}))},[t,p]),_=(0,v.useMemo)(()=>t?dj(t,n,i):[],[t,n,i]);return{available:!!t&&!o,root:t,rows:_,loading:!!t&&!o&&!n.has(t)&&!c,error:c,toggle:m,reveal:h,refresh:g}}var gj={available:!1,peers:[],names:[]},_j=2e4;function vj(e,t,n=!0){let[r,i]=(0,v.useState)(void 0),[a,o]=(0,v.useState)(!1),s=lj();return(0,v.useEffect)(()=>{if(!n||a)return;let t,r=()=>{e.listSessions().then(e=>{s.current&&i(e)}).catch(e=>{s.current&&uj(e)&&o(!0)}).finally(()=>{s.current&&(t=setTimeout(r,_j))})};return r(),()=>{t&&clearTimeout(t)}},[e,n,a]),(0,v.useMemo)(()=>{if(!n||a||!r)return gj;let e=r.filter(e=>e.id!==t).sort((e,t)=>(t.lastActivityAt??t.createdAt)-(e.lastActivityAt??e.createdAt)).map(e=>({id:e.id,slug:yk(e.title,e.id),label:MO(e),engine:e.engine,status:e.status,cwd:e.cwd,project:e.project?.name,lastActivityAt:e.lastActivityAt}));return{available:e.length>0,peers:e,names:e.map(e=>bk(e.slug))}},[n,t,r,a])}var yj=new Map,bj=new Set,xj=new Set;function Sj(e,t){let[n,r]=(0,v.useState)(()=>Object.fromEntries(yj));return(0,v.useEffect)(()=>{let n=!0;for(let i of e){let e=i.info.project?.icon;if(e?.type!==`image`)continue;let{hash:a}=e;if(yj.has(a)||bj.has(a)||xj.has(a))continue;let o=t(i.hostId);o&&(bj.add(a),o.projectIcon(i.info.id).then(e=>{yj.set(a,URL.createObjectURL(e)),n&&r(Object.fromEntries(yj))}).catch(()=>{xj.add(a)}).finally(()=>bj.delete(a)))}return()=>{n=!1}},[e,t]),n}function Cj(e,t){let n=t?VA(e,t):void 0;return{initialText:(0,v.useMemo)(()=>n?HA(n):``,[n]),save:(0,v.useCallback)(e=>{n&&UA(n,e)},[n]),clear:(0,v.useCallback)(()=>{n&&UA(n,``)},[n])}}function wj(e,t,n={}){let{intervalMs:r=6e4,enabled:i=!0}=n,a=t?MA(e,t):void 0,[o,s]=(0,v.useState)(()=>a?NA(a):void 0),[c,l]=(0,v.useState)(void 0),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(0),m=(0,v.useCallback)(()=>p(e=>e+1),[]);(0,v.useEffect)(()=>{s(a?NA(a):void 0),l(void 0)},[a]);let h=lj();return(0,v.useEffect)(()=>{if(!t||!i||u)return;let n=!1,o=()=>{globalThis.document?.hidden||e.listProfiles().then(e=>{if(n||!h.current)return;let r=e.profiles.find(e=>e.name===t),i=r?.usage;a&&PA(a,i),s(i),l(r?.spend)}).catch(e=>{!n&&h.current&&uj(e)&&d(!0)})};o();let c=setInterval(o,r);return()=>{n=!0,clearInterval(c)}},[e,t,i,u,r,f,a]),{usage:o,spend:c,refresh:m}}function Tj(e,t){let[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(!!t),[o,s]=(0,v.useState)();return(0,v.useEffect)(()=>{if(!t){r(void 0),a(!1),s(void 0);return}let n=!1;return a(!0),s(void 0),r(void 0),e.getSession(t).then(e=>{n||(r(e),a(!1))}).catch(e=>{n||(s(e instanceof Error?e.message:`Session not found`),a(!1))}),()=>{n=!0}},[e,t]),{info:n,loading:i,error:o}}function Ej(e){return e.draft!==void 0&&e.draft!==e.content}function Dj(e){return e.draft??e.content??``}var Oj={files:[]};function kj(e,t){switch(t.type){case`open`:{if(e.files.some(e=>e.path===t.path))return e.activePath===t.path?e:{...e,activePath:t.path};let n={path:t.path,name:jj(t.path),status:`loading`};return{files:[...e.files,n],activePath:t.path}}case`close`:{let n=e.files.findIndex(e=>e.path===t.path);if(n===-1)return e;let r=e.files.filter(e=>e.path!==t.path);return e.activePath===t.path?{files:r,activePath:(r[n]??r[n-1])?.path}:{...e,files:r}}case`closeAll`:return Oj;case`activate`:return e.files.some(e=>e.path===t.path)?e.activePath===t.path?e:{...e,activePath:t.path}:e;case`loaded`:return Aj(e,t.path,()=>({path:t.path,name:jj(t.path),status:t.encoding===`utf8`?`ready`:`binary`,content:t.encoding===`utf8`?t.content:void 0,bytes:t.bytes,hash:t.hash,modifiedAt:t.modifiedAt}));case`failed`:return Aj(e,t.path,e=>({...e,status:`error`,error:t.error}));case`edit`:return Aj(e,t.path,e=>e.status===`ready`?{...e,draft:t.content}:e);case`revert`:return Aj(e,t.path,e=>({...e,draft:void 0,saveError:void 0,conflict:!1}));case`saveStart`:return Aj(e,t.path,e=>({...e,saving:!0,saveError:void 0,conflict:!1}));case`saved`:return Aj(e,t.path,e=>({...e,saving:!1,saveError:void 0,conflict:!1,content:t.content,bytes:t.bytes,hash:t.hash,modifiedAt:t.modifiedAt,draft:e.draft===t.content?void 0:e.draft}));case`saveFailed`:return Aj(e,t.path,e=>({...e,saving:!1,saveError:t.error,conflict:t.conflict??!1}));case`dismissConflict`:return Aj(e,t.path,e=>({...e,conflict:!1,saveError:void 0}))}}function Aj(e,t,n){let r=e.files.findIndex(e=>e.path===t);if(r===-1)return e;let i=e.files[r],a=n(i);if(a===i)return e;let o=e.files.slice();return o[r]=a,{...e,files:o}}function jj(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;return t.slice(t.lastIndexOf(`/`)+1)||t||e}function Mj(e){let[t,n]=(0,v.useReducer)(kj,Oj),r=(0,v.useRef)(new Set),i=(0,v.useRef)(!0);(0,v.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);let a=(0,v.useRef)(t);(0,v.useEffect)(()=>{a.current=t},[t]);let o=t.files.filter(e=>e.status===`loading`).map(e=>e.path).join(`
|
|
48
48
|
`),s=(0,v.useCallback)(t=>e.readHostFile(t).then(e=>{if(i.current)return n({type:`loaded`,path:t,content:e.content,encoding:e.encoding,bytes:e.bytes,hash:e.hash,modifiedAt:e.modifiedAt}),e}),[e]);(0,v.useEffect)(()=>{for(let e of o?o.split(`
|
|
49
|
-
`):[])r.current.has(e)||(r.current.add(e),s(e).catch(t=>{i.current&&n({type:`failed`,path:e,error:t instanceof Error?t.message:`Could not read that file`})}))},[s,o]);let c=(0,v.useCallback)(e=>n({type:`open`,path:e}),[]),l=(0,v.useCallback)(e=>{r.current.delete(e),n({type:`close`,path:e})},[]),u=(0,v.useCallback)(()=>{r.current.clear(),n({type:`closeAll`})},[]),d=(0,v.useCallback)(e=>n({type:`activate`,path:e}),[]),f=(0,v.useCallback)((e,t)=>n({type:`edit`,path:e,content:t}),[]),p=(0,v.useCallback)(e=>n({type:`revert`,path:e}),[]),m=(0,v.useCallback)(e=>n({type:`dismissConflict`,path:e}),[]),h=(0,v.useCallback)(e=>{r.current.add(e),s(e).catch(t=>{i.current&&n({type:`failed`,path:e,error:t instanceof Error?t.message:`Could not re-read that file`})})},[s]),g=(0,v.useCallback)(async(t,r,a)=>{try{let o=await e.writeHostFile({path:t,content:r,expectedHash:a});if(!i.current)return;n({type:`saved`,path:t,content:r,bytes:o.bytes,hash:o.hash,modifiedAt:o.modifiedAt})}catch(e){if(!i.current)return;let r=e instanceof sj&&e.status===409;n({type:`saveFailed`,path:t,conflict:r,error:r?`This file changed on disk since you opened it.`:e instanceof Error?e.message:`Could not save that file`})}},[e]),_=(0,v.useCallback)(async e=>{let t=a.current.files.find(t=>t.path===e);t&&!t.saving&&Ej(t)&&(n({type:`saveStart`,path:e}),await g(e,Dj(t),t.hash))},[g]),y=(0,v.useCallback)(async t=>{let r=a.current.files.find(e=>e.path===t);if(!r||r.saving)return;let o=Dj(r);n({type:`saveStart`,path:t});try{let n=await e.readHostFile(t);if(!i.current)return;await g(t,o,n.hash)}catch(e){if(!i.current)return;n({type:`saveFailed`,path:t,error:e instanceof Error?e.message:`Could not save that file`})}},[e,g]),b=(0,v.useMemo)(()=>t.files.find(e=>e.path===t.activePath),[t.files,t.activePath]),x=(0,v.useMemo)(()=>t.files.some(Ej),[t.files]);return{...t,active:b,hasUnsaved:x,open:c,close:l,closeAll:u,activate:d,edit:f,save:_,revert:p,reload:h,overwrite:y,dismissConflict:m}}var Nj=`modulepreload`,Pj=function(e){return`/`+e},Fj={},Ij=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Pj(t,n),t=s(t),t in Fj)return;Fj[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Nj,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Lj(e,t={}){let n=new Map,r,i=!1,a=e=>t.onExecution?.(e),o=(t,n,r,i)=>{e.sendToolCallError(t.executionId,n,r),a({executionId:t.executionId,toolName:t.toolName,status:`failed`,reason:n,startedAt:i,endedAt:Date.now()})},s=async(t,r)=>{let s=Date.now(),c=new AbortController;n.set(t.executionId,c),a({executionId:t.executionId,toolName:t.toolName,status:`running`,startedAt:s});try{let o=await r(t.input,{executionId:t.executionId,signal:c.signal});if(i||!n.has(t.executionId))return;`error`in o?(e.sendToolCallError(t.executionId,o.reason??`client_error`,o.error),a({executionId:t.executionId,toolName:t.toolName,status:`failed`,reason:o.reason??`client_error`,startedAt:s,endedAt:Date.now()})):(e.sendToolCallResult(t.executionId,{type:`json`,value:o.value}),a({executionId:t.executionId,toolName:t.toolName,status:`settled`,startedAt:s,endedAt:Date.now()}))}catch(e){if(i||!n.has(t.executionId))return;o(t,`host_error`,e instanceof Error?e.message:String(e),s)}finally{n.delete(t.executionId)}},c=async c=>{let l=Date.now(),u=t.clientTools?.[c.toolName];if(u)return s(c,u);if(!(t.tools??[`eval_script`]).includes(c.toolName)){o(c,`unsupported_tool`,`this client does not execute '${c.toolName}'`,l);return}let d=c.input?.script;if(typeof d!=`string`){o(c,`invalid_input`,"expected a string `script` input",l);return}let f=new AbortController;n.set(c.executionId,f),a({executionId:c.executionId,toolName:c.toolName,status:`running`,startedAt:l});try{let o=await Ij(()=>import(`./src-BcRpl0IM.js`),[]),s=o.createVfs(c.vfsSeed),u=Math.min(c.limits?.timeoutMs??1/0,t.timeoutMs??5e3),p=Math.min(c.limits?.memoryLimitBytes??1/0,t.memoryLimitBytes??67108864),m=t.execute?await t.execute({script:d,vfs:s,timeoutMs:u,memoryLimitBytes:p,signal:f.signal}):await(async()=>(r??=(t.loadEngine??Rj)(),o.runScript(await r,{script:d,vfs:s,timeoutMs:u,memoryLimitBytes:p,signal:f.signal,fetchText:t.fetchText})))();if(i||!n.has(c.executionId))return;let h=m.logs.map(e=>`[${e.level}] ${e.text}`);m.ok?(e.sendToolCallResult(c.executionId,{type:`json`,value:m.value},h),a({executionId:c.executionId,toolName:c.toolName,status:`settled`,startedAt:l,endedAt:Date.now()})):(e.sendToolCallError(c.executionId,m.reason,m.error,h),a({executionId:c.executionId,toolName:c.toolName,status:`failed`,reason:m.reason,startedAt:l,endedAt:Date.now()}))}catch(e){if(i||!n.has(c.executionId))return;o(c,`host_error`,e instanceof Error?e.message:String(e),l)}finally{n.delete(c.executionId)}},l=e.on(`toolCallRequest`,e=>void c(e)),u=e.on(`toolCallCanceled`,({executionId:e,reason:t})=>{let r=n.get(e);r&&(r.abort(),n.delete(e),a({executionId:e,toolName:``,status:`canceled`,reason:t,startedAt:Date.now(),endedAt:Date.now()}))});return{dispose:()=>{i=!0,l(),u();for(let e of n.values())e.abort();n.clear()}}}async function Rj(){let[e,t]=await Promise.all([Ij(()=>import(`./src-BcRpl0IM.js`),[]),Ij(()=>import(`./dist-BYhO38VS.js`),[])]);return e.loadEngine(t)}function zj(e,t={}){let[n,r]=(0,v.useState)([]),i=(0,v.useRef)(t);return i.current=t,(0,v.useEffect)(()=>{if(!e||t.enabled===!1)return;let n=Lj(e,{get tools(){let e=i.current.tools,t=i.current.clientTools;if(!t)return e;let n=Object.keys(t);return e?[...new Set([...e,...n])]:n},get clientTools(){return i.current.clientTools},get timeoutMs(){return i.current.timeoutMs},get memoryLimitBytes(){return i.current.memoryLimitBytes},get loadEngine(){return i.current.loadEngine},get execute(){return i.current.execute},get fetchText(){return i.current.fetchText},onExecution:e=>{i.current.onExecution?.(e);let t=i.current.historyLimit??50;r(n=>[...n.filter(t=>t.executionId!==e.executionId),e].slice(-t))}});return()=>n.dispose()},[e,t.enabled]),{executions:n}}function Bj(e,t){let n=Math.max(0,Math.min(t,e.items.length)),r=e.items.slice(n),i=new Map,a=0,o=0,s=0,c=0,l=0;for(let e of r)switch(e.kind){case`turn_result`:a+=1,e.isError&&(l+=1);break;case`assistant_text`:o+=1;break;case`tool_call`:s+=1,i.set(e.name,(i.get(e.name)??0)+1),(e.status===`failed`||e.result?.isError)&&(l+=1);break;case`file_delivered`:c+=1;break;case`notice`:e.level===`error`&&(l+=1)}let u=[...i.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e])=>e),d=e.pendingApprovals?.length??0;return{turns:a,replies:o,tools:s,toolNames:u,files:c,errors:l,pending:d,any:a+o+s+c+l+d>0}}function Vj(e){if(!e.any)return;let t=[];if(e.turns>0?t.push(Hj(e.turns,`turn`)):e.replies>0&&t.push(Hj(e.replies,`reply`,`replies`)),e.tools>0){let n=e.toolNames.slice(0,3).join(`, `),r=e.toolNames.length-3;t.push(`${Hj(e.tools,`tool call`)}${n?` (${n}${r>0?`, +${r}`:``})`:``}`)}return e.files>0&&t.push(Hj(e.files,`file`)),e.errors>0&&t.push(Hj(e.errors,`error`)),e.pending>0&&t.push(`${Hj(e.pending,`approval`)} waiting`),t.join(` · `)}function Hj(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function Uj(e,t,n){let[r,i]=(0,v.useState)(`idle`),[a,o]=(0,v.useState)(void 0),[s,c]=(0,v.useState)(void 0),l=(0,v.useRef)(n);l.current=n;let u=(0,v.useRef)({cols:80,rows:24}),d=(0,v.useRef)(!1);(0,v.useEffect)(()=>{d.current=!1,i(`idle`),o(void 0),c(void 0)},[e,t]),(0,v.useEffect)(()=>{if(!e||t===void 0)return;let n=e.on(`shellAttached`,e=>{if(e.shellId!==t)return;u.current={cols:e.cols,rows:e.rows},o(e.shell),c(void 0),i(`attached`);let n={shell:e.shell,cols:e.cols,rows:e.rows,scrollback:e.scrollback};l.current.onAttached?l.current.onAttached(n):e.scrollback&&l.current.onData(e.scrollback)}),r=e.on(`shellOutput`,e=>{e.shellId===t&&l.current.onData(e.data)}),a=e.on(`shellDetached`,e=>{e.shellId===t&&(d.current=!1,c(e.reason),i(`detached`),l.current.onEnded?.(e.reason))}),s=e.on(`connectionChange`,n=>{d.current&&(n?(i(`attaching`),e.attachShell(t,u.current)):i(e=>e===`attached`?`attaching`:e))});return()=>{n(),r(),a(),s(),d.current&&(d.current=!1,e.detachShell(t))}},[e,t]);let f=(0,v.useCallback)(n=>{e&&t!==void 0&&(u.current=n,d.current=!0,c(void 0),i(`attaching`),e.attachShell(t,n))},[e,t]),p=(0,v.useCallback)(n=>{e&&t!==void 0&&e.writeShell(t,n)},[e,t]),m=(0,v.useCallback)(n=>{(n.cols!==u.current.cols||n.rows!==u.current.rows)&&(u.current=n,e&&t!==void 0&&d.current&&e.resizeShell(t,n))},[e,t]),h=(0,v.useCallback)(()=>{e&&t!==void 0&&d.current&&e.detachShell(t),d.current=!1,i(`idle`)},[e,t]);return(0,v.useMemo)(()=>({status:r,shell:a,reason:s,attach:f,write:p,resize:m,detach:h}),[r,a,s,f,p,m,h])}var Wj={command:0,client:1,skill:2};function Gj(e){return e.replace(/\s*\(MCP\)$/i,``)}function Kj(e){return`$${e.name}`}function qj(e){let t=Kj(e),n=(e.defaultPrompt??``).split(t).join(` `).replace(/\s+/g,` `).trim();return n?` ${n} `:` `}function Jj(e){return Kj(e)+qj(e)}function Yj(e){let t=[],n=new Set;for(let r of e.commands??[]){let e=Gj(r.name);if(!n.has(e)){n.add(e);for(let e of r.aliases??[])n.add(Gj(e));t.push({kind:`command`,name:e,description:r.description,argumentHint:r.argumentHint,aliases:r.aliases})}}for(let r of e.clientCommands??[])n.has(r.name)||t.push({kind:`client`,name:r.name,description:r.description,argumentHint:r.argumentHint,command:r});for(let n of e.skills??[])t.push({kind:`skill`,name:n.name,label:n.displayName??n.name,description:n.shortDescription??n.description,enabled:n.enabled,scope:n.scope,skill:n});return t}function Xj(e){return e.kind===`skill`?[e.name,e.label,...e.name.split(/[-:_]/)]:[e.name,...e.kind===`command`?e.aliases??[]:[],...e.name.split(`:`)]}function Zj(e,t){let n=e.toLowerCase(),r=t.map(e=>e.toLowerCase());return r.some(e=>e.startsWith(n))?2:+!!r.some(e=>e.includes(n))}function Qj(e,t){let n=[];return t.forEach((t,r)=>{if(t.kind===`skill`&&!t.enabled)return;let i=Zj(e,Xj(t));i>0&&n.push({score:i,index:r,row:t})}),n.sort((e,t)=>t.score-e.score||Wj[e.row.kind]-Wj[t.row.kind]||e.index-t.index),n.map(({row:e})=>e)}function $j(e,t){let n=e.trim();if(!n)return[...t];let r=[];return t.forEach((e,t)=>{let i=Zj(n,[e.slug,e.label,...e.slug.split(`-`)]);i>0&&r.push({score:i,index:t,peer:e})}),r.sort((e,t)=>t.score-e.score||e.index-t.index),r.map(({peer:e})=>e)}function eM(e,t){let n=/^\/([\w:-]+)[ \t]*([\s\S]*)$/.exec(e.trim());if(!n)return;let r=t.find(e=>e.name===n[1]);return r?{command:r,args:n[2].trim()}:void 0}function tM(e){return e.map(e=>e.kind===`skill`?{kind:e.kind,name:e.name,label:e.label,description:e.description,scope:e.scope,enabled:e.enabled,insertText:Jj(e.skill)}:{kind:e.kind,name:e.name,label:`/${e.name}`,description:e.description,enabled:!0,insertText:`/${e.name} `})}var nM=(0,v.createContext)(`cards`);function rM({value:e,children:t}){return(0,U.jsx)(nM.Provider,{value:e,children:t})}function iM(){return(0,v.useContext)(nM)}var aM=(0,v.createContext)(`comfortable`);function oM({value:e,children:t}){return(0,U.jsx)(aM.Provider,{value:e,children:t})}var sM={terminal:{comfortable:{className:`term-row-gap`,px:18},compact:{className:`term-row-gap`,px:18}},cards:{comfortable:{className:`pt-4`,px:16},compact:{className:`pt-2`,px:8}}},cM=`context compacted · earlier turns summarised to fit the window`;function lM(e){return e.error?`context compaction failed · ${e.error}`:e.pending?`compacting context · summarising earlier turns to fit the window`:[cM,e.preTokens===void 0?void 0:e.postTokens===void 0?`from ${fM(e.preTokens)}`:`${fM(e.preTokens)} → ${fM(e.postTokens)}`,e.trigger===`auto`?`automatic`:void 0].filter(Boolean).join(` · `)}function uM(e){return e===void 0||Number.isNaN(e)?`-`:e===0?`$0.00`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function dM(e){if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`}function fM(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function pM(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function mM(e,t=Date.now()){let n=e-t;if(n<=0)return`now`;let r=Math.ceil(n/6e4);if(r<1)return`<1m`;if(r<60)return`${r}m`;let i=Math.floor(r/1440);return i>=1?`${i}d ${Math.floor(r%1440/60)}h`:`${Math.floor(r/60)}h ${r%60}m`}function hM(e,t=Date.now()){if(!e)return`-`;let n=Math.max(0,t-e),r=Math.floor(n/1e3);if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function gM(e){if(e===`five_hour`)return`5-hour session`;if(e===`seven_day`)return`Weekly`;if(e===`seven_day_oauth_apps`)return`Weekly · apps`;let t=e=>e.replace(/\b\w/g,e=>e.toUpperCase());return e.startsWith(`seven_day_`)?`Weekly · ${t(e.slice(10).replaceAll(`_`,` `))}`:t(e.replaceAll(`_`,` `))}function _M(e){if(e===`five_hour`)return 18e3;if(e.startsWith(`seven_day`))return 604800}function vM(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n} sec${n===1?``:`s`} ago`;if(n<3600){let e=Math.floor(n/60);return`${e} min${e===1?``:`s`} ago`}let r=Math.floor(n/3600);return`${r} hour${r===1?``:`s`} ago`}function yM(e,t=80){if(e==null)return``;if(typeof e==`object`){let n=e,r=n.command??n.file_path??n.path??n.url??n.pattern??n.query??n.description;if(typeof r==`string`)return r.length>t?r.slice(0,t-1)+`…`:r}let n=JSON.stringify(e)??``;return n.length>t?n.slice(0,t-1)+`…`:n}var bM={gpt:{name:`GPT`,joiner:`-`},deepseek:{name:`DeepSeek`},glm:{name:`GLM`},qwen:{name:`Qwen`},kimi:{name:`Kimi`},llama:{name:`Llama`},mistral:{name:`Mistral`},grok:{name:`Grok`}};function xM(e){if(!e)return;let t=(e.split(`[`)[0]??e).toLowerCase().split(`-`).filter(Boolean);t[0]===`claude`&&t.shift();let n=t.shift();if(!n)return e;let r=bM[n],i=r?.name??(/^o\d+$/.test(n)?n:`${n.charAt(0).toUpperCase()}${n.slice(1)}`),a=[],o=[];for(let e of t)/^\d{8}$/.test(e)||(/^\d+(\.\d+)?$/.test(e)?a.push(e):o.push(`${e.charAt(0).toUpperCase()}${e.slice(1)}`));return[a.length>0?`${i}${r?.joiner??` `}${a.join(`.`)}`:i,...o].join(` `)}function SM(e){switch(e){case`Bash`:case`BashOutput`:case`KillShell`:return QS;case`Read`:return sy;case`Write`:return MS;case`Edit`:case`MultiEdit`:case`NotebookEdit`:return fx;case`Glob`:return vy;case`Grep`:return oS;case`WebFetch`:return hv;case`WebSearch`:return Ry;case`Task`:case`Agent`:return mC;case`TodoWrite`:case`TaskCreate`:case`TaskUpdate`:case`TaskGet`:case`TaskList`:return AS;case`Skill`:return ES;case`AskUserQuestion`:return Ab;case`CodexCommand`:return QS;case`CodexFileChange`:return aee;case`CodexWebSearch`:return Ry;case`CodexImageGeneration`:case`CodexImageView`:return Qy;default:return e.startsWith(`mcp__`)?Ax:TC}}function CM(e){return e===`Bash`||e===`CodexCommand`}function wM(e){switch(e){case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:case`Update`:case`CodexFileChange`:return!0;default:return!1}}var TM=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],EM=new Set,DM,OM=`⠿`;function kM(e){return TM[Math.floor(e/90)%TM.length]}function AM(){let e=kM(Date.now());if(e!==OM){OM=e;for(let e of EM)e()}}function jM(e){return EM.add(e),DM===void 0&&(OM=kM(Date.now()),DM=setInterval(AM,90)),()=>{EM.delete(e),EM.size===0&&DM!==void 0&&(clearInterval(DM),DM=void 0)}}function MM(){return NM}function NM(){}function PM(){return OM}function FM(){return`⠿`}function IM(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);if(!e)return;t(e.matches);let n=()=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function LM(e){let t=IM(),n=e&&!t;return(0,v.useSyncExternalStore)(n?jM:MM,n?PM:FM,FM)}var RM=(0,v.createContext)(void 0),zM=(0,v.createContext)(void 0);function BM({names:e,children:t}){return(0,U.jsx)(RM.Provider,{value:e,children:t})}function VM({names:e,children:t}){return(0,U.jsx)(zM.Provider,{value:e,children:t})}function HM({text:e,className:t}){let n=$A(e,{skills:(0,v.useContext)(RM),sessions:(0,v.useContext)(zM)});if(n.length===0)return(0,U.jsx)(`span`,{className:t,children:e});let r=[],i=0;for(let[t,a]of n.entries())a.start>i&&r.push(e.slice(i,a.start)),r.push((0,U.jsx)(`span`,{className:W(`font-mono`,a.kind===`file`?`text-accent`:`text-info`),children:a.text},`${a.start}-${t}`)),i=a.end;return i<e.length&&r.push(e.slice(i)),(0,U.jsx)(`span`,{className:t,children:r.map((e,t)=>(0,U.jsx)(v.Fragment,{children:e},t))})}var UM=`output expired or not tracked by this gateway`;function WM(e){return e.label||e.command.split(`
|
|
49
|
+
`):[])r.current.has(e)||(r.current.add(e),s(e).catch(t=>{i.current&&n({type:`failed`,path:e,error:t instanceof Error?t.message:`Could not read that file`})}))},[s,o]);let c=(0,v.useCallback)(e=>n({type:`open`,path:e}),[]),l=(0,v.useCallback)(e=>{r.current.delete(e),n({type:`close`,path:e})},[]),u=(0,v.useCallback)(()=>{r.current.clear(),n({type:`closeAll`})},[]),d=(0,v.useCallback)(e=>n({type:`activate`,path:e}),[]),f=(0,v.useCallback)((e,t)=>n({type:`edit`,path:e,content:t}),[]),p=(0,v.useCallback)(e=>n({type:`revert`,path:e}),[]),m=(0,v.useCallback)(e=>n({type:`dismissConflict`,path:e}),[]),h=(0,v.useCallback)(e=>{r.current.add(e),s(e).catch(t=>{i.current&&n({type:`failed`,path:e,error:t instanceof Error?t.message:`Could not re-read that file`})})},[s]),g=(0,v.useCallback)(async(t,r,a)=>{try{let o=await e.writeHostFile({path:t,content:r,expectedHash:a});if(!i.current)return;n({type:`saved`,path:t,content:r,bytes:o.bytes,hash:o.hash,modifiedAt:o.modifiedAt})}catch(e){if(!i.current)return;let r=e instanceof sj&&e.status===409;n({type:`saveFailed`,path:t,conflict:r,error:r?`This file changed on disk since you opened it.`:e instanceof Error?e.message:`Could not save that file`})}},[e]),_=(0,v.useCallback)(async e=>{let t=a.current.files.find(t=>t.path===e);t&&!t.saving&&Ej(t)&&(n({type:`saveStart`,path:e}),await g(e,Dj(t),t.hash))},[g]),y=(0,v.useCallback)(async t=>{let r=a.current.files.find(e=>e.path===t);if(!r||r.saving)return;let o=Dj(r);n({type:`saveStart`,path:t});try{let n=await e.readHostFile(t);if(!i.current)return;await g(t,o,n.hash)}catch(e){if(!i.current)return;n({type:`saveFailed`,path:t,error:e instanceof Error?e.message:`Could not save that file`})}},[e,g]),b=(0,v.useMemo)(()=>t.files.find(e=>e.path===t.activePath),[t.files,t.activePath]),x=(0,v.useMemo)(()=>t.files.some(Ej),[t.files]);return{...t,active:b,hasUnsaved:x,open:c,close:l,closeAll:u,activate:d,edit:f,save:_,revert:p,reload:h,overwrite:y,dismissConflict:m}}var Nj=`modulepreload`,Pj=function(e){return`/`+e},Fj={},Ij=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Pj(t,n),t=s(t),t in Fj)return;Fj[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Nj,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Lj(e,t={}){let n=new Map,r,i=!1,a=e=>t.onExecution?.(e),o=(t,n,r,i)=>{e.sendToolCallError(t.executionId,n,r),a({executionId:t.executionId,toolName:t.toolName,status:`failed`,reason:n,startedAt:i,endedAt:Date.now()})},s=async(t,r)=>{let s=Date.now(),c=new AbortController;n.set(t.executionId,c),a({executionId:t.executionId,toolName:t.toolName,status:`running`,startedAt:s});try{let o=await r(t.input,{executionId:t.executionId,signal:c.signal});if(i||!n.has(t.executionId))return;`error`in o?(e.sendToolCallError(t.executionId,o.reason??`client_error`,o.error),a({executionId:t.executionId,toolName:t.toolName,status:`failed`,reason:o.reason??`client_error`,startedAt:s,endedAt:Date.now()})):(e.sendToolCallResult(t.executionId,{type:`json`,value:o.value}),a({executionId:t.executionId,toolName:t.toolName,status:`settled`,startedAt:s,endedAt:Date.now()}))}catch(e){if(i||!n.has(t.executionId))return;o(t,`host_error`,e instanceof Error?e.message:String(e),s)}finally{n.delete(t.executionId)}},c=async c=>{let l=Date.now(),u=t.clientTools?.[c.toolName];if(u)return s(c,u);if(!(t.tools??[`eval_script`]).includes(c.toolName)){o(c,`unsupported_tool`,`this client does not execute '${c.toolName}'`,l);return}let d=c.input?.script;if(typeof d!=`string`){o(c,`invalid_input`,"expected a string `script` input",l);return}let f=new AbortController;n.set(c.executionId,f),a({executionId:c.executionId,toolName:c.toolName,status:`running`,startedAt:l});try{let o=await Ij(()=>import(`./src-Dj2YGQOH.js`),[]),s=o.createVfs(c.vfsSeed),u=Math.min(c.limits?.timeoutMs??1/0,t.timeoutMs??5e3),p=Math.min(c.limits?.memoryLimitBytes??1/0,t.memoryLimitBytes??67108864),m=t.execute?await t.execute({script:d,vfs:s,timeoutMs:u,memoryLimitBytes:p,signal:f.signal}):await(async()=>(r??=(t.loadEngine??Rj)(),o.runScript(await r,{script:d,vfs:s,timeoutMs:u,memoryLimitBytes:p,signal:f.signal,fetchText:t.fetchText})))();if(i||!n.has(c.executionId))return;let h=m.logs.map(e=>`[${e.level}] ${e.text}`);m.ok?(e.sendToolCallResult(c.executionId,{type:`json`,value:m.value},h),a({executionId:c.executionId,toolName:c.toolName,status:`settled`,startedAt:l,endedAt:Date.now()})):(e.sendToolCallError(c.executionId,m.reason,m.error,h),a({executionId:c.executionId,toolName:c.toolName,status:`failed`,reason:m.reason,startedAt:l,endedAt:Date.now()}))}catch(e){if(i||!n.has(c.executionId))return;o(c,`host_error`,e instanceof Error?e.message:String(e),l)}finally{n.delete(c.executionId)}},l=e.on(`toolCallRequest`,e=>void c(e)),u=e.on(`toolCallCanceled`,({executionId:e,reason:t})=>{let r=n.get(e);r&&(r.abort(),n.delete(e),a({executionId:e,toolName:``,status:`canceled`,reason:t,startedAt:Date.now(),endedAt:Date.now()}))});return{dispose:()=>{i=!0,l(),u();for(let e of n.values())e.abort();n.clear()}}}async function Rj(){let[e,t]=await Promise.all([Ij(()=>import(`./src-Dj2YGQOH.js`),[]),Ij(()=>import(`./dist-DhMqnScS.js`),[])]);return e.loadEngine(t)}function zj(e,t={}){let[n,r]=(0,v.useState)([]),i=(0,v.useRef)(t);return i.current=t,(0,v.useEffect)(()=>{if(!e||t.enabled===!1)return;let n=Lj(e,{get tools(){let e=i.current.tools,t=i.current.clientTools;if(!t)return e;let n=Object.keys(t);return e?[...new Set([...e,...n])]:n},get clientTools(){return i.current.clientTools},get timeoutMs(){return i.current.timeoutMs},get memoryLimitBytes(){return i.current.memoryLimitBytes},get loadEngine(){return i.current.loadEngine},get execute(){return i.current.execute},get fetchText(){return i.current.fetchText},onExecution:e=>{i.current.onExecution?.(e);let t=i.current.historyLimit??50;r(n=>[...n.filter(t=>t.executionId!==e.executionId),e].slice(-t))}});return()=>n.dispose()},[e,t.enabled]),{executions:n}}function Bj(e,t){let n=Math.max(0,Math.min(t,e.items.length)),r=e.items.slice(n),i=new Map,a=0,o=0,s=0,c=0,l=0;for(let e of r)switch(e.kind){case`turn_result`:a+=1,e.isError&&(l+=1);break;case`assistant_text`:o+=1;break;case`tool_call`:s+=1,i.set(e.name,(i.get(e.name)??0)+1),(e.status===`failed`||e.result?.isError)&&(l+=1);break;case`file_delivered`:c+=1;break;case`notice`:e.level===`error`&&(l+=1)}let u=[...i.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e])=>e),d=e.pendingApprovals?.length??0;return{turns:a,replies:o,tools:s,toolNames:u,files:c,errors:l,pending:d,any:a+o+s+c+l+d>0}}function Vj(e){if(!e.any)return;let t=[];if(e.turns>0?t.push(Hj(e.turns,`turn`)):e.replies>0&&t.push(Hj(e.replies,`reply`,`replies`)),e.tools>0){let n=e.toolNames.slice(0,3).join(`, `),r=e.toolNames.length-3;t.push(`${Hj(e.tools,`tool call`)}${n?` (${n}${r>0?`, +${r}`:``})`:``}`)}return e.files>0&&t.push(Hj(e.files,`file`)),e.errors>0&&t.push(Hj(e.errors,`error`)),e.pending>0&&t.push(`${Hj(e.pending,`approval`)} waiting`),t.join(` · `)}function Hj(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function Uj(e,t,n){let[r,i]=(0,v.useState)(`idle`),[a,o]=(0,v.useState)(void 0),[s,c]=(0,v.useState)(void 0),l=(0,v.useRef)(n);l.current=n;let u=(0,v.useRef)({cols:80,rows:24}),d=(0,v.useRef)(!1);(0,v.useEffect)(()=>{d.current=!1,i(`idle`),o(void 0),c(void 0)},[e,t]),(0,v.useEffect)(()=>{if(!e||t===void 0)return;let n=e.on(`shellAttached`,e=>{if(e.shellId!==t)return;u.current={cols:e.cols,rows:e.rows},o(e.shell),c(void 0),i(`attached`);let n={shell:e.shell,cols:e.cols,rows:e.rows,scrollback:e.scrollback};l.current.onAttached?l.current.onAttached(n):e.scrollback&&l.current.onData(e.scrollback)}),r=e.on(`shellOutput`,e=>{e.shellId===t&&l.current.onData(e.data)}),a=e.on(`shellDetached`,e=>{e.shellId===t&&(d.current=!1,c(e.reason),i(`detached`),l.current.onEnded?.(e.reason))}),s=e.on(`connectionChange`,n=>{d.current&&(n?(i(`attaching`),e.attachShell(t,u.current)):i(e=>e===`attached`?`attaching`:e))});return()=>{n(),r(),a(),s(),d.current&&(d.current=!1,e.detachShell(t))}},[e,t]);let f=(0,v.useCallback)(n=>{e&&t!==void 0&&(u.current=n,d.current=!0,c(void 0),i(`attaching`),e.attachShell(t,n))},[e,t]),p=(0,v.useCallback)(n=>{e&&t!==void 0&&e.writeShell(t,n)},[e,t]),m=(0,v.useCallback)(n=>{(n.cols!==u.current.cols||n.rows!==u.current.rows)&&(u.current=n,e&&t!==void 0&&d.current&&e.resizeShell(t,n))},[e,t]),h=(0,v.useCallback)(()=>{e&&t!==void 0&&d.current&&e.detachShell(t),d.current=!1,i(`idle`)},[e,t]);return(0,v.useMemo)(()=>({status:r,shell:a,reason:s,attach:f,write:p,resize:m,detach:h}),[r,a,s,f,p,m,h])}var Wj={command:0,client:1,skill:2};function Gj(e){return e.replace(/\s*\(MCP\)$/i,``)}function Kj(e){return`$${e.name}`}function qj(e){let t=Kj(e),n=(e.defaultPrompt??``).split(t).join(` `).replace(/\s+/g,` `).trim();return n?` ${n} `:` `}function Jj(e){return Kj(e)+qj(e)}function Yj(e){let t=[],n=new Set;for(let r of e.commands??[]){let e=Gj(r.name);if(!n.has(e)){n.add(e);for(let e of r.aliases??[])n.add(Gj(e));t.push({kind:`command`,name:e,description:r.description,argumentHint:r.argumentHint,aliases:r.aliases})}}for(let r of e.clientCommands??[])n.has(r.name)||t.push({kind:`client`,name:r.name,description:r.description,argumentHint:r.argumentHint,command:r});for(let n of e.skills??[])t.push({kind:`skill`,name:n.name,label:n.displayName??n.name,description:n.shortDescription??n.description,enabled:n.enabled,scope:n.scope,skill:n});return t}function Xj(e){return e.kind===`skill`?[e.name,e.label,...e.name.split(/[-:_]/)]:[e.name,...e.kind===`command`?e.aliases??[]:[],...e.name.split(`:`)]}function Zj(e,t){let n=e.toLowerCase(),r=t.map(e=>e.toLowerCase());return r.some(e=>e.startsWith(n))?2:+!!r.some(e=>e.includes(n))}function Qj(e,t){let n=[];return t.forEach((t,r)=>{if(t.kind===`skill`&&!t.enabled)return;let i=Zj(e,Xj(t));i>0&&n.push({score:i,index:r,row:t})}),n.sort((e,t)=>t.score-e.score||Wj[e.row.kind]-Wj[t.row.kind]||e.index-t.index),n.map(({row:e})=>e)}function $j(e,t){let n=e.trim();if(!n)return[...t];let r=[];return t.forEach((e,t)=>{let i=Zj(n,[e.slug,e.label,...e.slug.split(`-`)]);i>0&&r.push({score:i,index:t,peer:e})}),r.sort((e,t)=>t.score-e.score||e.index-t.index),r.map(({peer:e})=>e)}function eM(e,t){let n=/^\/([\w:-]+)[ \t]*([\s\S]*)$/.exec(e.trim());if(!n)return;let r=t.find(e=>e.name===n[1]);return r?{command:r,args:n[2].trim()}:void 0}function tM(e){return e.map(e=>e.kind===`skill`?{kind:e.kind,name:e.name,label:e.label,description:e.description,scope:e.scope,enabled:e.enabled,insertText:Jj(e.skill)}:{kind:e.kind,name:e.name,label:`/${e.name}`,description:e.description,enabled:!0,insertText:`/${e.name} `})}var nM=(0,v.createContext)(`cards`);function rM({value:e,children:t}){return(0,U.jsx)(nM.Provider,{value:e,children:t})}function iM(){return(0,v.useContext)(nM)}var aM=(0,v.createContext)(`comfortable`);function oM({value:e,children:t}){return(0,U.jsx)(aM.Provider,{value:e,children:t})}var sM={terminal:{comfortable:{className:`term-row-gap`,px:18},compact:{className:`term-row-gap`,px:18}},cards:{comfortable:{className:`pt-4`,px:16},compact:{className:`pt-2`,px:8}}},cM=`context compacted · earlier turns summarised to fit the window`;function lM(e){return e.error?`context compaction failed · ${e.error}`:e.pending?`compacting context · summarising earlier turns to fit the window`:[cM,e.preTokens===void 0?void 0:e.postTokens===void 0?`from ${fM(e.preTokens)}`:`${fM(e.preTokens)} → ${fM(e.postTokens)}`,e.trigger===`auto`?`automatic`:void 0].filter(Boolean).join(` · `)}function uM(e){return e===void 0||Number.isNaN(e)?`-`:e===0?`$0.00`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function dM(e){if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`}function fM(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function pM(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function mM(e,t=Date.now()){let n=e-t;if(n<=0)return`now`;let r=Math.ceil(n/6e4);if(r<1)return`<1m`;if(r<60)return`${r}m`;let i=Math.floor(r/1440);return i>=1?`${i}d ${Math.floor(r%1440/60)}h`:`${Math.floor(r/60)}h ${r%60}m`}function hM(e,t=Date.now()){if(!e)return`-`;let n=Math.max(0,t-e),r=Math.floor(n/1e3);if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function gM(e){if(e===`five_hour`)return`5-hour session`;if(e===`seven_day`)return`Weekly`;if(e===`seven_day_oauth_apps`)return`Weekly · apps`;let t=e=>e.replace(/\b\w/g,e=>e.toUpperCase());return e.startsWith(`seven_day_`)?`Weekly · ${t(e.slice(10).replaceAll(`_`,` `))}`:t(e.replaceAll(`_`,` `))}function _M(e){if(e===`five_hour`)return 18e3;if(e.startsWith(`seven_day`))return 604800}function vM(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n} sec${n===1?``:`s`} ago`;if(n<3600){let e=Math.floor(n/60);return`${e} min${e===1?``:`s`} ago`}let r=Math.floor(n/3600);return`${r} hour${r===1?``:`s`} ago`}function yM(e,t=80){if(e==null)return``;if(typeof e==`object`){let n=e,r=n.command??n.file_path??n.path??n.url??n.pattern??n.query??n.description;if(typeof r==`string`)return r.length>t?r.slice(0,t-1)+`…`:r}let n=JSON.stringify(e)??``;return n.length>t?n.slice(0,t-1)+`…`:n}var bM={gpt:{name:`GPT`,joiner:`-`},deepseek:{name:`DeepSeek`},glm:{name:`GLM`},qwen:{name:`Qwen`},kimi:{name:`Kimi`},llama:{name:`Llama`},mistral:{name:`Mistral`},grok:{name:`Grok`}};function xM(e){if(!e)return;let t=(e.split(`[`)[0]??e).toLowerCase().split(`-`).filter(Boolean);t[0]===`claude`&&t.shift();let n=t.shift();if(!n)return e;let r=bM[n],i=r?.name??(/^o\d+$/.test(n)?n:`${n.charAt(0).toUpperCase()}${n.slice(1)}`),a=[],o=[];for(let e of t)/^\d{8}$/.test(e)||(/^\d+(\.\d+)?$/.test(e)?a.push(e):o.push(`${e.charAt(0).toUpperCase()}${e.slice(1)}`));return[a.length>0?`${i}${r?.joiner??` `}${a.join(`.`)}`:i,...o].join(` `)}function SM(e){switch(e){case`Bash`:case`BashOutput`:case`KillShell`:return QS;case`Read`:return sy;case`Write`:return MS;case`Edit`:case`MultiEdit`:case`NotebookEdit`:return fx;case`Glob`:return vy;case`Grep`:return oS;case`WebFetch`:return hv;case`WebSearch`:return Ry;case`Task`:case`Agent`:return mC;case`TodoWrite`:case`TaskCreate`:case`TaskUpdate`:case`TaskGet`:case`TaskList`:return AS;case`Skill`:return ES;case`AskUserQuestion`:return Ab;case`CodexCommand`:return QS;case`CodexFileChange`:return aee;case`CodexWebSearch`:return Ry;case`CodexImageGeneration`:case`CodexImageView`:return Qy;default:return e.startsWith(`mcp__`)?Ax:TC}}function CM(e){return e===`Bash`||e===`CodexCommand`}function wM(e){switch(e){case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:case`Update`:case`CodexFileChange`:return!0;default:return!1}}var TM=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],EM=new Set,DM,OM=`⠿`;function kM(e){return TM[Math.floor(e/90)%TM.length]}function AM(){let e=kM(Date.now());if(e!==OM){OM=e;for(let e of EM)e()}}function jM(e){return EM.add(e),DM===void 0&&(OM=kM(Date.now()),DM=setInterval(AM,90)),()=>{EM.delete(e),EM.size===0&&DM!==void 0&&(clearInterval(DM),DM=void 0)}}function MM(){return NM}function NM(){}function PM(){return OM}function FM(){return`⠿`}function IM(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);if(!e)return;t(e.matches);let n=()=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function LM(e){let t=IM(),n=e&&!t;return(0,v.useSyncExternalStore)(n?jM:MM,n?PM:FM,FM)}var RM=(0,v.createContext)(void 0),zM=(0,v.createContext)(void 0);function BM({names:e,children:t}){return(0,U.jsx)(RM.Provider,{value:e,children:t})}function VM({names:e,children:t}){return(0,U.jsx)(zM.Provider,{value:e,children:t})}function HM({text:e,className:t}){let n=$A(e,{skills:(0,v.useContext)(RM),sessions:(0,v.useContext)(zM)});if(n.length===0)return(0,U.jsx)(`span`,{className:t,children:e});let r=[],i=0;for(let[t,a]of n.entries())a.start>i&&r.push(e.slice(i,a.start)),r.push((0,U.jsx)(`span`,{className:W(`font-mono`,a.kind===`file`?`text-accent`:`text-info`),children:a.text},`${a.start}-${t}`)),i=a.end;return i<e.length&&r.push(e.slice(i)),(0,U.jsx)(`span`,{className:t,children:r.map((e,t)=>(0,U.jsx)(v.Fragment,{children:e},t))})}var UM=`output expired or not tracked by this gateway`;function WM(e){return e.label||e.command.split(`
|
|
50
50
|
`)[0]||``}function GM(e){return`#${e.ordinal} ${WM(e)}`}function KM(e){return WM(e.shell)}function qM(e){return YM(e.shell)}function JM(e){return e.status===`exited`&&e.exitCode!==0}function YM(e){if(e.status===`running`)return`running`;if(typeof e.exitCode==`number`)return e.exitCode===0?`exit 0`:`exit ${e.exitCode}`;switch(e.endReason){case`killed`:return`killed`;case`timeout`:return`timed out`;case`server_stopped`:return`killed: the gateway stopped`;case`server_restarted`:return`ended: the gateway restarted, the process may still be running`;case`spawn_failed`:return`failed to start`;default:return`ended`}}function XM(e){return JM(e.shell)}function ZM(e){return`${KM(e)} · ${qM(e)}`}function QM(e,t){let n=t&&e.expanded!==void 0?e.expanded:e.text;if(n===``)return[];let r=n.split(`
|
|
51
51
|
`);if(!t)return r;let i=[],a=0;for(let e of r){if(i.length>0&&a+e.length>1e5)break;i.push(e),a+=e.length+1}return i}function $M(e,t,n){if(e.missing)return UM;if(!t)return e.truncated?`… more output - expand to fetch it`:void 0;let r=e.expanded===void 0?void 0:e.expanded.split(`
|
|
52
52
|
`).length;if(r!==void 0&&r>n)return`… +${(r-n).toLocaleString()} lines not shown`;if(e.expanded===void 0&&e.truncated)return`… fetching the full output`}var eN={hover:!0,actions:!0},tN=(0,v.createContext)(eN);function nN(){return(0,v.useContext)(tN)}function rN(e){return e===!1?{hover:!1,actions:!1}:e===!0||e===void 0?eN:{...eN,...e}}function iN({value:e,children:t}){return(0,U.jsx)(tN.Provider,{value:e,children:t})}function aN({actions:e,children:t,className:n}){let{actions:r}=nN();return r?(0,U.jsxs)(`div`,{className:W(`term-hoverable`,n),children:[t,(0,U.jsx)(`div`,{className:`term-actions`,children:e})]}):(0,U.jsx)(U.Fragment,{children:t})}var oN=(0,v.createContext)(void 0);function sN({value:e,children:t}){return(0,U.jsx)(oN.Provider,{value:e,children:t})}function cN({id:e}){let t=(0,v.useContext)(oN);if(!t)return null;let n=t.has(e),r=n?`Remove bookmark`:`Bookmark`;return(0,U.jsx)(`button`,{type:`button`,className:`term-action`,title:r,"aria-label":r,"aria-pressed":n,onClick:n=>{n.stopPropagation(),t.toggle(e)},children:n?`★`:`☆`})}function lN({onOpen:e,label:t=`Open sub-agent`}){return(0,U.jsx)(`button`,{type:`button`,className:`term-action`,title:t,"aria-label":t,onClick:t=>{t.stopPropagation(),e()},children:`⤢`})}function uN({onOpen:e,label:t=`Open terminal`}){return(0,U.jsx)(`button`,{type:`button`,className:`term-action`,title:t,"aria-label":t,"data-tone":`magenta`,onClick:t=>{t.stopPropagation(),e()},children:`⤢`})}function dN({onKill:e,label:t=`Kill this shell`}){return(0,U.jsx)(`button`,{type:`button`,className:`term-action`,title:t,"aria-label":t,"data-tone":`red`,onClick:t=>{t.stopPropagation(),e()},children:`✕`})}function fN({text:e,label:t=`Copy`}){let[n,r]=(0,v.useState)(!1);return(0,U.jsx)(`button`,{type:`button`,className:`term-action`,title:t,"aria-label":t,onClick:t=>{t.stopPropagation(),HT(e).then(e=>{e&&(r(!0),setTimeout(()=>r(!1),1200))})},children:n?`✓`:`⧉`})}function pN({glyph:e,glyphTone:t,tone:n,bold:r,indent:i,columns:a,className:o,children:s,style:c,...l}){return(0,U.jsxs)(`div`,{className:W(`term-row`,o),"data-indent":i?String(i):void 0,"data-tone":n,"data-weight":r?`bold`:void 0,style:a===void 0?c:{...c,"--term-cell":`${a}ch`},...l,children:[(0,U.jsx)(`span`,{className:`term-gutter`,"data-tone":t,"aria-hidden":!0,children:e??` `}),(0,U.jsx)(`div`,{className:`term-body`,children:s})]})}function mN(){return(0,U.jsx)(`div`,{className:`term-blank`,"aria-hidden":!0})}function hN({className:e,...t}){return(0,U.jsx)(`div`,{className:W(`term-band`,e),...t})}function gN({tone:e,bold:t,className:n,...r}){return(0,U.jsx)(`span`,{"data-tone":e,"data-weight":t?`bold`:void 0,className:n,...r})}function _N(e){return e.startsWith(`+`)?`add`:e.startsWith(`-`)?`remove`:`context`}function vN(e){let t=e.oldStart,n=e.newStart,r=[];for(let i of e.lines){let e=_N(i),a=i.slice(1);e===`add`?r.push({kind:e,number:n++,text:a}):e===`remove`?r.push({kind:e,number:t++,text:a}):(r.push({kind:e,number:n,text:a}),t++,n++)}return r}var yN={context:` `,add:`+`,remove:`-`};function bN(e){let t=e,n=typeof t?.old_string==`string`?t.old_string:void 0,r=typeof t?.new_string==`string`?t.new_string:void 0;if(n===void 0&&r===void 0)return;let i=[...n?n.split(`
|
|
@@ -160,7 +160,7 @@ ${e}</tr>
|
|
|
160
160
|
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${qX(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=JX(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+qX(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=JX(e);if(i===null)return qX(n);e=i;let a=`<img src="${e}" alt="${qX(n)}"`;return t&&(a+=` title="${qX(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:qX(e.text)}},iZ=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},aZ=class e{options;renderer;textRenderer;constructor(e){this.options=e||PY,this.options.renderer=this.options.renderer||new rZ,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new iZ}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},oZ=class{options;block;constructor(e){this.options=e||PY}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?nZ.lex:nZ.lexInline}provideParser(e=this.block){return e?aZ.parse:aZ.parseInline}},sZ=new class{defaults=NY();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=aZ;Renderer=rZ;TextRenderer=iZ;Lexer=nZ;Tokenizer=tZ;Hooks=oZ;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new rZ(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new tZ(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new oZ;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=oZ.passThroughHooks.has(n)?e=>{if(this.defaults.async&&oZ.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return nZ.lex(e,t??this.defaults)}parser(e,t){return aZ.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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 t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?nZ.lex:nZ.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?aZ.parse:aZ.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?nZ.lex:nZ.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?aZ.parse:aZ.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
161
161
|
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+qX(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function cZ(e,t){return sZ.parse(e,t)}cZ.options=cZ.setOptions=function(e){return sZ.setOptions(e),cZ.defaults=sZ.defaults,FY(cZ.defaults),cZ},cZ.getDefaults=NY,cZ.defaults=PY,cZ.use=function(...e){return sZ.use(...e),cZ.defaults=sZ.defaults,FY(cZ.defaults),cZ},cZ.walkTokens=function(e,t){return sZ.walkTokens(e,t)},cZ.parseInline=sZ.parseInline,cZ.Parser=aZ,cZ.parser=aZ.parse,cZ.Renderer=rZ,cZ.TextRenderer=iZ,cZ.Lexer=nZ,cZ.lexer=nZ.lex,cZ.Tokenizer=tZ,cZ.Hooks=oZ,cZ.parse=cZ,cZ.options,cZ.setOptions,cZ.use,cZ.walkTokens,cZ.parseInline,aZ.parse,nZ.lex;var lZ=300,uZ=`300px`,dZ=500;function fZ(e={}){let{immediate:t=!1,debounceDelay:n=lZ,rootMargin:r=uZ,idleTimeout:i=dZ}=e,[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null),c=(0,v.useRef)(null),l=(0,v.useRef)(null),u=(0,v.useMemo)(()=>e=>{let t=Date.now();return window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1)},[]),d=(0,v.useMemo)(()=>typeof window<`u`&&window.requestIdleCallback?(e,t)=>window.requestIdleCallback(e,t):u,[u]),f=(0,v.useMemo)(()=>typeof window<`u`&&window.cancelIdleCallback?e=>window.cancelIdleCallback(e):e=>{clearTimeout(e)},[]);return(0,v.useEffect)(()=>{if(t){o(!0);return}let e=s.current;if(!e)return;c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null);let a=()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null)},u=e=>{l.current=d(t=>{t.timeRemaining()>0||t.didTimeout?(o(!0),e.disconnect()):l.current=d(()=>{o(!0),e.disconnect()},{timeout:i/2})},{timeout:i})},p=e=>{a(),c.current=window.setTimeout(()=>{var t;let n=e.takeRecords();(n.length===0||(t=n.at(-1)?.isIntersecting)!=null&&t)&&u(e)},n)},m=(e,t)=>{e.isIntersecting?p(t):a()},h=new IntersectionObserver(e=>{for(let t of e)m(t,h)},{rootMargin:r,threshold:0});return h.observe(e),()=>{c.current&&clearTimeout(c.current),l.current&&f(l.current),h.disconnect()}},[t,n,r,i,f,d]),{shouldRender:a,containerRef:s}}var pZ=320,mZ=4,hZ=()=>typeof performance>`u`?Date.now():performance.now();function gZ(e){let t=e?.now??hZ,n=e?.maxBacklogMs??pZ,r=0,i=0;return{now:t,beginPass(e){i=Math.min(Math.max(r,e),e+n)},mark(){return i},rewind(e){i=e},take(e,t,r){if(e<=0)return{baseDelay:0,step:Math.max(0,t)};let a=Math.max(0,t),o=a===0?0:Math.min(a,mZ),s=Math.max(i,r),c=r+n,l=s+Math.max(0,e-1)*a,u=a;if(l>c&&e>1){if(s<c){let t=c-s;u=Math.max(o,t/(e-1))}else u=o}let d=Math.max(0,Math.round(s-r));return i=s+e*u,{baseDelay:d,step:u}},commitPass(){r=i}}}var _Z=/\s/,vZ=/^\s+$/,yZ=new Set([`pre`,`svg`,`math`,`annotation`]),bZ=new Set([`img`,`hr`]),xZ=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`element`,SZ=e=>e.some(e=>xZ(e)&&yZ.has(e.tagName)),CZ=e=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(xZ(n)&&n.tagName===`li`)return n}},wZ=(e,t,n,r)=>{e.properties??={},e.properties[`data-sd-animate-marker`]=!0;let i=typeof e.properties.style==`string`?`${e.properties.style};`:``;e.properties.style=`${i}--sd-marker-duration:${t}ms;--sd-marker-delay:${Math.round(n)}ms;--sd-marker-easing:${r}`},TZ=new Set([`ul`,`ol`,`li`]),EZ=e=>{for(let t of e.children)if(xZ(t)){if(t.tagName===`input`)return t;if(TZ.has(t.tagName))continue;let e=EZ(t);if(e)return e}},DZ=(e,t,n,r)=>{e.properties??={},e.properties[`data-sd-animate`]=!0;let i=typeof e.properties.style==`string`?`${e.properties.style};`:``;e.properties.style=`${i}--sd-animation:sd-${t.animation};--sd-duration:${n}ms;--sd-easing:${t.easing};--sd-delay:${Math.round(r)}ms`},OZ=(e,t,n,r)=>{let i=EZ(e);i&&DZ(i,t,n,r)},kZ=(e,t,n,r,i,a)=>{if(SZ(t))return;let o=r.prevContentLength,s=i.count;i.count+=1;let c=o>0&&s<o,l=c?0:a.baseDelay+i.newIndex++*a.step;DZ(e,n,c?0:n.duration,l)},AZ=e=>{var t;for(let n=e.length-1;n>=0;--n){let r=e[n];if(xZ(r)){if((t=r.properties)!=null&&t[`data-sd-animated`])break;r.properties={...r.properties,"data-sd-animated":!0}}}},jZ=e=>{let t=[],n=``,r=!1;for(let i of e){let e=_Z.test(i);if(e!==r&&n){if(e){n+=i,r=!0;continue}t.push(n),n=``}n+=i,r=e}return n&&t.push(n),t},MZ=e=>{let t=[],n=``;for(let r of e)_Z.test(r)?t.length>0&&!vZ.test(t.at(-1))?t[t.length-1]+=r:n+=r:(n&&=(t.push(n),``),t.push(r));return n&&(t.length>0?t[t.length-1]+=n:t.push(n)),t},NZ=(e,t,n,r,i,a)=>{let o=`--sd-animation:sd-${t};--sd-duration:${i?0:n}ms;--sd-easing:${r}`;return a&&(o+=`;--sd-delay:${Math.round(a)}ms`),{type:`element`,tagName:`span`,properties:{"data-sd-animate":!0,style:o},children:[{type:`text`,value:e}]}},PZ=(e,t)=>!(e>0&&t<e),FZ=e=>xZ(e)&&bZ.has(e.tagName),IZ=(e,t,n)=>{let r=0,i=0;return MN(e,e=>e.type===`text`||FZ(e),(e,a)=>{if(SZ(a))return jN;if(FZ(e)){PZ(n,i)&&(r+=1),i+=1;return}let o=e.value;if(!o.trim()){i+=o.length;return}let s=t.sep===`char`?MZ(o):jZ(o);for(let e of s){let t=i;i+=e.length,!vZ.test(e)&&PZ(n,t)&&(r+=1)}}),r},LZ=(e,t,n,r,i,a)=>{var o;let s=t.at(-1);if(!(s&&`children`in s))return;if(SZ(t))return jN;let c=s,l=c.children.indexOf(e);if(l===-1)return;let u=e.value;if(!u.trim()){i.count+=u.length;return}let d=n.sep===`char`?MZ(u):jZ(u),f=r.prevContentLength,p=!1,m=CZ(t),h=!(!m||(o=m.properties)!=null&&o[`data-sd-animate-marker`]),g=!1,_=d.map(e=>{let t=i.count;if(i.count+=e.length,vZ.test(e))return{type:`text`,value:e};let r=f>0&&t<f,o=r?0:a.baseDelay+i.newIndex++*a.step;if(p=!0,m&&h&&!g){let e=r?0:n.duration;wZ(m,e,o,n.easing),OZ(m,n,e,o),g=!0}return NZ(e,n.animation,n.duration,n.easing,r,o)});return p&&AZ(t),c.children.splice(l,1,..._),l+_.length},RZ=0;function zZ(e){let t={animation:e?.animation??`fadeIn`,duration:e?.duration??150,easing:e?.easing??`ease`,sep:e?.sep??`word`,stagger:e?.stagger??40,timeline:e?.timeline},n={committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null},r=RZ++,i=()=>e=>{let r={count:0,newIndex:0};n.prevContentLength=n.committedCharCount;let i=t.timeline,a=i?.now()??hZ();i&&(n.pendingMark===null?n.pendingMark=i.mark():i.rewind(n.pendingMark));let o=i?i.take(IZ(e,t,n.prevContentLength),t.stagger,a):{baseDelay:0,step:t.stagger};MN(e,e=>e.type===`text`||FZ(e),(e,i)=>{if(e.type===`text`)return LZ(e,i,t,n,r,o);kZ(e,i,t,n,r,o)}),n.lastRenderCharCount=r.count,n.prevContentLength=0};return Object.defineProperty(i,"name",{value:`rehypeAnimate$${r}`}),{name:`animate`,type:`animate`,rehypePlugin:i,setPrevContentLength(e){n.committedCharCount=e,n.prevContentLength=e},getLastRenderCharCount(){return n.lastRenderCharCount},commit(){n.committedCharCount=n.lastRenderCharCount,n.pendingMark=null}}}zZ();var BZ=(0,v.createContext)(!1),VZ=()=>(0,v.useContext)(BZ),HZ=(...e)=>oo(Si(e)),UZ=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(t=>t.startsWith(n)?t:`${e}:${t}`).join(` `)},WZ=e=>e?(...t)=>UZ(e,oo(Si(t))):HZ,GZ=(e,t,n)=>{let r=typeof t==`string`&&n.startsWith(`text/csv`)?``:``,i=typeof t==`string`?new Blob([r+t],{type:n}):t,a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},KZ=(0,v.createContext)(HZ),qZ=()=>(0,v.useContext)(KZ),JZ=8,YZ=e=>{if(e!==void 0&&e!==0&&e!==1/0){if(typeof e==`number`)return Number.isFinite(e)&&e>0?`${e}px`:void 0;if(e!==`0`&&e!==`none`&&e!==`Infinity`)return e}},XZ=(e,t,n)=>{let r=(0,v.useRef)(null),i=(0,v.useRef)(!0),a=(0,v.useRef)(!1);return(0,v.useEffect)(()=>{let e=r.current;if(!(e&&t))return;let n=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight<JZ;i.current=t};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[t]),(0,v.useEffect)(()=>{e&&!a.current&&(i.current=!0),e||(i.current=!0),a.current=e},[e]),(0,v.useEffect)(()=>{let n=r.current;n&&t&&e&&i.current&&n.scrollTo({top:n.scrollHeight,behavior:`instant`})},[e,t,n]),r},ZZ=HZ(`block`),QZ=HZ(`block`,`before:content-[counter(line)]`,`before:inline-block`,`before:[counter-increment:line]`,`before:w-6`,`before:mr-4`,`before:text-[13px]`,`before:text-right`,`before:text-muted-foreground/50`,`before:font-mono`,`before:select-none`),$Z=e=>{let t={};for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}}return t},eQ=(0,v.memo)(({children:e,result:t,language:n,className:r,maxHeight:i,startLine:a,lineNumbers:o=!0,...s})=>{let c=qZ(),{isAnimating:l}=(0,v.useContext)(L1),u=YZ(i),d=XZ(l,!!u,t),f=(0,v.useMemo)(()=>c(QZ),[c]),p=(0,v.useMemo)(()=>c(ZZ),[c]),m=(0,v.useMemo)(()=>{let e={};return t.bg&&(e[`--sdm-bg`]=t.bg),t.fg&&(e[`--sdm-fg`]=t.fg),t.rootStyle&&Object.assign(e,$Z(t.rootStyle)),e},[t.bg,t.fg,t.rootStyle]);return(0,U.jsx)(`div`,{className:c(r,u?`overflow-y-auto`:null,`overflow-x-auto rounded-md border border-border bg-background p-4 text-sm`),"data-language":n,"data-streamdown":`code-block-body`,ref:d,style:u?{maxHeight:u}:void 0,...s,children:(0,U.jsx)(`pre`,{className:c(r,`bg-[var(--sdm-bg,inherit)]`,`dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]`),style:m,children:(0,U.jsx)(`code`,{className:o?c(`[counter-increment:line_0] [counter-reset:line]`):void 0,style:o&&a&&a>1?{counterReset:`line ${a-1}`}:void 0,children:t.tokens.map((e,t)=>(0,U.jsx)(`span`,{className:o?f:p,children:e.length===0||e.length===1&&e[0].content===``?`
|
|
162
162
|
`:e.map((e,t)=>{let n={},r=!!e.bgColor;if(e.color&&(n[`--sdm-c`]=e.color),e.bgColor&&(n[`--sdm-tbg`]=e.bgColor),e.htmlStyle)for(let[t,i]of Object.entries(e.htmlStyle))t===`color`?n[`--sdm-c`]=i:t===`background-color`?(n[`--sdm-tbg`]=i,r=!0):n[t]=i;return(0,U.jsx)(`span`,{className:c(`text-[var(--sdm-c,inherit)]`,`dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]`,r&&`bg-[var(--sdm-tbg)]`,r&&`dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]`),style:n,...e.htmlAttrs,children:e.content},t)})},t))})})})}),tQ=({className:e,language:t,style:n,isIncomplete:r,...i})=>{let a=qZ();return(0,U.jsx)(`div`,{className:a(`my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,e),"data-incomplete":r||void 0,"data-language":t,"data-streamdown":`code-block`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 200px`,...n},...i})},nQ=(0,v.createContext)({code:``}),rQ=()=>(0,v.useContext)(nQ),iQ=({language:e})=>{let t=qZ();return(0,U.jsx)(`div`,{className:t(`flex h-8 items-center text-muted-foreground text-xs`),"data-language":e,"data-streamdown":`code-block-header`,children:(0,U.jsx)(`span`,{className:t(`ml-1 font-mono lowercase`),children:e})})},aQ=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
163
|
-
`;)t--;return e.slice(0,t)},oQ=(0,v.lazy)(()=>Ij(()=>import(`./highlighted-body-KPVGNVTW-
|
|
163
|
+
`;)t--;return e.slice(0,t)},oQ=(0,v.lazy)(()=>Ij(()=>import(`./highlighted-body-KPVGNVTW-CfDzUpBA.js`).then(e=>({default:e.HighlightedCodeBlockBody})),[])),sQ=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=qZ(),{codeBlockMaxHeight:l}=(0,v.useContext)(L1),u=(0,v.useMemo)(()=>aQ(e),[e]),d=(0,v.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:u.split(`
|
|
164
164
|
`).map(e=>[{content:e,color:`inherit`,bgColor:`transparent`,htmlStyle:{},offset:0}])}),[u]);return(0,U.jsx)(nQ.Provider,{value:{code:e},children:(0,U.jsxs)(tQ,{dir:`ltr`,isIncomplete:i,language:t,children:[(0,U.jsx)(iQ,{language:t}),r?(0,U.jsx)(`div`,{className:c(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,U.jsx)(`div`,{className:c(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`code-block-actions`,children:r})}):null,(0,U.jsx)(v.Suspense,{fallback:(0,U.jsx)(eQ,{className:n,language:t,lineNumbers:o,maxHeight:l,result:d,startLine:a,...s}),children:(0,U.jsx)(oQ,{className:n,code:u,language:t,lineNumbers:o,maxHeight:l,raw:d,startLine:a,...s})})]})})},cQ={CheckIcon:e=>(0,U.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,U.jsx)(`path`,{clipRule:`evenodd`,d:`M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z`,fill:`currentColor`,fillRule:`evenodd`})}),CopyIcon:e=>(0,U.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,U.jsx)(`path`,{clipRule:`evenodd`,d:`M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),DownloadIcon:e=>(0,U.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,U.jsx)(`path`,{clipRule:`evenodd`,d:`M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),ExternalLinkIcon:e=>(0,U.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,U.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z`,fill:`currentColor`,fillRule:`evenodd`})}),Loader2Icon:e=>(0,U.jsxs)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:[(0,U.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,U.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,U.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,U.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,U.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,U.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,U.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,U.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,U.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,U.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),Maximize2Icon:e=>(0,U.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,U.jsx)(`path`,{clipRule:`evenodd`,d:`M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z`,fill:`currentColor`,fillRule:`evenodd`})}),RotateCcwIcon:e=>(0,U.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,U.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z`,fill:`currentColor`,fillRule:`evenodd`})}),XIcon:e=>(0,U.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,U.jsx)(`path`,{clipRule:`evenodd`,d:`M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomInIcon:e=>(0,U.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,U.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomOutIcon:e=>(0,U.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,U.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})})},lQ=(0,v.createContext)(cQ),uQ=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])},dQ=({icons:e,children:t})=>{let n=(0,v.useRef)(e),r=(0,v.useRef)(e?{...cQ,...e}:cQ);uQ(n.current,e)||(n.current=e,r.current=e?{...cQ,...e}:cQ);let i=r.current;return(0,U.jsx)(lQ.Provider,{value:i,children:t})},fQ=()=>(0,v.useContext)(lQ),pQ={copyCode:`Copy Code`,downloadFile:`Download file`,downloadDiagram:`Download diagram`,downloadDiagramAsSvg:`Download diagram as SVG`,downloadDiagramAsPng:`Download diagram as PNG`,downloadDiagramAsMmd:`Download diagram as MMD`,viewFullscreen:`View fullscreen`,exitFullscreen:`Exit fullscreen`,mermaidFormatSvg:`SVG`,mermaidFormatPng:`PNG`,mermaidFormatMmd:`MMD`,zoomIn:`Zoom in`,zoomOut:`Zoom out`,resetView:`Reset zoom and pan`,copyTable:`Copy table`,copyTableAsMarkdown:`Copy table as Markdown`,copyTableAsCsv:`Copy table as CSV`,copyTableAsTsv:`Copy table as TSV`,downloadTable:`Download table`,downloadTableAsCsv:`Download table as CSV`,downloadTableAsMarkdown:`Download table as Markdown`,tableFormatMarkdown:`Markdown`,tableFormatCsv:`CSV`,tableFormatTsv:`TSV`,imageNotAvailable:`Image not available`,downloadImage:`Download image`,openExternalLink:`Open external link?`,externalLinkWarning:`You're about to visit an external website.`,close:`Close`,copyLink:`Copy link`,copied:`Copied`,openLink:`Open link`},mQ=(0,v.createContext)(pQ),hQ=()=>(0,v.useContext)(mQ),gQ=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let s=qZ(),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(0),{code:d}=rQ(),{isAnimating:f}=(0,v.useContext)(L1),p=hQ(),m=a??d,h=async()=>{var r;if(typeof window>`u`||!((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)){t?.(Error(`Clipboard API not available`));return}try{c||(await navigator.clipboard.writeText(m),l(!0),e?.(),u.current=window.setTimeout(()=>l(!1),n))}catch(e){t?.(e)}};(0,v.useEffect)(()=>()=>{window.clearTimeout(u.current)},[]);let g=fQ(),_=c?g.CheckIcon:g.CopyIcon;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{"aria-label":p.copyCode,className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-copy-button`,disabled:f,onClick:h,title:p.copyCode,type:`button`,...o,children:r??(0,U.jsx)(_,{"aria-hidden":`true`,size:14})}),c&&(0,U.jsx)(`output`,{"aria-live":`polite`,className:`sr-only`,children:p.copied})]})},_Q=(e,t,n)=>{if(typeof e==`boolean`)return n;let r=e[t];if(typeof r!=`object`)return n;let i=r.download;return typeof i==`object`&&i.filename||n},vQ={"1c":`1c`,"1c-query":`1cq`,abap:`abap`,"actionscript-3":`as`,ada:`ada`,adoc:`adoc`,"angular-html":`html`,"angular-ts":`ts`,apache:`conf`,apex:`cls`,apl:`apl`,applescript:`applescript`,ara:`ara`,asciidoc:`adoc`,asm:`asm`,astro:`astro`,awk:`awk`,ballerina:`bal`,bash:`sh`,bat:`bat`,batch:`bat`,be:`be`,beancount:`beancount`,berry:`berry`,bibtex:`bib`,bicep:`bicep`,blade:`blade.php`,bsl:`bsl`,c:`c`,"c#":`cs`,"c++":`cpp`,cadence:`cdc`,cairo:`cairo`,cdc:`cdc`,clarity:`clar`,clj:`clj`,clojure:`clj`,"closure-templates":`soy`,cmake:`cmake`,cmd:`cmd`,cobol:`cob`,codeowners:`CODEOWNERS`,codeql:`ql`,coffee:`coffee`,coffeescript:`coffee`,"common-lisp":`lisp`,console:`sh`,coq:`v`,cpp:`cpp`,cql:`cql`,crystal:`cr`,cs:`cs`,csharp:`cs`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cql`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,docker:`dockerfile`,dockerfile:`dockerfile`,dotenv:`env`,"dream-maker":`dm`,edge:`edge`,elisp:`el`,elixir:`ex`,elm:`elm`,"emacs-lisp":`el`,erb:`erb`,erl:`erl`,erlang:`erl`,f:`f`,"f#":`fs`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`f90`,f95:`f95`,fennel:`fnl`,fish:`fish`,fluent:`ftl`,for:`for`,"fortran-fixed-form":`f`,"fortran-free-form":`f90`,fs:`fs`,fsharp:`fs`,fsl:`fsl`,ftl:`ftl`,gdresource:`tres`,gdscript:`gd`,gdshader:`gdshader`,genie:`gs`,gherkin:`feature`,"git-commit":`gitcommit`,"git-rebase":`gitrebase`,gjs:`js`,gleam:`gleam`,"glimmer-js":`js`,"glimmer-ts":`ts`,glsl:`glsl`,gnuplot:`plt`,go:`go`,gql:`gql`,graphql:`graphql`,groovy:`groovy`,gts:`gts`,hack:`hack`,haml:`haml`,handlebars:`hbs`,haskell:`hs`,haxe:`hx`,hbs:`hbs`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,hs:`hs`,html:`html`,"html-derivative":`html`,http:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,jade:`jade`,java:`java`,javascript:`js`,jinja:`jinja`,jison:`jison`,jl:`jl`,js:`js`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,julia:`jl`,kotlin:`kt`,kql:`kql`,kt:`kt`,kts:`kts`,kusto:`kql`,latex:`tex`,lean:`lean`,lean4:`lean`,less:`less`,liquid:`liquid`,lisp:`lisp`,lit:`lit`,llvm:`ll`,log:`log`,logo:`logo`,lua:`lua`,luau:`luau`,make:`mak`,makefile:`mak`,markdown:`md`,marko:`marko`,matlab:`m`,md:`md`,mdc:`mdc`,mdx:`mdx`,mediawiki:`wiki`,mermaid:`mmd`,mips:`s`,mipsasm:`s`,mmd:`mmd`,mojo:`mojo`,move:`move`,nar:`nar`,narrat:`narrat`,nextflow:`nf`,nf:`nf`,nginx:`conf`,nim:`nim`,nix:`nix`,nu:`nu`,nushell:`nu`,objc:`m`,"objective-c":`m`,"objective-cpp":`mm`,ocaml:`ml`,pascal:`pas`,perl:`pl`,perl6:`p6`,php:`php`,plsql:`pls`,po:`po`,polar:`polar`,postcss:`pcss`,pot:`pot`,potx:`potx`,powerquery:`pq`,powershell:`ps1`,prisma:`prisma`,prolog:`pl`,properties:`properties`,proto:`proto`,protobuf:`proto`,ps:`ps`,ps1:`ps1`,pug:`pug`,puppet:`pp`,purescript:`purs`,py:`py`,python:`py`,ql:`ql`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,racket:`rkt`,raku:`raku`,razor:`cshtml`,rb:`rb`,reg:`reg`,regex:`regex`,regexp:`regexp`,rel:`rel`,riscv:`s`,rs:`rs`,rst:`rst`,ruby:`rb`,rust:`rs`,sas:`sas`,sass:`sass`,scala:`scala`,scheme:`scm`,scss:`scss`,sdbl:`sdbl`,sh:`sh`,shader:`shader`,shaderlab:`shader`,shell:`sh`,shellscript:`sh`,shellsession:`sh`,smalltalk:`st`,solidity:`sol`,soy:`soy`,sparql:`rq`,spl:`spl`,splunk:`spl`,sql:`sql`,"ssh-config":`config`,stata:`do`,styl:`styl`,stylus:`styl`,svelte:`svelte`,swift:`swift`,"system-verilog":`sv`,systemd:`service`,talon:`talon`,talonscript:`talon`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,terraform:`tf`,tex:`tex`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`ts`,"ts-tags":`ts`,tsp:`tsp`,tsv:`tsv`,tsx:`tsx`,turtle:`ttl`,twig:`twig`,typ:`typ`,typescript:`ts`,typespec:`tsp`,typst:`typ`,v:`v`,vala:`vala`,vb:`vb`,verilog:`v`,vhdl:`vhdl`,vim:`vim`,viml:`vim`,vimscript:`vim`,vue:`vue`,"vue-html":`html`,"vue-vine":`vine`,vy:`vy`,vyper:`vy`,wasm:`wasm`,wenyan:`wy`,wgsl:`wgsl`,wiki:`wiki`,wikitext:`wiki`,wit:`wit`,wl:`wl`,wolfram:`wl`,xml:`xml`,xsl:`xsl`,yaml:`yaml`,yml:`yml`,zenscript:`zs`,zig:`zig`,zsh:`zsh`,文言:`wy`},yQ=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=qZ(),{code:c}=rQ(),{isAnimating:l,controls:u}=(0,v.useContext)(L1),d=hQ(),f=fQ(),p=a??c,m=n&&n in vQ?vQ[n]:`txt`,h=`${_Q(u,`code`,`file`)}.${m}`;return(0,U.jsx)(`button`,{"aria-label":d.downloadFile,className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-download-button`,disabled:l,onClick:()=>{try{GZ(h,p,`text/plain`),e?.()}catch(e){t?.(e)}},title:d.downloadFile,type:`button`,...o,children:r??(0,U.jsx)(f.DownloadIcon,{size:14})})},bQ=()=>{let{Loader2Icon:e}=fQ(),t=qZ();return(0,U.jsxs)(`div`,{className:t(`w-full divide-y divide-border overflow-hidden rounded-xl border border-border`),children:[(0,U.jsx)(`div`,{className:t(`h-[46px] w-full bg-muted/80`)}),(0,U.jsx)(`div`,{className:t(`flex w-full items-center justify-center p-4`),children:(0,U.jsx)(e,{className:t(`size-4 animate-spin`)})})]})},xQ=/\.[^/.]+$/,SQ=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,showControls:o=!0,showDownloadControl:s=!0,...c})=>{let{DownloadIcon:l}=fQ(),u=qZ(),d=(0,v.useRef)(null),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),g=hQ(),_=c.width!=null||c.height!=null,y=(f||_)&&!m&&o&&s,b=m&&!_;(0,v.useEffect)(()=>{let e=d.current;if(e!=null&&e.complete){let t=e.naturalWidth>0;p(t),h(!t)}},[]);let x=(0,v.useCallback)(e=>{p(!0),h(!1),i?.(e)},[i]),S=(0,v.useCallback)(e=>{p(!1),h(!0),a?.(e)},[a]),C=async()=>{if(n)try{let e=await(await fetch(n)).blob(),t=new URL(n,window.location.origin).pathname.split(`/`).pop()||``,i=t.split(`.`).pop(),a=t.includes(`.`)&&i!==void 0&&i.length<=4,o=``;if(a)o=t;else{let n=e.type,i=`png`;n.includes(`jpeg`)||n.includes(`jpg`)?i=`jpg`:n.includes(`png`)?i=`png`:n.includes(`svg`)?i=`svg`:n.includes(`gif`)?i=`gif`:n.includes(`webp`)&&(i=`webp`),o=`${(r||t||`image`).replace(xQ,``)}.${i}`}GZ(o,e,e.type)}catch{window.open(n,`_blank`)}};return n?(0,U.jsxs)(`div`,{className:u(`group relative my-4 inline-block`),"data-streamdown":`image-wrapper`,children:[(0,U.jsx)(`img`,{alt:r,className:u(`max-w-full rounded-lg`,b&&`hidden`,t),"data-streamdown":`image`,onError:S,onLoad:x,ref:d,src:n,...c}),b&&(0,U.jsx)(`span`,{className:u(`text-muted-foreground text-xs italic`),"data-streamdown":`image-fallback`,children:g.imageNotAvailable}),o&&(0,U.jsx)(`div`,{className:u(`pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block`),"data-streamdown":`image-overlay`}),y&&(0,U.jsx)(`button`,{className:u(`absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background`,`opacity-0 group-hover:opacity-100`),onClick:C,title:g.downloadImage,type:`button`,children:(0,U.jsx)(l,{size:14})})]}):null},CQ=0,wQ=()=>{CQ+=1,CQ===1&&(document.body.style.overflow=`hidden`)},TQ=()=>{CQ=Math.max(0,CQ-1),CQ===0&&(document.body.style.overflow=``)},EQ=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=fQ(),c=qZ(),[l,u]=(0,v.useState)(!1),d=hQ(),f=(0,v.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[e]),p=(0,v.useCallback)(()=>{r(),n()},[r,n]);if((0,v.useEffect)(()=>{if(t){wQ();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),TQ()}}},[t,n]),!t||typeof document>`u`)return null;let m=(0,U.jsx)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm`),"data-streamdown":`link-safety-modal`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`button`,tabIndex:0,children:(0,U.jsxs)(`div`,{className:c(`relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,U.jsx)(`button`,{className:c(`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:n,title:d.close,type:`button`,children:(0,U.jsx)(s,{size:16})}),(0,U.jsxs)(`div`,{className:c(`flex flex-col gap-2`),children:[(0,U.jsxs)(`div`,{className:c(`flex items-center gap-2 font-semibold text-lg`),children:[(0,U.jsx)(o,{size:20}),(0,U.jsx)(`span`,{children:d.openExternalLink})]}),(0,U.jsx)(`p`,{className:c(`text-muted-foreground text-sm`),children:d.externalLinkWarning})]}),(0,U.jsx)(`div`,{className:c(`break-all rounded-md bg-muted p-3 font-mono text-sm`,e.length>100&&`max-h-32 overflow-y-auto`),children:e}),(0,U.jsxs)(`div`,{className:c(`flex gap-2`),children:[(0,U.jsx)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted`),onClick:f,type:`button`,children:l?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(i,{size:14}),(0,U.jsx)(`span`,{children:d.copied})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a,{size:14}),(0,U.jsx)(`span`,{children:d.copyLink})]})}),(0,U.jsxs)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90`),onClick:p,type:`button`,children:[(0,U.jsx)(o,{size:14}),(0,U.jsx)(`span`,{children:d.openLink})]})]})]})});return(0,Ed.createPortal)(m,document.body)},DQ=(0,v.createContext)(null),OQ=()=>(0,v.useContext)(DQ),kQ=()=>OQ()?.code??null,AQ=()=>OQ()?.mermaid??null,jQ=e=>{var t;let n=OQ();return n!=null&&n.renderers&&e&&(t=n.renderers.find(t=>Array.isArray(t.language)?t.language.includes(e):t.language===e))!=null?t:null},MQ=e=>{if(typeof DOMParser>`u`||typeof XMLSerializer>`u`)return e;let t=new DOMParser().parseFromString(e,`text/html`).querySelector(`svg`);return t?new XMLSerializer().serializeToString(t):e},NQ=(e,t)=>new Promise((t,n)=>{let r=`data:image/svg+xml;base64,`+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{let e=document.createElement(`canvas`),r=i.width*5,a=i.height*5;e.width=r,e.height=a;let o=e.getContext(`2d`);if(!o){n(Error(`Failed to create 2D canvas context for PNG export`));return}o.drawImage(i,0,0,r,a),e.toBlob(e=>{if(!e){n(Error(`Failed to create PNG blob`));return}t(e)},`image/png`)},i.onerror=()=>n(Error(`Failed to load SVG image`)),i.src=r}),PQ=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let o=qZ(),[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(null),{isAnimating:u,controls:d}=(0,v.useContext)(L1),f=fQ(),p=AQ(),m=hQ(),h=_Q(d,`mermaid`,`diagram`),g=async t=>{try{if(t===`mmd`){GZ(`${h}.mmd`,e,`text/plain`),c(!1),r?.(t);return}if(!p){a?.(Error(`Mermaid plugin not available`));return}let n=p.getMermaid(i),o=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),s=`mermaid-${Math.abs(o)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:l}=await n.render(s,e);if(!l){a?.(Error(`SVG not found. Please wait for the diagram to render.`));return}let u=MQ(l);if(t===`svg`){GZ(`${h}.svg`,u,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){let e=await NQ(u);GZ(`${h}.png`,e,`image/png`),r?.(t),c(!1);return}}catch(e){a?.(e)}};return(0,v.useEffect)(()=>{let e=e=>{let t=e.composedPath();l.current&&!t.includes(l.current)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,U.jsxs)(`div`,{className:o(`relative`),ref:l,children:[(0,U.jsx)(`button`,{"aria-label":m.downloadDiagram,className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),disabled:u,onClick:()=>c(!s),title:m.downloadDiagram,type:`button`,children:t??(0,U.jsx)(f.DownloadIcon,{"aria-hidden":`true`,size:14})}),s?(0,U.jsxs)(`div`,{className:o(`absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,U.jsx)(`button`,{"aria-label":m.downloadDiagramAsSvg,className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>g(`svg`),title:m.downloadDiagramAsSvg,type:`button`,children:m.mermaidFormatSvg}),(0,U.jsx)(`button`,{"aria-label":m.downloadDiagramAsPng,className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>g(`png`),title:m.downloadDiagramAsPng,type:`button`,children:m.mermaidFormatPng}),(0,U.jsx)(`button`,{"aria-label":m.downloadDiagramAsMmd,className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>g(`mmd`),title:m.downloadDiagramAsMmd,type:`button`,children:m.mermaidFormatMmd})]}):null]})},FQ=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=fQ(),c=qZ(),[l,u]=(0,v.useState)(!1),{isAnimating:d,controls:f}=(0,v.useContext)(L1),p=hQ(),m=(()=>{if(typeof f==`boolean`)return f;let e=f.mermaid;return e===!1?!1:e===!0||e===void 0||e.panZoom!==!1})(),h=(()=>{if(typeof f==`boolean`)return f;let e=f.mermaid;return e===!1?!1:e===!0||e===void 0||e.download!==!1})(),g=(()=>{if(typeof f==`boolean`)return f;let e=f.mermaid;return e===!1?!1:e===!0||e===void 0||e.copy!==!1})(),_=()=>{u(!l)};return(0,v.useEffect)(()=>{if(l){wQ();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),TQ()}}},[l]),(0,v.useEffect)(()=>{l?n?.():r&&r()},[l,n,r]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{className:c(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),disabled:d,onClick:_,title:p.viewFullscreen,type:`button`,...a,"aria-label":p.viewFullscreen,children:(0,U.jsx)(o,{"aria-hidden":`true`,size:14})}),l?(0,Ed.createPortal)((0,U.jsxs)(`div`,{"aria-label":p.viewFullscreen,"aria-modal":`true`,className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm`),"data-streamdown":`mermaid-fullscreen`,onClick:_,onKeyDown:e=>{e.key===`Escape`&&_()},role:`dialog`,children:[(0,U.jsxs)(`div`,{className:c(`absolute top-4 right-4 z-10 flex items-center gap-1`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[h?(0,U.jsx)(PQ,{chart:e,config:t}):null,g?(0,U.jsx)(gQ,{code:e}):null,(0,U.jsx)(`button`,{"aria-label":p.exitFullscreen,className:c(`rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:_,title:p.exitFullscreen,type:`button`,children:(0,U.jsx)(s,{"aria-hidden":`true`,size:20})})]}),(0,U.jsx)(`div`,{className:c(`flex size-full items-center justify-center p-4`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:(0,U.jsx)(V1,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:m})})]}),document.body):null]})};function IQ(e){if(e.nodeType===Node.TEXT_NODE)return e.textContent??``;if(e.nodeType!==Node.ELEMENT_NODE)return``;let t=e;return t.tagName===`BR`?`
|
|
165
165
|
`:Array.from(t.childNodes).map(IQ).join(``)}var LQ=e=>{let t=[],n=[],r=e.querySelectorAll(`thead th`);for(let e of r)t.push(IQ(e).trim());let i=e.querySelectorAll(`tbody tr`);for(let e of i){let t=[],r=e.querySelectorAll(`td`);for(let e of r)t.push(IQ(e).trim());n.push(t)}return{headers:t,rows:n}},RQ=e=>{if(typeof e!=`object`)return`,`;let t=e.table;return typeof t==`object`?t.csvSeparator??`,`:`,`},zQ=(e,t=`,`)=>{let n;n=t===`auto`?Intl.NumberFormat().format(1.1).includes(`,`)?`;`:`,`:t;let{headers:r,rows:i}=e,a=e=>{let t=!1;for(let r of e)if(r===n||r===`"`||r===`
|
|
166
166
|
`||r===`\r`){t=!0;break}return t?`"${e.replace(/"/g,`""`)}"`:e},o=r.length>0?i.length+1:i.length,s=Array(o),c=0;r.length>0&&(s[c]=r.map(a).join(n),c+=1);for(let e of i)s[c]=e.map(a).join(n),c+=1;return s.join(`
|
|
@@ -170,7 +170,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
170
170
|
`)},VQ=e=>{let t=!1;for(let n of e)if(n===`\\`||n===`|`||n===`
|
|
171
171
|
`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===`\\`?n.push(`\\\\`):t===`|`?n.push(`\\|`):t===`
|
|
172
172
|
`?n.push(`<br>`):n.push(t);return n.join(``)},HQ=e=>{let{headers:t,rows:n}=e;if(t.length===0)return``;let r=Array(n.length+2),i=0,a=t.map(e=>VQ(e));r[i]=`| ${a.join(` | `)} |`,i+=1;let o=Array(t.length);for(let e=0;e<t.length;e+=1)o[e]=`---`;r[i]=`| ${o.join(` | `)} |`,i+=1;for(let e of n)if(e.length<t.length){let n=Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=r<e.length?VQ(e[r]):``;r[i]=`| ${n.join(` | `)} |`,i+=1}else{let t=e.map(e=>VQ(e));r[i]=`| ${t.join(` | `)} |`,i+=1}return r.join(`
|
|
173
|
-
`)},UQ=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=qZ(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(null),d=(0,v.useRef)(0),{isAnimating:f,controls:p}=(0,v.useContext)(L1),m=hQ(),h=RQ(p),g=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=LQ(t),o=``;o=e===`csv`?zQ(a,h):e===`tsv`?BQ(a):HQ(a);let c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,v.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let _=fQ(),y=c?_.CheckIcon:_.CopyIcon;return(0,U.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,U.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:m.copyTable,type:`button`,children:e??(0,U.jsx)(y,{height:14,width:14})}),o?(0,U.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,U.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>g(`md`),title:m.copyTableAsMarkdown,type:`button`,children:m.tableFormatMarkdown}),(0,U.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>g(`csv`),title:m.copyTableAsCsv,type:`button`,children:m.tableFormatCsv}),(0,U.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>g(`tsv`),title:m.copyTableAsTsv,type:`button`,children:m.tableFormatTsv})]}):null]})},WQ=({children:e,className:t,onDownload:n,onError:r})=>{let i=qZ(),[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null),{isAnimating:c,controls:l}=(0,v.useContext)(L1),u=hQ(),d=fQ(),f=RQ(l),p=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=LQ(t),a=e===`csv`?zQ(i,f):HQ(i),c=e===`csv`?`csv`:`md`;GZ(`${_Q(l,`table`,`table`)}.${c}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,v.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,U.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,U.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:u.downloadTable,type:`button`,children:e??(0,U.jsx)(d.DownloadIcon,{size:14})}),a?(0,U.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,U.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>p(`csv`),title:u.downloadTableAsCsv,type:`button`,children:u.tableFormatCsv}),(0,U.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>p(`markdown`),title:u.downloadTableAsMarkdown,type:`button`,children:u.tableFormatMarkdown})]}):null]})},GQ=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=fQ(),o=qZ(),[s,c]=(0,v.useState)(!1),{isAnimating:l}=(0,v.useContext)(L1),u=hQ(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,v.useEffect)(()=>{if(s){wQ();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),TQ()}}},[s]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,U.jsx)(i,{size:14})}),s?(0,Ed.createPortal)((0,U.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,U.jsxs)(`div`,{className:o(`flex h-full flex-col`),"data-streamdown":`table-wrapper`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,U.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,U.jsx)(UQ,{}):null,r?(0,U.jsx)(WQ,{}):null,(0,U.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,U.jsx)(a,{size:20})})]}),(0,U.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,U.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},KQ=({children:e,className:t,maxHeight:n,showControls:r,showCopy:i=!0,showDownload:a=!0,showFullscreen:o=!0,...s})=>{let c=qZ(),{isAnimating:l}=(0,v.useContext)(L1),u=YZ(n),d=XZ(l,!!u,e),f=r&&i,p=r&&a,m=r&&o,h=f||p||m;return(0,U.jsxs)(`div`,{className:c(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[h?(0,U.jsxs)(`div`,{className:c(`flex items-center justify-end gap-1`),children:[f?(0,U.jsx)(UQ,{}):null,p?(0,U.jsx)(WQ,{}):null,m?(0,U.jsx)(GQ,{showCopy:f,showDownload:p,children:e}):null]}):null,(0,U.jsx)(`div`,{className:c(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),ref:d,style:u?{maxHeight:u}:void 0,children:(0,U.jsx)(`table`,{className:c(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...s,children:e})})]})},qQ=/startLine=(\d+)/,JQ=/\bnoLineNumbers\b/,YQ=(0,v.lazy)(()=>Ij(()=>import(`./mermaid-HWGCJPDP-BRHSVJqI.js`).then(e=>({default:e.Mermaid})),[])),XQ=/language-([^\s]+)/,ZQ=`node`;function QQ(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;let r=e,i=t;for(let e of n)if(e!==ZQ&&!Object.is(r[e],i[e]))return!1;return!0}function $Q(e,t){return e?.properties?.metastring===t?.properties?.metastring}var e$=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,t$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},n$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},r$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},i$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.image;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},a$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`ol`,{className:i(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e})},(e,t)=>QQ(e,t));a$.displayName=`MarkdownOl`;var o$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`li`,{className:i(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e})},(e,t)=>QQ(e,t));o$.displayName=`MarkdownLi`;var s$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`ul`,{className:i(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e})},(e,t)=>QQ(e,t));s$.displayName=`MarkdownUl`;var c$=(0,v.memo)(({className:e,node:t,...n})=>{let r=qZ();return(0,U.jsx)(`hr`,{className:r(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n})},(e,t)=>QQ(e,t));c$.displayName=`MarkdownHr`;var l$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`span`,{className:i(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e})},(e,t)=>QQ(e,t));l$.displayName=`MarkdownStrong`;var u$=(0,v.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=qZ(),{linkSafety:o}=(0,v.useContext)(L1),[s,c]=(0,v.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,v.useCallback)(async e=>{if(o!=null&&o.enabled&&n&&!l){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,v.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,v.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,U.jsx)(EQ,{...p})]}):(0,U.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>QQ(e,t));u$.displayName=`MarkdownA`;var d$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h1`,{className:i(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e})},(e,t)=>QQ(e,t));d$.displayName=`MarkdownH1`;var f$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h2`,{className:i(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e})},(e,t)=>QQ(e,t));f$.displayName=`MarkdownH2`;var p$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h3`,{className:i(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e})},(e,t)=>QQ(e,t));p$.displayName=`MarkdownH3`;var m$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h4`,{className:i(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e})},(e,t)=>QQ(e,t));m$.displayName=`MarkdownH4`;var h$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h5`,{className:i(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e})},(e,t)=>QQ(e,t));h$.displayName=`MarkdownH5`;var g$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h6`,{className:i(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e})},(e,t)=>QQ(e,t));g$.displayName=`MarkdownH6`;var _$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i,tableMaxHeight:a}=(0,v.useContext)(L1),o=e$(i,`table`),s=t$(i,`copy`),c=t$(i,`download`),l=t$(i,`fullscreen`);return(0,U.jsx)(KQ,{className:t,maxHeight:a,showControls:o,showCopy:s,showDownload:c,showFullscreen:l,...r,children:e})},(e,t)=>QQ(e,t));_$.displayName=`MarkdownTable`;var v$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`thead`,{className:i(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e})},(e,t)=>QQ(e,t));v$.displayName=`MarkdownThead`;var y$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`tbody`,{className:i(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e})},(e,t)=>QQ(e,t));y$.displayName=`MarkdownTbody`;var b$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`tr`,{className:i(`border-border`,t),"data-streamdown":`table-row`,...r,children:e})},(e,t)=>QQ(e,t));b$.displayName=`MarkdownTr`;var x$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`th`,{className:i(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e})},(e,t)=>QQ(e,t));x$.displayName=`MarkdownTh`;var S$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`td`,{className:i(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e})},(e,t)=>QQ(e,t));S$.displayName=`MarkdownTd`;var C$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`blockquote`,{className:i(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e})},(e,t)=>QQ(e,t));C$.displayName=`MarkdownBlockquote`;var w$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`sup`,{className:i(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e})},(e,t)=>QQ(e,t));w$.displayName=`MarkdownSup`;var T$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`sub`,{className:i(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e})},(e,t)=>QQ(e,t));T$.displayName=`MarkdownSub`;var E$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,v.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,v.isValidElement)(e)){if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,v.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,v.isValidElement)(e))return e;if(e.type===a$){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,U.jsx)(`section`,{className:t,...r,children:i}):null}return(0,U.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>QQ(e,t));E$.displayName=`MarkdownSection`;var D$=(0,v.memo)(({node:e,className:t,children:n,...r})=>{let i=qZ(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,v.useContext)(L1),l=AQ(),u=VZ(),d=(t?.match(XQ))?.at(1)??``,f=jQ(d);if(a)return(0,U.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(qQ),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&JQ.test(p))&&c!==!1,y=``;if((0,v.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?y=n.props.children:typeof n==`string`&&(y=n),f){let e=f.component;return(0,U.jsx)(v.Suspense,{fallback:(0,U.jsx)(bQ,{}),children:(0,U.jsx)(e,{code:y,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=e$(s,`mermaid`),n=r$(s,`download`),r=r$(s,`copy`),a=r$(s,`fullscreen`),c=r$(s,`panZoom`),l=e&&(n||r||a);return(0,U.jsx)(v.Suspense,{fallback:(0,U.jsx)(bQ,{}),children:(0,U.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,U.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,U.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,U.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,U.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,U.jsx)(PQ,{chart:y,config:o?.config}):null,r?(0,U.jsx)(gQ,{code:y}):null,a?(0,U.jsx)(FQ,{chart:y,config:o?.config}):null]})}):null,(0,U.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,U.jsx)(YQ,{chart:y,config:o?.config,showControls:c})})]})})}let b=e$(s,`code`),x=n$(s,`download`),S=n$(s,`copy`),{"data-block":C,...w}=r;return(0,U.jsx)(sQ,{className:t,code:y,isIncomplete:u,language:d,lineNumbers:_,startLine:g,...w,children:b?(0,U.jsxs)(U.Fragment,{children:[x?(0,U.jsx)(yQ,{code:y,language:d}):null,S?(0,U.jsx)(gQ,{}):null]}):null})},(e,t)=>QQ(e,t)&&$Q(e.node,t.node));D$.displayName=`MarkdownCode`;var O$=(0,v.memo)(({node:e,className:t,...n})=>{let{controls:r}=(0,v.useContext)(L1),i=e$(r,`image`),a=i&&i$(r,`download`);return(0,U.jsx)(SQ,{className:t,node:e,showControls:i,showDownloadControl:a,...n})},(e,t)=>QQ(e,t));O$.displayName=`MarkdownImg`;var k$=(0,v.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,v.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,U.jsx)(U.Fragment,{children:e})}return(0,U.jsx)(`p`,{...n,children:e})},(e,t)=>QQ(e,t));k$.displayName=`MarkdownParagraph`;var A$={ol:a$,li:o$,ul:s$,hr:c$,strong:l$,a:u$,h1:d$,h2:f$,h3:p$,h4:m$,h5:h$,h6:g$,table:_$,thead:v$,tbody:y$,tr:b$,th:x$,td:S$,blockquote:C$,code:D$,img:O$,pre:({children:e})=>(0,v.isValidElement)(e)?(0,v.cloneElement)(e,{"data-block":`true`}):e,sup:w$,sub:T$,p:k$,section:E$},j$=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,M$=/\p{L}/u;function N$(e){let t=e.replace(/(```|~~~)[\s\S]*?\1/g,``).replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``),n,r=0,i=0;for(let e of t){if(j$.test(e)){n??=`rtl`,i+=1;continue}M$.test(e)&&(n??=`ltr`,r+=1)}return i>r?`rtl`:r>i?`ltr`:n??`ltr`}var P$=/^[ \t]{0,3}(`{3,}|~{3,})/,F$=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,I$=e=>{let t=e.split(`
|
|
173
|
+
`)},UQ=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=qZ(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(null),d=(0,v.useRef)(0),{isAnimating:f,controls:p}=(0,v.useContext)(L1),m=hQ(),h=RQ(p),g=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=LQ(t),o=``;o=e===`csv`?zQ(a,h):e===`tsv`?BQ(a):HQ(a);let c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,v.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let _=fQ(),y=c?_.CheckIcon:_.CopyIcon;return(0,U.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,U.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:m.copyTable,type:`button`,children:e??(0,U.jsx)(y,{height:14,width:14})}),o?(0,U.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,U.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>g(`md`),title:m.copyTableAsMarkdown,type:`button`,children:m.tableFormatMarkdown}),(0,U.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>g(`csv`),title:m.copyTableAsCsv,type:`button`,children:m.tableFormatCsv}),(0,U.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>g(`tsv`),title:m.copyTableAsTsv,type:`button`,children:m.tableFormatTsv})]}):null]})},WQ=({children:e,className:t,onDownload:n,onError:r})=>{let i=qZ(),[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null),{isAnimating:c,controls:l}=(0,v.useContext)(L1),u=hQ(),d=fQ(),f=RQ(l),p=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=LQ(t),a=e===`csv`?zQ(i,f):HQ(i),c=e===`csv`?`csv`:`md`;GZ(`${_Q(l,`table`,`table`)}.${c}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,v.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,U.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,U.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:u.downloadTable,type:`button`,children:e??(0,U.jsx)(d.DownloadIcon,{size:14})}),a?(0,U.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,U.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>p(`csv`),title:u.downloadTableAsCsv,type:`button`,children:u.tableFormatCsv}),(0,U.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>p(`markdown`),title:u.downloadTableAsMarkdown,type:`button`,children:u.tableFormatMarkdown})]}):null]})},GQ=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=fQ(),o=qZ(),[s,c]=(0,v.useState)(!1),{isAnimating:l}=(0,v.useContext)(L1),u=hQ(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,v.useEffect)(()=>{if(s){wQ();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),TQ()}}},[s]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,U.jsx)(i,{size:14})}),s?(0,Ed.createPortal)((0,U.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,U.jsxs)(`div`,{className:o(`flex h-full flex-col`),"data-streamdown":`table-wrapper`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,U.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,U.jsx)(UQ,{}):null,r?(0,U.jsx)(WQ,{}):null,(0,U.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,U.jsx)(a,{size:20})})]}),(0,U.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,U.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},KQ=({children:e,className:t,maxHeight:n,showControls:r,showCopy:i=!0,showDownload:a=!0,showFullscreen:o=!0,...s})=>{let c=qZ(),{isAnimating:l}=(0,v.useContext)(L1),u=YZ(n),d=XZ(l,!!u,e),f=r&&i,p=r&&a,m=r&&o,h=f||p||m;return(0,U.jsxs)(`div`,{className:c(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[h?(0,U.jsxs)(`div`,{className:c(`flex items-center justify-end gap-1`),children:[f?(0,U.jsx)(UQ,{}):null,p?(0,U.jsx)(WQ,{}):null,m?(0,U.jsx)(GQ,{showCopy:f,showDownload:p,children:e}):null]}):null,(0,U.jsx)(`div`,{className:c(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),ref:d,style:u?{maxHeight:u}:void 0,children:(0,U.jsx)(`table`,{className:c(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...s,children:e})})]})},qQ=/startLine=(\d+)/,JQ=/\bnoLineNumbers\b/,YQ=(0,v.lazy)(()=>Ij(()=>import(`./mermaid-HWGCJPDP-CeY4jgtW.js`).then(e=>({default:e.Mermaid})),[])),XQ=/language-([^\s]+)/,ZQ=`node`;function QQ(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;let r=e,i=t;for(let e of n)if(e!==ZQ&&!Object.is(r[e],i[e]))return!1;return!0}function $Q(e,t){return e?.properties?.metastring===t?.properties?.metastring}var e$=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,t$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},n$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},r$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},i$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.image;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},a$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`ol`,{className:i(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e})},(e,t)=>QQ(e,t));a$.displayName=`MarkdownOl`;var o$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`li`,{className:i(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e})},(e,t)=>QQ(e,t));o$.displayName=`MarkdownLi`;var s$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`ul`,{className:i(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e})},(e,t)=>QQ(e,t));s$.displayName=`MarkdownUl`;var c$=(0,v.memo)(({className:e,node:t,...n})=>{let r=qZ();return(0,U.jsx)(`hr`,{className:r(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n})},(e,t)=>QQ(e,t));c$.displayName=`MarkdownHr`;var l$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`span`,{className:i(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e})},(e,t)=>QQ(e,t));l$.displayName=`MarkdownStrong`;var u$=(0,v.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=qZ(),{linkSafety:o}=(0,v.useContext)(L1),[s,c]=(0,v.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,v.useCallback)(async e=>{if(o!=null&&o.enabled&&n&&!l){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,v.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,v.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,U.jsx)(EQ,{...p})]}):(0,U.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>QQ(e,t));u$.displayName=`MarkdownA`;var d$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h1`,{className:i(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e})},(e,t)=>QQ(e,t));d$.displayName=`MarkdownH1`;var f$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h2`,{className:i(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e})},(e,t)=>QQ(e,t));f$.displayName=`MarkdownH2`;var p$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h3`,{className:i(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e})},(e,t)=>QQ(e,t));p$.displayName=`MarkdownH3`;var m$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h4`,{className:i(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e})},(e,t)=>QQ(e,t));m$.displayName=`MarkdownH4`;var h$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h5`,{className:i(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e})},(e,t)=>QQ(e,t));h$.displayName=`MarkdownH5`;var g$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`h6`,{className:i(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e})},(e,t)=>QQ(e,t));g$.displayName=`MarkdownH6`;var _$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i,tableMaxHeight:a}=(0,v.useContext)(L1),o=e$(i,`table`),s=t$(i,`copy`),c=t$(i,`download`),l=t$(i,`fullscreen`);return(0,U.jsx)(KQ,{className:t,maxHeight:a,showControls:o,showCopy:s,showDownload:c,showFullscreen:l,...r,children:e})},(e,t)=>QQ(e,t));_$.displayName=`MarkdownTable`;var v$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`thead`,{className:i(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e})},(e,t)=>QQ(e,t));v$.displayName=`MarkdownThead`;var y$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`tbody`,{className:i(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e})},(e,t)=>QQ(e,t));y$.displayName=`MarkdownTbody`;var b$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`tr`,{className:i(`border-border`,t),"data-streamdown":`table-row`,...r,children:e})},(e,t)=>QQ(e,t));b$.displayName=`MarkdownTr`;var x$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`th`,{className:i(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e})},(e,t)=>QQ(e,t));x$.displayName=`MarkdownTh`;var S$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`td`,{className:i(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e})},(e,t)=>QQ(e,t));S$.displayName=`MarkdownTd`;var C$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`blockquote`,{className:i(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e})},(e,t)=>QQ(e,t));C$.displayName=`MarkdownBlockquote`;var w$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`sup`,{className:i(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e})},(e,t)=>QQ(e,t));w$.displayName=`MarkdownSup`;var T$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=qZ();return(0,U.jsx)(`sub`,{className:i(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e})},(e,t)=>QQ(e,t));T$.displayName=`MarkdownSub`;var E$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,v.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,v.isValidElement)(e)){if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,v.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,v.isValidElement)(e))return e;if(e.type===a$){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,U.jsx)(`section`,{className:t,...r,children:i}):null}return(0,U.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>QQ(e,t));E$.displayName=`MarkdownSection`;var D$=(0,v.memo)(({node:e,className:t,children:n,...r})=>{let i=qZ(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,v.useContext)(L1),l=AQ(),u=VZ(),d=(t?.match(XQ))?.at(1)??``,f=jQ(d);if(a)return(0,U.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(qQ),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&JQ.test(p))&&c!==!1,y=``;if((0,v.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?y=n.props.children:typeof n==`string`&&(y=n),f){let e=f.component;return(0,U.jsx)(v.Suspense,{fallback:(0,U.jsx)(bQ,{}),children:(0,U.jsx)(e,{code:y,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=e$(s,`mermaid`),n=r$(s,`download`),r=r$(s,`copy`),a=r$(s,`fullscreen`),c=r$(s,`panZoom`),l=e&&(n||r||a);return(0,U.jsx)(v.Suspense,{fallback:(0,U.jsx)(bQ,{}),children:(0,U.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,U.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,U.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,U.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,U.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,U.jsx)(PQ,{chart:y,config:o?.config}):null,r?(0,U.jsx)(gQ,{code:y}):null,a?(0,U.jsx)(FQ,{chart:y,config:o?.config}):null]})}):null,(0,U.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,U.jsx)(YQ,{chart:y,config:o?.config,showControls:c})})]})})}let b=e$(s,`code`),x=n$(s,`download`),S=n$(s,`copy`),{"data-block":C,...w}=r;return(0,U.jsx)(sQ,{className:t,code:y,isIncomplete:u,language:d,lineNumbers:_,startLine:g,...w,children:b?(0,U.jsxs)(U.Fragment,{children:[x?(0,U.jsx)(yQ,{code:y,language:d}):null,S?(0,U.jsx)(gQ,{}):null]}):null})},(e,t)=>QQ(e,t)&&$Q(e.node,t.node));D$.displayName=`MarkdownCode`;var O$=(0,v.memo)(({node:e,className:t,...n})=>{let{controls:r}=(0,v.useContext)(L1),i=e$(r,`image`),a=i&&i$(r,`download`);return(0,U.jsx)(SQ,{className:t,node:e,showControls:i,showDownloadControl:a,...n})},(e,t)=>QQ(e,t));O$.displayName=`MarkdownImg`;var k$=(0,v.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,v.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,U.jsx)(U.Fragment,{children:e})}return(0,U.jsx)(`p`,{...n,children:e})},(e,t)=>QQ(e,t));k$.displayName=`MarkdownParagraph`;var A$={ol:a$,li:o$,ul:s$,hr:c$,strong:l$,a:u$,h1:d$,h2:f$,h3:p$,h4:m$,h5:h$,h6:g$,table:_$,thead:v$,tbody:y$,tr:b$,th:x$,td:S$,blockquote:C$,code:D$,img:O$,pre:({children:e})=>(0,v.isValidElement)(e)?(0,v.cloneElement)(e,{"data-block":`true`}):e,sup:w$,sub:T$,p:k$,section:E$},j$=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,M$=/\p{L}/u;function N$(e){let t=e.replace(/(```|~~~)[\s\S]*?\1/g,``).replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``),n,r=0,i=0;for(let e of t){if(j$.test(e)){n??=`rtl`,i+=1;continue}M$.test(e)&&(n??=`ltr`,r+=1)}return i>r?`rtl`:r>i?`ltr`:n??`ltr`}var P$=/^[ \t]{0,3}(`{3,}|~{3,})/,F$=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,I$=e=>{let t=e.split(`
|
|
174
174
|
`),n=null,r=0;for(let e of t){let t=P$.exec(e);if(n===null){if(t){let e=t[1];n=e[0],r=e.length}}else if(t){let e=t[1],i=e[0],a=e.length;i===n&&a>=r&&(n=null,r=0)}}return n!==null},L$=e=>{let t=e.split(`
|
|
175
175
|
`);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&F$.test(t))return!0}return!1},R$=()=>e=>{PN(e,`html`,(e,t,n)=>{!n||typeof t!=`number`||(n.children[t]={type:`text`,value:e.value})})},z$=[],B$={allowDangerousHtml:!0},V$=new WeakMap,H$=new class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let n=e.rehypePlugins,r=e.remarkPlugins,i=e.remarkRehypeOptions;if(!(n||r||i)){let t=`default`;return this.keyCache.set(e,t),t}let a=e=>{if(!e||e.length===0)return``;let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(n>0&&(t+=`,`),Array.isArray(r)){let[e,n]=r;if(typeof e==`function`){let n=V$.get(e);n||(n=e.name,V$.set(e,n)),t+=n}else t+=String(e);t+=`:`,t+=JSON.stringify(n)}else if(typeof r==`function`){let e=V$.get(r);e||(e=r.name,V$.set(r,e)),t+=e}else t+=String(r)}return t},o=a(n),s=`${a(r)}::${o}::${i?JSON.stringify(i):``}`;return this.keyCache.set(e,s),s}get(e){let t=this.generateCacheKey(e),n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(e,t){let n=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(n,t)}clear(){this.cache.clear()}},U$=e=>{let t=W$(e),n=e.children||``;return Z$(t.runSync(t.parse(n),n),e)},W$=e=>{let t=H$.get(e);if(t)return t;let n=K$(e);return H$.set(e,n),n},G$=e=>e.some(e=>Array.isArray(e)?e[0]===rz:e===rz),K$=e=>{let t=e.rehypePlugins||z$,n=e.remarkPlugins||z$,r=G$(t)?n:[...n,R$],i=e.remarkRehypeOptions?{...B$,...e.remarkRehypeOptions}:B$;return CY().use(iJ).use(r).use(YJ,i).use(t)},q$=e=>e,J$=(e,t,n,r)=>{n?e.children.splice(t,1):e.children[t]={type:`text`,value:r}},Y$=(e,t)=>{for(let n in yq)if(Object.hasOwn(yq,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],i=yq[n];(i===null||i.includes(e.tagName))&&(e.properties[n]=t(String(r||``),n,e)??void 0)}},X$=(e,t,n,r,i,a)=>{let o=!1;return r?o=!r.includes(e.tagName):i&&(o=i.includes(e.tagName)),!o&&a&&typeof t==`number`&&(o=!a(e,t,n)),o},Z$=(e,t)=>{let{allowElement:n,allowedElements:r,disallowedElements:i,skipHtml:a,unwrapDisallowed:o,urlTransform:s}=t;if(n||r||i||a||s){let t=s||q$;PN(e,(e,s,c)=>{if(e.type===`raw`&&c&&typeof s==`number`)return J$(c,s,a,e.value),s;if(e.type===`element`&&(Y$(e,t),X$(e,s,c,r,i,n)&&c&&typeof s==`number`))return o&&e.children?c.children.splice(s,1,...e.children):c.children.splice(s,1),s})}return ZK(e,{Fragment:U.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:U.jsx,jsxs:U.jsxs,passKeys:!0,passNode:!0})},Q$=/\[\^[\w-]{1,200}\](?!:)/,$$=/\[\^[\w-]{1,200}\]:/,e1=/<([A-Za-z][\w:-]*)[\s>/]/,t1=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),n1=new Map,r1=new Map,i1=e=>{let t=e.toLowerCase(),n=n1.get(t);if(n)return n;let r=RegExp(`<${t}(?=[\\s>/])[^>]*>`,`gi`);return n1.set(t,r),r},a1=e=>{let t=e.toLowerCase(),n=r1.get(t);if(n)return n;let r=RegExp(`</${t}(?=[\\s>])[^>]*>`,`gi`);return r1.set(t,r),r},o1=(e,t)=>{if(t1.has(t.toLowerCase()))return 0;let n=e.match(i1(t));if(!n)return 0;let r=0;for(let e of n)e.trimEnd().endsWith(`/>`)||(r+=1);return r},s1=(e,t)=>{let n=e.match(a1(t));return n?n.length:0},c1=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]===`$`&&e[n+1]===`$`&&(t+=1,n+=1);return t},l1=e=>{let t=Q$.test(e),n=$$.test(e);if(t||n)return[e];let r=nZ.lex(e,{gfm:!0}),i=[],a=[],o=!1;for(let e of r){let t=e.raw,n=i.length;if(a.length>0){i[n-1]+=t;let e=a.at(-1),r=o1(t,e),o=s1(t,e);for(let t=0;t<r;t+=1)a.push(e);for(let t=0;t<o;t+=1)a.length>0&&a.at(-1)===e&&a.pop();continue}if(e.type===`html`&&e.block){let e=t.match(e1);if(e){let n=e[1];o1(t,n)>s1(t,n)&&a.push(n)}}if(n>0&&!o){let e=i[n-1];if(c1(e)%2==1){i[n-1]=e+t;continue}}i.push(t),e.type!==`space`&&(o=e.type===`code`)}return i},u1=/^\n*/,d1=/\n*$/,f1=/\n\n/g,p1=(e,t,n)=>t.includes(`
|
|
176
176
|
`)?`${e}${t.replace(f1,`
|
|
@@ -208,4 +208,4 @@ ${u}`,i=e.length;break}return i===0?e:r+e.slice(i)},h1=(e,t)=>{if(!t.length)retu
|
|
|
208
208
|
`).find(e=>e.trim()!==``):void 0;o=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`term-scrub-ex`,"data-tone":t.kind===`error`||t.kind===`toolFailed`?`red`:`fg`,children:[t.kind===`user`?(0,U.jsx)(`span`,{"data-tone":`dim`,children:`❯ `}):null,R6(e)]}),n?(0,U.jsx)(`div`,{className:`term-scrub-ex`,"data-tone":`red`,children:n}):null]})}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{"data-tone":`faint`,children:[P6[t?.kind??e.kind],a]}),o]})}function V6(e){let{scrollOffset:t,viewportH:n,totalSize:r,onJumpToRow:i,interactive:a,fontSize:o,lineHeight:s}=e,c=T3(),l=(0,v.useRef)(null),u=(0,v.useRef)(null),[d,f]=(0,v.useState)(0),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=l.current;if(!e)return;let t=new ResizeObserver(()=>f(e.clientHeight));return t.observe(e),f(e.clientHeight),()=>t.disconnect()},[]);let[g,_]=(0,v.useState)(t);(0,v.useEffect)(()=>{let e=c.scrollRef.current;if(!e)return;let t=()=>_(e.scrollTop);return e.addEventListener(`scroll`,t,{passive:!0}),_(e.scrollTop),()=>e.removeEventListener(`scroll`,t)},[c.scrollRef]),(0,v.useEffect)(()=>{m(null)},[e.items]),(0,v.useEffect)(()=>{if(!a)return;let e=l.current;if(!e)return;let t=e=>{let t=c.scrollRef.current;t&&(t.scrollTop+=e.deltaY,e.preventDefault())};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[a,c.scrollRef]),(0,v.useLayoutEffect)(()=>{let e=u.current;if(!e||!p)return;let t=e.offsetHeight,n=l.current?.clientHeight??0;e.style.top=`${Math.max(4,Math.min(n-t-4,p.y-t/2))}px`},[p]);let y=(0,v.useMemo)(()=>d>0?z6(e,d):[],[e.items,e.bookmarks,e.recapRow,e.pendingApprovals,r,d,n]),b=I6(d,r,n),x=Math.max(2,Math.min(d,Math.round(n*b))),S=Math.max(0,Math.min(d-x,Math.round(g*b))),C=e=>{let t=l.current,n=c.scrollRef.current;if(!t||!n)return;let r=t.getBoundingClientRect();n.scrollTop=Math.min(1,Math.max(0,(e-r.top)/r.height))*n.scrollHeight-n.clientHeight/2},w=e=>e-(l.current?.getBoundingClientRect().top??0),T=(e,t)=>{if(e.kind===`approval`&&e.marks.length===0){c.scrollToBottom();return}let n=j6(e,w(t));n&&i(n.rowIndex)},E=(e,t)=>{let n=w(t),r=j6(e,n);m(t=>t&&t.cluster===e&&t.mark===r?t:{cluster:e,mark:r,y:Math.min(Math.max(n,e.y),e.y+e.h)})},D=Math.max(1,r-n);return(0,U.jsx)(k2,{fontSize:o,lineHeight:s,className:`term-scrubber`,"data-interactive":a||void 0,...a?{role:`scrollbar`,"aria-orientation":`vertical`,"aria-label":`Transcript overview`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.max(0,Math.round(g/D*100)))}:{"aria-hidden":!0},children:(0,U.jsxs)(`div`,{ref:l,className:`term-scrubber-body`,...a?{onPointerDown:e=>{c.stopScroll(),h.current={y:e.clientY,moved:!1,target:e.target},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=h.current;t&&(!t.moved&&Math.abs(e.clientY-t.y)<3||(t.moved=!0,m(null),C(e.clientY)))},onPointerUp:e=>{let t=h.current;if(h.current=null,!t||t.moved)return;let n=t.target?.closest?.(`[data-ci]`),r=n?Number(n.dataset.ci):NaN;Number.isInteger(r)&&y[r]?T(y[r],e.clientY):C(e.clientY)}}:null,children:[(0,U.jsx)(`div`,{className:`term-scrub-band`,style:{top:S,height:x}}),y.map((e,t)=>(0,U.jsx)(`div`,{"data-ci":t,className:`term-scrub-mark`,"data-lane":e.lane,"data-kind":e.kind,style:{top:e.y,height:e.h},...a?{onPointerEnter:t=>E(e,t.clientY),onPointerMove:t=>{h.current||E(e,t.clientY)},onPointerLeave:()=>m(null)}:null},t)),p?(0,U.jsx)(`div`,{ref:u,className:`term-scrub-peek`,style:{top:p.y},children:B6(p.cluster,p.mark,e)}):null]})})}function H6(e,t){let n;for(let r of e.marks)(!n||Math.abs(r.y-t)<Math.abs(n.y-t))&&(n=r);return n?.mark}var U6={user:`l`,subagent:`l`,shell:`l`,turn:`r`,turnFailed:`r`,toolFailed:`r`,error:`r`,approval:`f`,recap:`f`,bookmark:`f`},W6={approval:7,error:6,turnFailed:5,toolFailed:4,user:3,turn:2,bookmark:1,subagent:1,shell:1,recap:0},G6={user:`you`,subagent:`sub-agent`,shell:`shell`,turn:`response · turn end`,turnFailed:`turn failed`,toolFailed:`tool failed`,error:`error`,approval:`pending approval`,recap:`catch-up boundary`,bookmark:`bookmark`};function K6(e){return`${e.isError?e.subtype:`done`} · ${dM(e.durationMs)} · ${uM(e.totalCostUsd)}`}function q6(e){switch(e.kind){case`user`:case`assistant_text`:case`thinking`:case`notice`:return e.text;case`shell`:return e.shell.command;case`tool_call`:return`${e.name}(${yM(e.input)})`;case`turn_result`:return K6(e);case`file_delivered`:return e.path;default:return``}}function J6(e,{frameParentId:t,bookmarks:n=[],recapItemIndex:r}={}){let i=[],a=new Set;for(let t of e){let e=x4(t);e!==void 0&&a.add(e)}let o={},s=()=>{let e=o.response??o.turn;e!==void 0&&i.push({kind:o.failed?`turnFailed`:`turn`,itemIndex:e,turnIndex:o.turn}),o={}};e.forEach((e,n)=>{if(e.kind===`tool_call`&&a.has(e.id)&&i.push({kind:`subagent`,itemIndex:n}),e.kind===`user`&&x4(e)===t)s(),i.push({kind:`user`,itemIndex:n});else if(e.kind===`turn_result`)o.turn=n,o.failed=e.isError,s();else if(e.kind===`notice`&&e.level===`error`)i.push({kind:`error`,itemIndex:n});else if(e.kind===`shell`)i.push({kind:`shell`,itemIndex:n});else if(e.kind===`tool_call`&&x4(e)===t&&(e.status===`failed`||e.result?.isError===!0))i.push({kind:`toolFailed`,itemIndex:n});else if(e.kind===`assistant_text`&&x4(e)===t){if(t!==void 0){i.push({kind:`turn`,itemIndex:n});return}o.response=n}}),s();for(let t of n)t>=0&&t<e.length&&i.push({kind:`bookmark`,itemIndex:t});return r!==void 0&&i.push({kind:`recap`,itemIndex:r}),i}function Y6(e,t,n){let r=Math.max(1,n),i=Math.max(2,Math.round(t/r)),a=new Map;for(let n of e){let e=Math.min(Math.max(0,t-i),Math.round(n.itemIndex/r*t)),o=U6[n.kind],s=a.get(o)??[];s.push({mark:n,y:e}),a.set(o,s)}let o=[];for(let[e,t]of a){t.sort((e,t)=>e.y-t.y);let n=null;for(let{mark:r,y:a}of t)n&&a<=n.y+n.h+1?(n.h=Math.max(n.h,a+i-n.y),W6[r.kind]>W6[n.kind]&&(n.kind=r.kind),n.marks.push({mark:r,y:a})):(n={lane:e,kind:r.kind,y:a,h:i,marks:[{mark:r,y:a}]},o.push(n))}return o}function X6(e){return{lane:U6.approval,kind:`approval`,y:Math.max(0,e-2),h:2,marks:[]}}function Z6(e,t,n,r){let i=e.marks.length>1?` · ${e.marks.length} marks`:``,a=null;if(e.kind===`approval`){let e=r[0];a=e?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{children:e.title??`Permission required`}),(0,U.jsx)(`div`,{className:`wd-scrub-ex`,"data-tone":`muted`,children:`${e.displayName??e.toolName}(${yM(e.input)})`})]}):null}else if(t&&t.kind!==`recap`){let e=n[t.itemIndex];if(t.kind===`turn`||t.kind===`turnFailed`){let r=t.turnIndex===void 0?void 0:n[t.turnIndex];a=(0,U.jsxs)(U.Fragment,{children:[e?.kind===`assistant_text`?(0,U.jsx)(`div`,{className:`wd-scrub-ex`,children:e.text}):null,r?.kind===`turn_result`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{"data-tone":r.isError?`danger`:`muted`,children:K6(r)}),r.errors?.map((e,t)=>(0,U.jsx)(`div`,{"data-tone":`danger`,children:e},t))]}):null]})}else if(e){let n=t.kind===`toolFailed`&&e.kind===`tool_call`?e.result?.text.split(`
|
|
209
209
|
`).find(e=>e.trim()!==``):void 0;a=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`wd-scrub-ex`,"data-tone":t.kind===`error`||t.kind===`toolFailed`?`danger`:void 0,children:[t.kind===`user`?(0,U.jsx)(`span`,{"data-tone":`muted`,children:`❯ `}):null,q6(e)]}),n?(0,U.jsx)(`div`,{className:`wd-scrub-ex`,"data-tone":`danger`,children:n}):null]})}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{"data-tone":`muted`,children:[G6[t?.kind??e.kind],i]}),a]})}function Q6({items:e,pendingApprovals:t,recapItemIndex:n,bookmarks:r,frameParentId:i,interactive:a=!1,onJumpToItem:o,className:s}){let c=(0,v.useRef)(null),l=(0,v.useRef)(null),[u,d]=(0,v.useState)(0),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=c.current;if(!e)return;let t=new ResizeObserver(()=>d(e.clientHeight));return t.observe(e),d(e.clientHeight),()=>t.disconnect()},[]),(0,v.useEffect)(()=>{p(null)},[e]),(0,v.useLayoutEffect)(()=>{let e=l.current;if(!e||!f)return;let t=e.offsetHeight,n=c.current?.clientHeight??0;e.style.top=`${Math.max(4,Math.min(n-t-4,f.y-t/2))}px`},[f]);let m=(0,v.useMemo)(()=>{if(u<=0)return[];let a=Y6(J6(e,{frameParentId:i,bookmarks:r,recapItemIndex:n}),u,e.length);return t.length>0&&a.push(X6(u)),a},[e,i,r,n,t,u]),h=e=>e-(c.current?.getBoundingClientRect().top??0),g=(t,n)=>{if(t.kind===`approval`&&t.marks.length===0){e.length>0&&o?.(e.length-1);return}let r=H6(t,h(n));r&&o?.(r.itemIndex)},_=(e,t)=>{let n=h(t),r=H6(e,n);p(t=>t&&t.cluster===e&&t.mark===r?t:{cluster:e,mark:r,y:Math.min(Math.max(n,e.y),e.y+e.h)})};return(0,U.jsxs)(`div`,{ref:c,className:W(`wd-scrubber`,s),"data-interactive":a||void 0,"aria-hidden":!0,children:[m.map((e,t)=>(0,U.jsx)(`div`,{className:`wd-scrub-mark`,"data-lane":e.lane,"data-kind":e.kind,style:{top:e.y,height:e.h},...a?{onClick:t=>g(e,t.clientY),onPointerEnter:t=>_(e,t.clientY),onPointerMove:t=>_(e,t.clientY),onPointerLeave:()=>p(null)}:null},t)),f?(0,U.jsx)(`div`,{ref:l,className:`wd-scrub-peek`,style:{top:f.y},children:Z6(f.cluster,f.mark,e,t)}):null]})}var $6=new WeakMap,e8=new WeakMap;function t8(e){if(e){if(`item`in e)return e.item;if(`run`in e)return e.run[0];if(`task`in e)return e.task}}function n8(e,t){let n=t8(e[t-1]),r=t8(e[t]);return!n||!r||D4(n,r)}function r8(e){let t=$6.get(e);if(t)return t;let n=new Map;return e.forEach((e,t)=>{if(`task`in e)for(let r of e.childIndices)n.set(r,t)}),$6.set(e,n),n}function i8(e,t){let n=r8(e).get(t);if(n!==void 0)return n;let r=0,i=e.length-1,a=0;for(;r<=i;){let n=r+i>>1,o=e[n],s;if(`index`in o)s=o.index;else{let t=e[n+1];s=t&&`index`in t?t.index:2**53-1}s<=t?(`index`in o&&(a=n),r=n+1):i=n-1}return a}function a8(e){let t=e8.get(e);if(t)return t;let n=new Map;for(let t of e)if(`task`in t){let e=t.childIndices.length;t.childIndices.forEach((t,r)=>n.set(t,{ordinal:r,count:e}))}else if(`run`in t&&t.run.length>1){let e=t.run.length;t.indices.forEach((t,r)=>n.set(t,{ordinal:r,count:e}))}return e8.set(e,n),n}function o8(e,t){return a8(e).get(t)}function s8(e){let{terminal:t,fontSize:n,lineHeight:r,rowsRef:i}=e,[a,o]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(!t)return;let e=i.current;if(!e)return;let n,r=()=>{let t=Number.parseFloat(getComputedStyle(e).getPropertyValue(`--term-line`)),n=e.clientWidth,r=o6(e);t&&n&&r&&o(e=>e&&e.width===n&&e.ch===r&&e.line===t?e:r6(n,r,t))},a=new ResizeObserver(()=>{clearTimeout(n),n=setTimeout(r,150)});return a.observe(e),r(),()=>{a.disconnect(),clearTimeout(n)}},[t,n,r,i]),a}var c8=4,l8=50;function u8(e){let{state:t}=e;t.escapedFromLock=!1;let n=e.scrollToBottom({animation:`instant`,ignoreEscapes:!0,duration:750});t.animation={behavior:`instant`,ignoreEscapes:!0,promise:Promise.resolve(n)},t.scrollTop=t.calculatedTargetScrollTop}function d8(e,t){let{state:n}=e;if(n.resizeDifference=t,requestAnimationFrame(()=>{setTimeout(()=>{n.resizeDifference===t&&(n.resizeDifference=0)},1)}),n.animation?.ignoreEscapes){n.scrollTop=n.calculatedTargetScrollTop;return}e.scrollToBottom(`instant`)}function f8(e){let{rows:t,terminal:n,stickyPrompt:r,epoch:i,promptRows:a,scrollElement:o,rowsRef:s,virtualizer:c,stick:l,jumpToRecapRef:u,repinRef:d}=e,f=(0,v.useRef)(void 0);(0,v.useEffect)(()=>()=>clearTimeout(f.current),[]);let p=(e,u=`center`)=>{if(e<0||e>=t.length||!o)return;if(l.stopScroll(),clearTimeout(f.current),u===`start`){let l=e=>n&&i&&e>0&&n8(t,e)?i.line:0,u=()=>{let t=(c.measurementsCache[e]?.start??0)+(s.current?s.current.getBoundingClientRect().top-o.getBoundingClientRect().top+o.scrollTop:0)+l(e);return n&&r&&i&&!a.includes(e)&&a.some(t=>t<e)&&(t-=i.line),Math.round(t)},d=e=>{let t=u();o.scrollTo({top:t,behavior:`instant`}),!(e>=c8)&&(f.current=setTimeout(()=>{Math.abs(o.scrollTop-u())>1&&d(e+1)},l8))};d(0);return}let d=t=>{let n=o.querySelector(`[data-index="${e}"]`);if(n){n.scrollIntoView({behavior:`instant`,block:u});return}t>=c8||(c.scrollToIndex(e,{align:u,behavior:`auto`}),f.current=setTimeout(()=>d(t+1),l8))};d(0)};return(0,v.useEffect)(()=>{if(u)return u.current=()=>{p(t.findIndex(e=>e.key===`recap`),`start`)},()=>{u.current=null}}),(0,v.useEffect)(()=>{if(d)return d.current=()=>{clearTimeout(f.current),u8(l)},()=>{d.current=null}}),p}function p8({item:e,fileUrl:t}){switch(e.kind){case`user`:return(0,U.jsx)(f2,{item:e});case`assistant_text`:return(0,U.jsx)(p2,{item:e});case`thinking`:return(0,U.jsx)(m2,{item:e});case`tool_call`:return i0(e)?(0,U.jsx)(d2,{item:e}):(0,U.jsx)(g2,{item:e});case`turn_result`:return(0,U.jsx)(S2,{item:e});case`notice`:return(0,U.jsx)(w2,{item:e});case`compaction`:return(0,U.jsx)(C2,{item:e});case`file_delivered`:return(0,U.jsx)(E2,{item:e,href:t?.(e.path)});case`shell`:return(0,U.jsx)(T2,{item:e});default:return null}}function m8({text:e,terminal:t}){let[n,r]=(0,v.useState)(!1);return t?(0,U.jsx)(`div`,{"data-slot":`brief`,children:(0,U.jsx)(k0,{onPress:()=>r(e=>!e),expanded:n,children:(0,U.jsx)(pN,{glyph:`>`,glyphTone:`blue`,tone:`dim`,children:(0,U.jsx)(`span`,{className:W(`whitespace-pre-wrap`,!n&&`term-brief-clip`),style:n?void 0:{WebkitLineClamp:4},children:e})})})}):(0,U.jsx)(`div`,{"data-slot":`brief`,className:`px-4 py-2 text-body-sm whitespace-pre-wrap text-fg-2`,children:e})}function h8({block:e,fileUrl:t,onOpenSubagent:n}){let[r,i]=(0,v.useState)(!1),a=A0(r),o=(0,v.useMemo)(()=>w4(e),[e]),s=o.some(e=>e.kind===`user`)?void 0:v0(e.task),c=S0(e.task,o),l=C0(e.task),u=LM(c),d=(0,U.jsxs)(`div`,{ref:a,className:r?`term-open`:void 0,children:[(0,U.jsx)(k0,{onPress:()=>i(e=>!e),expanded:r,children:(0,U.jsx)(pN,{glyph:c?u:`●`,glyphTone:l?`red`:c?`mark`:`dim`,tone:l?`red`:`green`,children:c?(0,U.jsx)(`span`,{className:`term-shimmer`,children:w0(e.task,o)}):w0(e.task,o)})}),r?(0,U.jsxs)(`div`,{className:`term-nested`,children:[s?(0,U.jsx)(m8,{text:s,terminal:!0}):null,e.children.map((n,r)=>(0,U.jsxs)(v.Fragment,{children:[r>0&&k4(e.children[r-1],n)?(0,U.jsx)(mN,{}):null,`run`in n?(0,U.jsx)(x2,{items:n.run}):(0,U.jsx)(p8,{item:n.item,fileUrl:t})]},n.key))]}):null]});return n===void 0?d:(0,U.jsx)(aN,{actions:(0,U.jsx)(lN,{onOpen:()=>n(e.task.id)}),children:d})}function g8({item:e,href:t,className:n}){let r=e.path.split(`/`).pop()||e.path;return(0,U.jsxs)(`div`,{"data-slot":`file-delivered`,className:W(`flex w-full items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2.5`,n),children:[(0,U.jsx)(sy,{className:`size-4 shrink-0 text-fg-3`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate font-mono text-body-sm font-medium text-fg-1`,children:r}),(0,U.jsxs)(`div`,{className:`truncate text-label text-fg-4`,children:[pM(e.bytes),e.description?` · ${e.description}`:``]})]}),t?(0,U.jsxs)(`a`,{href:t,download:r,className:W(`flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5`,`text-body-sm text-fg-2 transition-colors hover:bg-surface-hover`),children:[(0,U.jsx)($v,{className:`size-3.5`}),`Download`]}):null]})}function _8({from:e,className:t,children:n,...r}){return(0,U.jsx)(`div`,{"data-slot":`message`,"data-from":e,className:W(`flex w-full flex-col items-start gap-1`,t),...r,children:n})}function v8({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`message-content`,className:W(`min-w-0 text-body-sm leading-6 text-fg-1`,`in-data-[from=user]:max-w-[85%] in-data-[from=user]:rounded-lg in-data-[from=user]:rounded-bl-sm`,`in-data-[from=user]:bg-accent-bg in-data-[from=user]:px-3 in-data-[from=user]:py-2`,`in-data-[from=user]:whitespace-pre-wrap`,`in-data-[from=assistant]:w-full`,e),...t})}function y8({children:e,isStreaming:t=!1,defaultOpen:n,className:r}){let[i,a]=(0,v.useState)(n??t),o=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!o.current){if(t)a(!0);else{let e=setTimeout(()=>a(!1),600);return()=>clearTimeout(e)}}},[t]);let s=e.trim()!==``;return!s&&!t?null:(0,U.jsxs)(`div`,{"data-slot":`reasoning`,"data-streaming":t||void 0,className:W(`w-full`,r),children:[(0,U.jsxs)(`button`,{type:`button`,disabled:!s,onClick:()=>{o.current=!0,a(e=>!e)},className:`flex items-center gap-1.5 text-label text-fg-3 transition-colors outline-none disabled:cursor-default hover:text-fg-1 disabled:hover:text-fg-3`,children:[(0,U.jsx)(F_,{className:`size-3.5`}),(0,U.jsx)(`span`,{children:t?`Thinking…`:`Thought process`}),s?(0,U.jsx)(av,{className:W(`size-3.5 transition-transform`,i&&`rotate-180`)}):null]}),i&&s?(0,U.jsx)(`div`,{className:`mt-2 border-l-2 border-border pl-3 text-body-sm text-fg-3 [&_*]:text-fg-3`,children:(0,U.jsx)(v4,{streaming:t,children:e})}):null]})}var b8=2e3,x8=new Set([`CodexImageGeneration`,`CodexImageView`]);function S8(e){if(!x8.has(e.name))return;let t=e.input,n=t?.savedPath??t?.path;return typeof n==`string`?n:void 0}var C8={running:{label:`Running`,variant:`info`,busy:!0},pending:{label:`Executing`,variant:`info`,busy:!0},deferred:{label:`Deferred`,variant:`accent`,busy:!1},settled:{label:`Done`,variant:`success`,busy:!1},failed:{label:`Error`,variant:`danger`,busy:!1}},w8={ts:`ts`,tsx:`tsx`,js:`js`,jsx:`jsx`,mjs:`js`,cjs:`js`,json:`json`,jsonc:`json`,md:`md`,mdx:`md`,css:`css`,scss:`scss`,html:`html`,xml:`xml`,yml:`yaml`,yaml:`yaml`,toml:`toml`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,h:`c`,cpp:`cpp`,hpp:`cpp`,cs:`csharp`,php:`php`,sh:`bash`,bash:`bash`,zsh:`bash`,fish:`fish`,sql:`sql`,graphql:`graphql`,dockerfile:`dockerfile`,diff:`diff`,patch:`diff`};function T8(e){if(e.name===`Bash`||e.name===`CodexCommand`)return`bash`;if(e.name===`CodexFileChange`)return`diff`;let t=e.input,n=t?.file_path??t?.path;return typeof n==`string`?w8[n.slice(n.lastIndexOf(`.`)+1).toLowerCase()]:void 0}function E8({item:e,hostImage:t,className:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),l=B0(),u=S8(e),d=e.status??(e.result===void 0?`running`:`settled`),f=C8[d],p=d===`failed`||e.result?.isError===!0,m=SM(e.name),h=U0(e.name),g=e.result?.text??``,_=!a&&g.length>b8,y=_?g.slice(0,b8):g,b=e.result?.truncated===!0,x=e.result?.totalChars??g.length,S=r?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border p-2.5`,children:[h?(0,U.jsx)(`p`,{className:`font-mono text-label text-fg-4`,children:e.name}):null,(0,U.jsx)(D8,{code:JSON.stringify(e.input,null,2),language:`json`,label:`Parameters`}),e.logs?.length?(0,U.jsx)(D8,{code:e.logs.join(`
|
|
210
210
|
`),label:`Logs`}):null,e.result===void 0?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(D8,{code:y||`(empty result)`,language:T8(e),label:p?`Error`:`Result`,className:W(p&&`border-danger/40 [&_pre]:text-danger`)}),s?(0,U.jsxs)(`p`,{className:`mt-1 text-label text-fg-3`,children:[`Fetching `,x.toLocaleString(),` chars…`]}):_||b?(0,U.jsxs)(`button`,{type:`button`,className:`mt-1 text-label text-fg-3 underline-offset-2 hover:underline`,onClick:()=>{o(!0),b&&(c(!0),l(e.id).finally(()=>c(!1)))},children:[`Show all `,x.toLocaleString(),` chars`]}):null]})]}):null,C=u&&t?(0,U.jsx)(k8,{path:u,load:t}):null,w=e.result?.images?.length?(0,U.jsx)(`div`,{className:`flex flex-col gap-2 border-t border-border p-2.5`,children:e.result.images.map(t=>(0,U.jsx)(O8,{toolUseId:e.id,image:t},t.partIndex))}):null;return(0,U.jsxs)(`div`,{"data-slot":`tool-call`,"data-state":d,className:W(`w-full overflow-hidden rounded-lg border border-border bg-surface`,n),children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:W(`flex w-full items-center gap-2 px-3 py-2 text-left transition-colors outline-none`,`hover:bg-surface-hover focus-visible:bg-surface-hover`),children:[(0,U.jsx)(m,{className:`size-3.5 shrink-0 text-fg-3`}),(0,U.jsx)(`span`,{className:W(`shrink-0 text-body-sm font-medium text-fg-1`,h===void 0&&`font-mono`),title:e.name,children:h??e.name}),e.backend&&e.backend!==`server`?(0,U.jsx)(fo,{variant:`neutral`,className:`shrink-0`,children:e.backend}):null,(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-label text-fg-4`,children:yM(e.input)}),(0,U.jsxs)(fo,{variant:f.variant,dot:!f.busy,className:`shrink-0 gap-1`,children:[f.busy?(0,U.jsx)(GT,{className:`size-3 text-current`}):null,d===`deferred`?(0,U.jsx)(Dv,{className:`size-3 text-current`}):null,f.label]}),(0,U.jsx)(av,{className:W(`size-3.5 shrink-0 text-fg-4 transition-transform`,r&&`rotate-180`)})]}),C,w,S]})}function D8({code:e,label:t,className:n}){return(0,U.jsx)(KT,{code:e,label:t,variant:`panel`,className:n})}function O8({toolUseId:e,image:t}){let{src:n,failed:r}=Y0({toolUseId:e,...t});return(0,U.jsx)(`div`,{className:`flex h-60 items-start overflow-hidden rounded-md border border-border bg-surface-hover`,children:n?(0,U.jsx)(`img`,{src:n,alt:M0(t),className:`h-full max-w-full object-contain`}):(0,U.jsx)(`span`,{className:`p-2 text-label text-fg-4`,children:r?N0:M0(t)})})}function k8({path:e,load:t}){let[n,r]=(0,v.useState)();return(0,v.useEffect)(()=>{let n=!1;return r(void 0),t(e).then(e=>{n||r(e)}).catch(()=>{}),()=>{n=!0}},[e,t]),n?(0,U.jsx)(`div`,{className:`border-t border-border p-2.5`,children:(0,U.jsx)(`img`,{src:n,alt:e.split(`/`).pop()??`Generated image`,className:`max-h-96 w-auto max-w-full rounded-md border border-border`})}):null}function A8({item:e}){return(0,U.jsxs)(`div`,{"data-slot":`turn-result`,className:`py-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,U.jsxs)(`span`,{className:W(`font-mono text-label`,e.isError?`text-danger`:`text-fg-4`),children:[e.isError?e.subtype:`turn done`,` · `,dM(e.durationMs),` · `,uM(e.costUsd??e.totalCostUsd)]}),(0,U.jsx)(`div`,{className:`h-px flex-1 bg-border`})]}),e.errors?.length?(0,U.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5 text-center`,children:e.errors.map((e,t)=>(0,U.jsx)(`li`,{className:`text-label break-words text-danger`,children:e},t))}):null]})}function j8({item:e}){return(0,U.jsx)(`div`,{"data-slot":`notice`,className:W(`rounded-md border px-3 py-2 text-body-sm`,e.level===`error`?`border-transparent bg-danger-bg text-danger`:`border-border bg-surface text-fg-3`),children:e.text})}function M8({item:e,fileUrl:t,attachmentUrl:n,hostImage:r,terminal:i}){if(i)return(0,U.jsx)(p8,{item:e,fileUrl:t});switch(e.kind){case`user`:return(0,U.jsxs)(_8,{from:`user`,children:[e.origin?(0,U.jsx)(`div`,{className:`wd-peer-origin text-xs text-muted-foreground`,children:l2(e.origin)}):null,e.attachments?.length?(0,U.jsx)(I8,{attachments:e.attachments,attachmentUrl:n}):null,e.text?(0,U.jsx)(v8,{children:(0,U.jsx)(HM,{text:e.text})}):null]});case`assistant_text`:return(0,U.jsx)(_8,{from:`assistant`,children:(0,U.jsx)(v8,{children:(0,U.jsx)(v4,{streaming:e.streaming,children:e.text})})});case`thinking`:return(0,U.jsx)(y8,{isStreaming:e.id===`streaming-thinking`,children:e.text});case`tool_call`:return(0,U.jsx)(E8,{item:e,hostImage:r});case`turn_result`:return(0,U.jsx)(A8,{item:e});case`notice`:return(0,U.jsx)(j8,{item:e});case`compaction`:return(0,U.jsx)(P8,{item:e});case`file_delivered`:return(0,U.jsx)(g8,{item:e,href:t?.(e.path)});case`shell`:return(0,U.jsx)(N8,{item:e});default:return null}}function N8({item:e}){let[t,n]=(0,v.useState)(!1),r=o2(),i=e.shell.status===`running`,a=XM(e),o=QM(e,t),s=$M(e,t,o.length),c=e.shell.id,l=r.verify;return(0,v.useEffect)(()=>{i&&l(c)},[i,c,l]),(0,U.jsxs)(`div`,{"data-slot":`shell`,className:`overflow-hidden rounded-md border border-border bg-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5`,children:[(0,U.jsx)(`span`,{className:`font-mono text-label text-[var(--wd-shell-accent)]`,children:`$`}),(0,U.jsx)(`button`,{type:`button`,"aria-expanded":t,className:`min-w-0 flex-1 truncate text-left font-mono text-label text-fg-1`,onClick:()=>{let i=!t;n(i),i&&e.truncated&&e.expanded===void 0&&!e.missing&&r.loadOutput(c)},children:KM(e)}),(0,U.jsx)(`span`,{className:W(`shrink-0 text-label`,a?`text-danger`:`text-fg-4`),children:qM(e)}),r.open?(0,U.jsx)(`button`,{type:`button`,"aria-label":`Open terminal`,title:`Open terminal`,className:`shrink-0 text-label text-fg-3 hover:text-fg-1`,onClick:()=>r.open?.(c),children:`⤢`}):null,i?(0,U.jsx)(`button`,{type:`button`,"aria-label":`Kill this shell`,className:`shrink-0 text-label text-fg-3`,onClick:()=>void r.kill(c),children:`✕`}):null]}),o.length>0?(0,U.jsx)(`pre`,{className:`overflow-x-auto border-t border-border px-3 py-2 font-mono text-label whitespace-pre-wrap text-fg-2`,children:o.join(`
|
|
211
|
-
`)}):null,s?(0,U.jsx)(`div`,{className:`px-3 pb-2 text-label text-fg-4`,children:s}):null]})}function P8({item:e}){return(0,U.jsxs)(`div`,{"data-slot":`compaction`,className:`flex items-center gap-2 py-1`,children:[(0,U.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,U.jsxs)(`span`,{className:`font-mono text-label ${e.error===void 0?`text-fg-3`:`text-danger`}`,children:[e.pending?`⋯`:`≡`,` `,lM(e)]}),(0,U.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function F8({line:e,since:t,terminal:n}){let r=t===void 0?void 0:hM(t),i=r?`${e} · last here ${r}`:e;return n?(0,U.jsx)(`div`,{"data-slot":`recap`,children:(0,U.jsxs)(pN,{glyph:`※`,glyphTone:`faint`,tone:`faint`,children:[`recap: `,i]})}):(0,U.jsxs)(`div`,{"data-slot":`recap`,className:`flex items-center gap-2 py-1`,children:[(0,U.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,U.jsxs)(`span`,{className:`font-mono text-label text-fg-3`,children:[`※ recap: `,i]}),(0,U.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function I8({attachments:e,attachmentUrl:t}){return(0,U.jsx)(`div`,{className:`mb-1 flex flex-wrap justify-start gap-1.5`,children:e.map(e=>{let n=t?.(e.id);return e.mediaType.startsWith(`image/`)&&n?(0,U.jsx)(`img`,{src:n,alt:e.name,className:`size-20 rounded-md border border-border object-cover`},e.id):(0,U.jsx)(`span`,{className:`rounded-full border border-border bg-surface px-2.5 py-1 text-body-xs text-fg-3`,children:e.name},e.id)})})}function L8(e,t){return e!==void 0&&t<e}function R8(e,t){let n=`parentToolUseId`in e?e.parentToolUseId:void 0;return n!=null&&n!==t?`border-l-2 border-border pl-3`:void 0}function z8(e){return e.text||(e.attachments??[]).map(e=>e.name).join(`, `)}function B8({top:e,height:t,gapClass:n,gapPx:r,terminal:i,scrollRoot:a,index:o,measureRef:s,head:c,content:l}){let u=(0,v.useRef)(null),d=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=u.current,t=d.current;if(!e||!t||!a)return;let n=()=>{let n=t.getBoundingClientRect().top<a.getBoundingClientRect().top;e.toggleAttribute(`data-stuck`,n)};return n(),a.addEventListener(`scroll`,n,{passive:!0}),()=>a.removeEventListener(`scroll`,n)},[a,e,t,n]),(0,U.jsxs)(`div`,{"data-sticky-lane":i?`terminal`:`cards`,className:`absolute inset-x-0`,style:{top:e,height:t},children:[(0,U.jsx)(`div`,{"data-sticky-headlane":``,"aria-hidden":!0,children:(0,U.jsx)(`div`,{ref:u,"data-sticky-head":``,className:i&&n||void 0,children:c})}),(0,U.jsx)(`div`,{ref:d,"aria-hidden":!0,className:`absolute left-0 w-px`,style:{top:n?i?`var(--term-line)`:r:0,height:1}}),(0,U.jsx)(`div`,{ref:s,"data-index":o,className:n||void 0,children:l})]})}function V8({rows:e,boundary:t,since:n,terminal:r,replaying:i,stickyPrompt:a,frameParentId:o,onOpenSubagent:s,gap:c,fontSize:l,lineHeight:u,items:d,pendingApprovals:f,scrubber:p,bookmarks:m,affordances:h,fileUrl:g,attachmentUrl:_,hostImage:y,jumpToRecapRef:b,repinRef:x,reveal:S}){let C=T3(),[w,T]=(0,v.useState)(null),E=(0,v.useMemo)(()=>e.flatMap((e,t)=>`item`in e&&e.item.kind===`user`&&x4(e.item)===void 0?[t]:[]),[e]),D=(0,v.useRef)({enabled:!1,promptRows:[]});D.current={enabled:a,promptRows:E},(0,v.useEffect)(()=>{T(C.scrollRef.current)},[C.scrollRef]),(0,v.useEffect)(()=>{if(!w)return;let e=w.clientHeight,t=new ResizeObserver(()=>{let t=w.clientHeight;if(t===e)return;let n=t-e;e=t,C.state.isAtBottom&&d8(C,n)});return t.observe(w),()=>t.disconnect()},[w,C]);let O=(0,v.useRef)(i);(0,v.useLayoutEffect)(()=>{let e=O.current;O.current=i,e&&!i&&C.state.isAtBottom&&(C.state.scrollTop=C.state.calculatedTargetScrollTop)},[i,C]);let k=(0,v.useRef)(null),A=s8({terminal:r,fontSize:l,lineHeight:u,rowsRef:k}),j=n6({count:e.length,getScrollElement:()=>(w&&j.scrollElement!==w&&(j.scrollOffset=w.scrollTop),w),estimateSize:t=>{if(r&&A){let n=e[t],r=t>0&&n8(e,t)?A.line:0;return n&&`text`in n&&n.key===`brief`?a6(n.text,A)+r:n&&!(`line`in n)?i6(n,A)+r:A.line+r}return(r?36:100)+c.px},overscan:8,getItemKey:t=>e[t].key,rangeExtractor:(0,v.useCallback)(e=>{let t=new Set(V3(e)),{enabled:n,promptRows:r}=D.current;if(n){let e=j.scrollOffset??0,n=-1;for(let t of r)if((j.measurementsCache[t]?.start??1/0)<=e)n=t;else break;n>=0&&t.add(n)}return[...t].sort((e,t)=>e-t)},[]),useFlushSync:!0});j.shouldAdjustScrollPositionOnItemSizeChange=(e,t,n)=>{if(C.state.isAtBottom)return!1;let r=(n.scrollOffset??0)+n.scrollAdjustments;return n.itemSizeCache.has(e.key)?e.end<=r&&n.scrollDirection!==`backward`:e.start<r},(0,v.useEffect)(()=>{if(!r||!A)return;j.measure();let e=k.current;if(e){j.getTotalSize();for(let t of e.querySelectorAll(`[data-index]`)){let e=Number(t.getAttribute(`data-index`));Number.isInteger(e)&&e>=0&&j.resizeItem(e,t.getBoundingClientRect().height)}}},[r,A,j]);let M=f8({rows:e,terminal:r,stickyPrompt:a,epoch:A,promptRows:E,scrollElement:w,rowsRef:k,virtualizer:j,stick:C,jumpToRecapRef:b,repinRef:x}),N=S?.nonce,P=S?.toolUseId;(0,v.useEffect)(()=>{if(P===void 0)return;let t=d.findIndex(e=>e.kind===`tool_call`&&e.id===P);t<0||M(i8(e,t),`start`)},[N]);let F=rN(h).hover,I=(0,v.useMemo)(()=>{if(!m?.length)return[];let e=new Map(d.map((e,t)=>[e.id,t]));return m.map(t=>e.get(t)).filter(e=>e!==void 0)},[m,d]),L=e.findIndex(e=>e.key===`recap`),R=L>=0?{rowIndex:L,label:e[L].line}:void 0;(0,v.useEffect)(()=>{if(r&&p&&F&&w)return w.setAttribute(`data-term-scrubber-host`,``),()=>w.removeAttribute(`data-term-scrubber-host`)},[r,p,F,w]);let z=j.measurementsCache;return(0,U.jsxs)(`div`,{ref:k,"data-slot":`transcript-rows`,className:`relative w-full`,style:{height:j.getTotalSize()},children:[(0,U.jsx)(E0,{items:d,children:j.getVirtualItems().map(i=>{let l=e[i.index],u=i.index>0&&(!r||n8(e,i.index))?c.className:void 0,d=`run`in l?(0,U.jsx)(`div`,{className:W(L8(t,l.index)&&`opacity-45`),children:(0,U.jsx)(x2,{items:l.run})}):`item`in l?(0,U.jsx)(`div`,{className:W(L8(t,l.index)&&`opacity-45`,R8(l.item,o)),children:(0,U.jsx)(M8,{item:l.item,fileUrl:g,attachmentUrl:_,hostImage:y,terminal:r})}):`text`in l&&l.key===`brief`?(0,U.jsx)(m8,{text:l.text,terminal:r}):`line`in l?(0,U.jsx)(F8,{line:l.line,since:n,terminal:r}):(0,U.jsx)(`div`,{className:W(L8(t,l.index)&&`opacity-45`),children:(0,U.jsx)(h8,{block:l,fileUrl:g,onOpenSubagent:s})});if(a&&`item`in l&&l.item.kind===`user`&&x4(l.item)===void 0){let e=E.find(e=>e>i.index),t=e===void 0?j.getTotalSize():z[e]?.start??i.start;return(0,U.jsx)(B8,{top:i.start,height:Math.max(t-i.start,0),gapClass:u,gapPx:c.px,terminal:r,scrollRoot:w,index:i.index,measureRef:j.measureElement,head:r?d:z8(l.item),content:d},l.key)}return(0,U.jsx)(`div`,{ref:j.measureElement,"data-index":i.index,className:W(`absolute inset-x-0 top-0`,u),style:{transform:`translateY(${i.start}px)`},children:d},l.key)})}),p&&w?.parentElement?(0,Ed.createPortal)(r?(0,U.jsx)(V6,{items:d,pendingApprovals:f,recapRow:R,bookmarks:I,frameParentId:o,rowIndexFor:t=>i8(e,t),positionInRow:t=>o8(e,t),offsetOfRow:e=>j.measurementsCache[e]?.start??0,sizeOfRow:e=>j.measurementsCache[e]?.size??0,totalSize:j.getTotalSize(),scrollOffset:j.scrollOffset??0,viewportH:j.scrollRect?.height??0,onJumpToRow:e=>M(e,`start`),interactive:F,fontSize:l,lineHeight:u}):(0,U.jsx)(Q6,{items:d,pendingApprovals:f,recapItemIndex:L>=0?t:void 0,bookmarks:I,frameParentId:o,interactive:F,onJumpToItem:t=>M(i8(e,t),`start`)}),w.parentElement):null]})}function H8(e){let t=e===`running`||e===`starting`,[n,r]=(0,v.useState)(void 0);return(0,v.useEffect)(()=>{r(e=>t?e??Date.now():void 0)},[t]),t?n:void 0}function U8(e){if(e.status!==`running`&&e.status!==`starting`)return!1;let t=e.items.at(-1);return t?t.kind===`assistant_text`&&t.streaming||t.kind===`thinking`&&t.id===`streaming-thinking`?!1:t.kind!==`turn_result`||e.status===`running`:!0}function W8({active:e,fontSize:t,lineHeight:n,affordances:r,children:i}){return e?(0,U.jsx)(k2,{fontSize:t,lineHeight:n,affordances:r,bleed:`1ch`,className:`term-transcript`,children:i}):(0,U.jsx)(U.Fragment,{children:i})}function G8({state:e,fileUrl:t,attachmentUrl:n,canBrowseFiles:r,hostImage:i,variant:a=`cards`,density:o=`comfortable`,fontSize:s,lineHeight:c,affordances:l,stickyPrompt:u=!1,scrubber:d,bookmarks:f,sessionNames:p,replaying:m=!1,catchUp:h,jumpToRecapRef:g,repinRef:_,reveal:y,frame:b,onOpenSubagent:x,emptyState:S,className:C}){let w=a===`terminal`,T=(0,v.useMemo)(()=>b?S4(e.items,b.parentToolUseId):e.items,[e.items,b]),E=(0,v.useMemo)(()=>b?e.items.find(e=>e.kind===`tool_call`&&e.id===b.parentToolUseId):void 0,[e.items,b]),D=sM[a][o],O=H8(e.status),k=!b&&h&&h.from>0&&h.from<e.items.length?h.from:void 0,A=(0,v.useMemo)(()=>k===void 0?void 0:Vj(Bj(e,k)),[e,k]),j=(0,v.useMemo)(()=>b&&E&&!T.some(e=>e.kind===`user`)?v0(E):void 0,[b,E,T]),M=(0,v.useMemo)(()=>{let e=(e,t)=>E4(T.slice(e,t),e,w);return k===void 0||!A?[...j?[{key:`brief`,text:j}]:[],...e(0,T.length)]:[...e(0,k),{key:`recap`,line:A},...e(k,T.length)]},[T,k,A,w,j]),N=(0,v.useMemo)(()=>e.skills?.map(e=>e.name),[e.skills]);return(0,U.jsx)(rM,{value:a,children:(0,U.jsx)(BM,{names:N,children:(0,U.jsx)(VM,{names:p,children:(0,U.jsxs)(E3,{className:W(m&&`invisible`,C),children:[(0,U.jsx)(D3,{className:W(w&&`gap-0 p-0`),children:(0,U.jsxs)(W8,{active:w,fontSize:s,lineHeight:c,affordances:l,children:[b?E===void 0&&!m?(0,U.jsx)(`div`,{className:W(w?`term-row text-fg-4`:`p-4 text-body-sm text-fg-4`),children:`This sub-agent's work is not in this transcript.`}):null:T.length===0&&e.status!==`starting`?S===void 0?(0,U.jsx)(A3,{cwd:e.cwd,hasCommands:!!e.commands?.length,hasSkills:!!e.skills?.some(e=>e.enabled),canBrowseFiles:r}):S:null,b&&E===void 0&&!m?null:(0,U.jsx)(V8,{rows:M,boundary:k,since:h?.since,terminal:w,replaying:m,stickyPrompt:!b&&u,gap:D,fontSize:s,lineHeight:c,items:T,pendingApprovals:e.pendingApprovals,scrubber:d,bookmarks:b?void 0:f,affordances:l,fileUrl:t,attachmentUrl:n,hostImage:i,jumpToRecapRef:g,repinRef:_,reveal:b?void 0:y,frameParentId:b?.parentToolUseId,onOpenSubagent:b?void 0:x}),(b?E!==void 0&&S0(E,T):U8(e))?w?(0,U.jsxs)(U.Fragment,{children:[e.items.length>0?(0,U.jsx)(`div`,{className:`term-blank`,"aria-hidden":!0}):null,(0,U.jsx)(O2,{label:e.status===`starting`?`Starting…`:`Working…`,startedAt:O,tokens:e.contextUsage?.totalTokens})]}):(0,U.jsx)(k3,{label:e.status===`starting`?`Starting session…`:void 0}):null]})}),(0,U.jsx)(O3,{}),m?(0,U.jsx)(`div`,{"data-slot":`transcript-hold`,"aria-hidden":!0,className:`wd-hold-appear visible pointer-events-none absolute inset-0 overflow-hidden`,children:(0,U.jsx)(`div`,{className:W(`mx-auto w-full max-w-[var(--wd-transcript-max-width)]`,!w&&`px-4 py-4`),children:w?(0,U.jsx)(k2,{fontSize:s,lineHeight:c,affordances:!1,bleed:`1ch`,className:`term-transcript`,children:(0,U.jsx)(O2,{label:`Loading…`})}):(0,U.jsx)(k3,{label:`Loading session…`})})}):null]})})})})}var K8=.02;function q8(e){let t=e.usageByModel??{},n=e.pricing,r=gk(t,n),i=e.costUsd??(r.unpriced||Object.keys(t).length===0?void 0:r.total),a=e.totalCostUsd,o=Object.entries(t).map(([e,t])=>({model:uk(e),usage:t,tokens:fk(t),costUsd:dk(e,n)?hk(t,e,n).total:void 0,costBasis:t.costBasis})).sort((e,t)=>t.tokens-e.tokens),s=i!==void 0&&a!==void 0?a-i:void 0,c=s!==void 0&&Math.abs(s)>Math.max(.01,K8*Math.max(i??0,a??0));return{displayUsd:i??a,computedUsd:i,reportedUsd:a,breakdown:r,rows:o,unpricedShare:r.unpricedShare,showUnpricedWarning:r.unpricedShare>Lee,unknownBasisModels:pk(t),gapUsd:c?s:void 0}}function J8(e=!0){let[t,n]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(t)},[e]),t}function Y8({windows:e,now:t,className:n}){let r=J8(t===void 0),i=t??r;return(0,U.jsx)(`div`,{className:W(`flex flex-col gap-5`,n),children:e.map(e=>(0,U.jsx)(X8,{window:e,now:i},e.key))})}function X8({window:e,now:t}){let{key:n,info:r,updatedAt:i,inferredReset:a}=e,o=r.utilization??0,s=kk(e,t),c=r.resetsAt===void 0?void 0:r.resetsAt*1e3,l=_M(n),u=c===void 0?void 0:(c-t)/1e3,d=l!==void 0&&u!==void 0&&u>0&&u<l?(l-u)/l:void 0;return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,U.jsx)(`span`,{className:`truncate text-body-sm text-fg-1`,children:gM(n)}),(0,U.jsxs)(`span`,{className:W(`shrink-0 font-mono text-body-sm font-medium`,r.status===`rejected`?`text-danger`:s?`text-fg-4`:`text-fg-1`),children:[o.toFixed(0),`% used`]})]}),(0,U.jsxs)(`div`,{className:`relative mt-2 h-2 rounded-full bg-border`,children:[(0,U.jsx)(`div`,{className:W(`h-full rounded-full`,U2(o),s&&`opacity-40`),style:{width:`${Math.min(100,Math.max(2,o))}%`}}),d===void 0?null:(0,U.jsx)(`span`,{"aria-hidden":!0,title:`Spent evenly, usage would be here by now`,className:`absolute -top-1 h-4 w-0.5 -translate-x-1/2 rounded-full bg-fg-1`,style:{left:`${Math.min(100,Math.max(0,d*100))}%`}})]}),(0,U.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3 text-label text-fg-4`,children:[c===void 0?null:(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(Wx,{className:`size-3`}),` Resets in `,mM(c,t)]}),r.isUsingOverage?(0,U.jsx)(`span`,{className:`text-warning`,children:`overage`}):null,r.status===`rejected`?(0,U.jsx)(`span`,{className:`text-danger`,children:`limit reached`}):null,a?(0,U.jsx)(`span`,{children:`window reset · nothing reported since`}):null,i&&!a?(0,U.jsxs)(`span`,{className:W(s&&`text-warning`),children:[s?`last reported `:``,vM(i,t)]}):null]})]})}function Z8(e){return e===`claude`?`Claude Code`:e}function Q8({label:e,value:t,tone:n}){return(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:n===`muted`?`text-label text-fg-4`:`text-label text-fg-3`,children:e}),(0,U.jsx)(`span`,{className:`font-mono text-body-sm ${n===`muted`?`text-fg-4`:`text-fg-1`}`,children:t})]})}function $8({cost:e,engine:t}){let{breakdown:n,rows:r}=e;return r.length===0?(0,U.jsx)(Q8,{label:`This session has cost`,value:uM(e.displayUsd)}):(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`text-label text-fg-3`,children:`This session has cost`}),(0,U.jsx)(`span`,{className:`font-mono text-body text-fg-1`,children:uM(e.displayUsd)})]}),(0,U.jsxs)(`div`,{className:`space-y-1 border-t border-border pt-2`,children:[(0,U.jsx)(Q8,{label:`input`,value:uM(n.input),tone:`muted`}),(0,U.jsx)(Q8,{label:`output`,value:uM(n.output),tone:`muted`}),(0,U.jsx)(Q8,{label:`cache write`,value:uM(n.cacheWrite),tone:`muted`}),(0,U.jsx)(Q8,{label:`cache read`,value:uM(n.cacheRead),tone:`muted`})]}),(0,U.jsx)(`div`,{className:`space-y-1 border-t border-border pt-2`,children:r.map(e=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`truncate text-label text-fg-4`,children:e.model}),(0,U.jsxs)(`span`,{className:`shrink-0 font-mono text-label text-fg-4`,children:[fM(e.tokens),` · `,e.costUsd===void 0?`no rate`:uM(e.costUsd)]})]},e.model))}),e.showUnpricedWarning?(0,U.jsxs)(`p`,{className:`text-label text-warning`,children:[Math.round(e.unpricedShare*100),`% of these tokens ran on a model with no bundled rate, so the total is an understatement rather than an estimate.`]}):null,e.unknownBasisModels.length>0?(0,U.jsxs)(`p`,{className:`text-label text-warning`,children:[Z8(t),` matched no rate table of its own to `,e.unknownBasisModels.join(`, `),`, so the figure it reports for those tokens is a guess rather than a rate.`]}):null,e.gapUsd===void 0?null:(0,U.jsxs)(`p`,{className:`text-label text-fg-4`,children:[Z8(t),` reports `,uM(e.reportedUsd),` for the same tokens.`]})]})}function e5({spend:e}){let{subscription:t}=e;return(0,U.jsxs)(`div`,{className:`mt-4 space-y-1 border-t border-border pt-3`,children:[(0,U.jsx)(Q8,{label:`This profile, last 7 days`,value:uM(e.weekUsd)}),(0,U.jsx)(Q8,{label:`Last 30 days`,value:uM(e.monthUsd),tone:`muted`}),t?(0,U.jsxs)(`p`,{className:`pt-1 text-label text-fg-4`,children:[t5(t.ratio),` the `,uM(t.weeklyShareUsd),` weekly share of your`,` `,uM(t.monthlyUsd),` a month. A subscription is a flat fee, so this is leverage, not a bill.`]}):null]})}function t5(e){return e>=10?`${Math.round(e)}x`:`${e.toFixed(1)}x`}function n5({rateLimits:e,subscriptionType:t,engine:n,totalCostUsd:r,costUsd:i,usageByModel:a,pricing:o,spend:s,updatedAt:c,open:l,onOpenChange:u,className:d}){let f=J8(l),p=q8({costUsd:i,totalCostUsd:r,usageByModel:a,pricing:o}),m=lk(f);return(0,U.jsx)(Fw,{open:l,onOpenChange:u,children:(0,U.jsxs)(Iw,{className:d,children:[(0,U.jsx)(Lw,{title:`Usage`,description:Z8(n),actions:t?(0,U.jsx)(fo,{variant:`accent`,className:`mt-0.5 shrink-0 capitalize`,children:t}):null}),(0,U.jsxs)(Rw,{children:[e.length===0?(0,U.jsx)(`p`,{className:`py-6 text-center text-body-sm text-fg-4`,children:n===`claude`?`This session reports no plan windows - API-key sessions have none, and a subscription session reports them once a turn has run.`:`Plan windows are a claude.ai subscription thing; this session runs on the ${n} engine.`}):(0,U.jsx)(Y8,{windows:e,now:f}),(0,U.jsx)(`div`,{className:`mt-5 border-t border-border pt-3`,children:(0,U.jsx)($8,{cost:p,engine:n})}),s?(0,U.jsx)(e5,{spend:s}):null,(0,U.jsx)(`p`,{className:`mt-3 text-label text-fg-4`,children:m?`${QO} ${m}`:QO}),c?(0,U.jsxs)(`p`,{className:`mt-2 text-label text-fg-4`,children:[`Updated `,vM(c,f)]}):null]})]})})}function r5({terminal:e,metrics:t,affordances:n,children:r}){return e?(0,U.jsx)(k2,{fontSize:t?.fontSize,lineHeight:t?.lineHeight,affordances:n,bleed:`1ch`,className:`term-transcript`,children:r}):(0,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-[var(--wd-transcript-max-width)] flex-col gap-2`,children:r})}var i5=[`button`,`a`,`input`,`textarea`,`select`,`summary`,`img`,`[contenteditable="true"]`,`[role="button"]`,`[role="menuitem"]`,`[role="checkbox"]`,`[role="radio"]`,`[role="tab"]`].join(`,`);function a5({client:e,sessionId:t,header:n,panelSurface:r=`internal`,statusSurface:i=`internal`,statusPlacement:a=`top`,onOpenPanel:o,onVitals:s,transcriptVariant:c=`cards`,transcriptDensity:l=`comfortable`,transcriptFont:u=`sans`,affordances:d,terminalMetrics:f,scrubber:p=!1,bookmarks:m,peerMentions:h=!0,onToggleBookmark:g,reveal:_,subagents:y,shells:b,openSubagent:x,onSubagentChange:S,openShell:C,onShellChange:w,stickyPrompt:T=!1,controlsSurface:E=`internal`,onControls:D,focusComposerOnClick:O=!1,unseen:k,readOnly:A=!1,approvalPrompts:j,toolHost:M,clientTools:N,cacheTranscript:P,emptyState:F,onLinkClick:I,onOpenFile:L,fontSize:R,className:z}){let ee=f?.fontSize??R,B=f?.lineHeight??(R===void 0?void 0:Math.round(18/13*R)),V=r===`external`,te=i===`external`,ne=E===`status`&&!te,H=E===`external`||ne,[re,ie]=(0,v.useState)(void 0),[ae,oe]=(0,v.useState)(),[se,ce]=(0,v.useState)(!1),[le,ue]=(0,v.useState)(),{state:de,connection:fe,replaying:pe,protocolMismatch:me,shell:he,pricing:ge,models:_e,effectiveModel:ve,handle:ye,send:be,runShell:xe,approve:Se,deny:Ce,interrupt:we,clearContext:Te,setModel:Ee,setPermissionMode:De,reconnectNow:Oe,loadFullResult:ke,loadShellOutput:Ae,verifyShell:je,killShell:Me}=kA(e,t,{onProtocolError:ie,cacheTranscript:P}),{shellId:Ne,enterShell:Pe,leaveShell:Fe,returnReveal:Ie,shell:Le,label:Re}=L4({sessionId:t,items:de.items,session:de.session,shells:b,reveal:_,openShell:C,onShellChange:w}),ze=(0,v.useMemo)(()=>({loadOutput:Ae,verify:je,kill:Me,open:Pe}),[Ae,je,Me,Pe]);(0,v.useEffect)(()=>ie(void 0),[t]);let{subagentId:Be,enterSubagent:Ve,leaveSubagent:He,returnReveal:Ue,frameItems:We,task:Ge,fallbackLabel:Ke}=A4({sessionId:t,items:de.items,session:de.session,reveal:_,openSubagent:x,onSubagentChange:S}),qe=(0,v.useMemo)(()=>Ue&&Ie?Ue.nonce>=Ie.nonce?Ue:Ie:Ue??Ie,[Ue,Ie]),[Je,Ye]=(0,v.useState)(!1);(0,v.useEffect)(()=>{Ye(!1)},[t]);let[Xe]=(0,v.useState)(k),Ze=Je?void 0:Xe,Qe=Ze?Math.max(0,de.items.length-Ze.itemCount):0,$e=(0,v.useCallback)(e=>{V?o?.(e):oe(e)},[V,o]);(0,v.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&Oe()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Oe]),zj(ye,M===!1?{enabled:!1}:N?{...M,clientTools:{...M?.clientTools,...N}}:M);let et=c===`terminal`,tt=de.capabilities,{usage:nt,spend:rt}=wj(e,de.session?.profile,{enabled:tt.rateLimits}),it=(0,v.useMemo)(()=>Dk({rateLimits:de.rateLimits,updatedAt:de.rateLimitsUpdatedAt},nt),[de.rateLimits,de.rateLimitsUpdatedAt,nt]),at=(0,v.useMemo)(()=>Object.keys(it).length>0?jk(it):void 0,[it]),ot=(0,v.useMemo)(()=>{let e=Object.values(it).map(e=>e.updatedAt);return e.length>0?Math.max(...e):void 0},[it]),st=(0,v.useMemo)(()=>Pee({checklist:de.checklist,subagents:y??de.session?.subagents}),[de.checklist,y,de.session?.subagents]),ct=(0,v.useMemo)(()=>{let e=tt.permissionModes,t=[];return _e.length>0&&t.push({name:`model`,description:`Switch the model for this session`,argumentHint:`<model>`,requiresArgs:!0,run:e=>{let t=e.split(/\s+/)[0];return t?(Ee(t),!0):!1}}),e.length>1&&t.push({name:`permissions`,description:`Set the permission mode (${e.join(`, `)})`,argumentHint:`<mode>`,requiresArgs:!0,run:t=>{let n=t.split(/\s+/)[0];return e.includes(n)?(De(n),!0):!1}}),tt.clearContext&&t.push({name:`clear`,description:`Clear the conversation - the session keeps running and the old one stays resumable`,run:()=>(Te(),!0)}),tt.mcpStatus&&t.push({name:`mcp`,description:`MCP servers and their status`,run:()=>($e(`mcp`),!0)}),tt.contextUsage&&t.push({name:`context`,description:`Context window usage`,run:()=>($e(`context`),!0)}),t.push({name:`status`,description:`Session details`,run:()=>($e(`info`),!0)}),tt.rateLimits&&t.push({name:`usage`,description:`Rate limits and spend`,run:()=>($e(`usage`),!0)}),tt.skillsList&&t.push({name:`skills`,description:`Browse the skills this session can use`,run:()=>($e(`skills`),!0)}),t},[tt,_e.length,$e,Te,Ee,De]),lt=(0,v.useMemo)(()=>tM(Yj({commands:tt.slashCommands?de.commands:void 0,clientCommands:ct,skills:tt.skillsList?de.skills:void 0})),[tt.slashCommands,tt.skillsList,de.commands,de.skills,ct]),ut=(0,v.useRef)(s);ut.current=s;let dt=ve??de.model,ft=(0,v.useMemo)(()=>h4(tt.permissionModes,de.session?.canBypassPermissions),[tt.permissionModes,de.session?.canBypassPermissions]);(0,v.useEffect)(()=>{ut.current?.({status:de.status,connection:fe,engine:de.engine,capabilities:de.capabilities,model:dt,models:_e,permissionMode:de.permissionMode,permissionModes:ft,skills:de.skills,composerCommands:lt,cwd:de.cwd,contextUsage:de.contextUsage,tasks:st,rateLimits:at,rateLimitsUpdatedAt:ot,itemCount:de.items.length,totalCostUsd:de.totalCostUsd})},[de.status,fe,de.engine,de.capabilities,dt,_e,de.permissionMode,ft,de.skills,lt,de.cwd,de.contextUsage,st,at,ot,de.items.length,de.totalCostUsd]);let pt=(0,v.useRef)(D);pt.current=D;let mt=(0,v.useRef)({setModel:Ee,setPermissionMode:De,interrupt:we});mt.current={setModel:Ee,setPermissionMode:De,interrupt:we};let ht=(0,v.useRef)({setModel:e=>mt.current.setModel(e),setPermissionMode:e=>mt.current.setPermissionMode(e),interrupt:()=>mt.current.interrupt(),focusComposer:()=>Ot.current?.focus(),insertComposerText:e=>Ot.current?.insertText(e)});(0,v.useEffect)(()=>{let e=pt.current;return e?.(ht.current),()=>e?.(void 0)},[t]);let gt=(0,v.useMemo)(()=>new Set(m??[]),[m]),_t=(0,v.useMemo)(()=>g?{has:e=>gt.has(e),toggle:g}:void 0,[gt,g]),vt=de.status===`running`||de.status===`awaiting_approval`,yt=de.status===`failed`||de.status===`closed`,bt=qA(e,t,{capabilities:tt,engine:de.engine}),xt=pj(e,de.cwd),St=vj(e,t,h),Ct=Cj(e,t),wt=(0,v.useCallback)((e,t)=>xt.search(e,{...t,limit:8}),[xt.search]),Tt=(0,v.useMemo)(()=>Ak(it),[it]),Et=o5(e,t,de.producedFiles),Dt=Z0(e,t),Ot=(0,v.useRef)(null),kt=(0,v.useRef)(null),At=(0,v.useRef)(null),jt=(e,t)=>{if(t.length===0){let t=eM(e,ct);if(t&&t.command.run(t.args))return}Ye(!0),At.current?.(),be(e,t)},Mt=(0,U.jsxs)(jw,{children:[(0,U.jsx)(Mw,{render:(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Session actions`,children:(0,U.jsx)(ty,{className:`size-4`})})}),(0,U.jsxs)(Nw,{children:[tt.contextUsage?(0,U.jsxs)(Pw,{onClick:()=>$e(`context`),children:[(0,U.jsx)(tv,{className:`size-3.5 text-fg-3`}),` Context`]}):null,tt.rateLimits?(0,U.jsxs)(Pw,{onClick:()=>$e(`usage`),children:[(0,U.jsx)(Oy,{className:`size-3.5 text-fg-3`}),` Usage`]}):null,(0,U.jsxs)(Pw,{onClick:()=>$e(`info`),children:[(0,U.jsx)(eb,{className:`size-3.5 text-fg-3`}),` Session info`]}),tt.mcpStatus?(0,U.jsxs)(Pw,{onClick:()=>$e(`mcp`),children:[(0,U.jsx)(Sx,{className:`size-3.5 text-fg-3`}),` MCP servers`]}):null,tt.skillsList?(0,U.jsxs)(Pw,{onClick:()=>$e(`skills`),children:[(0,U.jsx)(ES,{className:`size-3.5 text-fg-3`}),` Skills`]}):null,xt.available?(0,U.jsxs)(Pw,{onClick:()=>$e(`files`),children:[(0,U.jsx)(by,{className:`size-3.5 text-fg-3`}),` Project files`]}):null]})]}),Nt=V?null:Mt,Pt=typeof n==`function`,Ft=(0,U.jsxs)(U.Fragment,{children:[_e.length?(0,U.jsx)(f4,{models:_e,model:ve,onModelChange:Ee,disabled:yt,className:ne?`h-5`:void 0}):null,de.permissionMode?(0,U.jsx)(g4,{mode:de.permissionMode,onModeChange:De,modes:tt.permissionModes,canBypass:de.session?.canBypassPermissions,disabled:yt,className:ne?`h-5`:void 0}):null]}),It=te?null:(0,U.jsx)(f3,{state:de,rateLimits:at,connection:fe,placement:a,controls:ne&&!A?Ft:void 0,onOpenStatus:V&&!o?void 0:()=>$e(`info`),onOpenContext:V&&!o?void 0:()=>$e(`context`),onOpenUsage:V&&!o?void 0:()=>$e(`usage`),tasks:st,onOpenTasks:V&&!o?void 0:()=>$e(`tasks`),actions:Pt?void 0:Nt}),Lt=(0,v.useMemo)(()=>L?{cwd:de.cwd,open:L}:void 0,[L,de.cwd]),Rt=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!I)return;let e=Rt.current;if(!e)return;let t=e=>{let t=e.target?.closest?.(`a[href]`);if(!t)return;let n=t.getAttribute(`href`);n&&I(n)&&(e.preventDefault(),e.stopPropagation())};return e.addEventListener(`click`,t,!0),()=>e.removeEventListener(`click`,t,!0)},[I]),(0,U.jsx)(rM,{value:c,children:(0,U.jsx)(oM,{value:l,children:(0,U.jsx)(Y1,{value:Lt,children:(0,U.jsx)(z0,{value:ke,children:(0,U.jsx)(a2,{value:ze,children:(0,U.jsx)(H0,{value:de.toolTitles,children:(0,U.jsx)(K0,{value:Dt,children:(0,U.jsxs)(`div`,{ref:Rt,"data-slot":`session-panel`,"data-agent-font":u,onClick:e=>{O&&!A&&(e.target?.closest(i5)||window.getSelection()?.isCollapsed!==!1&&Ot.current?.focus())},className:W(`flex h-full min-h-0 flex-col overflow-hidden bg-bg`,z),style:R===void 0?void 0:{"--wd-font-size":`${Math.round(R)}px`},children:[Pt?n({actions:Nt}):n,a===`top`?It:null,me===void 0?null:(0,U.jsxs)(c5,{level:`warning`,children:[`Server speaks protocol v`,me,`, this build renders v`,1,`. Some events may not render.`]}),re?(0,U.jsx)(c5,{level:`error`,onDismiss:()=>ie(void 0),children:re}):null,Ne===void 0?null:(0,U.jsx)(j4,{shell:Le,label:Re,onBack:Fe,onKill:()=>void Me(Ne),terminal:et,fontSize:ee,lineHeight:B}),Ne===void 0&&Be!==void 0?(0,U.jsx)(b4,{task:Ge,items:We,label:Ke,onBack:He,terminal:et,fontSize:ee,lineHeight:B}):null,Ne===void 0?(0,U.jsx)(sN,{value:_t,children:(0,U.jsx)(G8,{state:de,fileUrl:t?n=>e.sessionFileUrl(t,n):void 0,attachmentUrl:t?n=>e.attachmentUrl(t,n):void 0,canBrowseFiles:xt.available,sessionNames:St.names,hostImage:Et,variant:c,density:l,fontSize:ee,lineHeight:B,affordances:d,stickyPrompt:T,scrubber:p,bookmarks:m,replaying:pe,catchUp:Ze&&Qe>0?{from:Ze.itemCount,since:Ze.since}:void 0,reveal:le??qe??_,frame:Be===void 0?void 0:{parentToolUseId:Be},onOpenSubagent:Ve,emptyState:F,jumpToRecapRef:kt,repinRef:At},Be??`session`)}):(0,U.jsx)(M4,{handle:ye,shellId:Ne,fontSize:ee},Ne),Ze&&Qe>0&&!pe&&Be===void 0&&Ne===void 0?(0,U.jsx)(`div`,{className:`px-3 pb-1`,children:(0,U.jsxs)(`div`,{"data-slot":`catch-up`,className:`mx-auto flex w-full max-w-[var(--wd-transcript-max-width)] items-center gap-2 text-label text-fg-3`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:W(`select-none`,et?`text-fg-3`:`text-accent`),children:`※`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[Qe,` new `,Qe===1?`row`:`rows`,Ze.since===void 0?``:` since you were last here`]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>kt.current?.(),className:`shrink-0 underline-offset-2 hover:text-fg-1 hover:underline`,children:`jump`}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>Ye(!0),className:`shrink-0 underline-offset-2 hover:text-fg-1 hover:underline`,children:`dismiss`})]})}):null,!A&&tt.interactiveApprovals&&de.pendingApprovals.length>0?(0,U.jsx)(`div`,{className:W(et?`pb-2`:`px-3 pb-2`),children:(0,U.jsx)(r5,{terminal:et,metrics:{fontSize:ee,lineHeight:B},affordances:d,children:de.pendingApprovals.map(e=>{let t=j?.[e.toolName];if(t)return(0,U.jsx)(t,{request:e,onApprove:Se,onDeny:Ce},e.id);let n=e.toolName===`AskUserQuestion`&&Lk(e.input).length>0;return et?n?(0,U.jsx)(t3,{request:e,onAnswer:Se,onDismiss:e=>Ce(e,`Question dismissed by user`)},e.id):(0,U.jsx)(Q4,{request:e,onApprove:Se,onDeny:Ce},e.id):n?(0,U.jsx)(V4,{request:e,onAnswer:Se,onDismiss:e=>Ce(e,`Question dismissed by user`)},e.id):(0,U.jsx)(y4,{request:e,onApprove:Se,onDeny:Ce},e.id)})})}):null,A||Be!==void 0||Ne!==void 0?null:(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(M2,{ref:Ot,onSend:jt,onInterrupt:we,busy:vt,disabled:yt||!t,commands:tt.slashCommands?de.commands:void 0,skills:tt.skillsList?de.skills:void 0,clientCommands:ct,attachments:bt,draft:Ct,onSearchFiles:xt.available?wt:void 0,peers:St.peers,onShellCommand:he?xe:void 0,layout:H?`inline`:`stacked`,toolbar:H?void 0:Ft,fontSize:ee,lineHeight:B,affordances:d})}),a===`bottom`?It:null,V?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(i3,{state:de,client:e,sessionId:t,open:ae===`info`,onOpenChange:e=>oe(e?`info`:void 0)}),(0,U.jsx)(W2,{usage:de.contextUsage,engine:de.engine??`claude`,open:ae===`context`,onOpenChange:e=>oe(e?`context`:void 0)}),(0,U.jsx)(n5,{rateLimits:Tt,subscriptionType:de.subscriptionType,engine:de.engine??`claude`,totalCostUsd:de.totalCostUsd,costUsd:de.costUsd,usageByModel:de.usageByModel,pricing:ge,spend:rt,updatedAt:ot,open:ae===`usage`,onOpenChange:e=>oe(e?`usage`:void 0)}),(0,U.jsx)(Q2,{client:e,sessionId:t,canManageServers:tt.mcpServerActions,open:ae===`mcp`,onOpenChange:e=>oe(e?`mcp`:void 0)}),(0,U.jsx)(J2,{tasks:st,showCompleted:se,onShowCompletedChange:ce,onSelectTask:e=>{e.toolUseId&&ue({toolUseId:e.toolUseId,nonce:Date.now()})},open:ae===`tasks`,onOpenChange:e=>oe(e?`tasks`:void 0)}),(0,U.jsx)(i4,{skills:de.skills,open:ae===`skills`,onOpenChange:e=>oe(e?`skills`:void 0),onUse:e=>Ot.current?.insertText(Jj(e))}),(0,U.jsx)(X2,{client:e,cwd:de.cwd,open:ae===`files`,onOpenChange:e=>oe(e?`files`:void 0)})]})]})})})})})})})})}function o5(e,t,n){let r=(0,v.useRef)(new Map),i=(0,v.useRef)([]);return(0,v.useEffect)(()=>()=>{for(let e of i.current)URL.revokeObjectURL(e);i.current=[]},[]),(0,v.useCallback)(a=>{let o=n?.[a],s=o?`produced:${o.fileId}`:`fs:${a}`,c=r.current.get(s);if(c)return c;let l=o&&t?e.readProducedFile(t,o.fileId).then(e=>{if(e.size===0)return;let t=URL.createObjectURL(e);return i.current.push(t),t}).catch(()=>void 0):e.readHostFile(a).then(e=>{if(e.encoding!==`base64`)return;let t=s5[a.slice(a.lastIndexOf(`.`)+1).toLowerCase()];return t?`data:${t};base64,${e.content}`:void 0}).catch(()=>void 0);return r.current.set(s,l),l},[e,t,n])}var s5={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`};function c5({level:e,onDismiss:t,children:n}){return(0,U.jsx)(`div`,{className:`px-3 pt-2`,children:(0,U.jsxs)(`div`,{role:`alert`,className:W(`mx-auto flex w-full max-w-[var(--wd-transcript-max-width)] items-start gap-2 rounded-md border px-3 py-2 text-body-sm`,e===`error`?`border-danger/40 bg-danger-bg text-danger`:`border-warning/40 bg-warning-bg text-warning`),children:[(0,U.jsx)(oC,{className:`mt-0.5 size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:n}),t?(0,U.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Dismiss`,className:`shrink-0 opacity-70 transition-opacity hover:opacity-100`,children:(0,U.jsx)(DC,{className:`size-3.5`})}):null]})})}var l5=`[^\\s:'"\`()\\[\\]{}<>|]+`,u5=RegExp(`(?:^|[\\s'"\`([{<@,])((?:\\.\\.?)?(?:/${l5})+|[^\\s:'"\`()\\[\\]{}<>|@,]+(?:/${l5})+)(?::(\\d+))?`),d5=/^([\w.@-]+\.[A-Za-z0-9]{1,10})(?::(\d+))?$/,f5=/[.,;:!?)\]}'"`]+$/,p5=/\.[A-Za-z0-9]{1,10}$/;function m5(e,t=!1){let n=e??``,r=u5.exec(n);if(!r)return t?h5(n):void 0;let i=r[1].replace(f5,``);if(i.includes(`/`)&&!i.endsWith(`/`)&&(i.startsWith(`/`)||i.startsWith(`./`)||i.startsWith(`../`)||p5.test(i)))return{path:i,line:r[2]?Number(r[2]):void 0,length:i.length+(r[2]?r[2].length+1:0)}}function h5(e){let t=d5.exec(e.trim());if(!t)return;let n=t[2]?Number(t[2]):void 0;return{path:t[1],line:n,length:t[0].length}}var g5=`wd-path-link`,_5=.6;function v5(e){if(!e)return;let t=e.closest(`code`)!==null,n=e.textContent?.trim()??``,r=m5(n,t);if(r&&!(!t&&r.length<n.length*_5))return{path:r.path,line:r.line}}function y5({container:e,onOpen:t,enabled:n=!0,ignore:r}){(0,v.useEffect)(()=>{let i=e.current;if(!i||!n)return;let a=e=>r!==void 0&&e?.closest(r)!==null&&e!==void 0,o,s=()=>{o?.classList.remove(g5),o=void 0},c=e=>{if(!e.metaKey&&!e.ctrlKey)return;let n=e.target instanceof HTMLElement?e.target:void 0;if(a(n))return;let r=v5(n);r&&(e.preventDefault(),e.stopPropagation(),s(),t(r))},l=e=>{if(!e.metaKey&&!e.ctrlKey)return s();let t=e.target instanceof HTMLElement?e.target:void 0;t!==o&&(s(),t&&!a(t)&&v5(t)&&(o=t,t.classList.add(g5)))},u=e=>{!e.metaKey&&!e.ctrlKey&&s()};return i.addEventListener(`click`,c,!0),i.addEventListener(`mousemove`,l),document.addEventListener(`keydown`,u),document.addEventListener(`keyup`,u),window.addEventListener(`blur`,s),()=>{s(),i.removeEventListener(`click`,c,!0),i.removeEventListener(`mousemove`,l),document.removeEventListener(`keydown`,u),document.removeEventListener(`keyup`,u),window.removeEventListener(`blur`,s)}},[e,t,n,r])}function b5(e,t){return G1(e,t)?.path??e}var x5={anchor:s_,atom:__,beaker:x_,bike:T_,binary:D_,blocks:k_,bot:j_,box:N_,brain:F_,briefcase:L_,brush:z_,bug:V_,"building-2":U_,cable:G_,camera:Y_,car:Z_,cat:$_,"circuit-board":Cv,cloud:kv,code:jv,coffee:Nv,cog:Fv,compass:Lv,container:zv,cpu:Uv,"credit-card":Gv,database:qv,diamond:Yv,dog:Zv,feather:iee,film:see,flame:fy,"flask-conical":my,folder:Sy,"gamepad-2":Ey,gauge:Oy,gem:Ay,ghost:My,gift:Py,"git-branch":Iy,globe:Ry,"graduation-cap":By,hammer:Hy,hexagon:Ky,house:Jy,image:Qy,key:nb,landmark:ib,laptop:ob,layers:cb,leaf:ub,library:fb,lightbulb:mb,lock:wb,mail:Eb,map:Ob,"message-circle":Mb,mic:Ib,monitor:Rb,moon:Bb,mountain:Hb,music:Wb,network:Kb,newspaper:Jb,notebook:Xb,orbit:Qb,package:ex,palette:nx,"pen-tool":ux,phone:gx,"piggy-bank":vx,plane:bx,plug:Sx,puzzle:Ax,radar:Mx,radio:Px,receipt:Ix,rocket:Bx,ruler:Jx,satellite:Xx,scale:eS,scissors:nS,server:cS,shield:mS,ship:gS,"shopping-cart":vS,signal:bS,smartphone:wS,sparkles:ES,sprout:OS,square:RS,star:BS,sun:HS,table:WS,tag:KS,target:XS,telescope:JS,terminal:QS,"test-tube":eC,"tree-pine":iC,trophy:cC,truck:uC,umbrella:fC,users:gC,wallet:vC,wand:cee,waves:lee,webhook:uee,wifi:fee,wrench:TC,zap:kC};function S5({icon:e,src:t,name:n,className:r}){if(!e)return null;if(e.type===`image`)return t?(0,U.jsx)(`img`,{src:t,alt:``,"aria-hidden":!0,title:n,className:W(`inline-block size-3 shrink-0 object-contain`,r)}):null;let i=x5[e.name]??Sy;return(0,U.jsx)(i,{className:W(`inline-block size-3 shrink-0`,r)})}function C5({usage:e,engine:t,size:n=11,className:r}){if(e===void 0)return null;let i=B2(t),a=`Context ${e.percentage.toFixed(0)}% · ${fM(e.totalTokens)} / ${fM(e.maxTokens)}`,o=W(`shrink-0 leading-none`,H2(e.percentage),r),s=(0,U.jsx)(XT,{value:e.percentage,size:n,strokeWidth:2});return i?(0,U.jsx)(uT,{render:(0,U.jsx)(`span`,{className:o}),content:(0,U.jsxs)(`div`,{className:`flex max-w-64 flex-col gap-1 py-0.5`,children:[(0,U.jsx)(`span`,{className:`font-mono text-fg-2`,children:a}),(0,U.jsx)(`span`,{className:`text-fg-3`,children:i.summary}),(0,U.jsx)(`span`,{className:`text-fg-3`,children:i.hint})]}),children:s}):(0,U.jsx)(`span`,{title:a,className:o,children:s})}var w5={claude:{title:`Claude`,d:`M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z`},codex:{title:`OpenAI`,d:`M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z`},gemini:{title:`Gemini`,d:`M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z`},deepseek:{title:`DeepSeek`,d:`M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z`},moonshot:{title:`Moonshot`,d:`M1.052 16.916l9.539 2.552a21.007 21.007 0 00.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865l-.18-.016-.044-.004-.084-.009-.094-.01a11.605 11.605 0 01-.157-.02l-.107-.014-.11-.016a11.962 11.962 0 01-.32-.051l-.042-.008-.075-.013-.107-.02-.07-.015-.093-.019-.075-.016-.095-.02-.097-.023-.094-.022-.068-.017-.088-.022-.09-.024-.095-.025-.082-.023-.109-.03-.062-.02-.084-.025-.093-.028-.105-.034-.058-.019-.08-.026-.09-.031-.066-.024a6.293 6.293 0 01-.044-.015l-.068-.025-.101-.037-.057-.022-.08-.03-.087-.035-.088-.035-.079-.032-.095-.04-.063-.028-.063-.027a5.655 5.655 0 01-.041-.018l-.066-.03-.103-.047-.052-.024-.096-.046-.062-.03-.084-.04-.086-.044-.093-.047-.052-.027-.103-.055-.057-.03-.058-.032a6.49 6.49 0 01-.046-.026l-.094-.053-.06-.034-.051-.03-.072-.041-.082-.05-.093-.056-.052-.032-.084-.053-.061-.039-.079-.05-.07-.047-.053-.035a7.785 7.785 0 01-.054-.036l-.044-.03-.044-.03a6.066 6.066 0 01-.04-.028l-.057-.04-.076-.054-.069-.05-.074-.054-.056-.042-.076-.057-.076-.059-.086-.067-.045-.035-.064-.052-.074-.06-.089-.073-.046-.039-.046-.039a7.516 7.516 0 01-.043-.037l-.045-.04-.061-.053-.07-.062-.068-.06-.062-.058-.067-.062-.053-.05-.088-.084a13.28 13.28 0 01-.099-.097l-.029-.028-.041-.042-.069-.07-.05-.051-.05-.053a6.457 6.457 0 01-.168-.179l-.08-.088-.062-.07-.071-.08-.042-.049-.053-.062-.058-.068-.046-.056a7.175 7.175 0 01-.027-.033l-.045-.055-.066-.082-.041-.052-.05-.064-.02-.025a11.99 11.99 0 01-1.44-2.402zm-1.02-5.794l11.353 3.037a20.468 20.468 0 00-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923l-.016-.046-.035-.104a11.965 11.965 0 01-.05-.153l-.007-.023a11.896 11.896 0 01-.207-.741l-.03-.126-.018-.08-.021-.097-.018-.081-.018-.09-.017-.084-.018-.094c-.026-.141-.05-.283-.071-.426l-.017-.118-.011-.083-.013-.102a12.01 12.01 0 01-.019-.161l-.005-.047a12.12 12.12 0 01-.034-2.145zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26l.015-.1.008-.049.01-.067.015-.087.018-.098c.026-.148.056-.295.088-.442l.028-.124.02-.085.024-.097c.022-.09.045-.18.07-.268l.028-.102.023-.083.03-.1.025-.082.03-.096.026-.082.031-.095a11.896 11.896 0 011.01-2.232zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213l.045-.065.027-.04.04-.055.046-.065.055-.076.054-.072.064-.086.05-.065.057-.073.055-.07.06-.074.055-.069.065-.077.054-.066.066-.077.053-.06.072-.082.053-.06.067-.074.054-.058.073-.078.058-.06.063-.067.168-.17.1-.098.059-.056.076-.071a12.084 12.084 0 012.272-1.677zM12.017 0h.097l.082.001.069.001.054.002.068.002.046.001.076.003.047.002.06.003.054.002.087.005.105.007.144.011.088.007.044.004.077.008.082.008.047.005.102.012.05.006.108.014.081.01.042.006.065.01.207.032.07.012.065.011.14.026.092.018.11.022.046.01.075.016.041.01L14.7.3l.042.01.065.015.049.012.071.017.096.024.112.03.113.03.113.032.05.015.07.02.078.024.073.023.05.016.05.016.076.025.099.033.102.036.048.017.064.023.093.034.11.041.116.045.1.04.047.02.06.024.041.018.063.026.04.018.057.025.11.048.1.046.074.035.075.036.06.028.092.046.091.045.102.052.053.028.049.026.046.024.06.033.041.022.052.029.088.05.106.06.087.051.057.034.053.032.096.059.088.055.098.062.036.024.064.041.084.056.04.027.062.042.062.043.023.017c.054.037.108.075.161.114l.083.06.065.048.056.043.086.065.082.064.04.03.05.041.086.069.079.065.085.071c.712.6 1.353 1.283 1.909 2.031L7.222.994l.062-.027.065-.028.081-.034.086-.035c.113-.045.227-.09.341-.131l.096-.035.093-.033.084-.03.096-.031c.087-.03.176-.058.264-.085l.091-.027.086-.025.102-.03.085-.023.1-.026L9.04.37l.09-.023.091-.022.095-.022.09-.02.098-.021.091-.02.095-.018.092-.018.1-.018.091-.016.098-.017.092-.014.097-.015.092-.013.102-.013.091-.012.105-.012.09-.01.105-.01c.093-.01.186-.018.28-.024l.106-.008.09-.005.11-.006.093-.004.1-.004.097-.002.099-.002.197-.002z`}};function T5(e,t){if(e===`claude`)return`claude`;if(e===`codex`)return`codex`;let n=t?.toLowerCase()??``;if(n){if(n.includes(`gemini`))return`gemini`;if(n.includes(`deepseek`))return`deepseek`;if(n.includes(`moonshot`)||n.includes(`kimi`))return`moonshot`;if(n.includes(`claude`))return`claude`;if(n.startsWith(`gpt`)||n.startsWith(`o1`)||n.startsWith(`o3`)||n.includes(`openai`))return`codex`}}var E5={claude:`text-vendor-claude`,codex:`text-vendor-openai`},D5={claude:`text-vendor-claude`};function O5(e,t){return E5[T5(e,t)??``]??`text-fg-3`}function k5(e,t){return D5[T5(e,t)??``]??`text-fg-3`}function A5({engine:e,model:t,className:n}){let r=w5[T5(e,t)??``];return r?(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,fillRule:`evenodd`,role:`img`,"aria-label":r.title,className:W(`size-3 shrink-0 text-fg-3`,n),children:[(0,U.jsx)(`title`,{children:r.title}),(0,U.jsx)(`path`,{d:r.d})]}):(0,U.jsx)(`span`,{"aria-hidden":!0,title:e,className:W(`shrink-0 text-fg-3`,n),children:`·`})}function j5({row:e,className:t}){let{info:n}=e,r=W(`size-4 shrink-0`,t);if(e.state===`attention`)return(0,U.jsx)(C_,{className:W(r,`animate-pulse text-warning`)});if(e.state===`working`)return(0,U.jsx)(GT,{className:W(r,`text-info`)});switch(n.status){case`failed`:return(0,U.jsx)(pv,{className:W(r,`text-danger`)});case`closed`:return(0,U.jsx)(yv,{className:W(r,`text-fg-4`)});case`parked`:return(0,U.jsx)(_v,{className:W(r,`text-fg-3`)});default:return(0,U.jsx)(Bb,{className:W(r,`text-fg-4`)})}}function M5(e,t,n=`all`,r){let i=EO(e,n).filter(DO).map(e=>({key:e.toolUseId,kind:`agent`,label:OO(e),noun:`agent`,state:P5(e.status),detail:e.toolCount>0?String(e.toolCount):void 0,title:`${OO(e)} · ${e.toolCount} tool${e.toolCount===1?``:`s`}`,onSelect:()=>t(e.toolUseId)}));return r===void 0?i:[...i,...RO(e,r.now).map(e=>N5(e,r))]}function N5(e,t){let n=YM(e),r=e.status===`running`;return{key:e.id,kind:`shell`,label:WM(e),noun:`shell`,state:JM(e)?`failed`:r?`running`:`done`,detail:r?void 0:n,title:`${GM(e)} · ${n}`,onSelect:()=>t.onSelect(e.id),onKill:r&&t.onKill?()=>t.onKill?.(e.id):void 0}}function P5(e){switch(e){case`running`:return`running`;case`failed`:return`failed`;default:return`done`}}function F5({step:e,active:t=!1,onSelect:n}){let r=e.state===`failed`?`text-danger`:e.kind===`shell`?`text-[var(--wd-shell-accent)]`:`text-success`;return(0,U.jsxs)(`div`,{className:W(`flex w-full items-center rounded-[4px] pr-1.5`,t?`bg-row-selected`:`hover:bg-row-active`,r),children:[(0,U.jsxs)(`button`,{type:`button`,title:e.title,"aria-current":t||void 0,onClick:e=>{e.stopPropagation(),n()},className:`flex min-w-0 flex-1 items-center gap-1.5 py-1 pr-1 pl-3.5 text-left text-micro outline-none`,children:[(0,U.jsx)(I5,{step:e}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.detail?(0,U.jsx)(`span`,{className:`shrink-0 tabular-nums text-fg-4`,children:e.detail}):null,(0,U.jsx)(p_,{className:`size-3.5 shrink-0 text-fg-4`})]}),e.onKill?(0,U.jsx)(`button`,{type:`button`,"aria-label":`Kill ${e.label}`,title:`Kill this shell`,onClick:t=>{t.stopPropagation(),e.onKill?.()},className:`shrink-0 px-1 text-micro leading-none text-fg-4 outline-none hover:text-danger`,children:`✕`}):null]})}function I5({step:e}){if(e.kind===`shell`)return(0,U.jsx)(`span`,{className:`w-[11px] shrink-0 text-center leading-none`,children:`$`});switch(e.state){case`running`:return(0,U.jsx)(GT,{className:`size-[11px] shrink-0`});case`failed`:return(0,U.jsx)(pv,{className:`size-[11px] shrink-0`});default:return(0,U.jsx)(rv,{className:`size-[11px] shrink-0`})}}var L5={meta:!1,ctrl:!1,alt:!1};function R5({row:e,active:t=!1,activeStepKey:n,showGateway:r,showProject:i=!0,projectIcons:a,subagents:o=`active`,onSelect:s,onSelectSubagent:c,onSelectShell:l,onKillShell:u,now:d,onRename:f,renameOn:p=`doubleClick`,editing:m,onEditingChange:h,actions:g,className:_}){let{info:y}=e,[b,x]=(0,v.useState)(!1),S=m??b,C=e=>{x(e),h?.(e)},w=y.engine??`claude`,T=i?PO(e):IO(e),E=i?FO(e):void 0,D=i?y.project?.icon:void 0,O=D?.type===`image`?a?.[D.hash]:void 0,k=uM(y.costUsd??y.totalCostUsd),A=[r?e.hostName:void 0,y.profile?`@${y.profile}`:void 0,k===`-`?void 0:k].filter(e=>!!e),j=xM(y.model),M=[];j&&M.push((0,U.jsx)(`span`,{className:k5(w,y.model),children:j},`model`)),T!==void 0&&M.push((0,U.jsxs)(`span`,{title:E,children:[(0,U.jsx)(S5,{icon:D,src:O,name:E,className:`mr-1.5 size-4 align-[-0.3em]`}),T]},`project`));for(let e of A)M.push((0,U.jsx)(`span`,{children:e},e));let N=M5(y,e=>c?c(e):s?.(L5),o,{now:d??Date.now(),onSelect:e=>l?l(e):s?.(L5),onKill:u}),P=N.some(e=>e.key===n);return(0,U.jsxs)(`div`,{"data-slot":`session-item`,"data-active":t||void 0,role:`button`,tabIndex:0,onClick:e=>{e.detail>1||S||s?.({meta:e.metaKey,ctrl:e.ctrlKey,alt:e.altKey})},onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s?.({meta:e.metaKey,ctrl:e.ctrlKey,alt:e.altKey}))},className:W(`group flex w-full cursor-pointer flex-col p-1 text-left outline-none`,`rounded-[4px] transition-colors focus-visible:ring-2 focus-visible:ring-ring`,P?`bg-row-selected-weak`:t?`bg-row-selected`:`hover:bg-row-hover`,_),children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 py-0.5 pr-0.5 pl-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex h-5 items-center gap-1.5 overflow-hidden`,children:[(0,U.jsx)(z5,{children:(0,U.jsx)(j5,{row:e})}),S&&f?(0,U.jsx)(B5,{initial:y.title??``,onCommit:e=>{C(!1),e!==(y.title??``)&&f(e)},onCancel:()=>C(!1)}):(0,U.jsx)(`span`,{onDoubleClick:f&&p===`doubleClick`?e=>{e.stopPropagation(),C(!0)}:void 0,className:`min-w-0 flex-1 truncate text-body-sm font-medium tracking-[-0.005em] text-fg-1`,children:MO(y)}),e.unseen>0?(0,U.jsx)(`span`,{title:`${e.unseen} new message${e.unseen===1?``:`s`}`,className:W(`flex h-4 min-w-6 shrink-0 items-center justify-center rounded-full px-2`,`text-[0.75rem] leading-none tracking-[-0.005em] tabular-nums`,e.state===`working`?`bg-badge text-badge-fg`:`bg-accent text-accent-fg`),children:e.unseen}):null,(0,U.jsx)(C5,{usage:y.contextUsage,engine:w,size:16,className:`p-0.5`})]}),(0,U.jsxs)(`div`,{className:`flex h-5 items-center gap-1.5 overflow-hidden text-body-sm tracking-[-0.005em]`,children:[(0,U.jsx)(z5,{children:(0,U.jsx)(A5,{engine:w,model:y.model,className:W(`size-4`,O5(w,y.model))})}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-fg-4`,children:M.map((e,t)=>(0,U.jsxs)(v.Fragment,{children:[t>0?` · `:``,e]},t))}),(0,U.jsxs)(`span`,{className:`shrink-0 text-fg-4`,children:[M.length>0?`· `:``,hM(y.lastActivityAt??y.createdAt)]}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1`}),g]})]}),N.length>0?(0,U.jsx)(`div`,{className:`flex flex-col`,children:N.map(e=>(0,U.jsx)(F5,{step:e,active:e.key===n,onSelect:e.onSelect},e.key))}):null]})}function z5({children:e}){return(0,U.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:e})}function B5({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,v.useState)(e),a=(0,v.useRef)(null);return(0,v.useEffect)(()=>{a.current?.focus(),a.current?.select()},[]),(0,v.useEffect)(()=>{let e=()=>{a.current?.focus(),a.current?.select()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),(0,U.jsx)(`input`,{ref:a,value:r,spellCheck:!1,placeholder:`Session name`,"aria-label":`Session name`,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onChange:e=>i(e.target.value),onBlur:()=>{document.hasFocus()&&t(r.trim())},onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?t(r.trim()):e.key===`Escape`&&n()},className:W(`-my-0.5 min-w-0 flex-1 rounded-sm border border-ring bg-bg px-1 py-px`,`text-body-sm leading-5 text-fg-1 outline-none`)})}function V5(e){return W(`px-2 py-1.5 hover:bg-row-hover`,e?`mr-1 ml-0 rounded-r-md border-l-4 border-l-accent`:`mx-1 rounded-md`)}function H5({rows:e,config:t,onConfigChange:n,scope:r,activeId:i,activeSubagentId:a,activeShellId:o,now:s,onSelect:c,onDelete:l,onRename:u,onClearContext:d,onSelectSubagent:f,onSelectShell:p,onKillShell:m,emptyState:h,showControls:g=!0,projectIcons:_,className:y}){let b=(0,v.useMemo)(()=>WO(e,t,r),[e,t,r]),x=(0,v.useMemo)(()=>Oee(b,t),[b,t]),S=kee(t,r,b.length,e.length),C=(0,v.useMemo)(()=>AO(e),[e]),w=(0,v.useMemo)(()=>jO(e),[e]),T=(0,v.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.hostId,n.hostName);return[...t].map(([e,t])=>({id:e,name:t}))},[e]),E=e=>n({...t,...e});return(0,U.jsxs)(`div`,{"data-slot":`session-browser`,className:W(`flex flex-col gap-3`,y),children:[(0,U.jsxs)(`div`,{className:W(`flex flex-col gap-1.5 px-2`,!g&&`hidden`),children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(oS,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-fg-4`}),(0,U.jsx)(_o,{value:t.search,onChange:e=>E({search:e.target.value}),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`pl-8`})]}),(0,U.jsx)(K5,{label:`State`,children:(0,U.jsx)(q5,{label:`State`,value:t.states,options:SO.map(e=>({value:e,label:CO[e]})),onChange:e=>E({states:e})})}),C.length>1?(0,U.jsx)(K5,{label:`Engine`,children:(0,U.jsx)(q5,{label:`Engine`,value:t.adapters,options:C.map(e=>({value:e,label:e})),onChange:e=>E({adapters:e})})}):null,T.length>1?(0,U.jsx)(K5,{label:`Gateway`,children:(0,U.jsx)(q5,{label:`Gateway`,value:t.gateways,options:T.map(e=>({value:e.id,label:e.name})),onChange:e=>E({gateways:e})})}):null,w.length>1?(0,U.jsx)(K5,{label:`Project`,children:(0,U.jsx)(q5,{label:`Project`,value:t.projects??[],options:w.map(e=>({value:e.key,label:e.label})),onChange:e=>E({projects:e})})}):null,(0,U.jsx)(K5,{label:`Group`,children:(0,U.jsx)(J5,{label:`Group`,value:t.groupBy,options:[{value:`none`,label:`No grouping`},{value:`state`,label:`By state`},{value:`adapter`,label:`By engine`},...w.length>1?[{value:`project`,label:`By project`}]:[],...T.length>1?[{value:`gateway`,label:`By gateway`}]:[]],onChange:e=>E({groupBy:e})})}),(0,U.jsx)(K5,{label:`Sub-agents`,children:(0,U.jsx)(J5,{label:`Sub-agents`,value:t.subagents,options:[{value:`active`,label:`Hide completed`},{value:`all`,label:`Show all`},{value:`none`,label:`Hide all`}],onChange:e=>E({subagents:e})})}),(0,U.jsx)(K5,{label:`Sort`,children:(0,U.jsx)(J5,{label:`Sort`,value:t.sortBy,options:[{value:`recent`,label:`Recent`},{value:`name`,label:`Name`},{value:`state`,label:`State`},...w.length>1?[{value:`project`,label:`Project`}]:[],...T.length>1?[{value:`gateway`,label:`Gateway`}]:[]],onChange:e=>E({sortBy:e})})})]}),S?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-label text-fg-4`,children:[(0,U.jsxs)(`span`,{children:[S.shown,` of `,S.total,S.causes.length?` · ${S.causes.join(` · `)}`:null]}),(0,U.jsx)(`button`,{type:`button`,className:`text-fg-3 underline underline-offset-2 hover:text-fg-1`,onClick:()=>n(YO(t)),children:`Show all`})]}):null,e.length===0?h??(0,U.jsx)(JT,{icon:(0,U.jsx)(cb,{}),title:`No sessions yet`}):b.length===0?Aee(t)?(0,U.jsx)(JT,{icon:(0,U.jsx)(iS,{}),title:`No matches`,description:`No session matches the current search and filters.`,action:`Clear filters`,onAction:()=>n(YO(t))}):(0,U.jsx)(JT,{icon:(0,U.jsx)(cb,{}),title:`Nothing here`,description:`No session to show.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-4 px-1`,children:x.map(e=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t.groupBy!==`none`&&e.label?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-2 text-label font-medium text-fg-4`,children:[t.groupBy===`project`?(0,U.jsx)(S5,{icon:e.rows[0]?.info.project?.icon,src:U5(e.rows[0],_),name:e.label}):null,(0,U.jsx)(`span`,{className:`uppercase tracking-wide`,children:e.label}),(0,U.jsx)(`span`,{className:`text-fg-4/70`,children:e.rows.length})]}):null,e.rows.map(e=>(0,U.jsx)(W5,{row:e,active:e.info.id===i,activeSubagentId:a,activeShellId:o,now:s,showGateway:T.length>1&&t.groupBy!==`gateway`,showProject:t.groupBy!==`project`,subagents:t.subagents,projectIcons:_,onSelect:c,onDelete:l,onRename:u,onClearContext:d,onSelectSubagent:f,onSelectShell:p,onKillShell:m},`${e.hostId}:${e.info.id}`))]},e.key))})]})}function U5(e,t){let n=e?.info.project?.icon;return n?.type===`image`?t?.[n.hash]:void 0}function W5({row:e,active:t,activeSubagentId:n,activeShellId:r,now:i,showGateway:a,showProject:o=!0,subagents:s,projectIcons:c,onSelect:l,onDelete:u,onRename:d,onClearContext:f,onSelectSubagent:p,onSelectShell:m,onKillShell:h}){let{info:g}=e,[_,y]=(0,v.useState)(!1);return(0,U.jsx)(R5,{row:e,active:t===!0,activeStepKey:r??n,now:i,showGateway:a,showProject:o,subagents:s,projectIcons:c,onSelect:()=>l?.(e),onSelectSubagent:p?t=>p(e,t):void 0,onSelectShell:m?t=>m(e,t):void 0,onKillShell:h?t=>h(e,t):void 0,onRename:d?t=>d(e,t):void 0,renameOn:`external`,editing:_,onEditingChange:y,actions:(0,U.jsxs)(U.Fragment,{children:[d&&!_?(0,U.jsx)(G5,{label:`Rename session`,onClick:()=>y(!0),children:(0,U.jsx)(mx,{className:`size-3 text-fg-3`})}):null,f&&g.capabilities?.clearContext?(0,U.jsx)(G5,{label:`Clear context`,title:`Clear the conversation - the session keeps running and the old conversation stays resumable`,onClick:()=>f(e),children:(0,U.jsx)(ree,{className:`size-3 text-fg-3`})}):null,u?(0,U.jsx)(G5,{label:`Close session`,onClick:()=>u(e),children:(0,U.jsx)(nC,{className:`size-3 text-fg-3`})}):null]})})}function G5({label:e,title:t,onClick:n,children:r}){return(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":e,title:t??e,className:`size-5 shrink-0 opacity-0 transition-opacity group-hover:opacity-100`,onClick:e=>{e.stopPropagation(),n()},children:r})}function K5({label:e,children:t}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`w-14 shrink-0 truncate text-label text-fg-3`,children:e}),(0,U.jsx)(`div`,{className:`min-w-0 flex-1`,children:t})]})}function q5({label:e,value:t,options:n,onChange:r}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsxs)(jC,{multiple:!0,value:t,onValueChange:e=>r(e),children:[(0,U.jsx)(PC,{"aria-label":e,className:`min-w-0 flex-1`,children:(0,U.jsx)(MC,{children:t.length===0?`All`:t.length===1?n.find(e=>e.value===t[0])?.label??`All`:`${t.length} selected`})}),(0,U.jsx)(FC,{children:n.map(e=>(0,U.jsx)(IC,{value:e.value,children:(0,U.jsx)(NC,{children:e.label})},e.value))})]}),t.length>0?(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clear ${e}`,onClick:()=>r([]),children:(0,U.jsx)(DC,{className:`size-3 text-fg-4`})}):null]})}function J5({label:e,value:t,options:n,onChange:r}){return(0,U.jsxs)(jC,{value:t,onValueChange:e=>r(e),children:[(0,U.jsx)(PC,{"aria-label":e,className:`w-full min-w-0`,children:(0,U.jsx)(MC,{children:n.find(e=>e.value===t)?.label??e})}),(0,U.jsx)(FC,{children:n.map(e=>(0,U.jsx)(IC,{value:e.value,children:(0,U.jsx)(NC,{children:e.label})},e.value))})]})}var Y5=[`all`,`active`,`none`],X5={all:{label:`All sub-agents`,hint:`Showing every sub-agent`},active:{label:`Hide completed`,hint:`Showing running and failed sub-agents`},none:{label:`Hide sub-agents`,hint:`Sub-agents hidden`}},Z5=.34;function Q5({value:e,className:t}){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:t,children:[(0,U.jsx)(`path`,{d:`M3 5h18`}),(0,U.jsx)(`path`,{d:`M9 12h12`,opacity:e===`none`?Z5:1}),(0,U.jsx)(`path`,{d:`M9 19h12`,opacity:e===`all`?1:Z5})]})}function $5({value:e,onChange:t,className:n}){let r=X5[e];return(0,U.jsxs)(jw,{children:[(0,U.jsx)(Mw,{render:(0,U.jsxs)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Sub-agents: ${r.label}`,title:r.hint,className:W(`w-9 gap-0.5`,n),children:[(0,U.jsx)(Q5,{value:e,className:`size-4`}),(0,U.jsx)(av,{className:`size-2.5 text-fg-4`})]})}),(0,U.jsx)(Nw,{className:`min-w-44`,children:Y5.map(n=>(0,U.jsxs)(Pw,{onClick:()=>t(n),children:[(0,U.jsx)(Q5,{value:n,className:`size-4 shrink-0 text-fg-3`}),(0,U.jsx)(`span`,{className:`flex-1`,children:X5[n].label}),n===e?(0,U.jsx)(rv,{className:`size-3.5 shrink-0 text-accent`}):null]},n))})]})}function e7(){let[e,t]=(0,v.useState)(T());return(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Toggle theme`,onClick:()=>t(O()),children:e===`dark`?(0,U.jsx)(HS,{className:`size-4`}):(0,U.jsx)(Bb,{className:`size-4`})})}var t7=[{value:`default`,displayName:`Default (recommended)`,description:`The CLI's configured default model`},{value:`fable`,displayName:`Fable`,description:`Fable 5.1 · Most capable for your hardest and longest-running tasks`},{value:`opus`,displayName:`Opus`,description:`Opus 5 with 1M context · Best for everyday, complex tasks`},{value:`sonnet`,displayName:`Sonnet`,description:`Sonnet 5 · Efficient for routine tasks`},{value:`haiku`,displayName:`Haiku`,description:`Haiku 4.5 · Fastest for quick answers`}],n7=`workerdeck.transcript-density`;function r7(){return b(n7)===`compact`?`compact`:`comfortable`}function i7(e){x(n7,e)}var a7=`workerdeck.transcript-variant`;function o7(){let e=b(a7);return e===`terminal`||e===`lines`?`terminal`:`cards`}function s7(e){x(a7,e)}var c7=`workerdeck.transcript-font`;function l7(){return b(c7)===`mono`?`mono`:`sans`}function u7(e){x(c7,e)}var d7=`workerdeck.font-size`;function f7(){let e=b(d7);if(e===void 0)return;let t=Number(e);return Number.isFinite(t)&&t>=8&&t<=24?Math.round(t):void 0}function Wte(e){x(d7,e===void 0?void 0:String(Math.round(e)))}var p7=`workerdeck.catch-up`;function m7(){return b(p7)===`off`?`off`:`on`}function Gte(e){x(p7,e)}function h7({label:e,options:t,read:n,write:r,onChange:i}){let[a,o]=(0,v.useState)(n);return(0,U.jsxs)(jC,{value:a,onValueChange:e=>{o(e),r(e),i?.(e)},children:[(0,U.jsx)(PC,{"aria-label":e,className:`min-w-40`,children:(0,U.jsx)(MC,{children:t.find(e=>e.value===a)?.label})}),(0,U.jsx)(FC,{children:t.map(e=>(0,U.jsx)(IC,{value:e.value,children:(0,U.jsx)(NC,{children:e.label})},e.value))})]})}function g7({title:e,children:t}){return(0,U.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(`h3`,{className:`text-label font-medium tracking-wide text-fg-3 uppercase`,children:e}),t]})}function Kte({open:e,onOpenChange:t}){let[n,r]=(0,v.useState)(o7);return(0,U.jsx)(Fw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Iw,{size:`md`,className:`w-[min(30rem,calc(100vw-2rem))]`,children:[(0,U.jsx)(Lw,{title:`Settings`,description:`Preferences held by this browser. What a run defaults to lives on its profile; server policy lives where the gateway runs.`}),(0,U.jsx)(Rw,{children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,U.jsxs)(g7,{title:`Appearance`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Theme`}),(0,U.jsx)(e7,{})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Agent view style`}),(0,U.jsx)(h7,{label:`Agent view style`,options:[{value:`cards`,label:`Cards`},{value:`terminal`,label:`Terminal`}],read:o7,write:s7,onChange:r})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Font size`}),(0,U.jsx)(h7,{label:`Font size`,options:[{value:``,label:`Default`},{value:`11`,label:`11 px`},{value:`12`,label:`12 px`},{value:`13`,label:`13 px`},{value:`14`,label:`14 px`},{value:`15`,label:`15 px`},{value:`16`,label:`16 px`}],read:()=>String(f7()??``),write:e=>Wte(e?Number(e):void 0)})]}),n===`cards`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Agent view density`}),(0,U.jsx)(h7,{label:`Agent view density`,options:[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`}],read:r7,write:i7})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Agent view font`}),(0,U.jsx)(h7,{label:`Agent view font`,options:[{value:`sans`,label:`Regular`},{value:`mono`,label:`Monospace`}],read:l7,write:u7})]})]}):null]}),(0,U.jsx)(g7,{title:`Sessions`,children:(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsxs)(`span`,{className:`text-body-sm text-fg-2`,children:[`Catch-up mode`,(0,U.jsx)(`span`,{className:`block text-label text-fg-4`,children:`Mark what arrived since you last read a session, with a bar that counts the new rows and jumps to them.`})]}),(0,U.jsx)(h7,{label:`Catch-up mode`,options:[{value:`on`,label:`On`},{value:`off`,label:`Off`}],read:m7,write:Gte})]})})]})})]})})}function _7({className:e}){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:e,children:[(0,U.jsx)(`path`,{d:`M12 3 20.5 7.75 12 12.5 3.5 7.75Z`}),(0,U.jsx)(`path`,{d:`M3.5 12.25 12 17l8.5-4.75`}),(0,U.jsx)(`path`,{d:`M3.5 16.5 12 21.25l8.5-4.75`}),(0,U.jsx)(`path`,{d:`M12 6.15 14.85 7.75 12 9.35 9.15 7.75Z`,fill:`#2fbf71`,stroke:`none`})]})}function v7(e){let t=e,n=new Set,r=()=>t,i=()=>{for(let e of n)e()},a=e=>(n.add(e),()=>void n.delete(e));return{get:r,subscribe:a,set:e=>{t=e,i()},patch:e=>{t={...t,...e},i()},use:()=>(0,v.useSyncExternalStore)(a,r,r)}}var y7=`workerdeck.hosts.v1`;function b7(e){return`workerdeck.host.${e}.key`}var x7=`gateway`,S7=v7({hosts:[],ready:!1});function C7(e){O7.clear(),S7.set(e)}function w7(){let e=S(y7,[]);return Array.isArray(e)?e.map(({implicit:e,...t})=>t):[]}function T7(e){C(y7,e.filter(e=>!e.implicit))}function qte(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function E7(e){return b(b7(e))??``}function D7(e,t){x(b7(e),t===``?void 0:t)}var O7=new Map;function k7(e){let t=O7.get(e);if(t)return t;let n=S7.get().hosts.find(t=>t.id===e);if(!n)return;let r=ij(n);if(r===void 0)return;let i=new cj({baseUrl:r,...n.implicit?{}:oj({baseUrl:r,key:E7(n.id)})});return O7.set(e,i),i}function A7(){return S7.get().hosts.find(e=>e.implicit)??S7.get().hosts[0]}function Jte(){let e=A7();return e?k7(e.id):void 0}function j7(e){return aj(e)}function Yte(e,t){let n=w7(),r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[...n,e];T7(r),D7(e.id,t),C7({...S7.get(),hosts:[...S7.get().hosts.filter(e=>e.implicit),...r]})}function Xte(e){let t=w7().filter(t=>t.id!==e);T7(t),D7(e,``),C7({...S7.get(),hosts:[...S7.get().hosts.filter(e=>e.implicit),...t]})}async function Zte(){try{let e=await fetch(`${location.origin}/auth/status`,{headers:{accept:`application/json`}});if(!e.ok||!e.headers.get(`content-type`)?.includes(`application/json`))return!1;let t=await e.json();return typeof t==`object`&&!!t&&`enabled`in t}catch{return!1}}var M7=!1;function N7(){if(M7)return;M7=!0;let e=w7();C7({hosts:e,ready:!1}),Zte().then(t=>{C7({hosts:t?[{id:x7,name:`This gateway`,baseUrl:location.origin,implicit:!0},...e]:e,ready:!0})})}function P7(e){return N7(),S7.subscribe(e)}function F7(){return(0,v.useSyncExternalStore)(P7,S7.get,S7.get)}function Qte(){return N7(),S7.get().hosts}function $te(e){return P7(e)}function I7({host:e,submitLabel:t=`Save`,onSaved:n,actions:r}){let[i,a]=(0,v.useState)(e.name),[o,s]=(0,v.useState)(e.baseUrl),[c,l]=(0,v.useState)(()=>E7(e.id));return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label text-fg-3`,children:`Name`}),(0,U.jsx)(_o,{value:i,onChange:e=>a(e.target.value),placeholder:`Mac mini`})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label text-fg-3`,children:`Address`}),(0,U.jsx)(_o,{value:o,onChange:e=>s(e.target.value),placeholder:`http://toby.ts.net:8787`,spellCheck:!1,className:`font-mono`})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label text-fg-3`,children:`Auth key`}),(0,U.jsx)(_o,{type:`password`,value:c,onChange:e=>l(e.target.value),placeholder:`Leave empty for an unauthenticated gateway`,spellCheck:!1}),(0,U.jsx)(`span`,{className:`text-label text-fg-4`,children:`Stored in this browser’s local storage, and sent on the WebSocket URL when attaching. Use a gateway you control, over a network you trust.`})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2`,children:[r,(0,U.jsx)(lo,{onClick:()=>{if(ij({baseUrl:o})===void 0){DT.error(`That address is not a URL`);return}if(!i.trim()){DT.error(`Give the gateway a name`);return}let t={id:e.id,name:i.trim(),baseUrl:o.trim()};Yte(t,c),n(t)},children:t})]})]})}function ene({open:e,onOpenChange:t,onCreated:n}){let[r,i]=(0,v.useState)(()=>L7());return(0,U.jsx)(Fw,{open:e,onOpenChange:e=>{e&&i(L7()),t(e)},children:(0,U.jsxs)(Iw,{children:[(0,U.jsx)(Lw,{title:`Add gateway`,description:`A workerdeck gateway you run - typically over Tailscale.`}),(0,U.jsx)(Rw,{children:(0,U.jsx)(I7,{host:r,submitLabel:`Add gateway`,onSaved:n,actions:(0,U.jsx)(lo,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`})})})]})})}function L7(){return{id:qte(),name:``,baseUrl:``}}function R7({host:e,onClose:t,onRemoved:n}){return(0,U.jsx)(Fw,{open:!0,onOpenChange:e=>!e&&t(),children:(0,U.jsxs)(Iw,{children:[(0,U.jsx)(Lw,{title:`Remove ${e.name}?`,description:`Its auth key is deleted from this browser. The gateway itself keeps running.`}),(0,U.jsx)(Rw,{children:(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(lo,{variant:`outline`,onClick:t,children:`Cancel`}),(0,U.jsx)(lo,{variant:`destructive`,onClick:()=>{Xte(e.id),n()},children:`Remove`})]})})]})})}function z7(e){return e===`sessions`?`workerdeck.sessions-sidebar-width`:`workerdeck.${e}-sidebar-width`}function B7(e){return e===`sessions`?`workerdeck.sessions-sidebar-collapsed`:`workerdeck.${e}-sidebar-collapsed`}function tne(e){let t=Number(b(z7(e)));return t?Math.min(520,Math.max(240,t)):300}function nne(e,t){x(z7(e),String(t))}function rne(e){return b(B7(e))===`1`}function ine(e,t){x(B7(e),t?`1`:`0`)}var V7=`workerdeck.sessions-filters-shown`;function ane(){return b(V7)===`1`}function one(e){x(V7,e?`1`:`0`)}function H7({section:e,title:t,badge:n,actions:r,children:i,rail:a,railActions:o}){let[s,c]=(0,v.useState)(()=>tne(e)),[l,u]=(0,v.useState)(()=>rne(e)),d=t=>{u(t),ine(e,t)};return l?(0,U.jsxs)(`div`,{className:`flex min-h-0 w-11 shrink-0 flex-col items-center gap-1 border-r border-border bg-sidebar py-1.5`,children:[(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Expand ${t.toLowerCase()}`,onClick:()=>d(!1),children:(0,U.jsx)(ox,{className:`size-4`})}),o,a?(0,U.jsx)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col items-center gap-0.5 overflow-y-auto pt-1`,children:a}):null]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{style:{width:s},className:`flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar`,children:[(0,U.jsxs)(`header`,{className:`flex h-9 shrink-0 items-center gap-1 pr-1 pl-3`,children:[(0,U.jsx)(`span`,{className:`truncate text-label font-medium tracking-wide text-fg-3 uppercase`,children:t}),n,(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Collapse ${t.toLowerCase()}`,onClick:()=>d(!0),children:(0,U.jsx)(ix,{className:`size-3.5`})}),r]}),i]}),(0,U.jsx)(qT,{orientation:`vertical`,value:s,onValueChange:t=>{c(t),nne(e,t)},min:240,max:520,defaultValue:300,"aria-label":`Resize ${t.toLowerCase()} sidebar`})]})}function U7({children:e,className:t}){return(0,U.jsx)(`div`,{className:W(`min-h-0 flex-1 overflow-y-auto pb-2`,t),children:e})}function W7({title:e,status:t,description:n,actions:r,active:i,onSelect:a,onDoubleClick:o}){return(0,U.jsxs)(`div`,{"data-slot":`sidebar-row`,"data-active":i||void 0,onClick:a,onDoubleClick:o,className:W(`group flex cursor-pointer flex-col gap-0.5 text-left transition-colors`,V5(i===!0)),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`button`,{type:`button`,className:W(`min-w-0 flex-1 truncate text-left text-body-sm outline-none`,i?`font-medium text-fg-1`:`text-fg-2`),children:e}),t]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 text-label text-fg-4`,children:[(0,U.jsx)(`button`,{type:`button`,tabIndex:-1,className:`flex min-w-0 flex-1 items-center gap-1.5 truncate text-left font-mono outline-none`,children:n}),r]})]})}function G7({label:e,onClick:t,children:n}){return(0,U.jsx)(`button`,{type:`button`,"aria-label":e,title:e,onClick:e=>{e.stopPropagation(),t()},className:`flex size-5 shrink-0 items-center justify-center rounded text-fg-3 opacity-0 transition-opacity outline-none hover:bg-surface-hover hover:text-fg-1 group-hover:opacity-100`,children:n})}var K7=`workerdeck.watermarks.v1`,q7=v7(0),J7=new Fk({read:()=>S(K7,void 0),write:e=>{C(K7,e),q7.set(q7.get()+1)}});function Y7(){return q7.use(),{unseenFor:(0,v.useCallback)((e,t)=>Ik(J7.get(e,t.id),{proseCount:t.proseCount,activityCount:t.activityCount,turns:t.numTurns}),[]),watermarks:J7}}function sne(e,t){let n=J7.get(e,t);return n?{itemCount:n.itemCount,since:n.seenAt}:void 0}function cne(e,t){let n=(0,v.useRef)({});return(0,v.useCallback)(r=>{t&&!document.hidden&&(n.current={...n.current,...r},J7.mark(e,t,n.current))},[e,t])}function lne(e){let{unseenFor:t}=Y7();return(0,v.useMemo)(()=>e.reduce((e,n)=>e+t(n.hostId,n.info),0),[e,t])}var une=5e3,dne=1200,fne=700,X7=v7({snapshots:[],loaded:!1}),pne=X7.set,Z7,Q7=0,$7;function e9(){return Z7??=(async()=>{Q7=Date.now();try{let e=Qte(),t=new Map(X7.get().snapshots.map(e=>[e.host.id,e]));pne({snapshots:await Promise.all(e.map(async e=>{let n=k7(e.id);if(!n)return{host:e,sessions:[],error:`unusable address`};try{return{host:e,sessions:await n.listSessions()}}catch(n){return{host:e,sessions:t.get(e.id)?.sessions??[],error:n instanceof Error?n.message:String(n)}}})),loaded:!0})}finally{Z7=void 0}})(),Z7}function mne(){if($7!==void 0)return;let e=Math.max(0,fne-(Date.now()-Q7));$7=setTimeout(()=>{$7=void 0,e9()},e)}var t9,n9;function hne(e){let t=e?dne:une;(t9===void 0||n9!==t)&&(t9!==void 0&&clearInterval(t9),n9=t,t9=setInterval(()=>void e9(),t))}function r9(){let e=X7.use();(0,v.useEffect)(()=>$te(()=>void e9()),[]);let t=e.snapshots.some(e=>e.sessions.some(e=>{let t=wO(e);return t===`working`||t===`attention`}));return(0,v.useEffect)(()=>{hne(t),X7.get().loaded||e9()},[t]),{...e,refresh:e9}}function i9(e){let{unseenFor:t}=Y7();return(0,v.useMemo)(()=>e.flatMap(({host:e,sessions:n})=>n.filter(e=>!LO(e)).map(n=>({hostId:e.id,hostName:e.name,local:j7(e),adapter:n.engine??`claude`,state:wO(n),info:n,unseen:t(e.id,n)}))),[e,t])}function gne(){let e=jr(),t=bi({select:e=>e.location.pathname.match(/^\/gateways\/(.+)$/)?.[1]}),{hosts:n,ready:r}=F7(),{snapshots:i}=r9(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),l=i.filter(e=>e.error===void 0).length,u=(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Add gateway`,onClick:()=>o(!0),children:(0,U.jsx)(wx,{className:`size-4`})});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(H7,{section:`gateways`,title:`Gateways`,badge:r&&n.length>0?(0,U.jsxs)(`span`,{className:`shrink-0 text-label text-fg-4`,children:[l,`/`,n.length]}):void 0,actions:u,railActions:u,children:(0,U.jsxs)(U7,{children:[r&&n.length===0?(0,U.jsx)(JT,{icon:(0,U.jsx)(cS,{}),title:`No gateways yet`,description:(0,U.jsxs)(U.Fragment,{children:[`Add one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})}):null,n.map(n=>{let r=i.find(e=>e.host.id===n.id),a=r===void 0?`pending`:r.error?`error`:`ok`;return(0,U.jsx)(W7,{active:n.id===t,onSelect:()=>void e({to:`/gateways/$hostId`,params:{hostId:n.id}}),title:n.name,status:(0,U.jsxs)(U.Fragment,{children:[n.implicit?(0,U.jsx)(`span`,{className:`shrink-0 text-label text-fg-4`,children:`this page`}):null,(0,U.jsx)(`span`,{"aria-hidden":!0,title:r?.error??(a===`ok`?`Connected`:`Connecting…`),className:W(`size-1.5 shrink-0 rounded-full`,a===`ok`?`bg-success`:a===`error`?`bg-danger`:`bg-fg-4`)})]}),description:n.baseUrl,actions:n.implicit?null:(0,U.jsx)(G7,{label:`Remove ${n.name}`,onClick:()=>c(n),children:(0,U.jsx)(nC,{className:`size-3`})})},n.id)})]})}),s?(0,U.jsx)(R7,{host:s,onClose:()=>c(void 0),onRemoved:()=>{let n=s.id===t;c(void 0),n&&e({to:`/gateways`})}}):null,(0,U.jsx)(ene,{open:a,onOpenChange:o,onCreated:t=>{o(!1),e({to:`/gateways/$hostId`,params:{hostId:t.id}})}})]})}function a9({value:e,onChange:t,models:n=t7,className:r}){return(0,U.jsx)(f4,{variant:`form`,models:n,model:e||void 0,onModelChange:e=>t(e??``),className:r})}function _ne({profiles:e,value:t,onChange:n,className:r}){return e.length===0?null:(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Profile`}),(0,U.jsxs)(jC,{items:e.map(e=>({value:e.name,label:e.name})),value:t,onValueChange:e=>n(e),children:[(0,U.jsx)(PC,{className:r,children:(0,U.jsx)(MC,{})}),(0,U.jsx)(FC,{children:e.map(e=>(0,U.jsx)(IC,{value:e.name,children:(0,U.jsx)(NC,{children:(0,U.jsxs)(`span`,{className:e.available===!1?`text-fg-4`:void 0,title:e.unavailableReason,children:[e.description?`${e.name} - ${e.description}`:e.name,e.available===!1?` (unavailable)`:``]})})},e.name))})]})]})}function o9(){return Jte()}function s9(e,t,n){let r=e?.capabilities??zk[e?.engine??`claude`],i=r.permissionModes.includes(t)?t:r.defaultPermissionMode,a,o;if(e?.models?.length)a=e.models,o=e.defaultModel;else if(e?.engine===`provider`){let t=e.provider;a=(t?.models?.length?t.models:t?.model?[t.model]:[]).map(e=>({value:e,displayName:e})),o=t?.model}else a=t7.filter(e=>e.value!=="default");let s=a.find(e=>e.value===n||e.resolvedModel===n),c=s||n===``?n:``;return{capabilities:r,modes:r.permissionModes,models:[{value:`default`,displayName:`Profile default`,description:o??`the profile's configured model`},...a],mode:i,model:c,reasoningEfforts:(s?s.reasoningEfforts:void 0)??r.reasoningEfforts??[]}}var c9={profiles:[]},l9,u9,d9=new Set;async function f9(){let e=await(o9()?.listProfiles().catch(()=>c9)??Promise.resolve(c9));l9=e;for(let t of d9)t(e);return e}function p9(){let[e,t]=(0,v.useState)(l9??c9);(0,v.useEffect)(()=>(d9.add(t),l9||(u9??=f9()),()=>{d9.delete(t)}),[]);let n=(0,v.useCallback)(async()=>{u9=f9(),await u9},[]);return{...e,refresh:n}}function vne(){return p9().profiles}var m9=`workerdeck.last-profile`;function yne(){let e=vne(),[t,n]=(0,v.useState)(()=>b(m9)??``),r=e.some(e=>e.name===t)?t:e[0]?.name??``;return{profiles:e,profile:r,selected:e.find(e=>e.name===r),select:e=>{n(e),x(m9,e)}}}var h9=`workerdeck.last-cwd`;function bne(e){let[t,n]=(0,v.useState)([]);return(0,v.useEffect)(()=>{o9()?.listHostRoots().then(e=>n(e.roots.map(e=>e.path))).catch(()=>n([]))},[]),(0,v.useMemo)(()=>{let n=b(h9),r=[...n?[n]:[],...[...e].sort((e,t)=>(t.lastActivityAt??t.createdAt)-(e.lastActivityAt??e.createdAt)).map(e=>e.cwd),...t];return[...new Set(r)].slice(0,12)},[e,t])}var xne={session:`default`,job:`acceptEdits`},Sne={session:`ask`,job:`auto`};function g9(e){let[t,n]=(0,v.useState)(()=>b(h9)??``),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(void 0),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(Sne[e]),{profiles:p,profile:m,selected:h,select:g}=yne(),_=s9(h,s??h?.defaults?.permissionMode??xne[e],a);return{cwd:t,setCwd:n,prompt:r,setPrompt:i,mode:_.mode,setMode:c,model:a,setModel:o,effort:l,setEffort:u,questions:d,setQuestions:f,profiles:p,profile:m,selectProfile:g,engine:_,sessionFields:e=>({cwd:_.capabilities.hostCwd===!1?void 0:t.trim(),profile:m||void 0,prompt:e.prompt,permissionMode:_.mode,model:_.model.trim()||void 0,resume:e.resume,reasoningEffort:l&&_.reasoningEfforts.includes(l)?l:void 0,questionBehavior:_.capabilities.interactiveApprovals?d:void 0,..._.capabilities.settingSources?{settingSources:[`user`,`project`],allowDangerouslySkipPermissions:e.allowBypass||void 0}:{}}),rememberCwd:e=>x(h9,t.trim()||e)}}function _9({form:e}){return e.engine.capabilities.interactiveApprovals?(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Questions`}),(0,U.jsxs)(jC,{items:R4.map(e=>({value:e.value,label:e.label})),value:e.questions,onValueChange:t=>e.setQuestions(t),children:[(0,U.jsx)(PC,{className:`min-w-36`,children:(0,U.jsx)(MC,{})}),(0,U.jsx)(FC,{children:R4.map(e=>(0,U.jsx)(IC,{value:e.value,children:(0,U.jsx)(NC,{children:`${e.label} - ${e.description}`})},e.value))})]})]}):null}function v9({form:e,sessions:t,promptLabel:n,promptPlaceholder:r=`e.g. /verify-content 42, or a task description`,extras:i,actions:a,onProfileChange:o}){let s=bne(t),c=(0,v.useId)(),{engine:l}=e;return(0,U.jsxs)(U.Fragment,{children:[l.capabilities.hostCwd!==!1&&(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Working directory`}),(0,U.jsx)(_o,{value:e.cwd,list:c,onChange:t=>e.setCwd(t.target.value),placeholder:`/path/to/project`,spellCheck:!1,className:`font-mono`}),(0,U.jsx)(`datalist`,{id:c,children:s.map(e=>(0,U.jsx)(`option`,{value:e},e))})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:n}),(0,U.jsx)(vo,{value:e.prompt,onChange:t=>e.setPrompt(t.target.value),rows:2,placeholder:r})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(_ne,{profiles:e.profiles,value:e.profile,onChange:t=>{e.selectProfile(t),o?.(t)},className:`min-w-32`}),(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Permission mode`}),(0,U.jsx)(g4,{variant:`form`,mode:l.mode,onModeChange:e.setMode,modes:l.modes,className:`min-w-44`})]}),i,(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Model`}),(0,U.jsx)(a9,{value:l.model,onChange:e.setModel,models:l.models,className:`min-w-40`})]}),l.reasoningEfforts.length>0?(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Effort`}),(0,U.jsxs)(jC,{items:[{value:`default`,label:`Default`},...l.reasoningEfforts.map(e=>({value:e,label:e}))],value:e.effort||`default`,onValueChange:t=>e.setEffort(t==="default"?``:String(t)),children:[(0,U.jsx)(PC,{className:`min-w-28`,children:(0,U.jsx)(MC,{})}),(0,U.jsx)(FC,{children:[`default`,...l.reasoningEfforts].map(e=>(0,U.jsx)(IC,{value:e,children:(0,U.jsx)(NC,{children:e})},e))})]})]}):null,a]})]})}var Cne=15e3,y9=v7({jobs:[],stats:void 0,enabled:!0,live:!1,error:void 0}),b9=y9.patch,x9;function S9(){return x9??=(async()=>{try{let e=o9();if(!e)return;let[t,n]=await Promise.all([e.listJobs(),e.queueStats()]);b9({jobs:t,stats:n,enabled:!0,error:void 0})}catch(e){let t=e instanceof Error?e.message:String(e);/not configured/i.test(t)?b9({enabled:!1,error:void 0}):b9({error:t})}finally{x9=void 0}})(),x9}var C9=0,w9,T9;function wne(e){let t=y9.subscribe(e);return++C9===1&&(S9(),w9=setInterval(()=>void S9(),Cne)),()=>{t(),--C9===0&&(clearInterval(w9),w9=void 0,T9?.(),T9=void 0,b9({live:!1}))}}function Tne(){if(T9||!y9.get().enabled||y9.get().stats===void 0||C9===0)return;let e=o9();if(!e)return;let t=e.attachQueue(),n=[t.on(`attached`,()=>void S9()),t.on(`stats`,e=>b9({stats:e})),t.on(`connectionChange`,e=>b9({live:e})),t.on(`event`,e=>{b9({jobs:y9.get().jobs.some(t=>t.id===e.job.id)?y9.get().jobs.map(t=>t.id===e.job.id?e.job:t):[...y9.get().jobs,e.job]})})];T9=()=>{for(let e of n)e();t.detach()}}function E9(){let e=(0,v.useSyncExternalStore)(wne,y9.get,y9.get);return(0,v.useEffect)(Tne,[e.enabled,e.stats]),{...e,refresh:S9}}function Ene({stats:e}){let t=e.dailyTokenLimit!==void 0&&e.dailyTokenLimit>0?e.dailyTokensUsed/e.dailyTokenLimit*100:void 0;return(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-5 gap-y-2 rounded-md border border-border bg-surface px-3 py-2 text-body-sm text-fg-2`,children:[(0,U.jsxs)(`span`,{children:[`Running`,` `,(0,U.jsxs)(`span`,{className:`font-mono text-fg-1`,children:[e.running,`/`,e.maxConcurrency]})]}),(0,U.jsxs)(`span`,{children:[`Queued `,(0,U.jsx)(`span`,{className:`font-mono text-fg-1`,children:e.queued})]}),e.parked>0?(0,U.jsxs)(`span`,{children:[`Parked `,(0,U.jsx)(`span`,{className:`font-mono text-fg-1`,children:e.parked})]}):null,(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[t===void 0?null:(0,U.jsx)(XT,{value:t,className:t>=95?`text-danger`:t>=80?`text-warning`:`text-fg-3`}),`Daily tokens`,` `,(0,U.jsxs)(`span`,{className:`font-mono text-fg-1`,children:[fM(e.dailyTokensUsed),e.dailyTokenLimit===void 0?``:` / ${fM(e.dailyTokenLimit)}`]})]}),e.sessionTokenLimit===void 0?null:(0,U.jsxs)(`span`,{children:[`Per-job cap `,(0,U.jsx)(`span`,{className:`font-mono text-fg-1`,children:fM(e.sessionTokenLimit)})]}),e.paused?(0,U.jsx)(fo,{variant:`warning`,dot:!0,children:`Paused - daily budget exhausted`}):null]})}function Dne({onScheduled:e}){let{snapshots:t}=r9(),n=t.find(e=>e.host.id===A7()?.id)?.sessions??[],r=g9(`job`),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),{engine:m}=r,h=async()=>{if(!r.cwd.trim()||!r.prompt.trim()){DT.error(`Working directory and prompt are required`);return}let t=o.trim()?Number(o.trim()):void 0;if(t!==void 0&&(!Number.isFinite(t)||t<=0)){DT.error(`Max tokens must be a positive number`);return}let n=c.trim()?Number(c.trim()):void 0;if(n!==void 0&&(!Number.isInteger(n)||n<1)){DT.error(`Attempts must be a whole number of at least 1`);return}p(!0);try{r.rememberCwd(r.cwd.trim()),await o9().createJob({session:{...r.sessionFields({allowBypass:i}),prompt:r.prompt.trim()},maxTokens:t,attempts:n,webhook:u.trim()?{url:u.trim()}:void 0}),r.setPrompt(``),DT.success(`Job scheduled`),e()}catch(e){DT.error(e instanceof Error?e.message:`Failed to schedule job`)}finally{p(!1)}};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(v9,{form:r,sessions:n,promptLabel:`Prompt (the task - runs unattended)`,extras:(0,U.jsx)(_9,{form:r}),actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Max tokens (optional)`}),(0,U.jsx)(_o,{value:o,onChange:e=>s(e.target.value),placeholder:`per-job cap`,inputMode:`numeric`,className:`min-w-28 font-mono`})]}),(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Attempts (optional)`}),(0,U.jsx)(_o,{value:c,onChange:e=>l(e.target.value),placeholder:`1`,inputMode:`numeric`,className:`min-w-20 font-mono`})]}),(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Webhook URL (optional)`}),(0,U.jsx)(_o,{value:u,onChange:e=>d(e.target.value),placeholder:`https://…/hook`,spellCheck:!1,className:`min-w-44 font-mono`})]}),(0,U.jsxs)(lo,{className:`ml-auto`,onClick:()=>void h(),disabled:f,children:[f?(0,U.jsx)(GT,{className:`size-3.5 text-current`}):(0,U.jsx)(wx,{className:`size-4`}),`Schedule`]})]})}),m.capabilities.settingSources?(0,U.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2 text-body-sm text-fg-2`,title:`Spawns the CLI with --dangerously-skip-permissions available, so the mode can be switched on while watching the run. The job still starts in the mode selected above.`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),className:`size-3.5 accent-(--color-fg-1)`}),`Allow switching to `,(0,U.jsx)(`code`,{className:`font-mono`,children:`bypassPermissions`}),` mid-run`,(0,U.jsx)(`span`,{className:`text-label text-fg-4`,children:`(dangerous)`})]}):null,(0,U.jsxs)(`p`,{className:`text-label text-fg-4`,children:[`Unattended runs still surface permission prompts - the job's page is read-only, so answer them from the session itself, or pick a mode that doesn't ask. Unanswered prompts deny after the server's timeout. With Questions set to Ask, webhook deliveries carry the full question so a controller can answer via `,(0,U.jsx)(`code`,{className:`font-mono`,children:`POST /sessions/:id/permissions/:requestId`}),`.`]})]})}function One({open:e,onOpenChange:t,onScheduled:n}){return(0,U.jsx)(Fw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Iw,{size:`lg`,children:[(0,U.jsx)(Lw,{title:`Schedule a job`,description:`A one-shot run the queue executes unattended.`}),(0,U.jsx)(Rw,{children:e?(0,U.jsx)(Dne,{onScheduled:n}):null})]})})}function kne(){let{stats:e,enabled:t,error:n}=E9();return(0,U.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[n?(0,U.jsxs)(`div`,{className:`rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger`,children:[`Can't reach the worker server: `,n,`. Start it with `,(0,U.jsx)(`code`,{className:`font-mono`,children:`pnpm server`}),`.`]}):null,t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(JT,{icon:(0,U.jsx)(vb,{}),title:`No job selected`,description:(0,U.jsxs)(U.Fragment,{children:[`Pick one on the left, or schedule one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})}),e?(0,U.jsx)(`div`,{className:`mt-2 w-full max-w-xl`,children:(0,U.jsx)(Ene,{stats:e})}):null]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(q_,{className:`size-8 text-fg-4`}),(0,U.jsx)(`p`,{className:`text-body-sm text-fg-3`,children:`The server has no job queue configured.`}),(0,U.jsxs)(`p`,{className:`max-w-md text-label text-fg-4`,children:[`Pass `,(0,U.jsxs)(`code`,{className:`font-mono`,children:[`queue: `,`{ maxConcurrency, … }`]}),` to`,` `,(0,U.jsx)(`code`,{className:`font-mono`,children:`createWorkerServer`}),` - the dev server enables it by default.`]})]})]})}var D9={queued:{label:`Queued`,variant:`neutral`},running:{label:`Running`,variant:`info`,busy:!0},parked:{label:`Parked`,variant:`accent`},succeeded:{label:`Succeeded`,variant:`success`},failed:{label:`Failed`,variant:`danger`},canceled:{label:`Canceled`,variant:`warning`}},Ane=[`queued`,`running`,`parked`];function jne(){let e=jr(),t=bi({select:e=>e.location.pathname.match(/^\/jobs\/(.+)$/)?.[1]}),{jobs:n,enabled:r,live:i,refresh:a}=E9(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),f=c.trim().toLowerCase(),p=[...n].sort((e,t)=>t.createdAt-e.createdAt).filter(e=>(!u||Ane.includes(e.status))&&(!f||e.prompt.toLowerCase().includes(f)||e.cwd.toLowerCase().includes(f)||(e.profile?.toLowerCase().includes(f)??!1)||e.id.startsWith(f))),m=n.length-p.length,h=r?(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Schedule a job`,onClick:()=>s(!0),children:(0,U.jsx)(wx,{className:`size-4`})}):void 0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(H7,{section:`jobs`,title:`Jobs`,badge:r?(0,U.jsx)(`span`,{"aria-hidden":!0,title:i?`Streaming over the queue socket`:`Polling`,className:W(`size-1.5 shrink-0 rounded-full`,i?`bg-success`:`bg-fg-4`)}):void 0,actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh`,onClick:()=>void a(),children:(0,U.jsx)(Rx,{className:`size-3.5`})}),h]}),railActions:h,children:r?(0,U.jsxs)(U.Fragment,{children:[n.length>0?(0,U.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pb-2`,children:[(0,U.jsx)(_o,{value:c,onChange:e=>l(e.target.value),placeholder:`Search jobs`,"aria-label":`Search jobs`,className:`h-7 min-w-0 flex-1 text-body-sm`}),(0,U.jsx)(lo,{variant:u?`default`:`outline`,size:`xs`,"aria-pressed":u,onClick:()=>d(!u),children:`Active`})]}):null,(0,U.jsxs)(U7,{children:[n.length===0?(0,U.jsx)(JT,{icon:(0,U.jsx)(bb,{}),title:`No jobs yet`,description:(0,U.jsxs)(U.Fragment,{children:[`Schedule one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})}):p.length===0?(0,U.jsx)(JT,{icon:(0,U.jsx)(iS,{}),title:`No matches`,description:`No job matches the active filter.`,action:`Show all`,onAction:()=>d(!1)}):null,p.map(n=>(0,U.jsx)(Mne,{job:n,active:n.id===t,onOpen:()=>void e({to:`/jobs/$jobId`,params:{jobId:n.id}}),onChanged:()=>void a()},n.id)),m>0?(0,U.jsxs)(`p`,{className:`px-1 pt-2 text-center text-label text-fg-4`,children:[p.length,` of `,n.length]}):null]})]}):(0,U.jsx)(JT,{icon:(0,U.jsx)(bb,{}),title:`No job queue`,description:`This gateway runs without one, so there is nothing to schedule against.`})}),(0,U.jsx)(One,{open:o,onOpenChange:s,onScheduled:()=>{s(!1),a()}})]})}function Mne({job:e,active:t,onOpen:n,onChanged:r}){let i=D9[e.status],a=e.status===`queued`||e.status===`running`||e.status===`parked`,o=[hM(e.finishedAt??e.startedAt??e.createdAt),e.cwd.split(`/`).filter(Boolean).pop()??e.cwd];e.profile&&o.push(`@${e.profile}`);let s=e.usage.costUsd??e.usage.totalCostUsd;return s>0&&o.push(uM(s)),(0,U.jsx)(W7,{active:t,onSelect:n,title:e.prompt,status:(0,U.jsxs)(fo,{variant:i.variant,dot:!i.busy,className:`shrink-0`,children:[i.busy?(0,U.jsx)(GT,{className:`size-3 text-current`}):null,i.label]}),description:o.join(` · `),actions:a?(0,U.jsx)(G7,{label:`Cancel job`,onClick:()=>{o9()?.cancelJob(e.id).then(r).catch(e=>DT.error(e instanceof Error?e.message:`Cancel failed`))},children:(0,U.jsx)(DC,{className:`size-3`})}):null})}var O9=[`web_search`,`download`,`web_fetch`,`deliver_file`];function k9(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}function A9({label:e,children:t}){return(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:e}),t]})}function Nne({onCreated:e}){let[t,n]=(0,v.useState)(`provider`),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(!1),O=t===`provider`,k=t===`codex`,A=async()=>{if(!r.trim()){DT.error(`Name is required`);return}let n={name:r.trim(),engine:t};if(a.trim()&&(n.description=a.trim()),O){n.provider={id:s.trim(),model:l.trim()||void 0,models:k9(d).length>0?k9(d):void 0,apiKeyEnv:p.trim()||void 0};let e={};b.length>0&&(e.capabilities=b),k9(S).length>0&&(e.mcpServers=k9(S)),w.trim()&&(e.instructions=w.trim()),Object.keys(e).length>0&&(n.session=e)}else k?_.trim()&&(n.codexHome=_.trim()):n.configDir=h.trim();D(!0);try{await o9().createProfile(n),DT.success(`Profile '${n.name}' created`),e(n.name)}catch(e){DT.error(e instanceof Error?e.message:`Failed to create profile`)}finally{D(!1)}};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`Engine`,children:(0,U.jsxs)(jC,{items:[{value:`provider`,label:`provider`},{value:`claude`,label:`claude`},{value:`codex`,label:`codex`}],value:t,onValueChange:e=>n(e),children:[(0,U.jsx)(PC,{className:`min-w-32`,children:(0,U.jsx)(MC,{})}),(0,U.jsxs)(FC,{children:[(0,U.jsx)(IC,{value:`provider`,children:(0,U.jsx)(NC,{children:`provider - model-agnostic engine`})}),(0,U.jsx)(IC,{value:`claude`,children:(0,U.jsx)(NC,{children:`claude - Agent SDK + config dir`})}),(0,U.jsx)(IC,{value:`codex`,children:(0,U.jsx)(NC,{children:`codex - app-server + CODEX_HOME`})})]})]})}),(0,U.jsx)(A9,{label:`Name`,children:(0,U.jsx)(_o,{value:r,onChange:e=>i(e.target.value),placeholder:`kimi`})}),(0,U.jsx)(A9,{label:`Description (optional)`,children:(0,U.jsx)(_o,{value:a,onChange:e=>o(e.target.value),placeholder:`what this profile is for`})})]}),O?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`Provider id`,children:(0,U.jsx)(_o,{value:s,onChange:e=>c(e.target.value),placeholder:`anthropic / openai / moonshotai`,className:`font-mono`})}),(0,U.jsx)(A9,{label:`Default model`,children:(0,U.jsx)(_o,{value:l,onChange:e=>u(e.target.value),placeholder:`kimi-k3`,className:`font-mono`})}),(0,U.jsx)(A9,{label:`Models offered (comma-separated)`,children:(0,U.jsx)(_o,{value:d,onChange:e=>f(e.target.value),placeholder:`kimi-k3, kimi-k2`,className:`font-mono`})}),(0,U.jsx)(A9,{label:`API key variable`,children:(0,U.jsx)(_o,{value:p,onChange:e=>m(e.target.value),placeholder:`MOONSHOT_API_KEY`,className:`font-mono`})})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`Capabilities granted`,children:(0,U.jsx)(`div`,{className:`flex flex-wrap gap-3 py-1.5`,children:O9.map(e=>(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:b.includes(e),onChange:t=>x(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e)),className:`size-3.5 accent-(--color-fg-1)`}),(0,U.jsx)(`code`,{className:`font-mono text-label`,children:e})]},e))})}),(0,U.jsx)(A9,{label:`MCP servers (names, comma-separated)`,children:(0,U.jsx)(_o,{value:S,onChange:e=>C(e.target.value),placeholder:`deepwiki`,className:`font-mono`})})]}),(0,U.jsx)(A9,{label:`Instructions (optional)`,children:(0,U.jsx)(_o,{value:w,onChange:e=>T(e.target.value),placeholder:`prepended to the session's system prompt`})}),(0,U.jsx)(`p`,{className:`text-label text-fg-4`,children:`Leave capabilities and MCP servers empty to inherit whatever the server's engine factory wired - that factory is the ceiling either way, so a grant here can never exceed it. MCP servers are named, never configured: their transport config (and any credentials in it) stays on the server.`})]}):k?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(A9,{label:`Home directory (optional)`,children:(0,U.jsx)(_o,{value:_,onChange:e=>y(e.target.value),placeholder:`/Users/you/.codex`,spellCheck:!1,className:`font-mono`})}),(0,U.jsxs)(`p`,{className:`text-label text-fg-4`,children:[`This profile's `,(0,U.jsx)(`code`,{className:`font-mono`,children:`CODEX_HOME`}),`. Must resolve inside the server's`,` `,(0,U.jsx)(`code`,{className:`font-mono`,children:`allowedConfigDirRoots`}),` - a home directory is a credential store, so the server bounds which ones a managed profile may point at. Leave it empty to run on the server's own environment.`]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(A9,{label:`Config directory`,children:(0,U.jsx)(_o,{value:h,onChange:e=>g(e.target.value),placeholder:`/Users/you/.claude`,spellCheck:!1,className:`font-mono`})}),(0,U.jsxs)(`p`,{className:`text-label text-fg-4`,children:[`Must resolve inside the server's `,(0,U.jsx)(`code`,{className:`font-mono`,children:`allowedConfigDirRoots`}),` - a config directory is a credential store, so the server bounds which ones a managed profile may point at.`]})]}),(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsxs)(lo,{onClick:()=>void A(),disabled:E,children:[E?(0,U.jsx)(GT,{className:`size-3.5 text-current`}):(0,U.jsx)(wx,{className:`size-4`}),`Create profile`]})})]})}function Pne({open:e,onOpenChange:t,onCreated:n}){return(0,U.jsx)(Fw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Iw,{size:`lg`,children:[(0,U.jsx)(Lw,{title:`New profile`,description:`What a session runs as - a Claude config directory, or a model provider.`}),(0,U.jsx)(Rw,{children:e?(0,U.jsx)(Nne,{onCreated:n}):null})]})})}function Fne(){let e=jr(),t=bi({select:e=>e.location.pathname.match(/^\/profiles\/(.+)$/)?.[1]}),{profiles:n,canManage:r,refresh:i}=p9(),[a,o]=(0,v.useState)(!1),s=r?(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`New profile`,onClick:()=>o(!0),children:(0,U.jsx)(wx,{className:`size-4`})}):void 0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(H7,{section:`profiles`,title:`Profiles`,badge:n.length>0?(0,U.jsx)(`span`,{className:`shrink-0 text-label text-fg-4`,children:n.length}):void 0,actions:s,railActions:s,children:(0,U.jsxs)(U7,{children:[n.length===0?(0,U.jsx)(JT,{icon:(0,U.jsx)(Xy,{}),title:r?`No profiles yet`:`No profiles`,description:r?(0,U.jsxs)(U.Fragment,{children:[`Add one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]}):`This gateway declares none, and this login may not add them.`}):null,n.map(n=>(0,U.jsx)(W7,{active:n.name===t,onSelect:()=>void e({to:`/profiles/$profileName`,params:{profileName:n.name}}),title:n.name,status:n.managed?null:(0,U.jsx)(fo,{variant:`neutral`,className:`shrink-0`,children:`declared`}),description:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(A5,{engine:n.engine??`claude`,model:n.defaults?.model??n.provider?.model,className:`size-3 shrink-0 text-fg-3`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:n.configDir??(n.provider?`${n.provider.id}${n.provider.model?` · ${n.provider.model}`:``}`:n.engine??`claude`)})]})},n.name))]})}),(0,U.jsx)(Pne,{open:a,onOpenChange:o,onCreated:t=>{o(!1),i(),e({to:`/profiles/$profileName`,params:{profileName:t}})}})]})}function Ine({sessions:e,onCreated:t}){let n=g9(`session`),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(),[s,c]=(0,v.useState)(!1),{engine:l}=n,u=async e=>{let r=e?.cwd??n.cwd.trim();if(!r){DT.error(`Working directory is required`);return}i(!0);try{n.rememberCwd(r),t((await o9().createSession({...n.sessionFields({prompt:e?void 0:n.prompt.trim()||void 0,resume:e?.sessionId,allowBypass:!0}),cwd:r})).id)}catch(e){DT.error(e instanceof Error?e.message:`Failed to create session`)}finally{i(!1)}},d=async()=>{if(!n.cwd.trim()){DT.error(`Set a working directory first - resumable sessions are listed per project`);return}c(!0);try{o(await o9().listSdkSessions({dir:n.cwd.trim(),limit:20,profile:n.profile||void 0}))}catch(e){DT.error(e instanceof Error?e.message:`Failed to list resumable sessions`)}finally{c(!1)}};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(v9,{form:n,sessions:e,promptLabel:`Initial prompt (optional)`,onProfileChange:()=>o(void 0),extras:(0,U.jsx)(_9,{form:n}),actions:(0,U.jsxs)(lo,{className:`ml-auto`,onClick:()=>void u(),disabled:r,children:[r?(0,U.jsx)(GT,{className:`size-3.5 text-current`}):(0,U.jsx)(wx,{className:`size-4`}),`Create`]})}),l.capabilities.listSessions?(0,U.jsxs)(`div`,{className:`mt-1 border-t border-border pt-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Resume a previous session`}),(0,U.jsxs)(lo,{variant:`ghost`,size:`xs`,onClick:()=>void d(),disabled:s,children:[s?(0,U.jsx)(GT,{className:`size-3 text-current`}):(0,U.jsx)(Hx,{className:`size-3`}),a?`Reload`:`Browse`]})]}),a===void 0?null:a.length===0?(0,U.jsx)(`div`,{className:`py-3 text-center text-body-sm text-fg-4`,children:`No stored sessions for this directory.`}):(0,U.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:a.map(e=>(0,U.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-body-sm text-fg-1`,children:e.customTitle??e.summary}),(0,U.jsxs)(`div`,{className:`flex gap-2 font-mono text-label text-fg-4`,children:[e.gitBranch?(0,U.jsx)(`span`,{className:`truncate`,children:e.gitBranch}):null,(0,U.jsx)(`span`,{className:`shrink-0`,children:hM(e.lastModified)})]})]}),(0,U.jsx)(lo,{variant:`outline`,size:`xs`,onClick:()=>void u(e),disabled:r,children:`Resume`})]},e.sessionId))})]}):null]})}function Lne({open:e,onOpenChange:t,sessions:n,onCreated:r}){return(0,U.jsx)(Fw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Iw,{size:`lg`,children:[(0,U.jsx)(Lw,{title:`New session`,description:`Pick a directory and an engine.`}),(0,U.jsx)(Rw,{children:(0,U.jsx)(Ine,{sessions:n,onCreated:r})})]})})}function Rne(){return(0,U.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,U.jsx)(JT,{icon:(0,U.jsx)(_7,{}),title:`No session open`,description:(0,U.jsxs)(U.Fragment,{children:[`Pick one on the left, or start a new one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})})})}var j9=`workerdeck.view-config`;function zne(){let[e,t]=(0,v.useState)(()=>({...kO,...S(j9,{}),search:``,scoped:!1}));return[e,(0,v.useCallback)(e=>{t(e),C(j9,e)},[])]}function Bne(){let e=jr(),t=bi({select:e=>e.location.pathname.match(/^\/sessions\/[^/]+\/(.+)$/)?.[1]??void 0}),n=Ar({strict:!1}).subagent,r=Ar({strict:!1}).shell,{snapshots:i,refresh:a}=r9(),o=i9(i),s=Sj(o,k7),c=i.filter(e=>e.error!==void 0),l=A7(),u=i.find(e=>e.host.id===l?.id)?.sessions??[],d=t=>{l&&e({to:`/sessions/$hostId/$sessionId`,params:{hostId:l.id,sessionId:t},search:{}})},[f,p]=zne(),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(ane),y=(0,v.useMemo)(()=>WO(o,f),[o,f]),b=t=>void e({to:`/sessions/$hostId/$sessionId`,params:{hostId:t.hostId,sessionId:t.info.id},search:{}}),x=(0,v.useRef)(0),S=(t,n)=>void e({to:`/sessions/$hostId/$sessionId`,params:{hostId:t.hostId,sessionId:t.info.id},search:{subagent:n,sn:++x.current}}),C=(0,v.useRef)(0),w=(t,n)=>void e({to:`/sessions/$hostId/$sessionId`,params:{hostId:t.hostId,sessionId:t.info.id},search:{shell:n,shn:++C.current}}),T=(e,t)=>{k7(e.hostId)?.killShell(e.info.id,t).then(()=>a()).catch(e=>DT.error(e instanceof Error?e.message:`Kill failed`))},E=(e,t)=>{k7(e.hostId)?.updateSession(e.info.id,{title:t||null}).then(()=>a()).catch(e=>DT.error(e instanceof Error?e.message:`Rename failed`))},D=(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`New session`,onClick:()=>h(!0),children:(0,U.jsx)(wx,{className:`size-4`})});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(H7,{section:`sessions`,title:`Sessions`,railActions:D,actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($5,{value:f.subagents,onChange:e=>p({...f,subagents:e})}),(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":g?`Hide filters`:`Show filters`,"aria-pressed":g,onClick:()=>{_(!g),one(!g)},children:(0,U.jsx)(wy,{className:W(`size-3.5`,g&&`fill-current text-fg-1`)})}),(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh`,onClick:()=>void a(),children:(0,U.jsx)(Rx,{className:`size-3.5`})}),D]}),rail:y.map(e=>(0,U.jsxs)(`button`,{type:`button`,title:`${MO(e.info)} - ${e.state}`,"aria-label":MO(e.info),onClick:()=>b(e),className:W(`flex w-full flex-col items-center gap-0.5 border-l-2 py-1.5`,e.info.id===t?`border-l-accent bg-row-active`:`border-l-transparent hover:bg-row-hover`),children:[(0,U.jsx)(A5,{engine:e.adapter,model:e.info.model,className:`size-4`}),(0,U.jsx)(j5,{row:e})]},e.info.id)),children:[c.map(({host:e,error:t})=>(0,U.jsxs)(`div`,{className:`mx-2 mb-2 rounded-md bg-danger-bg px-2 py-1.5 text-label text-danger`,children:[`Can’t reach `,e.name,`: `,t]},e.id)),(0,U.jsx)(U7,{children:(0,U.jsx)(H5,{rows:o,config:f,onConfigChange:p,showControls:g,projectIcons:s,activeId:t,activeSubagentId:n,activeShellId:r,onSelect:b,onSelectSubagent:S,onSelectShell:w,onKillShell:T,onRename:E,onClearContext:e=>{let t=k7(e.hostId);if(!t)return;let n=t.attach(e.info.id,{reconnect:!1}),r=setTimeout(()=>{n.detach(),DT.error(`Clear failed - the gateway did not answer`)},5e3);n.on(`attached`,()=>{n.clearContext(),setTimeout(()=>{clearTimeout(r),n.detach(),DT.success(`Context cleared - the previous conversation stays resumable`),a()},150)})},onDelete:e=>{k7(e.hostId)?.deleteSession(e.info.id).then(()=>a()).catch(e=>DT.error(e instanceof Error?e.message:`Delete failed`))},emptyState:(0,U.jsx)(JT,{icon:(0,U.jsx)(cb,{}),title:`No sessions yet`,description:(0,U.jsxs)(U.Fragment,{children:[`Start one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})})})})]}),(0,U.jsx)(Lne,{open:m,onOpenChange:h,sessions:u,onCreated:e=>{h(!1),d(e),a()}})]})}function Vne(){let{snapshots:e}=r9(),t=lne(i9(e));(0,v.useEffect)(()=>{document.title=t>0?`(${t}) workerdeck`:`workerdeck`},[t])}var M9=[{id:`sessions`,label:`Sessions`,icon:IS,path:`/sessions`,sidebar:Bne},{id:`gateways`,label:`Gateways`,icon:Sx,path:`/gateways`,sidebar:gne},{id:`jobs`,label:`Jobs`,icon:vb,path:`/jobs`,sidebar:jne},{id:`profiles`,label:`Profiles`,icon:mC,path:`/profiles`,sidebar:Fne}],N9=`workerdeck.sidebar-collapsed`;function Hne({children:e}){Vne();let t=bi({select:e=>e.location.pathname}),n=[...M9].sort((e,t)=>t.path.length-e.path.length).find(e=>t.startsWith(e.path)),r=n?.sidebar,[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(()=>b(N9)===`1`),c=()=>{s(e=>(x(N9,e?`0`:`1`),!e))},l=`flex size-7 items-center justify-center rounded-md text-fg-3 transition-colors outline-none hover:bg-row-hover hover:text-fg-1`,u=e=>W(`flex items-center rounded-md text-body-sm transition-colors outline-none`,o?`justify-center p-2`:`gap-2 px-2 py-1.5`,e?`bg-surface font-medium text-fg-1 shadow-(--shadow-xs)`:`text-fg-3 hover:bg-row-hover hover:text-fg-1`);return(0,U.jsxs)(`div`,{className:`flex h-dvh bg-sidebar`,children:[(0,U.jsxs)(`aside`,{className:W(`flex shrink-0 flex-col gap-1 p-3 transition-[width] duration-150`,o?`w-14 items-center`:`w-52`),children:[(0,U.jsxs)(`div`,{className:W(`flex items-center py-2`,o?`justify-center`:`gap-2 px-2`),children:[(0,U.jsx)(_7,{className:`size-4 shrink-0 text-fg-1`}),!o&&(0,U.jsx)(`span`,{className:`text-body-sm font-semibold tracking-tight text-fg-1`,children:`workerdeck`})]}),(0,U.jsx)(`nav`,{className:W(`mt-1 flex flex-1 flex-col gap-0.5`,o&&`items-center`),children:M9.map(e=>(0,U.jsxs)(Jr,{to:e.path,title:o?e.label:void 0,"aria-label":e.label,onClick:t=>{e.id===n?.id&&t.preventDefault()},className:u(e.id===n?.id),children:[(0,U.jsx)(e.icon,{className:`size-4 shrink-0`}),!o&&e.label]},e.id))}),(0,U.jsxs)(`div`,{className:W(`mt-1 grid place-items-center gap-1`,o?`grid-rows-3`:`grid-cols-3`),children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>a(!0),title:`Settings`,"aria-label":`Settings`,className:l,children:(0,U.jsx)(uS,{className:`size-4`})}),(0,U.jsx)(e7,{}),(0,U.jsx)(`button`,{type:`button`,onClick:c,title:o?`Expand sidebar`:`Collapse sidebar`,"aria-label":o?`Expand sidebar`:`Collapse sidebar`,className:l,children:o?(0,U.jsx)(ox,{className:`size-4`}):(0,U.jsx)(ix,{className:`size-4`})})]})]}),(0,U.jsxs)(`div`,{className:`app-frame frame-shine m-2 ml-0 flex min-w-0 flex-1 overflow-hidden rounded-xl`,children:[r?(0,U.jsx)(r,{},n?.id):null,(0,U.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:e??(0,U.jsx)(ui,{})})]}),(0,U.jsx)(Kte,{open:i,onOpenChange:a})]})}function P9({crumbs:e,actions:t,children:n}){return(0,U.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border bg-surface px-3`,children:[(0,U.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`flex min-w-0 items-center gap-1`,children:e.map((e,t)=>(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[t>0?(0,U.jsx)(lv,{"aria-hidden":!0,className:`size-3 shrink-0 text-fg-4`}):null,e.to?(0,U.jsx)(Jr,{to:e.to,className:`shrink-0 text-body-sm text-fg-3 outline-none hover:text-fg-1`,children:e.label}):(0,U.jsx)(`span`,{"aria-current":`page`,className:`min-w-0 truncate text-body-sm font-medium text-fg-1`,title:e.label,children:e.label})]},e.label))}),n,(0,U.jsx)(`span`,{className:`flex-1`}),t]})}function F9({children:e}){return(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-5 px-6 py-6`,children:e})})}function I9({label:e,children:t}){return(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-1.5`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-label font-medium text-fg-3`,children:e}),(0,U.jsx)(`span`,{className:`min-w-0 text-right text-body-sm text-fg-1`,children:t})]})}function Une(){let{hostId:e}=kr({from:`/gateways/$hostId`}),t=jr(),{hosts:n,ready:r}=F7(),{snapshots:i}=r9(),[a,o]=(0,v.useState)(!1),s=n.find(t=>t.id===e),c=i.find(t=>t.host.id===e);if((0,v.useEffect)(()=>{r&&!s&&t({to:`/gateways`})},[r,s,t]),!s)return null;let l=c===void 0?`pending`:c.error?`error`:`ok`;return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(P9,{crumbs:[{label:`Gateways`,to:`/gateways`},{label:s.name}],actions:s.implicit?null:(0,U.jsxs)(lo,{variant:`outline`,size:`xs`,onClick:()=>o(!0),children:[(0,U.jsx)(nC,{className:`size-3`}),`Remove`]}),children:(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-label text-fg-4`,title:s.baseUrl,children:s.baseUrl})}),(0,U.jsxs)(F9,{children:[(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Connection`})}),(0,U.jsxs)(go,{className:`flex flex-col divide-y divide-border`,children:[(0,U.jsx)(I9,{label:`Status`,children:l===`ok`?(0,U.jsx)(fo,{variant:`success`,dot:!0,children:`Connected`}):l===`error`?(0,U.jsx)(fo,{variant:`danger`,dot:!0,children:`Unreachable`}):(0,U.jsx)(fo,{variant:`neutral`,dot:!0,children:`Connecting…`})}),c?.error?(0,U.jsx)(I9,{label:`Last error`,children:(0,U.jsx)(`span`,{className:`text-danger`,children:c.error})}):null,(0,U.jsx)(I9,{label:`Live sessions`,children:c?c.sessions.length:(0,U.jsx)(`span`,{className:`text-fg-4`,children:`-`})}),(0,U.jsx)(I9,{label:`Reachability`,children:j7(s)?`This machine (loopback)`:`Remote`}),(0,U.jsx)(I9,{label:`Credential`,children:s.implicit?(0,U.jsx)(`span`,{className:`text-fg-4`,children:`the login cookie it set - same origin`}):(0,U.jsx)(`span`,{className:`text-fg-4`,children:`an auth key held in this browser`})})]})]}),s.implicit?(0,U.jsx)(`p`,{className:`text-label text-fg-4`,children:`This is the gateway that served the page. Its address is this origin and its credential is the cookie it already set, so there is nothing here to change - and nothing to remove, since removing it would just be closing the tab.`}):(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Settings`})}),(0,U.jsx)(go,{children:(0,U.jsx)(I7,{host:s,onSaved:e=>DT.success(`Saved ${e.name}`)},s.id)})]}),a?(0,U.jsx)(R7,{host:s,onClose:()=>o(!1),onRemoved:()=>{o(!1),t({to:`/gateways`})}}):null]})]})}function Wne(){return(0,U.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,U.jsx)(JT,{icon:(0,U.jsx)(Sx,{}),title:`No gateway selected`,description:(0,U.jsxs)(U.Fragment,{children:[`Pick one on the left, or add one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})})})}function Gne({files:e,activePath:t,onActivate:n,onClose:r,className:i}){return(0,U.jsx)(cT,{delay:500,closeDelay:0,children:(0,U.jsx)(`div`,{"data-slot":`editor-tabs`,role:`tablist`,"aria-label":`Open files`,className:W(`flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-surface`,i),children:e.map(i=>(0,U.jsx)(Kne,{file:i,active:i.path===t,onActivate:()=>n(i.path),onClose:()=>r(i.path),onArrow:t=>{let r=e[e.findIndex(e=>e.path===i.path)+t];r&&n(r.path)}},i.path))})})}function Kne({file:e,active:t,onActivate:n,onClose:r,onArrow:i}){let a=Ej(e),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{t&&o.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t]),(0,U.jsxs)(uT,{side:`bottom`,render:(0,U.jsx)(`div`,{ref:o,role:`tab`,tabIndex:t?0:-1,"aria-selected":t,onClick:n,onAuxClick:e=>{e.button===1&&(e.preventDefault(),r())},onKeyDown:e=>{if(e.key===`ArrowRight`)i(1);else if(e.key===`ArrowLeft`)i(-1);else if(e.key===`Enter`||e.key===` `)n();else return;e.preventDefault()},className:W(`group flex min-w-0 shrink-0 cursor-pointer items-center gap-1.5 border-r border-border px-3 py-1.5 transition-colors`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent focus-visible:ring-inset`,t?`bg-bg text-fg-1`:`text-fg-3 hover:bg-surface-hover hover:text-fg-2`)}),content:(0,U.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsx)(`span`,{className:`font-mono break-all`,children:e.path}),e.bytes===void 0?null:(0,U.jsx)(`span`,{className:`text-fg-4`,children:pM(e.bytes)})]}),children:[(0,U.jsx)(`span`,{className:W(`max-w-40 truncate font-mono text-label`,a&&`italic`),children:e.name}),e.status===`error`?(0,U.jsx)(`span`,{className:`shrink-0 text-danger`,children:`!`}):null,(0,U.jsxs)(`button`,{type:`button`,"aria-label":a?`Close ${e.name} (unsaved changes)`:`Close ${e.name}`,onClick:e=>{e.stopPropagation(),r()},className:W(`shrink-0 rounded p-0.5 text-fg-4 transition-opacity hover:bg-surface-hover hover:text-fg-1`,t||a?`opacity-70`:`opacity-0 group-hover:opacity-70 focus-visible:opacity-100`),children:[(0,U.jsx)(`span`,{className:W(`block`,a&&`group-hover:hidden`),children:a?(0,U.jsx)(`span`,{className:`block size-3 rounded-full bg-fg-2`}):(0,U.jsx)(DC,{className:`size-3`})}),a?(0,U.jsx)(`span`,{className:`hidden group-hover:block`,children:(0,U.jsx)(DC,{className:`size-3`})}):null]})]})}var L9=12;function qne({tree:e,search:t,activePath:n,onOpenFile:r,onCollapse:i,style:a,className:o}){let[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(),d=s.trim().length>0;return(0,v.useEffect)(()=>{if(!t?.available)return;let e=s.trim();if(!e){u(void 0);return}let n=new AbortController,r=setTimeout(()=>{t.search(e,{limit:60,signal:n.signal}).then(e=>{n.signal.aborted||u(e)})},150);return()=>{n.abort(),clearTimeout(r)}},[t,s]),(0,U.jsxs)(`div`,{"data-slot":`file-tree`,style:a,className:W(`flex min-h-0 min-w-0 flex-col bg-surface`,o),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-2`,children:[t?.available?(0,U.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,U.jsx)(oS,{className:`absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-fg-4`}),(0,U.jsx)(_o,{value:s,onChange:e=>c(e.target.value),placeholder:`Search files…`,className:`h-7 pr-7 pl-7 text-label`,spellCheck:!1}),d?(0,U.jsx)(`button`,{type:`button`,onClick:()=>c(``),"aria-label":`Clear search`,className:`absolute top-1/2 right-1.5 -translate-y-1/2 text-fg-4 transition-colors hover:text-fg-2`,children:(0,U.jsx)(DC,{className:`size-3.5`})}):null]}):(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate px-1 text-label text-fg-4`,children:e.root}),(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh the file tree`,onClick:()=>e.refresh(),children:(0,U.jsx)(Rx,{className:`size-3.5 text-fg-3`})}),i?(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Hide project files`,onClick:i,children:(0,U.jsx)(ix,{className:`size-3.5 text-fg-3`})}):null]}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-1 py-1`,children:e.error?(0,U.jsx)(`p`,{className:`px-2 py-3 text-body-sm text-danger`,children:e.error}):d?l===void 0?(0,U.jsx)(`div`,{className:`py-6 text-center`,children:(0,U.jsx)(GT,{className:`size-4 text-fg-4`})}):l.length===0?(0,U.jsx)(`p`,{className:`px-2 py-6 text-center text-body-sm text-fg-4`,children:`No matching files.`}):(0,U.jsx)(`ul`,{children:l.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsx)(R9,{label:Jne(e.relative),detail:Yne(e.relative),title:e.relative,icon:(0,U.jsx)(ly,{className:`size-3.5 shrink-0 text-fg-4`}),active:e.path===n,onClick:()=>r(e.path)})},e.path))}):e.loading?(0,U.jsx)(`div`,{className:`py-6 text-center`,children:(0,U.jsx)(GT,{className:`size-4 text-fg-4`})}):e.rows.length===0?(0,U.jsx)(`p`,{className:`px-2 py-6 text-center text-body-sm text-fg-4`,children:`This project is empty.`}):(0,U.jsx)(`ul`,{role:`tree`,"aria-label":`Project files`,children:e.rows.map(t=>(0,U.jsxs)(`li`,{role:`treeitem`,"aria-expanded":t.expanded,"aria-level":t.depth+1,children:[(0,U.jsx)(R9,{label:t.entry.name,indent:t.depth,active:t.entry.path===n,icon:t.entry.type===`dir`?t.loading?(0,U.jsx)(GT,{className:`size-3.5 shrink-0 text-fg-4`}):t.expanded?(0,U.jsx)(gy,{className:`size-3.5 shrink-0 text-accent`}):(0,U.jsx)(Sy,{className:`size-3.5 shrink-0 text-accent`}):(0,U.jsx)(Y2,{type:t.entry.type}),chevron:t.entry.type===`dir`?(0,U.jsx)(lv,{className:W(`size-3 shrink-0 text-fg-4 transition-transform`,t.expanded&&`rotate-90`)}):void 0,onClick:()=>t.entry.type===`dir`?e.toggle(t.entry.path):r(t.entry.path)}),t.truncated?(0,U.jsx)(`p`,{className:`truncate py-0.5 text-label text-fg-4`,style:{paddingLeft:(t.depth+1)*L9+22},children:`More entries than the server will return - use search.`}):null]},t.entry.path))})})]})}function R9({label:e,detail:t,title:n,icon:r,chevron:i,indent:a=0,active:o,onClick:s}){let c=(0,v.useRef)(null);return(0,v.useEffect)(()=>{o&&c.current?.scrollIntoView({block:`nearest`})},[o]),(0,U.jsxs)(`button`,{ref:c,type:`button`,onClick:s,title:n??e,style:{paddingLeft:a*L9+4},className:W(`flex w-full items-center gap-1 rounded py-1 pr-2 text-left transition-colors`,o?`bg-surface-hover text-fg-1`:`text-fg-2 hover:bg-surface-hover`),children:[(0,U.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center`,children:i}),r,(0,U.jsx)(`span`,{className:`shrink-0 truncate text-label`,children:e}),t?(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label text-fg-4`,children:t}):null]})}function Jne(e){return e.slice(e.lastIndexOf(`/`)+1)}function Yne(e){let t=e.lastIndexOf(`/`);return t===-1?void 0:e.slice(0,t)}function Xne({path:e,value:t,onChange:n,onSave:r,readOnly:i,className:a}){let o=(0,v.useRef)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(null),[l,u]=(0,v.useState)(!1),d=Zne(),f=(0,v.useRef)({onChange:n,onSave:r});return f.current={onChange:n,onSave:r},(0,v.useEffect)(()=>{let n=!1;return Qne().then(r=>{if(n||!o.current)return;c.current=r;let a=r.editor.create(o.current,{value:t,language:V9(e),readOnly:i,automaticLayout:!0,theme:z9(document.documentElement.getAttribute(`data-theme`)),minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,lineHeight:20,fontFamily:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace`,renderLineHighlight:`line`,smoothScrolling:!0,padding:{top:8,bottom:8},scrollbar:{verticalScrollbarSize:10,horizontalScrollbarSize:10},wordBasedSuggestions:`off`,quickSuggestions:!1});s.current=a,a.onDidChangeModelContent(()=>{f.current.onChange?.(a.getValue())}),a.addCommand(r.KeyMod.CtrlCmd|r.KeyCode.KeyS,()=>{f.current.onSave?.()}),u(!0)}),()=>{n=!0,s.current?.dispose(),s.current=null,u(!1)}},[]),(0,v.useEffect)(()=>{let n=c.current,r=s.current;if(!n||!r||!l)return;let i=n.Uri.parse(`workerdeck://host${e}`),a=n.editor.getModel(i)??n.editor.createModel(t,V9(e),i);r.getModel()!==a&&r.setModel(a)},[e,l,t]),(0,v.useEffect)(()=>{let e=s.current;if(!e||!l)return;let n=e.getModel();n&&n.getValue()!==t&&n.pushEditOperations([],[{range:n.getFullModelRange(),text:t}],()=>null)},[t,l]),(0,v.useEffect)(()=>{l&&s.current?.updateOptions({readOnly:i})},[i,l]),(0,v.useEffect)(()=>{l&&c.current?.editor.setTheme(z9(d))},[d,l]),(0,U.jsxs)(`div`,{className:W(`relative min-h-0 min-w-0 flex-1`,a),children:[(0,U.jsx)(`div`,{ref:o,className:`absolute inset-0`}),l?null:(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bg`,children:(0,U.jsx)(GT,{className:`size-4 text-fg-4`})})]})}function Zne(){let[e,t]=(0,v.useState)(()=>typeof document>`u`?null:document.documentElement.getAttribute(`data-theme`));return(0,v.useEffect)(()=>{let e=document.documentElement,n=()=>t(e.getAttribute(`data-theme`));n();let r=new MutationObserver(n);return r.observe(e,{attributes:!0,attributeFilter:[`data-theme`]}),()=>r.disconnect()},[]),e}function z9(e){return e===`light`?`wd-light`:`wd-dark`}var B9;function Qne(){return B9??=(async()=>{let e=await Ij(()=>import(`./vs-CdkLmTlg.js`).then(e=>e.t),__vite__mapDeps([0,1]));return e.editor.defineTheme(`wd-dark`,{base:`vs-dark`,inherit:!0,rules:[],colors:{"editor.background":`#00000000`}}),e.editor.defineTheme(`wd-light`,{base:`vs`,inherit:!0,rules:[],colors:{"editor.background":`#00000000`}}),e})(),B9}function V9(e){let t=e.slice(e.lastIndexOf(`/`)+1);return $ne[t.toLowerCase()]||(ere[t.slice(t.lastIndexOf(`.`)+1).toLowerCase()]??`plaintext`)}var $ne={dockerfile:`dockerfile`,makefile:`plaintext`,".gitignore":`plaintext`,".env":`shell`},ere={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,md:`markdown`,mdx:`markdown`,css:`css`,scss:`scss`,less:`less`,html:`html`,htm:`html`,xml:`xml`,svg:`xml`,yml:`yaml`,yaml:`yaml`,toml:`plaintext`,sh:`shell`,bash:`shell`,zsh:`shell`,fish:`shell`,py:`python`,rb:`ruby`,rs:`rust`,go:`go`,swift:`swift`,java:`java`,kt:`kotlin`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,hpp:`cpp`,cs:`csharp`,php:`php`,sql:`sql`,graphql:`graphql`,gql:`graphql`,lua:`lua`,r:`r`,pl:`perl`,dart:`dart`,scala:`scala`,ini:`ini`,cfg:`ini`,conf:`ini`,txt:`plaintext`,log:`plaintext`};function tre({file:e,canWrite:t,onChange:n,onSave:r,onRevert:i,onReload:a,onOverwrite:o,onDismissConflict:s,className:c}){return e?(0,U.jsxs)(`div`,{"data-slot":`file-viewer`,className:W(`flex min-h-0 min-w-0 flex-1 flex-col bg-bg`,c),children:[e.conflict?(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-warning/40 bg-warning-bg px-3 py-2`,children:[(0,U.jsx)(oC,{className:`size-3.5 shrink-0 text-warning`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-warning`,children:`This file changed on disk since you opened it.`}),(0,U.jsx)(lo,{variant:`outline`,size:`xs`,onClick:()=>a?.(e.path),children:`Use the version on disk`}),(0,U.jsx)(lo,{variant:`outline`,size:`xs`,onClick:()=>o?.(e.path),children:`Keep mine`}),(0,U.jsx)(lo,{variant:`ghost`,size:`xs`,onClick:()=>s?.(e.path),children:`Dismiss`})]}):e.saveError?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-danger/40 bg-danger-bg px-3 py-2`,children:[(0,U.jsx)(oC,{className:`size-3.5 shrink-0 text-danger`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-danger`,children:e.saveError}),(0,U.jsx)(lo,{variant:`ghost`,size:`xs`,onClick:()=>s?.(e.path),children:`Dismiss`})]}):null,e.status===`loading`?(0,U.jsx)(H9,{children:(0,U.jsx)(GT,{className:`size-4 text-fg-4`})}):e.status===`error`?(0,U.jsxs)(H9,{children:[(0,U.jsx)(oC,{className:`size-4 text-danger`}),(0,U.jsx)(`p`,{className:`text-body-sm text-danger`,children:e.error})]}):e.status===`binary`?(0,U.jsxs)(H9,{children:[(0,U.jsx)(oee,{className:`size-4 text-fg-4`}),(0,U.jsx)(`p`,{className:`text-body-sm text-fg-4`,children:`This file isn’t text.`}),(0,U.jsx)(`p`,{className:`text-label text-fg-4`,children:`It can’t be edited here without corrupting it.`})]}):(0,U.jsx)(Xne,{path:e.path,value:Dj(e),readOnly:!t,onChange:n?t=>n(e.path,t):void 0,onSave:r?()=>r(e.path):void 0}),e.status===`ready`&&(e.saving||Ej(e)||!t)?(0,U.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-border px-3 py-1`,children:e.saving?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(GT,{className:`size-3 text-fg-4`}),(0,U.jsx)(`span`,{className:`text-label text-fg-4`,children:`Saving…`})]}):t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-label text-fg-3`,children:`Unsaved changes`}),(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(lo,{variant:`ghost`,size:`xs`,onClick:()=>i?.(e.path),children:`Revert`}),(0,U.jsxs)(lo,{variant:`outline`,size:`xs`,onClick:()=>r?.(e.path),children:[`Save`,(0,U.jsx)(`span`,{className:`ml-1 text-fg-4`,children:`⌘S`})]})]}):(0,U.jsx)(`span`,{className:`text-label text-fg-4`,children:`Read-only - this gateway doesn’t allow writes.`})}):null]}):null}function H9({children:e}){return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-6`,children:e})}var nre=180,rre=520,ire=220,U9=120;function W9({client:e,sessionId:t,header:n,transcriptVariant:r,transcriptDensity:i,transcriptFont:a,scrubber:o,bookmarks:s,onToggleBookmark:c,stickyPrompt:l,openSubagent:u,reveal:d,subagents:f,onSubagentChange:p,openShell:m,shells:h,onShellChange:g,statusPlacement:_,controlsSurface:y,fontSize:b,onLinkClick:x,onOpenFile:S,unseen:C,readOnly:w,onVitals:T,defaultRailWidth:E=260,defaultRailCollapsed:D,onRailChange:O,className:k}){let{info:A}=Tj(e,t),j=A?.cwd,M=hj(e,j),N=pj(e,j),P=Mj(e),{canWrite:F}=mj(e);(0,v.useEffect)(()=>{if(!P.hasUnsaved)return;let e=e=>e.preventDefault();return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[P.hasUnsaved]);let I=ore(),[L,R]=(0,v.useState)(D??!1),[z,ee]=(0,v.useState)(E),B=(0,v.useRef)(O);B.current=O,(0,v.useEffect)(()=>{B.current?.({width:z,collapsed:L})},[z,L]);let[V,te]=(0,v.useState)(360),ne=P.files.length>0,H=!I,re=M.available&&!L;(0,v.useEffect)(()=>{H&&R(!0)},[H]);let ie=(0,v.useCallback)(e=>{let t=P.files.find(t=>t.path===e);if(t&&Ej(t)){let e=t.name;if(!window.confirm(`${e} has unsaved changes. Close it and lose them?`))return}P.close(e)},[P]),ae=(0,v.useRef)(null),oe=are(ae);y5({container:ae,onOpen:(0,v.useCallback)(({path:e})=>P.open(b5(e,j)),[P.open,j]),enabled:M.available,ignore:`.monaco-editor, .xterm`});let se=Math.max(U9,oe-ire),[ce,le]=(0,v.useState)(null),ue=n===void 0||ce===null?void 0:typeof n==`function`?e=>(0,Ed.createPortal)(n(e),ce):(0,Ed.createPortal)(n,ce);return(0,U.jsxs)(`div`,{"data-slot":`session-workspace`,className:W(`flex h-full min-h-0 w-full flex-col overflow-hidden bg-bg`,k),children:[n===void 0?null:(0,U.jsx)(`div`,{ref:le,className:`shrink-0`}),(0,U.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[re?(0,U.jsx)(qne,{tree:M,search:N,activePath:P.activePath,onOpenFile:P.open,onCollapse:()=>R(!0),style:{width:H?Math.min(z,320):z},className:W(`shrink-0 border-r border-border`,H&&`absolute inset-y-0 left-0 z-20 shadow-lg`)}):M.available?(0,U.jsx)(`div`,{className:`flex w-8 shrink-0 flex-col items-center border-r border-border bg-surface pt-1.5`,children:(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Show project files`,onClick:()=>R(!1),children:(0,U.jsx)(ox,{className:`size-4 text-fg-3`})})}):null,re&&!H?(0,U.jsx)(qT,{orientation:`vertical`,value:z,onValueChange:ee,min:nre,max:rre,defaultValue:E,"aria-label":`Resize the file tree`}):null,(0,U.jsxs)(`div`,{ref:ae,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[ne?(0,U.jsxs)(`div`,{className:`flex min-h-0 shrink-0 flex-col overflow-hidden`,style:{height:Math.min(V,se||V)},children:[(0,U.jsx)(Gne,{files:P.files,activePath:P.activePath,onActivate:P.activate,onClose:ie}),(0,U.jsx)(tre,{file:P.active,canWrite:F,onChange:P.edit,onSave:e=>void P.save(e),onRevert:P.revert,onReload:P.reload,onOverwrite:e=>void P.overwrite(e),onDismissConflict:P.dismissConflict})]}):null,ne?(0,U.jsx)(qT,{orientation:`horizontal`,value:Math.min(V,se||V),onValueChange:te,min:U9,max:se,"aria-label":`Resize the open file`}):null,(0,U.jsx)(a5,{client:e,sessionId:t,header:ue,transcriptVariant:r,transcriptDensity:i,transcriptFont:a,scrubber:o,bookmarks:s,onToggleBookmark:c,stickyPrompt:l,openSubagent:u,reveal:d,subagents:f,onSubagentChange:p,openShell:m,shells:h,onShellChange:g,controlsSurface:y,fontSize:b,onLinkClick:x,onOpenFile:S??P.open,statusPlacement:_,unseen:C,readOnly:w,onVitals:T,className:`min-h-0 flex-1`})]}),H&&re?(0,U.jsx)(`button`,{type:`button`,"aria-label":`Close the file tree`,onClick:()=>R(!0),className:`absolute inset-0 z-10 bg-black/30`}):null]})]})}function are(e){let[t,n]=(0,v.useState)(0);return(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(([e])=>{e&&n(e.contentRect.height)});return r.observe(t),()=>r.disconnect()},[e]),t}function ore(){let[e,t]=(0,v.useState)(!0);return(0,v.useEffect)(()=>{let e=window.matchMedia(`(min-width: 768px)`),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var G9=`workerdeck.rail`,sre={width:260,collapsed:!1};function K9(){let e=S(G9,{});return{width:Math.min(520,Math.max(180,Number(e.width)||sre.width)),collapsed:e.collapsed===!0}}function q9(e){C(G9,e)}function cre(){let{jobId:e}=kr({from:`/jobs/$jobId`}),t=jr(),{jobs:n,refresh:r}=E9(),{snapshots:i}=r9(),a=n.find(t=>t.id===e),o=o9(),s=A7()?.id,c=a?.sessionId!==void 0&&(i.find(e=>e.host.id===s)?.sessions.some(e=>e.id===a.sessionId)??!1),[l,u]=(0,v.useState)(!1);(0,v.useEffect)(()=>{n.length>0&&u(!0)},[n.length]),(0,v.useEffect)(()=>{l&&!a&&(DT.error(`That job is no longer in the queue`),t({to:`/jobs`}))},[l,a,t]);let[d]=(0,v.useState)(r7),[f]=(0,v.useState)(o7),[p]=(0,v.useState)(l7),[m]=(0,v.useState)(f7),[h]=(0,v.useState)(K9);if(!a)return null;let g=(0,U.jsx)(J9,{job:a,onChanged:()=>void r()});return!o||!c||!a.sessionId?(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[g,(0,U.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center`,children:[(0,U.jsx)(`p`,{className:`text-body-sm text-fg-3`,children:a.sessionId?`This job’s session is no longer on the gateway.`:`This job never got as far as a session.`}),(0,U.jsx)(`p`,{className:`max-w-md text-label text-fg-4`,children:`The queue keeps the job record - status, usage, error - but the transcript lives with the session, and that one has been closed or swept.`})]})]}):(0,U.jsx)(W9,{client:o,sessionId:a.sessionId,readOnly:!0,transcriptVariant:f,transcriptDensity:d,transcriptFont:p,fontSize:m,scrubber:!0,stickyPrompt:!0,statusPlacement:`bottom`,defaultRailWidth:h.width,defaultRailCollapsed:h.collapsed,onRailChange:q9,header:({actions:e})=>(0,U.jsx)(J9,{job:a,onChanged:()=>void r(),actions:e})},a.sessionId)}function J9({job:e,onChanged:t,actions:n}){let r=D9[e.status],i=e.status===`queued`||e.status===`running`||e.status===`parked`,a=async()=>{try{await o9().cancelJob(e.id),t()}catch(e){DT.error(e instanceof Error?e.message:`Cancel failed`)}};return(0,U.jsxs)(P9,{crumbs:[{label:`Jobs`,to:`/jobs`},{label:e.prompt}],actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(fo,{variant:`neutral`,className:`shrink-0`,children:`read-only`}),(0,U.jsx)(WT,{value:e.id,"aria-label":`Copy job id`}),i?(0,U.jsxs)(lo,{variant:`outline`,size:`xs`,onClick:()=>void a(),children:[(0,U.jsx)(DC,{className:`size-3`}),`Cancel`]}):null,n]}),children:[(0,U.jsxs)(fo,{variant:r.variant,dot:!r.busy,className:`shrink-0`,children:[r.busy?(0,U.jsx)(GT,{className:`size-3 text-current`}):null,r.label]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-x-3 font-mono text-label text-fg-4`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:e.cwd}),e.profile?(0,U.jsxs)(`span`,{className:`shrink-0`,children:[`@`,e.profile]}):null,(0,U.jsx)(`span`,{className:`shrink-0`,children:hM(e.finishedAt??e.startedAt??e.createdAt)}),e.maxAttempts!==void 0&&e.maxAttempts>1?(0,U.jsxs)(`span`,{className:`shrink-0`,children:[`attempt `,e.attempt??1,`/`,e.maxAttempts,e.status===`queued`&&e.nextRunAt!==void 0&&e.nextRunAt>Date.now()?` - retry pending`:``]}):null,e.usage.tokens>0?(0,U.jsxs)(`span`,{className:`shrink-0`,children:[fM(e.usage.tokens),` tok`]}):null,(e.usage.costUsd??e.usage.totalCostUsd)>0?(0,U.jsx)(`span`,{className:`shrink-0`,children:uM(e.usage.costUsd??e.usage.totalCostUsd)}):null,e.error?(0,U.jsx)(`span`,{className:`truncate text-danger`,children:e.error}):null]})]})}function lre({profile:e,onSaved:t}){let n=e.engine===`provider`,[r,i]=(0,v.useState)(e.description??``),[a,o]=(0,v.useState)(e.defaults?.model??``),[s,c]=(0,v.useState)(e.defaults?.permissionMode),[l,u]=(0,v.useState)(e.provider?.model??``),[d,f]=(0,v.useState)((e.provider?.models??[]).join(`, `)),[p,m]=(0,v.useState)(e.session?.capabilities),[h,g]=(0,v.useState)((e.session?.mcpServers??[]).join(`, `)),[_,y]=(0,v.useState)(e.session?.instructions??``),[b,x]=(0,v.useState)(!1),S=s9(e,s??`default`,a),C=S.models.map(t=>t.value==="default"?{...t,displayName:`Unset`,description:e.defaultModel??`whatever the engine's own config picks`}:t),w=async()=>{let i={description:r.trim()||void 0,defaults:{model:a.trim()||void 0,permissionMode:s}};n&&(i.provider={...e.provider,id:e.provider?.id??``,model:l.trim()||void 0,models:k9(d).length>0?k9(d):void 0},i.session={capabilities:p,mcpServers:k9(h).length>0?k9(h):void 0,instructions:_.trim()||void 0}),x(!0);try{t(await o9().updateProfile(e.name,i)),DT.success(`Profile saved`)}catch(e){DT.error(e instanceof Error?e.message:`Failed to save profile`)}finally{x(!1)}};return(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Edit profile`})}),(0,U.jsxs)(go,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(A9,{label:`Description`,children:(0,U.jsx)(_o,{value:r,onChange:e=>i(e.target.value)})}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`Default model`,children:C.length>1?(0,U.jsx)(a9,{value:a,onChange:o,models:C}):(0,U.jsx)(_o,{value:a,onChange:e=>o(e.target.value),placeholder:`unset - request / engine default`,className:`font-mono`})}),(0,U.jsx)(A9,{label:`Default permission mode`,children:(0,U.jsx)(g4,{variant:`form`,mode:s,onModeChange:c,modes:S.modes})})]}),n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`Default model id`,children:(0,U.jsx)(_o,{value:l,onChange:e=>u(e.target.value),className:`font-mono`})}),(0,U.jsx)(A9,{label:`Models offered (comma-separated)`,children:(0,U.jsx)(_o,{value:d,onChange:e=>f(e.target.value),className:`font-mono`})})]}),(0,U.jsx)(A9,{label:`Capabilities granted`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 py-1.5`,children:[(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:p===void 0,onChange:e=>m(e.target.checked?void 0:[]),className:`size-3.5 accent-(--color-fg-1)`}),`not declared`]}),O9.map(e=>(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,disabled:p===void 0,checked:p?.includes(e)??!1,onChange:t=>m(n=>t.target.checked?[...n??[],e]:(n??[]).filter(t=>t!==e)),className:`size-3.5 accent-(--color-fg-1) disabled:opacity-40`}),(0,U.jsx)(`code`,{className:`font-mono text-label`,children:e})]},e))]})}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`MCP servers (names, comma-separated)`,children:(0,U.jsx)(_o,{value:h,onChange:e=>g(e.target.value),className:`font-mono`})}),(0,U.jsx)(A9,{label:`Instructions`,children:(0,U.jsx)(_o,{value:_,onChange:e=>y(e.target.value)})})]})]}):null,(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-label text-fg-4`,children:`Name and engine are fixed - sessions and jobs are pinned to the name, and the engine decides what the rest of these fields mean.`}),(0,U.jsxs)(lo,{onClick:()=>void w(),disabled:b,children:[b?(0,U.jsx)(GT,{className:`size-3.5 text-current`}):(0,U.jsx)(Qx,{className:`size-4`}),`Save`]})]})]})]})}function ure(e){window.location.href=`vscode://file${e}`}function dre(){return(0,U.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,U.jsx)(JT,{icon:(0,U.jsx)(mC,{}),title:`No profile selected`,description:`A profile is what a session runs as - its config directory and credentials, or a model provider.`})})}function Y9({items:e,empty:t}){return e.length===0?(0,U.jsx)(`span`,{className:`text-fg-4`,children:t}):(0,U.jsx)(`span`,{className:`flex flex-wrap justify-end gap-1`,children:e.map(e=>(0,U.jsx)(fo,{variant:`neutral`,children:e},e))})}function fre(){let{profileName:e}=kr({from:`/profiles/$profileName`}),t=jr(),{refresh:n}=p9(),[r,i]=(0,v.useState)(),[a,o]=(0,v.useState)();(0,v.useEffect)(()=>{let t=!0,n=()=>{o9()?.getProfile(e).then(e=>{t&&i(e)}).catch(e=>{t&&o(e instanceof Error?e.message:`Failed to load profile`)})};n();let r=setInterval(n,6e4);return()=>{t=!1,clearInterval(r)}},[e]);let s=r?.profile,c=r?.config,l=(0,v.useMemo)(()=>Ak(s?.usage),[s?.usage]),u=async()=>{try{await o9().deleteProfile(e),await n(),DT.success(`Profile '${e}' deleted`),t({to:`/profiles`})}catch(e){DT.error(e instanceof Error?e.message:`Delete failed`)}};return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(P9,{crumbs:[{label:`Profiles`,to:`/profiles`},{label:e}],actions:(0,U.jsxs)(U.Fragment,{children:[s?.configDir?(0,U.jsxs)(lo,{variant:`outline`,size:`xs`,onClick:()=>ure(s.configDir),children:[(0,U.jsx)(jv,{className:`size-3`}),`Open in VSCode`]}):null,s?.managed?(0,U.jsxs)(lo,{variant:`outline`,size:`xs`,onClick:()=>void u(),children:[(0,U.jsx)(nC,{className:`size-3`}),`Delete`]}):null]}),children:s?.description?(0,U.jsx)(`span`,{className:`min-w-0 truncate text-label text-fg-4`,children:s.description}):null}),(0,U.jsxs)(F9,{children:[a?(0,U.jsx)(`div`,{className:`rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger`,children:a}):null,!r&&!a?(0,U.jsx)(GT,{className:`mx-auto size-5 text-fg-4`}):null,s&&c?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Worker defaults`})}),(0,U.jsxs)(go,{className:`flex flex-col divide-y divide-border`,children:[(0,U.jsx)(I9,{label:`Engine`,children:(0,U.jsx)(fo,{variant:`neutral`,children:s.engine??`claude`})}),s.engine===`provider`?(0,U.jsx)(I9,{label:`Provider`,children:(0,U.jsx)(`span`,{className:`font-mono text-label`,children:s.provider?.id})}):(0,U.jsx)(I9,{label:`Config directory`,children:(0,U.jsx)(`span`,{className:`font-mono text-label`,children:s.configDir})}),(0,U.jsx)(I9,{label:`Default model`,children:s.defaults?.model??s.provider?.model??(0,U.jsx)(`span`,{className:`text-fg-4`,children:`request / engine default`})}),(0,U.jsx)(I9,{label:`Default permission mode`,children:s.defaults?.permissionMode??(0,U.jsx)(`span`,{className:`text-fg-4`,children:`request / engine default`})}),s.engine===`provider`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(I9,{label:`Models offered`,children:(0,U.jsx)(Y9,{items:s.provider?.models??[],empty:`the default model only`})}),(0,U.jsx)(I9,{label:`API key variable`,children:s.provider?.apiKeyEnv?(0,U.jsx)(`span`,{className:`font-mono text-label`,children:s.provider.apiKeyEnv}):(0,U.jsx)(`span`,{className:`text-fg-4`,children:`provider SDK default`})})]}):null]})]}),l.length>0?(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Plan usage`})}),(0,U.jsx)(go,{children:(0,U.jsx)(Y8,{windows:l})})]}):null,s.engine===`provider`?(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Session grants`})}),(0,U.jsxs)(go,{className:`flex flex-col divide-y divide-border`,children:[(0,U.jsx)(I9,{label:`Capabilities`,children:(0,U.jsx)(Y9,{items:s.session?.capabilities??[],empty:`not declared - whatever the server wired`})}),(0,U.jsx)(I9,{label:`MCP servers`,children:(0,U.jsx)(Y9,{items:s.session?.mcpServers??[],empty:`not declared - every connected server`})}),(0,U.jsx)(I9,{label:`Instructions`,children:s.session?.instructions?`${s.session.instructions.length} characters`:(0,U.jsx)(`span`,{className:`text-fg-4`,children:`none`})})]})]}):null,s.engine===`provider`?null:(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Claude Code configuration`})}),(0,U.jsxs)(go,{className:`flex flex-col divide-y divide-border`,children:[c.settings?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(I9,{label:`Model (settings.json)`,children:c.settings.model??(0,U.jsx)(`span`,{className:`text-fg-4`,children:`not set`})}),(0,U.jsx)(I9,{label:`Default permission mode`,children:c.settings.defaultPermissionMode??(0,U.jsx)(`span`,{className:`text-fg-4`,children:`not set`})}),(0,U.jsx)(I9,{label:`Permission rules`,children:(0,U.jsx)(`span`,{className:`font-mono text-label`,children:c.settings.permissionRules?`${c.settings.permissionRules.allow} allow · ${c.settings.permissionRules.ask} ask · ${c.settings.permissionRules.deny} deny`:`-`})}),(0,U.jsx)(I9,{label:`Env vars (names only)`,children:(0,U.jsx)(Y9,{items:c.settings.envKeys??[],empty:`none`})}),(0,U.jsx)(I9,{label:`Hooks`,children:(0,U.jsx)(Y9,{items:c.settings.hooks??[],empty:`none`})})]}):(0,U.jsx)(I9,{label:`settings.json`,children:(0,U.jsx)(`span`,{className:`text-fg-4`,children:`not found`})}),(0,U.jsx)(I9,{label:`User memory (CLAUDE.md)`,children:c.hasUserMemory?`present`:(0,U.jsx)(`span`,{className:`text-fg-4`,children:`none`})}),(0,U.jsx)(I9,{label:`Skills`,children:(0,U.jsx)(Y9,{items:c.skills,empty:`none`})}),(0,U.jsx)(I9,{label:`Agents`,children:(0,U.jsx)(Y9,{items:c.agents,empty:`none`})}),(0,U.jsx)(I9,{label:`Commands`,children:(0,U.jsx)(Y9,{items:c.commands,empty:`none`})})]})]}),s.managed?(0,U.jsx)(lre,{profile:s,onSaved:e=>i({...r,profile:e})}):null,(0,U.jsxs)(`p`,{className:`text-label text-fg-4`,children:[s.managed?`Stored on the server and editable here. `:`View only - this profile is declared in the server options. `,`Other profile configuration lives on the server (the `,(0,U.jsx)(`code`,{className:`font-mono`,children:`profiles`}),` option; for Claude profiles, the config directory itself, e.g. via VSCode). Provider credentials are resolved from the server's environment and never leave it.`]})]}):null]})]})}var X9=`workerdeck.bookmarks.v1`;function Z9(e,t){return`${e}:${t}`}function pre(e,t){let[n,r]=(0,v.useState)(()=>S(X9,{}));return{bookmarks:(0,v.useMemo)(()=>n[Z9(e,t)]??[],[n,e,t]),toggle:(0,v.useCallback)(n=>{r(r=>{let i=Z9(e,t),a=r[i]??[],o=a.includes(n)?a.filter(e=>e!==n):[...a,n],s={...r,[i]:o};return o.length===0&&delete s[i],C(X9,s),s})},[e,t])}}function mre(){let{hostId:e,sessionId:t}=kr({from:`/sessions/$hostId/$sessionId`}),{ready:n}=F7(),r=jr(),i=k7(e);return(0,v.useEffect)(()=>{n&&!i&&(DT.error(`That gateway is not configured here`),r({to:`/sessions`}))},[n,i,r]),i?(0,U.jsx)(hre,{hostId:e,sessionId:t,client:i},`${e}:${t}`):null}function hre({hostId:e,sessionId:t,client:n}){let r=jr(),{subagent:i,sn:a,reveal:o,rn:s,shell:c,shn:l}=Ar({from:`/sessions/$hostId/$sessionId`}),{info:u,error:d}=Tj(n,t),f=cne(e,t),{bookmarks:p,toggle:m}=pre(e,t),[h]=(0,v.useState)(()=>m7()===`on`?sne(e,t):void 0),[g]=(0,v.useState)(r7),[_]=(0,v.useState)(o7),[y]=(0,v.useState)(l7),[b]=(0,v.useState)(f7),[x]=(0,v.useState)(K9);(0,v.useEffect)(()=>{d&&(DT.error(`Session not found`),r({to:`/sessions`}))},[d,r]);let[S,C]=(0,v.useState)(()=>!document.hidden);(0,v.useEffect)(()=>{let e=()=>C(!document.hidden);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let{snapshots:w}=r9(),T=(0,v.useMemo)(()=>w.find(t=>t.host.id===e)?.sessions.find(e=>e.id===t),[w,e,t]);(0,v.useEffect)(()=>{T&&S&&f({activity:T.activityCount,prose:T.proseCount,turns:T.numTurns})},[T?.activityCount,T?.proseCount,T?.numTurns,S,f]);let E=async()=>{try{await n.deleteSession(t)}catch{}r({to:`/sessions`})},D=u?.cwd?.split(`/`).filter(Boolean).pop();return(0,U.jsx)(W9,{client:n,sessionId:t,transcriptVariant:_,transcriptDensity:g,transcriptFont:y,fontSize:b,openSubagent:i?{toolUseId:i,nonce:a??0}:void 0,reveal:o?{toolUseId:o,nonce:s??0}:void 0,subagents:T?.subagents,onSubagentChange:n=>{n!==i&&r({to:`/sessions/$hostId/$sessionId`,params:{hostId:e,sessionId:t},search:n===void 0?{}:e=>({subagent:n,sn:e.sn}),replace:!0})},openShell:c?{shellId:c,nonce:l??0}:void 0,shells:T?.shells,onShellChange:n=>{n!==c&&r({to:`/sessions/$hostId/$sessionId`,params:{hostId:e,sessionId:t},search:e=>({subagent:e.subagent,sn:e.sn,shell:n,shn:e.shn}),replace:!0})},scrubber:!0,bookmarks:p,onToggleBookmark:m,stickyPrompt:!0,statusPlacement:`bottom`,controlsSurface:`status`,defaultRailWidth:x.width,defaultRailCollapsed:x.collapsed,onRailChange:q9,unseen:h,onVitals:e=>{f({itemCount:e.itemCount}),mne()},header:({actions:e})=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border bg-surface px-3 py-2`,children:[(0,U.jsx)(`span`,{className:`truncate text-body-sm font-medium text-fg-1`,children:u?.title??D??t.slice(0,8)}),u?.engine&&u.engine!==`claude`?(0,U.jsx)(fo,{variant:`neutral`,className:`shrink-0`,children:u.engine}):null,u?.cwd?(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-label text-fg-4`,title:u.cwd,children:u.cwd}):null,(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(WT,{value:t,"aria-label":`Copy session id`}),(0,U.jsxs)(qC,{children:[(0,U.jsx)(JC,{render:(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close session`,children:(0,U.jsx)(nC,{className:`size-4 text-fg-3`})})}),(0,U.jsxs)(XC,{children:[(0,U.jsx)(ZC,{children:`Close this session?`}),(0,U.jsx)(QC,{children:`The run is terminated on the server. You can pick it up later from “Resume a previous session” - the transcript is kept by the engine, not by the gateway.`}),(0,U.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,U.jsx)(YC,{render:(0,U.jsx)(lo,{variant:`outline`,children:`Cancel`})}),(0,U.jsx)(lo,{variant:`destructive`,onClick:()=>void E(),children:`Close session`})]})]})]}),e]})},t)}var Q9=$r({component:Hne}),gre=Zr({getParentRoute:()=>Q9,path:`/`,beforeLoad:()=>{throw Ve({to:`/sessions`})}}),_re=Zr({getParentRoute:()=>Q9,path:`/sessions`,component:Rne}),vre=Zr({getParentRoute:()=>Q9,path:`/sessions/$hostId/$sessionId`,component:mre,validateSearch:e=>({subagent:typeof e.subagent==`string`?e.subagent:void 0,sn:typeof e.sn==`number`?e.sn:void 0,reveal:typeof e.reveal==`string`?e.reveal:void 0,rn:typeof e.rn==`number`?e.rn:void 0,shell:typeof e.shell==`string`?e.shell:void 0,shn:typeof e.shn==`number`?e.shn:void 0})}),yre=Zr({getParentRoute:()=>Q9,path:`/sessions/$sessionId`,beforeLoad:({params:e})=>{throw Ve({to:`/sessions/$hostId/$sessionId`,params:{hostId:x7,sessionId:e.sessionId},search:{}})}}),bre=Zr({getParentRoute:()=>Q9,path:`/gateways`,component:Wne}),xre=Zr({getParentRoute:()=>Q9,path:`/gateways/$hostId`,component:Une}),Sre=Zr({getParentRoute:()=>Q9,path:`/jobs`,component:kne}),Cre=Zr({getParentRoute:()=>Q9,path:`/jobs/$jobId`,component:cre}),wre=Zr({getParentRoute:()=>Q9,path:`/profiles`,component:dre}),Tre=Zr({getParentRoute:()=>Q9,path:`/profiles/$profileName`,component:fre}),Ere=Zr({getParentRoute:()=>Q9,path:`/settings`,beforeLoad:()=>{throw Ve({to:`/sessions`})}}),Dre=gi({routeTree:Q9.addChildren([gre,_re,vre,yre,bre,xre,Sre,Cre,wre,Tre,Ere]),history:wt()});function Ore(){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yi,{router:Dre}),(0,U.jsx)(VT,{})]})}E();var $9=document.getElementById(`root`);if(!$9)throw Error(`Root element #root not found`);(0,y.createRoot)($9).render((0,U.jsx)(v.StrictMode,{children:(0,U.jsx)(Ore,{})}));export{Ij as a,s as c,eQ as i,l,L1 as n,Hn as o,V1 as r,d as s,kQ as t};
|
|
211
|
+
`)}):null,s?(0,U.jsx)(`div`,{className:`px-3 pb-2 text-label text-fg-4`,children:s}):null]})}function P8({item:e}){return(0,U.jsxs)(`div`,{"data-slot":`compaction`,className:`flex items-center gap-2 py-1`,children:[(0,U.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,U.jsxs)(`span`,{className:`font-mono text-label ${e.error===void 0?`text-fg-3`:`text-danger`}`,children:[e.pending?`⋯`:`≡`,` `,lM(e)]}),(0,U.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function F8({line:e,since:t,terminal:n}){let r=t===void 0?void 0:hM(t),i=r?`${e} · last here ${r}`:e;return n?(0,U.jsx)(`div`,{"data-slot":`recap`,children:(0,U.jsxs)(pN,{glyph:`※`,glyphTone:`faint`,tone:`faint`,children:[`recap: `,i]})}):(0,U.jsxs)(`div`,{"data-slot":`recap`,className:`flex items-center gap-2 py-1`,children:[(0,U.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,U.jsxs)(`span`,{className:`font-mono text-label text-fg-3`,children:[`※ recap: `,i]}),(0,U.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function I8({attachments:e,attachmentUrl:t}){return(0,U.jsx)(`div`,{className:`mb-1 flex flex-wrap justify-start gap-1.5`,children:e.map(e=>{let n=t?.(e.id);return e.mediaType.startsWith(`image/`)&&n?(0,U.jsx)(`img`,{src:n,alt:e.name,className:`size-20 rounded-md border border-border object-cover`},e.id):(0,U.jsx)(`span`,{className:`rounded-full border border-border bg-surface px-2.5 py-1 text-body-xs text-fg-3`,children:e.name},e.id)})})}function L8(e,t){return e!==void 0&&t<e}function R8(e,t){let n=`parentToolUseId`in e?e.parentToolUseId:void 0;return n!=null&&n!==t?`border-l-2 border-border pl-3`:void 0}function z8(e){return e.text||(e.attachments??[]).map(e=>e.name).join(`, `)}function B8({top:e,height:t,gapClass:n,gapPx:r,terminal:i,scrollRoot:a,index:o,measureRef:s,head:c,content:l}){let u=(0,v.useRef)(null),d=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=u.current,t=d.current;if(!e||!t||!a)return;let n=()=>{let n=t.getBoundingClientRect().top<a.getBoundingClientRect().top;e.toggleAttribute(`data-stuck`,n)};return n(),a.addEventListener(`scroll`,n,{passive:!0}),()=>a.removeEventListener(`scroll`,n)},[a,e,t,n]),(0,U.jsxs)(`div`,{"data-sticky-lane":i?`terminal`:`cards`,className:`absolute inset-x-0`,style:{top:e,height:t},children:[(0,U.jsx)(`div`,{"data-sticky-headlane":``,"aria-hidden":!0,children:(0,U.jsx)(`div`,{ref:u,"data-sticky-head":``,className:i&&n||void 0,children:c})}),(0,U.jsx)(`div`,{ref:d,"aria-hidden":!0,className:`absolute left-0 w-px`,style:{top:n?i?`var(--term-line)`:r:0,height:1}}),(0,U.jsx)(`div`,{ref:s,"data-index":o,className:n||void 0,children:l})]})}function V8({rows:e,boundary:t,since:n,terminal:r,replaying:i,stickyPrompt:a,frameParentId:o,onOpenSubagent:s,gap:c,fontSize:l,lineHeight:u,items:d,pendingApprovals:f,scrubber:p,bookmarks:m,affordances:h,fileUrl:g,attachmentUrl:_,hostImage:y,jumpToRecapRef:b,repinRef:x,reveal:S}){let C=T3(),[w,T]=(0,v.useState)(null),E=(0,v.useMemo)(()=>e.flatMap((e,t)=>`item`in e&&e.item.kind===`user`&&x4(e.item)===void 0?[t]:[]),[e]),D=(0,v.useRef)({enabled:!1,promptRows:[]});D.current={enabled:a,promptRows:E},(0,v.useEffect)(()=>{T(C.scrollRef.current)},[C.scrollRef]),(0,v.useEffect)(()=>{if(!w)return;let e=w.clientHeight,t=new ResizeObserver(()=>{let t=w.clientHeight;if(t===e)return;let n=t-e;e=t,C.state.isAtBottom&&d8(C,n)});return t.observe(w),()=>t.disconnect()},[w,C]);let O=(0,v.useRef)(i);(0,v.useLayoutEffect)(()=>{let e=O.current;O.current=i,e&&!i&&C.state.isAtBottom&&(C.state.scrollTop=C.state.calculatedTargetScrollTop)},[i,C]);let k=(0,v.useRef)(null),A=s8({terminal:r,fontSize:l,lineHeight:u,rowsRef:k}),j=n6({count:e.length,getScrollElement:()=>(w&&j.scrollElement!==w&&(j.scrollOffset=w.scrollTop),w),estimateSize:t=>{if(r&&A){let n=e[t],r=t>0&&n8(e,t)?A.line:0;return n&&`text`in n&&n.key===`brief`?a6(n.text,A)+r:n&&!(`line`in n)?i6(n,A)+r:A.line+r}return(r?36:100)+c.px},overscan:8,getItemKey:t=>e[t].key,rangeExtractor:(0,v.useCallback)(e=>{let t=new Set(V3(e)),{enabled:n,promptRows:r}=D.current;if(n){let e=j.scrollOffset??0,n=-1;for(let t of r)if((j.measurementsCache[t]?.start??1/0)<=e)n=t;else break;n>=0&&t.add(n)}return[...t].sort((e,t)=>e-t)},[]),useFlushSync:!0});j.shouldAdjustScrollPositionOnItemSizeChange=(e,t,n)=>{if(C.state.isAtBottom)return!1;let r=(n.scrollOffset??0)+n.scrollAdjustments;return n.itemSizeCache.has(e.key)?e.end<=r&&n.scrollDirection!==`backward`:e.start<r},(0,v.useEffect)(()=>{if(!r||!A)return;j.measure();let e=k.current;if(e){j.getTotalSize();for(let t of e.querySelectorAll(`[data-index]`)){let e=Number(t.getAttribute(`data-index`));Number.isInteger(e)&&e>=0&&j.resizeItem(e,t.getBoundingClientRect().height)}}},[r,A,j]);let M=f8({rows:e,terminal:r,stickyPrompt:a,epoch:A,promptRows:E,scrollElement:w,rowsRef:k,virtualizer:j,stick:C,jumpToRecapRef:b,repinRef:x}),N=S?.nonce,P=S?.toolUseId;(0,v.useEffect)(()=>{if(P===void 0)return;let t=d.findIndex(e=>e.kind===`tool_call`&&e.id===P);t<0||M(i8(e,t),`start`)},[N]);let F=rN(h).hover,I=(0,v.useMemo)(()=>{if(!m?.length)return[];let e=new Map(d.map((e,t)=>[e.id,t]));return m.map(t=>e.get(t)).filter(e=>e!==void 0)},[m,d]),L=e.findIndex(e=>e.key===`recap`),R=L>=0?{rowIndex:L,label:e[L].line}:void 0;(0,v.useEffect)(()=>{if(r&&p&&F&&w)return w.setAttribute(`data-term-scrubber-host`,``),()=>w.removeAttribute(`data-term-scrubber-host`)},[r,p,F,w]);let z=j.measurementsCache;return(0,U.jsxs)(`div`,{ref:k,"data-slot":`transcript-rows`,className:`relative w-full`,style:{height:j.getTotalSize()},children:[(0,U.jsx)(E0,{items:d,children:j.getVirtualItems().map(i=>{let l=e[i.index],u=i.index>0&&(!r||n8(e,i.index))?c.className:void 0,d=`run`in l?(0,U.jsx)(`div`,{className:W(L8(t,l.index)&&`opacity-45`),children:(0,U.jsx)(x2,{items:l.run})}):`item`in l?(0,U.jsx)(`div`,{className:W(L8(t,l.index)&&`opacity-45`,R8(l.item,o)),children:(0,U.jsx)(M8,{item:l.item,fileUrl:g,attachmentUrl:_,hostImage:y,terminal:r})}):`text`in l&&l.key===`brief`?(0,U.jsx)(m8,{text:l.text,terminal:r}):`line`in l?(0,U.jsx)(F8,{line:l.line,since:n,terminal:r}):(0,U.jsx)(`div`,{className:W(L8(t,l.index)&&`opacity-45`),children:(0,U.jsx)(h8,{block:l,fileUrl:g,onOpenSubagent:s})});if(a&&`item`in l&&l.item.kind===`user`&&x4(l.item)===void 0){let e=E.find(e=>e>i.index),t=e===void 0?j.getTotalSize():z[e]?.start??i.start;return(0,U.jsx)(B8,{top:i.start,height:Math.max(t-i.start,0),gapClass:u,gapPx:c.px,terminal:r,scrollRoot:w,index:i.index,measureRef:j.measureElement,head:r?d:z8(l.item),content:d},l.key)}return(0,U.jsx)(`div`,{ref:j.measureElement,"data-index":i.index,className:W(`absolute inset-x-0 top-0`,u),style:{transform:`translateY(${i.start}px)`},children:d},l.key)})}),p&&w?.parentElement?(0,Ed.createPortal)(r?(0,U.jsx)(V6,{items:d,pendingApprovals:f,recapRow:R,bookmarks:I,frameParentId:o,rowIndexFor:t=>i8(e,t),positionInRow:t=>o8(e,t),offsetOfRow:e=>j.measurementsCache[e]?.start??0,sizeOfRow:e=>j.measurementsCache[e]?.size??0,totalSize:j.getTotalSize(),scrollOffset:j.scrollOffset??0,viewportH:j.scrollRect?.height??0,onJumpToRow:e=>M(e,`start`),interactive:F,fontSize:l,lineHeight:u}):(0,U.jsx)(Q6,{items:d,pendingApprovals:f,recapItemIndex:L>=0?t:void 0,bookmarks:I,frameParentId:o,interactive:F,onJumpToItem:t=>M(i8(e,t),`start`)}),w.parentElement):null]})}function H8(e){let t=e===`running`||e===`starting`,[n,r]=(0,v.useState)(void 0);return(0,v.useEffect)(()=>{r(e=>t?e??Date.now():void 0)},[t]),t?n:void 0}function U8(e){if(e.status!==`running`&&e.status!==`starting`)return!1;let t=e.items.at(-1);return t?t.kind===`assistant_text`&&t.streaming||t.kind===`thinking`&&t.id===`streaming-thinking`?!1:t.kind!==`turn_result`||e.status===`running`:!0}function W8({active:e,fontSize:t,lineHeight:n,affordances:r,children:i}){return e?(0,U.jsx)(k2,{fontSize:t,lineHeight:n,affordances:r,bleed:`1ch`,className:`term-transcript`,children:i}):(0,U.jsx)(U.Fragment,{children:i})}function G8({state:e,fileUrl:t,attachmentUrl:n,canBrowseFiles:r,hostImage:i,variant:a=`cards`,density:o=`comfortable`,fontSize:s,lineHeight:c,affordances:l,stickyPrompt:u=!1,scrubber:d,bookmarks:f,sessionNames:p,replaying:m=!1,catchUp:h,jumpToRecapRef:g,repinRef:_,reveal:y,frame:b,onOpenSubagent:x,emptyState:S,className:C}){let w=a===`terminal`,T=(0,v.useMemo)(()=>b?S4(e.items,b.parentToolUseId):e.items,[e.items,b]),E=(0,v.useMemo)(()=>b?e.items.find(e=>e.kind===`tool_call`&&e.id===b.parentToolUseId):void 0,[e.items,b]),D=sM[a][o],O=H8(e.status),k=!b&&h&&h.from>0&&h.from<e.items.length?h.from:void 0,A=(0,v.useMemo)(()=>k===void 0?void 0:Vj(Bj(e,k)),[e,k]),j=(0,v.useMemo)(()=>b&&E&&!T.some(e=>e.kind===`user`)?v0(E):void 0,[b,E,T]),M=(0,v.useMemo)(()=>{let e=(e,t)=>E4(T.slice(e,t),e,w);return k===void 0||!A?[...j?[{key:`brief`,text:j}]:[],...e(0,T.length)]:[...e(0,k),{key:`recap`,line:A},...e(k,T.length)]},[T,k,A,w,j]),N=(0,v.useMemo)(()=>e.skills?.map(e=>e.name),[e.skills]);return(0,U.jsx)(rM,{value:a,children:(0,U.jsx)(BM,{names:N,children:(0,U.jsx)(VM,{names:p,children:(0,U.jsxs)(E3,{className:W(m&&`invisible`,C),children:[(0,U.jsx)(D3,{className:W(w&&`gap-0 p-0`),children:(0,U.jsxs)(W8,{active:w,fontSize:s,lineHeight:c,affordances:l,children:[b?E===void 0&&!m?(0,U.jsx)(`div`,{className:W(w?`term-row text-fg-4`:`p-4 text-body-sm text-fg-4`),children:`This sub-agent's work is not in this transcript.`}):null:T.length===0&&e.status!==`starting`?S===void 0?(0,U.jsx)(A3,{cwd:e.cwd,hasCommands:!!e.commands?.length,hasSkills:!!e.skills?.some(e=>e.enabled),canBrowseFiles:r}):S:null,b&&E===void 0&&!m?null:(0,U.jsx)(V8,{rows:M,boundary:k,since:h?.since,terminal:w,replaying:m,stickyPrompt:!b&&u,gap:D,fontSize:s,lineHeight:c,items:T,pendingApprovals:e.pendingApprovals,scrubber:d,bookmarks:b?void 0:f,affordances:l,fileUrl:t,attachmentUrl:n,hostImage:i,jumpToRecapRef:g,repinRef:_,reveal:b?void 0:y,frameParentId:b?.parentToolUseId,onOpenSubagent:b?void 0:x}),(b?E!==void 0&&S0(E,T):U8(e))?w?(0,U.jsxs)(U.Fragment,{children:[e.items.length>0?(0,U.jsx)(`div`,{className:`term-blank`,"aria-hidden":!0}):null,(0,U.jsx)(O2,{label:e.status===`starting`?`Starting…`:`Working…`,startedAt:O,tokens:e.contextUsage?.totalTokens})]}):(0,U.jsx)(k3,{label:e.status===`starting`?`Starting session…`:void 0}):null]})}),(0,U.jsx)(O3,{}),m?(0,U.jsx)(`div`,{"data-slot":`transcript-hold`,"aria-hidden":!0,className:`wd-hold-appear visible pointer-events-none absolute inset-0 overflow-hidden`,children:(0,U.jsx)(`div`,{className:W(`mx-auto w-full max-w-[var(--wd-transcript-max-width)]`,!w&&`px-4 py-4`),children:w?(0,U.jsx)(k2,{fontSize:s,lineHeight:c,affordances:!1,bleed:`1ch`,className:`term-transcript`,children:(0,U.jsx)(O2,{label:`Loading…`})}):(0,U.jsx)(k3,{label:`Loading session…`})})}):null]})})})})}var K8=.02;function q8(e){let t=e.usageByModel??{},n=e.pricing,r=gk(t,n),i=e.costUsd??(r.unpriced||Object.keys(t).length===0?void 0:r.total),a=e.totalCostUsd,o=Object.entries(t).map(([e,t])=>({model:uk(e),usage:t,tokens:fk(t),costUsd:dk(e,n)?hk(t,e,n).total:void 0,costBasis:t.costBasis})).sort((e,t)=>t.tokens-e.tokens),s=i!==void 0&&a!==void 0?a-i:void 0,c=s!==void 0&&Math.abs(s)>Math.max(.01,K8*Math.max(i??0,a??0));return{displayUsd:i??a,computedUsd:i,reportedUsd:a,breakdown:r,rows:o,unpricedShare:r.unpricedShare,showUnpricedWarning:r.unpricedShare>Lee,unknownBasisModels:pk(t),gapUsd:c?s:void 0}}function J8(e=!0){let[t,n]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(t)},[e]),t}function Y8({windows:e,now:t,className:n}){let r=J8(t===void 0),i=t??r;return(0,U.jsx)(`div`,{className:W(`flex flex-col gap-5`,n),children:e.map(e=>(0,U.jsx)(X8,{window:e,now:i},e.key))})}function X8({window:e,now:t}){let{key:n,info:r,updatedAt:i,inferredReset:a}=e,o=r.utilization??0,s=kk(e,t),c=r.resetsAt===void 0?void 0:r.resetsAt*1e3,l=_M(n),u=c===void 0?void 0:(c-t)/1e3,d=l!==void 0&&u!==void 0&&u>0&&u<l?(l-u)/l:void 0;return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,U.jsx)(`span`,{className:`truncate text-body-sm text-fg-1`,children:gM(n)}),(0,U.jsxs)(`span`,{className:W(`shrink-0 font-mono text-body-sm font-medium`,r.status===`rejected`?`text-danger`:s?`text-fg-4`:`text-fg-1`),children:[o.toFixed(0),`% used`]})]}),(0,U.jsxs)(`div`,{className:`relative mt-2 h-2 rounded-full bg-border`,children:[(0,U.jsx)(`div`,{className:W(`h-full rounded-full`,U2(o),s&&`opacity-40`),style:{width:`${Math.min(100,Math.max(2,o))}%`}}),d===void 0?null:(0,U.jsx)(`span`,{"aria-hidden":!0,title:`Spent evenly, usage would be here by now`,className:`absolute -top-1 h-4 w-0.5 -translate-x-1/2 rounded-full bg-fg-1`,style:{left:`${Math.min(100,Math.max(0,d*100))}%`}})]}),(0,U.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3 text-label text-fg-4`,children:[c===void 0?null:(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(Wx,{className:`size-3`}),` Resets in `,mM(c,t)]}),r.isUsingOverage?(0,U.jsx)(`span`,{className:`text-warning`,children:`overage`}):null,r.status===`rejected`?(0,U.jsx)(`span`,{className:`text-danger`,children:`limit reached`}):null,a?(0,U.jsx)(`span`,{children:`window reset · nothing reported since`}):null,i&&!a?(0,U.jsxs)(`span`,{className:W(s&&`text-warning`),children:[s?`last reported `:``,vM(i,t)]}):null]})]})}function Z8(e){return e===`claude`?`Claude Code`:e}function Q8({label:e,value:t,tone:n}){return(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:n===`muted`?`text-label text-fg-4`:`text-label text-fg-3`,children:e}),(0,U.jsx)(`span`,{className:`font-mono text-body-sm ${n===`muted`?`text-fg-4`:`text-fg-1`}`,children:t})]})}function $8({cost:e,engine:t}){let{breakdown:n,rows:r}=e;return r.length===0?(0,U.jsx)(Q8,{label:`This session has cost`,value:uM(e.displayUsd)}):(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`text-label text-fg-3`,children:`This session has cost`}),(0,U.jsx)(`span`,{className:`font-mono text-body text-fg-1`,children:uM(e.displayUsd)})]}),(0,U.jsxs)(`div`,{className:`space-y-1 border-t border-border pt-2`,children:[(0,U.jsx)(Q8,{label:`input`,value:uM(n.input),tone:`muted`}),(0,U.jsx)(Q8,{label:`output`,value:uM(n.output),tone:`muted`}),(0,U.jsx)(Q8,{label:`cache write`,value:uM(n.cacheWrite),tone:`muted`}),(0,U.jsx)(Q8,{label:`cache read`,value:uM(n.cacheRead),tone:`muted`})]}),(0,U.jsx)(`div`,{className:`space-y-1 border-t border-border pt-2`,children:r.map(e=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`truncate text-label text-fg-4`,children:e.model}),(0,U.jsxs)(`span`,{className:`shrink-0 font-mono text-label text-fg-4`,children:[fM(e.tokens),` · `,e.costUsd===void 0?`no rate`:uM(e.costUsd)]})]},e.model))}),e.showUnpricedWarning?(0,U.jsxs)(`p`,{className:`text-label text-warning`,children:[Math.round(e.unpricedShare*100),`% of these tokens ran on a model with no bundled rate, so the total is an understatement rather than an estimate.`]}):null,e.unknownBasisModels.length>0?(0,U.jsxs)(`p`,{className:`text-label text-warning`,children:[Z8(t),` matched no rate table of its own to `,e.unknownBasisModels.join(`, `),`, so the figure it reports for those tokens is a guess rather than a rate.`]}):null,e.gapUsd===void 0?null:(0,U.jsxs)(`p`,{className:`text-label text-fg-4`,children:[Z8(t),` reports `,uM(e.reportedUsd),` for the same tokens.`]})]})}function e5({spend:e}){let{subscription:t}=e;return(0,U.jsxs)(`div`,{className:`mt-4 space-y-1 border-t border-border pt-3`,children:[(0,U.jsx)(Q8,{label:`This profile, last 7 days`,value:uM(e.weekUsd)}),(0,U.jsx)(Q8,{label:`Last 30 days`,value:uM(e.monthUsd),tone:`muted`}),t?(0,U.jsxs)(`p`,{className:`pt-1 text-label text-fg-4`,children:[t5(t.ratio),` the `,uM(t.weeklyShareUsd),` weekly share of your`,` `,uM(t.monthlyUsd),` a month. A subscription is a flat fee, so this is leverage, not a bill.`]}):null]})}function t5(e){return e>=10?`${Math.round(e)}x`:`${e.toFixed(1)}x`}function n5({rateLimits:e,subscriptionType:t,engine:n,totalCostUsd:r,costUsd:i,usageByModel:a,pricing:o,spend:s,updatedAt:c,open:l,onOpenChange:u,className:d}){let f=J8(l),p=q8({costUsd:i,totalCostUsd:r,usageByModel:a,pricing:o}),m=lk(f);return(0,U.jsx)(Fw,{open:l,onOpenChange:u,children:(0,U.jsxs)(Iw,{className:d,children:[(0,U.jsx)(Lw,{title:`Usage`,description:Z8(n),actions:t?(0,U.jsx)(fo,{variant:`accent`,className:`mt-0.5 shrink-0 capitalize`,children:t}):null}),(0,U.jsxs)(Rw,{children:[e.length===0?(0,U.jsx)(`p`,{className:`py-6 text-center text-body-sm text-fg-4`,children:n===`claude`?`This session reports no plan windows - API-key sessions have none, and a subscription session reports them once a turn has run.`:`Plan windows are a claude.ai subscription thing; this session runs on the ${n} engine.`}):(0,U.jsx)(Y8,{windows:e,now:f}),(0,U.jsx)(`div`,{className:`mt-5 border-t border-border pt-3`,children:(0,U.jsx)($8,{cost:p,engine:n})}),s?(0,U.jsx)(e5,{spend:s}):null,(0,U.jsx)(`p`,{className:`mt-3 text-label text-fg-4`,children:m?`${QO} ${m}`:QO}),c?(0,U.jsxs)(`p`,{className:`mt-2 text-label text-fg-4`,children:[`Updated `,vM(c,f)]}):null]})]})})}function r5({terminal:e,metrics:t,affordances:n,children:r}){return e?(0,U.jsx)(k2,{fontSize:t?.fontSize,lineHeight:t?.lineHeight,affordances:n,bleed:`1ch`,className:`term-transcript`,children:r}):(0,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-[var(--wd-transcript-max-width)] flex-col gap-2`,children:r})}var i5=[`button`,`a`,`input`,`textarea`,`select`,`summary`,`img`,`[contenteditable="true"]`,`[role="button"]`,`[role="menuitem"]`,`[role="checkbox"]`,`[role="radio"]`,`[role="tab"]`].join(`,`);function a5({client:e,sessionId:t,header:n,panelSurface:r=`internal`,statusSurface:i=`internal`,statusPlacement:a=`top`,onOpenPanel:o,onVitals:s,transcriptVariant:c=`cards`,transcriptDensity:l=`comfortable`,transcriptFont:u=`sans`,affordances:d,terminalMetrics:f,scrubber:p=!1,bookmarks:m,peerMentions:h=!0,onToggleBookmark:g,reveal:_,subagents:y,shells:b,openSubagent:x,onSubagentChange:S,openShell:C,onShellChange:w,stickyPrompt:T=!1,controlsSurface:E=`internal`,onControls:D,focusComposerOnClick:O=!1,unseen:k,readOnly:A=!1,approvalPrompts:j,toolHost:M,clientTools:N,cacheTranscript:P,emptyState:F,onLinkClick:I,onOpenFile:L,fontSize:R,className:z}){let ee=f?.fontSize??R,B=f?.lineHeight??(R===void 0?void 0:Math.round(18/13*R)),V=r===`external`,te=i===`external`,ne=E===`status`&&!te,H=E===`external`||ne,[re,ie]=(0,v.useState)(void 0),[ae,oe]=(0,v.useState)(),[se,ce]=(0,v.useState)(!1),[le,ue]=(0,v.useState)(),{state:de,connection:fe,replaying:pe,protocolMismatch:me,shell:he,pricing:ge,models:_e,effectiveModel:ve,handle:ye,send:be,runShell:xe,approve:Se,deny:Ce,interrupt:we,clearContext:Te,setModel:Ee,setPermissionMode:De,reconnectNow:Oe,loadFullResult:ke,loadShellOutput:Ae,verifyShell:je,killShell:Me}=kA(e,t,{onProtocolError:ie,cacheTranscript:P}),{shellId:Ne,enterShell:Pe,leaveShell:Fe,returnReveal:Ie,shell:Le,label:Re}=L4({sessionId:t,items:de.items,session:de.session,shells:b,reveal:_,openShell:C,onShellChange:w}),ze=(0,v.useMemo)(()=>({loadOutput:Ae,verify:je,kill:Me,open:Pe}),[Ae,je,Me,Pe]);(0,v.useEffect)(()=>ie(void 0),[t]);let{subagentId:Be,enterSubagent:Ve,leaveSubagent:He,returnReveal:Ue,frameItems:We,task:Ge,fallbackLabel:Ke}=A4({sessionId:t,items:de.items,session:de.session,reveal:_,openSubagent:x,onSubagentChange:S}),qe=(0,v.useMemo)(()=>Ue&&Ie?Ue.nonce>=Ie.nonce?Ue:Ie:Ue??Ie,[Ue,Ie]),[Je,Ye]=(0,v.useState)(!1);(0,v.useEffect)(()=>{Ye(!1)},[t]);let[Xe]=(0,v.useState)(k),Ze=Je?void 0:Xe,Qe=Ze?Math.max(0,de.items.length-Ze.itemCount):0,$e=(0,v.useCallback)(e=>{V?o?.(e):oe(e)},[V,o]);(0,v.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&Oe()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Oe]),zj(ye,M===!1?{enabled:!1}:N?{...M,clientTools:{...M?.clientTools,...N}}:M);let et=c===`terminal`,tt=de.capabilities,{usage:nt,spend:rt}=wj(e,de.session?.profile,{enabled:tt.rateLimits}),it=(0,v.useMemo)(()=>Dk({rateLimits:de.rateLimits,updatedAt:de.rateLimitsUpdatedAt},nt),[de.rateLimits,de.rateLimitsUpdatedAt,nt]),at=(0,v.useMemo)(()=>Object.keys(it).length>0?jk(it):void 0,[it]),ot=(0,v.useMemo)(()=>{let e=Object.values(it).map(e=>e.updatedAt);return e.length>0?Math.max(...e):void 0},[it]),st=(0,v.useMemo)(()=>Pee({checklist:de.checklist,subagents:y??de.session?.subagents}),[de.checklist,y,de.session?.subagents]),ct=(0,v.useMemo)(()=>{let e=tt.permissionModes,t=[];return _e.length>0&&t.push({name:`model`,description:`Switch the model for this session`,argumentHint:`<model>`,requiresArgs:!0,run:e=>{let t=e.split(/\s+/)[0];return t?(Ee(t),!0):!1}}),e.length>1&&t.push({name:`permissions`,description:`Set the permission mode (${e.join(`, `)})`,argumentHint:`<mode>`,requiresArgs:!0,run:t=>{let n=t.split(/\s+/)[0];return e.includes(n)?(De(n),!0):!1}}),tt.clearContext&&t.push({name:`clear`,description:`Clear the conversation - the session keeps running and the old one stays resumable`,run:()=>(Te(),!0)}),tt.mcpStatus&&t.push({name:`mcp`,description:`MCP servers and their status`,run:()=>($e(`mcp`),!0)}),tt.contextUsage&&t.push({name:`context`,description:`Context window usage`,run:()=>($e(`context`),!0)}),t.push({name:`status`,description:`Session details`,run:()=>($e(`info`),!0)}),tt.rateLimits&&t.push({name:`usage`,description:`Rate limits and spend`,run:()=>($e(`usage`),!0)}),tt.skillsList&&t.push({name:`skills`,description:`Browse the skills this session can use`,run:()=>($e(`skills`),!0)}),t},[tt,_e.length,$e,Te,Ee,De]),lt=(0,v.useMemo)(()=>tM(Yj({commands:tt.slashCommands?de.commands:void 0,clientCommands:ct,skills:tt.skillsList?de.skills:void 0})),[tt.slashCommands,tt.skillsList,de.commands,de.skills,ct]),ut=(0,v.useRef)(s);ut.current=s;let dt=ve??de.model,ft=(0,v.useMemo)(()=>h4(tt.permissionModes,de.session?.canBypassPermissions),[tt.permissionModes,de.session?.canBypassPermissions]);(0,v.useEffect)(()=>{ut.current?.({status:de.status,connection:fe,engine:de.engine,capabilities:de.capabilities,model:dt,models:_e,permissionMode:de.permissionMode,permissionModes:ft,skills:de.skills,composerCommands:lt,cwd:de.cwd,contextUsage:de.contextUsage,tasks:st,rateLimits:at,rateLimitsUpdatedAt:ot,itemCount:de.items.length,totalCostUsd:de.totalCostUsd})},[de.status,fe,de.engine,de.capabilities,dt,_e,de.permissionMode,ft,de.skills,lt,de.cwd,de.contextUsage,st,at,ot,de.items.length,de.totalCostUsd]);let pt=(0,v.useRef)(D);pt.current=D;let mt=(0,v.useRef)({setModel:Ee,setPermissionMode:De,interrupt:we});mt.current={setModel:Ee,setPermissionMode:De,interrupt:we};let ht=(0,v.useRef)({setModel:e=>mt.current.setModel(e),setPermissionMode:e=>mt.current.setPermissionMode(e),interrupt:()=>mt.current.interrupt(),focusComposer:()=>Ot.current?.focus(),insertComposerText:e=>Ot.current?.insertText(e)});(0,v.useEffect)(()=>{let e=pt.current;return e?.(ht.current),()=>e?.(void 0)},[t]);let gt=(0,v.useMemo)(()=>new Set(m??[]),[m]),_t=(0,v.useMemo)(()=>g?{has:e=>gt.has(e),toggle:g}:void 0,[gt,g]),vt=de.status===`running`||de.status===`awaiting_approval`,yt=de.status===`failed`||de.status===`closed`,bt=qA(e,t,{capabilities:tt,engine:de.engine}),xt=pj(e,de.cwd),St=vj(e,t,h),Ct=Cj(e,t),wt=(0,v.useCallback)((e,t)=>xt.search(e,{...t,limit:8}),[xt.search]),Tt=(0,v.useMemo)(()=>Ak(it),[it]),Et=o5(e,t,de.producedFiles),Dt=Z0(e,t),Ot=(0,v.useRef)(null),kt=(0,v.useRef)(null),At=(0,v.useRef)(null),jt=(e,t)=>{if(t.length===0){let t=eM(e,ct);if(t&&t.command.run(t.args))return}Ye(!0),At.current?.(),be(e,t)},Mt=(0,U.jsxs)(jw,{children:[(0,U.jsx)(Mw,{render:(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Session actions`,children:(0,U.jsx)(ty,{className:`size-4`})})}),(0,U.jsxs)(Nw,{children:[tt.contextUsage?(0,U.jsxs)(Pw,{onClick:()=>$e(`context`),children:[(0,U.jsx)(tv,{className:`size-3.5 text-fg-3`}),` Context`]}):null,tt.rateLimits?(0,U.jsxs)(Pw,{onClick:()=>$e(`usage`),children:[(0,U.jsx)(Oy,{className:`size-3.5 text-fg-3`}),` Usage`]}):null,(0,U.jsxs)(Pw,{onClick:()=>$e(`info`),children:[(0,U.jsx)(eb,{className:`size-3.5 text-fg-3`}),` Session info`]}),tt.mcpStatus?(0,U.jsxs)(Pw,{onClick:()=>$e(`mcp`),children:[(0,U.jsx)(Sx,{className:`size-3.5 text-fg-3`}),` MCP servers`]}):null,tt.skillsList?(0,U.jsxs)(Pw,{onClick:()=>$e(`skills`),children:[(0,U.jsx)(ES,{className:`size-3.5 text-fg-3`}),` Skills`]}):null,xt.available?(0,U.jsxs)(Pw,{onClick:()=>$e(`files`),children:[(0,U.jsx)(by,{className:`size-3.5 text-fg-3`}),` Project files`]}):null]})]}),Nt=V?null:Mt,Pt=typeof n==`function`,Ft=(0,U.jsxs)(U.Fragment,{children:[_e.length?(0,U.jsx)(f4,{models:_e,model:ve,onModelChange:Ee,disabled:yt,className:ne?`h-5`:void 0}):null,de.permissionMode?(0,U.jsx)(g4,{mode:de.permissionMode,onModeChange:De,modes:tt.permissionModes,canBypass:de.session?.canBypassPermissions,disabled:yt,className:ne?`h-5`:void 0}):null]}),It=te?null:(0,U.jsx)(f3,{state:de,rateLimits:at,connection:fe,placement:a,controls:ne&&!A?Ft:void 0,onOpenStatus:V&&!o?void 0:()=>$e(`info`),onOpenContext:V&&!o?void 0:()=>$e(`context`),onOpenUsage:V&&!o?void 0:()=>$e(`usage`),tasks:st,onOpenTasks:V&&!o?void 0:()=>$e(`tasks`),actions:Pt?void 0:Nt}),Lt=(0,v.useMemo)(()=>L?{cwd:de.cwd,open:L}:void 0,[L,de.cwd]),Rt=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!I)return;let e=Rt.current;if(!e)return;let t=e=>{let t=e.target?.closest?.(`a[href]`);if(!t)return;let n=t.getAttribute(`href`);n&&I(n)&&(e.preventDefault(),e.stopPropagation())};return e.addEventListener(`click`,t,!0),()=>e.removeEventListener(`click`,t,!0)},[I]),(0,U.jsx)(rM,{value:c,children:(0,U.jsx)(oM,{value:l,children:(0,U.jsx)(Y1,{value:Lt,children:(0,U.jsx)(z0,{value:ke,children:(0,U.jsx)(a2,{value:ze,children:(0,U.jsx)(H0,{value:de.toolTitles,children:(0,U.jsx)(K0,{value:Dt,children:(0,U.jsxs)(`div`,{ref:Rt,"data-slot":`session-panel`,"data-agent-font":u,onClick:e=>{O&&!A&&(e.target?.closest(i5)||window.getSelection()?.isCollapsed!==!1&&Ot.current?.focus())},className:W(`flex h-full min-h-0 flex-col overflow-hidden bg-bg`,z),style:R===void 0?void 0:{"--wd-font-size":`${Math.round(R)}px`},children:[Pt?n({actions:Nt}):n,a===`top`?It:null,me===void 0?null:(0,U.jsxs)(c5,{level:`warning`,children:[`Server speaks protocol v`,me,`, this build renders v`,1,`. Some events may not render.`]}),re?(0,U.jsx)(c5,{level:`error`,onDismiss:()=>ie(void 0),children:re}):null,Ne===void 0?null:(0,U.jsx)(j4,{shell:Le,label:Re,onBack:Fe,onKill:()=>void Me(Ne),terminal:et,fontSize:ee,lineHeight:B}),Ne===void 0&&Be!==void 0?(0,U.jsx)(b4,{task:Ge,items:We,label:Ke,onBack:He,terminal:et,fontSize:ee,lineHeight:B}):null,Ne===void 0?(0,U.jsx)(sN,{value:_t,children:(0,U.jsx)(G8,{state:de,fileUrl:t?n=>e.sessionFileUrl(t,n):void 0,attachmentUrl:t?n=>e.attachmentUrl(t,n):void 0,canBrowseFiles:xt.available,sessionNames:St.names,hostImage:Et,variant:c,density:l,fontSize:ee,lineHeight:B,affordances:d,stickyPrompt:T,scrubber:p,bookmarks:m,replaying:pe,catchUp:Ze&&Qe>0?{from:Ze.itemCount,since:Ze.since}:void 0,reveal:le??qe??_,frame:Be===void 0?void 0:{parentToolUseId:Be},onOpenSubagent:Ve,emptyState:F,jumpToRecapRef:kt,repinRef:At},Be??`session`)}):(0,U.jsx)(M4,{handle:ye,shellId:Ne,fontSize:ee},Ne),Ze&&Qe>0&&!pe&&Be===void 0&&Ne===void 0?(0,U.jsx)(`div`,{className:`px-3 pb-1`,children:(0,U.jsxs)(`div`,{"data-slot":`catch-up`,className:`mx-auto flex w-full max-w-[var(--wd-transcript-max-width)] items-center gap-2 text-label text-fg-3`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:W(`select-none`,et?`text-fg-3`:`text-accent`),children:`※`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[Qe,` new `,Qe===1?`row`:`rows`,Ze.since===void 0?``:` since you were last here`]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>kt.current?.(),className:`shrink-0 underline-offset-2 hover:text-fg-1 hover:underline`,children:`jump`}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>Ye(!0),className:`shrink-0 underline-offset-2 hover:text-fg-1 hover:underline`,children:`dismiss`})]})}):null,!A&&tt.interactiveApprovals&&de.pendingApprovals.length>0?(0,U.jsx)(`div`,{className:W(et?`pb-2`:`px-3 pb-2`),children:(0,U.jsx)(r5,{terminal:et,metrics:{fontSize:ee,lineHeight:B},affordances:d,children:de.pendingApprovals.map(e=>{let t=j?.[e.toolName];if(t)return(0,U.jsx)(t,{request:e,onApprove:Se,onDeny:Ce},e.id);let n=e.toolName===`AskUserQuestion`&&Lk(e.input).length>0;return et?n?(0,U.jsx)(t3,{request:e,onAnswer:Se,onDismiss:e=>Ce(e,`Question dismissed by user`)},e.id):(0,U.jsx)(Q4,{request:e,onApprove:Se,onDeny:Ce},e.id):n?(0,U.jsx)(V4,{request:e,onAnswer:Se,onDismiss:e=>Ce(e,`Question dismissed by user`)},e.id):(0,U.jsx)(y4,{request:e,onApprove:Se,onDeny:Ce},e.id)})})}):null,A||Be!==void 0||Ne!==void 0?null:(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(M2,{ref:Ot,onSend:jt,onInterrupt:we,busy:vt,disabled:yt||!t,commands:tt.slashCommands?de.commands:void 0,skills:tt.skillsList?de.skills:void 0,clientCommands:ct,attachments:bt,draft:Ct,onSearchFiles:xt.available?wt:void 0,peers:St.peers,onShellCommand:he?xe:void 0,layout:H?`inline`:`stacked`,toolbar:H?void 0:Ft,fontSize:ee,lineHeight:B,affordances:d})}),a===`bottom`?It:null,V?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(i3,{state:de,client:e,sessionId:t,open:ae===`info`,onOpenChange:e=>oe(e?`info`:void 0)}),(0,U.jsx)(W2,{usage:de.contextUsage,engine:de.engine??`claude`,open:ae===`context`,onOpenChange:e=>oe(e?`context`:void 0)}),(0,U.jsx)(n5,{rateLimits:Tt,subscriptionType:de.subscriptionType,engine:de.engine??`claude`,totalCostUsd:de.totalCostUsd,costUsd:de.costUsd,usageByModel:de.usageByModel,pricing:ge,spend:rt,updatedAt:ot,open:ae===`usage`,onOpenChange:e=>oe(e?`usage`:void 0)}),(0,U.jsx)(Q2,{client:e,sessionId:t,canManageServers:tt.mcpServerActions,open:ae===`mcp`,onOpenChange:e=>oe(e?`mcp`:void 0)}),(0,U.jsx)(J2,{tasks:st,showCompleted:se,onShowCompletedChange:ce,onSelectTask:e=>{e.toolUseId&&ue({toolUseId:e.toolUseId,nonce:Date.now()})},open:ae===`tasks`,onOpenChange:e=>oe(e?`tasks`:void 0)}),(0,U.jsx)(i4,{skills:de.skills,open:ae===`skills`,onOpenChange:e=>oe(e?`skills`:void 0),onUse:e=>Ot.current?.insertText(Jj(e))}),(0,U.jsx)(X2,{client:e,cwd:de.cwd,open:ae===`files`,onOpenChange:e=>oe(e?`files`:void 0)})]})]})})})})})})})})}function o5(e,t,n){let r=(0,v.useRef)(new Map),i=(0,v.useRef)([]);return(0,v.useEffect)(()=>()=>{for(let e of i.current)URL.revokeObjectURL(e);i.current=[]},[]),(0,v.useCallback)(a=>{let o=n?.[a],s=o?`produced:${o.fileId}`:`fs:${a}`,c=r.current.get(s);if(c)return c;let l=o&&t?e.readProducedFile(t,o.fileId).then(e=>{if(e.size===0)return;let t=URL.createObjectURL(e);return i.current.push(t),t}).catch(()=>void 0):e.readHostFile(a).then(e=>{if(e.encoding!==`base64`)return;let t=s5[a.slice(a.lastIndexOf(`.`)+1).toLowerCase()];return t?`data:${t};base64,${e.content}`:void 0}).catch(()=>void 0);return r.current.set(s,l),l},[e,t,n])}var s5={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`};function c5({level:e,onDismiss:t,children:n}){return(0,U.jsx)(`div`,{className:`px-3 pt-2`,children:(0,U.jsxs)(`div`,{role:`alert`,className:W(`mx-auto flex w-full max-w-[var(--wd-transcript-max-width)] items-start gap-2 rounded-md border px-3 py-2 text-body-sm`,e===`error`?`border-danger/40 bg-danger-bg text-danger`:`border-warning/40 bg-warning-bg text-warning`),children:[(0,U.jsx)(oC,{className:`mt-0.5 size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:n}),t?(0,U.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Dismiss`,className:`shrink-0 opacity-70 transition-opacity hover:opacity-100`,children:(0,U.jsx)(DC,{className:`size-3.5`})}):null]})})}var l5=`[^\\s:'"\`()\\[\\]{}<>|]+`,u5=RegExp(`(?:^|[\\s'"\`([{<@,])((?:\\.\\.?)?(?:/${l5})+|[^\\s:'"\`()\\[\\]{}<>|@,]+(?:/${l5})+)(?::(\\d+))?`),d5=/^([\w.@-]+\.[A-Za-z0-9]{1,10})(?::(\d+))?$/,f5=/[.,;:!?)\]}'"`]+$/,p5=/\.[A-Za-z0-9]{1,10}$/;function m5(e,t=!1){let n=e??``,r=u5.exec(n);if(!r)return t?h5(n):void 0;let i=r[1].replace(f5,``);if(i.includes(`/`)&&!i.endsWith(`/`)&&(i.startsWith(`/`)||i.startsWith(`./`)||i.startsWith(`../`)||p5.test(i)))return{path:i,line:r[2]?Number(r[2]):void 0,length:i.length+(r[2]?r[2].length+1:0)}}function h5(e){let t=d5.exec(e.trim());if(!t)return;let n=t[2]?Number(t[2]):void 0;return{path:t[1],line:n,length:t[0].length}}var g5=`wd-path-link`,_5=.6;function v5(e){if(!e)return;let t=e.closest(`code`)!==null,n=e.textContent?.trim()??``,r=m5(n,t);if(r&&!(!t&&r.length<n.length*_5))return{path:r.path,line:r.line}}function y5({container:e,onOpen:t,enabled:n=!0,ignore:r}){(0,v.useEffect)(()=>{let i=e.current;if(!i||!n)return;let a=e=>r!==void 0&&e?.closest(r)!==null&&e!==void 0,o,s=()=>{o?.classList.remove(g5),o=void 0},c=e=>{if(!e.metaKey&&!e.ctrlKey)return;let n=e.target instanceof HTMLElement?e.target:void 0;if(a(n))return;let r=v5(n);r&&(e.preventDefault(),e.stopPropagation(),s(),t(r))},l=e=>{if(!e.metaKey&&!e.ctrlKey)return s();let t=e.target instanceof HTMLElement?e.target:void 0;t!==o&&(s(),t&&!a(t)&&v5(t)&&(o=t,t.classList.add(g5)))},u=e=>{!e.metaKey&&!e.ctrlKey&&s()};return i.addEventListener(`click`,c,!0),i.addEventListener(`mousemove`,l),document.addEventListener(`keydown`,u),document.addEventListener(`keyup`,u),window.addEventListener(`blur`,s),()=>{s(),i.removeEventListener(`click`,c,!0),i.removeEventListener(`mousemove`,l),document.removeEventListener(`keydown`,u),document.removeEventListener(`keyup`,u),window.removeEventListener(`blur`,s)}},[e,t,n,r])}function b5(e,t){return G1(e,t)?.path??e}var x5={anchor:s_,atom:__,beaker:x_,bike:T_,binary:D_,blocks:k_,bot:j_,box:N_,brain:F_,briefcase:L_,brush:z_,bug:V_,"building-2":U_,cable:G_,camera:Y_,car:Z_,cat:$_,"circuit-board":Cv,cloud:kv,code:jv,coffee:Nv,cog:Fv,compass:Lv,container:zv,cpu:Uv,"credit-card":Gv,database:qv,diamond:Yv,dog:Zv,feather:iee,film:see,flame:fy,"flask-conical":my,folder:Sy,"gamepad-2":Ey,gauge:Oy,gem:Ay,ghost:My,gift:Py,"git-branch":Iy,globe:Ry,"graduation-cap":By,hammer:Hy,hexagon:Ky,house:Jy,image:Qy,key:nb,landmark:ib,laptop:ob,layers:cb,leaf:ub,library:fb,lightbulb:mb,lock:wb,mail:Eb,map:Ob,"message-circle":Mb,mic:Ib,monitor:Rb,moon:Bb,mountain:Hb,music:Wb,network:Kb,newspaper:Jb,notebook:Xb,orbit:Qb,package:ex,palette:nx,"pen-tool":ux,phone:gx,"piggy-bank":vx,plane:bx,plug:Sx,puzzle:Ax,radar:Mx,radio:Px,receipt:Ix,rocket:Bx,ruler:Jx,satellite:Xx,scale:eS,scissors:nS,server:cS,shield:mS,ship:gS,"shopping-cart":vS,signal:bS,smartphone:wS,sparkles:ES,sprout:OS,square:RS,star:BS,sun:HS,table:WS,tag:KS,target:XS,telescope:JS,terminal:QS,"test-tube":eC,"tree-pine":iC,trophy:cC,truck:uC,umbrella:fC,users:gC,wallet:vC,wand:cee,waves:lee,webhook:uee,wifi:fee,wrench:TC,zap:kC};function S5({icon:e,src:t,name:n,className:r}){if(!e)return null;if(e.type===`image`)return t?(0,U.jsx)(`img`,{src:t,alt:``,"aria-hidden":!0,title:n,className:W(`inline-block size-3 shrink-0 object-contain`,r)}):null;let i=x5[e.name]??Sy;return(0,U.jsx)(i,{className:W(`inline-block size-3 shrink-0`,r)})}function C5({usage:e,engine:t,size:n=11,className:r}){if(e===void 0)return null;let i=B2(t),a=`Context ${e.percentage.toFixed(0)}% · ${fM(e.totalTokens)} / ${fM(e.maxTokens)}`,o=W(`shrink-0 leading-none`,H2(e.percentage),r),s=(0,U.jsx)(XT,{value:e.percentage,size:n,strokeWidth:2});return i?(0,U.jsx)(uT,{render:(0,U.jsx)(`span`,{className:o}),content:(0,U.jsxs)(`div`,{className:`flex max-w-64 flex-col gap-1 py-0.5`,children:[(0,U.jsx)(`span`,{className:`font-mono text-fg-2`,children:a}),(0,U.jsx)(`span`,{className:`text-fg-3`,children:i.summary}),(0,U.jsx)(`span`,{className:`text-fg-3`,children:i.hint})]}),children:s}):(0,U.jsx)(`span`,{title:a,className:o,children:s})}var w5={claude:{title:`Claude`,d:`M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z`},codex:{title:`OpenAI`,d:`M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z`},gemini:{title:`Gemini`,d:`M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z`},deepseek:{title:`DeepSeek`,d:`M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z`},moonshot:{title:`Moonshot`,d:`M1.052 16.916l9.539 2.552a21.007 21.007 0 00.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865l-.18-.016-.044-.004-.084-.009-.094-.01a11.605 11.605 0 01-.157-.02l-.107-.014-.11-.016a11.962 11.962 0 01-.32-.051l-.042-.008-.075-.013-.107-.02-.07-.015-.093-.019-.075-.016-.095-.02-.097-.023-.094-.022-.068-.017-.088-.022-.09-.024-.095-.025-.082-.023-.109-.03-.062-.02-.084-.025-.093-.028-.105-.034-.058-.019-.08-.026-.09-.031-.066-.024a6.293 6.293 0 01-.044-.015l-.068-.025-.101-.037-.057-.022-.08-.03-.087-.035-.088-.035-.079-.032-.095-.04-.063-.028-.063-.027a5.655 5.655 0 01-.041-.018l-.066-.03-.103-.047-.052-.024-.096-.046-.062-.03-.084-.04-.086-.044-.093-.047-.052-.027-.103-.055-.057-.03-.058-.032a6.49 6.49 0 01-.046-.026l-.094-.053-.06-.034-.051-.03-.072-.041-.082-.05-.093-.056-.052-.032-.084-.053-.061-.039-.079-.05-.07-.047-.053-.035a7.785 7.785 0 01-.054-.036l-.044-.03-.044-.03a6.066 6.066 0 01-.04-.028l-.057-.04-.076-.054-.069-.05-.074-.054-.056-.042-.076-.057-.076-.059-.086-.067-.045-.035-.064-.052-.074-.06-.089-.073-.046-.039-.046-.039a7.516 7.516 0 01-.043-.037l-.045-.04-.061-.053-.07-.062-.068-.06-.062-.058-.067-.062-.053-.05-.088-.084a13.28 13.28 0 01-.099-.097l-.029-.028-.041-.042-.069-.07-.05-.051-.05-.053a6.457 6.457 0 01-.168-.179l-.08-.088-.062-.07-.071-.08-.042-.049-.053-.062-.058-.068-.046-.056a7.175 7.175 0 01-.027-.033l-.045-.055-.066-.082-.041-.052-.05-.064-.02-.025a11.99 11.99 0 01-1.44-2.402zm-1.02-5.794l11.353 3.037a20.468 20.468 0 00-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923l-.016-.046-.035-.104a11.965 11.965 0 01-.05-.153l-.007-.023a11.896 11.896 0 01-.207-.741l-.03-.126-.018-.08-.021-.097-.018-.081-.018-.09-.017-.084-.018-.094c-.026-.141-.05-.283-.071-.426l-.017-.118-.011-.083-.013-.102a12.01 12.01 0 01-.019-.161l-.005-.047a12.12 12.12 0 01-.034-2.145zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26l.015-.1.008-.049.01-.067.015-.087.018-.098c.026-.148.056-.295.088-.442l.028-.124.02-.085.024-.097c.022-.09.045-.18.07-.268l.028-.102.023-.083.03-.1.025-.082.03-.096.026-.082.031-.095a11.896 11.896 0 011.01-2.232zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213l.045-.065.027-.04.04-.055.046-.065.055-.076.054-.072.064-.086.05-.065.057-.073.055-.07.06-.074.055-.069.065-.077.054-.066.066-.077.053-.06.072-.082.053-.06.067-.074.054-.058.073-.078.058-.06.063-.067.168-.17.1-.098.059-.056.076-.071a12.084 12.084 0 012.272-1.677zM12.017 0h.097l.082.001.069.001.054.002.068.002.046.001.076.003.047.002.06.003.054.002.087.005.105.007.144.011.088.007.044.004.077.008.082.008.047.005.102.012.05.006.108.014.081.01.042.006.065.01.207.032.07.012.065.011.14.026.092.018.11.022.046.01.075.016.041.01L14.7.3l.042.01.065.015.049.012.071.017.096.024.112.03.113.03.113.032.05.015.07.02.078.024.073.023.05.016.05.016.076.025.099.033.102.036.048.017.064.023.093.034.11.041.116.045.1.04.047.02.06.024.041.018.063.026.04.018.057.025.11.048.1.046.074.035.075.036.06.028.092.046.091.045.102.052.053.028.049.026.046.024.06.033.041.022.052.029.088.05.106.06.087.051.057.034.053.032.096.059.088.055.098.062.036.024.064.041.084.056.04.027.062.042.062.043.023.017c.054.037.108.075.161.114l.083.06.065.048.056.043.086.065.082.064.04.03.05.041.086.069.079.065.085.071c.712.6 1.353 1.283 1.909 2.031L7.222.994l.062-.027.065-.028.081-.034.086-.035c.113-.045.227-.09.341-.131l.096-.035.093-.033.084-.03.096-.031c.087-.03.176-.058.264-.085l.091-.027.086-.025.102-.03.085-.023.1-.026L9.04.37l.09-.023.091-.022.095-.022.09-.02.098-.021.091-.02.095-.018.092-.018.1-.018.091-.016.098-.017.092-.014.097-.015.092-.013.102-.013.091-.012.105-.012.09-.01.105-.01c.093-.01.186-.018.28-.024l.106-.008.09-.005.11-.006.093-.004.1-.004.097-.002.099-.002.197-.002z`}};function T5(e,t){if(e===`claude`)return`claude`;if(e===`codex`)return`codex`;let n=t?.toLowerCase()??``;if(n){if(n.includes(`gemini`))return`gemini`;if(n.includes(`deepseek`))return`deepseek`;if(n.includes(`moonshot`)||n.includes(`kimi`))return`moonshot`;if(n.includes(`claude`))return`claude`;if(n.startsWith(`gpt`)||n.startsWith(`o1`)||n.startsWith(`o3`)||n.includes(`openai`))return`codex`}}var E5={claude:`text-vendor-claude`,codex:`text-vendor-openai`},D5={claude:`text-vendor-claude`};function O5(e,t){return E5[T5(e,t)??``]??`text-fg-3`}function k5(e,t){return D5[T5(e,t)??``]??`text-fg-3`}function A5({engine:e,model:t,className:n}){let r=w5[T5(e,t)??``];return r?(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,fillRule:`evenodd`,role:`img`,"aria-label":r.title,className:W(`size-3 shrink-0 text-fg-3`,n),children:[(0,U.jsx)(`title`,{children:r.title}),(0,U.jsx)(`path`,{d:r.d})]}):(0,U.jsx)(`span`,{"aria-hidden":!0,title:e,className:W(`shrink-0 text-fg-3`,n),children:`·`})}function j5({row:e,className:t}){let{info:n}=e,r=W(`size-4 shrink-0`,t);if(e.state===`attention`)return(0,U.jsx)(C_,{className:W(r,`animate-pulse text-warning`)});if(e.state===`working`)return(0,U.jsx)(GT,{className:W(r,`text-info`)});switch(n.status){case`failed`:return(0,U.jsx)(pv,{className:W(r,`text-danger`)});case`closed`:return(0,U.jsx)(yv,{className:W(r,`text-fg-4`)});case`parked`:return(0,U.jsx)(_v,{className:W(r,`text-fg-3`)});default:return(0,U.jsx)(Bb,{className:W(r,`text-fg-4`)})}}function M5(e,t,n=`all`,r){let i=EO(e,n).filter(DO).map(e=>({key:e.toolUseId,kind:`agent`,label:OO(e),noun:`agent`,state:P5(e.status),detail:e.toolCount>0?String(e.toolCount):void 0,title:`${OO(e)} · ${e.toolCount} tool${e.toolCount===1?``:`s`}`,onSelect:()=>t(e.toolUseId)}));return r===void 0?i:[...i,...RO(e,r.now).map(e=>N5(e,r))]}function N5(e,t){let n=YM(e),r=e.status===`running`;return{key:e.id,kind:`shell`,label:WM(e),noun:`shell`,state:JM(e)?`failed`:r?`running`:`done`,detail:r?void 0:n,title:`${GM(e)} · ${n}`,onSelect:()=>t.onSelect(e.id),onKill:r&&t.onKill?()=>t.onKill?.(e.id):void 0}}function P5(e){switch(e){case`running`:return`running`;case`failed`:return`failed`;default:return`done`}}function F5({step:e,active:t=!1,onSelect:n}){let r=e.state===`failed`?`text-danger`:e.kind===`shell`?`text-[var(--wd-shell-accent)]`:`text-success`;return(0,U.jsxs)(`div`,{className:W(`flex w-full items-center rounded-[4px] pr-1.5`,t?`bg-row-selected`:`hover:bg-row-active`,r),children:[(0,U.jsxs)(`button`,{type:`button`,title:e.title,"aria-current":t||void 0,onClick:e=>{e.stopPropagation(),n()},className:`flex min-w-0 flex-1 items-center gap-1.5 py-1 pr-1 pl-3.5 text-left text-micro outline-none`,children:[(0,U.jsx)(I5,{step:e}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.detail?(0,U.jsx)(`span`,{className:`shrink-0 tabular-nums text-fg-4`,children:e.detail}):null,(0,U.jsx)(p_,{className:`size-3.5 shrink-0 text-fg-4`})]}),e.onKill?(0,U.jsx)(`button`,{type:`button`,"aria-label":`Kill ${e.label}`,title:`Kill this shell`,onClick:t=>{t.stopPropagation(),e.onKill?.()},className:`shrink-0 px-1 text-micro leading-none text-fg-4 outline-none hover:text-danger`,children:`✕`}):null]})}function I5({step:e}){if(e.kind===`shell`)return(0,U.jsx)(`span`,{className:`w-[11px] shrink-0 text-center leading-none`,children:`$`});switch(e.state){case`running`:return(0,U.jsx)(GT,{className:`size-[11px] shrink-0`});case`failed`:return(0,U.jsx)(pv,{className:`size-[11px] shrink-0`});default:return(0,U.jsx)(rv,{className:`size-[11px] shrink-0`})}}var L5={meta:!1,ctrl:!1,alt:!1};function R5({row:e,active:t=!1,activeStepKey:n,showGateway:r,showProject:i=!0,projectIcons:a,subagents:o=`active`,onSelect:s,onSelectSubagent:c,onSelectShell:l,onKillShell:u,now:d,onRename:f,renameOn:p=`doubleClick`,editing:m,onEditingChange:h,actions:g,className:_}){let{info:y}=e,[b,x]=(0,v.useState)(!1),S=m??b,C=e=>{x(e),h?.(e)},w=y.engine??`claude`,T=i?PO(e):IO(e),E=i?FO(e):void 0,D=i?y.project?.icon:void 0,O=D?.type===`image`?a?.[D.hash]:void 0,k=uM(y.costUsd??y.totalCostUsd),A=[r?e.hostName:void 0,y.profile?`@${y.profile}`:void 0,k===`-`?void 0:k].filter(e=>!!e),j=xM(y.model),M=[];j&&M.push((0,U.jsx)(`span`,{className:k5(w,y.model),children:j},`model`)),T!==void 0&&M.push((0,U.jsxs)(`span`,{title:E,children:[(0,U.jsx)(S5,{icon:D,src:O,name:E,className:`mr-1.5 size-4 align-[-0.3em]`}),T]},`project`));for(let e of A)M.push((0,U.jsx)(`span`,{children:e},e));let N=M5(y,e=>c?c(e):s?.(L5),o,{now:d??Date.now(),onSelect:e=>l?l(e):s?.(L5),onKill:u}),P=N.some(e=>e.key===n);return(0,U.jsxs)(`div`,{"data-slot":`session-item`,"data-active":t||void 0,role:`button`,tabIndex:0,onClick:e=>{e.detail>1||S||s?.({meta:e.metaKey,ctrl:e.ctrlKey,alt:e.altKey})},onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s?.({meta:e.metaKey,ctrl:e.ctrlKey,alt:e.altKey}))},className:W(`group flex w-full cursor-pointer flex-col p-1 text-left outline-none`,`rounded-[4px] transition-colors focus-visible:ring-2 focus-visible:ring-ring`,P?`bg-row-selected-weak`:t?`bg-row-selected`:`hover:bg-row-hover`,_),children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 py-0.5 pr-0.5 pl-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex h-5 items-center gap-1.5 overflow-hidden`,children:[(0,U.jsx)(z5,{children:(0,U.jsx)(j5,{row:e})}),S&&f?(0,U.jsx)(B5,{initial:y.title??``,onCommit:e=>{C(!1),e!==(y.title??``)&&f(e)},onCancel:()=>C(!1)}):(0,U.jsx)(`span`,{onDoubleClick:f&&p===`doubleClick`?e=>{e.stopPropagation(),C(!0)}:void 0,className:`min-w-0 flex-1 truncate text-body-sm font-medium tracking-[-0.005em] text-fg-1`,children:MO(y)}),e.unseen>0?(0,U.jsx)(`span`,{title:`${e.unseen} new message${e.unseen===1?``:`s`}`,className:W(`flex h-4 min-w-6 shrink-0 items-center justify-center rounded-full px-2`,`text-[0.75rem] leading-none tracking-[-0.005em] tabular-nums`,e.state===`working`?`bg-badge text-badge-fg`:`bg-accent text-accent-fg`),children:e.unseen}):null,(0,U.jsx)(C5,{usage:y.contextUsage,engine:w,size:16,className:`p-0.5`})]}),(0,U.jsxs)(`div`,{className:`flex h-5 items-center gap-1.5 overflow-hidden text-body-sm tracking-[-0.005em]`,children:[(0,U.jsx)(z5,{children:(0,U.jsx)(A5,{engine:w,model:y.model,className:W(`size-4`,O5(w,y.model))})}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-fg-4`,children:M.map((e,t)=>(0,U.jsxs)(v.Fragment,{children:[t>0?` · `:``,e]},t))}),(0,U.jsxs)(`span`,{className:`shrink-0 text-fg-4`,children:[M.length>0?`· `:``,hM(y.lastActivityAt??y.createdAt)]}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1`}),g]})]}),N.length>0?(0,U.jsx)(`div`,{className:`flex flex-col`,children:N.map(e=>(0,U.jsx)(F5,{step:e,active:e.key===n,onSelect:e.onSelect},e.key))}):null]})}function z5({children:e}){return(0,U.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:e})}function B5({initial:e,onCommit:t,onCancel:n}){let[r,i]=(0,v.useState)(e),a=(0,v.useRef)(null);return(0,v.useEffect)(()=>{a.current?.focus(),a.current?.select()},[]),(0,v.useEffect)(()=>{let e=()=>{a.current?.focus(),a.current?.select()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),(0,U.jsx)(`input`,{ref:a,value:r,spellCheck:!1,placeholder:`Session name`,"aria-label":`Session name`,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onChange:e=>i(e.target.value),onBlur:()=>{document.hasFocus()&&t(r.trim())},onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?t(r.trim()):e.key===`Escape`&&n()},className:W(`-my-0.5 min-w-0 flex-1 rounded-sm border border-ring bg-bg px-1 py-px`,`text-body-sm leading-5 text-fg-1 outline-none`)})}function V5(e){return W(`px-2 py-1.5 hover:bg-row-hover`,e?`mr-1 ml-0 rounded-r-md border-l-4 border-l-accent`:`mx-1 rounded-md`)}function H5({rows:e,config:t,onConfigChange:n,scope:r,activeId:i,activeSubagentId:a,activeShellId:o,now:s,onSelect:c,onDelete:l,onRename:u,onClearContext:d,onSelectSubagent:f,onSelectShell:p,onKillShell:m,emptyState:h,showControls:g=!0,projectIcons:_,className:y}){let b=(0,v.useMemo)(()=>WO(e,t,r),[e,t,r]),x=(0,v.useMemo)(()=>Oee(b,t),[b,t]),S=kee(t,r,b.length,e.length),C=(0,v.useMemo)(()=>AO(e),[e]),w=(0,v.useMemo)(()=>jO(e),[e]),T=(0,v.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.hostId,n.hostName);return[...t].map(([e,t])=>({id:e,name:t}))},[e]),E=e=>n({...t,...e});return(0,U.jsxs)(`div`,{"data-slot":`session-browser`,className:W(`flex flex-col gap-3`,y),children:[(0,U.jsxs)(`div`,{className:W(`flex flex-col gap-1.5 px-2`,!g&&`hidden`),children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(oS,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-fg-4`}),(0,U.jsx)(_o,{value:t.search,onChange:e=>E({search:e.target.value}),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`pl-8`})]}),(0,U.jsx)(K5,{label:`State`,children:(0,U.jsx)(q5,{label:`State`,value:t.states,options:SO.map(e=>({value:e,label:CO[e]})),onChange:e=>E({states:e})})}),C.length>1?(0,U.jsx)(K5,{label:`Engine`,children:(0,U.jsx)(q5,{label:`Engine`,value:t.adapters,options:C.map(e=>({value:e,label:e})),onChange:e=>E({adapters:e})})}):null,T.length>1?(0,U.jsx)(K5,{label:`Gateway`,children:(0,U.jsx)(q5,{label:`Gateway`,value:t.gateways,options:T.map(e=>({value:e.id,label:e.name})),onChange:e=>E({gateways:e})})}):null,w.length>1?(0,U.jsx)(K5,{label:`Project`,children:(0,U.jsx)(q5,{label:`Project`,value:t.projects??[],options:w.map(e=>({value:e.key,label:e.label})),onChange:e=>E({projects:e})})}):null,(0,U.jsx)(K5,{label:`Group`,children:(0,U.jsx)(J5,{label:`Group`,value:t.groupBy,options:[{value:`none`,label:`No grouping`},{value:`state`,label:`By state`},{value:`adapter`,label:`By engine`},...w.length>1?[{value:`project`,label:`By project`}]:[],...T.length>1?[{value:`gateway`,label:`By gateway`}]:[]],onChange:e=>E({groupBy:e})})}),(0,U.jsx)(K5,{label:`Sub-agents`,children:(0,U.jsx)(J5,{label:`Sub-agents`,value:t.subagents,options:[{value:`active`,label:`Hide completed`},{value:`all`,label:`Show all`},{value:`none`,label:`Hide all`}],onChange:e=>E({subagents:e})})}),(0,U.jsx)(K5,{label:`Sort`,children:(0,U.jsx)(J5,{label:`Sort`,value:t.sortBy,options:[{value:`recent`,label:`Recent`},{value:`name`,label:`Name`},{value:`state`,label:`State`},...w.length>1?[{value:`project`,label:`Project`}]:[],...T.length>1?[{value:`gateway`,label:`Gateway`}]:[]],onChange:e=>E({sortBy:e})})})]}),S?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-label text-fg-4`,children:[(0,U.jsxs)(`span`,{children:[S.shown,` of `,S.total,S.causes.length?` · ${S.causes.join(` · `)}`:null]}),(0,U.jsx)(`button`,{type:`button`,className:`text-fg-3 underline underline-offset-2 hover:text-fg-1`,onClick:()=>n(YO(t)),children:`Show all`})]}):null,e.length===0?h??(0,U.jsx)(JT,{icon:(0,U.jsx)(cb,{}),title:`No sessions yet`}):b.length===0?Aee(t)?(0,U.jsx)(JT,{icon:(0,U.jsx)(iS,{}),title:`No matches`,description:`No session matches the current search and filters.`,action:`Clear filters`,onAction:()=>n(YO(t))}):(0,U.jsx)(JT,{icon:(0,U.jsx)(cb,{}),title:`Nothing here`,description:`No session to show.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-4 px-1`,children:x.map(e=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t.groupBy!==`none`&&e.label?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-2 text-label font-medium text-fg-4`,children:[t.groupBy===`project`?(0,U.jsx)(S5,{icon:e.rows[0]?.info.project?.icon,src:U5(e.rows[0],_),name:e.label}):null,(0,U.jsx)(`span`,{className:`uppercase tracking-wide`,children:e.label}),(0,U.jsx)(`span`,{className:`text-fg-4/70`,children:e.rows.length})]}):null,e.rows.map(e=>(0,U.jsx)(W5,{row:e,active:e.info.id===i,activeSubagentId:a,activeShellId:o,now:s,showGateway:T.length>1&&t.groupBy!==`gateway`,showProject:t.groupBy!==`project`,subagents:t.subagents,projectIcons:_,onSelect:c,onDelete:l,onRename:u,onClearContext:d,onSelectSubagent:f,onSelectShell:p,onKillShell:m},`${e.hostId}:${e.info.id}`))]},e.key))})]})}function U5(e,t){let n=e?.info.project?.icon;return n?.type===`image`?t?.[n.hash]:void 0}function W5({row:e,active:t,activeSubagentId:n,activeShellId:r,now:i,showGateway:a,showProject:o=!0,subagents:s,projectIcons:c,onSelect:l,onDelete:u,onRename:d,onClearContext:f,onSelectSubagent:p,onSelectShell:m,onKillShell:h}){let{info:g}=e,[_,y]=(0,v.useState)(!1);return(0,U.jsx)(R5,{row:e,active:t===!0,activeStepKey:r??n,now:i,showGateway:a,showProject:o,subagents:s,projectIcons:c,onSelect:()=>l?.(e),onSelectSubagent:p?t=>p(e,t):void 0,onSelectShell:m?t=>m(e,t):void 0,onKillShell:h?t=>h(e,t):void 0,onRename:d?t=>d(e,t):void 0,renameOn:`external`,editing:_,onEditingChange:y,actions:(0,U.jsxs)(U.Fragment,{children:[d&&!_?(0,U.jsx)(G5,{label:`Rename session`,onClick:()=>y(!0),children:(0,U.jsx)(mx,{className:`size-3 text-fg-3`})}):null,f&&g.capabilities?.clearContext?(0,U.jsx)(G5,{label:`Clear context`,title:`Clear the conversation - the session keeps running and the old conversation stays resumable`,onClick:()=>f(e),children:(0,U.jsx)(ree,{className:`size-3 text-fg-3`})}):null,u?(0,U.jsx)(G5,{label:`Close session`,onClick:()=>u(e),children:(0,U.jsx)(nC,{className:`size-3 text-fg-3`})}):null]})})}function G5({label:e,title:t,onClick:n,children:r}){return(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":e,title:t??e,className:`size-5 shrink-0 opacity-0 transition-opacity group-hover:opacity-100`,onClick:e=>{e.stopPropagation(),n()},children:r})}function K5({label:e,children:t}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`w-14 shrink-0 truncate text-label text-fg-3`,children:e}),(0,U.jsx)(`div`,{className:`min-w-0 flex-1`,children:t})]})}function q5({label:e,value:t,options:n,onChange:r}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsxs)(jC,{multiple:!0,value:t,onValueChange:e=>r(e),children:[(0,U.jsx)(PC,{"aria-label":e,className:`min-w-0 flex-1`,children:(0,U.jsx)(MC,{children:t.length===0?`All`:t.length===1?n.find(e=>e.value===t[0])?.label??`All`:`${t.length} selected`})}),(0,U.jsx)(FC,{children:n.map(e=>(0,U.jsx)(IC,{value:e.value,children:(0,U.jsx)(NC,{children:e.label})},e.value))})]}),t.length>0?(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clear ${e}`,onClick:()=>r([]),children:(0,U.jsx)(DC,{className:`size-3 text-fg-4`})}):null]})}function J5({label:e,value:t,options:n,onChange:r}){return(0,U.jsxs)(jC,{value:t,onValueChange:e=>r(e),children:[(0,U.jsx)(PC,{"aria-label":e,className:`w-full min-w-0`,children:(0,U.jsx)(MC,{children:n.find(e=>e.value===t)?.label??e})}),(0,U.jsx)(FC,{children:n.map(e=>(0,U.jsx)(IC,{value:e.value,children:(0,U.jsx)(NC,{children:e.label})},e.value))})]})}var Y5=[`all`,`active`,`none`],X5={all:{label:`All sub-agents`,hint:`Showing every sub-agent`},active:{label:`Hide completed`,hint:`Showing running and failed sub-agents`},none:{label:`Hide sub-agents`,hint:`Sub-agents hidden`}},Z5=.34;function Q5({value:e,className:t}){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:t,children:[(0,U.jsx)(`path`,{d:`M3 5h18`}),(0,U.jsx)(`path`,{d:`M9 12h12`,opacity:e===`none`?Z5:1}),(0,U.jsx)(`path`,{d:`M9 19h12`,opacity:e===`all`?1:Z5})]})}function $5({value:e,onChange:t,className:n}){let r=X5[e];return(0,U.jsxs)(jw,{children:[(0,U.jsx)(Mw,{render:(0,U.jsxs)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Sub-agents: ${r.label}`,title:r.hint,className:W(`w-9 gap-0.5`,n),children:[(0,U.jsx)(Q5,{value:e,className:`size-4`}),(0,U.jsx)(av,{className:`size-2.5 text-fg-4`})]})}),(0,U.jsx)(Nw,{className:`min-w-44`,children:Y5.map(n=>(0,U.jsxs)(Pw,{onClick:()=>t(n),children:[(0,U.jsx)(Q5,{value:n,className:`size-4 shrink-0 text-fg-3`}),(0,U.jsx)(`span`,{className:`flex-1`,children:X5[n].label}),n===e?(0,U.jsx)(rv,{className:`size-3.5 shrink-0 text-accent`}):null]},n))})]})}function e7(){let[e,t]=(0,v.useState)(T());return(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Toggle theme`,onClick:()=>t(O()),children:e===`dark`?(0,U.jsx)(HS,{className:`size-4`}):(0,U.jsx)(Bb,{className:`size-4`})})}var t7=[{value:`default`,displayName:`Default (recommended)`,description:`The CLI's configured default model`},{value:`fable`,displayName:`Fable`,description:`Fable 5.1 · Most capable for your hardest and longest-running tasks`},{value:`opus`,displayName:`Opus`,description:`Opus 5.5 with 1M context · Best for everyday, complex tasks`},{value:`sonnet`,displayName:`Sonnet`,description:`Sonnet 5 · Efficient for routine tasks`},{value:`haiku`,displayName:`Haiku`,description:`Haiku 4.5 · Fastest for quick answers`}],n7=`workerdeck.transcript-density`;function r7(){return b(n7)===`compact`?`compact`:`comfortable`}function i7(e){x(n7,e)}var a7=`workerdeck.transcript-variant`;function o7(){let e=b(a7);return e===`terminal`||e===`lines`?`terminal`:`cards`}function s7(e){x(a7,e)}var c7=`workerdeck.transcript-font`;function l7(){return b(c7)===`mono`?`mono`:`sans`}function u7(e){x(c7,e)}var d7=`workerdeck.font-size`;function f7(){let e=b(d7);if(e===void 0)return;let t=Number(e);return Number.isFinite(t)&&t>=8&&t<=24?Math.round(t):void 0}function Wte(e){x(d7,e===void 0?void 0:String(Math.round(e)))}var p7=`workerdeck.catch-up`;function m7(){return b(p7)===`off`?`off`:`on`}function Gte(e){x(p7,e)}function h7({label:e,options:t,read:n,write:r,onChange:i}){let[a,o]=(0,v.useState)(n);return(0,U.jsxs)(jC,{value:a,onValueChange:e=>{o(e),r(e),i?.(e)},children:[(0,U.jsx)(PC,{"aria-label":e,className:`min-w-40`,children:(0,U.jsx)(MC,{children:t.find(e=>e.value===a)?.label})}),(0,U.jsx)(FC,{children:t.map(e=>(0,U.jsx)(IC,{value:e.value,children:(0,U.jsx)(NC,{children:e.label})},e.value))})]})}function g7({title:e,children:t}){return(0,U.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(`h3`,{className:`text-label font-medium tracking-wide text-fg-3 uppercase`,children:e}),t]})}function Kte({open:e,onOpenChange:t}){let[n,r]=(0,v.useState)(o7);return(0,U.jsx)(Fw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Iw,{size:`md`,className:`w-[min(30rem,calc(100vw-2rem))]`,children:[(0,U.jsx)(Lw,{title:`Settings`,description:`Preferences held by this browser. What a run defaults to lives on its profile; server policy lives where the gateway runs.`}),(0,U.jsx)(Rw,{children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,U.jsxs)(g7,{title:`Appearance`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Theme`}),(0,U.jsx)(e7,{})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Agent view style`}),(0,U.jsx)(h7,{label:`Agent view style`,options:[{value:`cards`,label:`Cards`},{value:`terminal`,label:`Terminal`}],read:o7,write:s7,onChange:r})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Font size`}),(0,U.jsx)(h7,{label:`Font size`,options:[{value:``,label:`Default`},{value:`11`,label:`11 px`},{value:`12`,label:`12 px`},{value:`13`,label:`13 px`},{value:`14`,label:`14 px`},{value:`15`,label:`15 px`},{value:`16`,label:`16 px`}],read:()=>String(f7()??``),write:e=>Wte(e?Number(e):void 0)})]}),n===`cards`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Agent view density`}),(0,U.jsx)(h7,{label:`Agent view density`,options:[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`}],read:r7,write:i7})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Agent view font`}),(0,U.jsx)(h7,{label:`Agent view font`,options:[{value:`sans`,label:`Regular`},{value:`mono`,label:`Monospace`}],read:l7,write:u7})]})]}):null]}),(0,U.jsx)(g7,{title:`Sessions`,children:(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsxs)(`span`,{className:`text-body-sm text-fg-2`,children:[`Catch-up mode`,(0,U.jsx)(`span`,{className:`block text-label text-fg-4`,children:`Mark what arrived since you last read a session, with a bar that counts the new rows and jumps to them.`})]}),(0,U.jsx)(h7,{label:`Catch-up mode`,options:[{value:`on`,label:`On`},{value:`off`,label:`Off`}],read:m7,write:Gte})]})})]})})]})})}function _7({className:e}){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:e,children:[(0,U.jsx)(`path`,{d:`M12 3 20.5 7.75 12 12.5 3.5 7.75Z`}),(0,U.jsx)(`path`,{d:`M3.5 12.25 12 17l8.5-4.75`}),(0,U.jsx)(`path`,{d:`M3.5 16.5 12 21.25l8.5-4.75`}),(0,U.jsx)(`path`,{d:`M12 6.15 14.85 7.75 12 9.35 9.15 7.75Z`,fill:`#2fbf71`,stroke:`none`})]})}function v7(e){let t=e,n=new Set,r=()=>t,i=()=>{for(let e of n)e()},a=e=>(n.add(e),()=>void n.delete(e));return{get:r,subscribe:a,set:e=>{t=e,i()},patch:e=>{t={...t,...e},i()},use:()=>(0,v.useSyncExternalStore)(a,r,r)}}var y7=`workerdeck.hosts.v1`;function b7(e){return`workerdeck.host.${e}.key`}var x7=`gateway`,S7=v7({hosts:[],ready:!1});function C7(e){O7.clear(),S7.set(e)}function w7(){let e=S(y7,[]);return Array.isArray(e)?e.map(({implicit:e,...t})=>t):[]}function T7(e){C(y7,e.filter(e=>!e.implicit))}function qte(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function E7(e){return b(b7(e))??``}function D7(e,t){x(b7(e),t===``?void 0:t)}var O7=new Map;function k7(e){let t=O7.get(e);if(t)return t;let n=S7.get().hosts.find(t=>t.id===e);if(!n)return;let r=ij(n);if(r===void 0)return;let i=new cj({baseUrl:r,...n.implicit?{}:oj({baseUrl:r,key:E7(n.id)})});return O7.set(e,i),i}function A7(){return S7.get().hosts.find(e=>e.implicit)??S7.get().hosts[0]}function Jte(){let e=A7();return e?k7(e.id):void 0}function j7(e){return aj(e)}function Yte(e,t){let n=w7(),r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[...n,e];T7(r),D7(e.id,t),C7({...S7.get(),hosts:[...S7.get().hosts.filter(e=>e.implicit),...r]})}function Xte(e){let t=w7().filter(t=>t.id!==e);T7(t),D7(e,``),C7({...S7.get(),hosts:[...S7.get().hosts.filter(e=>e.implicit),...t]})}async function Zte(){try{let e=await fetch(`${location.origin}/auth/status`,{headers:{accept:`application/json`}});if(!e.ok||!e.headers.get(`content-type`)?.includes(`application/json`))return!1;let t=await e.json();return typeof t==`object`&&!!t&&`enabled`in t}catch{return!1}}var M7=!1;function N7(){if(M7)return;M7=!0;let e=w7();C7({hosts:e,ready:!1}),Zte().then(t=>{C7({hosts:t?[{id:x7,name:`This gateway`,baseUrl:location.origin,implicit:!0},...e]:e,ready:!0})})}function P7(e){return N7(),S7.subscribe(e)}function F7(){return(0,v.useSyncExternalStore)(P7,S7.get,S7.get)}function Qte(){return N7(),S7.get().hosts}function $te(e){return P7(e)}function I7({host:e,submitLabel:t=`Save`,onSaved:n,actions:r}){let[i,a]=(0,v.useState)(e.name),[o,s]=(0,v.useState)(e.baseUrl),[c,l]=(0,v.useState)(()=>E7(e.id));return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label text-fg-3`,children:`Name`}),(0,U.jsx)(_o,{value:i,onChange:e=>a(e.target.value),placeholder:`Mac mini`})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label text-fg-3`,children:`Address`}),(0,U.jsx)(_o,{value:o,onChange:e=>s(e.target.value),placeholder:`http://toby.ts.net:8787`,spellCheck:!1,className:`font-mono`})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label text-fg-3`,children:`Auth key`}),(0,U.jsx)(_o,{type:`password`,value:c,onChange:e=>l(e.target.value),placeholder:`Leave empty for an unauthenticated gateway`,spellCheck:!1}),(0,U.jsx)(`span`,{className:`text-label text-fg-4`,children:`Stored in this browser’s local storage, and sent on the WebSocket URL when attaching. Use a gateway you control, over a network you trust.`})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2`,children:[r,(0,U.jsx)(lo,{onClick:()=>{if(ij({baseUrl:o})===void 0){DT.error(`That address is not a URL`);return}if(!i.trim()){DT.error(`Give the gateway a name`);return}let t={id:e.id,name:i.trim(),baseUrl:o.trim()};Yte(t,c),n(t)},children:t})]})]})}function ene({open:e,onOpenChange:t,onCreated:n}){let[r,i]=(0,v.useState)(()=>L7());return(0,U.jsx)(Fw,{open:e,onOpenChange:e=>{e&&i(L7()),t(e)},children:(0,U.jsxs)(Iw,{children:[(0,U.jsx)(Lw,{title:`Add gateway`,description:`A workerdeck gateway you run - typically over Tailscale.`}),(0,U.jsx)(Rw,{children:(0,U.jsx)(I7,{host:r,submitLabel:`Add gateway`,onSaved:n,actions:(0,U.jsx)(lo,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`})})})]})})}function L7(){return{id:qte(),name:``,baseUrl:``}}function R7({host:e,onClose:t,onRemoved:n}){return(0,U.jsx)(Fw,{open:!0,onOpenChange:e=>!e&&t(),children:(0,U.jsxs)(Iw,{children:[(0,U.jsx)(Lw,{title:`Remove ${e.name}?`,description:`Its auth key is deleted from this browser. The gateway itself keeps running.`}),(0,U.jsx)(Rw,{children:(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(lo,{variant:`outline`,onClick:t,children:`Cancel`}),(0,U.jsx)(lo,{variant:`destructive`,onClick:()=>{Xte(e.id),n()},children:`Remove`})]})})]})})}function z7(e){return e===`sessions`?`workerdeck.sessions-sidebar-width`:`workerdeck.${e}-sidebar-width`}function B7(e){return e===`sessions`?`workerdeck.sessions-sidebar-collapsed`:`workerdeck.${e}-sidebar-collapsed`}function tne(e){let t=Number(b(z7(e)));return t?Math.min(520,Math.max(240,t)):300}function nne(e,t){x(z7(e),String(t))}function rne(e){return b(B7(e))===`1`}function ine(e,t){x(B7(e),t?`1`:`0`)}var V7=`workerdeck.sessions-filters-shown`;function ane(){return b(V7)===`1`}function one(e){x(V7,e?`1`:`0`)}function H7({section:e,title:t,badge:n,actions:r,children:i,rail:a,railActions:o}){let[s,c]=(0,v.useState)(()=>tne(e)),[l,u]=(0,v.useState)(()=>rne(e)),d=t=>{u(t),ine(e,t)};return l?(0,U.jsxs)(`div`,{className:`flex min-h-0 w-11 shrink-0 flex-col items-center gap-1 border-r border-border bg-sidebar py-1.5`,children:[(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Expand ${t.toLowerCase()}`,onClick:()=>d(!1),children:(0,U.jsx)(ox,{className:`size-4`})}),o,a?(0,U.jsx)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col items-center gap-0.5 overflow-y-auto pt-1`,children:a}):null]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{style:{width:s},className:`flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar`,children:[(0,U.jsxs)(`header`,{className:`flex h-9 shrink-0 items-center gap-1 pr-1 pl-3`,children:[(0,U.jsx)(`span`,{className:`truncate text-label font-medium tracking-wide text-fg-3 uppercase`,children:t}),n,(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Collapse ${t.toLowerCase()}`,onClick:()=>d(!0),children:(0,U.jsx)(ix,{className:`size-3.5`})}),r]}),i]}),(0,U.jsx)(qT,{orientation:`vertical`,value:s,onValueChange:t=>{c(t),nne(e,t)},min:240,max:520,defaultValue:300,"aria-label":`Resize ${t.toLowerCase()} sidebar`})]})}function U7({children:e,className:t}){return(0,U.jsx)(`div`,{className:W(`min-h-0 flex-1 overflow-y-auto pb-2`,t),children:e})}function W7({title:e,status:t,description:n,actions:r,active:i,onSelect:a,onDoubleClick:o}){return(0,U.jsxs)(`div`,{"data-slot":`sidebar-row`,"data-active":i||void 0,onClick:a,onDoubleClick:o,className:W(`group flex cursor-pointer flex-col gap-0.5 text-left transition-colors`,V5(i===!0)),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`button`,{type:`button`,className:W(`min-w-0 flex-1 truncate text-left text-body-sm outline-none`,i?`font-medium text-fg-1`:`text-fg-2`),children:e}),t]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 text-label text-fg-4`,children:[(0,U.jsx)(`button`,{type:`button`,tabIndex:-1,className:`flex min-w-0 flex-1 items-center gap-1.5 truncate text-left font-mono outline-none`,children:n}),r]})]})}function G7({label:e,onClick:t,children:n}){return(0,U.jsx)(`button`,{type:`button`,"aria-label":e,title:e,onClick:e=>{e.stopPropagation(),t()},className:`flex size-5 shrink-0 items-center justify-center rounded text-fg-3 opacity-0 transition-opacity outline-none hover:bg-surface-hover hover:text-fg-1 group-hover:opacity-100`,children:n})}var K7=`workerdeck.watermarks.v1`,q7=v7(0),J7=new Fk({read:()=>S(K7,void 0),write:e=>{C(K7,e),q7.set(q7.get()+1)}});function Y7(){return q7.use(),{unseenFor:(0,v.useCallback)((e,t)=>Ik(J7.get(e,t.id),{proseCount:t.proseCount,activityCount:t.activityCount,turns:t.numTurns}),[]),watermarks:J7}}function sne(e,t){let n=J7.get(e,t);return n?{itemCount:n.itemCount,since:n.seenAt}:void 0}function cne(e,t){let n=(0,v.useRef)({});return(0,v.useCallback)(r=>{t&&!document.hidden&&(n.current={...n.current,...r},J7.mark(e,t,n.current))},[e,t])}function lne(e){let{unseenFor:t}=Y7();return(0,v.useMemo)(()=>e.reduce((e,n)=>e+t(n.hostId,n.info),0),[e,t])}var une=5e3,dne=1200,fne=700,X7=v7({snapshots:[],loaded:!1}),pne=X7.set,Z7,Q7=0,$7;function e9(){return Z7??=(async()=>{Q7=Date.now();try{let e=Qte(),t=new Map(X7.get().snapshots.map(e=>[e.host.id,e]));pne({snapshots:await Promise.all(e.map(async e=>{let n=k7(e.id);if(!n)return{host:e,sessions:[],error:`unusable address`};try{return{host:e,sessions:await n.listSessions()}}catch(n){return{host:e,sessions:t.get(e.id)?.sessions??[],error:n instanceof Error?n.message:String(n)}}})),loaded:!0})}finally{Z7=void 0}})(),Z7}function mne(){if($7!==void 0)return;let e=Math.max(0,fne-(Date.now()-Q7));$7=setTimeout(()=>{$7=void 0,e9()},e)}var t9,n9;function hne(e){let t=e?dne:une;(t9===void 0||n9!==t)&&(t9!==void 0&&clearInterval(t9),n9=t,t9=setInterval(()=>void e9(),t))}function r9(){let e=X7.use();(0,v.useEffect)(()=>$te(()=>void e9()),[]);let t=e.snapshots.some(e=>e.sessions.some(e=>{let t=wO(e);return t===`working`||t===`attention`}));return(0,v.useEffect)(()=>{hne(t),X7.get().loaded||e9()},[t]),{...e,refresh:e9}}function i9(e){let{unseenFor:t}=Y7();return(0,v.useMemo)(()=>e.flatMap(({host:e,sessions:n})=>n.filter(e=>!LO(e)).map(n=>({hostId:e.id,hostName:e.name,local:j7(e),adapter:n.engine??`claude`,state:wO(n),info:n,unseen:t(e.id,n)}))),[e,t])}function gne(){let e=jr(),t=bi({select:e=>e.location.pathname.match(/^\/gateways\/(.+)$/)?.[1]}),{hosts:n,ready:r}=F7(),{snapshots:i}=r9(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),l=i.filter(e=>e.error===void 0).length,u=(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Add gateway`,onClick:()=>o(!0),children:(0,U.jsx)(wx,{className:`size-4`})});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(H7,{section:`gateways`,title:`Gateways`,badge:r&&n.length>0?(0,U.jsxs)(`span`,{className:`shrink-0 text-label text-fg-4`,children:[l,`/`,n.length]}):void 0,actions:u,railActions:u,children:(0,U.jsxs)(U7,{children:[r&&n.length===0?(0,U.jsx)(JT,{icon:(0,U.jsx)(cS,{}),title:`No gateways yet`,description:(0,U.jsxs)(U.Fragment,{children:[`Add one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})}):null,n.map(n=>{let r=i.find(e=>e.host.id===n.id),a=r===void 0?`pending`:r.error?`error`:`ok`;return(0,U.jsx)(W7,{active:n.id===t,onSelect:()=>void e({to:`/gateways/$hostId`,params:{hostId:n.id}}),title:n.name,status:(0,U.jsxs)(U.Fragment,{children:[n.implicit?(0,U.jsx)(`span`,{className:`shrink-0 text-label text-fg-4`,children:`this page`}):null,(0,U.jsx)(`span`,{"aria-hidden":!0,title:r?.error??(a===`ok`?`Connected`:`Connecting…`),className:W(`size-1.5 shrink-0 rounded-full`,a===`ok`?`bg-success`:a===`error`?`bg-danger`:`bg-fg-4`)})]}),description:n.baseUrl,actions:n.implicit?null:(0,U.jsx)(G7,{label:`Remove ${n.name}`,onClick:()=>c(n),children:(0,U.jsx)(nC,{className:`size-3`})})},n.id)})]})}),s?(0,U.jsx)(R7,{host:s,onClose:()=>c(void 0),onRemoved:()=>{let n=s.id===t;c(void 0),n&&e({to:`/gateways`})}}):null,(0,U.jsx)(ene,{open:a,onOpenChange:o,onCreated:t=>{o(!1),e({to:`/gateways/$hostId`,params:{hostId:t.id}})}})]})}function a9({value:e,onChange:t,models:n=t7,className:r}){return(0,U.jsx)(f4,{variant:`form`,models:n,model:e||void 0,onModelChange:e=>t(e??``),className:r})}function _ne({profiles:e,value:t,onChange:n,className:r}){return e.length===0?null:(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Profile`}),(0,U.jsxs)(jC,{items:e.map(e=>({value:e.name,label:e.name})),value:t,onValueChange:e=>n(e),children:[(0,U.jsx)(PC,{className:r,children:(0,U.jsx)(MC,{})}),(0,U.jsx)(FC,{children:e.map(e=>(0,U.jsx)(IC,{value:e.name,children:(0,U.jsx)(NC,{children:(0,U.jsxs)(`span`,{className:e.available===!1?`text-fg-4`:void 0,title:e.unavailableReason,children:[e.description?`${e.name} - ${e.description}`:e.name,e.available===!1?` (unavailable)`:``]})})},e.name))})]})]})}function o9(){return Jte()}function s9(e,t,n){let r=e?.capabilities??zk[e?.engine??`claude`],i=r.permissionModes.includes(t)?t:r.defaultPermissionMode,a,o;if(e?.models?.length)a=e.models,o=e.defaultModel;else if(e?.engine===`provider`){let t=e.provider;a=(t?.models?.length?t.models:t?.model?[t.model]:[]).map(e=>({value:e,displayName:e})),o=t?.model}else a=t7.filter(e=>e.value!=="default");let s=a.find(e=>e.value===n||e.resolvedModel===n),c=s||n===``?n:``;return{capabilities:r,modes:r.permissionModes,models:[{value:`default`,displayName:`Profile default`,description:o??`the profile's configured model`},...a],mode:i,model:c,reasoningEfforts:(s?s.reasoningEfforts:void 0)??r.reasoningEfforts??[]}}var c9={profiles:[]},l9,u9,d9=new Set;async function f9(){let e=await(o9()?.listProfiles().catch(()=>c9)??Promise.resolve(c9));l9=e;for(let t of d9)t(e);return e}function p9(){let[e,t]=(0,v.useState)(l9??c9);(0,v.useEffect)(()=>(d9.add(t),l9||(u9??=f9()),()=>{d9.delete(t)}),[]);let n=(0,v.useCallback)(async()=>{u9=f9(),await u9},[]);return{...e,refresh:n}}function vne(){return p9().profiles}var m9=`workerdeck.last-profile`;function yne(){let e=vne(),[t,n]=(0,v.useState)(()=>b(m9)??``),r=e.some(e=>e.name===t)?t:e[0]?.name??``;return{profiles:e,profile:r,selected:e.find(e=>e.name===r),select:e=>{n(e),x(m9,e)}}}var h9=`workerdeck.last-cwd`;function bne(e){let[t,n]=(0,v.useState)([]);return(0,v.useEffect)(()=>{o9()?.listHostRoots().then(e=>n(e.roots.map(e=>e.path))).catch(()=>n([]))},[]),(0,v.useMemo)(()=>{let n=b(h9),r=[...n?[n]:[],...[...e].sort((e,t)=>(t.lastActivityAt??t.createdAt)-(e.lastActivityAt??e.createdAt)).map(e=>e.cwd),...t];return[...new Set(r)].slice(0,12)},[e,t])}var xne={session:`default`,job:`acceptEdits`},Sne={session:`ask`,job:`auto`};function g9(e){let[t,n]=(0,v.useState)(()=>b(h9)??``),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(void 0),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(Sne[e]),{profiles:p,profile:m,selected:h,select:g}=yne(),_=s9(h,s??h?.defaults?.permissionMode??xne[e],a);return{cwd:t,setCwd:n,prompt:r,setPrompt:i,mode:_.mode,setMode:c,model:a,setModel:o,effort:l,setEffort:u,questions:d,setQuestions:f,profiles:p,profile:m,selectProfile:g,engine:_,sessionFields:e=>({cwd:_.capabilities.hostCwd===!1?void 0:t.trim(),profile:m||void 0,prompt:e.prompt,permissionMode:_.mode,model:_.model.trim()||void 0,resume:e.resume,reasoningEffort:l&&_.reasoningEfforts.includes(l)?l:void 0,questionBehavior:_.capabilities.interactiveApprovals?d:void 0,..._.capabilities.settingSources?{settingSources:[`user`,`project`],allowDangerouslySkipPermissions:e.allowBypass||void 0}:{}}),rememberCwd:e=>x(h9,t.trim()||e)}}function _9({form:e}){return e.engine.capabilities.interactiveApprovals?(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Questions`}),(0,U.jsxs)(jC,{items:R4.map(e=>({value:e.value,label:e.label})),value:e.questions,onValueChange:t=>e.setQuestions(t),children:[(0,U.jsx)(PC,{className:`min-w-36`,children:(0,U.jsx)(MC,{})}),(0,U.jsx)(FC,{children:R4.map(e=>(0,U.jsx)(IC,{value:e.value,children:(0,U.jsx)(NC,{children:`${e.label} - ${e.description}`})},e.value))})]})]}):null}function v9({form:e,sessions:t,promptLabel:n,promptPlaceholder:r=`e.g. /verify-content 42, or a task description`,extras:i,actions:a,onProfileChange:o}){let s=bne(t),c=(0,v.useId)(),{engine:l}=e;return(0,U.jsxs)(U.Fragment,{children:[l.capabilities.hostCwd!==!1&&(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Working directory`}),(0,U.jsx)(_o,{value:e.cwd,list:c,onChange:t=>e.setCwd(t.target.value),placeholder:`/path/to/project`,spellCheck:!1,className:`font-mono`}),(0,U.jsx)(`datalist`,{id:c,children:s.map(e=>(0,U.jsx)(`option`,{value:e},e))})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:n}),(0,U.jsx)(vo,{value:e.prompt,onChange:t=>e.setPrompt(t.target.value),rows:2,placeholder:r})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(_ne,{profiles:e.profiles,value:e.profile,onChange:t=>{e.selectProfile(t),o?.(t)},className:`min-w-32`}),(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Permission mode`}),(0,U.jsx)(g4,{variant:`form`,mode:l.mode,onModeChange:e.setMode,modes:l.modes,className:`min-w-44`})]}),i,(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Model`}),(0,U.jsx)(a9,{value:l.model,onChange:e.setModel,models:l.models,className:`min-w-40`})]}),l.reasoningEfforts.length>0?(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Effort`}),(0,U.jsxs)(jC,{items:[{value:`default`,label:`Default`},...l.reasoningEfforts.map(e=>({value:e,label:e}))],value:e.effort||`default`,onValueChange:t=>e.setEffort(t==="default"?``:String(t)),children:[(0,U.jsx)(PC,{className:`min-w-28`,children:(0,U.jsx)(MC,{})}),(0,U.jsx)(FC,{children:[`default`,...l.reasoningEfforts].map(e=>(0,U.jsx)(IC,{value:e,children:(0,U.jsx)(NC,{children:e})},e))})]})]}):null,a]})]})}var Cne=15e3,y9=v7({jobs:[],stats:void 0,enabled:!0,live:!1,error:void 0}),b9=y9.patch,x9;function S9(){return x9??=(async()=>{try{let e=o9();if(!e)return;let[t,n]=await Promise.all([e.listJobs(),e.queueStats()]);b9({jobs:t,stats:n,enabled:!0,error:void 0})}catch(e){let t=e instanceof Error?e.message:String(e);/not configured/i.test(t)?b9({enabled:!1,error:void 0}):b9({error:t})}finally{x9=void 0}})(),x9}var C9=0,w9,T9;function wne(e){let t=y9.subscribe(e);return++C9===1&&(S9(),w9=setInterval(()=>void S9(),Cne)),()=>{t(),--C9===0&&(clearInterval(w9),w9=void 0,T9?.(),T9=void 0,b9({live:!1}))}}function Tne(){if(T9||!y9.get().enabled||y9.get().stats===void 0||C9===0)return;let e=o9();if(!e)return;let t=e.attachQueue(),n=[t.on(`attached`,()=>void S9()),t.on(`stats`,e=>b9({stats:e})),t.on(`connectionChange`,e=>b9({live:e})),t.on(`event`,e=>{b9({jobs:y9.get().jobs.some(t=>t.id===e.job.id)?y9.get().jobs.map(t=>t.id===e.job.id?e.job:t):[...y9.get().jobs,e.job]})})];T9=()=>{for(let e of n)e();t.detach()}}function E9(){let e=(0,v.useSyncExternalStore)(wne,y9.get,y9.get);return(0,v.useEffect)(Tne,[e.enabled,e.stats]),{...e,refresh:S9}}function Ene({stats:e}){let t=e.dailyTokenLimit!==void 0&&e.dailyTokenLimit>0?e.dailyTokensUsed/e.dailyTokenLimit*100:void 0;return(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-5 gap-y-2 rounded-md border border-border bg-surface px-3 py-2 text-body-sm text-fg-2`,children:[(0,U.jsxs)(`span`,{children:[`Running`,` `,(0,U.jsxs)(`span`,{className:`font-mono text-fg-1`,children:[e.running,`/`,e.maxConcurrency]})]}),(0,U.jsxs)(`span`,{children:[`Queued `,(0,U.jsx)(`span`,{className:`font-mono text-fg-1`,children:e.queued})]}),e.parked>0?(0,U.jsxs)(`span`,{children:[`Parked `,(0,U.jsx)(`span`,{className:`font-mono text-fg-1`,children:e.parked})]}):null,(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[t===void 0?null:(0,U.jsx)(XT,{value:t,className:t>=95?`text-danger`:t>=80?`text-warning`:`text-fg-3`}),`Daily tokens`,` `,(0,U.jsxs)(`span`,{className:`font-mono text-fg-1`,children:[fM(e.dailyTokensUsed),e.dailyTokenLimit===void 0?``:` / ${fM(e.dailyTokenLimit)}`]})]}),e.sessionTokenLimit===void 0?null:(0,U.jsxs)(`span`,{children:[`Per-job cap `,(0,U.jsx)(`span`,{className:`font-mono text-fg-1`,children:fM(e.sessionTokenLimit)})]}),e.paused?(0,U.jsx)(fo,{variant:`warning`,dot:!0,children:`Paused - daily budget exhausted`}):null]})}function Dne({onScheduled:e}){let{snapshots:t}=r9(),n=t.find(e=>e.host.id===A7()?.id)?.sessions??[],r=g9(`job`),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),{engine:m}=r,h=async()=>{if(!r.cwd.trim()||!r.prompt.trim()){DT.error(`Working directory and prompt are required`);return}let t=o.trim()?Number(o.trim()):void 0;if(t!==void 0&&(!Number.isFinite(t)||t<=0)){DT.error(`Max tokens must be a positive number`);return}let n=c.trim()?Number(c.trim()):void 0;if(n!==void 0&&(!Number.isInteger(n)||n<1)){DT.error(`Attempts must be a whole number of at least 1`);return}p(!0);try{r.rememberCwd(r.cwd.trim()),await o9().createJob({session:{...r.sessionFields({allowBypass:i}),prompt:r.prompt.trim()},maxTokens:t,attempts:n,webhook:u.trim()?{url:u.trim()}:void 0}),r.setPrompt(``),DT.success(`Job scheduled`),e()}catch(e){DT.error(e instanceof Error?e.message:`Failed to schedule job`)}finally{p(!1)}};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(v9,{form:r,sessions:n,promptLabel:`Prompt (the task - runs unattended)`,extras:(0,U.jsx)(_9,{form:r}),actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Max tokens (optional)`}),(0,U.jsx)(_o,{value:o,onChange:e=>s(e.target.value),placeholder:`per-job cap`,inputMode:`numeric`,className:`min-w-28 font-mono`})]}),(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Attempts (optional)`}),(0,U.jsx)(_o,{value:c,onChange:e=>l(e.target.value),placeholder:`1`,inputMode:`numeric`,className:`min-w-20 font-mono`})]}),(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Webhook URL (optional)`}),(0,U.jsx)(_o,{value:u,onChange:e=>d(e.target.value),placeholder:`https://…/hook`,spellCheck:!1,className:`min-w-44 font-mono`})]}),(0,U.jsxs)(lo,{className:`ml-auto`,onClick:()=>void h(),disabled:f,children:[f?(0,U.jsx)(GT,{className:`size-3.5 text-current`}):(0,U.jsx)(wx,{className:`size-4`}),`Schedule`]})]})}),m.capabilities.settingSources?(0,U.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2 text-body-sm text-fg-2`,title:`Spawns the CLI with --dangerously-skip-permissions available, so the mode can be switched on while watching the run. The job still starts in the mode selected above.`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),className:`size-3.5 accent-(--color-fg-1)`}),`Allow switching to `,(0,U.jsx)(`code`,{className:`font-mono`,children:`bypassPermissions`}),` mid-run`,(0,U.jsx)(`span`,{className:`text-label text-fg-4`,children:`(dangerous)`})]}):null,(0,U.jsxs)(`p`,{className:`text-label text-fg-4`,children:[`Unattended runs still surface permission prompts - the job's page is read-only, so answer them from the session itself, or pick a mode that doesn't ask. Unanswered prompts deny after the server's timeout. With Questions set to Ask, webhook deliveries carry the full question so a controller can answer via `,(0,U.jsx)(`code`,{className:`font-mono`,children:`POST /sessions/:id/permissions/:requestId`}),`.`]})]})}function One({open:e,onOpenChange:t,onScheduled:n}){return(0,U.jsx)(Fw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Iw,{size:`lg`,children:[(0,U.jsx)(Lw,{title:`Schedule a job`,description:`A one-shot run the queue executes unattended.`}),(0,U.jsx)(Rw,{children:e?(0,U.jsx)(Dne,{onScheduled:n}):null})]})})}function kne(){let{stats:e,enabled:t,error:n}=E9();return(0,U.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[n?(0,U.jsxs)(`div`,{className:`rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger`,children:[`Can't reach the worker server: `,n,`. Start it with `,(0,U.jsx)(`code`,{className:`font-mono`,children:`pnpm server`}),`.`]}):null,t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(JT,{icon:(0,U.jsx)(vb,{}),title:`No job selected`,description:(0,U.jsxs)(U.Fragment,{children:[`Pick one on the left, or schedule one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})}),e?(0,U.jsx)(`div`,{className:`mt-2 w-full max-w-xl`,children:(0,U.jsx)(Ene,{stats:e})}):null]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(q_,{className:`size-8 text-fg-4`}),(0,U.jsx)(`p`,{className:`text-body-sm text-fg-3`,children:`The server has no job queue configured.`}),(0,U.jsxs)(`p`,{className:`max-w-md text-label text-fg-4`,children:[`Pass `,(0,U.jsxs)(`code`,{className:`font-mono`,children:[`queue: `,`{ maxConcurrency, … }`]}),` to`,` `,(0,U.jsx)(`code`,{className:`font-mono`,children:`createWorkerServer`}),` - the dev server enables it by default.`]})]})]})}var D9={queued:{label:`Queued`,variant:`neutral`},running:{label:`Running`,variant:`info`,busy:!0},parked:{label:`Parked`,variant:`accent`},succeeded:{label:`Succeeded`,variant:`success`},failed:{label:`Failed`,variant:`danger`},canceled:{label:`Canceled`,variant:`warning`}},Ane=[`queued`,`running`,`parked`];function jne(){let e=jr(),t=bi({select:e=>e.location.pathname.match(/^\/jobs\/(.+)$/)?.[1]}),{jobs:n,enabled:r,live:i,refresh:a}=E9(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),f=c.trim().toLowerCase(),p=[...n].sort((e,t)=>t.createdAt-e.createdAt).filter(e=>(!u||Ane.includes(e.status))&&(!f||e.prompt.toLowerCase().includes(f)||e.cwd.toLowerCase().includes(f)||(e.profile?.toLowerCase().includes(f)??!1)||e.id.startsWith(f))),m=n.length-p.length,h=r?(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Schedule a job`,onClick:()=>s(!0),children:(0,U.jsx)(wx,{className:`size-4`})}):void 0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(H7,{section:`jobs`,title:`Jobs`,badge:r?(0,U.jsx)(`span`,{"aria-hidden":!0,title:i?`Streaming over the queue socket`:`Polling`,className:W(`size-1.5 shrink-0 rounded-full`,i?`bg-success`:`bg-fg-4`)}):void 0,actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh`,onClick:()=>void a(),children:(0,U.jsx)(Rx,{className:`size-3.5`})}),h]}),railActions:h,children:r?(0,U.jsxs)(U.Fragment,{children:[n.length>0?(0,U.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pb-2`,children:[(0,U.jsx)(_o,{value:c,onChange:e=>l(e.target.value),placeholder:`Search jobs`,"aria-label":`Search jobs`,className:`h-7 min-w-0 flex-1 text-body-sm`}),(0,U.jsx)(lo,{variant:u?`default`:`outline`,size:`xs`,"aria-pressed":u,onClick:()=>d(!u),children:`Active`})]}):null,(0,U.jsxs)(U7,{children:[n.length===0?(0,U.jsx)(JT,{icon:(0,U.jsx)(bb,{}),title:`No jobs yet`,description:(0,U.jsxs)(U.Fragment,{children:[`Schedule one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})}):p.length===0?(0,U.jsx)(JT,{icon:(0,U.jsx)(iS,{}),title:`No matches`,description:`No job matches the active filter.`,action:`Show all`,onAction:()=>d(!1)}):null,p.map(n=>(0,U.jsx)(Mne,{job:n,active:n.id===t,onOpen:()=>void e({to:`/jobs/$jobId`,params:{jobId:n.id}}),onChanged:()=>void a()},n.id)),m>0?(0,U.jsxs)(`p`,{className:`px-1 pt-2 text-center text-label text-fg-4`,children:[p.length,` of `,n.length]}):null]})]}):(0,U.jsx)(JT,{icon:(0,U.jsx)(bb,{}),title:`No job queue`,description:`This gateway runs without one, so there is nothing to schedule against.`})}),(0,U.jsx)(One,{open:o,onOpenChange:s,onScheduled:()=>{s(!1),a()}})]})}function Mne({job:e,active:t,onOpen:n,onChanged:r}){let i=D9[e.status],a=e.status===`queued`||e.status===`running`||e.status===`parked`,o=[hM(e.finishedAt??e.startedAt??e.createdAt),e.cwd.split(`/`).filter(Boolean).pop()??e.cwd];e.profile&&o.push(`@${e.profile}`);let s=e.usage.costUsd??e.usage.totalCostUsd;return s>0&&o.push(uM(s)),(0,U.jsx)(W7,{active:t,onSelect:n,title:e.prompt,status:(0,U.jsxs)(fo,{variant:i.variant,dot:!i.busy,className:`shrink-0`,children:[i.busy?(0,U.jsx)(GT,{className:`size-3 text-current`}):null,i.label]}),description:o.join(` · `),actions:a?(0,U.jsx)(G7,{label:`Cancel job`,onClick:()=>{o9()?.cancelJob(e.id).then(r).catch(e=>DT.error(e instanceof Error?e.message:`Cancel failed`))},children:(0,U.jsx)(DC,{className:`size-3`})}):null})}var O9=[`web_search`,`download`,`web_fetch`,`deliver_file`];function k9(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}function A9({label:e,children:t}){return(0,U.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:e}),t]})}function Nne({onCreated:e}){let[t,n]=(0,v.useState)(`provider`),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(!1),O=t===`provider`,k=t===`codex`,A=async()=>{if(!r.trim()){DT.error(`Name is required`);return}let n={name:r.trim(),engine:t};if(a.trim()&&(n.description=a.trim()),O){n.provider={id:s.trim(),model:l.trim()||void 0,models:k9(d).length>0?k9(d):void 0,apiKeyEnv:p.trim()||void 0};let e={};b.length>0&&(e.capabilities=b),k9(S).length>0&&(e.mcpServers=k9(S)),w.trim()&&(e.instructions=w.trim()),Object.keys(e).length>0&&(n.session=e)}else k?_.trim()&&(n.codexHome=_.trim()):n.configDir=h.trim();D(!0);try{await o9().createProfile(n),DT.success(`Profile '${n.name}' created`),e(n.name)}catch(e){DT.error(e instanceof Error?e.message:`Failed to create profile`)}finally{D(!1)}};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`Engine`,children:(0,U.jsxs)(jC,{items:[{value:`provider`,label:`provider`},{value:`claude`,label:`claude`},{value:`codex`,label:`codex`}],value:t,onValueChange:e=>n(e),children:[(0,U.jsx)(PC,{className:`min-w-32`,children:(0,U.jsx)(MC,{})}),(0,U.jsxs)(FC,{children:[(0,U.jsx)(IC,{value:`provider`,children:(0,U.jsx)(NC,{children:`provider - model-agnostic engine`})}),(0,U.jsx)(IC,{value:`claude`,children:(0,U.jsx)(NC,{children:`claude - Agent SDK + config dir`})}),(0,U.jsx)(IC,{value:`codex`,children:(0,U.jsx)(NC,{children:`codex - app-server + CODEX_HOME`})})]})]})}),(0,U.jsx)(A9,{label:`Name`,children:(0,U.jsx)(_o,{value:r,onChange:e=>i(e.target.value),placeholder:`kimi`})}),(0,U.jsx)(A9,{label:`Description (optional)`,children:(0,U.jsx)(_o,{value:a,onChange:e=>o(e.target.value),placeholder:`what this profile is for`})})]}),O?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`Provider id`,children:(0,U.jsx)(_o,{value:s,onChange:e=>c(e.target.value),placeholder:`anthropic / openai / moonshotai`,className:`font-mono`})}),(0,U.jsx)(A9,{label:`Default model`,children:(0,U.jsx)(_o,{value:l,onChange:e=>u(e.target.value),placeholder:`kimi-k3`,className:`font-mono`})}),(0,U.jsx)(A9,{label:`Models offered (comma-separated)`,children:(0,U.jsx)(_o,{value:d,onChange:e=>f(e.target.value),placeholder:`kimi-k3, kimi-k2`,className:`font-mono`})}),(0,U.jsx)(A9,{label:`API key variable`,children:(0,U.jsx)(_o,{value:p,onChange:e=>m(e.target.value),placeholder:`MOONSHOT_API_KEY`,className:`font-mono`})})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`Capabilities granted`,children:(0,U.jsx)(`div`,{className:`flex flex-wrap gap-3 py-1.5`,children:O9.map(e=>(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:b.includes(e),onChange:t=>x(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e)),className:`size-3.5 accent-(--color-fg-1)`}),(0,U.jsx)(`code`,{className:`font-mono text-label`,children:e})]},e))})}),(0,U.jsx)(A9,{label:`MCP servers (names, comma-separated)`,children:(0,U.jsx)(_o,{value:S,onChange:e=>C(e.target.value),placeholder:`deepwiki`,className:`font-mono`})})]}),(0,U.jsx)(A9,{label:`Instructions (optional)`,children:(0,U.jsx)(_o,{value:w,onChange:e=>T(e.target.value),placeholder:`prepended to the session's system prompt`})}),(0,U.jsx)(`p`,{className:`text-label text-fg-4`,children:`Leave capabilities and MCP servers empty to inherit whatever the server's engine factory wired - that factory is the ceiling either way, so a grant here can never exceed it. MCP servers are named, never configured: their transport config (and any credentials in it) stays on the server.`})]}):k?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(A9,{label:`Home directory (optional)`,children:(0,U.jsx)(_o,{value:_,onChange:e=>y(e.target.value),placeholder:`/Users/you/.codex`,spellCheck:!1,className:`font-mono`})}),(0,U.jsxs)(`p`,{className:`text-label text-fg-4`,children:[`This profile's `,(0,U.jsx)(`code`,{className:`font-mono`,children:`CODEX_HOME`}),`. Must resolve inside the server's`,` `,(0,U.jsx)(`code`,{className:`font-mono`,children:`allowedConfigDirRoots`}),` - a home directory is a credential store, so the server bounds which ones a managed profile may point at. Leave it empty to run on the server's own environment.`]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(A9,{label:`Config directory`,children:(0,U.jsx)(_o,{value:h,onChange:e=>g(e.target.value),placeholder:`/Users/you/.claude`,spellCheck:!1,className:`font-mono`})}),(0,U.jsxs)(`p`,{className:`text-label text-fg-4`,children:[`Must resolve inside the server's `,(0,U.jsx)(`code`,{className:`font-mono`,children:`allowedConfigDirRoots`}),` - a config directory is a credential store, so the server bounds which ones a managed profile may point at.`]})]}),(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsxs)(lo,{onClick:()=>void A(),disabled:E,children:[E?(0,U.jsx)(GT,{className:`size-3.5 text-current`}):(0,U.jsx)(wx,{className:`size-4`}),`Create profile`]})})]})}function Pne({open:e,onOpenChange:t,onCreated:n}){return(0,U.jsx)(Fw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Iw,{size:`lg`,children:[(0,U.jsx)(Lw,{title:`New profile`,description:`What a session runs as - a Claude config directory, or a model provider.`}),(0,U.jsx)(Rw,{children:e?(0,U.jsx)(Nne,{onCreated:n}):null})]})})}function Fne(){let e=jr(),t=bi({select:e=>e.location.pathname.match(/^\/profiles\/(.+)$/)?.[1]}),{profiles:n,canManage:r,refresh:i}=p9(),[a,o]=(0,v.useState)(!1),s=r?(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`New profile`,onClick:()=>o(!0),children:(0,U.jsx)(wx,{className:`size-4`})}):void 0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(H7,{section:`profiles`,title:`Profiles`,badge:n.length>0?(0,U.jsx)(`span`,{className:`shrink-0 text-label text-fg-4`,children:n.length}):void 0,actions:s,railActions:s,children:(0,U.jsxs)(U7,{children:[n.length===0?(0,U.jsx)(JT,{icon:(0,U.jsx)(Xy,{}),title:r?`No profiles yet`:`No profiles`,description:r?(0,U.jsxs)(U.Fragment,{children:[`Add one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]}):`This gateway declares none, and this login may not add them.`}):null,n.map(n=>(0,U.jsx)(W7,{active:n.name===t,onSelect:()=>void e({to:`/profiles/$profileName`,params:{profileName:n.name}}),title:n.name,status:n.managed?null:(0,U.jsx)(fo,{variant:`neutral`,className:`shrink-0`,children:`declared`}),description:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(A5,{engine:n.engine??`claude`,model:n.defaults?.model??n.provider?.model,className:`size-3 shrink-0 text-fg-3`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:n.configDir??(n.provider?`${n.provider.id}${n.provider.model?` · ${n.provider.model}`:``}`:n.engine??`claude`)})]})},n.name))]})}),(0,U.jsx)(Pne,{open:a,onOpenChange:o,onCreated:t=>{o(!1),i(),e({to:`/profiles/$profileName`,params:{profileName:t}})}})]})}function Ine({sessions:e,onCreated:t}){let n=g9(`session`),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(),[s,c]=(0,v.useState)(!1),{engine:l}=n,u=async e=>{let r=e?.cwd??n.cwd.trim();if(!r){DT.error(`Working directory is required`);return}i(!0);try{n.rememberCwd(r),t((await o9().createSession({...n.sessionFields({prompt:e?void 0:n.prompt.trim()||void 0,resume:e?.sessionId,allowBypass:!0}),cwd:r})).id)}catch(e){DT.error(e instanceof Error?e.message:`Failed to create session`)}finally{i(!1)}},d=async()=>{if(!n.cwd.trim()){DT.error(`Set a working directory first - resumable sessions are listed per project`);return}c(!0);try{o(await o9().listSdkSessions({dir:n.cwd.trim(),limit:20,profile:n.profile||void 0}))}catch(e){DT.error(e instanceof Error?e.message:`Failed to list resumable sessions`)}finally{c(!1)}};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(v9,{form:n,sessions:e,promptLabel:`Initial prompt (optional)`,onProfileChange:()=>o(void 0),extras:(0,U.jsx)(_9,{form:n}),actions:(0,U.jsxs)(lo,{className:`ml-auto`,onClick:()=>void u(),disabled:r,children:[r?(0,U.jsx)(GT,{className:`size-3.5 text-current`}):(0,U.jsx)(wx,{className:`size-4`}),`Create`]})}),l.capabilities.listSessions?(0,U.jsxs)(`div`,{className:`mt-1 border-t border-border pt-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Resume a previous session`}),(0,U.jsxs)(lo,{variant:`ghost`,size:`xs`,onClick:()=>void d(),disabled:s,children:[s?(0,U.jsx)(GT,{className:`size-3 text-current`}):(0,U.jsx)(Hx,{className:`size-3`}),a?`Reload`:`Browse`]})]}),a===void 0?null:a.length===0?(0,U.jsx)(`div`,{className:`py-3 text-center text-body-sm text-fg-4`,children:`No stored sessions for this directory.`}):(0,U.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:a.map(e=>(0,U.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-body-sm text-fg-1`,children:e.customTitle??e.summary}),(0,U.jsxs)(`div`,{className:`flex gap-2 font-mono text-label text-fg-4`,children:[e.gitBranch?(0,U.jsx)(`span`,{className:`truncate`,children:e.gitBranch}):null,(0,U.jsx)(`span`,{className:`shrink-0`,children:hM(e.lastModified)})]})]}),(0,U.jsx)(lo,{variant:`outline`,size:`xs`,onClick:()=>void u(e),disabled:r,children:`Resume`})]},e.sessionId))})]}):null]})}function Lne({open:e,onOpenChange:t,sessions:n,onCreated:r}){return(0,U.jsx)(Fw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Iw,{size:`lg`,children:[(0,U.jsx)(Lw,{title:`New session`,description:`Pick a directory and an engine.`}),(0,U.jsx)(Rw,{children:(0,U.jsx)(Ine,{sessions:n,onCreated:r})})]})})}function Rne(){return(0,U.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,U.jsx)(JT,{icon:(0,U.jsx)(_7,{}),title:`No session open`,description:(0,U.jsxs)(U.Fragment,{children:[`Pick one on the left, or start a new one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})})})}var j9=`workerdeck.view-config`;function zne(){let[e,t]=(0,v.useState)(()=>({...kO,...S(j9,{}),search:``,scoped:!1}));return[e,(0,v.useCallback)(e=>{t(e),C(j9,e)},[])]}function Bne(){let e=jr(),t=bi({select:e=>e.location.pathname.match(/^\/sessions\/[^/]+\/(.+)$/)?.[1]??void 0}),n=Ar({strict:!1}).subagent,r=Ar({strict:!1}).shell,{snapshots:i,refresh:a}=r9(),o=i9(i),s=Sj(o,k7),c=i.filter(e=>e.error!==void 0),l=A7(),u=i.find(e=>e.host.id===l?.id)?.sessions??[],d=t=>{l&&e({to:`/sessions/$hostId/$sessionId`,params:{hostId:l.id,sessionId:t},search:{}})},[f,p]=zne(),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(ane),y=(0,v.useMemo)(()=>WO(o,f),[o,f]),b=t=>void e({to:`/sessions/$hostId/$sessionId`,params:{hostId:t.hostId,sessionId:t.info.id},search:{}}),x=(0,v.useRef)(0),S=(t,n)=>void e({to:`/sessions/$hostId/$sessionId`,params:{hostId:t.hostId,sessionId:t.info.id},search:{subagent:n,sn:++x.current}}),C=(0,v.useRef)(0),w=(t,n)=>void e({to:`/sessions/$hostId/$sessionId`,params:{hostId:t.hostId,sessionId:t.info.id},search:{shell:n,shn:++C.current}}),T=(e,t)=>{k7(e.hostId)?.killShell(e.info.id,t).then(()=>a()).catch(e=>DT.error(e instanceof Error?e.message:`Kill failed`))},E=(e,t)=>{k7(e.hostId)?.updateSession(e.info.id,{title:t||null}).then(()=>a()).catch(e=>DT.error(e instanceof Error?e.message:`Rename failed`))},D=(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`New session`,onClick:()=>h(!0),children:(0,U.jsx)(wx,{className:`size-4`})});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(H7,{section:`sessions`,title:`Sessions`,railActions:D,actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($5,{value:f.subagents,onChange:e=>p({...f,subagents:e})}),(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":g?`Hide filters`:`Show filters`,"aria-pressed":g,onClick:()=>{_(!g),one(!g)},children:(0,U.jsx)(wy,{className:W(`size-3.5`,g&&`fill-current text-fg-1`)})}),(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh`,onClick:()=>void a(),children:(0,U.jsx)(Rx,{className:`size-3.5`})}),D]}),rail:y.map(e=>(0,U.jsxs)(`button`,{type:`button`,title:`${MO(e.info)} - ${e.state}`,"aria-label":MO(e.info),onClick:()=>b(e),className:W(`flex w-full flex-col items-center gap-0.5 border-l-2 py-1.5`,e.info.id===t?`border-l-accent bg-row-active`:`border-l-transparent hover:bg-row-hover`),children:[(0,U.jsx)(A5,{engine:e.adapter,model:e.info.model,className:`size-4`}),(0,U.jsx)(j5,{row:e})]},e.info.id)),children:[c.map(({host:e,error:t})=>(0,U.jsxs)(`div`,{className:`mx-2 mb-2 rounded-md bg-danger-bg px-2 py-1.5 text-label text-danger`,children:[`Can’t reach `,e.name,`: `,t]},e.id)),(0,U.jsx)(U7,{children:(0,U.jsx)(H5,{rows:o,config:f,onConfigChange:p,showControls:g,projectIcons:s,activeId:t,activeSubagentId:n,activeShellId:r,onSelect:b,onSelectSubagent:S,onSelectShell:w,onKillShell:T,onRename:E,onClearContext:e=>{let t=k7(e.hostId);if(!t)return;let n=t.attach(e.info.id,{reconnect:!1}),r=setTimeout(()=>{n.detach(),DT.error(`Clear failed - the gateway did not answer`)},5e3);n.on(`attached`,()=>{n.clearContext(),setTimeout(()=>{clearTimeout(r),n.detach(),DT.success(`Context cleared - the previous conversation stays resumable`),a()},150)})},onDelete:e=>{k7(e.hostId)?.deleteSession(e.info.id).then(()=>a()).catch(e=>DT.error(e instanceof Error?e.message:`Delete failed`))},emptyState:(0,U.jsx)(JT,{icon:(0,U.jsx)(cb,{}),title:`No sessions yet`,description:(0,U.jsxs)(U.Fragment,{children:[`Start one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})})})})]}),(0,U.jsx)(Lne,{open:m,onOpenChange:h,sessions:u,onCreated:e=>{h(!1),d(e),a()}})]})}function Vne(){let{snapshots:e}=r9(),t=lne(i9(e));(0,v.useEffect)(()=>{document.title=t>0?`(${t}) workerdeck`:`workerdeck`},[t])}var M9=[{id:`sessions`,label:`Sessions`,icon:IS,path:`/sessions`,sidebar:Bne},{id:`gateways`,label:`Gateways`,icon:Sx,path:`/gateways`,sidebar:gne},{id:`jobs`,label:`Jobs`,icon:vb,path:`/jobs`,sidebar:jne},{id:`profiles`,label:`Profiles`,icon:mC,path:`/profiles`,sidebar:Fne}],N9=`workerdeck.sidebar-collapsed`;function Hne({children:e}){Vne();let t=bi({select:e=>e.location.pathname}),n=[...M9].sort((e,t)=>t.path.length-e.path.length).find(e=>t.startsWith(e.path)),r=n?.sidebar,[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(()=>b(N9)===`1`),c=()=>{s(e=>(x(N9,e?`0`:`1`),!e))},l=`flex size-7 items-center justify-center rounded-md text-fg-3 transition-colors outline-none hover:bg-row-hover hover:text-fg-1`,u=e=>W(`flex items-center rounded-md text-body-sm transition-colors outline-none`,o?`justify-center p-2`:`gap-2 px-2 py-1.5`,e?`bg-surface font-medium text-fg-1 shadow-(--shadow-xs)`:`text-fg-3 hover:bg-row-hover hover:text-fg-1`);return(0,U.jsxs)(`div`,{className:`flex h-dvh bg-sidebar`,children:[(0,U.jsxs)(`aside`,{className:W(`flex shrink-0 flex-col gap-1 p-3 transition-[width] duration-150`,o?`w-14 items-center`:`w-52`),children:[(0,U.jsxs)(`div`,{className:W(`flex items-center py-2`,o?`justify-center`:`gap-2 px-2`),children:[(0,U.jsx)(_7,{className:`size-4 shrink-0 text-fg-1`}),!o&&(0,U.jsx)(`span`,{className:`text-body-sm font-semibold tracking-tight text-fg-1`,children:`workerdeck`})]}),(0,U.jsx)(`nav`,{className:W(`mt-1 flex flex-1 flex-col gap-0.5`,o&&`items-center`),children:M9.map(e=>(0,U.jsxs)(Jr,{to:e.path,title:o?e.label:void 0,"aria-label":e.label,onClick:t=>{e.id===n?.id&&t.preventDefault()},className:u(e.id===n?.id),children:[(0,U.jsx)(e.icon,{className:`size-4 shrink-0`}),!o&&e.label]},e.id))}),(0,U.jsxs)(`div`,{className:W(`mt-1 grid place-items-center gap-1`,o?`grid-rows-3`:`grid-cols-3`),children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>a(!0),title:`Settings`,"aria-label":`Settings`,className:l,children:(0,U.jsx)(uS,{className:`size-4`})}),(0,U.jsx)(e7,{}),(0,U.jsx)(`button`,{type:`button`,onClick:c,title:o?`Expand sidebar`:`Collapse sidebar`,"aria-label":o?`Expand sidebar`:`Collapse sidebar`,className:l,children:o?(0,U.jsx)(ox,{className:`size-4`}):(0,U.jsx)(ix,{className:`size-4`})})]})]}),(0,U.jsxs)(`div`,{className:`app-frame frame-shine m-2 ml-0 flex min-w-0 flex-1 overflow-hidden rounded-xl`,children:[r?(0,U.jsx)(r,{},n?.id):null,(0,U.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:e??(0,U.jsx)(ui,{})})]}),(0,U.jsx)(Kte,{open:i,onOpenChange:a})]})}function P9({crumbs:e,actions:t,children:n}){return(0,U.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border bg-surface px-3`,children:[(0,U.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`flex min-w-0 items-center gap-1`,children:e.map((e,t)=>(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[t>0?(0,U.jsx)(lv,{"aria-hidden":!0,className:`size-3 shrink-0 text-fg-4`}):null,e.to?(0,U.jsx)(Jr,{to:e.to,className:`shrink-0 text-body-sm text-fg-3 outline-none hover:text-fg-1`,children:e.label}):(0,U.jsx)(`span`,{"aria-current":`page`,className:`min-w-0 truncate text-body-sm font-medium text-fg-1`,title:e.label,children:e.label})]},e.label))}),n,(0,U.jsx)(`span`,{className:`flex-1`}),t]})}function F9({children:e}){return(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-5 px-6 py-6`,children:e})})}function I9({label:e,children:t}){return(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-1.5`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-label font-medium text-fg-3`,children:e}),(0,U.jsx)(`span`,{className:`min-w-0 text-right text-body-sm text-fg-1`,children:t})]})}function Une(){let{hostId:e}=kr({from:`/gateways/$hostId`}),t=jr(),{hosts:n,ready:r}=F7(),{snapshots:i}=r9(),[a,o]=(0,v.useState)(!1),s=n.find(t=>t.id===e),c=i.find(t=>t.host.id===e);if((0,v.useEffect)(()=>{r&&!s&&t({to:`/gateways`})},[r,s,t]),!s)return null;let l=c===void 0?`pending`:c.error?`error`:`ok`;return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(P9,{crumbs:[{label:`Gateways`,to:`/gateways`},{label:s.name}],actions:s.implicit?null:(0,U.jsxs)(lo,{variant:`outline`,size:`xs`,onClick:()=>o(!0),children:[(0,U.jsx)(nC,{className:`size-3`}),`Remove`]}),children:(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-label text-fg-4`,title:s.baseUrl,children:s.baseUrl})}),(0,U.jsxs)(F9,{children:[(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Connection`})}),(0,U.jsxs)(go,{className:`flex flex-col divide-y divide-border`,children:[(0,U.jsx)(I9,{label:`Status`,children:l===`ok`?(0,U.jsx)(fo,{variant:`success`,dot:!0,children:`Connected`}):l===`error`?(0,U.jsx)(fo,{variant:`danger`,dot:!0,children:`Unreachable`}):(0,U.jsx)(fo,{variant:`neutral`,dot:!0,children:`Connecting…`})}),c?.error?(0,U.jsx)(I9,{label:`Last error`,children:(0,U.jsx)(`span`,{className:`text-danger`,children:c.error})}):null,(0,U.jsx)(I9,{label:`Live sessions`,children:c?c.sessions.length:(0,U.jsx)(`span`,{className:`text-fg-4`,children:`-`})}),(0,U.jsx)(I9,{label:`Reachability`,children:j7(s)?`This machine (loopback)`:`Remote`}),(0,U.jsx)(I9,{label:`Credential`,children:s.implicit?(0,U.jsx)(`span`,{className:`text-fg-4`,children:`the login cookie it set - same origin`}):(0,U.jsx)(`span`,{className:`text-fg-4`,children:`an auth key held in this browser`})})]})]}),s.implicit?(0,U.jsx)(`p`,{className:`text-label text-fg-4`,children:`This is the gateway that served the page. Its address is this origin and its credential is the cookie it already set, so there is nothing here to change - and nothing to remove, since removing it would just be closing the tab.`}):(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Settings`})}),(0,U.jsx)(go,{children:(0,U.jsx)(I7,{host:s,onSaved:e=>DT.success(`Saved ${e.name}`)},s.id)})]}),a?(0,U.jsx)(R7,{host:s,onClose:()=>o(!1),onRemoved:()=>{o(!1),t({to:`/gateways`})}}):null]})]})}function Wne(){return(0,U.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,U.jsx)(JT,{icon:(0,U.jsx)(Sx,{}),title:`No gateway selected`,description:(0,U.jsxs)(U.Fragment,{children:[`Pick one on the left, or add one with `,(0,U.jsx)(YT,{children:`+`}),` above.`]})})})}function Gne({files:e,activePath:t,onActivate:n,onClose:r,className:i}){return(0,U.jsx)(cT,{delay:500,closeDelay:0,children:(0,U.jsx)(`div`,{"data-slot":`editor-tabs`,role:`tablist`,"aria-label":`Open files`,className:W(`flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-surface`,i),children:e.map(i=>(0,U.jsx)(Kne,{file:i,active:i.path===t,onActivate:()=>n(i.path),onClose:()=>r(i.path),onArrow:t=>{let r=e[e.findIndex(e=>e.path===i.path)+t];r&&n(r.path)}},i.path))})})}function Kne({file:e,active:t,onActivate:n,onClose:r,onArrow:i}){let a=Ej(e),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{t&&o.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t]),(0,U.jsxs)(uT,{side:`bottom`,render:(0,U.jsx)(`div`,{ref:o,role:`tab`,tabIndex:t?0:-1,"aria-selected":t,onClick:n,onAuxClick:e=>{e.button===1&&(e.preventDefault(),r())},onKeyDown:e=>{if(e.key===`ArrowRight`)i(1);else if(e.key===`ArrowLeft`)i(-1);else if(e.key===`Enter`||e.key===` `)n();else return;e.preventDefault()},className:W(`group flex min-w-0 shrink-0 cursor-pointer items-center gap-1.5 border-r border-border px-3 py-1.5 transition-colors`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent focus-visible:ring-inset`,t?`bg-bg text-fg-1`:`text-fg-3 hover:bg-surface-hover hover:text-fg-2`)}),content:(0,U.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsx)(`span`,{className:`font-mono break-all`,children:e.path}),e.bytes===void 0?null:(0,U.jsx)(`span`,{className:`text-fg-4`,children:pM(e.bytes)})]}),children:[(0,U.jsx)(`span`,{className:W(`max-w-40 truncate font-mono text-label`,a&&`italic`),children:e.name}),e.status===`error`?(0,U.jsx)(`span`,{className:`shrink-0 text-danger`,children:`!`}):null,(0,U.jsxs)(`button`,{type:`button`,"aria-label":a?`Close ${e.name} (unsaved changes)`:`Close ${e.name}`,onClick:e=>{e.stopPropagation(),r()},className:W(`shrink-0 rounded p-0.5 text-fg-4 transition-opacity hover:bg-surface-hover hover:text-fg-1`,t||a?`opacity-70`:`opacity-0 group-hover:opacity-70 focus-visible:opacity-100`),children:[(0,U.jsx)(`span`,{className:W(`block`,a&&`group-hover:hidden`),children:a?(0,U.jsx)(`span`,{className:`block size-3 rounded-full bg-fg-2`}):(0,U.jsx)(DC,{className:`size-3`})}),a?(0,U.jsx)(`span`,{className:`hidden group-hover:block`,children:(0,U.jsx)(DC,{className:`size-3`})}):null]})]})}var L9=12;function qne({tree:e,search:t,activePath:n,onOpenFile:r,onCollapse:i,style:a,className:o}){let[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(),d=s.trim().length>0;return(0,v.useEffect)(()=>{if(!t?.available)return;let e=s.trim();if(!e){u(void 0);return}let n=new AbortController,r=setTimeout(()=>{t.search(e,{limit:60,signal:n.signal}).then(e=>{n.signal.aborted||u(e)})},150);return()=>{n.abort(),clearTimeout(r)}},[t,s]),(0,U.jsxs)(`div`,{"data-slot":`file-tree`,style:a,className:W(`flex min-h-0 min-w-0 flex-col bg-surface`,o),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-2`,children:[t?.available?(0,U.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,U.jsx)(oS,{className:`absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-fg-4`}),(0,U.jsx)(_o,{value:s,onChange:e=>c(e.target.value),placeholder:`Search files…`,className:`h-7 pr-7 pl-7 text-label`,spellCheck:!1}),d?(0,U.jsx)(`button`,{type:`button`,onClick:()=>c(``),"aria-label":`Clear search`,className:`absolute top-1/2 right-1.5 -translate-y-1/2 text-fg-4 transition-colors hover:text-fg-2`,children:(0,U.jsx)(DC,{className:`size-3.5`})}):null]}):(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate px-1 text-label text-fg-4`,children:e.root}),(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh the file tree`,onClick:()=>e.refresh(),children:(0,U.jsx)(Rx,{className:`size-3.5 text-fg-3`})}),i?(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Hide project files`,onClick:i,children:(0,U.jsx)(ix,{className:`size-3.5 text-fg-3`})}):null]}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-1 py-1`,children:e.error?(0,U.jsx)(`p`,{className:`px-2 py-3 text-body-sm text-danger`,children:e.error}):d?l===void 0?(0,U.jsx)(`div`,{className:`py-6 text-center`,children:(0,U.jsx)(GT,{className:`size-4 text-fg-4`})}):l.length===0?(0,U.jsx)(`p`,{className:`px-2 py-6 text-center text-body-sm text-fg-4`,children:`No matching files.`}):(0,U.jsx)(`ul`,{children:l.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsx)(R9,{label:Jne(e.relative),detail:Yne(e.relative),title:e.relative,icon:(0,U.jsx)(ly,{className:`size-3.5 shrink-0 text-fg-4`}),active:e.path===n,onClick:()=>r(e.path)})},e.path))}):e.loading?(0,U.jsx)(`div`,{className:`py-6 text-center`,children:(0,U.jsx)(GT,{className:`size-4 text-fg-4`})}):e.rows.length===0?(0,U.jsx)(`p`,{className:`px-2 py-6 text-center text-body-sm text-fg-4`,children:`This project is empty.`}):(0,U.jsx)(`ul`,{role:`tree`,"aria-label":`Project files`,children:e.rows.map(t=>(0,U.jsxs)(`li`,{role:`treeitem`,"aria-expanded":t.expanded,"aria-level":t.depth+1,children:[(0,U.jsx)(R9,{label:t.entry.name,indent:t.depth,active:t.entry.path===n,icon:t.entry.type===`dir`?t.loading?(0,U.jsx)(GT,{className:`size-3.5 shrink-0 text-fg-4`}):t.expanded?(0,U.jsx)(gy,{className:`size-3.5 shrink-0 text-accent`}):(0,U.jsx)(Sy,{className:`size-3.5 shrink-0 text-accent`}):(0,U.jsx)(Y2,{type:t.entry.type}),chevron:t.entry.type===`dir`?(0,U.jsx)(lv,{className:W(`size-3 shrink-0 text-fg-4 transition-transform`,t.expanded&&`rotate-90`)}):void 0,onClick:()=>t.entry.type===`dir`?e.toggle(t.entry.path):r(t.entry.path)}),t.truncated?(0,U.jsx)(`p`,{className:`truncate py-0.5 text-label text-fg-4`,style:{paddingLeft:(t.depth+1)*L9+22},children:`More entries than the server will return - use search.`}):null]},t.entry.path))})})]})}function R9({label:e,detail:t,title:n,icon:r,chevron:i,indent:a=0,active:o,onClick:s}){let c=(0,v.useRef)(null);return(0,v.useEffect)(()=>{o&&c.current?.scrollIntoView({block:`nearest`})},[o]),(0,U.jsxs)(`button`,{ref:c,type:`button`,onClick:s,title:n??e,style:{paddingLeft:a*L9+4},className:W(`flex w-full items-center gap-1 rounded py-1 pr-2 text-left transition-colors`,o?`bg-surface-hover text-fg-1`:`text-fg-2 hover:bg-surface-hover`),children:[(0,U.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center`,children:i}),r,(0,U.jsx)(`span`,{className:`shrink-0 truncate text-label`,children:e}),t?(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label text-fg-4`,children:t}):null]})}function Jne(e){return e.slice(e.lastIndexOf(`/`)+1)}function Yne(e){let t=e.lastIndexOf(`/`);return t===-1?void 0:e.slice(0,t)}function Xne({path:e,value:t,onChange:n,onSave:r,readOnly:i,className:a}){let o=(0,v.useRef)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(null),[l,u]=(0,v.useState)(!1),d=Zne(),f=(0,v.useRef)({onChange:n,onSave:r});return f.current={onChange:n,onSave:r},(0,v.useEffect)(()=>{let n=!1;return Qne().then(r=>{if(n||!o.current)return;c.current=r;let a=r.editor.create(o.current,{value:t,language:V9(e),readOnly:i,automaticLayout:!0,theme:z9(document.documentElement.getAttribute(`data-theme`)),minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,lineHeight:20,fontFamily:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace`,renderLineHighlight:`line`,smoothScrolling:!0,padding:{top:8,bottom:8},scrollbar:{verticalScrollbarSize:10,horizontalScrollbarSize:10},wordBasedSuggestions:`off`,quickSuggestions:!1});s.current=a,a.onDidChangeModelContent(()=>{f.current.onChange?.(a.getValue())}),a.addCommand(r.KeyMod.CtrlCmd|r.KeyCode.KeyS,()=>{f.current.onSave?.()}),u(!0)}),()=>{n=!0,s.current?.dispose(),s.current=null,u(!1)}},[]),(0,v.useEffect)(()=>{let n=c.current,r=s.current;if(!n||!r||!l)return;let i=n.Uri.parse(`workerdeck://host${e}`),a=n.editor.getModel(i)??n.editor.createModel(t,V9(e),i);r.getModel()!==a&&r.setModel(a)},[e,l,t]),(0,v.useEffect)(()=>{let e=s.current;if(!e||!l)return;let n=e.getModel();n&&n.getValue()!==t&&n.pushEditOperations([],[{range:n.getFullModelRange(),text:t}],()=>null)},[t,l]),(0,v.useEffect)(()=>{l&&s.current?.updateOptions({readOnly:i})},[i,l]),(0,v.useEffect)(()=>{l&&c.current?.editor.setTheme(z9(d))},[d,l]),(0,U.jsxs)(`div`,{className:W(`relative min-h-0 min-w-0 flex-1`,a),children:[(0,U.jsx)(`div`,{ref:o,className:`absolute inset-0`}),l?null:(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bg`,children:(0,U.jsx)(GT,{className:`size-4 text-fg-4`})})]})}function Zne(){let[e,t]=(0,v.useState)(()=>typeof document>`u`?null:document.documentElement.getAttribute(`data-theme`));return(0,v.useEffect)(()=>{let e=document.documentElement,n=()=>t(e.getAttribute(`data-theme`));n();let r=new MutationObserver(n);return r.observe(e,{attributes:!0,attributeFilter:[`data-theme`]}),()=>r.disconnect()},[]),e}function z9(e){return e===`light`?`wd-light`:`wd-dark`}var B9;function Qne(){return B9??=(async()=>{let e=await Ij(()=>import(`./vs-DeKW9hVr.js`).then(e=>e.t),__vite__mapDeps([0,1]));return e.editor.defineTheme(`wd-dark`,{base:`vs-dark`,inherit:!0,rules:[],colors:{"editor.background":`#00000000`}}),e.editor.defineTheme(`wd-light`,{base:`vs`,inherit:!0,rules:[],colors:{"editor.background":`#00000000`}}),e})(),B9}function V9(e){let t=e.slice(e.lastIndexOf(`/`)+1);return $ne[t.toLowerCase()]||(ere[t.slice(t.lastIndexOf(`.`)+1).toLowerCase()]??`plaintext`)}var $ne={dockerfile:`dockerfile`,makefile:`plaintext`,".gitignore":`plaintext`,".env":`shell`},ere={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,md:`markdown`,mdx:`markdown`,css:`css`,scss:`scss`,less:`less`,html:`html`,htm:`html`,xml:`xml`,svg:`xml`,yml:`yaml`,yaml:`yaml`,toml:`plaintext`,sh:`shell`,bash:`shell`,zsh:`shell`,fish:`shell`,py:`python`,rb:`ruby`,rs:`rust`,go:`go`,swift:`swift`,java:`java`,kt:`kotlin`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,hpp:`cpp`,cs:`csharp`,php:`php`,sql:`sql`,graphql:`graphql`,gql:`graphql`,lua:`lua`,r:`r`,pl:`perl`,dart:`dart`,scala:`scala`,ini:`ini`,cfg:`ini`,conf:`ini`,txt:`plaintext`,log:`plaintext`};function tre({file:e,canWrite:t,onChange:n,onSave:r,onRevert:i,onReload:a,onOverwrite:o,onDismissConflict:s,className:c}){return e?(0,U.jsxs)(`div`,{"data-slot":`file-viewer`,className:W(`flex min-h-0 min-w-0 flex-1 flex-col bg-bg`,c),children:[e.conflict?(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-warning/40 bg-warning-bg px-3 py-2`,children:[(0,U.jsx)(oC,{className:`size-3.5 shrink-0 text-warning`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-warning`,children:`This file changed on disk since you opened it.`}),(0,U.jsx)(lo,{variant:`outline`,size:`xs`,onClick:()=>a?.(e.path),children:`Use the version on disk`}),(0,U.jsx)(lo,{variant:`outline`,size:`xs`,onClick:()=>o?.(e.path),children:`Keep mine`}),(0,U.jsx)(lo,{variant:`ghost`,size:`xs`,onClick:()=>s?.(e.path),children:`Dismiss`})]}):e.saveError?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-danger/40 bg-danger-bg px-3 py-2`,children:[(0,U.jsx)(oC,{className:`size-3.5 shrink-0 text-danger`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-danger`,children:e.saveError}),(0,U.jsx)(lo,{variant:`ghost`,size:`xs`,onClick:()=>s?.(e.path),children:`Dismiss`})]}):null,e.status===`loading`?(0,U.jsx)(H9,{children:(0,U.jsx)(GT,{className:`size-4 text-fg-4`})}):e.status===`error`?(0,U.jsxs)(H9,{children:[(0,U.jsx)(oC,{className:`size-4 text-danger`}),(0,U.jsx)(`p`,{className:`text-body-sm text-danger`,children:e.error})]}):e.status===`binary`?(0,U.jsxs)(H9,{children:[(0,U.jsx)(oee,{className:`size-4 text-fg-4`}),(0,U.jsx)(`p`,{className:`text-body-sm text-fg-4`,children:`This file isn’t text.`}),(0,U.jsx)(`p`,{className:`text-label text-fg-4`,children:`It can’t be edited here without corrupting it.`})]}):(0,U.jsx)(Xne,{path:e.path,value:Dj(e),readOnly:!t,onChange:n?t=>n(e.path,t):void 0,onSave:r?()=>r(e.path):void 0}),e.status===`ready`&&(e.saving||Ej(e)||!t)?(0,U.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-border px-3 py-1`,children:e.saving?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(GT,{className:`size-3 text-fg-4`}),(0,U.jsx)(`span`,{className:`text-label text-fg-4`,children:`Saving…`})]}):t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-label text-fg-3`,children:`Unsaved changes`}),(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(lo,{variant:`ghost`,size:`xs`,onClick:()=>i?.(e.path),children:`Revert`}),(0,U.jsxs)(lo,{variant:`outline`,size:`xs`,onClick:()=>r?.(e.path),children:[`Save`,(0,U.jsx)(`span`,{className:`ml-1 text-fg-4`,children:`⌘S`})]})]}):(0,U.jsx)(`span`,{className:`text-label text-fg-4`,children:`Read-only - this gateway doesn’t allow writes.`})}):null]}):null}function H9({children:e}){return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-6`,children:e})}var nre=180,rre=520,ire=220,U9=120;function W9({client:e,sessionId:t,header:n,transcriptVariant:r,transcriptDensity:i,transcriptFont:a,scrubber:o,bookmarks:s,onToggleBookmark:c,stickyPrompt:l,openSubagent:u,reveal:d,subagents:f,onSubagentChange:p,openShell:m,shells:h,onShellChange:g,statusPlacement:_,controlsSurface:y,fontSize:b,onLinkClick:x,onOpenFile:S,unseen:C,readOnly:w,onVitals:T,defaultRailWidth:E=260,defaultRailCollapsed:D,onRailChange:O,className:k}){let{info:A}=Tj(e,t),j=A?.cwd,M=hj(e,j),N=pj(e,j),P=Mj(e),{canWrite:F}=mj(e);(0,v.useEffect)(()=>{if(!P.hasUnsaved)return;let e=e=>e.preventDefault();return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[P.hasUnsaved]);let I=ore(),[L,R]=(0,v.useState)(D??!1),[z,ee]=(0,v.useState)(E),B=(0,v.useRef)(O);B.current=O,(0,v.useEffect)(()=>{B.current?.({width:z,collapsed:L})},[z,L]);let[V,te]=(0,v.useState)(360),ne=P.files.length>0,H=!I,re=M.available&&!L;(0,v.useEffect)(()=>{H&&R(!0)},[H]);let ie=(0,v.useCallback)(e=>{let t=P.files.find(t=>t.path===e);if(t&&Ej(t)){let e=t.name;if(!window.confirm(`${e} has unsaved changes. Close it and lose them?`))return}P.close(e)},[P]),ae=(0,v.useRef)(null),oe=are(ae);y5({container:ae,onOpen:(0,v.useCallback)(({path:e})=>P.open(b5(e,j)),[P.open,j]),enabled:M.available,ignore:`.monaco-editor, .xterm`});let se=Math.max(U9,oe-ire),[ce,le]=(0,v.useState)(null),ue=n===void 0||ce===null?void 0:typeof n==`function`?e=>(0,Ed.createPortal)(n(e),ce):(0,Ed.createPortal)(n,ce);return(0,U.jsxs)(`div`,{"data-slot":`session-workspace`,className:W(`flex h-full min-h-0 w-full flex-col overflow-hidden bg-bg`,k),children:[n===void 0?null:(0,U.jsx)(`div`,{ref:le,className:`shrink-0`}),(0,U.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[re?(0,U.jsx)(qne,{tree:M,search:N,activePath:P.activePath,onOpenFile:P.open,onCollapse:()=>R(!0),style:{width:H?Math.min(z,320):z},className:W(`shrink-0 border-r border-border`,H&&`absolute inset-y-0 left-0 z-20 shadow-lg`)}):M.available?(0,U.jsx)(`div`,{className:`flex w-8 shrink-0 flex-col items-center border-r border-border bg-surface pt-1.5`,children:(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Show project files`,onClick:()=>R(!1),children:(0,U.jsx)(ox,{className:`size-4 text-fg-3`})})}):null,re&&!H?(0,U.jsx)(qT,{orientation:`vertical`,value:z,onValueChange:ee,min:nre,max:rre,defaultValue:E,"aria-label":`Resize the file tree`}):null,(0,U.jsxs)(`div`,{ref:ae,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[ne?(0,U.jsxs)(`div`,{className:`flex min-h-0 shrink-0 flex-col overflow-hidden`,style:{height:Math.min(V,se||V)},children:[(0,U.jsx)(Gne,{files:P.files,activePath:P.activePath,onActivate:P.activate,onClose:ie}),(0,U.jsx)(tre,{file:P.active,canWrite:F,onChange:P.edit,onSave:e=>void P.save(e),onRevert:P.revert,onReload:P.reload,onOverwrite:e=>void P.overwrite(e),onDismissConflict:P.dismissConflict})]}):null,ne?(0,U.jsx)(qT,{orientation:`horizontal`,value:Math.min(V,se||V),onValueChange:te,min:U9,max:se,"aria-label":`Resize the open file`}):null,(0,U.jsx)(a5,{client:e,sessionId:t,header:ue,transcriptVariant:r,transcriptDensity:i,transcriptFont:a,scrubber:o,bookmarks:s,onToggleBookmark:c,stickyPrompt:l,openSubagent:u,reveal:d,subagents:f,onSubagentChange:p,openShell:m,shells:h,onShellChange:g,controlsSurface:y,fontSize:b,onLinkClick:x,onOpenFile:S??P.open,statusPlacement:_,unseen:C,readOnly:w,onVitals:T,className:`min-h-0 flex-1`})]}),H&&re?(0,U.jsx)(`button`,{type:`button`,"aria-label":`Close the file tree`,onClick:()=>R(!0),className:`absolute inset-0 z-10 bg-black/30`}):null]})]})}function are(e){let[t,n]=(0,v.useState)(0);return(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(([e])=>{e&&n(e.contentRect.height)});return r.observe(t),()=>r.disconnect()},[e]),t}function ore(){let[e,t]=(0,v.useState)(!0);return(0,v.useEffect)(()=>{let e=window.matchMedia(`(min-width: 768px)`),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var G9=`workerdeck.rail`,sre={width:260,collapsed:!1};function K9(){let e=S(G9,{});return{width:Math.min(520,Math.max(180,Number(e.width)||sre.width)),collapsed:e.collapsed===!0}}function q9(e){C(G9,e)}function cre(){let{jobId:e}=kr({from:`/jobs/$jobId`}),t=jr(),{jobs:n,refresh:r}=E9(),{snapshots:i}=r9(),a=n.find(t=>t.id===e),o=o9(),s=A7()?.id,c=a?.sessionId!==void 0&&(i.find(e=>e.host.id===s)?.sessions.some(e=>e.id===a.sessionId)??!1),[l,u]=(0,v.useState)(!1);(0,v.useEffect)(()=>{n.length>0&&u(!0)},[n.length]),(0,v.useEffect)(()=>{l&&!a&&(DT.error(`That job is no longer in the queue`),t({to:`/jobs`}))},[l,a,t]);let[d]=(0,v.useState)(r7),[f]=(0,v.useState)(o7),[p]=(0,v.useState)(l7),[m]=(0,v.useState)(f7),[h]=(0,v.useState)(K9);if(!a)return null;let g=(0,U.jsx)(J9,{job:a,onChanged:()=>void r()});return!o||!c||!a.sessionId?(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[g,(0,U.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center`,children:[(0,U.jsx)(`p`,{className:`text-body-sm text-fg-3`,children:a.sessionId?`This job’s session is no longer on the gateway.`:`This job never got as far as a session.`}),(0,U.jsx)(`p`,{className:`max-w-md text-label text-fg-4`,children:`The queue keeps the job record - status, usage, error - but the transcript lives with the session, and that one has been closed or swept.`})]})]}):(0,U.jsx)(W9,{client:o,sessionId:a.sessionId,readOnly:!0,transcriptVariant:f,transcriptDensity:d,transcriptFont:p,fontSize:m,scrubber:!0,stickyPrompt:!0,statusPlacement:`bottom`,defaultRailWidth:h.width,defaultRailCollapsed:h.collapsed,onRailChange:q9,header:({actions:e})=>(0,U.jsx)(J9,{job:a,onChanged:()=>void r(),actions:e})},a.sessionId)}function J9({job:e,onChanged:t,actions:n}){let r=D9[e.status],i=e.status===`queued`||e.status===`running`||e.status===`parked`,a=async()=>{try{await o9().cancelJob(e.id),t()}catch(e){DT.error(e instanceof Error?e.message:`Cancel failed`)}};return(0,U.jsxs)(P9,{crumbs:[{label:`Jobs`,to:`/jobs`},{label:e.prompt}],actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(fo,{variant:`neutral`,className:`shrink-0`,children:`read-only`}),(0,U.jsx)(WT,{value:e.id,"aria-label":`Copy job id`}),i?(0,U.jsxs)(lo,{variant:`outline`,size:`xs`,onClick:()=>void a(),children:[(0,U.jsx)(DC,{className:`size-3`}),`Cancel`]}):null,n]}),children:[(0,U.jsxs)(fo,{variant:r.variant,dot:!r.busy,className:`shrink-0`,children:[r.busy?(0,U.jsx)(GT,{className:`size-3 text-current`}):null,r.label]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-x-3 font-mono text-label text-fg-4`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:e.cwd}),e.profile?(0,U.jsxs)(`span`,{className:`shrink-0`,children:[`@`,e.profile]}):null,(0,U.jsx)(`span`,{className:`shrink-0`,children:hM(e.finishedAt??e.startedAt??e.createdAt)}),e.maxAttempts!==void 0&&e.maxAttempts>1?(0,U.jsxs)(`span`,{className:`shrink-0`,children:[`attempt `,e.attempt??1,`/`,e.maxAttempts,e.status===`queued`&&e.nextRunAt!==void 0&&e.nextRunAt>Date.now()?` - retry pending`:``]}):null,e.usage.tokens>0?(0,U.jsxs)(`span`,{className:`shrink-0`,children:[fM(e.usage.tokens),` tok`]}):null,(e.usage.costUsd??e.usage.totalCostUsd)>0?(0,U.jsx)(`span`,{className:`shrink-0`,children:uM(e.usage.costUsd??e.usage.totalCostUsd)}):null,e.error?(0,U.jsx)(`span`,{className:`truncate text-danger`,children:e.error}):null]})]})}function lre({profile:e,onSaved:t}){let n=e.engine===`provider`,[r,i]=(0,v.useState)(e.description??``),[a,o]=(0,v.useState)(e.defaults?.model??``),[s,c]=(0,v.useState)(e.defaults?.permissionMode),[l,u]=(0,v.useState)(e.provider?.model??``),[d,f]=(0,v.useState)((e.provider?.models??[]).join(`, `)),[p,m]=(0,v.useState)(e.session?.capabilities),[h,g]=(0,v.useState)((e.session?.mcpServers??[]).join(`, `)),[_,y]=(0,v.useState)(e.session?.instructions??``),[b,x]=(0,v.useState)(!1),S=s9(e,s??`default`,a),C=S.models.map(t=>t.value==="default"?{...t,displayName:`Unset`,description:e.defaultModel??`whatever the engine's own config picks`}:t),w=async()=>{let i={description:r.trim()||void 0,defaults:{model:a.trim()||void 0,permissionMode:s}};n&&(i.provider={...e.provider,id:e.provider?.id??``,model:l.trim()||void 0,models:k9(d).length>0?k9(d):void 0},i.session={capabilities:p,mcpServers:k9(h).length>0?k9(h):void 0,instructions:_.trim()||void 0}),x(!0);try{t(await o9().updateProfile(e.name,i)),DT.success(`Profile saved`)}catch(e){DT.error(e instanceof Error?e.message:`Failed to save profile`)}finally{x(!1)}};return(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Edit profile`})}),(0,U.jsxs)(go,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(A9,{label:`Description`,children:(0,U.jsx)(_o,{value:r,onChange:e=>i(e.target.value)})}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`Default model`,children:C.length>1?(0,U.jsx)(a9,{value:a,onChange:o,models:C}):(0,U.jsx)(_o,{value:a,onChange:e=>o(e.target.value),placeholder:`unset - request / engine default`,className:`font-mono`})}),(0,U.jsx)(A9,{label:`Default permission mode`,children:(0,U.jsx)(g4,{variant:`form`,mode:s,onModeChange:c,modes:S.modes})})]}),n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`Default model id`,children:(0,U.jsx)(_o,{value:l,onChange:e=>u(e.target.value),className:`font-mono`})}),(0,U.jsx)(A9,{label:`Models offered (comma-separated)`,children:(0,U.jsx)(_o,{value:d,onChange:e=>f(e.target.value),className:`font-mono`})})]}),(0,U.jsx)(A9,{label:`Capabilities granted`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 py-1.5`,children:[(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:p===void 0,onChange:e=>m(e.target.checked?void 0:[]),className:`size-3.5 accent-(--color-fg-1)`}),`not declared`]}),O9.map(e=>(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,disabled:p===void 0,checked:p?.includes(e)??!1,onChange:t=>m(n=>t.target.checked?[...n??[],e]:(n??[]).filter(t=>t!==e)),className:`size-3.5 accent-(--color-fg-1) disabled:opacity-40`}),(0,U.jsx)(`code`,{className:`font-mono text-label`,children:e})]},e))]})}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,U.jsx)(A9,{label:`MCP servers (names, comma-separated)`,children:(0,U.jsx)(_o,{value:h,onChange:e=>g(e.target.value),className:`font-mono`})}),(0,U.jsx)(A9,{label:`Instructions`,children:(0,U.jsx)(_o,{value:_,onChange:e=>y(e.target.value)})})]})]}):null,(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-label text-fg-4`,children:`Name and engine are fixed - sessions and jobs are pinned to the name, and the engine decides what the rest of these fields mean.`}),(0,U.jsxs)(lo,{onClick:()=>void w(),disabled:b,children:[b?(0,U.jsx)(GT,{className:`size-3.5 text-current`}):(0,U.jsx)(Qx,{className:`size-4`}),`Save`]})]})]})]})}function ure(e){window.location.href=`vscode://file${e}`}function dre(){return(0,U.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,U.jsx)(JT,{icon:(0,U.jsx)(mC,{}),title:`No profile selected`,description:`A profile is what a session runs as - its config directory and credentials, or a model provider.`})})}function Y9({items:e,empty:t}){return e.length===0?(0,U.jsx)(`span`,{className:`text-fg-4`,children:t}):(0,U.jsx)(`span`,{className:`flex flex-wrap justify-end gap-1`,children:e.map(e=>(0,U.jsx)(fo,{variant:`neutral`,children:e},e))})}function fre(){let{profileName:e}=kr({from:`/profiles/$profileName`}),t=jr(),{refresh:n}=p9(),[r,i]=(0,v.useState)(),[a,o]=(0,v.useState)();(0,v.useEffect)(()=>{let t=!0,n=()=>{o9()?.getProfile(e).then(e=>{t&&i(e)}).catch(e=>{t&&o(e instanceof Error?e.message:`Failed to load profile`)})};n();let r=setInterval(n,6e4);return()=>{t=!1,clearInterval(r)}},[e]);let s=r?.profile,c=r?.config,l=(0,v.useMemo)(()=>Ak(s?.usage),[s?.usage]),u=async()=>{try{await o9().deleteProfile(e),await n(),DT.success(`Profile '${e}' deleted`),t({to:`/profiles`})}catch(e){DT.error(e instanceof Error?e.message:`Delete failed`)}};return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(P9,{crumbs:[{label:`Profiles`,to:`/profiles`},{label:e}],actions:(0,U.jsxs)(U.Fragment,{children:[s?.configDir?(0,U.jsxs)(lo,{variant:`outline`,size:`xs`,onClick:()=>ure(s.configDir),children:[(0,U.jsx)(jv,{className:`size-3`}),`Open in VSCode`]}):null,s?.managed?(0,U.jsxs)(lo,{variant:`outline`,size:`xs`,onClick:()=>void u(),children:[(0,U.jsx)(nC,{className:`size-3`}),`Delete`]}):null]}),children:s?.description?(0,U.jsx)(`span`,{className:`min-w-0 truncate text-label text-fg-4`,children:s.description}):null}),(0,U.jsxs)(F9,{children:[a?(0,U.jsx)(`div`,{className:`rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger`,children:a}):null,!r&&!a?(0,U.jsx)(GT,{className:`mx-auto size-5 text-fg-4`}):null,s&&c?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Worker defaults`})}),(0,U.jsxs)(go,{className:`flex flex-col divide-y divide-border`,children:[(0,U.jsx)(I9,{label:`Engine`,children:(0,U.jsx)(fo,{variant:`neutral`,children:s.engine??`claude`})}),s.engine===`provider`?(0,U.jsx)(I9,{label:`Provider`,children:(0,U.jsx)(`span`,{className:`font-mono text-label`,children:s.provider?.id})}):(0,U.jsx)(I9,{label:`Config directory`,children:(0,U.jsx)(`span`,{className:`font-mono text-label`,children:s.configDir})}),(0,U.jsx)(I9,{label:`Default model`,children:s.defaults?.model??s.provider?.model??(0,U.jsx)(`span`,{className:`text-fg-4`,children:`request / engine default`})}),(0,U.jsx)(I9,{label:`Default permission mode`,children:s.defaults?.permissionMode??(0,U.jsx)(`span`,{className:`text-fg-4`,children:`request / engine default`})}),s.engine===`provider`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(I9,{label:`Models offered`,children:(0,U.jsx)(Y9,{items:s.provider?.models??[],empty:`the default model only`})}),(0,U.jsx)(I9,{label:`API key variable`,children:s.provider?.apiKeyEnv?(0,U.jsx)(`span`,{className:`font-mono text-label`,children:s.provider.apiKeyEnv}):(0,U.jsx)(`span`,{className:`text-fg-4`,children:`provider SDK default`})})]}):null]})]}),l.length>0?(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Plan usage`})}),(0,U.jsx)(go,{children:(0,U.jsx)(Y8,{windows:l})})]}):null,s.engine===`provider`?(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Session grants`})}),(0,U.jsxs)(go,{className:`flex flex-col divide-y divide-border`,children:[(0,U.jsx)(I9,{label:`Capabilities`,children:(0,U.jsx)(Y9,{items:s.session?.capabilities??[],empty:`not declared - whatever the server wired`})}),(0,U.jsx)(I9,{label:`MCP servers`,children:(0,U.jsx)(Y9,{items:s.session?.mcpServers??[],empty:`not declared - every connected server`})}),(0,U.jsx)(I9,{label:`Instructions`,children:s.session?.instructions?`${s.session.instructions.length} characters`:(0,U.jsx)(`span`,{className:`text-fg-4`,children:`none`})})]})]}):null,s.engine===`provider`?null:(0,U.jsxs)(po,{children:[(0,U.jsx)(mo,{children:(0,U.jsx)(ho,{children:`Claude Code configuration`})}),(0,U.jsxs)(go,{className:`flex flex-col divide-y divide-border`,children:[c.settings?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(I9,{label:`Model (settings.json)`,children:c.settings.model??(0,U.jsx)(`span`,{className:`text-fg-4`,children:`not set`})}),(0,U.jsx)(I9,{label:`Default permission mode`,children:c.settings.defaultPermissionMode??(0,U.jsx)(`span`,{className:`text-fg-4`,children:`not set`})}),(0,U.jsx)(I9,{label:`Permission rules`,children:(0,U.jsx)(`span`,{className:`font-mono text-label`,children:c.settings.permissionRules?`${c.settings.permissionRules.allow} allow · ${c.settings.permissionRules.ask} ask · ${c.settings.permissionRules.deny} deny`:`-`})}),(0,U.jsx)(I9,{label:`Env vars (names only)`,children:(0,U.jsx)(Y9,{items:c.settings.envKeys??[],empty:`none`})}),(0,U.jsx)(I9,{label:`Hooks`,children:(0,U.jsx)(Y9,{items:c.settings.hooks??[],empty:`none`})})]}):(0,U.jsx)(I9,{label:`settings.json`,children:(0,U.jsx)(`span`,{className:`text-fg-4`,children:`not found`})}),(0,U.jsx)(I9,{label:`User memory (CLAUDE.md)`,children:c.hasUserMemory?`present`:(0,U.jsx)(`span`,{className:`text-fg-4`,children:`none`})}),(0,U.jsx)(I9,{label:`Skills`,children:(0,U.jsx)(Y9,{items:c.skills,empty:`none`})}),(0,U.jsx)(I9,{label:`Agents`,children:(0,U.jsx)(Y9,{items:c.agents,empty:`none`})}),(0,U.jsx)(I9,{label:`Commands`,children:(0,U.jsx)(Y9,{items:c.commands,empty:`none`})})]})]}),s.managed?(0,U.jsx)(lre,{profile:s,onSaved:e=>i({...r,profile:e})}):null,(0,U.jsxs)(`p`,{className:`text-label text-fg-4`,children:[s.managed?`Stored on the server and editable here. `:`View only - this profile is declared in the server options. `,`Other profile configuration lives on the server (the `,(0,U.jsx)(`code`,{className:`font-mono`,children:`profiles`}),` option; for Claude profiles, the config directory itself, e.g. via VSCode). Provider credentials are resolved from the server's environment and never leave it.`]})]}):null]})]})}var X9=`workerdeck.bookmarks.v1`;function Z9(e,t){return`${e}:${t}`}function pre(e,t){let[n,r]=(0,v.useState)(()=>S(X9,{}));return{bookmarks:(0,v.useMemo)(()=>n[Z9(e,t)]??[],[n,e,t]),toggle:(0,v.useCallback)(n=>{r(r=>{let i=Z9(e,t),a=r[i]??[],o=a.includes(n)?a.filter(e=>e!==n):[...a,n],s={...r,[i]:o};return o.length===0&&delete s[i],C(X9,s),s})},[e,t])}}function mre(){let{hostId:e,sessionId:t}=kr({from:`/sessions/$hostId/$sessionId`}),{ready:n}=F7(),r=jr(),i=k7(e);return(0,v.useEffect)(()=>{n&&!i&&(DT.error(`That gateway is not configured here`),r({to:`/sessions`}))},[n,i,r]),i?(0,U.jsx)(hre,{hostId:e,sessionId:t,client:i},`${e}:${t}`):null}function hre({hostId:e,sessionId:t,client:n}){let r=jr(),{subagent:i,sn:a,reveal:o,rn:s,shell:c,shn:l}=Ar({from:`/sessions/$hostId/$sessionId`}),{info:u,error:d}=Tj(n,t),f=cne(e,t),{bookmarks:p,toggle:m}=pre(e,t),[h]=(0,v.useState)(()=>m7()===`on`?sne(e,t):void 0),[g]=(0,v.useState)(r7),[_]=(0,v.useState)(o7),[y]=(0,v.useState)(l7),[b]=(0,v.useState)(f7),[x]=(0,v.useState)(K9);(0,v.useEffect)(()=>{d&&(DT.error(`Session not found`),r({to:`/sessions`}))},[d,r]);let[S,C]=(0,v.useState)(()=>!document.hidden);(0,v.useEffect)(()=>{let e=()=>C(!document.hidden);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let{snapshots:w}=r9(),T=(0,v.useMemo)(()=>w.find(t=>t.host.id===e)?.sessions.find(e=>e.id===t),[w,e,t]);(0,v.useEffect)(()=>{T&&S&&f({activity:T.activityCount,prose:T.proseCount,turns:T.numTurns})},[T?.activityCount,T?.proseCount,T?.numTurns,S,f]);let E=async()=>{try{await n.deleteSession(t)}catch{}r({to:`/sessions`})},D=u?.cwd?.split(`/`).filter(Boolean).pop();return(0,U.jsx)(W9,{client:n,sessionId:t,transcriptVariant:_,transcriptDensity:g,transcriptFont:y,fontSize:b,openSubagent:i?{toolUseId:i,nonce:a??0}:void 0,reveal:o?{toolUseId:o,nonce:s??0}:void 0,subagents:T?.subagents,onSubagentChange:n=>{n!==i&&r({to:`/sessions/$hostId/$sessionId`,params:{hostId:e,sessionId:t},search:n===void 0?{}:e=>({subagent:n,sn:e.sn}),replace:!0})},openShell:c?{shellId:c,nonce:l??0}:void 0,shells:T?.shells,onShellChange:n=>{n!==c&&r({to:`/sessions/$hostId/$sessionId`,params:{hostId:e,sessionId:t},search:e=>({subagent:e.subagent,sn:e.sn,shell:n,shn:e.shn}),replace:!0})},scrubber:!0,bookmarks:p,onToggleBookmark:m,stickyPrompt:!0,statusPlacement:`bottom`,controlsSurface:`status`,defaultRailWidth:x.width,defaultRailCollapsed:x.collapsed,onRailChange:q9,unseen:h,onVitals:e=>{f({itemCount:e.itemCount}),mne()},header:({actions:e})=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border bg-surface px-3 py-2`,children:[(0,U.jsx)(`span`,{className:`truncate text-body-sm font-medium text-fg-1`,children:u?.title??D??t.slice(0,8)}),u?.engine&&u.engine!==`claude`?(0,U.jsx)(fo,{variant:`neutral`,className:`shrink-0`,children:u.engine}):null,u?.cwd?(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-label text-fg-4`,title:u.cwd,children:u.cwd}):null,(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(WT,{value:t,"aria-label":`Copy session id`}),(0,U.jsxs)(qC,{children:[(0,U.jsx)(JC,{render:(0,U.jsx)(lo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close session`,children:(0,U.jsx)(nC,{className:`size-4 text-fg-3`})})}),(0,U.jsxs)(XC,{children:[(0,U.jsx)(ZC,{children:`Close this session?`}),(0,U.jsx)(QC,{children:`The run is terminated on the server. You can pick it up later from “Resume a previous session” - the transcript is kept by the engine, not by the gateway.`}),(0,U.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,U.jsx)(YC,{render:(0,U.jsx)(lo,{variant:`outline`,children:`Cancel`})}),(0,U.jsx)(lo,{variant:`destructive`,onClick:()=>void E(),children:`Close session`})]})]})]}),e]})},t)}var Q9=$r({component:Hne}),gre=Zr({getParentRoute:()=>Q9,path:`/`,beforeLoad:()=>{throw Ve({to:`/sessions`})}}),_re=Zr({getParentRoute:()=>Q9,path:`/sessions`,component:Rne}),vre=Zr({getParentRoute:()=>Q9,path:`/sessions/$hostId/$sessionId`,component:mre,validateSearch:e=>({subagent:typeof e.subagent==`string`?e.subagent:void 0,sn:typeof e.sn==`number`?e.sn:void 0,reveal:typeof e.reveal==`string`?e.reveal:void 0,rn:typeof e.rn==`number`?e.rn:void 0,shell:typeof e.shell==`string`?e.shell:void 0,shn:typeof e.shn==`number`?e.shn:void 0})}),yre=Zr({getParentRoute:()=>Q9,path:`/sessions/$sessionId`,beforeLoad:({params:e})=>{throw Ve({to:`/sessions/$hostId/$sessionId`,params:{hostId:x7,sessionId:e.sessionId},search:{}})}}),bre=Zr({getParentRoute:()=>Q9,path:`/gateways`,component:Wne}),xre=Zr({getParentRoute:()=>Q9,path:`/gateways/$hostId`,component:Une}),Sre=Zr({getParentRoute:()=>Q9,path:`/jobs`,component:kne}),Cre=Zr({getParentRoute:()=>Q9,path:`/jobs/$jobId`,component:cre}),wre=Zr({getParentRoute:()=>Q9,path:`/profiles`,component:dre}),Tre=Zr({getParentRoute:()=>Q9,path:`/profiles/$profileName`,component:fre}),Ere=Zr({getParentRoute:()=>Q9,path:`/settings`,beforeLoad:()=>{throw Ve({to:`/sessions`})}}),Dre=gi({routeTree:Q9.addChildren([gre,_re,vre,yre,bre,xre,Sre,Cre,wre,Tre,Ere]),history:wt()});function Ore(){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yi,{router:Dre}),(0,U.jsx)(VT,{})]})}E();var $9=document.getElementById(`root`);if(!$9)throw Error(`Root element #root not found`);(0,y.createRoot)($9).render((0,U.jsx)(v.StrictMode,{children:(0,U.jsx)(Ore,{})}));export{Ij as a,s as c,eQ as i,l,L1 as n,Hn as o,V1 as r,d as s,kQ as t};
|