@workerdeck/web 3.1.0 → 3.2.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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vs-B6pYAMqR.js","assets/vs-DWxI6Y27.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vs-OdJ6Y9dc.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`),te=Symbol.for(`react.activity`),ne=Symbol.for(`react.legacy_hidden`),re=Symbol.for(`react.memo_cache_sentinel`),ie=Symbol.for(`react.view_transition`),B=Symbol.for(`react.recoverable`),ae=Symbol.iterator;function oe(e){return typeof e!=`object`||!e?null:(e=ae&&e[ae]||e[`@@iterator`],typeof e==`function`?e:null)}var V=Symbol.for(`react.client.reference`);function se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===V?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 te:return`Activity`;case ie: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?se(e.type)||`Memo`:t;case ee:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var ce=Array.isArray,le=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de={pending:!1,data:null,method:null,action:null},fe=[],pe=-1;function me(e){return{current:e}}function he(e){0>pe||(e.current=fe[pe],fe[pe]=null,pe--)}function ge(e,t){pe++,fe[pe]=e.current,e.current=t}var _e=me(null),ve=me(null),ye=me(null),be=me(null);function xe(e,t){switch(ge(ye,t),ge(ve,e),ge(_e,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}}he(_e),ge(_e,e)}function Se(){he(_e),he(ve),he(ye)}function Ce(e){var t=e.memoizedState;t!==null&&(gh._currentValue=t.memoizedState,ge(be,e)),t=_e.current;var n=bp(t,e.type);t!==n&&(ge(ve,e),ge(_e,n))}function we(e){ve.current===e&&(he(_e),he(ve)),be.current===e&&(he(be),gh._currentValue=de)}var Te,Ee;function De(e){if(Te===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Te=t&&t[1]||``,Ee=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+Te+e+Ee}var Oe=!1;function ke(e,t){if(!e||Oe)return``;Oe=!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),hD(o);let C=n(),w=FE(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=_D();if(!t)return;let n=t.cloneContents(),r=DD(n);e.clipboardData.setData(`text/plain`,r);let i=OD(n);if(i.some(e=>e.type===`chip`)){let t=oD(i);t&&e.clipboardData.setData(`text/prompt-area-segments`,t)}},[]),C=(0,v.useCallback)(e=>{S(e);let i=_D();if(!i)return;let o=n();y(o),i.deleteContents();let s=t.current;s&&hD(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 ZD({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=fD(e,t);if(r===-1)return!1;let i=pD(e,r),a=n[i],s=NE(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=fD(e,t);if(r===-1)return!1;let i=pD(e,r),a=n[i],s=PE(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+=CE(t).length}return d+=s.revertedText.length,o(s.segments),u(s.segments),bD(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=_D();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&&nD(e))return aD(e)?O(t,e):D(t,e)}if(r.nodeType===Node.TEXT_NODE&&i===0){let e=mD(t,r);if(!e)return!1;let n=e.previousSibling;for(;n&&n.nodeType===Node.TEXT_NODE&&n.textContent===``;)n=n.previousSibling;if(n&&nD(n))return aD(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=_D();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&&nD(e))return D(t,e)}if(r.nodeType===Node.TEXT_NODE&&i===(r.textContent??``).length){let e=mD(t,r);if(!e)return!1;let n=e.nextSibling;for(;n&&n.nodeType===Node.TEXT_NODE&&n.textContent===``;)n=n.nextSibling;if(n&&nD(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=jE(n,t,a);o(c.segments),u(c.segments),s?.({type:`chip`,trigger:t.config.char,...a});let d=e.current;d&&bD(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=XE(r);r=e.segments,i=YE(i,e.edits)}w.current=r,o(r),u(r),bD(e,i)},v=e=>{if(!n)return!1;let t=l(),r=vD(e);if(r===null||!UE(wE(t),r))return!1;let i=Pee(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=SD(t);if(!n||n.start===n.end)return;let r=s.key===`b`?`**`:`*`,i=l();S(i);let a=RE(i,n.start,n.end,r);if(!a)return;w.current=a.segments,o(a.segments),u(a.segments),CD(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=vD(r);if(e!==null){let t=l(),r=wE(t),i=Math.min(e,r.length);if(kE(r,i,n.position)){s.preventDefault(),n.onActivate({text:r,cursorPosition:i,insertChip:p(LE(t,i,i,n.char),{config:n,startOffset:i,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=wE(e),r=vD(t);if(r!==null&&UE(n,r)){s.preventDefault();let n=s.shiftKey?Lee(e,r):Iee(e,r);n&&c(t,n);return}}}let D=e=>{let t=SD(e);if(!t)return;let n=l();S(n);let r=LE(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=SD(t);if(e&&e.start!==e.end){s.preventDefault();let n=l();S(n),c(t,{segments:LE(n,e.start,e.end,``),cursorOffset:e.start}),d();return}}}if(s.key===`Backspace`){let t=e.current;if(t){let e=l(),r=vD(t);if(n&&r!==null){let n=Ree(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 QD({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(Vee(s)){if(r.metaKey||r.ctrlKey){r.preventDefault(),c?.(s.href),window.open(s.href,`_blank`,`noopener,noreferrer`);return}break}if(nD(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=dD(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=fD(o,s);h.current={chip:p,segIndex:pD(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(nD(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||oD(f.data)!==oD(e.data))&&(s?.(f),o?.(e)),bD(d,wE(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 $D(){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 eO=300,tO=[];function nO({value:e,onChange:t,triggers:n=tO,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}=$D(),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(nD(a)){let e=dD(a);e&&(t.push(e),n=!0)}else if(rD(a)){if(a.dataset.sentinel){r=!0;continue}t.push({type:`text`,text:`
43
43
  `})}else if(tD(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=vD(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=oD(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=U(`prompt-area-chip`,a===`inline`&&`prompt-area-chip--inline`,i?.chipClassName),e.textContent=CE(r),e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`-1`),t.appendChild(e)}if(t.lastChild&&rD(t.lastChild)){let e=document.createElement(`br`);e.dataset.sentinel=`true`,t.appendChild(e)}gD(t,h),r!==null&&bD(t,r),N.current=e,M.current=!1},[n,h]),R=QD({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=jE(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&&bD(a,i.cursorOffset)},[t,L,s]),ee=(0,v.useCallback)(()=>{let e=b.current;if(!e)return;let t=I(),r=wE(t),i=vD(e);if(i===null)return;let a=AE(r,i,n);if(R.clear(),a){S(a),w(0);let n=Zee(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]),te=(0,v.useCallback)(()=>{R.clear(),S(null),w(0),j()},[j,R]),ne=XD({editorRef:b,readSegmentsFromDOM:I,onChange:t,renderSegmentsToDOM:L,runTriggerDetection:ee,dismissTrigger:te,triggers:n,markdownEnabled:h,normalizeBullets:g,onPaste:u,onRawPaste:d,onUndo:f,onRedo:p,onChipAdd:s,onImagePaste:m});(0,v.useLayoutEffect)(()=>{if(!M.current&&!zE(e,N.current)){if(h&&g){let n=KE(e,!0);if(n!==e){t(n);return}}if(BE(I(),e)){N.current=e;return}L(e)}},[e,I,L,h,g,t]);let re=(0,v.useRef)(h);(0,v.useLayoutEffect)(()=>{if(re.current===h)return;re.current=h;let n=g?KE(e,h):e;n===e?L(e):t(n)},[h,g,L,e,t]),(0,v.useEffect)(()=>()=>{P.current&&clearTimeout(P.current)},[]);let ie=(0,v.useCallback)(()=>{if(M.current)return;if(ne.isComposing.current){let e=I();N.current=e,t(e);return}let e=b.current,n=e?vD(e):null;e&&hD(e);let r=I();if(y!=null&&e&&wE(r).length>y){let n=vD(e),i=EE(r,y);N.current=i,t(i),L(i),bD(e,n==null?y:Math.min(n,y)),ee();return}if(h&&g&&e&&n!==null){let i=Nee(r,n);if(i){N.current=i.segments,t(i.segments),L(i.segments),bD(e,i.cursorOffset),ee();return}}let i=r,a=null;if(h&&n!==null&&qE(wE(r))){let e=XE(r);e.edits.length>0&&(i=e.segments,a=YE(n,e.edits))}F.current||=N.current,N.current=i,t(i),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{F.current&&=(ne.pushUndo(F.current),null),P.current=null},eO),e&&(a===null?(gD(e,h),n!==null&&bD(e,n)):(L(i),bD(e,a))),ee()},[t,I,ee,L,h,g,y,ne]),B=(0,v.useCallback)(e=>{if(!x)return;let n=I(),r=x.config.insertAsText?.(e);if(r!==void 0){let e=ME(n,x,r);ne.pushUndo(n),t(e.segments),L(e.segments);let i=b.current;i&&bD(i,e.cursorOffset),te(),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,ne.pushUndo)){te(),setTimeout(()=>{b.current?.focus()},0);return}let c=jE(n,x,o,a?.trailingText);t(c.segments),L(c.segments),s?.({type:`chip`,trigger:x.config.char,...o});let l=b.current;l&&bD(l,c.cursorOffset),te(),setTimeout(()=>{b.current?.focus()},0)},[x,I,t,L,te,s,ne,R]),ae=B,oe=ZD({editorRef:b,triggers:n,markdownEnabled:h,submitOnEnter:_,onSubmit:i,onEscape:a,onChange:t,onChipAdd:s,onChipDelete:c,readSegmentsFromDOM:I,renderSegmentsToDOM:L,runTriggerDetection:ee,dismissTrigger:te,buildInsertChip:z,selectSuggestionInternal:B,activeTrigger:x,suggestions:D,suggestionsLoading:O,suggestionsError:k,selectedSuggestionIndex:C,setSelectedSuggestionIndex:w,pushUndo:ne.pushUndo,handleKeyDownForUndoRedo:ne.handleKeyDownForUndoRedo,lastRenderedValue:N,undoTimer:P,undoBaseState:F}),V=(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:()=>wE(I()),clear:()=>{t([]);let e=b.current;if(e)for(;e.firstChild;)e.removeChild(e.firstChild);ne.resetUndoHistory(),P.current&&=(clearTimeout(P.current),null),F.current=null},setText:e=>{ne.pushUndo(I());let n=TE(e);t(n),L(n);let r=b.current;r&&bD(r,e.length)},appendText:e=>{let n=I();ne.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&&bD(a,wE(i).length)},getCursorPosition:()=>{let e=b.current;return e?vD(e):null},setCursorPosition:e=>{let t=b.current;t&&bD(t,e)},setCursorToEnd:()=>{let e=b.current;e&&bD(e,wE(I()).length)},getSelection:()=>{let e=b.current;return e?SD(e):null},setSelection:(e,t)=>{let n=b.current;n&&CD(n,e,t)}}),[I,t,L,s,ne]),se=(0,v.useMemo)(()=>({onPaste:ne.handlePaste,onCopy:ne.handleCopy,onCut:ne.handleCut,onDrop:ne.handleDrop,onDragOver:ne.handleDragOver,onCompositionStart:ne.handleCompositionStart,onCompositionEnd:ne.handleCompositionEnd,onBlur:ne.handleBlur}),[ne.handlePaste,ne.handleCopy,ne.handleCut,ne.handleDrop,ne.handleDragOver,ne.handleCompositionStart,ne.handleCompositionEnd,ne.handleBlur]);return{editorRef:b,activeTrigger:x,suggestions:D,suggestionsLoading:O,suggestionsError:k,selectedSuggestionIndex:C,handleInput:ie,handleKeyDown:oe,handleClick:R.handleClick,handleMouseDown:R.handleMouseDown,selectSuggestion:ae,dismissTrigger:te,handle:V,triggerRect:T,eventHandlers:se}}var rO=240;function iO({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<rO&&s.top>p,h={position:`fixed`,left:`${Math.max(8,f)}px`,zIndex:50,maxWidth:`${d}px`,maxHeight:`${rO}px`,...m?{bottom:`${window.innerHeight-s.top+4}px`}:{top:`${s.bottom+4}px`}};return(0,H.jsx)(`div`,{ref:l,className:U(`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,H.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-muted-foreground px-3 py-2 text-sm`,children:`Loading suggestions...`}):n?(0,H.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-destructive px-3 py-2 text-sm`,children:n}):e.length===0&&r?(0,H.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-muted-foreground px-3 py-2 text-sm`,children:r}):e.map((e,t)=>(0,H.jsxs)(`button`,{ref:t===i?u:void 0,type:`button`,role:`option`,"aria-selected":t===i,className:U(`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,H.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.icon}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate font-medium`,children:e.label}),e.description&&(0,H.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:e.description})]})]},e.value))})}function aO({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,H.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,H.jsx)(`div`,{className:`animate-in fade-in-0 slide-in-from-top-4 duration-300 ease-in-out`,children:e[n]},n)})}function oO({onClick:e,label:t,className:n}){return(0,H.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},className:U(`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,H.jsxs)(`svg`,{width:`8`,height:`8`,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,H.jsx)(`line`,{x1:`2.75`,y1:`2.75`,x2:`7.25`,y2:`7.25`}),(0,H.jsx)(`line`,{x1:`7.25`,y1:`2.75`,x2:`2.75`,y2:`7.25`})]})})}function sO({images:e,onRemove:t,onClick:n,className:r}){return e.length===0?null:(0,H.jsx)(`div`,{className:U(`flex flex-wrap gap-2`,r),role:`list`,"aria-label":`Attached images`,children:e.map(e=>(0,H.jsxs)(`div`,{role:`listitem`,className:U(`border-border relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border`,n&&`cursor-pointer`),onClick:()=>n?.(e),children:[(0,H.jsx)(`img`,{src:e.url,alt:e.alt??`Attached image`,className:`h-full w-full object-cover`}),e.loading&&(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,H.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent`})}),t&&(0,H.jsx)(oO,{onClick:()=>t(e),label:`Remove ${e.alt??`image`}`})]},e.id))})}function cO({className:e,children:t}){return(0,H.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 lO=(0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.jsx)(`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`})]});function uO({className:e}){return(0,H.jsx)(cO,{className:e,children:lO})}function dO({className:e}){return(0,H.jsxs)(cO,{className:e,children:[lO,(0,H.jsx)(`path`,{d:`M10 9H8`}),(0,H.jsx)(`path`,{d:`M16 13H8`}),(0,H.jsx)(`path`,{d:`M16 17H8`})]})}function fO({className:e}){return(0,H.jsxs)(cO,{className:e,children:[lO,(0,H.jsx)(`path`,{d:`M8 13h2`}),(0,H.jsx)(`path`,{d:`M14 13h2`}),(0,H.jsx)(`path`,{d:`M8 17h2`}),(0,H.jsx)(`path`,{d:`M14 17h2`})]})}function pO({className:e}){return(0,H.jsxs)(cO,{className:e,children:[lO,(0,H.jsx)(`path`,{d:`M10 12.5 8 15l2 2.5`}),(0,H.jsx)(`path`,{d:`m14 12.5 2 2.5-2 2.5`})]})}function mO({className:e}){return(0,H.jsxs)(cO,{className:e,children:[(0,H.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`}),(0,H.jsx)(`circle`,{cx:`9`,cy:`9`,r:`2`}),(0,H.jsx)(`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`})]})}var hO=3;function gO(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 _O={pdf:dO,spreadsheet:fO,code:pO,image:mO,default:uO};function vO(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 yO(e){let t=e.lastIndexOf(`.`);return t===-1||t===e.length-1?null:e.slice(t+1).toUpperCase()}function bO({file:e,compact:t,onRemove:n,onClick:r}){let i=[yO(e.name),e.size==null?null:vO(e.size)].filter(Boolean).join(` · `);return(0,H.jsxs)(`div`,{role:`listitem`,className:U(`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=_O[gO(e.type)];return(0,H.jsx)(n,{className:U(`text-muted-foreground flex-shrink-0`,t?`h-4 w-4`:`h-5 w-5`)})})(),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:U(`truncate font-medium`,t?`text-xs`:`text-sm`),title:e.name,children:e.name}),!t&&i&&(0,H.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:i})]}),e.loading&&(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,H.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent`})}),n&&(0,H.jsx)(oO,{onClick:()=>n(e),label:`Remove ${e.name}`})]})}function xO({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>hO,l=c,u=e.length-hO,d=e.slice(0,hO);return(0,H.jsxs)(`div`,{className:U(`relative`,r),children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`list`,"aria-label":`Attached files`,children:[(c?d:e).map(e=>(0,H.jsx)(bO,{file:e,compact:l,onRemove:t,onClick:n},e.id)),c&&(0,H.jsx)(`div`,{role:`listitem`,children:(0,H.jsx)(`button`,{ref:s,type:`button`,onClick:()=>a(e=>!e),className:U(`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,H.jsx)(`div`,{ref:o,className:U(`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,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`list`,"aria-label":`More attached files`,children:e.slice(hO).map(e=>(0,H.jsx)(bO,{file:e,compact:l,onRemove:t,onClick:n},e.id))})})]})}function SO({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:te,activeTrigger:ne,suggestions:re,suggestionsLoading:ie,suggestionsError:B,selectedSuggestionIndex:ae,handleInput:oe,handleKeyDown:V,handleClick:se,handleMouseDown:ce,selectSuggestion:le,dismissTrigger:ue,handle:de,triggerRect:fe,eventHandlers:pe}=nO({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,()=>de,[de]),(0,v.useEffect)(()=>{b&&te.current?.focus()},[b,te]);let[me,he]=(0,v.useState)(!1),[ge,_e]=(0,v.useState)(void 0),ve=(0,v.useCallback)(()=>{let e=te.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight;e.style.height=`${t}px`,_e(t)},[te]),ye=(0,v.useCallback)(()=>{x&&(he(!0),ve())},[x,ve]),be=(0,v.useCallback)(()=>{pe.onBlur(),x&&setTimeout(()=>{let e=te.current;if(!e)return;let t=document.activeElement;t&&e.parentElement?.contains(t)||(he(!1),_e(void 0))},150)},[pe,x,te]),xe=(0,v.useCallback)(()=>{oe(),x&&me&&ve()},[oe,x,me,ve]);(0,v.useEffect)(()=>{x&&me&&requestAnimationFrame(()=>ve())},[e,x,me,ve]);let[Se,Ce]=(0,v.useState)(!1),we=(0,v.useRef)(null);(0,v.useEffect)(()=>x?(we.current=setTimeout(()=>{if(me){Ce(!1);return}let e=te.current;e&&Ce(e.scrollHeight>e.clientHeight)},me?0:160),()=>{we.current!==null&&clearTimeout(we.current)}):void 0,[x,me,e,te]);let Te=(0,v.useMemo)(()=>{if(!x){let e={minHeight:`${_}px`};return y&&(e.maxHeight=`${y}px`,e.overflowY=`auto`),e}return{height:me&&ge?`${ge}px`:`${_}px`,minHeight:`${_}px`,maxHeight:y?`${y}px`:`70dvh`,overflowY:me?`auto`:`hidden`,transition:`height 150ms ease-out, min-height 240ms cubic-bezier(0.33, 1, 0.68, 1)`}},[x,_,y,me,ge]),Ee=(0,v.useCallback)(e=>{N?.(e),!e.defaultPrevented&&V(e)},[N,V]),De=(0,v.useCallback)(e=>{P?.(e),be()},[P,be]),Oe=e.length===0||e.length===1&&e[0].type===`text`&&e[0].text===``,ke=w.length>0?(0,H.jsx)(sO,{images:w,onRemove:D,onClick:O,className:T===`above`?`pb-2`:`pt-2`}):null,Ae=k.length>0?(0,H.jsx)(xO,{files:k,onRemove:j,onClick:M,className:A===`above`?`pb-2`:`pt-2`}):null;return(0,H.jsxs)(`div`,{className:U(`prompt-area-container relative text-sm leading-relaxed`,i),children:[T===`above`&&ke,A===`above`&&Ae,(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`div`,{ref:te,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:U(`prompt-area-editor`,`w-full min-w-0 break-words whitespace-pre-wrap outline-none`,a&&`cursor-not-allowed opacity-50`),style:Te,onFocus:ye,onInput:x?xe:oe,onKeyDown:Ee,onMouseDown:ce,onClick:se,onPaste:pe.onPaste,onCopy:pe.onCopy,onCut:pe.onCut,onDrop:pe.onDrop,onDragOver:pe.onDragOver,onCompositionStart:pe.onCompositionStart,onCompositionEnd:pe.onCompositionEnd,onBlur:De}),x&&Se&&!me&&(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-auto absolute right-0 bottom-0 left-0 cursor-pointer`,style:{height:`32px`},onClick:()=>te.current?.focus(),children:(0,H.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)))`}})}),Oe&&r&&(Array.isArray(r)?(0,H.jsx)(aO,{texts:r}):(0,H.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`&&Ae,T===`below`&&ke,ne&&ne.config.mode===`dropdown`&&(0,H.jsx)(iO,{suggestions:re,loading:ie,error:B,emptyMessage:ne.config.emptyMessage,selectedIndex:ae,onSelect:le,onDismiss:ue,triggerRect:fe,triggerChar:ne.config.char})]})}function CO(e={}){let{initialValue:t=[]}=e,[n,r]=(0,v.useState)(t),i=(0,v.useRef)(null),a=(0,v.useMemo)(()=>wE(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 wO(e={}){let{char:t=`@`,...n}=e;return{char:t,position:`any`,mode:`dropdown`,chipStyle:`pill`,accessibilityLabel:`mention`,...n}}function TO(e={}){let{char:t=`/`,position:n=`any`,...r}=e;return{char:t,position:n,mode:`dropdown`,chipStyle:`inline`,accessibilityLabel:`command`,...r}}function EO(e={}){let{char:t=`#`,...n}=e;return{char:t,position:`any`,mode:`dropdown`,chipStyle:`pill`,resolveOnSpace:!0,accessibilityLabel:`tag`,...n}}function DO(e){let{char:t,...n}=e;return{char:t,position:`start`,mode:`launch`,...n}}var OO=[`attention`,`working`,`idle`,`ended`],kO={attention:`Needs attention`,working:`Working`,idle:`Idle`,ended:`Ended`};function AO(e){return e.pendingPermissionCount>0||e.status===`awaiting_approval`?`attention`:e.status===`failed`||e.status===`closed`?`ended`:e.status===`running`||e.status===`starting`||jO(e).length>0?`working`:`idle`}function jO(e){return(e.subagents??[]).filter(e=>e.status===`running`)}function MO(e,t){if(t===`none`)return[];let n=e.subagents??[];return t===`all`?[...n]:n.filter(e=>e.status===`running`)}function NO(e){return e.isAgent===!0||(e.agentType?.trim()??``)!==``}function PO(e){let t=e.agentType?.trim(),n=e.description?.trim();return t&&n?`${t} · ${n}`:t||n||`Sub-agent`}var FO={search:``,gateways:[],adapters:[],states:[],projects:[],scoped:!0,groupBy:`state`,sortBy:`recent`,subagents:`active`,shells:`active`,tasks:`active`};function IO(e){return[...new Set(e.map(e=>e.adapter))].sort()}function LO(e){let t=new Map;for(let n of e)t.set(zO(n),BO(n));return[...t].map(([e,t])=>({key:e,label:t})).sort((e,t)=>e.label.toLowerCase().localeCompare(t.label.toLowerCase()))}function RO(e){return e.title??e.id.slice(0,8)}function zO(e){return`${e.hostId}:${KO(e.info.project?.root??e.info.cwd)}`}function BO(e){return e.info.project?.shortcode||VO(e)}function VO(e){let t=e.info.project?.name;if(t)return t;let n=KO(e.info.cwd);return n.slice(n.lastIndexOf(`/`)+1)||`No project`}function HO(e){let t=e.info.project?.root;if(t===void 0||!e.info.cwd)return;let n=KO(t),r=KO(e.info.cwd);if(r!==n&&r.startsWith(`${n}/`))return r.slice(n.length+1)||void 0}function UO(e){return typeof e.meta?.jobId==`string`}function WO(e,t,n){if(t===`none`)return[];let r=(e.shells??[]).filter(e=>e.status!==`running`||n-e.startedAt>=3e3);return t===`active`?r.filter(e=>e.status===`running`):r}function GO(e,t){return!t||RO(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 KO(e){return e.replace(/\\/g,`/`).replace(/\/+$/,``)}function qO(e,t){let n=KO(e),r=KO(t);return r===n||r.startsWith(`${n}/`)}function JO(e,t){return t.roots.some(t=>(t.hostId?t.hostId.toLowerCase()===e.hostId.toLowerCase():e.local)&&qO(t.path,e.info.cwd))}function YO(e,t){return e.scoped&&t!==void 0}function XO(e,t,n){let r=t.search.trim().toLowerCase(),i=YO(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(zO(e)))&&(!i||JO(e,i))&&GO(e,r))}function ZO(e,t){return t===`gateway`?e.hostId:t===`adapter`?e.adapter:t===`project`?zO(e):e.state}function QO(e,t){return t===`gateway`?e.hostName:t===`adapter`?e.adapter:t===`project`?BO(e):kO[e.state]}function $O(e,t){return t===`state`?String(OO.indexOf(e.state)):QO(e,t).toLowerCase()}function ek(e,t){return(t.info.lastActivityAt??t.info.createdAt)-(e.info.lastActivityAt??e.info.createdAt)}function tk(e,t,n){return n===`recent`?ek(e,t):n===`name`?RO(e.info).localeCompare(RO(t.info),void 0,{sensitivity:`base`})||ek(e,t):$O(e,n).localeCompare($O(t,n))||ek(e,t)}function nk(e,t){let n=[...e].sort((e,n)=>tk(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=ZO(e,r),n=i.get(t);n?n.rows.push(e):i.set(t,{key:t,label:QO(e,r),rank:$O(e,r),rows:[e]})}return[...i.values()].sort((e,t)=>e.rank.localeCompare(t.rank))}function rk(e,t,n,r){if(n>=r)return;let i=[];t&&YO(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 ik(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 ak(e){return[e.gateways,e.adapters,e.states,e.projects??[]].filter(e=>e.length>0).length}function ok(e){return e.subagents!==FO.subagents||(e.shells??FO.shells)!==FO.shells||(e.tasks??FO.tasks)!==FO.tasks}function sk(e){return{...FO,scoped:!1,groupBy:e.groupBy,sortBy:e.sortBy,subagents:e.subagents,shells:e.shells,tasks:e.tasks}}function ck(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 lk(e){let t=e?.todos;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=ck(e);if(t===void 0)return;n.push(t)}return n}function uk(e){switch(e){case`in_progress`:return`running`;case`completed`:return`done`;default:return`pending`}}function dk(e){let t=(e.checklist??[]).map((e,t)=>({key:`checklist:${t}`,label:e.text,source:`checklist`,state:uk(e.status)})),n=(e.subagents??[]).filter(e=>!NO(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,stoppable:e.status===`running`&&e.stoppable===!0||void 0}));return[...t,...n]}function fk(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 pk(e){return e.total===0?void 0:`${e.done}/${e.total}`}function mk(e,t){if(t===`none`)return[];let n=dk(e);return t===`all`?n:n.filter(e=>e.state===`running`||e.state===`pending`)}function hk(e,t){return e instanceof Error?e.message:t??String(e)}function gk(e,t){return e.startsWith(`/`)?_k(e):t?_k(`${t}/${e}`):void 0}function _k(e){let t=[];for(let n of e.split(`/`))n!==``&&n!==`.`&&(n===`..`?t.pop():t.push(n));return`/${t.join(`/`)}`}var vk=`2026-09-23`,yk=`List rates as of ${vk}. 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.`,bk=.005,xk=1e6,Sk=864e5,Ck=[`input`,`output`,`cacheWrite5m`,`cacheWrite1h`,`cacheRead`];function wk(e,t,n){return{input:e,output:t,cacheWrite5m:e*1.25,cacheWrite1h:e*2,cacheRead:n??e*.1}}function Tk(e,t,n){return{input:e,output:t,cacheWrite5m:e,cacheWrite1h:e,cacheRead:n}}var Ek={"claude-fable-5-1":wk(10,50,.25),"claude-fable-5":wk(10,50),"claude-mythos-5-1":wk(10,50,.25),"claude-mythos-5":wk(10,50),"claude-opus-5-5":wk(4,20,.2),"claude-opus-5":wk(5,25),"claude-opus-4-8":wk(5,25),"claude-opus-4-7":wk(5,25),"claude-opus-4-6":wk(5,25),"claude-opus-4-5":wk(5,25),"claude-sonnet-5":wk(2,10),"claude-sonnet-4-6":wk(3,15),"claude-sonnet-4-5":wk(3,15),"claude-haiku-4-5":wk(1,5),"gpt-6-astra":Tk(10,50,1),"gpt-5.6-sol":Tk(4,20,.4),"gpt-5.6-terra":Tk(2,12,.2),"gpt-5.6-luna":Tk(.2,1.2,.02),"gpt-5.5":Tk(5,30,.5),"gpt-5.4":Tk(2.5,15,.25),"gpt-5.2":Tk(1.75,14,.175),"gpt-5.1":Tk(1.25,10,.125),"gpt-5":Tk(1.25,10,.125)},Dk=Ek;function Ok(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 Ck){let r=t[e];if(typeof r!=`number`||!Number.isFinite(r)||r<0)return;n[e]=r}return n}function kk(e,t=Ek){let n={},r=[];if(typeof e==`object`&&e)for(let[t,i]of Object.entries(e)){let e=Ok(i),a=Nk(t);if(!e||a===``){r.push(t);continue}n[a]=e}return{pricing:{...t,...n},overrides:n,dropped:r}}function Ak(){return Dk}function jk(e,t=vk){let n=Date.parse(t);return Number.isFinite(n)?Math.floor((e-n)/Sk):0}function Mk(e,t=vk){let n=jk(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 Nk(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 Pk(e,t=Ak()){return e?t[Nk(e)]:void 0}function Fk(e){return e.input+e.output+e.cacheWrite5m+e.cacheWrite1h+e.cacheRead}function Ik(e){return Object.entries(e).filter(([,e])=>e.costBasis===`unknown`).map(([e])=>Nk(e))}function Lk(e){return{input:0,output:0,cacheWrite:0,cacheRead:0,total:0,unpriced:!0,unpricedTokens:e,unpricedShare:+(e>0)}}function Rk(e,t,n=Ak()){let r=Pk(t,n);if(!r)return Lk(Fk(e));let i=e.input/xk*r.input,a=e.output/xk*r.output,o=e.cacheWrite5m/xk*r.cacheWrite5m+e.cacheWrite1h/xk*r.cacheWrite1h,s=e.cacheRead/xk*r.cacheRead;return{input:i,output:a,cacheWrite:o,cacheRead:s,total:i+a+o+s,unpriced:!1,unpricedTokens:0,unpricedShare:0}}function zk(e,t=Ak()){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=Rk(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 Bk=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`)`,`]`,`}`,`"`,`'`]),Vk=/^[\p{L}\p{N}][\p{L}\p{N}\-_]*$/u;function Hk(e,t){return(e??``).normalize(`NFKC`).replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/^-+|-+$/g,``)||t.slice(0,8)}function Uk(e){return e.normalize(`NFKC`).toLowerCase().replace(/[_\s]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function Wk(e){return e.length>0&&e.length<=64&&Vk.test(e)}var Gk={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 Kk(e,t){return qk(t?.[e]??Gk[e],e)}function qk(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 Jk=[`peers_send`,`mcp__workerdeck__peers_send`];function Yk(e){return Jk.includes(e)}function Xk(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 Zk=9e5;function Qk(e,t){return e.inferredReset||e.updatedAt===void 0?!1:t-e.updatedAt>Zk}function $k(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 eA(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))t[n]=r.info;return t}var tA=2592e6,nA=6e4;function rA(e,t){return`${e}:${t}`}var iA=class{#e;#t;constructor(e){this.#e=e,this.#t={...e.read()}}get(e,t){return this.#t[rA(e,t)]}all(){return this.#t}mark(e,t,n,r=Date.now()){let i=rA(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<nA?!1:(this.#t[i]=o,this.#e.write(this.#n(r)),!0)}forget(e,t){let n=rA(e,t);n in this.#t&&(delete this.#t[n],this.#e.write(this.#t))}#n(e){let t=e-tA;for(let[e,n]of Object.entries(this.#t))n.seenAt<t&&delete this.#t[e];return this.#t}};function aA(e,t){return!e||t.proseCount===void 0?0:Math.max(0,t.proseCount-(e.prose??t.proseCount))}function oA(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 sA=`interactive output, no preview`,cA={claude:{interactiveApprovals:!0,permissionModes:[`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`],defaultPermissionMode:`default`,resume:!0,resumeBackfill:!0,forkSession:!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,forkSession:!1,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,forkSession:!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 lA(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 uA=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 dA(e){return Math.min(500*2**e,1e4)}var fA=class{sessionId;#e;#t;#n;#r=new uA;#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=dA(this.#o++);this.#r.emit(`reconnectAttempt`,this.#o),this.#c=setTimeout(()=>this.#u(),e)},e.onerror=()=>{}}},pA=class{#e;#t;#n;#r=new uA;#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=dA(this.#a++);this.#o=setTimeout(()=>this.#s(),e)},e.onerror=()=>{}}};function mA(e,t,n,r=!1,i=!1){let a=`afterSeq=${n}`+(r?`&truncateResults=1`:``)+(i?`&imageRefs=1`:``);return`${e.replace(/^http/,`ws`)}/sessions/${encodeURIComponent(t)}/ws?${a}`}function hA(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 gA(e){let t=hA(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 _A(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,n,r,a)=>i(mA(t,e,n,r,a)),buildQueueWsUrl:()=>i(`${r}/queue/ws`)}}var vA=class extends Error{status;constructor(e,t){super(e),this.name=`WorkerDeckError`,this.status=t}},yA=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.#s(`POST`,`/sessions`,`session`,e)}async listSessions(){return await this.#s(`GET`,`/sessions`,`sessions`)}async getSession(e){return await this.#s(`GET`,this.#i(e),`session`)}async updateSession(e,t){return await this.#s(`PATCH`,this.#i(e),`session`,t)}async deleteSession(e){return await this.#s(`DELETE`,this.#i(e),`session`)}async listSessionFiles(e){return await this.#s(`GET`,this.#i(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}${this.#i(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}${this.#i(e,`/attachments/${encodeURIComponent(t)}`)}`}producedFileUrl(e,t){return`${this.#e.baseUrl}${this.#i(e,`/produced/${encodeURIComponent(t)}`)}`}async readProducedFile(e,t){return await this.#o(this.producedFileUrl(e,t),`produced file request failed`)}projectIconUrl(e){return`${this.#e.baseUrl}${this.#i(e,`/project/icon`)}`}async projectIcon(e){return await this.#o(this.projectIconUrl(e),`project icon request failed`)}async listMcpServers(e){return await this.#s(`GET`,this.#i(e,`/mcp`),`servers`)}async mcpServerAction(e,t,n){let r=this.#i(e,`/mcp/${encodeURIComponent(t)}`);return await this.#s(`POST`,r,`servers`,{action:n})}sessionFileUrl(e,t){let n=t.split(`/`).filter(Boolean).map(encodeURIComponent).join(`/`);return`${this.#e.baseUrl}${this.#i(e,`/files/${n}`)}`}async resolvePermission(e,t,n){await this.#c(`POST`,this.#i(e,`/permissions/${encodeURIComponent(t)}`),n)}async submitExecutionResult(e,t){return await this.#c(`POST`,`/executions/${encodeURIComponent(e)}/result`,t)}async listProfiles(){return await this.#c(`GET`,`/profiles`)}async getProfile(e){return await this.#c(`GET`,`/profiles/${encodeURIComponent(e)}`)}async createProfile(e){return await this.#s(`POST`,`/profiles`,`profile`,e)}async updateProfile(e,t){return await this.#s(`PATCH`,`/profiles/${encodeURIComponent(e)}`,`profile`,t)}async deleteProfile(e){await this.#c(`DELETE`,`/profiles/${encodeURIComponent(e)}`)}async listSdkSessions(e){let t=bA({dir:e?.dir||void 0,limit:e?.limit,offset:e?.offset,profile:e?.profile||void 0});return await this.#s(`GET`,`/sdk-sessions${t}`,`sdkSessions`)}async listHostRoots(){return await this.#c(`GET`,`/fs/roots`)}async meta(){return await this.#c(`GET`,`/meta`)}async listHostDir(e){return await this.#c(`GET`,`/fs/list${bA({path:e})}`)}async findHostFiles(e,t=``,n){return await this.#c(`GET`,`/fs/find${bA({path:e,q:t,limit:n})}`)}async readHostFile(e){return await this.#c(`GET`,`/fs/read${bA({path:e})}`)}async writeHostFile(e){return await this.#c(`PUT`,`/fs/write`,e)}async createJob(e){return await this.#s(`POST`,`/jobs`,`job`,e)}async listJobs(){return await this.#s(`GET`,`/jobs`,`jobs`)}async getJob(e){return await this.#s(`GET`,`/jobs/${encodeURIComponent(e)}`,`job`)}async cancelJob(e){return await this.#s(`DELETE`,`/jobs/${encodeURIComponent(e)}`,`job`)}async queueStats(){return await this.#s(`GET`,`/queue`,`stats`)}async listShells(e){return await this.#s(`GET`,this.#i(e,`/shells`),`shells`)}async getShell(e,t){return await this.#s(`GET`,this.#a(e,t),`shell`)}async shellOutput(e,t,n){let r=bA({view:n?.view||void 0,tail:n?.tail});return await(await this.#r(`${this.#e.baseUrl}${this.#a(e,t,`/output${r}`)}`,{headers:{...this.#e.headers}},`shell output request failed`)).text()}async killShell(e,t){return await this.#s(`POST`,this.#a(e,t,`/kill`),`shell`)}async stopTask(e,t){await this.#c(`POST`,this.#i(e,`/tasks/${encodeURIComponent(t)}/stop`))}async setShellAgentWrite(e,t,n){return await this.#s(`POST`,this.#a(e,t,`/agent-write`),`shell`,{enabled:n})}attach(e,t){return new fA(this,e,t)}attachQueue(e){return new pA(this,e)}openSocket(e,t,n=!1,r=!1){let i=this.#e.buildWsUrl?.(e,t,n,r)??mA(this.#e.baseUrl,e,t,n,r);return new this.#n(i)}async toolResult(e,t,n,r){return await this.#c(`GET`,this.#i(e,`/events/${t}/result${bA({toolUseId:n,imageRefs:r?.imageRefs?1:void 0})}`))}async toolResultImage(e,t,n,r){let i=`${this.#e.baseUrl}${this.#i(e,`/events/${t}/result${bA({toolUseId:n,part:r})}`)}`;return await this.#o(i,`image part request failed`)}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 vA((await r.json().catch(()=>({}))).error??`${n} with ${r.status}`,r.status);return r}#i(e,t=``){return`/sessions/${encodeURIComponent(e)}${t}`}#a(e,t,n=``){return this.#i(e,`/shells/${encodeURIComponent(t)}${n}`)}async#o(e,t){return await(await this.#r(e,{headers:{...this.#e.headers}},t)).blob()}async#s(e,t,n,r){return(await this.#c(e,t,r))[n]}async#c(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 vA(i.error??`${e} ${t} failed with ${r.status}`,r.status);return i}};function bA(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!==void 0&&t.set(n,String(r));return t.size>0?`?${t.toString()}`:``}var xA={status:`starting`,capabilities:cA.claude,items:[],pendingApprovals:[],totalCostUsd:0,lastSeq:0},SA=`streaming`,CA=`streaming-thinking`,wA=/^<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>$/,TA=/<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>/g,EA=`<local-command-caveat>`,DA=/^\[\.\.\. more output \.\.\.\]$/,OA=/^\[(exit -?\d+|killed|timed out|ended|failed to start)[^\]]*\]$/;function kA(e,t){let n=(wA.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=oD(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=U(`prompt-area-chip`,a===`inline`&&`prompt-area-chip--inline`,i?.chipClassName),e.textContent=CE(r),e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`-1`),t.appendChild(e)}if(t.lastChild&&rD(t.lastChild)){let e=document.createElement(`br`);e.dataset.sentinel=`true`,t.appendChild(e)}gD(t,h),r!==null&&bD(t,r),N.current=e,M.current=!1},[n,h]),R=QD({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=jE(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&&bD(a,i.cursorOffset)},[t,L,s]),ee=(0,v.useCallback)(()=>{let e=b.current;if(!e)return;let t=I(),r=wE(t),i=vD(e);if(i===null)return;let a=AE(r,i,n);if(R.clear(),a){S(a),w(0);let n=Zee(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]),te=(0,v.useCallback)(()=>{R.clear(),S(null),w(0),j()},[j,R]),ne=XD({editorRef:b,readSegmentsFromDOM:I,onChange:t,renderSegmentsToDOM:L,runTriggerDetection:ee,dismissTrigger:te,triggers:n,markdownEnabled:h,normalizeBullets:g,onPaste:u,onRawPaste:d,onUndo:f,onRedo:p,onChipAdd:s,onImagePaste:m});(0,v.useLayoutEffect)(()=>{if(!M.current&&!zE(e,N.current)){if(h&&g){let n=KE(e,!0);if(n!==e){t(n);return}}if(BE(I(),e)){N.current=e;return}L(e)}},[e,I,L,h,g,t]);let re=(0,v.useRef)(h);(0,v.useLayoutEffect)(()=>{if(re.current===h)return;re.current=h;let n=g?KE(e,h):e;n===e?L(e):t(n)},[h,g,L,e,t]),(0,v.useEffect)(()=>()=>{P.current&&clearTimeout(P.current)},[]);let ie=(0,v.useCallback)(()=>{if(M.current)return;if(ne.isComposing.current){let e=I();N.current=e,t(e);return}let e=b.current,n=e?vD(e):null;e&&hD(e);let r=I();if(y!=null&&e&&wE(r).length>y){let n=vD(e),i=EE(r,y);N.current=i,t(i),L(i),bD(e,n==null?y:Math.min(n,y)),ee();return}if(h&&g&&e&&n!==null){let i=Nee(r,n);if(i){N.current=i.segments,t(i.segments),L(i.segments),bD(e,i.cursorOffset),ee();return}}let i=r,a=null;if(h&&n!==null&&qE(wE(r))){let e=XE(r);e.edits.length>0&&(i=e.segments,a=YE(n,e.edits))}F.current||=N.current,N.current=i,t(i),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{F.current&&=(ne.pushUndo(F.current),null),P.current=null},eO),e&&(a===null?(gD(e,h),n!==null&&bD(e,n)):(L(i),bD(e,a))),ee()},[t,I,ee,L,h,g,y,ne]),B=(0,v.useCallback)(e=>{if(!x)return;let n=I(),r=x.config.insertAsText?.(e);if(r!==void 0){let e=ME(n,x,r);ne.pushUndo(n),t(e.segments),L(e.segments);let i=b.current;i&&bD(i,e.cursorOffset),te(),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,ne.pushUndo)){te(),setTimeout(()=>{b.current?.focus()},0);return}let c=jE(n,x,o,a?.trailingText);t(c.segments),L(c.segments),s?.({type:`chip`,trigger:x.config.char,...o});let l=b.current;l&&bD(l,c.cursorOffset),te(),setTimeout(()=>{b.current?.focus()},0)},[x,I,t,L,te,s,ne,R]),ae=B,oe=ZD({editorRef:b,triggers:n,markdownEnabled:h,submitOnEnter:_,onSubmit:i,onEscape:a,onChange:t,onChipAdd:s,onChipDelete:c,readSegmentsFromDOM:I,renderSegmentsToDOM:L,runTriggerDetection:ee,dismissTrigger:te,buildInsertChip:z,selectSuggestionInternal:B,activeTrigger:x,suggestions:D,suggestionsLoading:O,suggestionsError:k,selectedSuggestionIndex:C,setSelectedSuggestionIndex:w,pushUndo:ne.pushUndo,handleKeyDownForUndoRedo:ne.handleKeyDownForUndoRedo,lastRenderedValue:N,undoTimer:P,undoBaseState:F}),V=(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:()=>wE(I()),clear:()=>{t([]);let e=b.current;if(e)for(;e.firstChild;)e.removeChild(e.firstChild);ne.resetUndoHistory(),P.current&&=(clearTimeout(P.current),null),F.current=null},setText:e=>{ne.pushUndo(I());let n=TE(e);t(n),L(n);let r=b.current;r&&bD(r,e.length)},appendText:e=>{let n=I();ne.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&&bD(a,wE(i).length)},getCursorPosition:()=>{let e=b.current;return e?vD(e):null},setCursorPosition:e=>{let t=b.current;t&&bD(t,e)},setCursorToEnd:()=>{let e=b.current;e&&bD(e,wE(I()).length)},getSelection:()=>{let e=b.current;return e?SD(e):null},setSelection:(e,t)=>{let n=b.current;n&&CD(n,e,t)}}),[I,t,L,s,ne]),se=(0,v.useMemo)(()=>({onPaste:ne.handlePaste,onCopy:ne.handleCopy,onCut:ne.handleCut,onDrop:ne.handleDrop,onDragOver:ne.handleDragOver,onCompositionStart:ne.handleCompositionStart,onCompositionEnd:ne.handleCompositionEnd,onBlur:ne.handleBlur}),[ne.handlePaste,ne.handleCopy,ne.handleCut,ne.handleDrop,ne.handleDragOver,ne.handleCompositionStart,ne.handleCompositionEnd,ne.handleBlur]);return{editorRef:b,activeTrigger:x,suggestions:D,suggestionsLoading:O,suggestionsError:k,selectedSuggestionIndex:C,handleInput:ie,handleKeyDown:oe,handleClick:R.handleClick,handleMouseDown:R.handleMouseDown,selectSuggestion:ae,dismissTrigger:te,handle:V,triggerRect:T,eventHandlers:se}}var rO=240;function iO({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<rO&&s.top>p,h={position:`fixed`,left:`${Math.max(8,f)}px`,zIndex:50,maxWidth:`${d}px`,maxHeight:`${rO}px`,...m?{bottom:`${window.innerHeight-s.top+4}px`}:{top:`${s.bottom+4}px`}};return(0,H.jsx)(`div`,{ref:l,className:U(`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,H.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-muted-foreground px-3 py-2 text-sm`,children:`Loading suggestions...`}):n?(0,H.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-destructive px-3 py-2 text-sm`,children:n}):e.length===0&&r?(0,H.jsx)(`div`,{role:`option`,"aria-selected":!1,className:`text-muted-foreground px-3 py-2 text-sm`,children:r}):e.map((e,t)=>(0,H.jsxs)(`button`,{ref:t===i?u:void 0,type:`button`,role:`option`,"aria-selected":t===i,className:U(`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,H.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.icon}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate font-medium`,children:e.label}),e.description&&(0,H.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:e.description})]})]},e.value))})}function aO({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,H.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,H.jsx)(`div`,{className:`animate-in fade-in-0 slide-in-from-top-4 duration-300 ease-in-out`,children:e[n]},n)})}function oO({onClick:e,label:t,className:n}){return(0,H.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},className:U(`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,H.jsxs)(`svg`,{width:`8`,height:`8`,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,H.jsx)(`line`,{x1:`2.75`,y1:`2.75`,x2:`7.25`,y2:`7.25`}),(0,H.jsx)(`line`,{x1:`7.25`,y1:`2.75`,x2:`2.75`,y2:`7.25`})]})})}function sO({images:e,onRemove:t,onClick:n,className:r}){return e.length===0?null:(0,H.jsx)(`div`,{className:U(`flex flex-wrap gap-2`,r),role:`list`,"aria-label":`Attached images`,children:e.map(e=>(0,H.jsxs)(`div`,{role:`listitem`,className:U(`border-border relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border`,n&&`cursor-pointer`),onClick:()=>n?.(e),children:[(0,H.jsx)(`img`,{src:e.url,alt:e.alt??`Attached image`,className:`h-full w-full object-cover`}),e.loading&&(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,H.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent`})}),t&&(0,H.jsx)(oO,{onClick:()=>t(e),label:`Remove ${e.alt??`image`}`})]},e.id))})}function cO({className:e,children:t}){return(0,H.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 lO=(0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.jsx)(`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`})]});function uO({className:e}){return(0,H.jsx)(cO,{className:e,children:lO})}function dO({className:e}){return(0,H.jsxs)(cO,{className:e,children:[lO,(0,H.jsx)(`path`,{d:`M10 9H8`}),(0,H.jsx)(`path`,{d:`M16 13H8`}),(0,H.jsx)(`path`,{d:`M16 17H8`})]})}function fO({className:e}){return(0,H.jsxs)(cO,{className:e,children:[lO,(0,H.jsx)(`path`,{d:`M8 13h2`}),(0,H.jsx)(`path`,{d:`M14 13h2`}),(0,H.jsx)(`path`,{d:`M8 17h2`}),(0,H.jsx)(`path`,{d:`M14 17h2`})]})}function pO({className:e}){return(0,H.jsxs)(cO,{className:e,children:[lO,(0,H.jsx)(`path`,{d:`M10 12.5 8 15l2 2.5`}),(0,H.jsx)(`path`,{d:`m14 12.5 2 2.5-2 2.5`})]})}function mO({className:e}){return(0,H.jsxs)(cO,{className:e,children:[(0,H.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`}),(0,H.jsx)(`circle`,{cx:`9`,cy:`9`,r:`2`}),(0,H.jsx)(`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`})]})}var hO=3;function gO(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 _O={pdf:dO,spreadsheet:fO,code:pO,image:mO,default:uO};function vO(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 yO(e){let t=e.lastIndexOf(`.`);return t===-1||t===e.length-1?null:e.slice(t+1).toUpperCase()}function bO({file:e,compact:t,onRemove:n,onClick:r}){let i=[yO(e.name),e.size==null?null:vO(e.size)].filter(Boolean).join(` · `);return(0,H.jsxs)(`div`,{role:`listitem`,className:U(`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=_O[gO(e.type)];return(0,H.jsx)(n,{className:U(`text-muted-foreground flex-shrink-0`,t?`h-4 w-4`:`h-5 w-5`)})})(),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:U(`truncate font-medium`,t?`text-xs`:`text-sm`),title:e.name,children:e.name}),!t&&i&&(0,H.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:i})]}),e.loading&&(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40`,children:(0,H.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent`})}),n&&(0,H.jsx)(oO,{onClick:()=>n(e),label:`Remove ${e.name}`})]})}function xO({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>hO,l=c,u=e.length-hO,d=e.slice(0,hO);return(0,H.jsxs)(`div`,{className:U(`relative`,r),children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`list`,"aria-label":`Attached files`,children:[(c?d:e).map(e=>(0,H.jsx)(bO,{file:e,compact:l,onRemove:t,onClick:n},e.id)),c&&(0,H.jsx)(`div`,{role:`listitem`,children:(0,H.jsx)(`button`,{ref:s,type:`button`,onClick:()=>a(e=>!e),className:U(`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,H.jsx)(`div`,{ref:o,className:U(`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,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`list`,"aria-label":`More attached files`,children:e.slice(hO).map(e=>(0,H.jsx)(bO,{file:e,compact:l,onRemove:t,onClick:n},e.id))})})]})}function SO({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:te,activeTrigger:ne,suggestions:re,suggestionsLoading:ie,suggestionsError:B,selectedSuggestionIndex:ae,handleInput:oe,handleKeyDown:V,handleClick:se,handleMouseDown:ce,selectSuggestion:le,dismissTrigger:ue,handle:de,triggerRect:fe,eventHandlers:pe}=nO({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,()=>de,[de]),(0,v.useEffect)(()=>{b&&te.current?.focus()},[b,te]);let[me,he]=(0,v.useState)(!1),[ge,_e]=(0,v.useState)(void 0),ve=(0,v.useCallback)(()=>{let e=te.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight;e.style.height=`${t}px`,_e(t)},[te]),ye=(0,v.useCallback)(()=>{x&&(he(!0),ve())},[x,ve]),be=(0,v.useCallback)(()=>{pe.onBlur(),x&&setTimeout(()=>{let e=te.current;if(!e)return;let t=document.activeElement;t&&e.parentElement?.contains(t)||(he(!1),_e(void 0))},150)},[pe,x,te]),xe=(0,v.useCallback)(()=>{oe(),x&&me&&ve()},[oe,x,me,ve]);(0,v.useEffect)(()=>{x&&me&&requestAnimationFrame(()=>ve())},[e,x,me,ve]);let[Se,Ce]=(0,v.useState)(!1),we=(0,v.useRef)(null);(0,v.useEffect)(()=>x?(we.current=setTimeout(()=>{if(me){Ce(!1);return}let e=te.current;e&&Ce(e.scrollHeight>e.clientHeight)},me?0:160),()=>{we.current!==null&&clearTimeout(we.current)}):void 0,[x,me,e,te]);let Te=(0,v.useMemo)(()=>{if(!x){let e={minHeight:`${_}px`};return y&&(e.maxHeight=`${y}px`,e.overflowY=`auto`),e}return{height:me&&ge?`${ge}px`:`${_}px`,minHeight:`${_}px`,maxHeight:y?`${y}px`:`70dvh`,overflowY:me?`auto`:`hidden`,transition:`height 150ms ease-out, min-height 240ms cubic-bezier(0.33, 1, 0.68, 1)`}},[x,_,y,me,ge]),Ee=(0,v.useCallback)(e=>{N?.(e),!e.defaultPrevented&&V(e)},[N,V]),De=(0,v.useCallback)(e=>{P?.(e),be()},[P,be]),Oe=e.length===0||e.length===1&&e[0].type===`text`&&e[0].text===``,ke=w.length>0?(0,H.jsx)(sO,{images:w,onRemove:D,onClick:O,className:T===`above`?`pb-2`:`pt-2`}):null,Ae=k.length>0?(0,H.jsx)(xO,{files:k,onRemove:j,onClick:M,className:A===`above`?`pb-2`:`pt-2`}):null;return(0,H.jsxs)(`div`,{className:U(`prompt-area-container relative text-sm leading-relaxed`,i),children:[T===`above`&&ke,A===`above`&&Ae,(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`div`,{ref:te,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:U(`prompt-area-editor`,`w-full min-w-0 break-words whitespace-pre-wrap outline-none`,a&&`cursor-not-allowed opacity-50`),style:Te,onFocus:ye,onInput:x?xe:oe,onKeyDown:Ee,onMouseDown:ce,onClick:se,onPaste:pe.onPaste,onCopy:pe.onCopy,onCut:pe.onCut,onDrop:pe.onDrop,onDragOver:pe.onDragOver,onCompositionStart:pe.onCompositionStart,onCompositionEnd:pe.onCompositionEnd,onBlur:De}),x&&Se&&!me&&(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-auto absolute right-0 bottom-0 left-0 cursor-pointer`,style:{height:`32px`},onClick:()=>te.current?.focus(),children:(0,H.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)))`}})}),Oe&&r&&(Array.isArray(r)?(0,H.jsx)(aO,{texts:r}):(0,H.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`&&Ae,T===`below`&&ke,ne&&ne.config.mode===`dropdown`&&(0,H.jsx)(iO,{suggestions:re,loading:ie,error:B,emptyMessage:ne.config.emptyMessage,selectedIndex:ae,onSelect:le,onDismiss:ue,triggerRect:fe,triggerChar:ne.config.char})]})}function CO(e={}){let{initialValue:t=[]}=e,[n,r]=(0,v.useState)(t),i=(0,v.useRef)(null),a=(0,v.useMemo)(()=>wE(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 wO(e={}){let{char:t=`@`,...n}=e;return{char:t,position:`any`,mode:`dropdown`,chipStyle:`pill`,accessibilityLabel:`mention`,...n}}function TO(e={}){let{char:t=`/`,position:n=`any`,...r}=e;return{char:t,position:n,mode:`dropdown`,chipStyle:`inline`,accessibilityLabel:`command`,...r}}function EO(e={}){let{char:t=`#`,...n}=e;return{char:t,position:`any`,mode:`dropdown`,chipStyle:`pill`,resolveOnSpace:!0,accessibilityLabel:`tag`,...n}}function DO(e){let{char:t,...n}=e;return{char:t,position:`start`,mode:`launch`,...n}}var OO=[`attention`,`working`,`idle`,`ended`],kO={attention:`Needs attention`,working:`Working`,idle:`Idle`,ended:`Ended`};function AO(e){return e.pendingPermissionCount>0||e.status===`awaiting_approval`?`attention`:e.status===`failed`||e.status===`closed`?`ended`:e.status===`running`||e.status===`starting`||jO(e).length>0?`working`:`idle`}function jO(e){return(e.subagents??[]).filter(e=>e.status===`running`)}function MO(e,t){if(t===`none`)return[];let n=e.subagents??[];return t===`all`?[...n]:n.filter(e=>e.status===`running`)}function NO(e){return e.isAgent===!0||(e.agentType?.trim()??``)!==``}function PO(e){let t=e.agentType?.trim(),n=e.description?.trim();return t&&n?`${t} · ${n}`:t||n||`Sub-agent`}var FO={search:``,gateways:[],adapters:[],states:[],projects:[],scoped:!0,groupBy:`state`,sortBy:`recent`,subagents:`active`,shells:`active`,tasks:`active`};function IO(e){return[...new Set(e.map(e=>e.adapter))].sort()}function LO(e){let t=new Map;for(let n of e)t.set(zO(n),BO(n));return[...t].map(([e,t])=>({key:e,label:t})).sort((e,t)=>e.label.toLowerCase().localeCompare(t.label.toLowerCase()))}function RO(e){return e.title??e.id.slice(0,8)}function zO(e){return`${e.hostId}:${KO(e.info.project?.root??e.info.cwd)}`}function BO(e){return e.info.project?.shortcode||VO(e)}function VO(e){let t=e.info.project?.name;if(t)return t;let n=KO(e.info.cwd);return n.slice(n.lastIndexOf(`/`)+1)||`No project`}function HO(e){let t=e.info.project?.root;if(t===void 0||!e.info.cwd)return;let n=KO(t),r=KO(e.info.cwd);if(r!==n&&r.startsWith(`${n}/`))return r.slice(n.length+1)||void 0}function UO(e){return typeof e.meta?.jobId==`string`}function WO(e,t,n){if(t===`none`)return[];let r=(e.shells??[]).filter(e=>e.status!==`running`||n-e.startedAt>=3e3);return t===`active`?r.filter(e=>e.status===`running`):r}function GO(e,t){return!t||RO(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 KO(e){return e.replace(/\\/g,`/`).replace(/\/+$/,``)}function qO(e,t){let n=KO(e),r=KO(t);return r===n||r.startsWith(`${n}/`)}function JO(e,t){return t.roots.some(t=>(t.hostId?t.hostId.toLowerCase()===e.hostId.toLowerCase():e.local)&&qO(t.path,e.info.cwd))}function YO(e,t){return e.scoped&&t!==void 0}function XO(e,t,n){let r=t.search.trim().toLowerCase(),i=YO(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(zO(e)))&&(!i||JO(e,i))&&GO(e,r))}function ZO(e,t){return t===`gateway`?e.hostId:t===`adapter`?e.adapter:t===`project`?zO(e):e.state}function QO(e,t){return t===`gateway`?e.hostName:t===`adapter`?e.adapter:t===`project`?BO(e):kO[e.state]}function $O(e,t){return t===`state`?String(OO.indexOf(e.state)):QO(e,t).toLowerCase()}function ek(e,t){return(t.info.lastActivityAt??t.info.createdAt)-(e.info.lastActivityAt??e.info.createdAt)}function tk(e,t,n){return n===`recent`?ek(e,t):n===`name`?RO(e.info).localeCompare(RO(t.info),void 0,{sensitivity:`base`})||ek(e,t):$O(e,n).localeCompare($O(t,n))||ek(e,t)}function nk(e,t){let n=[...e].sort((e,n)=>tk(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=ZO(e,r),n=i.get(t);n?n.rows.push(e):i.set(t,{key:t,label:QO(e,r),rank:$O(e,r),rows:[e]})}return[...i.values()].sort((e,t)=>e.rank.localeCompare(t.rank))}function rk(e,t,n,r){if(n>=r)return;let i=[];t&&YO(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 ik(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 ak(e){return[e.gateways,e.adapters,e.states,e.projects??[]].filter(e=>e.length>0).length}function ok(e){return e.subagents!==FO.subagents||(e.shells??FO.shells)!==FO.shells||(e.tasks??FO.tasks)!==FO.tasks}function sk(e){return{...FO,scoped:!1,groupBy:e.groupBy,sortBy:e.sortBy,subagents:e.subagents,shells:e.shells,tasks:e.tasks}}function ck(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 lk(e){let t=e?.todos;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=ck(e);if(t===void 0)return;n.push(t)}return n}function uk(e){switch(e){case`in_progress`:return`running`;case`completed`:return`done`;default:return`pending`}}function dk(e){let t=(e.checklist??[]).map((e,t)=>({key:`checklist:${t}`,label:e.text,source:`checklist`,state:uk(e.status)})),n=(e.subagents??[]).filter(e=>!NO(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,stoppable:e.status===`running`&&e.stoppable===!0||void 0}));return[...t,...n]}function fk(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 pk(e){return e.total===0?void 0:`${e.done}/${e.total}`}function mk(e,t){if(t===`none`)return[];let n=dk(e);return t===`all`?n:n.filter(e=>e.state===`running`||e.state===`pending`)}function hk(e,t){return e instanceof Error?e.message:t??String(e)}function gk(e,t){return e.startsWith(`/`)?_k(e):t?_k(`${t}/${e}`):void 0}function _k(e){let t=[];for(let n of e.split(`/`))n!==``&&n!==`.`&&(n===`..`?t.pop():t.push(n));return`/${t.join(`/`)}`}var vk=`2026-09-29`,yk=`List rates as of ${vk}. 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.`,bk=.005,xk=1e6,Sk=864e5,Ck=[`input`,`output`,`cacheWrite5m`,`cacheWrite1h`,`cacheRead`];function wk(e,t,n){return{input:e,output:t,cacheWrite5m:e*1.25,cacheWrite1h:e*2,cacheRead:n??e*.1}}function Tk(e,t,n){return{input:e,output:t,cacheWrite5m:e,cacheWrite1h:e,cacheRead:n}}var Ek={"claude-fable-5-1":wk(10,50,.25),"claude-fable-5":wk(10,50),"claude-mythos-5-1":wk(10,50,.25),"claude-mythos-5":wk(10,50),"claude-opus-5-5":wk(4,20,.2),"claude-opus-5":wk(5,25),"claude-opus-4-8":wk(5,25),"claude-opus-4-7":wk(5,25),"claude-opus-4-6":wk(5,25),"claude-opus-4-5":wk(5,25),"claude-sonnet-5-5":wk(2,10),"claude-sonnet-5":wk(2,10),"claude-sonnet-4-6":wk(3,15),"claude-sonnet-4-5":wk(3,15),"claude-haiku-4-5":wk(1,5),"gpt-6-astra":Tk(10,50,1),"gpt-6-sol":Tk(2,10,.2),"gpt-6-luna":Tk(.1,.5,.01),"gpt-5.6-sol":Tk(4,20,.4),"gpt-5.6-terra":Tk(2,12,.2),"gpt-5.6-luna":Tk(.2,1.2,.02),"gpt-5.5":Tk(5,30,.5),"gpt-5.4":Tk(2.5,15,.25),"gpt-5.2":Tk(1.75,14,.175),"gpt-5.1":Tk(1.25,10,.125),"gpt-5":Tk(1.25,10,.125)},Dk=Ek;function Ok(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 Ck){let r=t[e];if(typeof r!=`number`||!Number.isFinite(r)||r<0)return;n[e]=r}return n}function kk(e,t=Ek){let n={},r=[];if(typeof e==`object`&&e)for(let[t,i]of Object.entries(e)){let e=Ok(i),a=Nk(t);if(!e||a===``){r.push(t);continue}n[a]=e}return{pricing:{...t,...n},overrides:n,dropped:r}}function Ak(){return Dk}function jk(e,t=vk){let n=Date.parse(t);return Number.isFinite(n)?Math.floor((e-n)/Sk):0}function Mk(e,t=vk){let n=jk(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 Nk(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 Pk(e,t=Ak()){return e?t[Nk(e)]:void 0}function Fk(e){return e.input+e.output+e.cacheWrite5m+e.cacheWrite1h+e.cacheRead}function Ik(e){return Object.entries(e).filter(([,e])=>e.costBasis===`unknown`).map(([e])=>Nk(e))}function Lk(e){return{input:0,output:0,cacheWrite:0,cacheRead:0,total:0,unpriced:!0,unpricedTokens:e,unpricedShare:+(e>0)}}function Rk(e,t,n=Ak()){let r=Pk(t,n);if(!r)return Lk(Fk(e));let i=e.input/xk*r.input,a=e.output/xk*r.output,o=e.cacheWrite5m/xk*r.cacheWrite5m+e.cacheWrite1h/xk*r.cacheWrite1h,s=e.cacheRead/xk*r.cacheRead;return{input:i,output:a,cacheWrite:o,cacheRead:s,total:i+a+o+s,unpriced:!1,unpricedTokens:0,unpricedShare:0}}function zk(e,t=Ak()){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=Rk(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 Bk=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`)`,`]`,`}`,`"`,`'`]),Vk=/^[\p{L}\p{N}][\p{L}\p{N}\-_]*$/u;function Hk(e,t){return(e??``).normalize(`NFKC`).replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/^-+|-+$/g,``)||t.slice(0,8)}function Uk(e){return e.normalize(`NFKC`).toLowerCase().replace(/[_\s]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function Wk(e){return e.length>0&&e.length<=64&&Vk.test(e)}var Gk={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 Kk(e,t){return qk(t?.[e]??Gk[e],e)}function qk(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 Jk=[`peers_send`,`mcp__workerdeck__peers_send`];function Yk(e){return Jk.includes(e)}function Xk(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 Zk=9e5;function Qk(e,t){return e.inferredReset||e.updatedAt===void 0?!1:t-e.updatedAt>Zk}function $k(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 eA(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))t[n]=r.info;return t}var tA=2592e6,nA=6e4;function rA(e,t){return`${e}:${t}`}var iA=class{#e;#t;constructor(e){this.#e=e,this.#t={...e.read()}}get(e,t){return this.#t[rA(e,t)]}all(){return this.#t}mark(e,t,n,r=Date.now()){let i=rA(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<nA?!1:(this.#t[i]=o,this.#e.write(this.#n(r)),!0)}forget(e,t){let n=rA(e,t);n in this.#t&&(delete this.#t[n],this.#e.write(this.#t))}#n(e){let t=e-tA;for(let[e,n]of Object.entries(this.#t))n.seenAt<t&&delete this.#t[e];return this.#t}};function aA(e,t){return!e||t.proseCount===void 0?0:Math.max(0,t.proseCount-(e.prose??t.proseCount))}function oA(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 sA=`interactive output, no preview`,cA={claude:{interactiveApprovals:!0,permissionModes:[`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`],defaultPermissionMode:`default`,resume:!0,resumeBackfill:!0,forkSession:!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,forkSession:!1,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,forkSession:!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 lA(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 uA=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 dA(e){return Math.min(500*2**e,1e4)}var fA=class{sessionId;#e;#t;#n;#r=new uA;#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=dA(this.#o++);this.#r.emit(`reconnectAttempt`,this.#o),this.#c=setTimeout(()=>this.#u(),e)},e.onerror=()=>{}}},pA=class{#e;#t;#n;#r=new uA;#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=dA(this.#a++);this.#o=setTimeout(()=>this.#s(),e)},e.onerror=()=>{}}};function mA(e,t,n,r=!1,i=!1){let a=`afterSeq=${n}`+(r?`&truncateResults=1`:``)+(i?`&imageRefs=1`:``);return`${e.replace(/^http/,`ws`)}/sessions/${encodeURIComponent(t)}/ws?${a}`}function hA(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 gA(e){let t=hA(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 _A(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,n,r,a)=>i(mA(t,e,n,r,a)),buildQueueWsUrl:()=>i(`${r}/queue/ws`)}}var vA=class extends Error{status;constructor(e,t){super(e),this.name=`WorkerDeckError`,this.status=t}},yA=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.#s(`POST`,`/sessions`,`session`,e)}async listSessions(){return await this.#s(`GET`,`/sessions`,`sessions`)}async getSession(e){return await this.#s(`GET`,this.#i(e),`session`)}async updateSession(e,t){return await this.#s(`PATCH`,this.#i(e),`session`,t)}async deleteSession(e){return await this.#s(`DELETE`,this.#i(e),`session`)}async listSessionFiles(e){return await this.#s(`GET`,this.#i(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}${this.#i(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}${this.#i(e,`/attachments/${encodeURIComponent(t)}`)}`}producedFileUrl(e,t){return`${this.#e.baseUrl}${this.#i(e,`/produced/${encodeURIComponent(t)}`)}`}async readProducedFile(e,t){return await this.#o(this.producedFileUrl(e,t),`produced file request failed`)}projectIconUrl(e){return`${this.#e.baseUrl}${this.#i(e,`/project/icon`)}`}async projectIcon(e){return await this.#o(this.projectIconUrl(e),`project icon request failed`)}async listMcpServers(e){return await this.#s(`GET`,this.#i(e,`/mcp`),`servers`)}async mcpServerAction(e,t,n){let r=this.#i(e,`/mcp/${encodeURIComponent(t)}`);return await this.#s(`POST`,r,`servers`,{action:n})}sessionFileUrl(e,t){let n=t.split(`/`).filter(Boolean).map(encodeURIComponent).join(`/`);return`${this.#e.baseUrl}${this.#i(e,`/files/${n}`)}`}async resolvePermission(e,t,n){await this.#c(`POST`,this.#i(e,`/permissions/${encodeURIComponent(t)}`),n)}async submitExecutionResult(e,t){return await this.#c(`POST`,`/executions/${encodeURIComponent(e)}/result`,t)}async listProfiles(){return await this.#c(`GET`,`/profiles`)}async getProfile(e){return await this.#c(`GET`,`/profiles/${encodeURIComponent(e)}`)}async createProfile(e){return await this.#s(`POST`,`/profiles`,`profile`,e)}async updateProfile(e,t){return await this.#s(`PATCH`,`/profiles/${encodeURIComponent(e)}`,`profile`,t)}async deleteProfile(e){await this.#c(`DELETE`,`/profiles/${encodeURIComponent(e)}`)}async listSdkSessions(e){let t=bA({dir:e?.dir||void 0,limit:e?.limit,offset:e?.offset,profile:e?.profile||void 0});return await this.#s(`GET`,`/sdk-sessions${t}`,`sdkSessions`)}async listHostRoots(){return await this.#c(`GET`,`/fs/roots`)}async meta(){return await this.#c(`GET`,`/meta`)}async listHostDir(e){return await this.#c(`GET`,`/fs/list${bA({path:e})}`)}async findHostFiles(e,t=``,n){return await this.#c(`GET`,`/fs/find${bA({path:e,q:t,limit:n})}`)}async readHostFile(e){return await this.#c(`GET`,`/fs/read${bA({path:e})}`)}async writeHostFile(e){return await this.#c(`PUT`,`/fs/write`,e)}async createJob(e){return await this.#s(`POST`,`/jobs`,`job`,e)}async listJobs(){return await this.#s(`GET`,`/jobs`,`jobs`)}async getJob(e){return await this.#s(`GET`,`/jobs/${encodeURIComponent(e)}`,`job`)}async cancelJob(e){return await this.#s(`DELETE`,`/jobs/${encodeURIComponent(e)}`,`job`)}async queueStats(){return await this.#s(`GET`,`/queue`,`stats`)}async listShells(e){return await this.#s(`GET`,this.#i(e,`/shells`),`shells`)}async getShell(e,t){return await this.#s(`GET`,this.#a(e,t),`shell`)}async shellOutput(e,t,n){let r=bA({view:n?.view||void 0,tail:n?.tail});return await(await this.#r(`${this.#e.baseUrl}${this.#a(e,t,`/output${r}`)}`,{headers:{...this.#e.headers}},`shell output request failed`)).text()}async killShell(e,t){return await this.#s(`POST`,this.#a(e,t,`/kill`),`shell`)}async stopTask(e,t){await this.#c(`POST`,this.#i(e,`/tasks/${encodeURIComponent(t)}/stop`))}async setShellAgentWrite(e,t,n){return await this.#s(`POST`,this.#a(e,t,`/agent-write`),`shell`,{enabled:n})}attach(e,t){return new fA(this,e,t)}attachQueue(e){return new pA(this,e)}openSocket(e,t,n=!1,r=!1){let i=this.#e.buildWsUrl?.(e,t,n,r)??mA(this.#e.baseUrl,e,t,n,r);return new this.#n(i)}async toolResult(e,t,n,r){return await this.#c(`GET`,this.#i(e,`/events/${t}/result${bA({toolUseId:n,imageRefs:r?.imageRefs?1:void 0})}`))}async toolResultImage(e,t,n,r){let i=`${this.#e.baseUrl}${this.#i(e,`/events/${t}/result${bA({toolUseId:n,part:r})}`)}`;return await this.#o(i,`image part request failed`)}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 vA((await r.json().catch(()=>({}))).error??`${n} with ${r.status}`,r.status);return r}#i(e,t=``){return`/sessions/${encodeURIComponent(e)}${t}`}#a(e,t,n=``){return this.#i(e,`/shells/${encodeURIComponent(t)}${n}`)}async#o(e,t){return await(await this.#r(e,{headers:{...this.#e.headers}},t)).blob()}async#s(e,t,n,r){return(await this.#c(e,t,r))[n]}async#c(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 vA(i.error??`${e} ${t} failed with ${r.status}`,r.status);return i}};function bA(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!==void 0&&t.set(n,String(r));return t.size>0?`?${t.toString()}`:``}var xA={status:`starting`,capabilities:cA.claude,items:[],pendingApprovals:[],totalCostUsd:0,lastSeq:0},SA=`streaming`,CA=`streaming-thinking`,wA=/^<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>$/,TA=/<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>/g,EA=`<local-command-caveat>`,DA=/^\[\.\.\. more output \.\.\.\]$/,OA=/^\[(exit -?\d+|killed|timed out|ended|failed to start)[^\]]*\]$/;function kA(e,t){let n=(wA.exec(t.trim())?.[2]??t).split(`
45
45
  `);n[0]?.startsWith(`$ `)&&n.shift(),e.status===`exited`&&n.length>0&&OA.test(n[n.length-1])&&n.pop();let r=!1;return{text:n.filter(e=>!DA.test(e)||(r=!0,!1)).join(`
46
46
  `).trimEnd(),truncated:r}}function AA(e,t,n,r){let i=kA(t,n);return{kind:`shell`,id:e,shell:t,text:i.text,truncated:i.truncated,...r?.expanded!==void 0&&{expanded:r.expanded}}}function jA(e,t){return e.find(e=>e.kind===`shell`&&e.shell.id===t)}var MA=/<command-name>([\s\S]*?)<\/command-name>/,NA=/<command-args>([\s\S]*?)<\/command-args>/;function PA(e){return BA(e).some(e=>e.type===`text`&&e.text.trimStart().startsWith(EA))}function FA(e){return e==null?SA:`${SA}:${e}`}function IA(e){return e==null?CA:`${CA}:${e}`}function LA(e){return e.kind===`assistant_text`&&e.id.startsWith(SA)||e.kind===`thinking`&&e.id.startsWith(CA)}function RA(e){return e===void 0?``:typeof e==`string`?e:e.map(e=>typeof e.text==`string`?e.text:``).filter(Boolean).join(`
47
47
  `)}function zA(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 BA(e){return typeof e==`string`?[{type:`text`,text:e}]:e}function VA(e){if(e.type===`text`)return e.value;try{return JSON.stringify(e.value)}catch{return String(e.value)}}function HA(e){let t=MA.exec(e)?.[1]?.trim();if(!t)return;let n=NA.exec(e)?.[1]?.trim();return n?`${t} ${n}`:t}function UA(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r];if(i?.id===n&&i.kind===t)return r}return-1}function WA(e,t,n){if(t===-1)return[...e,n];let r=[...e];return r[t]=n,r}function GA(e,t){return WA(e,e.findIndex(e=>e.id===t.id&&e.kind===t.kind),t)}function KA(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??cA[n??`claude`],totalCostUsd:e.totalCostUsd||(t.totalCostUsd??0),costUsd:e.costUsd??t.costUsd,usageByModel:e.usageByModel??t.usageByModel,session:t}}function qA(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 JA(e,t,n){let r=jA(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 YA(e,t,n){let r=jA(e.items,t);return r?{...e,items:e.items.map(e=>e===r?{...r,expanded:n,missing:void 0}:e)}:e}function XA(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:GA(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 BA(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:RA(r.content),isError:i,...r.truncated&&{truncated:!0,totalChars:r.total_chars,sourceSeq:t.seq},...zA(r.content,t.seq)&&{images:zA(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=wA.exec(r.trim());if(t.shell){let n=e.find(e=>e.kind===`shell`&&e.id===i);e=GA(e,AA(i,t.shell,r,n))}else if(a)e=GA(e,{kind:`notice`,id:i,level:a[1]===`stderr`?`error`:`info`,text:a[2].trim()});else if(r.trimStart().startsWith(EA)){let t=0;for(let n of r.matchAll(TA))e=GA(e,{kind:`notice`,id:`${i}#${t++}`,level:n[1]===`stderr`?`error`:`info`,text:n[2].trim()})}else(!t.synthetic||PA(t.message.content))&&(e=GA(e,{kind:`user`,id:t.uuid??`user-${t.seq}`,text:HA(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=FA(t.parentToolUseId),r=IA(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 BA(t.message.content).forEach((e,n)=>{let r=`${t.uuid}-${n}`;if(e.type===`text`)a=GA(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=GA(a,{kind:`thinking`,id:r,text:n,parentToolUseId:t.parentToolUseId})}else if(e.type===`tool_use`){let n=e;a=GA(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=FA(t.parentToolUseId),i=UA(n.items,`assistant_text`,r),a={kind:`assistant_text`,id:r,text:((i===-1?void 0:n.items[i])?.text??``)+(e.delta.text??``),streaming:!0,parentToolUseId:t.parentToolUseId};return{...n,items:WA(n.items,i,a)}}if(e.delta?.type===`thinking_delta`){let r=IA(t.parentToolUseId),i=UA(n.items,`thinking`,r),a=((i===-1?void 0:n.items[i])?.text??``)+(e.delta.thinking??``);if(a.trim()===``)return n;let o={kind:`thinking`,id:r,text:a,parentToolUseId:t.parentToolUseId};return{...n,items:WA(n.items,i,o)}}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(!LA(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:VA(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 ZA=5,QA=new Map;function $A(e,t){return`${e.identityKey}\u0000${t}`}function ej(e){return QA.get(e)}function tj(e,t){if(QA.delete(e),QA.set(e,t),QA.size>ZA){let e=QA.keys().next().value;e!==void 0&&QA.delete(e)}}function nj(e){QA.delete(e)}function rj(e,t){return`${e}:${t}`}function ij(e){let t=rj(e.resyncSeq,e.key),n=e.cacheEnabled&&!e.skipCache?e.warm:void 0,r=e.seededFor!==t,i=r?n??xA:e.current;return{held:i,seed:r,seedToken:t,...i.lastSeq>0?{afterSeq:i.lastSeq}:{}}}function aj(e){return e.cacheEnabled&&!e.skipCache&&e.parting.lastSeq>0&&e.parting.session!==void 0}function oj(e,t){return t.type===`transcript_seed`?t.state:t.type===`transcript_hydrate_result`?qA(e,t.toolUseId,t.text):t.type===`transcript_hydrate_shell`?JA(e,t.shellId,t.shell):t.type===`transcript_hydrate_shell_output`?YA(e,t.shellId,t.text):t.type===`attached`?KA(e,t.session):XA(e,t)}var sj=3;function cj(e){return e.replayingFrom===0&&e.session.lastSeq>0?e.session.lastSeq:void 0}function lj(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 uj=1500;function dj(e,t,n){let[r,i]=(0,v.useReducer)(oj,void 0,()=>(n?.cacheTranscript!==!1&&t!==void 0?ej($A(e,t)):void 0)??xA),[a,o]=(0,v.useState)(`reconnecting`),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(Ek),[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)(rj(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=ij({resyncSeq:h,key:r,seededFor:C.current,current:S.current,cacheEnabled:n,skipCache:w.current,warm:ej(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(lj(e,S.current)){l(),nj(r),w.current=!0,g(e=>e+1);return}i(e),m(cj(e)),c(e.protocolVersion===1?void 0:e.protocolVersion),u(e.shell===!0),f(kk(e.pricingOverrides).pricing)}),p=s.on(`connectionChange`,e=>o(e?`live`:`reconnecting`)),_=s.on(`reconnectAttempt`,e=>o(e>=sj?`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;aj({cacheEnabled:n,skipCache:w.current,parting:e})&&tj(r,e)}},[e,t,h]),(0,v.useEffect)(()=>{if(p===void 0)return;let e=setTimeout(()=>m(void 0),uj);return()=>clearTimeout(e)},[p]),(0,v.useEffect)(()=>{p!==void 0&&r.lastSeq>=p&&m(void 0)},[p,r.lastSeq]);let T=pj(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:RA(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(e){return fj(e)&&i({type:`transcript_hydrate_shell`,shellId:n,shell:void 0}),!1}},[e,t]),M=(0,v.useCallback)(async n=>{let r=A.current;if(!t||r.has(n))return!1;r.add(n);try{let r=await e.getShell(t,n);return i({type:`transcript_hydrate_shell`,shellId:n,shell:r}),!0}catch(e){return fj(e)?i({type:`transcript_hydrate_shell`,shellId:n,shell:void 0}):r.delete(n),!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]),P=(0,v.useCallback)(async(n,r)=>{if(!t)return!1;try{let a=await e.setShellAgentWrite(t,n,r);return i({type:`transcript_hydrate_shell`,shellId:n,shell:a}),!0}catch{return!1}},[e,t]),F=(0,v.useMemo)(()=>({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()}),[]);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:_,...F,reconnectNow:O,loadFullResult:k,loadShellOutput:j,verifyShell:M,killShell:N,setShellAgentWrite:P}),[r,E,a,D,s,l,d,T,_,F,O,k,j,M,N,P])}function fj(e){return e instanceof vA&&e.status===404}function pj(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 mj=new Map;function hj(e,t){return`${e.identityKey}\u0000${t}`}function gj(e){return mj.get(e)}function _j(e,t){t!==void 0&&mj.set(e,t)}var vj=`workerdeck.drafts.v1`,yj=20,bj;function xj(){try{return globalThis.localStorage}catch{return}}function Sj(){if(bj)return bj;bj={};let e=xj()?.getItem(vj);if(e)try{let t=JSON.parse(e);for(let[e,n]of Object.entries(t))typeof n?.text==`string`&&typeof n.savedAt==`number`&&(bj[e]=n)}catch{}return bj}function Cj(e){let t=Object.entries(e);if(t.length>yj){t.sort((e,t)=>t[1].savedAt-e[1].savedAt);for(let[n]of t.slice(yj))delete e[n]}try{xj()?.setItem(vj,JSON.stringify(e))}catch{}}function wj(e,t){return`${e.identityKey}\u0000${t}`}function Tj(e){return Sj()[e]?.text??``}function Ej(e,t,n=Date.now()){let r=Sj();if(t.trim()===``){if(r[e]===void 0)return;delete r[e]}else r[e]={text:t,savedAt:n};Cj(r)}var Dj=new Set([`application/json`,`application/xml`,`application/yaml`,`application/x-yaml`,`application/toml`,`application/javascript`,`application/typescript`,`application/x-sh`,`application/sql`]),Oj=1568;function kj(e){let t=e.split(`;`)[0].trim().toLowerCase();if(t.startsWith(`image/`))return`image`;if(t===`application/pdf`)return`pdf`;if(t.startsWith(`text/`)||Dj.has(t))return`text`}function Aj(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 Nj(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:hk(e,`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=kj(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:jj(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 jj(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 Mj=globalThis;async function Nj(e){let t=e.type||`application/octet-stream`,{createImageBitmap:n,document:r}=Mj;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<=Oj)return i.close(),{body:e,mediaType:t};let o=Oj/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 Pj=/^[A-Za-z0-9\-_.:]+$/,Fj=Bk;function Ij(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&&Fj.has(e[s-1]);)s--;let c=e.slice(o.index+1,s);c&&(a!==`command`||Pj.test(c))&&(a!==`skill`||r.has(c))&&(a!==`session`||Wk(c)&&i.has(Uk(c)))&&n.push({kind:a,start:o.index,end:s,text:e.slice(o.index,s)})}return n}function Lj(){let e=(0,v.useRef)(!0);return(0,v.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Rj(e){return e instanceof vA&&e.status===404}function zj(e,t,{enabled:n=!0,pollMs:r}={}){let[i,a]=(0,v.useState)(),[o,s]=(0,v.useState)(),[c,l]=(0,v.useState)(n),u=(0,v.useRef)(0),d=(0,v.useRef)(e);d.current=e;let f=(0,v.useCallback)(async()=>{let e=++u.current;l(!0);try{let t=await d.current();e===u.current&&(a(()=>t),s(void 0))}catch(t){e===u.current&&s(t)}finally{e===u.current&&l(!1)}},[]);return(0,v.useEffect)(()=>{a(void 0),s(void 0)},t),(0,v.useEffect)(()=>{if(!n){u.current++,l(!1);return}f();let e=r?setInterval(()=>void f(),r):void 0;return()=>{u.current++,clearInterval(e)}},[n,r,f,...t]),{data:i,error:o,loading:c,reload:f,setData:a}}function Bj(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 Vj(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 Hj(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 Rj(e)&&r(!0),[]}},[e,t,n]);return{available:!!t&&!n,search:a}}function Uj(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 Wj(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),Rj(e)){s(!0);return}l(hk(e,`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=Vj(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?Bj(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:[]},Kj=2e4;function qj(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&&Rj(e)&&o(!0)}).finally(()=>{s.current&&(t=setTimeout(r,Kj))})};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:Hk(e.title,e.id),label:RO(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=>Uk(e.slug))}},[n,t,r,a])}var Jj=new Map,Yj=new Set,Xj=new Set;function Zj(e,t){let[n,r]=(0,v.useState)(()=>Object.fromEntries(Jj));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(Jj.has(a)||Yj.has(a)||Xj.has(a))continue;let o=t(i.hostId);o&&(Yj.add(a),o.projectIcon(i.info.id).then(e=>{Jj.set(a,URL.createObjectURL(e)),n&&r(Object.fromEntries(Jj))}).catch(()=>{Xj.add(a)}).finally(()=>Yj.delete(a)))}return()=>{n=!1}},[e,t]),n}var Qj=`workerdeck.bookmarks.v1`,$j=Object.freeze([]),eM=new Set,tM,nM;function rM(){try{return globalThis.localStorage??void 0}catch{return}}function iM(){let e=globalThis.window;return typeof e?.addEventListener==`function`?e:void 0}function aM(){try{let e=rM()?.getItem(Qj);if(e==null)return{};let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))Array.isArray(r)&&(n[e]=r.filter(e=>typeof e==`string`));return n}catch{return}}function oM(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function sM(e){let t=tM??{},n={};for(let[r,i]of Object.entries(e)){let e=t[r];n[r]=e&&oM(e,i)?e:i}tM=n}function cM(){return tM===void 0&&sM(aM()??{}),tM??{}}function lM(){for(let e of eM)e()}function uM(e){return cM()[e]??$j}function dM(e,t){let n=aM()??cM(),r=n[e]??$j,i=r.includes(t)?r.filter(e=>e!==t):[...r,t],a={...n,[e]:i};i.length===0&&delete a[e];try{rM()?.setItem(Qj,JSON.stringify(a))}catch{}sM(a),lM()}function fM(e){if(e.key!==null&&e.key!==`workerdeck.bookmarks.v1`)return;let t=aM();t&&(sM(t),lM())}function pM(e){eM.add(e);let t=iM();return eM.size===1&&t&&(t.addEventListener(`storage`,fM),nM=()=>t.removeEventListener(`storage`,fM)),()=>{eM.delete(e),eM.size===0&&(nM?.(),nM=void 0)}}var mM=Object.freeze([]);function hM(e){let t=(0,v.useCallback)(()=>e?uM(e):mM,[e]),n=(0,v.useSyncExternalStore)(pM,t,()=>mM),r=(0,v.useCallback)(t=>{e&&dM(e,t)},[e]);return(0,v.useMemo)(()=>({bookmarks:n,toggle:r}),[n,r])}function gM(e,t){let n=t?wj(e,t):void 0;return{initialText:(0,v.useMemo)(()=>n?Tj(n):``,[n]),save:(0,v.useCallback)(e=>{n&&Ej(n,e)},[n]),clear:(0,v.useCallback)(()=>{n&&Ej(n,``)},[n])}}function _M(e,t,n={}){let{intervalMs:r=6e4,enabled:i=!0}=n,a=t?hj(e,t):void 0,[o,s]=(0,v.useState)(()=>a?gj(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?gj(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&&_j(a,i),s(i),l(r?.spend)}).catch(e=>{!n&&h.current&&Rj(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 vM(e,t){let{data:n,error:r,loading:i}=zj(()=>e.getSession(t),[e,t],{enabled:!!t});return{info:n,loading:i,error:r===void 0?void 0:hk(r,`Session not found`)}}function yM(e){return e.draft!==void 0&&e.draft!==e.content}function bM(e){return e.draft??e.content??``}var xM={files:[]};function SM(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:wM(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 xM;case`activate`:return e.files.some(e=>e.path===t.path)?e.activePath===t.path?e:{...e,activePath:t.path}:e;case`loaded`:return CM(e,t.path,()=>({path:t.path,name:wM(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 CM(e,t.path,e=>({...e,status:`error`,error:t.error}));case`edit`:return CM(e,t.path,e=>e.status===`ready`?{...e,draft:t.content}:e);case`revert`:return CM(e,t.path,e=>({...e,draft:void 0,saveError:void 0,conflict:!1}));case`saveStart`:return CM(e,t.path,e=>({...e,saving:!0,saveError:void 0,conflict:!1}));case`saved`:return CM(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 CM(e,t.path,e=>({...e,saving:!1,saveError:t.error,conflict:t.conflict??!1}));case`dismissConflict`:return CM(e,t.path,e=>({...e,conflict:!1,saveError:void 0}))}}function CM(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 wM(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;return t.slice(t.lastIndexOf(`/`)+1)||t||e}function TM(e){let[t,n]=(0,v.useReducer)(SM,xM),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:hk(t,`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:hk(t,`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 vA&&e.status===409;n({type:`saveFailed`,path:t,conflict:r,error:r?`This file changed on disk since you opened it.`:hk(e,`Could not save that file`)})}},[e]),_=(0,v.useCallback)(async e=>{let t=a.current.files.find(t=>t.path===e);t&&!t.saving&&yM(t)&&(n({type:`saveStart`,path:e}),await g(e,bM(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=bM(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:hk(e,`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(yM),[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 EM=`modulepreload`,DM=function(e){return`/`+e},OM={},kM=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=DM(t,n),t=s(t),t in OM)return;OM[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`:EM,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 AM(e,t={}){let n=new Map,r,i=!1,a=e=>t.onExecution?.(e),o=(t,n,r)=>{let{executionId:i,toolName:o}=t;r.ok?(e.sendToolCallResult(i,{type:`json`,value:r.value},r.logs),a({executionId:i,toolName:o,status:`settled`,startedAt:n,endedAt:Date.now()})):(e.sendToolCallError(i,r.reason,r.error,r.logs),a({executionId:i,toolName:o,status:`failed`,reason:r.reason,startedAt:n,endedAt:Date.now()}))},s=async(e,t,r)=>{let s=new AbortController;n.set(e.executionId,s),a({executionId:e.executionId,toolName:e.toolName,status:`running`,startedAt:t});let c;try{c=await r(s.signal)}catch(e){c={ok:!1,reason:`host_error`,error:hk(e)}}try{!i&&n.has(e.executionId)&&o(e,t,c)}finally{n.delete(e.executionId)}},c=(e,t,n)=>s(e,n,async n=>{let r=await t(e.input,{executionId:e.executionId,signal:n});return`error`in r?{ok:!1,reason:r.reason??`client_error`,error:r.error}:{ok:!0,value:r.value}}),l=(e,n,i)=>s(e,i,async i=>{let a=await kM(()=>import(`./src-BG3FCqin.js`),[]),o=a.createVfs(e.vfsSeed),s=Math.min(e.limits?.timeoutMs??1/0,t.timeoutMs??5e3),c=Math.min(e.limits?.memoryLimitBytes??1/0,t.memoryLimitBytes??67108864),l;t.execute?l=await t.execute({script:n,vfs:o,timeoutMs:s,memoryLimitBytes:c,signal:i}):(r??=(t.loadEngine??jM)(),l=await a.runScript(await r,{script:n,vfs:o,timeoutMs:s,memoryLimitBytes:c,signal:i,fetchText:t.fetchText}));let u=l.logs.map(e=>`[${e.level}] ${e.text}`);return l.ok?{ok:!0,value:l.value,logs:u}:{ok:!1,reason:l.reason,error:l.error,logs:u}}),u=async e=>{let n=Date.now(),r=t.clientTools?.[e.toolName];if(r)return c(e,r,n);if(!(t.tools??[`eval_script`]).includes(e.toolName)){o(e,n,{ok:!1,reason:`unsupported_tool`,error:`this client does not execute '${e.toolName}'`});return}let i=e.input?.script;if(typeof i!=`string`){o(e,n,{ok:!1,reason:`invalid_input`,error:"expected a string `script` input"});return}return l(e,i,n)},d=e.on(`toolCallRequest`,e=>void u(e)),f=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,d(),f();for(let e of n.values())e.abort();n.clear()}}}async function jM(){let[e,t]=await Promise.all([kM(()=>import(`./src-BG3FCqin.js`),[]),kM(()=>import(`./dist-C23qbS5Y.js`),[])]);return e.loadEngine(t)}function MM(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=AM(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 NM(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 PM(e){if(!e.any)return;let t=[];if(e.turns>0?t.push(FM(e.turns,`turn`)):e.replies>0&&t.push(FM(e.replies,`reply`,`replies`)),e.tools>0){let n=e.toolNames.slice(0,3).join(`, `),r=e.toolNames.length-3;t.push(`${FM(e.tools,`tool call`)}${n?` (${n}${r>0?`, +${r}`:``})`:``}`)}return e.files>0&&t.push(FM(e.files,`file`)),e.errors>0&&t.push(FM(e.errors,`error`)),e.pending>0&&t.push(`${FM(e.pending,`approval`)} waiting`),t.join(` · `)}function FM(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function IM(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 LM={command:0,client:1,skill:2};function RM(e){return e.replace(/\s*\(MCP\)$/i,``)}function zM(e){return`$${e.name}`}function BM(e){let t=zM(e),n=(e.defaultPrompt??``).split(t).join(` `).replace(/\s+/g,` `).trim();return n?` ${n} `:` `}function VM(e){return zM(e)+BM(e)}function HM(e){let t=[],n=new Set;for(let r of e.commands??[]){let e=RM(r.name);if(!n.has(e)){n.add(e);for(let e of r.aliases??[])n.add(RM(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 UM(e){return e.kind===`skill`?[e.name,e.label,...e.name.split(/[-:_]/)]:[e.name,...e.kind===`command`?e.aliases??[]:[],...e.name.split(`:`)]}function WM(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 GM(e,t){let n=[];return t.forEach((t,r)=>{if(t.kind===`skill`&&!t.enabled)return;let i=WM(e,UM(t));i>0&&n.push({score:i,index:r,row:t})}),n.sort((e,t)=>t.score-e.score||LM[e.row.kind]-LM[t.row.kind]||e.index-t.index),n.map(({row:e})=>e)}function KM(e,t){let n=e.trim();if(!n)return[...t];let r=[];return t.forEach((e,t)=>{let i=WM(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 qM(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 JM(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:VM(e.skill)}:{kind:e.kind,name:e.name,label:`/${e.name}`,description:e.description,enabled:!0,insertText:`/${e.name} `})}function YM({capabilities:e,hasModels:t,setModel:n,setPermissionMode:r,clearContext:i,openPanel:a}){let o=e.permissionModes,s=[];return t&&s.push({name:`model`,description:`Switch the model for this session`,argumentHint:`<model>`,requiresArgs:!0,run:e=>{let t=e.split(/\s+/)[0];return t?(n(t),!0):!1}}),o.length>1&&s.push({name:`permissions`,description:`Set the permission mode (${o.join(`, `)})`,argumentHint:`<mode>`,requiresArgs:!0,run:e=>{let t=e.split(/\s+/)[0];return o.includes(t)?(r(t),!0):!1}}),e.clearContext&&s.push({name:`clear`,description:`Clear the conversation - the session keeps running and the old one stays resumable`,run:()=>(i(),!0)}),e.mcpStatus&&s.push({name:`mcp`,description:`MCP servers and their status`,run:()=>(a(`mcp`),!0)}),e.contextUsage&&s.push({name:`context`,description:`Context window usage`,run:()=>(a(`context`),!0)}),s.push({name:`status`,description:`Session details`,run:()=>(a(`info`),!0)}),e.rateLimits&&s.push({name:`usage`,description:`Rate limits and spend`,run:()=>(a(`usage`),!0)}),e.skillsList&&s.push({name:`skills`,description:`Browse the skills this session can use`,run:()=>(a(`skills`),!0)}),s}var XM=(0,v.createContext)(`cards`);function ZM({value:e,children:t}){return(0,H.jsx)(XM.Provider,{value:e,children:t})}function QM(){return(0,v.useContext)(XM)}var $M={terminal:{className:`term-row-gap`,px:18},cards:{className:`pt-5`,px:20}},eN=`context compacted · earlier turns summarised to fit the window`;function tN(e){return e.error?`context compaction failed · ${e.error}`:e.pending?`compacting context · summarising earlier turns to fit the window`:[eN,e.preTokens===void 0?void 0:e.postTokens===void 0?`from ${iN(e.preTokens)}`:`${iN(e.preTokens)} → ${iN(e.postTokens)}`,e.trigger===`auto`?`automatic`:void 0].filter(Boolean).join(` · `)}function nN(e){return e===void 0||Number.isNaN(e)?`-`:e===0?`$0.00`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function rN(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 iN(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function aN(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function oN(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 sN(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 cN(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 lN(e){if(e===`five_hour`)return 18e3;if(e.startsWith(`seven_day`))return 604800}function uN(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 dN(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 fN={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 pN(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=fN[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 mN(e){switch(e){case`Bash`:case`BashOutput`:case`KillShell`:case`shell_list`:case`shell_read`:case`shell_run`:case`shell_write`:case`shell_kill`:case`shell_request_write`:case`mcp__workerdeck__shell_list`:case`mcp__workerdeck__shell_read`:case`mcp__workerdeck__shell_run`:case`mcp__workerdeck__shell_write`:case`mcp__workerdeck__shell_kill`:case`mcp__workerdeck__shell_request_write`:return FS;case`Read`:return ry;case`Write`:return hS;case`Edit`:case`MultiEdit`:case`NotebookEdit`:return sx;case`Glob`:return hy;case`Grep`:return Xx;case`WebFetch`:return sv;case`WebSearch`:return ky;case`Task`:case`Agent`:return ZS;case`TodoWrite`:case`TaskCreate`:case`TaskUpdate`:case`TaskGet`:case`TaskList`:return pS;case`Skill`:return lS;case`AskUserQuestion`:return Cb;case`CodexCommand`:return FS;case`CodexFileChange`:return $v;case`CodexWebSearch`:return ky;case`CodexImageGeneration`:case`CodexImageView`:return Vy;default:return e.startsWith(`mcp__`)?Tx:pC}}function hN(e){return e===`Bash`||e===`CodexCommand`}function gN(e){switch(e){case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:case`Update`:case`CodexFileChange`:return!0;default:return!1}}var _N=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],vN=new Set,yN,bN=`⠿`;function xN(e){return _N[Math.floor(e/90)%_N.length]}function SN(){let e=xN(Date.now());if(e!==bN){bN=e;for(let e of vN)e()}}function CN(e){return vN.add(e),yN===void 0&&(bN=xN(Date.now()),yN=setInterval(SN,90)),()=>{vN.delete(e),vN.size===0&&yN!==void 0&&(clearInterval(yN),yN=void 0)}}function wN(){return TN}function TN(){}function EN(){return bN}function DN(){return`⠿`}function ON(){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 kN(e){let t=ON(),n=e&&!t;return(0,v.useSyncExternalStore)(n?CN:wN,n?EN:DN,DN)}var AN=(0,v.createContext)(void 0),jN=(0,v.createContext)(void 0);function MN({names:e,children:t}){return(0,H.jsx)(AN.Provider,{value:e,children:t})}function NN({names:e,children:t}){return(0,H.jsx)(jN.Provider,{value:e,children:t})}function PN({text:e,className:t}){let n=Ij(e,{skills:(0,v.useContext)(AN),sessions:(0,v.useContext)(jN)});if(n.length===0)return(0,H.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,H.jsx)(`span`,{className:U(`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,H.jsx)(`span`,{className:t,children:r.map((e,t)=>(0,H.jsx)(v.Fragment,{children:e},t))})}var FN={hover:!0,actions:!0,labels:!1},IN=(0,v.createContext)(FN);function LN(){return(0,v.useContext)(IN)}function RN(e){return e===!1?{hover:!1,actions:!1,labels:!1}:e===!0||e===void 0?FN:{...FN,...e}}function zN({value:e,children:t}){return(0,H.jsx)(IN.Provider,{value:e,children:t})}var BN=(0,v.createContext)(`below`);function VN({value:e,children:t}){return(0,H.jsx)(BN.Provider,{value:e,children:t})}function HN({actions:e,children:t,className:n,placement:r}){let{actions:i}=LN(),a=(0,v.useContext)(BN);return i?(0,H.jsxs)(`div`,{className:U(`term-hoverable`,n),"data-placement":r??a,children:[(0,H.jsx)(BN.Provider,{value:`below`,children:t}),(0,H.jsx)(`div`,{className:`term-actions`,children:e})]}):(0,H.jsx)(H.Fragment,{children:t})}function UN({icon:e,word:t,label:n,tone:r,pressed:i,filled:a,onPress:o}){let{labels:s}=LN();return(0,H.jsxs)(`button`,{type:`button`,className:`term-action`,title:n,"aria-label":n,"aria-pressed":i,"data-tone":r,onClick:e=>{e.stopPropagation(),o()},children:[(0,H.jsx)(e,{"aria-hidden":!0,className:`term-action-icon`,fill:a?`currentColor`:`none`}),s?(0,H.jsx)(`span`,{className:`term-action-word`,children:t}):null]})}var WN=(0,v.createContext)(void 0);function GN({value:e,children:t}){return(0,H.jsx)(WN.Provider,{value:e,children:t})}function KN({id:e}){let t=(0,v.useContext)(WN);if(!t)return null;let n=t.has(e);return(0,H.jsx)(UN,{icon:CS,filled:!0,word:n?`bookmarked`:`bookmark`,label:n?`Remove bookmark`:`Bookmark`,tone:n?`yellow`:void 0,pressed:n,onPress:()=>t.toggle(e)})}function qN({onOpen:e,label:t=`Open sub-agent`}){return(0,H.jsx)(UN,{icon:yb,word:`open`,label:t,onPress:e})}function JN({onOpen:e,label:t=`Open terminal`}){return(0,H.jsx)(UN,{icon:yS,word:`enter shell`,label:t,tone:`magenta`,onPress:e})}function YN({onKill:e,label:t=`Kill this shell`}){return(0,H.jsx)(UN,{icon:hC,word:`kill`,label:t,tone:`danger`,onPress:e})}function XN({granted:e,label:t,onToggle:n}){return(0,H.jsx)(UN,{icon:e?T_:C_,word:e?`agent can type`:`agent read-only`,label:t,tone:e?`yellow`:void 0,pressed:e,onPress:n})}function ZN({text:e,label:t=`Copy`}){let[n,r]=(0,v.useState)(!1);return(0,H.jsx)(UN,{icon:n?X_:Nv,word:n?`copied`:`copy`,label:t,onPress:()=>{mE(e).then(e=>{e&&(r(!0),setTimeout(()=>r(!1),1200))})}})}function QN({granted:e,className:t}){return(0,H.jsx)(e?T_:C_,{"aria-hidden":!0,className:t})}function $N({glyph:e,glyphTone:t,tone:n,bold:r,indent:i,columns:a,className:o,children:s,style:c,...l}){return(0,H.jsxs)(`div`,{className:U(`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,H.jsx)(`span`,{className:`term-gutter`,"data-tone":t,"aria-hidden":!0,children:e??` `}),(0,H.jsx)(`div`,{className:`term-body`,children:s})]})}function eP(){return(0,H.jsx)(`div`,{className:`term-blank`,"aria-hidden":!0})}function tP({className:e,...t}){return(0,H.jsx)(`div`,{className:U(`term-band`,e),...t})}function nP({tone:e,bold:t,className:n,...r}){return(0,H.jsx)(`span`,{"data-tone":e,"data-weight":t?`bold`:void 0,className:n,...r})}function rP(e){return e.startsWith(`+`)?`add`:e.startsWith(`-`)?`remove`:`context`}function iP(e){let t=e.oldStart,n=e.newStart,r=[];for(let i of e.lines){let e=rP(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 aP={context:` `,add:`+`,remove:`-`};function oP(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(`
49
+ `):[])r.current.has(e)||(r.current.add(e),s(e).catch(t=>{i.current&&n({type:`failed`,path:e,error:hk(t,`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:hk(t,`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 vA&&e.status===409;n({type:`saveFailed`,path:t,conflict:r,error:r?`This file changed on disk since you opened it.`:hk(e,`Could not save that file`)})}},[e]),_=(0,v.useCallback)(async e=>{let t=a.current.files.find(t=>t.path===e);t&&!t.saving&&yM(t)&&(n({type:`saveStart`,path:e}),await g(e,bM(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=bM(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:hk(e,`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(yM),[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 EM=`modulepreload`,DM=function(e){return`/`+e},OM={},kM=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=DM(t,n),t=s(t),t in OM)return;OM[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`:EM,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 AM(e,t={}){let n=new Map,r,i=!1,a=e=>t.onExecution?.(e),o=(t,n,r)=>{let{executionId:i,toolName:o}=t;r.ok?(e.sendToolCallResult(i,{type:`json`,value:r.value},r.logs),a({executionId:i,toolName:o,status:`settled`,startedAt:n,endedAt:Date.now()})):(e.sendToolCallError(i,r.reason,r.error,r.logs),a({executionId:i,toolName:o,status:`failed`,reason:r.reason,startedAt:n,endedAt:Date.now()}))},s=async(e,t,r)=>{let s=new AbortController;n.set(e.executionId,s),a({executionId:e.executionId,toolName:e.toolName,status:`running`,startedAt:t});let c;try{c=await r(s.signal)}catch(e){c={ok:!1,reason:`host_error`,error:hk(e)}}try{!i&&n.has(e.executionId)&&o(e,t,c)}finally{n.delete(e.executionId)}},c=(e,t,n)=>s(e,n,async n=>{let r=await t(e.input,{executionId:e.executionId,signal:n});return`error`in r?{ok:!1,reason:r.reason??`client_error`,error:r.error}:{ok:!0,value:r.value}}),l=(e,n,i)=>s(e,i,async i=>{let a=await kM(()=>import(`./src-BGDKT6fI.js`),[]),o=a.createVfs(e.vfsSeed),s=Math.min(e.limits?.timeoutMs??1/0,t.timeoutMs??5e3),c=Math.min(e.limits?.memoryLimitBytes??1/0,t.memoryLimitBytes??67108864),l;t.execute?l=await t.execute({script:n,vfs:o,timeoutMs:s,memoryLimitBytes:c,signal:i}):(r??=(t.loadEngine??jM)(),l=await a.runScript(await r,{script:n,vfs:o,timeoutMs:s,memoryLimitBytes:c,signal:i,fetchText:t.fetchText}));let u=l.logs.map(e=>`[${e.level}] ${e.text}`);return l.ok?{ok:!0,value:l.value,logs:u}:{ok:!1,reason:l.reason,error:l.error,logs:u}}),u=async e=>{let n=Date.now(),r=t.clientTools?.[e.toolName];if(r)return c(e,r,n);if(!(t.tools??[`eval_script`]).includes(e.toolName)){o(e,n,{ok:!1,reason:`unsupported_tool`,error:`this client does not execute '${e.toolName}'`});return}let i=e.input?.script;if(typeof i!=`string`){o(e,n,{ok:!1,reason:`invalid_input`,error:"expected a string `script` input"});return}return l(e,i,n)},d=e.on(`toolCallRequest`,e=>void u(e)),f=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,d(),f();for(let e of n.values())e.abort();n.clear()}}}async function jM(){let[e,t]=await Promise.all([kM(()=>import(`./src-BGDKT6fI.js`),[]),kM(()=>import(`./dist-tN5FTiVN.js`),[])]);return e.loadEngine(t)}function MM(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=AM(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 NM(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 PM(e){if(!e.any)return;let t=[];if(e.turns>0?t.push(FM(e.turns,`turn`)):e.replies>0&&t.push(FM(e.replies,`reply`,`replies`)),e.tools>0){let n=e.toolNames.slice(0,3).join(`, `),r=e.toolNames.length-3;t.push(`${FM(e.tools,`tool call`)}${n?` (${n}${r>0?`, +${r}`:``})`:``}`)}return e.files>0&&t.push(FM(e.files,`file`)),e.errors>0&&t.push(FM(e.errors,`error`)),e.pending>0&&t.push(`${FM(e.pending,`approval`)} waiting`),t.join(` · `)}function FM(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function IM(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 LM={command:0,client:1,skill:2};function RM(e){return e.replace(/\s*\(MCP\)$/i,``)}function zM(e){return`$${e.name}`}function BM(e){let t=zM(e),n=(e.defaultPrompt??``).split(t).join(` `).replace(/\s+/g,` `).trim();return n?` ${n} `:` `}function VM(e){return zM(e)+BM(e)}function HM(e){let t=[],n=new Set;for(let r of e.commands??[]){let e=RM(r.name);if(!n.has(e)){n.add(e);for(let e of r.aliases??[])n.add(RM(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 UM(e){return e.kind===`skill`?[e.name,e.label,...e.name.split(/[-:_]/)]:[e.name,...e.kind===`command`?e.aliases??[]:[],...e.name.split(`:`)]}function WM(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 GM(e,t){let n=[];return t.forEach((t,r)=>{if(t.kind===`skill`&&!t.enabled)return;let i=WM(e,UM(t));i>0&&n.push({score:i,index:r,row:t})}),n.sort((e,t)=>t.score-e.score||LM[e.row.kind]-LM[t.row.kind]||e.index-t.index),n.map(({row:e})=>e)}function KM(e,t){let n=e.trim();if(!n)return[...t];let r=[];return t.forEach((e,t)=>{let i=WM(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 qM(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 JM(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:VM(e.skill)}:{kind:e.kind,name:e.name,label:`/${e.name}`,description:e.description,enabled:!0,insertText:`/${e.name} `})}function YM({capabilities:e,hasModels:t,setModel:n,setPermissionMode:r,clearContext:i,openPanel:a}){let o=e.permissionModes,s=[];return t&&s.push({name:`model`,description:`Switch the model for this session`,argumentHint:`<model>`,requiresArgs:!0,run:e=>{let t=e.split(/\s+/)[0];return t?(n(t),!0):!1}}),o.length>1&&s.push({name:`permissions`,description:`Set the permission mode (${o.join(`, `)})`,argumentHint:`<mode>`,requiresArgs:!0,run:e=>{let t=e.split(/\s+/)[0];return o.includes(t)?(r(t),!0):!1}}),e.clearContext&&s.push({name:`clear`,description:`Clear the conversation - the session keeps running and the old one stays resumable`,run:()=>(i(),!0)}),e.mcpStatus&&s.push({name:`mcp`,description:`MCP servers and their status`,run:()=>(a(`mcp`),!0)}),e.contextUsage&&s.push({name:`context`,description:`Context window usage`,run:()=>(a(`context`),!0)}),s.push({name:`status`,description:`Session details`,run:()=>(a(`info`),!0)}),e.rateLimits&&s.push({name:`usage`,description:`Rate limits and spend`,run:()=>(a(`usage`),!0)}),e.skillsList&&s.push({name:`skills`,description:`Browse the skills this session can use`,run:()=>(a(`skills`),!0)}),s}var XM=(0,v.createContext)(`cards`);function ZM({value:e,children:t}){return(0,H.jsx)(XM.Provider,{value:e,children:t})}function QM(){return(0,v.useContext)(XM)}var $M={terminal:{className:`term-row-gap`,px:18},cards:{className:`pt-5`,px:20}},eN=`context compacted · earlier turns summarised to fit the window`;function tN(e){return e.error?`context compaction failed · ${e.error}`:e.pending?`compacting context · summarising earlier turns to fit the window`:[eN,e.preTokens===void 0?void 0:e.postTokens===void 0?`from ${iN(e.preTokens)}`:`${iN(e.preTokens)} → ${iN(e.postTokens)}`,e.trigger===`auto`?`automatic`:void 0].filter(Boolean).join(` · `)}function nN(e){return e===void 0||Number.isNaN(e)?`-`:e===0?`$0.00`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function rN(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 iN(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function aN(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function oN(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 sN(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 cN(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 lN(e){if(e===`five_hour`)return 18e3;if(e.startsWith(`seven_day`))return 604800}function uN(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 dN(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 fN={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 pN(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=fN[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 mN(e){switch(e){case`Bash`:case`BashOutput`:case`KillShell`:case`shell_list`:case`shell_read`:case`shell_run`:case`shell_write`:case`shell_kill`:case`shell_request_write`:case`mcp__workerdeck__shell_list`:case`mcp__workerdeck__shell_read`:case`mcp__workerdeck__shell_run`:case`mcp__workerdeck__shell_write`:case`mcp__workerdeck__shell_kill`:case`mcp__workerdeck__shell_request_write`:return FS;case`Read`:return ry;case`Write`:return hS;case`Edit`:case`MultiEdit`:case`NotebookEdit`:return sx;case`Glob`:return hy;case`Grep`:return Xx;case`WebFetch`:return sv;case`WebSearch`:return ky;case`Task`:case`Agent`:return ZS;case`TodoWrite`:case`TaskCreate`:case`TaskUpdate`:case`TaskGet`:case`TaskList`:return pS;case`Skill`:return lS;case`AskUserQuestion`:return Cb;case`CodexCommand`:return FS;case`CodexFileChange`:return $v;case`CodexWebSearch`:return ky;case`CodexImageGeneration`:case`CodexImageView`:return Vy;default:return e.startsWith(`mcp__`)?Tx:pC}}function hN(e){return e===`Bash`||e===`CodexCommand`}function gN(e){switch(e){case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:case`Update`:case`CodexFileChange`:return!0;default:return!1}}var _N=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],vN=new Set,yN,bN=`⠿`;function xN(e){return _N[Math.floor(e/90)%_N.length]}function SN(){let e=xN(Date.now());if(e!==bN){bN=e;for(let e of vN)e()}}function CN(e){return vN.add(e),yN===void 0&&(bN=xN(Date.now()),yN=setInterval(SN,90)),()=>{vN.delete(e),vN.size===0&&yN!==void 0&&(clearInterval(yN),yN=void 0)}}function wN(){return TN}function TN(){}function EN(){return bN}function DN(){return`⠿`}function ON(){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 kN(e){let t=ON(),n=e&&!t;return(0,v.useSyncExternalStore)(n?CN:wN,n?EN:DN,DN)}var AN=(0,v.createContext)(void 0),jN=(0,v.createContext)(void 0);function MN({names:e,children:t}){return(0,H.jsx)(AN.Provider,{value:e,children:t})}function NN({names:e,children:t}){return(0,H.jsx)(jN.Provider,{value:e,children:t})}function PN({text:e,className:t}){let n=Ij(e,{skills:(0,v.useContext)(AN),sessions:(0,v.useContext)(jN)});if(n.length===0)return(0,H.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,H.jsx)(`span`,{className:U(`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,H.jsx)(`span`,{className:t,children:r.map((e,t)=>(0,H.jsx)(v.Fragment,{children:e},t))})}var FN={hover:!0,actions:!0,labels:!1},IN=(0,v.createContext)(FN);function LN(){return(0,v.useContext)(IN)}function RN(e){return e===!1?{hover:!1,actions:!1,labels:!1}:e===!0||e===void 0?FN:{...FN,...e}}function zN({value:e,children:t}){return(0,H.jsx)(IN.Provider,{value:e,children:t})}var BN=(0,v.createContext)(`below`);function VN({value:e,children:t}){return(0,H.jsx)(BN.Provider,{value:e,children:t})}function HN({actions:e,children:t,className:n,placement:r}){let{actions:i}=LN(),a=(0,v.useContext)(BN);return i?(0,H.jsxs)(`div`,{className:U(`term-hoverable`,n),"data-placement":r??a,children:[(0,H.jsx)(BN.Provider,{value:`below`,children:t}),(0,H.jsx)(`div`,{className:`term-actions`,children:e})]}):(0,H.jsx)(H.Fragment,{children:t})}function UN({icon:e,word:t,label:n,tone:r,pressed:i,filled:a,onPress:o}){let{labels:s}=LN();return(0,H.jsxs)(`button`,{type:`button`,className:`term-action`,title:n,"aria-label":n,"aria-pressed":i,"data-tone":r,onClick:e=>{e.stopPropagation(),o()},children:[(0,H.jsx)(e,{"aria-hidden":!0,className:`term-action-icon`,fill:a?`currentColor`:`none`}),s?(0,H.jsx)(`span`,{className:`term-action-word`,children:t}):null]})}var WN=(0,v.createContext)(void 0);function GN({value:e,children:t}){return(0,H.jsx)(WN.Provider,{value:e,children:t})}function KN({id:e}){let t=(0,v.useContext)(WN);if(!t)return null;let n=t.has(e);return(0,H.jsx)(UN,{icon:CS,filled:!0,word:n?`bookmarked`:`bookmark`,label:n?`Remove bookmark`:`Bookmark`,tone:n?`yellow`:void 0,pressed:n,onPress:()=>t.toggle(e)})}function qN({onOpen:e,label:t=`Open sub-agent`}){return(0,H.jsx)(UN,{icon:yb,word:`open`,label:t,onPress:e})}function JN({onOpen:e,label:t=`Open terminal`}){return(0,H.jsx)(UN,{icon:yS,word:`enter shell`,label:t,tone:`magenta`,onPress:e})}function YN({onKill:e,label:t=`Kill this shell`}){return(0,H.jsx)(UN,{icon:hC,word:`kill`,label:t,tone:`danger`,onPress:e})}function XN({granted:e,label:t,onToggle:n}){return(0,H.jsx)(UN,{icon:e?T_:C_,word:e?`agent can type`:`agent read-only`,label:t,tone:e?`yellow`:void 0,pressed:e,onPress:n})}function ZN({text:e,label:t=`Copy`}){let[n,r]=(0,v.useState)(!1);return(0,H.jsx)(UN,{icon:n?X_:Nv,word:n?`copied`:`copy`,label:t,onPress:()=>{mE(e).then(e=>{e&&(r(!0),setTimeout(()=>r(!1),1200))})}})}function QN({granted:e,className:t}){return(0,H.jsx)(e?T_:C_,{"aria-hidden":!0,className:t})}function $N({glyph:e,glyphTone:t,tone:n,bold:r,indent:i,columns:a,className:o,children:s,style:c,...l}){return(0,H.jsxs)(`div`,{className:U(`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,H.jsx)(`span`,{className:`term-gutter`,"data-tone":t,"aria-hidden":!0,children:e??` `}),(0,H.jsx)(`div`,{className:`term-body`,children:s})]})}function eP(){return(0,H.jsx)(`div`,{className:`term-blank`,"aria-hidden":!0})}function tP({className:e,...t}){return(0,H.jsx)(`div`,{className:U(`term-band`,e),...t})}function nP({tone:e,bold:t,className:n,...r}){return(0,H.jsx)(`span`,{"data-tone":e,"data-weight":t?`bold`:void 0,className:n,...r})}function rP(e){return e.startsWith(`+`)?`add`:e.startsWith(`-`)?`remove`:`context`}function iP(e){let t=e.oldStart,n=e.newStart,r=[];for(let i of e.lines){let e=rP(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 aP={context:` `,add:`+`,remove:`-`};function oP(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(`
50
50
  `).map(e=>`-${e}`):[],...r?r.split(`
51
51
  `).map(e=>`+${e}`):[]];if(i.length!==0)return{...typeof t?.file_path==`string`&&{path:t.file_path},hunks:[{oldStart:0,oldLines:0,newStart:0,newLines:0,lines:i}]}}function sP({patch:e}){let t=e.hunks.map(iP),n=e.hunks.some(e=>e.newStart>0),r=n?String(Math.max(...t.flat().map(e=>e.number),1)).length:0,i=n?r+3:2;return(0,H.jsxs)(`div`,{className:`term-diff`,children:[t.map((e,t)=>(0,H.jsxs)(`div`,{children:[t>0?(0,H.jsx)($N,{columns:i,glyph:` `.repeat(r)+` ⋮`,tone:`faint`}):null,e.map((e,t)=>(0,H.jsx)($N,{columns:i,"data-diff":e.kind,glyph:n?`${String(e.number).padStart(r)} ${aP[e.kind]}`:aP[e.kind],children:e.text||` `},t))]},t)),e.truncated?(0,H.jsx)($N,{columns:i,tone:`faint`,children:`… diff truncated`}):null]})}var cP=(function(e){if(e==null)return pP;if(typeof e==`function`)return fP(e);if(typeof e==`object`)return Array.isArray(e)?lP(e):uP(e);if(typeof e==`string`)return dP(e);throw Error(`Expected function, string, or object as test`)});function lP(e){let t=[],n=-1;for(;++n<e.length;)t[n]=cP(e[n]);return fP(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function uP(e){let t=e;return fP(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function dP(e){return fP(t);function t(t){return t&&t.type===e}}function fP(e){return t;function t(t,n,r){return!!(mP(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function pP(){return!0}function mP(e){return typeof e==`object`&&!!e&&`type`in e}function hP(e){return e}var gP=[],_P=`skip`;function vP(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=cP(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+hP(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=gP,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=yP(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function yP(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?gP:[e]}function bP(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),vP(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var xP={indicator:`indicator`,textOnly:`text-only`,remove:`remove`};function SP({defaultOrigin:e=``,allowedLinkPrefixes:t=[],allowedImagePrefixes:n=[],allowDataImages:r=!1,allowedProtocols:i=[],blockedImageClass:a=`inline-block bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-400 px-3 py-1 rounded text-sm`,blockedLinkClass:o=`text-gray-500`,linkBlockPolicy:s=xP.indicator,imageBlockPolicy:c=xP.indicator}){let l=t.length&&!t.every(e=>e===`*`),u=n.length&&!n.every(e=>e===`*`);if(!e&&(l||u))throw Error(`defaultOrigin is required when allowedLinkPrefixes or allowedImagePrefixes are provided`);return l=>{let u=MP(e,t,n,r,i,a,o,s,c);OP(l),bP(l,u)}}function CP(e,t){if(typeof e!=`string`)return null;try{return new URL(e)}catch{if(t)try{return new URL(e,t)}catch{return null}if(e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`))try{return new URL(e,`http://example.com`)}catch{return null}return null}}function wP(e){return typeof e==`string`?e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`):!1}var TP=new Set([`https:`,`http:`,`irc:`,`ircs:`,`mailto:`,`xmpp:`,`blob:`]),EP=new Set([`javascript:`,`data:`,`file:`,`vbscript:`]);function DP(e,t,n,r=!1,i=!1,a=[]){if(!e)return null;if(typeof e==`string`&&e.startsWith(`#`)&&!i)try{if(new URL(e,`http://example.com`).hash===e)return e}catch{}if(typeof e==`string`&&e.startsWith(`data:`))return i&&r&&e.startsWith(`data:image/`)?e:null;if(typeof e==`string`&&e.startsWith(`blob:`)){try{if(new URL(e).protocol===`blob:`&&e.length>5){let t=e.substring(5);if(t&&t.length>0&&t!==`invalid`)return e}}catch{return null}return null}let o=CP(e,n);if(!o||EP.has(o.protocol)||!(TP.has(o.protocol)||a.includes(o.protocol)||a.includes(`*`)))return null;if(o.protocol===`mailto:`||!o.protocol.match(/^https?:$/))return o.href;let s=wP(e);return o&&t.some(e=>{let t=CP(e,n);return!t||t.origin!==o.origin?!1:o.href.startsWith(t.href)})?s?o.pathname+o.search+o.hash:o.href:t.includes(`*`)?o.protocol!==`https:`&&o.protocol!==`http:`?null:s?o.pathname+o.search+o.hash:o.href:null}function OP(e){if(`children`in e&&Array.isArray(e.children)){e.children=e.children.filter(e=>e!=null);for(let t of e.children)OP(t)}}var kP=Symbol(`node-seen`);function AP(e,t,n){return t===xP.remove?{type:`remove`}:t===xP.textOnly?{type:`replace`,element:{type:`element`,tagName:`span`,properties:{},children:[...e.children]}}:{type:`replace`,element:{type:`element`,tagName:`span`,properties:{title:`Blocked URL: `+String(e.properties.href),class:n},children:[...e.children,{type:`text`,value:` [blocked]`}]}}}function jP(e,t,n){if(t===xP.remove)return{type:`remove`};if(t===xP.textOnly){let t=String(e.properties.alt||``);return t?{type:`replace`,element:{type:`element`,tagName:`span`,properties:{},children:[{type:`text`,value:t}]}}:{type:`remove`}}return{type:`replace`,element:{type:`element`,tagName:`span`,properties:{class:n},children:[{type:`text`,value:`[Image blocked: `+String(e.properties.alt||`No description`)+`]`}]}}}var MP=(e,t,n,r,i,a,o,s,c)=>{let l=(u,d,f)=>{if(u.type!==`element`||u[kP])return!0;if(u.tagName===`a`){let n=DP(u.properties.href,t,e,!1,!1,i);if(n===null){if(u[kP]=!0,bP(u,l),f&&typeof d==`number`){let e=AP(u,s,o);if(e.type===`remove`)return f.children.splice(d,1),[_P,d];f.children[d]=e.element}return _P}return u.properties.href=n,u.properties.target=`_blank`,u.properties.rel=`noopener noreferrer`,!0}if(u.tagName===`img`){let t=DP(u.properties.src,n,e,r,!0,i);if(t===null){if(u[kP]=!0,bP(u,l),f&&typeof d==`number`){let e=jP(u,c,a);if(e.type===`remove`)return f.children.splice(d,1),[_P,d];f.children[d]=e.element}return _P}return u.properties.src=t,!0}return!0};return l},{defineProperty:NP}=Object,PP=typeof self==`object`?self:globalThis,FP=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new PP[e](t)},IP=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?NP(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof PP[e]==`function`?FP(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(FP(a,o),i)};return r},LP=e=>IP(new Map,e)(0),RP=``,{toString:zP}={},{keys:BP,is:VP}=Object,HP=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=zP.call(e).slice(8,-1);switch(n){case`Array`:return[1,RP];case`Object`:return[2,RP];case`Date`:return[3,RP];case`RegExp`:return[4,RP];case`Map`:return[5,RP];case`Set`:return[6,RP];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},UP=([e,t])=>e===0&&(t===`function`||t===`symbol`),WP=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=HP(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&VP(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of BP(o))(e||!UP(HP(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?RP:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(UP(HP(n))||UP(HP(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!UP(HP(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},GP=(e,{json:t,lossy:n}={})=>{let r=[];return WP(!(t||n),!!t,new Map,r)(e),r},KP=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?LP(GP(e,t)):structuredClone(e):(e,t)=>LP(GP(e,t)),qP=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};qP.prototype.normal={},qP.prototype.property={},qP.prototype.space=void 0;function JP(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new qP(n,r,t)}function YP(e){return e.toLowerCase()}var XP=class{constructor(e,t){this.attribute=t,this.property=e}};XP.prototype.attribute=``,XP.prototype.booleanish=!1,XP.prototype.boolean=!1,XP.prototype.commaOrSpaceSeparated=!1,XP.prototype.commaSeparated=!1,XP.prototype.defined=!1,XP.prototype.mustUseProperty=!1,XP.prototype.number=!1,XP.prototype.overloadedBoolean=!1,XP.prototype.property=``,XP.prototype.spaceSeparated=!1,XP.prototype.space=void 0;var ZP=s({boolean:()=>$P,booleanish:()=>eF,commaOrSpaceSeparated:()=>aF,commaSeparated:()=>iF,number:()=>nF,overloadedBoolean:()=>tF,spaceSeparated:()=>rF}),QP=0,$P=oF(),eF=oF(),tF=oF(),nF=oF(),rF=oF(),iF=oF(),aF=oF();function oF(){return 2**++QP}var sF=Object.keys(ZP),cF=class extends XP{constructor(e,t,n,r){let i=-1;if(super(e,t),lF(this,`space`,r),typeof n==`number`)for(;++i<sF.length;){let e=sF[i];lF(this,sF[i],(n&ZP[e])===ZP[e])}}};cF.prototype.defined=!0;function lF(e,t,n){n&&(e[t]=n)}function uF(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new cF(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[YP(r)]=r,n[YP(a.attribute)]=r}return new qP(t,n,e.space)}var dF=uF({properties:{ariaActiveDescendant:null,ariaAtomic:eF,ariaAutoComplete:null,ariaBusy:eF,ariaChecked:eF,ariaColCount:nF,ariaColIndex:nF,ariaColSpan:nF,ariaControls:rF,ariaCurrent:null,ariaDescribedBy:rF,ariaDetails:null,ariaDisabled:eF,ariaDropEffect:rF,ariaErrorMessage:null,ariaExpanded:eF,ariaFlowTo:rF,ariaGrabbed:eF,ariaHasPopup:null,ariaHidden:eF,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:rF,ariaLevel:nF,ariaLive:null,ariaModal:eF,ariaMultiLine:eF,ariaMultiSelectable:eF,ariaOrientation:null,ariaOwns:rF,ariaPlaceholder:null,ariaPosInSet:nF,ariaPressed:eF,ariaReadOnly:eF,ariaRelevant:null,ariaRequired:eF,ariaRoleDescription:rF,ariaRowCount:nF,ariaRowIndex:nF,ariaRowSpan:nF,ariaSelected:eF,ariaSetSize:nF,ariaSort:null,ariaValueMax:nF,ariaValueMin:nF,ariaValueNow:nF,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function fF(e,t){return t in e?e[t]:t}function pF(e,t){return fF(e,t.toLowerCase())}var mF=uF({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:iF,acceptCharset:rF,accessKey:rF,action:null,allow:null,allowFullScreen:$P,allowPaymentRequest:$P,allowUserMedia:$P,alpha:$P,alt:null,as:null,async:$P,autoCapitalize:null,autoComplete:rF,autoFocus:$P,autoPlay:$P,blocking:rF,capture:null,charSet:null,checked:$P,cite:null,className:rF,closedBy:null,colorSpace:null,cols:nF,colSpan:nF,command:null,commandFor:null,content:null,contentEditable:eF,controls:$P,controlsList:rF,coords:nF|iF,crossOrigin:null,data:null,dateTime:null,decoding:null,default:$P,defer:$P,dir:null,dirName:null,disabled:$P,download:tF,draggable:eF,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:$P,formTarget:null,headers:rF,height:nF,hidden:tF,high:nF,href:null,hrefLang:null,htmlFor:rF,httpEquiv:rF,id:null,imageSizes:null,imageSrcSet:null,inert:$P,inputMode:null,integrity:null,is:null,isMap:$P,itemId:null,itemProp:rF,itemRef:rF,itemScope:$P,itemType:rF,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:$P,low:nF,manifest:null,max:null,maxLength:nF,media:null,method:null,min:null,minLength:nF,multiple:$P,muted:$P,name:null,nonce:null,noModule:$P,noValidate:$P,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:$P,optimum:nF,pattern:null,ping:rF,placeholder:null,playsInline:$P,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:$P,referrerPolicy:null,rel:rF,required:$P,reversed:$P,rows:nF,rowSpan:nF,sandbox:rF,scope:null,scoped:$P,seamless:$P,selected:$P,shadowRootClonable:$P,shadowRootCustomElementRegistry:$P,shadowRootDelegatesFocus:$P,shadowRootMode:null,shadowRootSerializable:$P,shape:null,size:nF,sizes:null,slot:null,span:nF,spellCheck:eF,src:null,srcDoc:null,srcLang:null,srcSet:null,start:nF,step:null,style:null,tabIndex:nF,target:null,title:null,translate:null,type:null,typeMustMatch:$P,useMap:null,value:eF,width:nF,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:rF,axis:null,background:null,bgColor:null,border:nF,borderColor:null,bottomMargin:nF,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:$P,declare:$P,event:null,face:null,frame:null,frameBorder:null,hSpace:nF,leftMargin:nF,link:null,longDesc:null,lowSrc:null,marginHeight:nF,marginWidth:nF,noResize:$P,noHref:$P,noShade:$P,noWrap:$P,object:null,profile:null,prompt:null,rev:null,rightMargin:nF,rules:null,scheme:null,scrolling:eF,standby:null,summary:null,text:null,topMargin:nF,valueType:null,version:null,vAlign:null,vLink:null,vSpace:nF,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:$P,disablePictureInPicture:$P,disableRemotePlayback:$P,exportParts:iF,part:rF,prefix:null,property:null,results:nF,security:null,unselectable:null},space:`html`,transform:pF}),hF=uF({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:aF,accentHeight:nF,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:nF,amplitude:nF,arabicForm:null,ascent:nF,attributeName:null,attributeType:null,azimuth:nF,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:nF,by:null,calcMode:null,capHeight:nF,className:rF,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:nF,diffuseConstant:nF,direction:null,display:null,dur:null,divisor:nF,dominantBaseline:null,download:$P,dx:null,dy:null,edgeMode:null,editable:null,elevation:nF,enableBackground:null,end:null,event:null,exponent:nF,externalResourcesRequired:null,fill:null,fillOpacity:nF,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:iF,g2:iF,glyphName:iF,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:nF,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:nF,horizOriginX:nF,horizOriginY:nF,id:null,ideographic:nF,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:nF,k:nF,k1:nF,k2:nF,k3:nF,k4:nF,kernelMatrix:aF,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:nF,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:nF,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:nF,overlineThickness:nF,paintOrder:null,panose1:null,path:null,pathLength:nF,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:rF,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:nF,pointsAtY:nF,pointsAtZ:nF,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:aF,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:aF,rev:aF,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:aF,requiredFeatures:aF,requiredFonts:aF,requiredFormats:aF,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:nF,specularExponent:nF,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:nF,strikethroughThickness:nF,string:null,stroke:null,strokeDashArray:aF,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:nF,strokeOpacity:nF,strokeWidth:null,style:null,surfaceScale:nF,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:aF,tabIndex:nF,tableValues:null,target:null,targetX:nF,targetY:nF,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:aF,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:nF,underlineThickness:nF,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:nF,values:null,vAlphabetic:nF,vMathematical:nF,vectorEffect:null,vHanging:nF,vIdeographic:nF,version:null,vertAdvY:nF,vertOriginX:nF,vertOriginY:nF,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:nF,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:fF}),gF=uF({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),_F=uF({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:pF}),vF=uF({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),yF={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},bF=/[A-Z]/g,xF=/-[a-z]/g,SF=/^data[-\w.:]+$/i;function CF(e,t){let n=YP(t),r=t,i=XP;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&SF.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(xF,TF);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!xF.test(e)){let n=e.replace(bF,wF);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=cF}return new i(r,t)}function wF(e){return`-`+e.toLowerCase()}function TF(e){return e.charAt(1).toUpperCase()}var EF=JP([dF,mF,gF,_F,vF],`html`),DF=JP([dF,hF,gF,_F,vF],`svg`);function OF(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function kF(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var AF=/[#.]/g;function jF(e,t){let n=e||``,r={},i=0,a,o;for(;i<n.length;){AF.lastIndex=i;let e=AF.exec(n),t=n.slice(i,e?e.index:n.length);t&&(a?a===`#`?r.id=t:Array.isArray(r.className)?r.className.push(t):r.className=[t]:o=t,i+=t.length),e&&(a=e[0],i++)}return{type:`element`,tagName:o||t||`div`,properties:r,children:[]}}function MF(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function NF(e){return e.join(` `).trim()}function PF(e,t,n){let r=n?BF(n):void 0;function i(n,i,...a){let o;if(n==null){o={type:`root`,children:[]};let e=i;a.unshift(e)}else{o=jF(n,t);let s=o.tagName.toLowerCase(),c=r?r.get(s):void 0;if(o.tagName=c||s,FF(i))a.unshift(i);else for(let[t,n]of Object.entries(i))IF(e,o.properties,t,n)}for(let e of a)LF(o.children,e);return o.type===`element`&&o.tagName===`template`&&(o.content={type:`root`,children:o.children},o.children=[]),o}return i}function FF(e){if(typeof e!=`object`||!e||Array.isArray(e))return!0;if(typeof e.type!=`string`)return!1;let t=e,n=Object.keys(e);for(let e of n){let n=t[e];if(n&&typeof n==`object`){if(!Array.isArray(n))return!0;let e=n;for(let t of e)if(typeof t!=`number`&&typeof t!=`string`)return!0}}return!!(`children`in e&&Array.isArray(e.children))}function IF(e,t,n,r){let i=CF(e,n),a;if(r!=null){if(typeof r==`number`){if(Number.isNaN(r))return;a=r}else a=typeof r==`boolean`?r:typeof r==`string`?i.spaceSeparated?MF(r):i.commaSeparated?OF(r):i.commaOrSpaceSeparated?MF(OF(r).join(` `)):RF(i,i.property,r):Array.isArray(r)?[...r]:i.property===`style`?zF(r):String(r);if(Array.isArray(a)){let e=[];for(let t of a)e.push(RF(i,i.property,t));a=e}i.property===`className`&&Array.isArray(t.className)&&(a=t.className.concat(a)),t[i.property]=a}}function LF(e,t){if(t!=null){if(typeof t==`number`||typeof t==`string`)e.push({type:`text`,value:String(t)});else if(Array.isArray(t))for(let n of t)LF(e,n);else if(typeof t==`object`&&`type`in t)t.type===`root`?LF(e,t.children):e.push(t);else throw Error("Expected node, nodes, or string, got `"+t+"`")}}function RF(e,t,n){if(typeof n==`string`){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===``||YP(n)===YP(t)))return!0}return n}function zF(e){let t=[];for(let[n,r]of Object.entries(e))t.push([n,r].join(`: `));return t.join(`; `)}function BF(e){let t=new Map;for(let n of e)t.set(n.toLowerCase(),n);return t}var VF=`altGlyph.altGlyphDef.altGlyphItem.animateColor.animateMotion.animateTransform.clipPath.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.foreignObject.glyphRef.linearGradient.radialGradient.solidColor.textArea.textPath`.split(`.`),HF=PF(EF,`div`),UF=PF(DF,`g`,VF);function WF(e){let t=String(e),n=[];return{toOffset:i,toPoint:r};function r(e){if(typeof e==`number`&&e>-1&&e<=t.length){let r=0;for(;;){let i=n[r];if(i===void 0){let e=GF(t,n[r-1]);i=e===-1?t.length+1:e+1,n[r]=i}if(i>e)return{line:r+1,column:e-(r>0?n[r-1]:0)+1,offset:e};r++}}}function i(e){if(e&&typeof e.line==`number`&&typeof e.column==`number`&&!Number.isNaN(e.line)&&!Number.isNaN(e.column)){for(;n.length<e.line;){let e=n[n.length-1],r=GF(t,e),i=r===-1?t.length+1:r+1;if(e===i)break;n.push(i)}let r=(e.line>1?n[e.line-2]:0)+e.column-1;if(r<n[e.line-1])return r}}}function GF(e,t){let n=e.indexOf(`\r`,t),r=e.indexOf(`
52
52
  `,t);return r===-1?n:n===-1||n+1===r?r:n<r?n:r}var KF={html:`http://www.w3.org/1999/xhtml`,mathml:`http://www.w3.org/1998/Math/MathML`,svg:`http://www.w3.org/2000/svg`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`},qF={}.hasOwnProperty,JF=Object.prototype;function YF(e,t){let n=t||{};return XF({file:n.file||void 0,location:!1,schema:n.space===`svg`?DF:EF,verbose:n.verbose||!1},e)}function XF(e,t){let n;switch(t.nodeName){case`#comment`:{let r=t;return n={type:`comment`,value:r.data},$F(e,r,n),n}case`#document`:case`#document-fragment`:{let r=t,i=`mode`in r?r.mode===`quirks`||r.mode===`limited-quirks`:!1;if(n={type:`root`,children:ZF(e,t.childNodes),data:{quirksMode:i}},e.file&&e.location){let t=String(e.file),r=WF(t),i=r.toPoint(0),a=r.toPoint(t.length);n.position={start:i,end:a}}return n}case`#documentType`:{let r=t;return n={type:`doctype`},$F(e,r,n),n}case`#text`:{let r=t;return n={type:`text`,value:r.value},$F(e,r,n),n}default:return n=QF(e,t),n}}function ZF(e,t){let n=-1,r=[];for(;++n<t.length;){let i=XF(e,t[n]);r.push(i)}return r}function QF(e,t){let n=e.schema;e.schema=t.namespaceURI===KF.svg?DF:EF;let r=-1,i={};for(;++r<t.attrs.length;){let e=t.attrs[r],n=(e.prefix?e.prefix+`:`:``)+e.name;qF.call(JF,n)||(i[n]=e.value)}let a=(e.schema.space===`svg`?UF:HF)(t.tagName,i,ZF(e,t.childNodes));if($F(e,t,a),a.tagName===`template`){let n=t,r=n.sourceCodeLocation,i=r&&r.startTag&&tI(r.startTag),o=r&&r.endTag&&tI(r.endTag),s=XF(e,n.content);i&&o&&e.file&&(s.position={start:i.end,end:o.start}),a.content=s}return e.schema=n,a}function $F(e,t,n){if(`sourceCodeLocation`in t&&t.sourceCodeLocation&&e.file){let r=eI(e,n,t.sourceCodeLocation);r&&(e.location=!0,n.position=r)}}function eI(e,t,n){let r=tI(n);if(t.type===`element`){let i=t.children[t.children.length-1];if(r&&!n.endTag&&i&&i.position&&i.position.end&&(r.end=Object.assign({},i.position.end)),e.verbose){let r={},i;if(n.attrs)for(i in n.attrs)qF.call(n.attrs,i)&&(r[CF(e.schema,i).property]=tI(n.attrs[i]));n.startTag;let a=tI(n.startTag),o=n.endTag?tI(n.endTag):void 0,s={opening:a};o&&(s.closing=o),s.properties=r,t.data={position:s}}}return r}function tI(e){let t=nI({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=nI({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function nI(e){return e.line&&e.column?e:void 0}var rI={}.hasOwnProperty;function iI(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&rI.call(t,e)){let n=String(t[e]);i=rI.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var aI={},oI={}.hasOwnProperty,sI=iI(`type`,{handlers:{root:lI,element:mI,text:fI,comment:pI,doctype:dI}});function cI(e,t){let n=(t||aI).space;return sI(e,n===`svg`?DF:EF)}function lI(e,t){let n={nodeName:`#document`,mode:(e.data||{}).quirksMode?`quirks`:`no-quirks`,childNodes:[]};return n.childNodes=gI(e.children,n,t),_I(e,n),n}function uI(e,t){let n={nodeName:`#document-fragment`,childNodes:[]};return n.childNodes=gI(e.children,n,t),_I(e,n),n}function dI(e){let t={nodeName:`#documentType`,name:`html`,publicId:``,systemId:``,parentNode:null};return _I(e,t),t}function fI(e){let t={nodeName:`#text`,value:e.value,parentNode:null};return _I(e,t),t}function pI(e){let t={nodeName:`#comment`,data:e.value,parentNode:null};return _I(e,t),t}function mI(e,t){let n=t,r=n;e.type===`element`&&e.tagName.toLowerCase()===`svg`&&n.space===`html`&&(r=DF);let i=[],a;if(e.properties){for(a in e.properties)if(a!==`children`&&oI.call(e.properties,a)){let t=hI(r,a,e.properties[a]);t&&i.push(t)}}let o=r.space,s={nodeName:e.tagName,tagName:e.tagName,attrs:i,namespaceURI:KF[o],childNodes:[],parentNode:null};return s.childNodes=gI(e.children,s,r),_I(e,s),e.tagName===`template`&&e.content&&(s.content=uI(e.content,r)),s}function hI(e,t,n){let r=CF(e,t);if(n===!1||n==null||typeof n==`number`&&Number.isNaN(n)||!n&&r.boolean)return;Array.isArray(n)&&(n=r.commaSeparated?kF(n):NF(n));let i={name:r.attribute,value:n===!0?``:String(n)};if(r.space&&r.space!==`html`&&r.space!==`svg`){let e=i.name.indexOf(`:`);e<0?i.prefix=``:(i.name=i.name.slice(e+1),i.prefix=r.attribute.slice(0,e)),i.namespace=KF[r.space]}return i}function gI(e,t,n){let r=-1,i=[];if(e)for(;++r<e.length;){let a=sI(e[r],n);a.parentNode=t,i.push(a)}return i}function _I(e,t){let n=e.position;n&&n.start&&n.end&&(n.start.offset,n.end.offset,t.sourceCodeLocation={startLine:n.start.line,startCol:n.start.column,startOffset:n.start.offset,endLine:n.end.line,endCol:n.end.column,endOffset:n.end.offset})}var vI=[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`],yI=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),K;(function(e){e[e.EOF=-1]=`EOF`,e[e.NULL=0]=`NULL`,e[e.TABULATION=9]=`TABULATION`,e[e.CARRIAGE_RETURN=13]=`CARRIAGE_RETURN`,e[e.LINE_FEED=10]=`LINE_FEED`,e[e.FORM_FEED=12]=`FORM_FEED`,e[e.SPACE=32]=`SPACE`,e[e.EXCLAMATION_MARK=33]=`EXCLAMATION_MARK`,e[e.QUOTATION_MARK=34]=`QUOTATION_MARK`,e[e.AMPERSAND=38]=`AMPERSAND`,e[e.APOSTROPHE=39]=`APOSTROPHE`,e[e.HYPHEN_MINUS=45]=`HYPHEN_MINUS`,e[e.SOLIDUS=47]=`SOLIDUS`,e[e.DIGIT_0=48]=`DIGIT_0`,e[e.DIGIT_9=57]=`DIGIT_9`,e[e.SEMICOLON=59]=`SEMICOLON`,e[e.LESS_THAN_SIGN=60]=`LESS_THAN_SIGN`,e[e.EQUALS_SIGN=61]=`EQUALS_SIGN`,e[e.GREATER_THAN_SIGN=62]=`GREATER_THAN_SIGN`,e[e.QUESTION_MARK=63]=`QUESTION_MARK`,e[e.LATIN_CAPITAL_A=65]=`LATIN_CAPITAL_A`,e[e.LATIN_CAPITAL_Z=90]=`LATIN_CAPITAL_Z`,e[e.RIGHT_SQUARE_BRACKET=93]=`RIGHT_SQUARE_BRACKET`,e[e.GRAVE_ACCENT=96]=`GRAVE_ACCENT`,e[e.LATIN_SMALL_A=97]=`LATIN_SMALL_A`,e[e.LATIN_SMALL_Z=122]=`LATIN_SMALL_Z`})(K||={});var bI={DASH_DASH:`--`,CDATA_START:`[CDATA[`,DOCTYPE:`doctype`,SCRIPT:`script`,PUBLIC:`public`,SYSTEM:`system`};function xI(e){return e>=55296&&e<=57343}function SI(e){return e>=56320&&e<=57343}function CI(e,t){return(e-55296)*1024+9216+t}function wI(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function TI(e){return e>=64976&&e<=65007||yI.has(e)}var q;(function(e){e.controlCharacterInInputStream=`control-character-in-input-stream`,e.noncharacterInInputStream=`noncharacter-in-input-stream`,e.surrogateInInputStream=`surrogate-in-input-stream`,e.nonVoidHtmlElementStartTagWithTrailingSolidus=`non-void-html-element-start-tag-with-trailing-solidus`,e.endTagWithAttributes=`end-tag-with-attributes`,e.endTagWithTrailingSolidus=`end-tag-with-trailing-solidus`,e.unexpectedSolidusInTag=`unexpected-solidus-in-tag`,e.unexpectedNullCharacter=`unexpected-null-character`,e.unexpectedQuestionMarkInsteadOfTagName=`unexpected-question-mark-instead-of-tag-name`,e.invalidFirstCharacterOfTagName=`invalid-first-character-of-tag-name`,e.unexpectedEqualsSignBeforeAttributeName=`unexpected-equals-sign-before-attribute-name`,e.missingEndTagName=`missing-end-tag-name`,e.unexpectedCharacterInAttributeName=`unexpected-character-in-attribute-name`,e.unknownNamedCharacterReference=`unknown-named-character-reference`,e.missingSemicolonAfterCharacterReference=`missing-semicolon-after-character-reference`,e.unexpectedCharacterAfterDoctypeSystemIdentifier=`unexpected-character-after-doctype-system-identifier`,e.unexpectedCharacterInUnquotedAttributeValue=`unexpected-character-in-unquoted-attribute-value`,e.eofBeforeTagName=`eof-before-tag-name`,e.eofInTag=`eof-in-tag`,e.missingAttributeValue=`missing-attribute-value`,e.missingWhitespaceBetweenAttributes=`missing-whitespace-between-attributes`,e.missingWhitespaceAfterDoctypePublicKeyword=`missing-whitespace-after-doctype-public-keyword`,e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers=`missing-whitespace-between-doctype-public-and-system-identifiers`,e.missingWhitespaceAfterDoctypeSystemKeyword=`missing-whitespace-after-doctype-system-keyword`,e.missingQuoteBeforeDoctypePublicIdentifier=`missing-quote-before-doctype-public-identifier`,e.missingQuoteBeforeDoctypeSystemIdentifier=`missing-quote-before-doctype-system-identifier`,e.missingDoctypePublicIdentifier=`missing-doctype-public-identifier`,e.missingDoctypeSystemIdentifier=`missing-doctype-system-identifier`,e.abruptDoctypePublicIdentifier=`abrupt-doctype-public-identifier`,e.abruptDoctypeSystemIdentifier=`abrupt-doctype-system-identifier`,e.cdataInHtmlContent=`cdata-in-html-content`,e.incorrectlyOpenedComment=`incorrectly-opened-comment`,e.eofInScriptHtmlCommentLikeText=`eof-in-script-html-comment-like-text`,e.eofInDoctype=`eof-in-doctype`,e.nestedComment=`nested-comment`,e.abruptClosingOfEmptyComment=`abrupt-closing-of-empty-comment`,e.eofInComment=`eof-in-comment`,e.incorrectlyClosedComment=`incorrectly-closed-comment`,e.eofInCdata=`eof-in-cdata`,e.absenceOfDigitsInNumericCharacterReference=`absence-of-digits-in-numeric-character-reference`,e.nullCharacterReference=`null-character-reference`,e.surrogateCharacterReference=`surrogate-character-reference`,e.characterReferenceOutsideUnicodeRange=`character-reference-outside-unicode-range`,e.controlCharacterReference=`control-character-reference`,e.noncharacterCharacterReference=`noncharacter-character-reference`,e.missingWhitespaceBeforeDoctypeName=`missing-whitespace-before-doctype-name`,e.missingDoctypeName=`missing-doctype-name`,e.invalidCharacterSequenceAfterDoctypeName=`invalid-character-sequence-after-doctype-name`,e.duplicateAttribute=`duplicate-attribute`,e.nonConformingDoctype=`non-conforming-doctype`,e.missingDoctype=`missing-doctype`,e.misplacedDoctype=`misplaced-doctype`,e.endTagWithoutMatchingOpenElement=`end-tag-without-matching-open-element`,e.closingOfElementWithOpenChildElements=`closing-of-element-with-open-child-elements`,e.disallowedContentInNoscriptInHead=`disallowed-content-in-noscript-in-head`,e.openElementsLeftAfterEof=`open-elements-left-after-eof`,e.abandonedHeadElementChild=`abandoned-head-element-child`,e.misplacedStartTagForHeadElement=`misplaced-start-tag-for-head-element`,e.nestedNoscriptInHead=`nested-noscript-in-head`,e.eofInElementThatCanContainOnlyText=`eof-in-element-that-can-contain-only-text`})(q||={});var EI=65536,DI=class{constructor(e){this.handler=e,this.html=``,this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=EI,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+Number(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(e,t){let{line:n,col:r,offset:i}=this,a=r+t,o=i+t;return{code:e,startLine:n,endLine:n,startCol:a,endCol:a,startOffset:o,endOffset:o}}_err(e){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(e,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(e){if(this.pos!==this.html.length-1){let t=this.html.charCodeAt(this.pos+1);if(SI(t))return this.pos++,this._addGap(),CI(e,t)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,K.EOF;return this._err(q.surrogateInInputStream),e}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(e,t){this.html.length>0?this.html+=e:this.html=e,this.endOfChunkHit=!1,this.lastChunkWritten=t}insertHtmlAtCurrentPos(e){this.html=this.html.substring(0,this.pos+1)+e+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(e,t){if(this.pos+e.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(t)return this.html.startsWith(e,this.pos);for(let t=0;t<e.length;t++)if((this.html.charCodeAt(this.pos+t)|32)!==e.charCodeAt(t))return!1;return!0}peek(e){let t=this.pos+e;if(t>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,K.EOF;let n=this.html.charCodeAt(t);return n===K.CARRIAGE_RETURN?K.LINE_FEED:n}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,K.EOF;let e=this.html.charCodeAt(this.pos);return e===K.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,K.LINE_FEED):e===K.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,xI(e)&&(e=this._processSurrogate(e)),this.handler.onParseError===null||e>31&&e<127||e===K.LINE_FEED||e===K.CARRIAGE_RETURN||e>159&&e<64976||this._checkForProblematicCharacters(e),e)}_checkForProblematicCharacters(e){wI(e)?this._err(q.controlCharacterInInputStream):TI(e)&&this._err(q.noncharacterInInputStream)}retreat(e){for(this.pos-=e;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}},OI;(function(e){e[e.CHARACTER=0]=`CHARACTER`,e[e.NULL_CHARACTER=1]=`NULL_CHARACTER`,e[e.WHITESPACE_CHARACTER=2]=`WHITESPACE_CHARACTER`,e[e.START_TAG=3]=`START_TAG`,e[e.END_TAG=4]=`END_TAG`,e[e.COMMENT=5]=`COMMENT`,e[e.DOCTYPE=6]=`DOCTYPE`,e[e.EOF=7]=`EOF`,e[e.HIBERNATION=8]=`HIBERNATION`})(OI||={});function kI(e,t){for(let n=e.attrs.length-1;n>=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}var AI=new Uint16Array(`ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻\xA0ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌`.split(``).map(e=>e.charCodeAt(0))),jI=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);String.fromCodePoint;function MI(e){return e>=55296&&e<=57343||e>1114111?65533:jI.get(e)??e}var NI;(function(e){e[e.NUM=35]=`NUM`,e[e.SEMI=59]=`SEMI`,e[e.EQUALS=61]=`EQUALS`,e[e.ZERO=48]=`ZERO`,e[e.NINE=57]=`NINE`,e[e.LOWER_A=97]=`LOWER_A`,e[e.LOWER_F=102]=`LOWER_F`,e[e.LOWER_X=120]=`LOWER_X`,e[e.LOWER_Z=122]=`LOWER_Z`,e[e.UPPER_A=65]=`UPPER_A`,e[e.UPPER_F=70]=`UPPER_F`,e[e.UPPER_Z=90]=`UPPER_Z`})(NI||={});var PI=32,FI;(function(e){e[e.VALUE_LENGTH=49152]=`VALUE_LENGTH`,e[e.BRANCH_LENGTH=16256]=`BRANCH_LENGTH`,e[e.JUMP_TABLE=127]=`JUMP_TABLE`})(FI||={});function II(e){return e>=NI.ZERO&&e<=NI.NINE}function LI(e){return e>=NI.UPPER_A&&e<=NI.UPPER_F||e>=NI.LOWER_A&&e<=NI.LOWER_F}function RI(e){return e>=NI.UPPER_A&&e<=NI.UPPER_Z||e>=NI.LOWER_A&&e<=NI.LOWER_Z||II(e)}function zI(e){return e===NI.EQUALS||RI(e)}var BI;(function(e){e[e.EntityStart=0]=`EntityStart`,e[e.NumericStart=1]=`NumericStart`,e[e.NumericDecimal=2]=`NumericDecimal`,e[e.NumericHex=3]=`NumericHex`,e[e.NamedEntity=4]=`NamedEntity`})(BI||={});var VI;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Strict=1]=`Strict`,e[e.Attribute=2]=`Attribute`})(VI||={});var HI=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=BI.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=VI.Strict}startEntity(e){this.decodeMode=e,this.state=BI.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case BI.EntityStart:return e.charCodeAt(t)===NI.NUM?(this.state=BI.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=BI.NamedEntity,this.stateNamedEntity(e,t));case BI.NumericStart:return this.stateNumericStart(e,t);case BI.NumericDecimal:return this.stateNumericDecimal(e,t);case BI.NumericHex:return this.stateNumericHex(e,t);case BI.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|PI)===NI.LOWER_X?(this.state=BI.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=BI.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,n,r){if(t!==n){let i=n-t;this.result=this.result*r**+i+Number.parseInt(e.substr(t,i),r),this.consumed+=i}}stateNumericHex(e,t){let n=t;for(;t<e.length;){let r=e.charCodeAt(t);if(II(r)||LI(r))t+=1;else return this.addToNumericResult(e,n,t,16),this.emitNumericEntity(r,3)}return this.addToNumericResult(e,n,t,16),-1}stateNumericDecimal(e,t){let n=t;for(;t<e.length;){let r=e.charCodeAt(t);if(II(r))t+=1;else return this.addToNumericResult(e,n,t,10),this.emitNumericEntity(r,2)}return this.addToNumericResult(e,n,t,10),-1}emitNumericEntity(e,t){var n;if(this.consumed<=t)return(n=this.errors)==null||n.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===NI.SEMI)this.consumed+=1;else if(this.decodeMode===VI.Strict)return 0;return this.emitCodePoint(MI(this.result),this.consumed),this.errors&&(e!==NI.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){let{decodeTree:n}=this,r=n[this.treeIndex],i=(r&FI.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){let a=e.charCodeAt(t);if(this.treeIndex=UI(n,r,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===VI.Attribute&&(i===0||zI(a))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],i=(r&FI.VALUE_LENGTH)>>14,i!==0){if(a===NI.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==VI.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;let{result:t,decodeTree:n}=this,r=(n[t]&FI.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,r,this.consumed),(e=this.errors)==null||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,n){let{decodeTree:r}=this;return this.emitCodePoint(t===1?r[e]&~FI.VALUE_LENGTH:r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case BI.NamedEntity:return this.result!==0&&(this.decodeMode!==VI.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case BI.NumericDecimal:return this.emitNumericEntity(0,2);case BI.NumericHex:return this.emitNumericEntity(0,3);case BI.NumericStart:return(e=this.errors)==null||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case BI.EntityStart:return 0}}};function UI(e,t,n,r){let i=(t&FI.BRANCH_LENGTH)>>7,a=t&FI.JUMP_TABLE;if(i===0)return a!==0&&r===a?n:-1;if(a){let t=r-a;return t<0||t>=i?-1:e[n+t]-1}let o=n,s=o+i-1;for(;o<=s;){let t=o+s>>>1,n=e[t];if(n<r)o=t+1;else if(n>r)s=t-1;else return e[t+i]}return-1}var J;(function(e){e.HTML=`http://www.w3.org/1999/xhtml`,e.MATHML=`http://www.w3.org/1998/Math/MathML`,e.SVG=`http://www.w3.org/2000/svg`,e.XLINK=`http://www.w3.org/1999/xlink`,e.XML=`http://www.w3.org/XML/1998/namespace`,e.XMLNS=`http://www.w3.org/2000/xmlns/`})(J||={});var WI;(function(e){e.TYPE=`type`,e.ACTION=`action`,e.ENCODING=`encoding`,e.PROMPT=`prompt`,e.NAME=`name`,e.COLOR=`color`,e.FACE=`face`,e.SIZE=`size`})(WI||={});var GI;(function(e){e.NO_QUIRKS=`no-quirks`,e.QUIRKS=`quirks`,e.LIMITED_QUIRKS=`limited-quirks`})(GI||={});var Y;(function(e){e.A=`a`,e.ADDRESS=`address`,e.ANNOTATION_XML=`annotation-xml`,e.APPLET=`applet`,e.AREA=`area`,e.ARTICLE=`article`,e.ASIDE=`aside`,e.B=`b`,e.BASE=`base`,e.BASEFONT=`basefont`,e.BGSOUND=`bgsound`,e.BIG=`big`,e.BLOCKQUOTE=`blockquote`,e.BODY=`body`,e.BR=`br`,e.BUTTON=`button`,e.CAPTION=`caption`,e.CENTER=`center`,e.CODE=`code`,e.COL=`col`,e.COLGROUP=`colgroup`,e.DD=`dd`,e.DESC=`desc`,e.DETAILS=`details`,e.DIALOG=`dialog`,e.DIR=`dir`,e.DIV=`div`,e.DL=`dl`,e.DT=`dt`,e.EM=`em`,e.EMBED=`embed`,e.FIELDSET=`fieldset`,e.FIGCAPTION=`figcaption`,e.FIGURE=`figure`,e.FONT=`font`,e.FOOTER=`footer`,e.FOREIGN_OBJECT=`foreignObject`,e.FORM=`form`,e.FRAME=`frame`,e.FRAMESET=`frameset`,e.H1=`h1`,e.H2=`h2`,e.H3=`h3`,e.H4=`h4`,e.H5=`h5`,e.H6=`h6`,e.HEAD=`head`,e.HEADER=`header`,e.HGROUP=`hgroup`,e.HR=`hr`,e.HTML=`html`,e.I=`i`,e.IMG=`img`,e.IMAGE=`image`,e.INPUT=`input`,e.IFRAME=`iframe`,e.KEYGEN=`keygen`,e.LABEL=`label`,e.LI=`li`,e.LINK=`link`,e.LISTING=`listing`,e.MAIN=`main`,e.MALIGNMARK=`malignmark`,e.MARQUEE=`marquee`,e.MATH=`math`,e.MENU=`menu`,e.META=`meta`,e.MGLYPH=`mglyph`,e.MI=`mi`,e.MO=`mo`,e.MN=`mn`,e.MS=`ms`,e.MTEXT=`mtext`,e.NAV=`nav`,e.NOBR=`nobr`,e.NOFRAMES=`noframes`,e.NOEMBED=`noembed`,e.NOSCRIPT=`noscript`,e.OBJECT=`object`,e.OL=`ol`,e.OPTGROUP=`optgroup`,e.OPTION=`option`,e.P=`p`,e.PARAM=`param`,e.PLAINTEXT=`plaintext`,e.PRE=`pre`,e.RB=`rb`,e.RP=`rp`,e.RT=`rt`,e.RTC=`rtc`,e.RUBY=`ruby`,e.S=`s`,e.SCRIPT=`script`,e.SEARCH=`search`,e.SECTION=`section`,e.SELECT=`select`,e.SOURCE=`source`,e.SMALL=`small`,e.SPAN=`span`,e.STRIKE=`strike`,e.STRONG=`strong`,e.STYLE=`style`,e.SUB=`sub`,e.SUMMARY=`summary`,e.SUP=`sup`,e.TABLE=`table`,e.TBODY=`tbody`,e.TEMPLATE=`template`,e.TEXTAREA=`textarea`,e.TFOOT=`tfoot`,e.TD=`td`,e.TH=`th`,e.THEAD=`thead`,e.TITLE=`title`,e.TR=`tr`,e.TRACK=`track`,e.TT=`tt`,e.U=`u`,e.UL=`ul`,e.SVG=`svg`,e.VAR=`var`,e.WBR=`wbr`,e.XMP=`xmp`})(Y||={});var X;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.A=1]=`A`,e[e.ADDRESS=2]=`ADDRESS`,e[e.ANNOTATION_XML=3]=`ANNOTATION_XML`,e[e.APPLET=4]=`APPLET`,e[e.AREA=5]=`AREA`,e[e.ARTICLE=6]=`ARTICLE`,e[e.ASIDE=7]=`ASIDE`,e[e.B=8]=`B`,e[e.BASE=9]=`BASE`,e[e.BASEFONT=10]=`BASEFONT`,e[e.BGSOUND=11]=`BGSOUND`,e[e.BIG=12]=`BIG`,e[e.BLOCKQUOTE=13]=`BLOCKQUOTE`,e[e.BODY=14]=`BODY`,e[e.BR=15]=`BR`,e[e.BUTTON=16]=`BUTTON`,e[e.CAPTION=17]=`CAPTION`,e[e.CENTER=18]=`CENTER`,e[e.CODE=19]=`CODE`,e[e.COL=20]=`COL`,e[e.COLGROUP=21]=`COLGROUP`,e[e.DD=22]=`DD`,e[e.DESC=23]=`DESC`,e[e.DETAILS=24]=`DETAILS`,e[e.DIALOG=25]=`DIALOG`,e[e.DIR=26]=`DIR`,e[e.DIV=27]=`DIV`,e[e.DL=28]=`DL`,e[e.DT=29]=`DT`,e[e.EM=30]=`EM`,e[e.EMBED=31]=`EMBED`,e[e.FIELDSET=32]=`FIELDSET`,e[e.FIGCAPTION=33]=`FIGCAPTION`,e[e.FIGURE=34]=`FIGURE`,e[e.FONT=35]=`FONT`,e[e.FOOTER=36]=`FOOTER`,e[e.FOREIGN_OBJECT=37]=`FOREIGN_OBJECT`,e[e.FORM=38]=`FORM`,e[e.FRAME=39]=`FRAME`,e[e.FRAMESET=40]=`FRAMESET`,e[e.H1=41]=`H1`,e[e.H2=42]=`H2`,e[e.H3=43]=`H3`,e[e.H4=44]=`H4`,e[e.H5=45]=`H5`,e[e.H6=46]=`H6`,e[e.HEAD=47]=`HEAD`,e[e.HEADER=48]=`HEADER`,e[e.HGROUP=49]=`HGROUP`,e[e.HR=50]=`HR`,e[e.HTML=51]=`HTML`,e[e.I=52]=`I`,e[e.IMG=53]=`IMG`,e[e.IMAGE=54]=`IMAGE`,e[e.INPUT=55]=`INPUT`,e[e.IFRAME=56]=`IFRAME`,e[e.KEYGEN=57]=`KEYGEN`,e[e.LABEL=58]=`LABEL`,e[e.LI=59]=`LI`,e[e.LINK=60]=`LINK`,e[e.LISTING=61]=`LISTING`,e[e.MAIN=62]=`MAIN`,e[e.MALIGNMARK=63]=`MALIGNMARK`,e[e.MARQUEE=64]=`MARQUEE`,e[e.MATH=65]=`MATH`,e[e.MENU=66]=`MENU`,e[e.META=67]=`META`,e[e.MGLYPH=68]=`MGLYPH`,e[e.MI=69]=`MI`,e[e.MO=70]=`MO`,e[e.MN=71]=`MN`,e[e.MS=72]=`MS`,e[e.MTEXT=73]=`MTEXT`,e[e.NAV=74]=`NAV`,e[e.NOBR=75]=`NOBR`,e[e.NOFRAMES=76]=`NOFRAMES`,e[e.NOEMBED=77]=`NOEMBED`,e[e.NOSCRIPT=78]=`NOSCRIPT`,e[e.OBJECT=79]=`OBJECT`,e[e.OL=80]=`OL`,e[e.OPTGROUP=81]=`OPTGROUP`,e[e.OPTION=82]=`OPTION`,e[e.P=83]=`P`,e[e.PARAM=84]=`PARAM`,e[e.PLAINTEXT=85]=`PLAINTEXT`,e[e.PRE=86]=`PRE`,e[e.RB=87]=`RB`,e[e.RP=88]=`RP`,e[e.RT=89]=`RT`,e[e.RTC=90]=`RTC`,e[e.RUBY=91]=`RUBY`,e[e.S=92]=`S`,e[e.SCRIPT=93]=`SCRIPT`,e[e.SEARCH=94]=`SEARCH`,e[e.SECTION=95]=`SECTION`,e[e.SELECT=96]=`SELECT`,e[e.SOURCE=97]=`SOURCE`,e[e.SMALL=98]=`SMALL`,e[e.SPAN=99]=`SPAN`,e[e.STRIKE=100]=`STRIKE`,e[e.STRONG=101]=`STRONG`,e[e.STYLE=102]=`STYLE`,e[e.SUB=103]=`SUB`,e[e.SUMMARY=104]=`SUMMARY`,e[e.SUP=105]=`SUP`,e[e.TABLE=106]=`TABLE`,e[e.TBODY=107]=`TBODY`,e[e.TEMPLATE=108]=`TEMPLATE`,e[e.TEXTAREA=109]=`TEXTAREA`,e[e.TFOOT=110]=`TFOOT`,e[e.TD=111]=`TD`,e[e.TH=112]=`TH`,e[e.THEAD=113]=`THEAD`,e[e.TITLE=114]=`TITLE`,e[e.TR=115]=`TR`,e[e.TRACK=116]=`TRACK`,e[e.TT=117]=`TT`,e[e.U=118]=`U`,e[e.UL=119]=`UL`,e[e.SVG=120]=`SVG`,e[e.VAR=121]=`VAR`,e[e.WBR=122]=`WBR`,e[e.XMP=123]=`XMP`})(X||={});var $ee=new Map([[Y.A,X.A],[Y.ADDRESS,X.ADDRESS],[Y.ANNOTATION_XML,X.ANNOTATION_XML],[Y.APPLET,X.APPLET],[Y.AREA,X.AREA],[Y.ARTICLE,X.ARTICLE],[Y.ASIDE,X.ASIDE],[Y.B,X.B],[Y.BASE,X.BASE],[Y.BASEFONT,X.BASEFONT],[Y.BGSOUND,X.BGSOUND],[Y.BIG,X.BIG],[Y.BLOCKQUOTE,X.BLOCKQUOTE],[Y.BODY,X.BODY],[Y.BR,X.BR],[Y.BUTTON,X.BUTTON],[Y.CAPTION,X.CAPTION],[Y.CENTER,X.CENTER],[Y.CODE,X.CODE],[Y.COL,X.COL],[Y.COLGROUP,X.COLGROUP],[Y.DD,X.DD],[Y.DESC,X.DESC],[Y.DETAILS,X.DETAILS],[Y.DIALOG,X.DIALOG],[Y.DIR,X.DIR],[Y.DIV,X.DIV],[Y.DL,X.DL],[Y.DT,X.DT],[Y.EM,X.EM],[Y.EMBED,X.EMBED],[Y.FIELDSET,X.FIELDSET],[Y.FIGCAPTION,X.FIGCAPTION],[Y.FIGURE,X.FIGURE],[Y.FONT,X.FONT],[Y.FOOTER,X.FOOTER],[Y.FOREIGN_OBJECT,X.FOREIGN_OBJECT],[Y.FORM,X.FORM],[Y.FRAME,X.FRAME],[Y.FRAMESET,X.FRAMESET],[Y.H1,X.H1],[Y.H2,X.H2],[Y.H3,X.H3],[Y.H4,X.H4],[Y.H5,X.H5],[Y.H6,X.H6],[Y.HEAD,X.HEAD],[Y.HEADER,X.HEADER],[Y.HGROUP,X.HGROUP],[Y.HR,X.HR],[Y.HTML,X.HTML],[Y.I,X.I],[Y.IMG,X.IMG],[Y.IMAGE,X.IMAGE],[Y.INPUT,X.INPUT],[Y.IFRAME,X.IFRAME],[Y.KEYGEN,X.KEYGEN],[Y.LABEL,X.LABEL],[Y.LI,X.LI],[Y.LINK,X.LINK],[Y.LISTING,X.LISTING],[Y.MAIN,X.MAIN],[Y.MALIGNMARK,X.MALIGNMARK],[Y.MARQUEE,X.MARQUEE],[Y.MATH,X.MATH],[Y.MENU,X.MENU],[Y.META,X.META],[Y.MGLYPH,X.MGLYPH],[Y.MI,X.MI],[Y.MO,X.MO],[Y.MN,X.MN],[Y.MS,X.MS],[Y.MTEXT,X.MTEXT],[Y.NAV,X.NAV],[Y.NOBR,X.NOBR],[Y.NOFRAMES,X.NOFRAMES],[Y.NOEMBED,X.NOEMBED],[Y.NOSCRIPT,X.NOSCRIPT],[Y.OBJECT,X.OBJECT],[Y.OL,X.OL],[Y.OPTGROUP,X.OPTGROUP],[Y.OPTION,X.OPTION],[Y.P,X.P],[Y.PARAM,X.PARAM],[Y.PLAINTEXT,X.PLAINTEXT],[Y.PRE,X.PRE],[Y.RB,X.RB],[Y.RP,X.RP],[Y.RT,X.RT],[Y.RTC,X.RTC],[Y.RUBY,X.RUBY],[Y.S,X.S],[Y.SCRIPT,X.SCRIPT],[Y.SEARCH,X.SEARCH],[Y.SECTION,X.SECTION],[Y.SELECT,X.SELECT],[Y.SOURCE,X.SOURCE],[Y.SMALL,X.SMALL],[Y.SPAN,X.SPAN],[Y.STRIKE,X.STRIKE],[Y.STRONG,X.STRONG],[Y.STYLE,X.STYLE],[Y.SUB,X.SUB],[Y.SUMMARY,X.SUMMARY],[Y.SUP,X.SUP],[Y.TABLE,X.TABLE],[Y.TBODY,X.TBODY],[Y.TEMPLATE,X.TEMPLATE],[Y.TEXTAREA,X.TEXTAREA],[Y.TFOOT,X.TFOOT],[Y.TD,X.TD],[Y.TH,X.TH],[Y.THEAD,X.THEAD],[Y.TITLE,X.TITLE],[Y.TR,X.TR],[Y.TRACK,X.TRACK],[Y.TT,X.TT],[Y.U,X.U],[Y.UL,X.UL],[Y.SVG,X.SVG],[Y.VAR,X.VAR],[Y.WBR,X.WBR],[Y.XMP,X.XMP]]);function KI(e){return $ee.get(e)??X.UNKNOWN}var Z=X,ete={[J.HTML]:new Set([Z.ADDRESS,Z.APPLET,Z.AREA,Z.ARTICLE,Z.ASIDE,Z.BASE,Z.BASEFONT,Z.BGSOUND,Z.BLOCKQUOTE,Z.BODY,Z.BR,Z.BUTTON,Z.CAPTION,Z.CENTER,Z.COL,Z.COLGROUP,Z.DD,Z.DETAILS,Z.DIR,Z.DIV,Z.DL,Z.DT,Z.EMBED,Z.FIELDSET,Z.FIGCAPTION,Z.FIGURE,Z.FOOTER,Z.FORM,Z.FRAME,Z.FRAMESET,Z.H1,Z.H2,Z.H3,Z.H4,Z.H5,Z.H6,Z.HEAD,Z.HEADER,Z.HGROUP,Z.HR,Z.HTML,Z.IFRAME,Z.IMG,Z.INPUT,Z.LI,Z.LINK,Z.LISTING,Z.MAIN,Z.MARQUEE,Z.MENU,Z.META,Z.NAV,Z.NOEMBED,Z.NOFRAMES,Z.NOSCRIPT,Z.OBJECT,Z.OL,Z.P,Z.PARAM,Z.PLAINTEXT,Z.PRE,Z.SCRIPT,Z.SECTION,Z.SELECT,Z.SOURCE,Z.STYLE,Z.SUMMARY,Z.TABLE,Z.TBODY,Z.TD,Z.TEMPLATE,Z.TEXTAREA,Z.TFOOT,Z.TH,Z.THEAD,Z.TITLE,Z.TR,Z.TRACK,Z.UL,Z.WBR,Z.XMP]),[J.MATHML]:new Set([Z.MI,Z.MO,Z.MN,Z.MS,Z.MTEXT,Z.ANNOTATION_XML]),[J.SVG]:new Set([Z.TITLE,Z.FOREIGN_OBJECT,Z.DESC]),[J.XLINK]:new Set,[J.XML]:new Set,[J.XMLNS]:new Set},qI=new Set([Z.H1,Z.H2,Z.H3,Z.H4,Z.H5,Z.H6]);Y.STYLE,Y.SCRIPT,Y.XMP,Y.IFRAME,Y.NOEMBED,Y.NOFRAMES,Y.PLAINTEXT;var Q;(function(e){e[e.DATA=0]=`DATA`,e[e.RCDATA=1]=`RCDATA`,e[e.RAWTEXT=2]=`RAWTEXT`,e[e.SCRIPT_DATA=3]=`SCRIPT_DATA`,e[e.PLAINTEXT=4]=`PLAINTEXT`,e[e.TAG_OPEN=5]=`TAG_OPEN`,e[e.END_TAG_OPEN=6]=`END_TAG_OPEN`,e[e.TAG_NAME=7]=`TAG_NAME`,e[e.RCDATA_LESS_THAN_SIGN=8]=`RCDATA_LESS_THAN_SIGN`,e[e.RCDATA_END_TAG_OPEN=9]=`RCDATA_END_TAG_OPEN`,e[e.RCDATA_END_TAG_NAME=10]=`RCDATA_END_TAG_NAME`,e[e.RAWTEXT_LESS_THAN_SIGN=11]=`RAWTEXT_LESS_THAN_SIGN`,e[e.RAWTEXT_END_TAG_OPEN=12]=`RAWTEXT_END_TAG_OPEN`,e[e.RAWTEXT_END_TAG_NAME=13]=`RAWTEXT_END_TAG_NAME`,e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]=`SCRIPT_DATA_LESS_THAN_SIGN`,e[e.SCRIPT_DATA_END_TAG_OPEN=15]=`SCRIPT_DATA_END_TAG_OPEN`,e[e.SCRIPT_DATA_END_TAG_NAME=16]=`SCRIPT_DATA_END_TAG_NAME`,e[e.SCRIPT_DATA_ESCAPE_START=17]=`SCRIPT_DATA_ESCAPE_START`,e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]=`SCRIPT_DATA_ESCAPE_START_DASH`,e[e.SCRIPT_DATA_ESCAPED=19]=`SCRIPT_DATA_ESCAPED`,e[e.SCRIPT_DATA_ESCAPED_DASH=20]=`SCRIPT_DATA_ESCAPED_DASH`,e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]=`SCRIPT_DATA_ESCAPED_DASH_DASH`,e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]=`SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN`,e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]=`SCRIPT_DATA_ESCAPED_END_TAG_OPEN`,e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]=`SCRIPT_DATA_ESCAPED_END_TAG_NAME`,e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]=`SCRIPT_DATA_DOUBLE_ESCAPE_START`,e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]=`SCRIPT_DATA_DOUBLE_ESCAPED`,e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]=`SCRIPT_DATA_DOUBLE_ESCAPED_DASH`,e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]=`SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH`,e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]=`SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN`,e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]=`SCRIPT_DATA_DOUBLE_ESCAPE_END`,e[e.BEFORE_ATTRIBUTE_NAME=31]=`BEFORE_ATTRIBUTE_NAME`,e[e.ATTRIBUTE_NAME=32]=`ATTRIBUTE_NAME`,e[e.AFTER_ATTRIBUTE_NAME=33]=`AFTER_ATTRIBUTE_NAME`,e[e.BEFORE_ATTRIBUTE_VALUE=34]=`BEFORE_ATTRIBUTE_VALUE`,e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]=`ATTRIBUTE_VALUE_DOUBLE_QUOTED`,e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]=`ATTRIBUTE_VALUE_SINGLE_QUOTED`,e[e.ATTRIBUTE_VALUE_UNQUOTED=37]=`ATTRIBUTE_VALUE_UNQUOTED`,e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]=`AFTER_ATTRIBUTE_VALUE_QUOTED`,e[e.SELF_CLOSING_START_TAG=39]=`SELF_CLOSING_START_TAG`,e[e.BOGUS_COMMENT=40]=`BOGUS_COMMENT`,e[e.MARKUP_DECLARATION_OPEN=41]=`MARKUP_DECLARATION_OPEN`,e[e.COMMENT_START=42]=`COMMENT_START`,e[e.COMMENT_START_DASH=43]=`COMMENT_START_DASH`,e[e.COMMENT=44]=`COMMENT`,e[e.COMMENT_LESS_THAN_SIGN=45]=`COMMENT_LESS_THAN_SIGN`,e[e.COMMENT_LESS_THAN_SIGN_BANG=46]=`COMMENT_LESS_THAN_SIGN_BANG`,e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]=`COMMENT_LESS_THAN_SIGN_BANG_DASH`,e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]=`COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH`,e[e.COMMENT_END_DASH=49]=`COMMENT_END_DASH`,e[e.COMMENT_END=50]=`COMMENT_END`,e[e.COMMENT_END_BANG=51]=`COMMENT_END_BANG`,e[e.DOCTYPE=52]=`DOCTYPE`,e[e.BEFORE_DOCTYPE_NAME=53]=`BEFORE_DOCTYPE_NAME`,e[e.DOCTYPE_NAME=54]=`DOCTYPE_NAME`,e[e.AFTER_DOCTYPE_NAME=55]=`AFTER_DOCTYPE_NAME`,e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]=`AFTER_DOCTYPE_PUBLIC_KEYWORD`,e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]=`BEFORE_DOCTYPE_PUBLIC_IDENTIFIER`,e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]=`DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED`,e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]=`DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED`,e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]=`AFTER_DOCTYPE_PUBLIC_IDENTIFIER`,e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]=`BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS`,e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]=`AFTER_DOCTYPE_SYSTEM_KEYWORD`,e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]=`BEFORE_DOCTYPE_SYSTEM_IDENTIFIER`,e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]=`DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED`,e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]=`DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED`,e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]=`AFTER_DOCTYPE_SYSTEM_IDENTIFIER`,e[e.BOGUS_DOCTYPE=67]=`BOGUS_DOCTYPE`,e[e.CDATA_SECTION=68]=`CDATA_SECTION`,e[e.CDATA_SECTION_BRACKET=69]=`CDATA_SECTION_BRACKET`,e[e.CDATA_SECTION_END=70]=`CDATA_SECTION_END`,e[e.CHARACTER_REFERENCE=71]=`CHARACTER_REFERENCE`,e[e.AMBIGUOUS_AMPERSAND=72]=`AMBIGUOUS_AMPERSAND`})(Q||={});var JI={DATA:Q.DATA,RCDATA:Q.RCDATA,RAWTEXT:Q.RAWTEXT,SCRIPT_DATA:Q.SCRIPT_DATA,PLAINTEXT:Q.PLAINTEXT,CDATA_SECTION:Q.CDATA_SECTION};function tte(e){return e>=K.DIGIT_0&&e<=K.DIGIT_9}function YI(e){return e>=K.LATIN_CAPITAL_A&&e<=K.LATIN_CAPITAL_Z}function nte(e){return e>=K.LATIN_SMALL_A&&e<=K.LATIN_SMALL_Z}function XI(e){return nte(e)||YI(e)}function ZI(e){return XI(e)||tte(e)}function QI(e){return e+32}function $I(e){return e===K.SPACE||e===K.LINE_FEED||e===K.TABULATION||e===K.FORM_FEED}function eL(e){return $I(e)||e===K.SOLIDUS||e===K.GREATER_THAN_SIGN}function rte(e){return e===K.NULL?q.nullCharacterReference:e>1114111?q.characterReferenceOutsideUnicodeRange:xI(e)?q.surrogateCharacterReference:TI(e)?q.noncharacterCharacterReference:wI(e)||e===K.CARRIAGE_RETURN?q.controlCharacterReference:null}var ite=class{constructor(e,t){this.options=e,this.handler=t,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName=``,this.active=!1,this.state=Q.DATA,this.returnState=Q.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:``,value:``},this.preprocessor=new DI(t),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new HI(AI,(e,t)=>{this.preprocessor.pos=this.entityStartPos+t-1,this._flushCodePointConsumedAsCharacterReference(e)},t.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(q.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:e=>{this._err(q.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+e)},validateNumericCharacterReference:e=>{let t=rte(e);t&&this._err(t,1)}}:void 0)}_err(e,t=0){var n,r;(r=(n=this.handler).onParseError)==null||r.call(n,this.preprocessor.getError(e,t))}getCurrentLocation(e){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-e,startOffset:this.preprocessor.offset-e,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;let e=this._consume();this._ensureHibernation()||this._callState(e)}this.inLoop=!1}}pause(){this.paused=!0}resume(e){if(!this.paused)throw Error(`Parser was already resumed`);this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||e?.())}write(e,t,n){this.active=!0,this.preprocessor.write(e,t),this._runParsingLoop(),this.paused||n?.()}insertHtmlAtCurrentPos(e){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(e),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(e){this.consumedAfterSnapshot+=e;for(let t=0;t<e;t++)this.preprocessor.advance()}_consumeSequenceIfMatch(e,t){return this.preprocessor.startsWith(e,t)?(this._advanceBy(e.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:OI.START_TAG,tagName:``,tagID:X.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:OI.END_TAG,tagName:``,tagID:X.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(e){this.currentToken={type:OI.COMMENT,data:``,location:this.getCurrentLocation(e)}}_createDoctypeToken(e){this.currentToken={type:OI.DOCTYPE,name:e,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(e,t){this.currentCharacterToken={type:e,chars:t,location:this.currentLocation}}_createAttr(e){this.currentAttr={name:e,value:``},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var e;let t=this.currentToken;if(kI(t,this.currentAttr.name)===null){if(t.attrs.push(this.currentAttr),t.location&&this.currentLocation){let n=(e=t.location).attrs??(e.attrs=Object.create(null));n[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(q.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(e){this._emitCurrentCharacterToken(e.location),this.currentToken=null,e.location&&(e.location.endLine=this.preprocessor.line,e.location.endCol=this.preprocessor.col+1,e.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){let e=this.currentToken;this.prepareToken(e),e.tagID=KI(e.tagName),e.type===OI.START_TAG?(this.lastStartTagName=e.tagName,this.handler.onStartTag(e)):(e.attrs.length>0&&this._err(q.endTagWithAttributes),e.selfClosing&&this._err(q.endTagWithTrailingSolidus),this.handler.onEndTag(e)),this.preprocessor.dropParsedChunk()}emitCurrentComment(e){this.prepareToken(e),this.handler.onComment(e),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(e){this.prepareToken(e),this.handler.onDoctype(e),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(e){if(this.currentCharacterToken){switch(e&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=e.startLine,this.currentCharacterToken.location.endCol=e.startCol,this.currentCharacterToken.location.endOffset=e.startOffset),this.currentCharacterToken.type){case OI.CHARACTER:this.handler.onCharacter(this.currentCharacterToken);break;case OI.NULL_CHARACTER:this.handler.onNullCharacter(this.currentCharacterToken);break;case OI.WHITESPACE_CHARACTER:this.handler.onWhitespaceCharacter(this.currentCharacterToken)}this.currentCharacterToken=null}}_emitEOFToken(){let e=this.getCurrentLocation(0);e&&(e.endLine=e.startLine,e.endCol=e.startCol,e.endOffset=e.startOffset),this._emitCurrentCharacterToken(e),this.handler.onEof({type:OI.EOF,location:e}),this.active=!1}_appendCharToCurrentCharacterToken(e,t){if(this.currentCharacterToken){if(this.currentCharacterToken.type===e){this.currentCharacterToken.chars+=t;return}this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk()}this._createCharacterToken(e,t)}_emitCodePoint(e){let t=$I(e)?OI.WHITESPACE_CHARACTER:e===K.NULL?OI.NULL_CHARACTER:OI.CHARACTER;this._appendCharToCurrentCharacterToken(t,String.fromCodePoint(e))}_emitChars(e){this._appendCharToCurrentCharacterToken(OI.CHARACTER,e)}_startCharacterReference(){this.returnState=this.state,this.state=Q.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?VI.Attribute:VI.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===Q.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===Q.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===Q.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(e){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(e):this._emitCodePoint(e)}_callState(e){switch(this.state){case Q.DATA:this._stateData(e);break;case Q.RCDATA:this._stateRcdata(e);break;case Q.RAWTEXT:this._stateRawtext(e);break;case Q.SCRIPT_DATA:this._stateScriptData(e);break;case Q.PLAINTEXT:this._statePlaintext(e);break;case Q.TAG_OPEN:this._stateTagOpen(e);break;case Q.END_TAG_OPEN:this._stateEndTagOpen(e);break;case Q.TAG_NAME:this._stateTagName(e);break;case Q.RCDATA_LESS_THAN_SIGN:this._stateRcdataLessThanSign(e);break;case Q.RCDATA_END_TAG_OPEN:this._stateRcdataEndTagOpen(e);break;case Q.RCDATA_END_TAG_NAME:this._stateRcdataEndTagName(e);break;case Q.RAWTEXT_LESS_THAN_SIGN:this._stateRawtextLessThanSign(e);break;case Q.RAWTEXT_END_TAG_OPEN:this._stateRawtextEndTagOpen(e);break;case Q.RAWTEXT_END_TAG_NAME:this._stateRawtextEndTagName(e);break;case Q.SCRIPT_DATA_LESS_THAN_SIGN:this._stateScriptDataLessThanSign(e);break;case Q.SCRIPT_DATA_END_TAG_OPEN:this._stateScriptDataEndTagOpen(e);break;case Q.SCRIPT_DATA_END_TAG_NAME:this._stateScriptDataEndTagName(e);break;case Q.SCRIPT_DATA_ESCAPE_START:this._stateScriptDataEscapeStart(e);break;case Q.SCRIPT_DATA_ESCAPE_START_DASH:this._stateScriptDataEscapeStartDash(e);break;case Q.SCRIPT_DATA_ESCAPED:this._stateScriptDataEscaped(e);break;case Q.SCRIPT_DATA_ESCAPED_DASH:this._stateScriptDataEscapedDash(e);break;case Q.SCRIPT_DATA_ESCAPED_DASH_DASH:this._stateScriptDataEscapedDashDash(e);break;case Q.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataEscapedLessThanSign(e);break;case Q.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:this._stateScriptDataEscapedEndTagOpen(e);break;case Q.SCRIPT_DATA_ESCAPED_END_TAG_NAME:this._stateScriptDataEscapedEndTagName(e);break;case Q.SCRIPT_DATA_DOUBLE_ESCAPE_START:this._stateScriptDataDoubleEscapeStart(e);break;case Q.SCRIPT_DATA_DOUBLE_ESCAPED:this._stateScriptDataDoubleEscaped(e);break;case Q.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:this._stateScriptDataDoubleEscapedDash(e);break;case Q.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:this._stateScriptDataDoubleEscapedDashDash(e);break;case Q.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataDoubleEscapedLessThanSign(e);break;case Q.SCRIPT_DATA_DOUBLE_ESCAPE_END:this._stateScriptDataDoubleEscapeEnd(e);break;case Q.BEFORE_ATTRIBUTE_NAME:this._stateBeforeAttributeName(e);break;case Q.ATTRIBUTE_NAME:this._stateAttributeName(e);break;case Q.AFTER_ATTRIBUTE_NAME:this._stateAfterAttributeName(e);break;case Q.BEFORE_ATTRIBUTE_VALUE:this._stateBeforeAttributeValue(e);break;case Q.ATTRIBUTE_VALUE_DOUBLE_QUOTED:this._stateAttributeValueDoubleQuoted(e);break;case Q.ATTRIBUTE_VALUE_SINGLE_QUOTED:this._stateAttributeValueSingleQuoted(e);break;case Q.ATTRIBUTE_VALUE_UNQUOTED:this._stateAttributeValueUnquoted(e);break;case Q.AFTER_ATTRIBUTE_VALUE_QUOTED:this._stateAfterAttributeValueQuoted(e);break;case Q.SELF_CLOSING_START_TAG:this._stateSelfClosingStartTag(e);break;case Q.BOGUS_COMMENT:this._stateBogusComment(e);break;case Q.MARKUP_DECLARATION_OPEN:this._stateMarkupDeclarationOpen(e);break;case Q.COMMENT_START:this._stateCommentStart(e);break;case Q.COMMENT_START_DASH:this._stateCommentStartDash(e);break;case Q.COMMENT:this._stateComment(e);break;case Q.COMMENT_LESS_THAN_SIGN:this._stateCommentLessThanSign(e);break;case Q.COMMENT_LESS_THAN_SIGN_BANG:this._stateCommentLessThanSignBang(e);break;case Q.COMMENT_LESS_THAN_SIGN_BANG_DASH:this._stateCommentLessThanSignBangDash(e);break;case Q.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:this._stateCommentLessThanSignBangDashDash(e);break;case Q.COMMENT_END_DASH:this._stateCommentEndDash(e);break;case Q.COMMENT_END:this._stateCommentEnd(e);break;case Q.COMMENT_END_BANG:this._stateCommentEndBang(e);break;case Q.DOCTYPE:this._stateDoctype(e);break;case Q.BEFORE_DOCTYPE_NAME:this._stateBeforeDoctypeName(e);break;case Q.DOCTYPE_NAME:this._stateDoctypeName(e);break;case Q.AFTER_DOCTYPE_NAME:this._stateAfterDoctypeName(e);break;case Q.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._stateAfterDoctypePublicKeyword(e);break;case Q.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:this._stateBeforeDoctypePublicIdentifier(e);break;case Q.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypePublicIdentifierDoubleQuoted(e);break;case Q.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypePublicIdentifierSingleQuoted(e);break;case Q.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:this._stateAfterDoctypePublicIdentifier(e);break;case Q.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:this._stateBetweenDoctypePublicAndSystemIdentifiers(e);break;case Q.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._stateAfterDoctypeSystemKeyword(e);break;case Q.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:this._stateBeforeDoctypeSystemIdentifier(e);break;case Q.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypeSystemIdentifierDoubleQuoted(e);break;case Q.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypeSystemIdentifierSingleQuoted(e);break;case Q.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:this._stateAfterDoctypeSystemIdentifier(e);break;case Q.BOGUS_DOCTYPE:this._stateBogusDoctype(e);break;case Q.CDATA_SECTION:this._stateCdataSection(e);break;case Q.CDATA_SECTION_BRACKET:this._stateCdataSectionBracket(e);break;case Q.CDATA_SECTION_END:this._stateCdataSectionEnd(e);break;case Q.CHARACTER_REFERENCE:this._stateCharacterReference();break;case Q.AMBIGUOUS_AMPERSAND:this._stateAmbiguousAmpersand(e);break;default:throw Error(`Unknown state`)}}_stateData(e){switch(e){case K.LESS_THAN_SIGN:this.state=Q.TAG_OPEN;break;case K.AMPERSAND:this._startCharacterReference();break;case K.NULL:this._err(q.unexpectedNullCharacter),this._emitCodePoint(e);break;case K.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRcdata(e){switch(e){case K.AMPERSAND:this._startCharacterReference();break;case K.LESS_THAN_SIGN:this.state=Q.RCDATA_LESS_THAN_SIGN;break;case K.NULL:this._err(q.unexpectedNullCharacter),this._emitChars(`�`);break;case K.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRawtext(e){switch(e){case K.LESS_THAN_SIGN:this.state=Q.RAWTEXT_LESS_THAN_SIGN;break;case K.NULL:this._err(q.unexpectedNullCharacter),this._emitChars(`�`);break;case K.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptData(e){switch(e){case K.LESS_THAN_SIGN:this.state=Q.SCRIPT_DATA_LESS_THAN_SIGN;break;case K.NULL:this._err(q.unexpectedNullCharacter),this._emitChars(`�`);break;case K.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_statePlaintext(e){switch(e){case K.NULL:this._err(q.unexpectedNullCharacter),this._emitChars(`�`);break;case K.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateTagOpen(e){if(XI(e))this._createStartTagToken(),this.state=Q.TAG_NAME,this._stateTagName(e);else switch(e){case K.EXCLAMATION_MARK:this.state=Q.MARKUP_DECLARATION_OPEN;break;case K.SOLIDUS:this.state=Q.END_TAG_OPEN;break;case K.QUESTION_MARK:this._err(q.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=Q.BOGUS_COMMENT,this._stateBogusComment(e);break;case K.EOF:this._err(q.eofBeforeTagName),this._emitChars(`<`),this._emitEOFToken();break;default:this._err(q.invalidFirstCharacterOfTagName),this._emitChars(`<`),this.state=Q.DATA,this._stateData(e)}}_stateEndTagOpen(e){if(XI(e))this._createEndTagToken(),this.state=Q.TAG_NAME,this._stateTagName(e);else switch(e){case K.GREATER_THAN_SIGN:this._err(q.missingEndTagName),this.state=Q.DATA;break;case K.EOF:this._err(q.eofBeforeTagName),this._emitChars(`</`),this._emitEOFToken();break;default:this._err(q.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=Q.BOGUS_COMMENT,this._stateBogusComment(e)}}_stateTagName(e){let t=this.currentToken;switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:this.state=Q.BEFORE_ATTRIBUTE_NAME;break;case K.SOLIDUS:this.state=Q.SELF_CLOSING_START_TAG;break;case K.GREATER_THAN_SIGN:this.state=Q.DATA,this.emitCurrentTagToken();break;case K.NULL:this._err(q.unexpectedNullCharacter),t.tagName+=`�`;break;case K.EOF:this._err(q.eofInTag),this._emitEOFToken();break;default:t.tagName+=String.fromCodePoint(YI(e)?QI(e):e)}}_stateRcdataLessThanSign(e){e===K.SOLIDUS?this.state=Q.RCDATA_END_TAG_OPEN:(this._emitChars(`<`),this.state=Q.RCDATA,this._stateRcdata(e))}_stateRcdataEndTagOpen(e){XI(e)?(this.state=Q.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(e)):(this._emitChars(`</`),this.state=Q.RCDATA,this._stateRcdata(e))}handleSpecialEndTag(e){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();let t=this.currentToken;switch(t.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=Q.BEFORE_ATTRIBUTE_NAME,!1;case K.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=Q.SELF_CLOSING_START_TAG,!1;case K.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=Q.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars(`</`),this.state=Q.RCDATA,this._stateRcdata(e))}_stateRawtextLessThanSign(e){e===K.SOLIDUS?this.state=Q.RAWTEXT_END_TAG_OPEN:(this._emitChars(`<`),this.state=Q.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagOpen(e){XI(e)?(this.state=Q.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(e)):(this._emitChars(`</`),this.state=Q.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars(`</`),this.state=Q.RAWTEXT,this._stateRawtext(e))}_stateScriptDataLessThanSign(e){switch(e){case K.SOLIDUS:this.state=Q.SCRIPT_DATA_END_TAG_OPEN;break;case K.EXCLAMATION_MARK:this.state=Q.SCRIPT_DATA_ESCAPE_START,this._emitChars(`<!`);break;default:this._emitChars(`<`),this.state=Q.SCRIPT_DATA,this._stateScriptData(e)}}_stateScriptDataEndTagOpen(e){XI(e)?(this.state=Q.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(e)):(this._emitChars(`</`),this.state=Q.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars(`</`),this.state=Q.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStart(e){e===K.HYPHEN_MINUS?(this.state=Q.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars(`-`)):(this.state=Q.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStartDash(e){e===K.HYPHEN_MINUS?(this.state=Q.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars(`-`)):(this.state=Q.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscaped(e){switch(e){case K.HYPHEN_MINUS:this.state=Q.SCRIPT_DATA_ESCAPED_DASH,this._emitChars(`-`);break;case K.LESS_THAN_SIGN:this.state=Q.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case K.NULL:this._err(q.unexpectedNullCharacter),this._emitChars(`�`);break;case K.EOF:this._err(q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataEscapedDash(e){switch(e){case K.HYPHEN_MINUS:this.state=Q.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars(`-`);break;case K.LESS_THAN_SIGN:this.state=Q.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case K.NULL:this._err(q.unexpectedNullCharacter),this.state=Q.SCRIPT_DATA_ESCAPED,this._emitChars(`�`);break;case K.EOF:this._err(q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Q.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedDashDash(e){switch(e){case K.HYPHEN_MINUS:this._emitChars(`-`);break;case K.LESS_THAN_SIGN:this.state=Q.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case K.GREATER_THAN_SIGN:this.state=Q.SCRIPT_DATA,this._emitChars(`>`);break;case K.NULL:this._err(q.unexpectedNullCharacter),this.state=Q.SCRIPT_DATA_ESCAPED,this._emitChars(`�`);break;case K.EOF:this._err(q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Q.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedLessThanSign(e){e===K.SOLIDUS?this.state=Q.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:XI(e)?(this._emitChars(`<`),this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(e)):(this._emitChars(`<`),this.state=Q.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagOpen(e){XI(e)?(this.state=Q.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(e)):(this._emitChars(`</`),this.state=Q.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars(`</`),this.state=Q.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscapeStart(e){if(this.preprocessor.startsWith(bI.SCRIPT,!1)&&eL(this.preprocessor.peek(bI.SCRIPT.length))){this._emitCodePoint(e);for(let e=0;e<bI.SCRIPT.length;e++)this._emitCodePoint(this._consume());this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=Q.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscaped(e){switch(e){case K.HYPHEN_MINUS:this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars(`-`);break;case K.LESS_THAN_SIGN:this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars(`<`);break;case K.NULL:this._err(q.unexpectedNullCharacter),this._emitChars(`�`);break;case K.EOF:this._err(q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDash(e){switch(e){case K.HYPHEN_MINUS:this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars(`-`);break;case K.LESS_THAN_SIGN:this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars(`<`);break;case K.NULL:this._err(q.unexpectedNullCharacter),this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(`�`);break;case K.EOF:this._err(q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDashDash(e){switch(e){case K.HYPHEN_MINUS:this._emitChars(`-`);break;case K.LESS_THAN_SIGN:this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars(`<`);break;case K.GREATER_THAN_SIGN:this.state=Q.SCRIPT_DATA,this._emitChars(`>`);break;case K.NULL:this._err(q.unexpectedNullCharacter),this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(`�`);break;case K.EOF:this._err(q.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedLessThanSign(e){e===K.SOLIDUS?(this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars(`/`)):(this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateScriptDataDoubleEscapeEnd(e){if(this.preprocessor.startsWith(bI.SCRIPT,!1)&&eL(this.preprocessor.peek(bI.SCRIPT.length))){this._emitCodePoint(e);for(let e=0;e<bI.SCRIPT.length;e++)this._emitCodePoint(this._consume());this.state=Q.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=Q.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateBeforeAttributeName(e){switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:break;case K.SOLIDUS:case K.GREATER_THAN_SIGN:case K.EOF:this.state=Q.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case K.EQUALS_SIGN:this._err(q.unexpectedEqualsSignBeforeAttributeName),this._createAttr(`=`),this.state=Q.ATTRIBUTE_NAME;break;default:this._createAttr(``),this.state=Q.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateAttributeName(e){switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:case K.SOLIDUS:case K.GREATER_THAN_SIGN:case K.EOF:this._leaveAttrName(),this.state=Q.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case K.EQUALS_SIGN:this._leaveAttrName(),this.state=Q.BEFORE_ATTRIBUTE_VALUE;break;case K.QUOTATION_MARK:case K.APOSTROPHE:case K.LESS_THAN_SIGN:this._err(q.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(e);break;case K.NULL:this._err(q.unexpectedNullCharacter),this.currentAttr.name+=`�`;break;default:this.currentAttr.name+=String.fromCodePoint(YI(e)?QI(e):e)}}_stateAfterAttributeName(e){switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:break;case K.SOLIDUS:this.state=Q.SELF_CLOSING_START_TAG;break;case K.EQUALS_SIGN:this.state=Q.BEFORE_ATTRIBUTE_VALUE;break;case K.GREATER_THAN_SIGN:this.state=Q.DATA,this.emitCurrentTagToken();break;case K.EOF:this._err(q.eofInTag),this._emitEOFToken();break;default:this._createAttr(``),this.state=Q.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateBeforeAttributeValue(e){switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:break;case K.QUOTATION_MARK:this.state=Q.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break;case K.APOSTROPHE:this.state=Q.ATTRIBUTE_VALUE_SINGLE_QUOTED;break;case K.GREATER_THAN_SIGN:this._err(q.missingAttributeValue),this.state=Q.DATA,this.emitCurrentTagToken();break;default:this.state=Q.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(e)}}_stateAttributeValueDoubleQuoted(e){switch(e){case K.QUOTATION_MARK:this.state=Q.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case K.AMPERSAND:this._startCharacterReference();break;case K.NULL:this._err(q.unexpectedNullCharacter),this.currentAttr.value+=`�`;break;case K.EOF:this._err(q.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueSingleQuoted(e){switch(e){case K.APOSTROPHE:this.state=Q.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case K.AMPERSAND:this._startCharacterReference();break;case K.NULL:this._err(q.unexpectedNullCharacter),this.currentAttr.value+=`�`;break;case K.EOF:this._err(q.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueUnquoted(e){switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:this._leaveAttrValue(),this.state=Q.BEFORE_ATTRIBUTE_NAME;break;case K.AMPERSAND:this._startCharacterReference();break;case K.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=Q.DATA,this.emitCurrentTagToken();break;case K.NULL:this._err(q.unexpectedNullCharacter),this.currentAttr.value+=`�`;break;case K.QUOTATION_MARK:case K.APOSTROPHE:case K.LESS_THAN_SIGN:case K.EQUALS_SIGN:case K.GRAVE_ACCENT:this._err(q.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(e);break;case K.EOF:this._err(q.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAfterAttributeValueQuoted(e){switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:this._leaveAttrValue(),this.state=Q.BEFORE_ATTRIBUTE_NAME;break;case K.SOLIDUS:this._leaveAttrValue(),this.state=Q.SELF_CLOSING_START_TAG;break;case K.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=Q.DATA,this.emitCurrentTagToken();break;case K.EOF:this._err(q.eofInTag),this._emitEOFToken();break;default:this._err(q.missingWhitespaceBetweenAttributes),this.state=Q.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateSelfClosingStartTag(e){switch(e){case K.GREATER_THAN_SIGN:{let e=this.currentToken;e.selfClosing=!0,this.state=Q.DATA,this.emitCurrentTagToken();break}case K.EOF:this._err(q.eofInTag),this._emitEOFToken();break;default:this._err(q.unexpectedSolidusInTag),this.state=Q.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateBogusComment(e){let t=this.currentToken;switch(e){case K.GREATER_THAN_SIGN:this.state=Q.DATA,this.emitCurrentComment(t);break;case K.EOF:this.emitCurrentComment(t),this._emitEOFToken();break;case K.NULL:this._err(q.unexpectedNullCharacter),t.data+=`�`;break;default:t.data+=String.fromCodePoint(e)}}_stateMarkupDeclarationOpen(e){this._consumeSequenceIfMatch(bI.DASH_DASH,!0)?(this._createCommentToken(bI.DASH_DASH.length+1),this.state=Q.COMMENT_START):this._consumeSequenceIfMatch(bI.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(bI.DOCTYPE.length+1),this.state=Q.DOCTYPE):this._consumeSequenceIfMatch(bI.CDATA_START,!0)?this.inForeignNode?this.state=Q.CDATA_SECTION:(this._err(q.cdataInHtmlContent),this._createCommentToken(bI.CDATA_START.length+1),this.currentToken.data=`[CDATA[`,this.state=Q.BOGUS_COMMENT):this._ensureHibernation()||(this._err(q.incorrectlyOpenedComment),this._createCommentToken(2),this.state=Q.BOGUS_COMMENT,this._stateBogusComment(e))}_stateCommentStart(e){switch(e){case K.HYPHEN_MINUS:this.state=Q.COMMENT_START_DASH;break;case K.GREATER_THAN_SIGN:{this._err(q.abruptClosingOfEmptyComment),this.state=Q.DATA;let e=this.currentToken;this.emitCurrentComment(e);break}default:this.state=Q.COMMENT,this._stateComment(e)}}_stateCommentStartDash(e){let t=this.currentToken;switch(e){case K.HYPHEN_MINUS:this.state=Q.COMMENT_END;break;case K.GREATER_THAN_SIGN:this._err(q.abruptClosingOfEmptyComment),this.state=Q.DATA,this.emitCurrentComment(t);break;case K.EOF:this._err(q.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=`-`,this.state=Q.COMMENT,this._stateComment(e)}}_stateComment(e){let t=this.currentToken;switch(e){case K.HYPHEN_MINUS:this.state=Q.COMMENT_END_DASH;break;case K.LESS_THAN_SIGN:t.data+=`<`,this.state=Q.COMMENT_LESS_THAN_SIGN;break;case K.NULL:this._err(q.unexpectedNullCharacter),t.data+=`�`;break;case K.EOF:this._err(q.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=String.fromCodePoint(e)}}_stateCommentLessThanSign(e){let t=this.currentToken;switch(e){case K.EXCLAMATION_MARK:t.data+=`!`,this.state=Q.COMMENT_LESS_THAN_SIGN_BANG;break;case K.LESS_THAN_SIGN:t.data+=`<`;break;default:this.state=Q.COMMENT,this._stateComment(e)}}_stateCommentLessThanSignBang(e){e===K.HYPHEN_MINUS?this.state=Q.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=Q.COMMENT,this._stateComment(e))}_stateCommentLessThanSignBangDash(e){e===K.HYPHEN_MINUS?this.state=Q.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=Q.COMMENT_END_DASH,this._stateCommentEndDash(e))}_stateCommentLessThanSignBangDashDash(e){e!==K.GREATER_THAN_SIGN&&e!==K.EOF&&this._err(q.nestedComment),this.state=Q.COMMENT_END,this._stateCommentEnd(e)}_stateCommentEndDash(e){let t=this.currentToken;switch(e){case K.HYPHEN_MINUS:this.state=Q.COMMENT_END;break;case K.EOF:this._err(q.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=`-`,this.state=Q.COMMENT,this._stateComment(e)}}_stateCommentEnd(e){let t=this.currentToken;switch(e){case K.GREATER_THAN_SIGN:this.state=Q.DATA,this.emitCurrentComment(t);break;case K.EXCLAMATION_MARK:this.state=Q.COMMENT_END_BANG;break;case K.HYPHEN_MINUS:t.data+=`-`;break;case K.EOF:this._err(q.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=`--`,this.state=Q.COMMENT,this._stateComment(e)}}_stateCommentEndBang(e){let t=this.currentToken;switch(e){case K.HYPHEN_MINUS:t.data+=`--!`,this.state=Q.COMMENT_END_DASH;break;case K.GREATER_THAN_SIGN:this._err(q.incorrectlyClosedComment),this.state=Q.DATA,this.emitCurrentComment(t);break;case K.EOF:this._err(q.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=`--!`,this.state=Q.COMMENT,this._stateComment(e)}}_stateDoctype(e){switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:this.state=Q.BEFORE_DOCTYPE_NAME;break;case K.GREATER_THAN_SIGN:this.state=Q.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e);break;case K.EOF:{this._err(q.eofInDoctype),this._createDoctypeToken(null);let e=this.currentToken;e.forceQuirks=!0,this.emitCurrentDoctype(e),this._emitEOFToken();break}default:this._err(q.missingWhitespaceBeforeDoctypeName),this.state=Q.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e)}}_stateBeforeDoctypeName(e){if(YI(e))this._createDoctypeToken(String.fromCharCode(QI(e))),this.state=Q.DOCTYPE_NAME;else switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:break;case K.NULL:this._err(q.unexpectedNullCharacter),this._createDoctypeToken(`�`),this.state=Q.DOCTYPE_NAME;break;case K.GREATER_THAN_SIGN:{this._err(q.missingDoctypeName),this._createDoctypeToken(null);let e=this.currentToken;e.forceQuirks=!0,this.emitCurrentDoctype(e),this.state=Q.DATA;break}case K.EOF:{this._err(q.eofInDoctype),this._createDoctypeToken(null);let e=this.currentToken;e.forceQuirks=!0,this.emitCurrentDoctype(e),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(e)),this.state=Q.DOCTYPE_NAME}}_stateDoctypeName(e){let t=this.currentToken;switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:this.state=Q.AFTER_DOCTYPE_NAME;break;case K.GREATER_THAN_SIGN:this.state=Q.DATA,this.emitCurrentDoctype(t);break;case K.NULL:this._err(q.unexpectedNullCharacter),t.name+=`�`;break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.name+=String.fromCodePoint(YI(e)?QI(e):e)}}_stateAfterDoctypeName(e){let t=this.currentToken;switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:break;case K.GREATER_THAN_SIGN:this.state=Q.DATA,this.emitCurrentDoctype(t);break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._consumeSequenceIfMatch(bI.PUBLIC,!1)?this.state=Q.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(bI.SYSTEM,!1)?this.state=Q.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(q.invalidCharacterSequenceAfterDoctypeName),t.forceQuirks=!0,this.state=Q.BOGUS_DOCTYPE,this._stateBogusDoctype(e))}}_stateAfterDoctypePublicKeyword(e){let t=this.currentToken;switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:this.state=Q.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break;case K.QUOTATION_MARK:this._err(q.missingWhitespaceAfterDoctypePublicKeyword),t.publicId=``,this.state=Q.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case K.APOSTROPHE:this._err(q.missingWhitespaceAfterDoctypePublicKeyword),t.publicId=``,this.state=Q.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case K.GREATER_THAN_SIGN:this._err(q.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Q.DATA,this.emitCurrentDoctype(t);break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(q.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Q.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypePublicIdentifier(e){let t=this.currentToken;switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:break;case K.QUOTATION_MARK:t.publicId=``,this.state=Q.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case K.APOSTROPHE:t.publicId=``,this.state=Q.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case K.GREATER_THAN_SIGN:this._err(q.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Q.DATA,this.emitCurrentDoctype(t);break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(q.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Q.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypePublicIdentifierDoubleQuoted(e){let t=this.currentToken;switch(e){case K.QUOTATION_MARK:this.state=Q.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case K.NULL:this._err(q.unexpectedNullCharacter),t.publicId+=`�`;break;case K.GREATER_THAN_SIGN:this._err(q.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Q.DATA;break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateDoctypePublicIdentifierSingleQuoted(e){let t=this.currentToken;switch(e){case K.APOSTROPHE:this.state=Q.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case K.NULL:this._err(q.unexpectedNullCharacter),t.publicId+=`�`;break;case K.GREATER_THAN_SIGN:this._err(q.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Q.DATA;break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateAfterDoctypePublicIdentifier(e){let t=this.currentToken;switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:this.state=Q.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break;case K.GREATER_THAN_SIGN:this.state=Q.DATA,this.emitCurrentDoctype(t);break;case K.QUOTATION_MARK:this._err(q.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId=``,this.state=Q.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case K.APOSTROPHE:this._err(q.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId=``,this.state=Q.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(q.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Q.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBetweenDoctypePublicAndSystemIdentifiers(e){let t=this.currentToken;switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:break;case K.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=Q.DATA;break;case K.QUOTATION_MARK:t.systemId=``,this.state=Q.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case K.APOSTROPHE:t.systemId=``,this.state=Q.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(q.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Q.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateAfterDoctypeSystemKeyword(e){let t=this.currentToken;switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:this.state=Q.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break;case K.QUOTATION_MARK:this._err(q.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId=``,this.state=Q.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case K.APOSTROPHE:this._err(q.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId=``,this.state=Q.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case K.GREATER_THAN_SIGN:this._err(q.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Q.DATA,this.emitCurrentDoctype(t);break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(q.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Q.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypeSystemIdentifier(e){let t=this.currentToken;switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:break;case K.QUOTATION_MARK:t.systemId=``,this.state=Q.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case K.APOSTROPHE:t.systemId=``,this.state=Q.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case K.GREATER_THAN_SIGN:this._err(q.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Q.DATA,this.emitCurrentDoctype(t);break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(q.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Q.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypeSystemIdentifierDoubleQuoted(e){let t=this.currentToken;switch(e){case K.QUOTATION_MARK:this.state=Q.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case K.NULL:this._err(q.unexpectedNullCharacter),t.systemId+=`�`;break;case K.GREATER_THAN_SIGN:this._err(q.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Q.DATA;break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateDoctypeSystemIdentifierSingleQuoted(e){let t=this.currentToken;switch(e){case K.APOSTROPHE:this.state=Q.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case K.NULL:this._err(q.unexpectedNullCharacter),t.systemId+=`�`;break;case K.GREATER_THAN_SIGN:this._err(q.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Q.DATA;break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateAfterDoctypeSystemIdentifier(e){let t=this.currentToken;switch(e){case K.SPACE:case K.LINE_FEED:case K.TABULATION:case K.FORM_FEED:break;case K.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=Q.DATA;break;case K.EOF:this._err(q.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(q.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=Q.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBogusDoctype(e){let t=this.currentToken;switch(e){case K.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=Q.DATA;break;case K.NULL:this._err(q.unexpectedNullCharacter);break;case K.EOF:this.emitCurrentDoctype(t),this._emitEOFToken()}}_stateCdataSection(e){switch(e){case K.RIGHT_SQUARE_BRACKET:this.state=Q.CDATA_SECTION_BRACKET;break;case K.EOF:this._err(q.eofInCdata),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateCdataSectionBracket(e){e===K.RIGHT_SQUARE_BRACKET?this.state=Q.CDATA_SECTION_END:(this._emitChars(`]`),this.state=Q.CDATA_SECTION,this._stateCdataSection(e))}_stateCdataSectionEnd(e){switch(e){case K.GREATER_THAN_SIGN:this.state=Q.DATA;break;case K.RIGHT_SQUARE_BRACKET:this._emitChars(`]`);break;default:this._emitChars(`]]`),this.state=Q.CDATA_SECTION,this._stateCdataSection(e)}}_stateCharacterReference(){let e=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(e<0){if(this.preprocessor.lastChunkWritten)e=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}}e===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(K.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&ZI(this.preprocessor.peek(1))?Q.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(e){ZI(e)?this._flushCodePointConsumedAsCharacterReference(e):(e===K.SEMICOLON&&this._err(q.unknownNamedCharacterReference),this.state=this.returnState,this._callState(e))}},tL=new Set([X.DD,X.DT,X.LI,X.OPTGROUP,X.OPTION,X.P,X.RB,X.RP,X.RT,X.RTC]),nL=new Set([...tL,X.CAPTION,X.COLGROUP,X.TBODY,X.TD,X.TFOOT,X.TH,X.THEAD,X.TR]),rL=new Set([X.APPLET,X.CAPTION,X.HTML,X.MARQUEE,X.OBJECT,X.TABLE,X.TD,X.TEMPLATE,X.TH]),ate=new Set([...rL,X.OL,X.UL]),ote=new Set([...rL,X.BUTTON]),iL=new Set([X.ANNOTATION_XML,X.MI,X.MN,X.MO,X.MS,X.MTEXT]),aL=new Set([X.DESC,X.FOREIGN_OBJECT,X.TITLE]),ste=new Set([X.TR,X.TEMPLATE,X.HTML]),cte=new Set([X.TBODY,X.TFOOT,X.THEAD,X.TEMPLATE,X.HTML]),lte=new Set([X.TABLE,X.TEMPLATE,X.HTML]),ute=new Set([X.TD,X.TH]),dte=class{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(e,t,n){this.treeAdapter=t,this.handler=n,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=X.UNKNOWN,this.current=e}_indexOf(e){return this.items.lastIndexOf(e,this.stackTop)}_isInTemplate(){return this.currentTagId===X.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===J.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(e,t){this.stackTop++,this.items[this.stackTop]=e,this.current=e,this.tagIDs[this.stackTop]=t,this.currentTagId=t,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(e,t,!0)}pop(){let e=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!0)}replace(e,t){let n=this._indexOf(e);this.items[n]=t,n===this.stackTop&&(this.current=t)}insertAfter(e,t,n){let r=this._indexOf(e)+1;this.items.splice(r,0,t),this.tagIDs.splice(r,0,n),this.stackTop++,r===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,r===this.stackTop)}popUntilTagNamePopped(e){let t=this.stackTop+1;do t=this.tagIDs.lastIndexOf(e,t-1);while(t>0&&this.treeAdapter.getNamespaceURI(this.items[t])!==J.HTML);this.shortenToLength(Math.max(t,0))}shortenToLength(e){for(;this.stackTop>=e;){let t=this.current;this.tmplCount>0&&this._isInTemplate()&&--this.tmplCount,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,this.stackTop<e)}}popUntilElementPopped(e){let t=this._indexOf(e);this.shortenToLength(Math.max(t,0))}popUntilPopped(e,t){let n=this._indexOfTagNames(e,t);this.shortenToLength(Math.max(n,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(qI,J.HTML)}popUntilTableCellPopped(){this.popUntilPopped(ute,J.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(e,t){for(let n=this.stackTop;n>=0;n--)if(e.has(this.tagIDs[n])&&this.treeAdapter.getNamespaceURI(this.items[n])===t)return n;return-1}clearBackTo(e,t){let n=this._indexOfTagNames(e,t);this.shortenToLength(n+1)}clearBackToTableContext(){this.clearBackTo(lte,J.HTML)}clearBackToTableBodyContext(){this.clearBackTo(cte,J.HTML)}clearBackToTableRowContext(){this.clearBackTo(ste,J.HTML)}remove(e){let t=this._indexOf(e);t>=0&&(t===this.stackTop?this.pop():(this.items.splice(t,1),this.tagIDs.splice(t,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===X.BODY?this.items[1]:null}contains(e){return this._indexOf(e)>-1}getCommonAncestor(e){let t=this._indexOf(e)-1;return t>=0?this.items[t]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===X.HTML}hasInDynamicScope(e,t){for(let n=this.stackTop;n>=0;n--){let r=this.tagIDs[n];switch(this.treeAdapter.getNamespaceURI(this.items[n])){case J.HTML:if(r===e)return!0;if(t.has(r))return!1;break;case J.SVG:if(aL.has(r))return!1;break;case J.MATHML:if(iL.has(r))return!1}}return!0}hasInScope(e){return this.hasInDynamicScope(e,rL)}hasInListItemScope(e){return this.hasInDynamicScope(e,ate)}hasInButtonScope(e){return this.hasInDynamicScope(e,ote)}hasNumberedHeaderInScope(){for(let e=this.stackTop;e>=0;e--){let t=this.tagIDs[e];switch(this.treeAdapter.getNamespaceURI(this.items[e])){case J.HTML:if(qI.has(t))return!0;if(rL.has(t))return!1;break;case J.SVG:if(aL.has(t))return!1;break;case J.MATHML:if(iL.has(t))return!1}}return!0}hasInTableScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===J.HTML)switch(this.tagIDs[t]){case e:return!0;case X.TABLE:case X.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let e=this.stackTop;e>=0;e--)if(this.treeAdapter.getNamespaceURI(this.items[e])===J.HTML)switch(this.tagIDs[e]){case X.TBODY:case X.THEAD:case X.TFOOT:return!0;case X.TABLE:case X.HTML:return!1}return!0}hasInSelectScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===J.HTML)switch(this.tagIDs[t]){case e:return!0;case X.OPTION:case X.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&tL.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&nL.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(e){for(;this.currentTagId!==void 0&&this.currentTagId!==e&&nL.has(this.currentTagId);)this.pop()}},oL=3,sL;(function(e){e[e.Marker=0]=`Marker`,e[e.Element=1]=`Element`})(sL||={});var cL={type:sL.Marker},fte=class{constructor(e){this.treeAdapter=e,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(e,t){let n=[],r=t.length,i=this.treeAdapter.getTagName(e),a=this.treeAdapter.getNamespaceURI(e);for(let e=0;e<this.entries.length;e++){let t=this.entries[e];if(t.type===sL.Marker)break;let{element:o}=t;if(this.treeAdapter.getTagName(o)===i&&this.treeAdapter.getNamespaceURI(o)===a){let t=this.treeAdapter.getAttrList(o);t.length===r&&n.push({idx:e,attrs:t})}}return n}_ensureNoahArkCondition(e){if(this.entries.length<oL)return;let t=this.treeAdapter.getAttrList(e),n=this._getNoahArkConditionCandidates(e,t);if(n.length<oL)return;let r=new Map(t.map(e=>[e.name,e.value])),i=0;for(let e=0;e<n.length;e++){let t=n[e];t.attrs.every(e=>r.get(e.name)===e.value)&&(i+=1,i>=oL&&this.entries.splice(t.idx,1))}}insertMarker(){this.entries.unshift(cL)}pushElement(e,t){this._ensureNoahArkCondition(e),this.entries.unshift({type:sL.Element,element:e,token:t})}insertElementAfterBookmark(e,t){let n=this.entries.indexOf(this.bookmark);this.entries.splice(n,0,{type:sL.Element,element:e,token:t})}removeEntry(e){let t=this.entries.indexOf(e);t!==-1&&this.entries.splice(t,1)}clearToLastMarker(){let e=this.entries.indexOf(cL);e===-1?this.entries.length=0:this.entries.splice(0,e+1)}getElementEntryInScopeWithTagName(e){let t=this.entries.find(t=>t.type===sL.Marker||this.treeAdapter.getTagName(t.element)===e);return t&&t.type===sL.Element?t:null}getElementEntry(e){return this.entries.find(t=>t.type===sL.Element&&t.element===e)}},lL={createDocument(){return{nodeName:`#document`,mode:GI.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:`#document-fragment`,childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:`#comment`,data:e,parentNode:null}},createTextNode(e){return{nodeName:`#text`,value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){let r=e.childNodes.indexOf(n);e.childNodes.splice(r,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,r){let i=e.childNodes.find(e=>e.nodeName===`#documentType`);if(i)i.name=t,i.publicId=n,i.systemId=r;else{let i={nodeName:`#documentType`,name:t,publicId:n,systemId:r,parentNode:null};lL.appendChild(e,i)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){let t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){let n=e.childNodes[e.childNodes.length-1];if(lL.isTextNode(n)){n.value+=t;return}}lL.appendChild(e,lL.createTextNode(t))},insertTextBefore(e,t,n){let r=e.childNodes[e.childNodes.indexOf(n)-1];r&&lL.isTextNode(r)?r.value+=t:lL.insertBefore(e,lL.createTextNode(t),n)},adoptAttributes(e,t){let n=new Set(e.attrs.map(e=>e.name));for(let r=0;r<t.length;r++)n.has(t[r].name)||e.attrs.push(t[r])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName===`#text`},isCommentNode(e){return e.nodeName===`#comment`},isDocumentTypeNode(e){return e.nodeName===`#documentType`},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,`tagName`)},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},uL=`html`,pte=`about:legacy-compat`,mte=`http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd`,dL=`+//silmaril//dtd html pro v0r11 19970101//,-//as//dtd html 3.0 aswedit + extensions//,-//advasoft ltd//dtd html 3.0 aswedit + extensions//,-//ietf//dtd html 2.0 level 1//,-//ietf//dtd html 2.0 level 2//,-//ietf//dtd html 2.0 strict level 1//,-//ietf//dtd html 2.0 strict level 2//,-//ietf//dtd html 2.0 strict//,-//ietf//dtd html 2.0//,-//ietf//dtd html 2.1e//,-//ietf//dtd html 3.0//,-//ietf//dtd html 3.2 final//,-//ietf//dtd html 3.2//,-//ietf//dtd html 3//,-//ietf//dtd html level 0//,-//ietf//dtd html level 1//,-//ietf//dtd html level 2//,-//ietf//dtd html level 3//,-//ietf//dtd html strict level 0//,-//ietf//dtd html strict level 1//,-//ietf//dtd html strict level 2//,-//ietf//dtd html strict level 3//,-//ietf//dtd html strict//,-//ietf//dtd html//,-//metrius//dtd metrius presentational//,-//microsoft//dtd internet explorer 2.0 html strict//,-//microsoft//dtd internet explorer 2.0 html//,-//microsoft//dtd internet explorer 2.0 tables//,-//microsoft//dtd internet explorer 3.0 html strict//,-//microsoft//dtd internet explorer 3.0 html//,-//microsoft//dtd internet explorer 3.0 tables//,-//netscape comm. corp.//dtd html//,-//netscape comm. corp.//dtd strict html//,-//o'reilly and associates//dtd html 2.0//,-//o'reilly and associates//dtd html extended 1.0//,-//o'reilly and associates//dtd html extended relaxed 1.0//,-//sq//dtd html 2.0 hotmetal + extensions//,-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//,-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//,-//spyglass//dtd html 2.0 extended//,-//sun microsystems corp.//dtd hotjava html//,-//sun microsystems corp.//dtd hotjava strict html//,-//w3c//dtd html 3 1995-03-24//,-//w3c//dtd html 3.2 draft//,-//w3c//dtd html 3.2 final//,-//w3c//dtd html 3.2//,-//w3c//dtd html 3.2s draft//,-//w3c//dtd html 4.0 frameset//,-//w3c//dtd html 4.0 transitional//,-//w3c//dtd html experimental 19960712//,-//w3c//dtd html experimental 970421//,-//w3c//dtd w3 html//,-//w3o//dtd w3 html 3.0//,-//webtechs//dtd mozilla html 2.0//,-//webtechs//dtd mozilla html//`.split(`,`),hte=[...dL,`-//w3c//dtd html 4.01 frameset//`,`-//w3c//dtd html 4.01 transitional//`],gte=new Set([`-//w3o//dtd w3 html strict 3.0//en//`,`-/w3c/dtd html 4.0 transitional/en`,`html`]),fL=[`-//w3c//dtd xhtml 1.0 frameset//`,`-//w3c//dtd xhtml 1.0 transitional//`],_te=[...fL,`-//w3c//dtd html 4.01 frameset//`,`-//w3c//dtd html 4.01 transitional//`];function pL(e,t){return t.some(t=>e.startsWith(t))}function vte(e){return e.name===uL&&e.publicId===null&&(e.systemId===null||e.systemId===pte)}function yte(e){if(e.name!==uL)return GI.QUIRKS;let{systemId:t}=e;if(t&&t.toLowerCase()===mte)return GI.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),gte.has(n))return GI.QUIRKS;let e=t===null?hte:dL;if(pL(n,e))return GI.QUIRKS;if(e=t===null?fL:_te,pL(n,e))return GI.LIMITED_QUIRKS}return GI.NO_QUIRKS}var mL={TEXT_HTML:`text/html`,APPLICATION_XML:`application/xhtml+xml`},bte=`definitionurl`,xte=`definitionURL`,Ste=new Map(`attributeName.attributeType.baseFrequency.baseProfile.calcMode.clipPathUnits.diffuseConstant.edgeMode.filterUnits.glyphRef.gradientTransform.gradientUnits.kernelMatrix.kernelUnitLength.keyPoints.keySplines.keyTimes.lengthAdjust.limitingConeAngle.markerHeight.markerUnits.markerWidth.maskContentUnits.maskUnits.numOctaves.pathLength.patternContentUnits.patternTransform.patternUnits.pointsAtX.pointsAtY.pointsAtZ.preserveAlpha.preserveAspectRatio.primitiveUnits.refX.refY.repeatCount.repeatDur.requiredExtensions.requiredFeatures.specularConstant.specularExponent.spreadMethod.startOffset.stdDeviation.stitchTiles.surfaceScale.systemLanguage.tableValues.targetX.targetY.textLength.viewBox.viewTarget.xChannelSelector.yChannelSelector.zoomAndPan`.split(`.`).map(e=>[e.toLowerCase(),e])),Cte=new Map([[`xlink:actuate`,{prefix:`xlink`,name:`actuate`,namespace:J.XLINK}],[`xlink:arcrole`,{prefix:`xlink`,name:`arcrole`,namespace:J.XLINK}],[`xlink:href`,{prefix:`xlink`,name:`href`,namespace:J.XLINK}],[`xlink:role`,{prefix:`xlink`,name:`role`,namespace:J.XLINK}],[`xlink:show`,{prefix:`xlink`,name:`show`,namespace:J.XLINK}],[`xlink:title`,{prefix:`xlink`,name:`title`,namespace:J.XLINK}],[`xlink:type`,{prefix:`xlink`,name:`type`,namespace:J.XLINK}],[`xml:lang`,{prefix:`xml`,name:`lang`,namespace:J.XML}],[`xml:space`,{prefix:`xml`,name:`space`,namespace:J.XML}],[`xmlns`,{prefix:``,name:`xmlns`,namespace:J.XMLNS}],[`xmlns:xlink`,{prefix:`xmlns`,name:`xlink`,namespace:J.XMLNS}]]),wte=new Map(`altGlyph.altGlyphDef.altGlyphItem.animateColor.animateMotion.animateTransform.clipPath.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.foreignObject.glyphRef.linearGradient.radialGradient.textPath`.split(`.`).map(e=>[e.toLowerCase(),e])),Tte=new Set([X.B,X.BIG,X.BLOCKQUOTE,X.BODY,X.BR,X.CENTER,X.CODE,X.DD,X.DIV,X.DL,X.DT,X.EM,X.EMBED,X.H1,X.H2,X.H3,X.H4,X.H5,X.H6,X.HEAD,X.HR,X.I,X.IMG,X.LI,X.LISTING,X.MENU,X.META,X.NOBR,X.OL,X.P,X.PRE,X.RUBY,X.S,X.SMALL,X.SPAN,X.STRONG,X.STRIKE,X.SUB,X.SUP,X.TABLE,X.TT,X.U,X.UL,X.VAR]);function Ete(e){let t=e.tagID;return t===X.FONT&&e.attrs.some(({name:e})=>e===WI.COLOR||e===WI.SIZE||e===WI.FACE)||Tte.has(t)}function hL(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===bte){e.attrs[t].name=xte;break}}function gL(e){for(let t=0;t<e.attrs.length;t++){let n=Ste.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function _L(e){for(let t=0;t<e.attrs.length;t++){let n=Cte.get(e.attrs[t].name);n&&(e.attrs[t].prefix=n.prefix,e.attrs[t].name=n.name,e.attrs[t].namespace=n.namespace)}}function Dte(e){let t=wte.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=KI(e.tagName))}function Ote(e,t){return t===J.MATHML&&(e===X.MI||e===X.MO||e===X.MN||e===X.MS||e===X.MTEXT)}function kte(e,t,n){if(t===J.MATHML&&e===X.ANNOTATION_XML){for(let e=0;e<n.length;e++)if(n[e].name===WI.ENCODING){let t=n[e].value.toLowerCase();return t===mL.TEXT_HTML||t===mL.APPLICATION_XML}}return t===J.SVG&&(e===X.FOREIGN_OBJECT||e===X.DESC||e===X.TITLE)}function Ate(e,t,n,r){return(!r||r===J.HTML)&&kte(e,t,n)||(!r||r===J.MATHML)&&Ote(e,t)}var jte=`hidden`,Mte=8,Nte=3,$;(function(e){e[e.INITIAL=0]=`INITIAL`,e[e.BEFORE_HTML=1]=`BEFORE_HTML`,e[e.BEFORE_HEAD=2]=`BEFORE_HEAD`,e[e.IN_HEAD=3]=`IN_HEAD`,e[e.IN_HEAD_NO_SCRIPT=4]=`IN_HEAD_NO_SCRIPT`,e[e.AFTER_HEAD=5]=`AFTER_HEAD`,e[e.IN_BODY=6]=`IN_BODY`,e[e.TEXT=7]=`TEXT`,e[e.IN_TABLE=8]=`IN_TABLE`,e[e.IN_TABLE_TEXT=9]=`IN_TABLE_TEXT`,e[e.IN_CAPTION=10]=`IN_CAPTION`,e[e.IN_COLUMN_GROUP=11]=`IN_COLUMN_GROUP`,e[e.IN_TABLE_BODY=12]=`IN_TABLE_BODY`,e[e.IN_ROW=13]=`IN_ROW`,e[e.IN_CELL=14]=`IN_CELL`,e[e.IN_SELECT=15]=`IN_SELECT`,e[e.IN_SELECT_IN_TABLE=16]=`IN_SELECT_IN_TABLE`,e[e.IN_TEMPLATE=17]=`IN_TEMPLATE`,e[e.AFTER_BODY=18]=`AFTER_BODY`,e[e.IN_FRAMESET=19]=`IN_FRAMESET`,e[e.AFTER_FRAMESET=20]=`AFTER_FRAMESET`,e[e.AFTER_AFTER_BODY=21]=`AFTER_AFTER_BODY`,e[e.AFTER_AFTER_FRAMESET=22]=`AFTER_AFTER_FRAMESET`})($||={});var Pte={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},vL=new Set([X.TABLE,X.TBODY,X.TFOOT,X.THEAD,X.TR]),yL={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:lL,onParseError:null},bL=class{constructor(e,t,n=null,r=null){this.fragmentContext=n,this.scriptHandler=r,this.currentToken=null,this.stopped=!1,this.insertionMode=$.INITIAL,this.originalInsertionMode=$.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...yL,...e},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=t??this.treeAdapter.createDocument(),this.tokenizer=new ite(this.options,this),this.activeFormattingElements=new fte(this.treeAdapter),this.fragmentContextID=n?KI(this.treeAdapter.getTagName(n)):X.UNKNOWN,this._setContextModes(n??this.document,this.fragmentContextID),this.openElements=new dte(this.document,this.treeAdapter,this)}static parse(e,t){let n=new this(t);return n.tokenizer.write(e,!0),n.document}static getFragmentParser(e,t){let n={...yL,...t};e??=n.treeAdapter.createElement(Y.TEMPLATE,J.HTML,[]);let r=n.treeAdapter.createElement(`documentmock`,J.HTML,[]),i=new this(n,r,e);return i.fragmentContextID===X.TEMPLATE&&i.tmplInsertionModeStack.unshift($.IN_TEMPLATE),i._initTokenizerForFragmentParsing(),i._insertFakeRootElement(),i._resetInsertionMode(),i._findFormInFragmentContext(),i}getFragment(){let e=this.treeAdapter.getFirstChild(this.document),t=this.treeAdapter.createDocumentFragment();return this._adoptNodes(e,t),t}_err(e,t,n){if(!this.onParseError)return;let r=e.location??Pte,i={code:t,startLine:r.startLine,startCol:r.startCol,startOffset:r.startOffset,endLine:n?r.startLine:r.endLine,endCol:n?r.startCol:r.endCol,endOffset:n?r.startOffset:r.endOffset};this.onParseError(i)}onItemPush(e,t,n){var r,i;(i=(r=this.treeAdapter).onItemPush)==null||i.call(r,e),n&&this.openElements.stackTop>0&&this._setContextModes(e,t)}onItemPop(e,t){var n,r;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(e,this.currentToken),(r=(n=this.treeAdapter).onItemPop)==null||r.call(n,e,this.openElements.current),t){let e,t;this.openElements.stackTop===0&&this.fragmentContext?(e=this.fragmentContext,t=this.fragmentContextID):{current:e,currentTagId:t}=this.openElements,this._setContextModes(e,t)}}_setContextModes(e,t){let n=e===this.document||e&&this.treeAdapter.getNamespaceURI(e)===J.HTML;this.currentNotInHTML=!n,this.tokenizer.inForeignNode=!n&&e!==void 0&&t!==void 0&&!this._isIntegrationPoint(t,e)}_switchToTextParsing(e,t){this._insertElement(e,J.HTML),this.tokenizer.state=t,this.originalInsertionMode=this.insertionMode,this.insertionMode=$.TEXT}switchToPlaintextParsing(){this.insertionMode=$.TEXT,this.originalInsertionMode=$.IN_BODY,this.tokenizer.state=JI.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let e=this.fragmentContext;for(;e;){if(this.treeAdapter.getTagName(e)===Y.FORM){this.formElement=e;break}e=this.treeAdapter.getParentNode(e)}}_initTokenizerForFragmentParsing(){if(this.fragmentContext&&this.treeAdapter.getNamespaceURI(this.fragmentContext)===J.HTML)switch(this.fragmentContextID){case X.TITLE:case X.TEXTAREA:this.tokenizer.state=JI.RCDATA;break;case X.STYLE:case X.XMP:case X.IFRAME:case X.NOEMBED:case X.NOFRAMES:case X.NOSCRIPT:this.tokenizer.state=JI.RAWTEXT;break;case X.SCRIPT:this.tokenizer.state=JI.SCRIPT_DATA;break;case X.PLAINTEXT:this.tokenizer.state=JI.PLAINTEXT}}_setDocumentType(e){let t=e.name||``,n=e.publicId||``,r=e.systemId||``;if(this.treeAdapter.setDocumentType(this.document,t,n,r),e.location){let t=this.treeAdapter.getChildNodes(this.document).find(e=>this.treeAdapter.isDocumentTypeNode(e));t&&this.treeAdapter.setNodeSourceCodeLocation(t,e.location)}}_attachElementToTree(e,t){if(this.options.sourceCodeLocationInfo){let n=t&&{...t,startTag:t};this.treeAdapter.setNodeSourceCodeLocation(e,n)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(e);else{let t=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(t??this.document,e)}}_appendElement(e,t){let n=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(n,e.location)}_insertElement(e,t){let n=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(n,e.location),this.openElements.push(n,e.tagID)}_insertFakeElement(e,t){let n=this.treeAdapter.createElement(e,J.HTML,[]);this._attachElementToTree(n,null),this.openElements.push(n,t)}_insertTemplate(e){let t=this.treeAdapter.createElement(e.tagName,J.HTML,e.attrs),n=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(t,n),this._attachElementToTree(t,e.location),this.openElements.push(t,e.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,null)}_insertFakeRootElement(){let e=this.treeAdapter.createElement(Y.HTML,J.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(e,null),this.treeAdapter.appendChild(this.openElements.current,e),this.openElements.push(e,X.HTML)}_appendCommentNode(e,t){let n=this.treeAdapter.createCommentNode(e.data);this.treeAdapter.appendChild(t,n),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,e.location)}_insertCharacters(e){let t,n;if(this._shouldFosterParentOnInsertion()?({parent:t,beforeElement:n}=this._findFosterParentingLocation(),n?this.treeAdapter.insertTextBefore(t,e.chars,n):this.treeAdapter.insertText(t,e.chars)):(t=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(t,e.chars)),!e.location)return;let r=this.treeAdapter.getChildNodes(t),i=r[(n?r.lastIndexOf(n):r.length)-1];if(this.treeAdapter.getNodeSourceCodeLocation(i)){let{endLine:t,endCol:n,endOffset:r}=e.location;this.treeAdapter.updateNodeSourceCodeLocation(i,{endLine:t,endCol:n,endOffset:r})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,e.location)}_adoptNodes(e,t){for(let n=this.treeAdapter.getFirstChild(e);n;n=this.treeAdapter.getFirstChild(e))this.treeAdapter.detachNode(n),this.treeAdapter.appendChild(t,n)}_setEndLocation(e,t){if(this.treeAdapter.getNodeSourceCodeLocation(e)&&t.location){let n=t.location,r=this.treeAdapter.getTagName(e),i=t.type===OI.END_TAG&&r===t.tagName?{endTag:{...n},endLine:n.endLine,endCol:n.endCol,endOffset:n.endOffset}:{endLine:n.startLine,endCol:n.startCol,endOffset:n.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(e,i)}}shouldProcessStartTagTokenInForeignContent(e){if(!this.currentNotInHTML)return!1;let t,n;return this.openElements.stackTop===0&&this.fragmentContext?(t=this.fragmentContext,n=this.fragmentContextID):{current:t,currentTagId:n}=this.openElements,e.tagID===X.SVG&&this.treeAdapter.getTagName(t)===Y.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(t)===J.MATHML?!1:this.tokenizer.inForeignNode||(e.tagID===X.MGLYPH||e.tagID===X.MALIGNMARK)&&n!==void 0&&!this._isIntegrationPoint(n,t,J.HTML)}_processToken(e){switch(e.type){case OI.CHARACTER:this.onCharacter(e);break;case OI.NULL_CHARACTER:this.onNullCharacter(e);break;case OI.COMMENT:this.onComment(e);break;case OI.DOCTYPE:this.onDoctype(e);break;case OI.START_TAG:this._processStartTag(e);break;case OI.END_TAG:this.onEndTag(e);break;case OI.EOF:this.onEof(e);break;case OI.WHITESPACE_CHARACTER:this.onWhitespaceCharacter(e)}}_isIntegrationPoint(e,t,n){return Ate(e,this.treeAdapter.getNamespaceURI(t),this.treeAdapter.getAttrList(t),n)}_reconstructActiveFormattingElements(){let e=this.activeFormattingElements.entries.length;if(e){let t=this.activeFormattingElements.entries.findIndex(e=>e.type===sL.Marker||this.openElements.contains(e.element)),n=t===-1?e-1:t-1;for(let e=n;e>=0;e--){let t=this.activeFormattingElements.entries[e];this._insertElement(t.token,this.treeAdapter.getNamespaceURI(t.element)),t.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=$.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(X.P),this.openElements.popUntilTagNamePopped(X.P)}_resetInsertionMode(){for(let e=this.openElements.stackTop;e>=0;e--)switch(e===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[e]){case X.TR:this.insertionMode=$.IN_ROW;return;case X.TBODY:case X.THEAD:case X.TFOOT:this.insertionMode=$.IN_TABLE_BODY;return;case X.CAPTION:this.insertionMode=$.IN_CAPTION;return;case X.COLGROUP:this.insertionMode=$.IN_COLUMN_GROUP;return;case X.TABLE:this.insertionMode=$.IN_TABLE;return;case X.BODY:this.insertionMode=$.IN_BODY;return;case X.FRAMESET:this.insertionMode=$.IN_FRAMESET;return;case X.SELECT:this._resetInsertionModeForSelect(e);return;case X.TEMPLATE:this.insertionMode=this.tmplInsertionModeStack[0];return;case X.HTML:this.insertionMode=this.headElement?$.AFTER_HEAD:$.BEFORE_HEAD;return;case X.TD:case X.TH:if(e>0){this.insertionMode=$.IN_CELL;return}break;case X.HEAD:if(e>0){this.insertionMode=$.IN_HEAD;return}}this.insertionMode=$.IN_BODY}_resetInsertionModeForSelect(e){if(e>0)for(let t=e-1;t>0;t--){let e=this.openElements.tagIDs[t];if(e===X.TEMPLATE)break;if(e===X.TABLE){this.insertionMode=$.IN_SELECT_IN_TABLE;return}}this.insertionMode=$.IN_SELECT}_isElementCausesFosterParenting(e){return vL.has(e)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let e=this.openElements.stackTop;e>=0;e--){let t=this.openElements.items[e];switch(this.openElements.tagIDs[e]){case X.TEMPLATE:if(this.treeAdapter.getNamespaceURI(t)===J.HTML)return{parent:this.treeAdapter.getTemplateContent(t),beforeElement:null};break;case X.TABLE:{let n=this.treeAdapter.getParentNode(t);return n?{parent:n,beforeElement:t}:{parent:this.openElements.items[e-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(e){let t=this._findFosterParentingLocation();t.beforeElement?this.treeAdapter.insertBefore(t.parent,e,t.beforeElement):this.treeAdapter.appendChild(t.parent,e)}_isSpecialElement(e,t){return ete[this.treeAdapter.getNamespaceURI(e)].has(t)}onCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){KR(this,e);return}switch(this.insertionMode){case $.INITIAL:wL(this,e);break;case $.BEFORE_HTML:TL(this,e);break;case $.BEFORE_HEAD:EL(this,e);break;case $.IN_HEAD:kL(this,e);break;case $.IN_HEAD_NO_SCRIPT:AL(this,e);break;case $.AFTER_HEAD:jL(this,e);break;case $.IN_BODY:case $.IN_CAPTION:case $.IN_CELL:case $.IN_TEMPLATE:PL(this,e);break;case $.TEXT:case $.IN_SELECT:case $.IN_SELECT_IN_TABLE:this._insertCharacters(e);break;case $.IN_TABLE:case $.IN_TABLE_BODY:case $.IN_ROW:tR(this,e);break;case $.IN_TABLE_TEXT:mR(this,e);break;case $.IN_COLUMN_GROUP:xR(this,e);break;case $.AFTER_BODY:LR(this,e);break;case $.AFTER_AFTER_BODY:UR(this,e)}}onNullCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){GR(this,e);return}switch(this.insertionMode){case $.INITIAL:wL(this,e);break;case $.BEFORE_HTML:TL(this,e);break;case $.BEFORE_HEAD:EL(this,e);break;case $.IN_HEAD:kL(this,e);break;case $.IN_HEAD_NO_SCRIPT:AL(this,e);break;case $.AFTER_HEAD:jL(this,e);break;case $.TEXT:this._insertCharacters(e);break;case $.IN_TABLE:case $.IN_TABLE_BODY:case $.IN_ROW:tR(this,e);break;case $.IN_COLUMN_GROUP:xR(this,e);break;case $.AFTER_BODY:LR(this,e);break;case $.AFTER_AFTER_BODY:UR(this,e)}}onComment(e){if(this.skipNextNewLine=!1,this.currentNotInHTML){SL(this,e);return}switch(this.insertionMode){case $.INITIAL:case $.BEFORE_HTML:case $.BEFORE_HEAD:case $.IN_HEAD:case $.IN_HEAD_NO_SCRIPT:case $.AFTER_HEAD:case $.IN_BODY:case $.IN_TABLE:case $.IN_CAPTION:case $.IN_COLUMN_GROUP:case $.IN_TABLE_BODY:case $.IN_ROW:case $.IN_CELL:case $.IN_SELECT:case $.IN_SELECT_IN_TABLE:case $.IN_TEMPLATE:case $.IN_FRAMESET:case $.AFTER_FRAMESET:SL(this,e);break;case $.IN_TABLE_TEXT:hR(this,e);break;case $.AFTER_BODY:Vte(this,e);break;case $.AFTER_AFTER_BODY:case $.AFTER_AFTER_FRAMESET:Hte(this,e)}}onDoctype(e){switch(this.skipNextNewLine=!1,this.insertionMode){case $.INITIAL:Ute(this,e);break;case $.BEFORE_HEAD:case $.IN_HEAD:case $.IN_HEAD_NO_SCRIPT:case $.AFTER_HEAD:this._err(e,q.misplacedDoctype);break;case $.IN_TABLE_TEXT:hR(this,e)}}onStartTag(e){this.skipNextNewLine=!1,this.currentToken=e,this._processStartTag(e),e.selfClosing&&!e.ackSelfClosing&&this._err(e,q.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(e){this.shouldProcessStartTagTokenInForeignContent(e)?JR(this,e):this._startTagOutsideForeignContent(e)}_startTagOutsideForeignContent(e){switch(this.insertionMode){case $.INITIAL:wL(this,e);break;case $.BEFORE_HTML:Wte(this,e);break;case $.BEFORE_HEAD:Kte(this,e);break;case $.IN_HEAD:DL(this,e);break;case $.IN_HEAD_NO_SCRIPT:Yte(this,e);break;case $.AFTER_HEAD:Zte(this,e);break;case $.IN_BODY:zL(this,e);break;case $.IN_TABLE:uR(this,e);break;case $.IN_TABLE_TEXT:hR(this,e);break;case $.IN_CAPTION:_R(this,e);break;case $.IN_COLUMN_GROUP:yR(this,e);break;case $.IN_TABLE_BODY:SR(this,e);break;case $.IN_ROW:wR(this,e);break;case $.IN_CELL:ER(this,e);break;case $.IN_SELECT:OR(this,e);break;case $.IN_SELECT_IN_TABLE:AR(this,e);break;case $.IN_TEMPLATE:MR(this,e);break;case $.AFTER_BODY:FR(this,e);break;case $.IN_FRAMESET:RR(this,e);break;case $.AFTER_FRAMESET:BR(this,e);break;case $.AFTER_AFTER_BODY:HR(this,e);break;case $.AFTER_AFTER_FRAMESET:WR(this,e)}}onEndTag(e){this.skipNextNewLine=!1,this.currentToken=e,this.currentNotInHTML?YR(this,e):this._endTagOutsideForeignContent(e)}_endTagOutsideForeignContent(e){switch(this.insertionMode){case $.INITIAL:wL(this,e);break;case $.BEFORE_HTML:Gte(this,e);break;case $.BEFORE_HEAD:qte(this,e);break;case $.IN_HEAD:Jte(this,e);break;case $.IN_HEAD_NO_SCRIPT:Xte(this,e);break;case $.AFTER_HEAD:Qte(this,e);break;case $.IN_BODY:ZL(this,e);break;case $.TEXT:$L(this,e);break;case $.IN_TABLE:dR(this,e);break;case $.IN_TABLE_TEXT:hR(this,e);break;case $.IN_CAPTION:vR(this,e);break;case $.IN_COLUMN_GROUP:bR(this,e);break;case $.IN_TABLE_BODY:CR(this,e);break;case $.IN_ROW:TR(this,e);break;case $.IN_CELL:DR(this,e);break;case $.IN_SELECT:kR(this,e);break;case $.IN_SELECT_IN_TABLE:jR(this,e);break;case $.IN_TEMPLATE:NR(this,e);break;case $.AFTER_BODY:IR(this,e);break;case $.IN_FRAMESET:zR(this,e);break;case $.AFTER_FRAMESET:VR(this,e);break;case $.AFTER_AFTER_BODY:UR(this,e)}}onEof(e){switch(this.insertionMode){case $.INITIAL:wL(this,e);break;case $.BEFORE_HTML:TL(this,e);break;case $.BEFORE_HEAD:EL(this,e);break;case $.IN_HEAD:kL(this,e);break;case $.IN_HEAD_NO_SCRIPT:AL(this,e);break;case $.AFTER_HEAD:jL(this,e);break;case $.IN_BODY:case $.IN_TABLE:case $.IN_CAPTION:case $.IN_COLUMN_GROUP:case $.IN_TABLE_BODY:case $.IN_ROW:case $.IN_CELL:case $.IN_SELECT:case $.IN_SELECT_IN_TABLE:QL(this,e);break;case $.TEXT:eR(this,e);break;case $.IN_TABLE_TEXT:hR(this,e);break;case $.IN_TEMPLATE:PR(this,e);break;case $.AFTER_BODY:case $.IN_FRAMESET:case $.AFTER_FRAMESET:case $.AFTER_AFTER_BODY:case $.AFTER_AFTER_FRAMESET:CL(this,e)}}onWhitespaceCharacter(e){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,e.chars.charCodeAt(0)===K.LINE_FEED)){if(e.chars.length===1)return;e.chars=e.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(e);return}switch(this.insertionMode){case $.IN_HEAD:case $.IN_HEAD_NO_SCRIPT:case $.AFTER_HEAD:case $.TEXT:case $.IN_COLUMN_GROUP:case $.IN_SELECT:case $.IN_SELECT_IN_TABLE:case $.IN_FRAMESET:case $.AFTER_FRAMESET:this._insertCharacters(e);break;case $.IN_BODY:case $.IN_CAPTION:case $.IN_CELL:case $.IN_TEMPLATE:case $.AFTER_BODY:case $.AFTER_AFTER_BODY:case $.AFTER_AFTER_FRAMESET:NL(this,e);break;case $.IN_TABLE:case $.IN_TABLE_BODY:case $.IN_ROW:tR(this,e);break;case $.IN_TABLE_TEXT:pR(this,e)}}};function Fte(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):XL(e,t),n}function Ite(e,t){let n=null,r=e.openElements.stackTop;for(;r>=0;r--){let i=e.openElements.items[r];if(i===t.element)break;e._isSpecialElement(i,e.openElements.tagIDs[r])&&(n=i)}return n||(e.openElements.shortenToLength(Math.max(r,0)),e.activeFormattingElements.removeEntry(t)),n}function Lte(e,t,n){let r=t,i=e.openElements.getCommonAncestor(t);for(let a=0,o=i;o!==n;a++,o=i){i=e.openElements.getCommonAncestor(o);let n=e.activeFormattingElements.getElementEntry(o),s=n&&a>=Nte;!n||s?(s&&e.activeFormattingElements.removeEntry(n),e.openElements.remove(o)):(o=Rte(e,n),r===t&&(e.activeFormattingElements.bookmark=n),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(o,r),r=o)}return r}function Rte(e,t){let n=e.treeAdapter.getNamespaceURI(t.element),r=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,r),t.element=r,r}function zte(e,t,n){let r=KI(e.treeAdapter.getTagName(t));if(e._isElementCausesFosterParenting(r))e._fosterParentElement(n);else{let i=e.treeAdapter.getNamespaceURI(t);r===X.TEMPLATE&&i===J.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function Bte(e,t,n){let r=e.treeAdapter.getNamespaceURI(n.element),{token:i}=n,a=e.treeAdapter.createElement(i.tagName,r,i.attrs);e._adoptNodes(t,a),e.treeAdapter.appendChild(t,a),e.activeFormattingElements.insertElementAfterBookmark(a,i),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,a,i.tagID)}function xL(e,t){for(let n=0;n<Mte;n++){let n=Fte(e,t);if(!n)break;let r=Ite(e,n);if(!r)break;e.activeFormattingElements.bookmark=n;let i=Lte(e,r,n.element),a=e.openElements.getCommonAncestor(n.element);e.treeAdapter.detachNode(i),a&&zte(e,a,i),Bte(e,r,n)}}function SL(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function Vte(e,t){e._appendCommentNode(t,e.openElements.items[0])}function Hte(e,t){e._appendCommentNode(t,e.document)}function CL(e,t){if(e.stopped=!0,t.location){let n=e.fragmentContext?0:2;for(let r=e.openElements.stackTop;r>=n;r--)e._setEndLocation(e.openElements.items[r],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){let n=e.openElements.items[0],r=e.treeAdapter.getNodeSourceCodeLocation(n);if(r&&!r.endTag&&(e._setEndLocation(n,t),e.openElements.stackTop>=1)){let n=e.openElements.items[1],r=e.treeAdapter.getNodeSourceCodeLocation(n);r&&!r.endTag&&e._setEndLocation(n,t)}}}}function Ute(e,t){e._setDocumentType(t);let n=t.forceQuirks?GI.QUIRKS:yte(t);vte(t)||e._err(t,q.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=$.BEFORE_HTML}function wL(e,t){e._err(t,q.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,GI.QUIRKS),e.insertionMode=$.BEFORE_HTML,e._processToken(t)}function Wte(e,t){t.tagID===X.HTML?(e._insertElement(t,J.HTML),e.insertionMode=$.BEFORE_HEAD):TL(e,t)}function Gte(e,t){let n=t.tagID;(n===X.HTML||n===X.HEAD||n===X.BODY||n===X.BR)&&TL(e,t)}function TL(e,t){e._insertFakeRootElement(),e.insertionMode=$.BEFORE_HEAD,e._processToken(t)}function Kte(e,t){switch(t.tagID){case X.HTML:zL(e,t);break;case X.HEAD:e._insertElement(t,J.HTML),e.headElement=e.openElements.current,e.insertionMode=$.IN_HEAD;break;default:EL(e,t)}}function qte(e,t){let n=t.tagID;n===X.HEAD||n===X.BODY||n===X.HTML||n===X.BR?EL(e,t):e._err(t,q.endTagWithoutMatchingOpenElement)}function EL(e,t){e._insertFakeElement(Y.HEAD,X.HEAD),e.headElement=e.openElements.current,e.insertionMode=$.IN_HEAD,e._processToken(t)}function DL(e,t){switch(t.tagID){case X.HTML:zL(e,t);break;case X.BASE:case X.BASEFONT:case X.BGSOUND:case X.LINK:case X.META:e._appendElement(t,J.HTML),t.ackSelfClosing=!0;break;case X.TITLE:e._switchToTextParsing(t,JI.RCDATA);break;case X.NOSCRIPT:e.options.scriptingEnabled?e._switchToTextParsing(t,JI.RAWTEXT):(e._insertElement(t,J.HTML),e.insertionMode=$.IN_HEAD_NO_SCRIPT);break;case X.NOFRAMES:case X.STYLE:e._switchToTextParsing(t,JI.RAWTEXT);break;case X.SCRIPT:e._switchToTextParsing(t,JI.SCRIPT_DATA);break;case X.TEMPLATE:e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=$.IN_TEMPLATE,e.tmplInsertionModeStack.unshift($.IN_TEMPLATE);break;case X.HEAD:e._err(t,q.misplacedStartTagForHeadElement);break;default:kL(e,t)}}function Jte(e,t){switch(t.tagID){case X.HEAD:e.openElements.pop(),e.insertionMode=$.AFTER_HEAD;break;case X.BODY:case X.BR:case X.HTML:kL(e,t);break;case X.TEMPLATE:OL(e,t);break;default:e._err(t,q.endTagWithoutMatchingOpenElement)}}function OL(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==X.TEMPLATE&&e._err(t,q.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(X.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,q.endTagWithoutMatchingOpenElement)}function kL(e,t){e.openElements.pop(),e.insertionMode=$.AFTER_HEAD,e._processToken(t)}function Yte(e,t){switch(t.tagID){case X.HTML:zL(e,t);break;case X.BASEFONT:case X.BGSOUND:case X.HEAD:case X.LINK:case X.META:case X.NOFRAMES:case X.STYLE:DL(e,t);break;case X.NOSCRIPT:e._err(t,q.nestedNoscriptInHead);break;default:AL(e,t)}}function Xte(e,t){switch(t.tagID){case X.NOSCRIPT:e.openElements.pop(),e.insertionMode=$.IN_HEAD;break;case X.BR:AL(e,t);break;default:e._err(t,q.endTagWithoutMatchingOpenElement)}}function AL(e,t){let n=t.type===OI.EOF?q.openElementsLeftAfterEof:q.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=$.IN_HEAD,e._processToken(t)}function Zte(e,t){switch(t.tagID){case X.HTML:zL(e,t);break;case X.BODY:e._insertElement(t,J.HTML),e.framesetOk=!1,e.insertionMode=$.IN_BODY;break;case X.FRAMESET:e._insertElement(t,J.HTML),e.insertionMode=$.IN_FRAMESET;break;case X.BASE:case X.BASEFONT:case X.BGSOUND:case X.LINK:case X.META:case X.NOFRAMES:case X.SCRIPT:case X.STYLE:case X.TEMPLATE:case X.TITLE:e._err(t,q.abandonedHeadElementChild),e.openElements.push(e.headElement,X.HEAD),DL(e,t),e.openElements.remove(e.headElement);break;case X.HEAD:e._err(t,q.misplacedStartTagForHeadElement);break;default:jL(e,t)}}function Qte(e,t){switch(t.tagID){case X.BODY:case X.HTML:case X.BR:jL(e,t);break;case X.TEMPLATE:OL(e,t);break;default:e._err(t,q.endTagWithoutMatchingOpenElement)}}function jL(e,t){e._insertFakeElement(Y.BODY,X.BODY),e.insertionMode=$.IN_BODY,ML(e,t)}function ML(e,t){switch(t.type){case OI.CHARACTER:PL(e,t);break;case OI.WHITESPACE_CHARACTER:NL(e,t);break;case OI.COMMENT:SL(e,t);break;case OI.START_TAG:zL(e,t);break;case OI.END_TAG:ZL(e,t);break;case OI.EOF:QL(e,t)}}function NL(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function PL(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function $te(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function ene(e,t){let n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function tne(e,t){let n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,J.HTML),e.insertionMode=$.IN_FRAMESET)}function nne(e,t){e.openElements.hasInButtonScope(X.P)&&e._closePElement(),e._insertElement(t,J.HTML)}function rne(e,t){e.openElements.hasInButtonScope(X.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&qI.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,J.HTML)}function ine(e,t){e.openElements.hasInButtonScope(X.P)&&e._closePElement(),e._insertElement(t,J.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function ane(e,t){let n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(X.P)&&e._closePElement(),e._insertElement(t,J.HTML),n||(e.formElement=e.openElements.current))}function one(e,t){e.framesetOk=!1;let n=t.tagID;for(let t=e.openElements.stackTop;t>=0;t--){let r=e.openElements.tagIDs[t];if(n===X.LI&&r===X.LI||(n===X.DD||n===X.DT)&&(r===X.DD||r===X.DT)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.popUntilTagNamePopped(r);break}if(r!==X.ADDRESS&&r!==X.DIV&&r!==X.P&&e._isSpecialElement(e.openElements.items[t],r))break}e.openElements.hasInButtonScope(X.P)&&e._closePElement(),e._insertElement(t,J.HTML)}function sne(e,t){e.openElements.hasInButtonScope(X.P)&&e._closePElement(),e._insertElement(t,J.HTML),e.tokenizer.state=JI.PLAINTEXT}function cne(e,t){e.openElements.hasInScope(X.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(X.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,J.HTML),e.framesetOk=!1}function lne(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(Y.A);n&&(xL(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,J.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function une(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,J.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function dne(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(X.NOBR)&&(xL(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,J.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function fne(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,J.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function pne(e,t){e.treeAdapter.getDocumentMode(e.document)!==GI.QUIRKS&&e.openElements.hasInButtonScope(X.P)&&e._closePElement(),e._insertElement(t,J.HTML),e.framesetOk=!1,e.insertionMode=$.IN_TABLE}function FL(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,J.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function IL(e){let t=kI(e,WI.TYPE);return t!=null&&t.toLowerCase()===jte}function mne(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,J.HTML),IL(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function hne(e,t){e._appendElement(t,J.HTML),t.ackSelfClosing=!0}function gne(e,t){e.openElements.hasInButtonScope(X.P)&&e._closePElement(),e._appendElement(t,J.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function _ne(e,t){t.tagName=Y.IMG,t.tagID=X.IMG,FL(e,t)}function vne(e,t){e._insertElement(t,J.HTML),e.skipNextNewLine=!0,e.tokenizer.state=JI.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=$.TEXT}function yne(e,t){e.openElements.hasInButtonScope(X.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,JI.RAWTEXT)}function bne(e,t){e.framesetOk=!1,e._switchToTextParsing(t,JI.RAWTEXT)}function LL(e,t){e._switchToTextParsing(t,JI.RAWTEXT)}function xne(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,J.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===$.IN_TABLE||e.insertionMode===$.IN_CAPTION||e.insertionMode===$.IN_TABLE_BODY||e.insertionMode===$.IN_ROW||e.insertionMode===$.IN_CELL?$.IN_SELECT_IN_TABLE:$.IN_SELECT}function Sne(e,t){e.openElements.currentTagId===X.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,J.HTML)}function Cne(e,t){e.openElements.hasInScope(X.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,J.HTML)}function wne(e,t){e.openElements.hasInScope(X.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(X.RTC),e._insertElement(t,J.HTML)}function Tne(e,t){e._reconstructActiveFormattingElements(),hL(t),_L(t),t.selfClosing?e._appendElement(t,J.MATHML):e._insertElement(t,J.MATHML),t.ackSelfClosing=!0}function Ene(e,t){e._reconstructActiveFormattingElements(),gL(t),_L(t),t.selfClosing?e._appendElement(t,J.SVG):e._insertElement(t,J.SVG),t.ackSelfClosing=!0}function RL(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,J.HTML)}function zL(e,t){switch(t.tagID){case X.I:case X.S:case X.B:case X.U:case X.EM:case X.TT:case X.BIG:case X.CODE:case X.FONT:case X.SMALL:case X.STRIKE:case X.STRONG:une(e,t);break;case X.A:lne(e,t);break;case X.H1:case X.H2:case X.H3:case X.H4:case X.H5:case X.H6:rne(e,t);break;case X.P:case X.DL:case X.OL:case X.UL:case X.DIV:case X.DIR:case X.NAV:case X.MAIN:case X.MENU:case X.ASIDE:case X.CENTER:case X.FIGURE:case X.FOOTER:case X.HEADER:case X.HGROUP:case X.DIALOG:case X.DETAILS:case X.ADDRESS:case X.ARTICLE:case X.SEARCH:case X.SECTION:case X.SUMMARY:case X.FIELDSET:case X.BLOCKQUOTE:case X.FIGCAPTION:nne(e,t);break;case X.LI:case X.DD:case X.DT:one(e,t);break;case X.BR:case X.IMG:case X.WBR:case X.AREA:case X.EMBED:case X.KEYGEN:FL(e,t);break;case X.HR:gne(e,t);break;case X.RB:case X.RTC:Cne(e,t);break;case X.RT:case X.RP:wne(e,t);break;case X.PRE:case X.LISTING:ine(e,t);break;case X.XMP:yne(e,t);break;case X.SVG:Ene(e,t);break;case X.HTML:$te(e,t);break;case X.BASE:case X.LINK:case X.META:case X.STYLE:case X.TITLE:case X.SCRIPT:case X.BGSOUND:case X.BASEFONT:case X.TEMPLATE:DL(e,t);break;case X.BODY:ene(e,t);break;case X.FORM:ane(e,t);break;case X.NOBR:dne(e,t);break;case X.MATH:Tne(e,t);break;case X.TABLE:pne(e,t);break;case X.INPUT:mne(e,t);break;case X.PARAM:case X.TRACK:case X.SOURCE:hne(e,t);break;case X.IMAGE:_ne(e,t);break;case X.BUTTON:cne(e,t);break;case X.APPLET:case X.OBJECT:case X.MARQUEE:fne(e,t);break;case X.IFRAME:bne(e,t);break;case X.SELECT:xne(e,t);break;case X.OPTION:case X.OPTGROUP:Sne(e,t);break;case X.NOEMBED:case X.NOFRAMES:LL(e,t);break;case X.FRAMESET:tne(e,t);break;case X.TEXTAREA:vne(e,t);break;case X.NOSCRIPT:e.options.scriptingEnabled?LL(e,t):RL(e,t);break;case X.PLAINTEXT:sne(e,t);break;case X.COL:case X.TH:case X.TD:case X.TR:case X.HEAD:case X.FRAME:case X.TBODY:case X.TFOOT:case X.THEAD:case X.CAPTION:case X.COLGROUP:break;default:RL(e,t)}}function BL(e,t){if(e.openElements.hasInScope(X.BODY)&&(e.insertionMode=$.AFTER_BODY,e.options.sourceCodeLocationInfo)){let n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function VL(e,t){e.openElements.hasInScope(X.BODY)&&(e.insertionMode=$.AFTER_BODY,IR(e,t))}function HL(e,t){let n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function UL(e){let t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(X.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(X.FORM):n&&e.openElements.remove(n))}function WL(e){e.openElements.hasInButtonScope(X.P)||e._insertFakeElement(Y.P,X.P),e._closePElement()}function GL(e){e.openElements.hasInListItemScope(X.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(X.LI),e.openElements.popUntilTagNamePopped(X.LI))}function KL(e,t){let n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function qL(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function JL(e,t){let n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function YL(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(Y.BR,X.BR),e.openElements.pop(),e.framesetOk=!1}function XL(e,t){let n=t.tagName,r=t.tagID;for(let t=e.openElements.stackTop;t>0;t--){let i=e.openElements.items[t],a=e.openElements.tagIDs[t];if(r===a&&(r!==X.UNKNOWN||e.treeAdapter.getTagName(i)===n)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.stackTop>=t&&e.openElements.shortenToLength(t);break}if(e._isSpecialElement(i,a))break}}function ZL(e,t){switch(t.tagID){case X.A:case X.B:case X.I:case X.S:case X.U:case X.EM:case X.TT:case X.BIG:case X.CODE:case X.FONT:case X.NOBR:case X.SMALL:case X.STRIKE:case X.STRONG:xL(e,t);break;case X.P:WL(e);break;case X.DL:case X.UL:case X.OL:case X.DIR:case X.DIV:case X.NAV:case X.PRE:case X.MAIN:case X.MENU:case X.ASIDE:case X.BUTTON:case X.CENTER:case X.FIGURE:case X.FOOTER:case X.HEADER:case X.HGROUP:case X.DIALOG:case X.ADDRESS:case X.ARTICLE:case X.DETAILS:case X.SEARCH:case X.SECTION:case X.SUMMARY:case X.LISTING:case X.FIELDSET:case X.BLOCKQUOTE:case X.FIGCAPTION:HL(e,t);break;case X.LI:GL(e);break;case X.DD:case X.DT:KL(e,t);break;case X.H1:case X.H2:case X.H3:case X.H4:case X.H5:case X.H6:qL(e);break;case X.BR:YL(e);break;case X.BODY:BL(e,t);break;case X.HTML:VL(e,t);break;case X.FORM:UL(e);break;case X.APPLET:case X.OBJECT:case X.MARQUEE:JL(e,t);break;case X.TEMPLATE:OL(e,t);break;default:XL(e,t)}}function QL(e,t){e.tmplInsertionModeStack.length>0?PR(e,t):CL(e,t)}function $L(e,t){var n;t.tagID===X.SCRIPT&&((n=e.scriptHandler)==null||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function eR(e,t){e._err(t,q.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function tR(e,t){if(e.openElements.currentTagId!==void 0&&vL.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=$.IN_TABLE_TEXT,t.type){case OI.CHARACTER:mR(e,t);break;case OI.WHITESPACE_CHARACTER:pR(e,t)}else fR(e,t)}function nR(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,J.HTML),e.insertionMode=$.IN_CAPTION}function rR(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,J.HTML),e.insertionMode=$.IN_COLUMN_GROUP}function iR(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(Y.COLGROUP,X.COLGROUP),e.insertionMode=$.IN_COLUMN_GROUP,yR(e,t)}function aR(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,J.HTML),e.insertionMode=$.IN_TABLE_BODY}function oR(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(Y.TBODY,X.TBODY),e.insertionMode=$.IN_TABLE_BODY,SR(e,t)}function sR(e,t){e.openElements.hasInTableScope(X.TABLE)&&(e.openElements.popUntilTagNamePopped(X.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function cR(e,t){IL(t)?e._appendElement(t,J.HTML):fR(e,t),t.ackSelfClosing=!0}function lR(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,J.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function uR(e,t){switch(t.tagID){case X.TD:case X.TH:case X.TR:oR(e,t);break;case X.STYLE:case X.SCRIPT:case X.TEMPLATE:DL(e,t);break;case X.COL:iR(e,t);break;case X.FORM:lR(e,t);break;case X.TABLE:sR(e,t);break;case X.TBODY:case X.TFOOT:case X.THEAD:aR(e,t);break;case X.INPUT:cR(e,t);break;case X.CAPTION:nR(e,t);break;case X.COLGROUP:rR(e,t);break;default:fR(e,t)}}function dR(e,t){switch(t.tagID){case X.TABLE:e.openElements.hasInTableScope(X.TABLE)&&(e.openElements.popUntilTagNamePopped(X.TABLE),e._resetInsertionMode());break;case X.TEMPLATE:OL(e,t);break;case X.BODY:case X.CAPTION:case X.COL:case X.COLGROUP:case X.HTML:case X.TBODY:case X.TD:case X.TFOOT:case X.TH:case X.THEAD:case X.TR:break;default:fR(e,t)}}function fR(e,t){let n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,ML(e,t),e.fosterParentingEnabled=n}function pR(e,t){e.pendingCharacterTokens.push(t)}function mR(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function hR(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)fR(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}var gR=new Set([X.CAPTION,X.COL,X.COLGROUP,X.TBODY,X.TD,X.TFOOT,X.TH,X.THEAD,X.TR]);function _R(e,t){let n=t.tagID;gR.has(n)?e.openElements.hasInTableScope(X.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(X.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=$.IN_TABLE,uR(e,t)):zL(e,t)}function vR(e,t){let n=t.tagID;switch(n){case X.CAPTION:case X.TABLE:e.openElements.hasInTableScope(X.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(X.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=$.IN_TABLE,n===X.TABLE&&dR(e,t));break;case X.BODY:case X.COL:case X.COLGROUP:case X.HTML:case X.TBODY:case X.TD:case X.TFOOT:case X.TH:case X.THEAD:case X.TR:break;default:ZL(e,t)}}function yR(e,t){switch(t.tagID){case X.HTML:zL(e,t);break;case X.COL:e._appendElement(t,J.HTML),t.ackSelfClosing=!0;break;case X.TEMPLATE:DL(e,t);break;default:xR(e,t)}}function bR(e,t){switch(t.tagID){case X.COLGROUP:e.openElements.currentTagId===X.COLGROUP&&(e.openElements.pop(),e.insertionMode=$.IN_TABLE);break;case X.TEMPLATE:OL(e,t);break;case X.COL:break;default:xR(e,t)}}function xR(e,t){e.openElements.currentTagId===X.COLGROUP&&(e.openElements.pop(),e.insertionMode=$.IN_TABLE,e._processToken(t))}function SR(e,t){switch(t.tagID){case X.TR:e.openElements.clearBackToTableBodyContext(),e._insertElement(t,J.HTML),e.insertionMode=$.IN_ROW;break;case X.TH:case X.TD:e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(Y.TR,X.TR),e.insertionMode=$.IN_ROW,wR(e,t);break;case X.CAPTION:case X.COL:case X.COLGROUP:case X.TBODY:case X.TFOOT:case X.THEAD:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=$.IN_TABLE,uR(e,t));break;default:uR(e,t)}}function CR(e,t){let n=t.tagID;switch(t.tagID){case X.TBODY:case X.TFOOT:case X.THEAD:e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=$.IN_TABLE);break;case X.TABLE:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=$.IN_TABLE,dR(e,t));break;case X.BODY:case X.CAPTION:case X.COL:case X.COLGROUP:case X.HTML:case X.TD:case X.TH:case X.TR:break;default:dR(e,t)}}function wR(e,t){switch(t.tagID){case X.TH:case X.TD:e.openElements.clearBackToTableRowContext(),e._insertElement(t,J.HTML),e.insertionMode=$.IN_CELL,e.activeFormattingElements.insertMarker();break;case X.CAPTION:case X.COL:case X.COLGROUP:case X.TBODY:case X.TFOOT:case X.THEAD:case X.TR:e.openElements.hasInTableScope(X.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=$.IN_TABLE_BODY,SR(e,t));break;default:uR(e,t)}}function TR(e,t){switch(t.tagID){case X.TR:e.openElements.hasInTableScope(X.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=$.IN_TABLE_BODY);break;case X.TABLE:e.openElements.hasInTableScope(X.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=$.IN_TABLE_BODY,CR(e,t));break;case X.TBODY:case X.TFOOT:case X.THEAD:(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(X.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=$.IN_TABLE_BODY,CR(e,t));break;case X.BODY:case X.CAPTION:case X.COL:case X.COLGROUP:case X.HTML:case X.TD:case X.TH:break;default:dR(e,t)}}function ER(e,t){let n=t.tagID;gR.has(n)?(e.openElements.hasInTableScope(X.TD)||e.openElements.hasInTableScope(X.TH))&&(e._closeTableCell(),wR(e,t)):zL(e,t)}function DR(e,t){let n=t.tagID;switch(n){case X.TD:case X.TH:e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=$.IN_ROW);break;case X.TABLE:case X.TBODY:case X.TFOOT:case X.THEAD:case X.TR:e.openElements.hasInTableScope(n)&&(e._closeTableCell(),TR(e,t));break;case X.BODY:case X.CAPTION:case X.COL:case X.COLGROUP:case X.HTML:break;default:ZL(e,t)}}function OR(e,t){switch(t.tagID){case X.HTML:zL(e,t);break;case X.OPTION:e.openElements.currentTagId===X.OPTION&&e.openElements.pop(),e._insertElement(t,J.HTML);break;case X.OPTGROUP:e.openElements.currentTagId===X.OPTION&&e.openElements.pop(),e.openElements.currentTagId===X.OPTGROUP&&e.openElements.pop(),e._insertElement(t,J.HTML);break;case X.HR:e.openElements.currentTagId===X.OPTION&&e.openElements.pop(),e.openElements.currentTagId===X.OPTGROUP&&e.openElements.pop(),e._appendElement(t,J.HTML),t.ackSelfClosing=!0;break;case X.INPUT:case X.KEYGEN:case X.TEXTAREA:case X.SELECT:e.openElements.hasInSelectScope(X.SELECT)&&(e.openElements.popUntilTagNamePopped(X.SELECT),e._resetInsertionMode(),t.tagID!==X.SELECT&&e._processStartTag(t));break;case X.SCRIPT:case X.TEMPLATE:DL(e,t)}}function kR(e,t){switch(t.tagID){case X.OPTGROUP:e.openElements.stackTop>0&&e.openElements.currentTagId===X.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===X.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===X.OPTGROUP&&e.openElements.pop();break;case X.OPTION:e.openElements.currentTagId===X.OPTION&&e.openElements.pop();break;case X.SELECT:e.openElements.hasInSelectScope(X.SELECT)&&(e.openElements.popUntilTagNamePopped(X.SELECT),e._resetInsertionMode());break;case X.TEMPLATE:OL(e,t)}}function AR(e,t){let n=t.tagID;n===X.CAPTION||n===X.TABLE||n===X.TBODY||n===X.TFOOT||n===X.THEAD||n===X.TR||n===X.TD||n===X.TH?(e.openElements.popUntilTagNamePopped(X.SELECT),e._resetInsertionMode(),e._processStartTag(t)):OR(e,t)}function jR(e,t){let n=t.tagID;n===X.CAPTION||n===X.TABLE||n===X.TBODY||n===X.TFOOT||n===X.THEAD||n===X.TR||n===X.TD||n===X.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(X.SELECT),e._resetInsertionMode(),e.onEndTag(t)):kR(e,t)}function MR(e,t){switch(t.tagID){case X.BASE:case X.BASEFONT:case X.BGSOUND:case X.LINK:case X.META:case X.NOFRAMES:case X.SCRIPT:case X.STYLE:case X.TEMPLATE:case X.TITLE:DL(e,t);break;case X.CAPTION:case X.COLGROUP:case X.TBODY:case X.TFOOT:case X.THEAD:e.tmplInsertionModeStack[0]=$.IN_TABLE,e.insertionMode=$.IN_TABLE,uR(e,t);break;case X.COL:e.tmplInsertionModeStack[0]=$.IN_COLUMN_GROUP,e.insertionMode=$.IN_COLUMN_GROUP,yR(e,t);break;case X.TR:e.tmplInsertionModeStack[0]=$.IN_TABLE_BODY,e.insertionMode=$.IN_TABLE_BODY,SR(e,t);break;case X.TD:case X.TH:e.tmplInsertionModeStack[0]=$.IN_ROW,e.insertionMode=$.IN_ROW,wR(e,t);break;default:e.tmplInsertionModeStack[0]=$.IN_BODY,e.insertionMode=$.IN_BODY,zL(e,t)}}function NR(e,t){t.tagID===X.TEMPLATE&&OL(e,t)}function PR(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(X.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):CL(e,t)}function FR(e,t){t.tagID===X.HTML?zL(e,t):LR(e,t)}function IR(e,t){if(t.tagID===X.HTML){if(e.fragmentContext||(e.insertionMode=$.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===X.HTML){e._setEndLocation(e.openElements.items[0],t);let n=e.openElements.items[1];n&&!e.treeAdapter.getNodeSourceCodeLocation(n)?.endTag&&e._setEndLocation(n,t)}}else LR(e,t)}function LR(e,t){e.insertionMode=$.IN_BODY,ML(e,t)}function RR(e,t){switch(t.tagID){case X.HTML:zL(e,t);break;case X.FRAMESET:e._insertElement(t,J.HTML);break;case X.FRAME:e._appendElement(t,J.HTML),t.ackSelfClosing=!0;break;case X.NOFRAMES:DL(e,t)}}function zR(e,t){t.tagID===X.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==X.FRAMESET&&(e.insertionMode=$.AFTER_FRAMESET))}function BR(e,t){switch(t.tagID){case X.HTML:zL(e,t);break;case X.NOFRAMES:DL(e,t)}}function VR(e,t){t.tagID===X.HTML&&(e.insertionMode=$.AFTER_AFTER_FRAMESET)}function HR(e,t){t.tagID===X.HTML?zL(e,t):UR(e,t)}function UR(e,t){e.insertionMode=$.IN_BODY,ML(e,t)}function WR(e,t){switch(t.tagID){case X.HTML:zL(e,t);break;case X.NOFRAMES:DL(e,t)}}function GR(e,t){t.chars=`�`,e._insertCharacters(t)}function KR(e,t){e._insertCharacters(t),e.framesetOk=!1}function qR(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==J.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function JR(e,t){if(Ete(t))qR(e),e._startTagOutsideForeignContent(t);else{let n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===J.MATHML?hL(t):r===J.SVG&&(Dte(t),gL(t)),_L(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function YR(e,t){if(t.tagID===X.P||t.tagID===X.BR){qR(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){let r=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(r)===J.HTML){e._endTagOutsideForeignContent(t);break}let i=e.treeAdapter.getTagName(r);if(i.toLowerCase()===t.tagName){t.tagName=i,e.openElements.shortenToLength(n);break}}}Y.AREA,Y.BASE,Y.BASEFONT,Y.BGSOUND,Y.BR,Y.COL,Y.EMBED,Y.FRAME,Y.HR,Y.IMG,Y.INPUT,Y.KEYGEN,Y.LINK,Y.META,Y.PARAM,Y.SOURCE,Y.TRACK,Y.WBR;var XR=QR(`end`),ZR=QR(`start`);function QR(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function $R(e){let t=ZR(e),n=XR(e);if(t&&n)return{start:t,end:n}}var ez=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,tz=new Set([`mdxFlowExpression`,`mdxJsxFlowElement`,`mdxJsxTextElement`,`mdxTextExpression`,`mdxjsEsm`]),nz={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function rz(e,t){let n=_z(e),r=iI(`type`,{handlers:{root:az,element:oz,text:sz,comment:uz,doctype:cz,raw:dz},unknown:fz}),i={parser:n?new bL(nz):bL.getFragmentParser(void 0,nz),handle(e){r(e,i)},stitches:!1,options:t||{}};r(e,i),pz(i,ZR());let a=YF(n?i.parser.document:i.parser.getFragment(),{file:i.options.file});return i.stitches&&bP(a,`comment`,function(e,t,n){let r=e;if(r.value.stitch&&n&&t!==void 0){let e=n.children;return e[t]=r.value.stitch,t}}),a.type===`root`&&a.children.length===1&&a.children[0].type===e.type?a.children[0]:a}function iz(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function az(e,t){iz(e.children,t)}function oz(e,t){hz(e,t),iz(e.children,t),gz(e,t)}function sz(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);let n={type:OI.CHARACTER,chars:e.value,location:vz(e)};pz(t,ZR(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function cz(e,t){let n={type:OI.DOCTYPE,name:`html`,forceQuirks:!1,publicId:``,systemId:``,location:vz(e)};pz(t,ZR(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function lz(e,t){t.stitches=!0;let n=yz(e);`children`in e&&`children`in n&&(n.children=rz({type:`root`,children:e.children},t.options).children),uz({type:`comment`,value:{stitch:n}},t)}function uz(e,t){let n=e.value,r={type:OI.COMMENT,data:n,location:vz(e)};pz(t,ZR(e)),t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken)}function dz(e,t){if(t.parser.tokenizer.preprocessor.html=``,t.parser.tokenizer.preprocessor.pos=-1,t.parser.tokenizer.preprocessor.lastGapPos=-2,t.parser.tokenizer.preprocessor.gapStack=[],t.parser.tokenizer.preprocessor.skipNextNewLine=!1,t.parser.tokenizer.preprocessor.lastChunkWritten=!1,t.parser.tokenizer.preprocessor.endOfChunkHit=!1,t.parser.tokenizer.preprocessor.isEol=!1,mz(t,ZR(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(ez,`&lt;$1$2`):e.value,!1),t.parser.tokenizer._runParsingLoop(),t.parser.tokenizer.state===72||t.parser.tokenizer.state===78){t.parser.tokenizer.preprocessor.lastChunkWritten=!0;let e=t.parser.tokenizer._consume();t.parser.tokenizer._callState(e)}}function fz(e,t){let n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))lz(n,t);else{let e=``;throw tz.has(n.type)&&(e=". It looks like you are using MDX nodes with `hast-util-raw` (or `rehype-raw`). If you use this because you are using remark or rehype plugins that inject `'html'` nodes, then please raise an issue with that plugin, as its a bad and slow idea. If you use this because you are using markdown syntax, then you have to configure this utility (or plugin) to pass through these nodes (see `passThrough` in docs), but you can also migrate to use the MDX syntax"),Error("Cannot compile `"+n.type+"` node"+e)}}function pz(e,t){mz(e,t);let n=e.parser.tokenizer.currentCharacterToken;n&&n.location&&(n.location.endLine=e.parser.tokenizer.preprocessor.line,n.location.endCol=e.parser.tokenizer.preprocessor.col+1,n.location.endOffset=e.parser.tokenizer.preprocessor.offset+1,e.parser.currentToken=n,e.parser._processToken(e.parser.currentToken)),e.parser.tokenizer.paused=!1,e.parser.tokenizer.inLoop=!1,e.parser.tokenizer.active=!1,e.parser.tokenizer.returnState=JI.DATA,e.parser.tokenizer.charRefCode=-1,e.parser.tokenizer.consumedAfterSnapshot=-1,e.parser.tokenizer.currentLocation=null,e.parser.tokenizer.currentCharacterToken=null,e.parser.tokenizer.currentToken=null,e.parser.tokenizer.currentAttr={name:``,value:``}}function mz(e,t){if(t&&t.offset!==void 0){let n={startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:-1,endCol:-1,endOffset:-1};e.parser.tokenizer.preprocessor.lineStartPos=-t.column+1,e.parser.tokenizer.preprocessor.droppedBufferSize=t.offset,e.parser.tokenizer.preprocessor.line=t.line,e.parser.tokenizer.currentLocation=n}}function hz(e,t){let n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===JI.PLAINTEXT)return;pz(t,ZR(e));let r=t.parser.openElements.current,i=`namespaceURI`in r?r.namespaceURI:KF.html;i===KF.html&&n===`svg`&&(i=KF.svg);let a=cI({...e,children:[]},{space:i===KF.svg?`svg`:`html`}),o={type:OI.START_TAG,tagName:n,tagID:KI(n),selfClosing:!1,ackSelfClosing:!1,attrs:`attrs`in a?a.attrs:[],location:vz(e)};t.parser.currentToken=o,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function gz(e,t){let n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&vI.includes(n)||t.parser.tokenizer.state===JI.PLAINTEXT)return;pz(t,XR(e));let r={type:OI.END_TAG,tagName:n,tagID:KI(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:vz(e)};t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===JI.RCDATA||t.parser.tokenizer.state===JI.RAWTEXT||t.parser.tokenizer.state===JI.SCRIPT_DATA)&&(t.parser.tokenizer.state=JI.DATA)}function _z(e){let t=e.type===`root`?e.children[0]:e;return!!(t&&(t.type===`doctype`||t.type===`element`&&t.tagName.toLowerCase()===`html`))}function vz(e){let t=ZR(e)||{line:void 0,column:void 0,offset:void 0},n=XR(e)||{line:void 0,column:void 0,offset:void 0};return{startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:n.line,endCol:n.column,endOffset:n.offset}}function yz(e){return`children`in e?KP({...e,children:[]}):KP(e)}function bz(e){return function(t,n){return rz(t,{...e,file:n})}}var xz=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],Sz={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...xz,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...xz],h2:[[`className`,`sr-only`]],img:[...xz,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...xz,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...xz],table:[...xz],ul:[...xz,[`className`,`contains-task-list`]],"*":`abbr.accept.acceptCharset.accessKey.action.align.alt.axis.border.cellPadding.cellSpacing.char.charOff.charSet.checked.clear.colSpan.color.cols.compact.coords.dateTime.dir.encType.frame.hSpace.headers.height.hrefLang.htmlFor.id.isMap.itemProp.label.lang.maxLength.media.method.multiple.name.noHref.noShade.noWrap.open.prompt.readOnly.rev.rowSpan.rows.rules.scope.selected.shape.size.span.start.summary.tabIndex.title.useMap.vAlign.value.width`.split(`.`)},clobber:[`ariaDescribedBy`,`ariaLabelledBy`,`id`,`name`],clobberPrefix:`user-content-`,protocols:{cite:[`http`,`https`],href:[`http`,`https`,`irc`,`ircs`,`mailto`,`xmpp`],longDesc:[`http`,`https`],src:[`http`,`https`]},required:{input:{disabled:!0,type:`checkbox`}},strip:[`script`],tagNames:`a.b.blockquote.br.code.dd.del.details.div.dl.dt.em.h1.h2.h3.h4.h5.h6.hr.i.img.input.ins.kbd.li.ol.p.picture.pre.q.rp.rt.ruby.s.samp.section.source.span.strike.strong.sub.summary.sup.table.tbody.td.tfoot.th.thead.tr.tt.ul.var`.split(`.`)},Cz={}.hasOwnProperty;function wz(e,t){let n={type:`root`,children:[]},r=Tz({schema:t?{...Sz,...t}:Sz,stack:[]},e);return r&&(Array.isArray(r)?r.length===1?n=r[0]:n.children=r:n=r),n}function Tz(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return Ez(e,n);case`doctype`:return Dz(e,n);case`element`:return Oz(e,n);case`root`:return kz(e,n);case`text`:return Az(e,n)}}}function Ez(e,t){if(e.schema.allowComments){let e=typeof t.value==`string`?t.value:``,n=e.indexOf(`-->`),r={type:`comment`,value:n<0?e:e.slice(0,n)};return Lz(r,t),r}}function Dz(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return Lz(e,t),e}}function Oz(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=jz(e,t.children),i=Mz(e,t.properties);e.stack.pop();let a=!1;if(n&&n!==`*`&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(a=!0,e.schema.ancestors&&Cz.call(e.schema.ancestors,n))){let t=e.schema.ancestors[n],r=-1;for(a=!1;++r<t.length;)e.stack.includes(t[r])&&(a=!0)}if(!a)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;let o={type:`element`,tagName:n,properties:i,children:r};return Lz(o,t),o}function kz(e,t){let n={type:`root`,children:jz(e,t.children)};return Lz(n,t),n}function Az(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return Lz(n,t),n}function jz(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=Tz(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function Mz(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,a=r&&Cz.call(r,n)?r[n]:void 0,o=r&&Cz.call(r,`*`)?r[`*`]:void 0,s=t&&typeof t==`object`?t:{},c={},l;for(l in s)if(Cz.call(s,l)){let t=s[l],n=Nz(e,Rz(a,l),l,t);n??=Nz(e,Rz(o,l),l,t),n!=null&&(c[l]=n)}if(i&&Cz.call(i,n)){let e=i[n];for(l in e)Cz.call(e,l)&&!Cz.call(c,l)&&(c[l]=e[l])}return c}function Nz(e,t,n,r){return t?Array.isArray(r)?Pz(e,t,n,r):Fz(e,t,n,r):void 0}function Pz(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=Fz(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function Fz(e,t,n,r){if((typeof r==`boolean`||typeof r==`number`||typeof r==`string`)&&Iz(e,n,r)){if(typeof t==`object`&&t.length>1){let e=!1,n=0;for(;++n<t.length;){let i=t[n];if(i&&typeof i==`object`&&`flags`in i){if(i.test(String(r))){e=!0;break}}else if(i===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function Iz(e,t,n){let r=e.schema.protocols&&Cz.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;let i=String(n),a=i.indexOf(`:`),o=i.indexOf(`?`),s=i.indexOf(`#`),c=i.indexOf(`/`);if(a<0||c>-1&&a>c||o>-1&&a>o||s>-1&&a>s)return!0;let l=-1;for(;++l<r.length;){let e=r[l];if(a===e.length&&i.slice(0,e.length)===e)return!0}return!1}function Lz(e,t){let n=$R(t);t.data&&(e.data=KP(t.data)),n&&(e.position=n)}function Rz(e,t){let n,r=-1;if(e)for(;++r<e.length;){let i=e[r],a=typeof i==`string`?i:i[0];if(a===t)return i;a===`data*`&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()===`data`)return n}function zz(e){return function(t){return wz(t,e)}}function Bz(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}var Vz=$z(/[A-Za-z]/),Hz=$z(/[\dA-Za-z]/),Uz=$z(/[#-'*+\--9=?A-Z^-~]/);function Wz(e){return e!==null&&(e<32||e===127)}var Gz=$z(/\d/),Kz=$z(/[\dA-Fa-f]/),qz=$z(/[!-/:-@[-`{-~]/);function Jz(e){return e!==null&&e<-2}function Yz(e){return e!==null&&(e<0||e===32)}function Xz(e){return e===-2||e===-1||e===32}var Zz=$z(/\p{P}|\p{S}/u),Qz=$z(/\s/);function $z(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function eB(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function tB(e,t,n){let r=cP((n||{}).ignore||[]),i=nB(t),a=-1;for(;++a<i.length;)vP(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function nB(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([rB(e[0]),iB(e[1])])}return t}function rB(e){return typeof e==`string`?new RegExp(eB(e),`g`):e}function iB(e){return typeof e==`function`?e:function(){return e}}var aB=`phrasing`,oB=[`autolink`,`link`,`image`,`label`];function sB(){return{transforms:[hB],enter:{literalAutolink:lB,literalAutolinkEmail:uB,literalAutolinkHttp:uB,literalAutolinkWww:uB},exit:{literalAutolink:mB,literalAutolinkEmail:pB,literalAutolinkHttp:dB,literalAutolinkWww:fB}}}function cB(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:aB,notInConstruct:oB},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:aB,notInConstruct:oB},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:aB,notInConstruct:oB}]}}function lB(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function uB(e){this.config.enter.autolinkProtocol.call(this,e)}function dB(e){this.config.exit.autolinkProtocol.call(this,e)}function fB(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function pB(e){this.config.exit.autolinkEmail.call(this,e)}function mB(e){this.exit(e)}function hB(e){tB(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,gB],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,_B]],{ignore:[`link`,`linkReference`]})}function gB(e,t,n,r,i){let a=``;if(!bB(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!vB(n)))return!1;let o=yB(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function _B(e,t,n,r){return!bB(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function vB(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function yB(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=Bz(e,`(`),a=Bz(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function bB(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||Qz(n)||Zz(n))&&(!t||n!==47)}function xB(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}jB.peek=AB;function SB(){this.buffer()}function CB(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function wB(){this.buffer()}function TB(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function EB(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=xB(this.sliceSerialize(e)).toLowerCase(),n.label=t}function DB(e){this.exit(e)}function OB(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=xB(this.sliceSerialize(e)).toLowerCase(),n.label=t}function kB(e){this.exit(e)}function AB(){return`[`}function jB(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function MB(){return{enter:{gfmFootnoteCallString:SB,gfmFootnoteCall:CB,gfmFootnoteDefinitionLabelString:wB,gfmFootnoteDefinition:TB},exit:{gfmFootnoteCallString:EB,gfmFootnoteCall:DB,gfmFootnoteDefinitionLabelString:OB,gfmFootnoteDefinition:kB}}}function NB(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:jB},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
@@ -157,7 +157,7 @@ ${e}</tr>
157
157
  `}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>${uZ(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=dZ(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+uZ(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=dZ(e);if(i===null)return uZ(n);e=i;let a=`<img src="${e}" alt="${uZ(n)}"`;return t&&(a+=` title="${uZ(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:uZ(e.text)}},xZ=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}},SZ=class e{options;renderer;textRenderer;constructor(e){this.options=e||ZY,this.options.renderer=this.options.renderer||new bZ,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new xZ}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}},CZ=class{options;block;constructor(e){this.options=e||ZY}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?yZ.lex:yZ.lexInline}provideParser(e=this.block){return e?SZ.parse:SZ.parseInline}},wZ=new class{defaults=XY();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=SZ;Renderer=bZ;TextRenderer=xZ;Lexer=yZ;Tokenizer=vZ;Hooks=CZ;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 bZ(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 vZ(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 CZ;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]=CZ.passThroughHooks.has(n)?e=>{if(this.defaults.async&&CZ.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 yZ.lex(e,t??this.defaults)}parser(e,t){return SZ.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?yZ.lex:yZ.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?SZ.parse:SZ.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?yZ.lex:yZ.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?SZ.parse:SZ.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+=`
158
158
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+uZ(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function TZ(e,t){return wZ.parse(e,t)}TZ.options=TZ.setOptions=function(e){return wZ.setOptions(e),TZ.defaults=wZ.defaults,QY(TZ.defaults),TZ},TZ.getDefaults=XY,TZ.defaults=ZY,TZ.use=function(...e){return wZ.use(...e),TZ.defaults=wZ.defaults,QY(TZ.defaults),TZ},TZ.walkTokens=function(e,t){return wZ.walkTokens(e,t)},TZ.parseInline=wZ.parseInline,TZ.Parser=SZ,TZ.parser=SZ.parse,TZ.Renderer=bZ,TZ.TextRenderer=xZ,TZ.Lexer=yZ,TZ.lexer=yZ.lex,TZ.Tokenizer=vZ,TZ.Hooks=CZ,TZ.parse=TZ,TZ.options,TZ.setOptions,TZ.use,TZ.walkTokens,TZ.parseInline,SZ.parse,yZ.lex;var EZ=300,DZ=`300px`,OZ=500;function kZ(e={}){let{immediate:t=!1,debounceDelay:n=EZ,rootMargin:r=DZ,idleTimeout:i=OZ}=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 AZ=320,jZ=4,MZ=()=>typeof performance>`u`?Date.now():performance.now();function NZ(e){let t=e?.now??MZ,n=e?.maxBacklogMs??AZ,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,jZ),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 PZ=/\s/,FZ=/^\s+$/,IZ=new Set([`pre`,`svg`,`math`,`annotation`]),LZ=new Set([`img`,`hr`]),RZ=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`element`,zZ=e=>e.some(e=>RZ(e)&&IZ.has(e.tagName)),BZ=e=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(RZ(n)&&n.tagName===`li`)return n}},VZ=(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}`},HZ=new Set([`ul`,`ol`,`li`]),UZ=e=>{for(let t of e.children)if(RZ(t)){if(t.tagName===`input`)return t;if(HZ.has(t.tagName))continue;let e=UZ(t);if(e)return e}},WZ=(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`},GZ=(e,t,n,r)=>{let i=UZ(e);i&&WZ(i,t,n,r)},KZ=(e,t,n,r,i,a)=>{if(zZ(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;WZ(e,n,c?0:n.duration,l)},qZ=e=>{var t;for(let n=e.length-1;n>=0;--n){let r=e[n];if(RZ(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=PZ.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},YZ=e=>{let t=[],n=``;for(let r of e)PZ.test(r)?t.length>0&&!FZ.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},XZ=(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}]}},ZZ=(e,t)=>!(e>0&&t<e),QZ=e=>RZ(e)&&LZ.has(e.tagName),$Z=(e,t,n)=>{let r=0,i=0;return vP(e,e=>e.type===`text`||QZ(e),(e,a)=>{if(zZ(a))return _P;if(QZ(e)){ZZ(n,i)&&(r+=1),i+=1;return}let o=e.value;if(!o.trim()){i+=o.length;return}let s=t.sep===`char`?YZ(o):JZ(o);for(let e of s){let t=i;i+=e.length,!FZ.test(e)&&ZZ(n,t)&&(r+=1)}}),r},eQ=(e,t,n,r,i,a)=>{var o;let s=t.at(-1);if(!(s&&`children`in s))return;if(zZ(t))return _P;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`?YZ(u):JZ(u),f=r.prevContentLength,p=!1,m=BZ(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,FZ.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;VZ(m,e,o,n.easing),GZ(m,n,e,o),g=!0}return XZ(e,n.animation,n.duration,n.easing,r,o)});return p&&qZ(t),c.children.splice(l,1,..._),l+_.length},tQ=0;function nQ(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=tQ++,i=()=>e=>{let r={count:0,newIndex:0};n.prevContentLength=n.committedCharCount;let i=t.timeline,a=i?.now()??MZ();i&&(n.pendingMark===null?n.pendingMark=i.mark():i.rewind(n.pendingMark));let o=i?i.take($Z(e,t,n.prevContentLength),t.stagger,a):{baseDelay:0,step:t.stagger};vP(e,e=>e.type===`text`||QZ(e),(e,i)=>{if(e.type===`text`)return eQ(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}}}nQ();var rQ=(0,v.createContext)(!1),iQ=()=>(0,v.useContext)(rQ),aQ=(...e)=>so(Ci(e)),oQ=(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(` `)},sQ=e=>e?(...t)=>oQ(e,so(Ci(t))):aQ,cQ=(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)},lQ=(0,v.createContext)(aQ),uQ=()=>(0,v.useContext)(lQ),dQ=8,fQ=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}},pQ=(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<dQ;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},mQ=aQ(`block`),hQ=aQ(`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`),gQ=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},_Q=(0,v.memo)(({children:e,result:t,language:n,className:r,maxHeight:i,startLine:a,lineNumbers:o=!0,...s})=>{let c=uQ(),{isAnimating:l}=(0,v.useContext)($1),u=fQ(i),d=pQ(l,!!u,t),f=(0,v.useMemo)(()=>c(hQ),[c]),p=(0,v.useMemo)(()=>c(mQ),[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,gQ(t.rootStyle)),e},[t.bg,t.fg,t.rootStyle]);return(0,H.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,H.jsx)(`pre`,{className:c(r,`bg-[var(--sdm-bg,inherit)]`,`dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]`),style:m,children:(0,H.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,H.jsx)(`span`,{className:o?f:p,children:e.length===0||e.length===1&&e[0].content===``?`
159
159
  `: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,H.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))})})})}),vQ=({className:e,language:t,style:n,isIncomplete:r,...i})=>{let a=uQ();return(0,H.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})},yQ=(0,v.createContext)({code:``}),bQ=()=>(0,v.useContext)(yQ),xQ=({language:e})=>{let t=uQ();return(0,H.jsx)(`div`,{className:t(`flex h-8 items-center text-muted-foreground text-xs`),"data-language":e,"data-streamdown":`code-block-header`,children:(0,H.jsx)(`span`,{className:t(`ml-1 font-mono lowercase`),children:e})})},SQ=e=>{let t=e.length;for(;t>0&&e[t-1]===`
160
- `;)t--;return e.slice(0,t)},CQ=(0,v.lazy)(()=>kM(()=>import(`./highlighted-body-KPVGNVTW-B1MvZDlz.js`).then(e=>({default:e.HighlightedCodeBlockBody})),[])),wQ=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=uQ(),{codeBlockMaxHeight:l}=(0,v.useContext)($1),u=(0,v.useMemo)(()=>SQ(e),[e]),d=(0,v.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:u.split(`
160
+ `;)t--;return e.slice(0,t)},CQ=(0,v.lazy)(()=>kM(()=>import(`./highlighted-body-KPVGNVTW-FyI0gO12.js`).then(e=>({default:e.HighlightedCodeBlockBody})),[])),wQ=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=uQ(),{codeBlockMaxHeight:l}=(0,v.useContext)($1),u=(0,v.useMemo)(()=>SQ(e),[e]),d=(0,v.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:u.split(`
161
161
  `).map(e=>[{content:e,color:`inherit`,bgColor:`transparent`,htmlStyle:{},offset:0}])}),[u]);return(0,H.jsx)(yQ.Provider,{value:{code:e},children:(0,H.jsxs)(vQ,{dir:`ltr`,isIncomplete:i,language:t,children:[(0,H.jsx)(xQ,{language:t}),r?(0,H.jsx)(`div`,{className:c(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,H.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,H.jsx)(v.Suspense,{fallback:(0,H.jsx)(_Q,{className:n,language:t,lineNumbers:o,maxHeight:l,result:d,startLine:a,...s}),children:(0,H.jsx)(CQ,{className:n,code:u,language:t,lineNumbers:o,maxHeight:l,raw:d,startLine:a,...s})})]})})},TQ={CheckIcon:e=>(0,H.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,H.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,H.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,H.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,H.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,H.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,H.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,H.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,H.jsxs)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:[(0,H.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,H.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,H.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,H.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,H.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,H.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,H.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,H.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,H.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,H.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),Maximize2Icon:e=>(0,H.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,H.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,H.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,H.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,H.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,H.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,H.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,H.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,H.jsx)(`svg`,{"aria-hidden":`true`,color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,H.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`})})},EQ=(0,v.createContext)(TQ),DQ=(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])},OQ=({icons:e,children:t})=>{let n=(0,v.useRef)(e),r=(0,v.useRef)(e?{...TQ,...e}:TQ);DQ(n.current,e)||(n.current=e,r.current=e?{...TQ,...e}:TQ);let i=r.current;return(0,H.jsx)(EQ.Provider,{value:i,children:t})},kQ=()=>(0,v.useContext)(EQ),AQ={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`},jQ=(0,v.createContext)(AQ),MQ=()=>(0,v.useContext)(jQ),NQ=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let s=uQ(),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(0),{code:d}=bQ(),{isAnimating:f}=(0,v.useContext)($1),p=MQ(),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=kQ(),_=c?g.CheckIcon:g.CopyIcon;return(0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.jsx)(_,{"aria-hidden":`true`,size:14})}),c&&(0,H.jsx)(`output`,{"aria-live":`polite`,className:`sr-only`,children:p.copied})]})},PQ=(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},FQ={"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`},IQ=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=uQ(),{code:c}=bQ(),{isAnimating:l,controls:u}=(0,v.useContext)($1),d=MQ(),f=kQ(),p=a??c,m=n&&n in FQ?FQ[n]:`txt`,h=`${PQ(u,`code`,`file`)}.${m}`;return(0,H.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{cQ(h,p,`text/plain`),e?.()}catch(e){t?.(e)}},title:d.downloadFile,type:`button`,...o,children:r??(0,H.jsx)(f.DownloadIcon,{size:14})})},LQ=()=>{let{Loader2Icon:e}=kQ(),t=uQ();return(0,H.jsxs)(`div`,{className:t(`w-full divide-y divide-border overflow-hidden rounded-xl border border-border`),children:[(0,H.jsx)(`div`,{className:t(`h-[46px] w-full bg-muted/80`)}),(0,H.jsx)(`div`,{className:t(`flex w-full items-center justify-center p-4`),children:(0,H.jsx)(e,{className:t(`size-4 animate-spin`)})})]})},RQ=/\.[^/.]+$/,zQ=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,showControls:o=!0,showDownloadControl:s=!0,...c})=>{let{DownloadIcon:l}=kQ(),u=uQ(),d=(0,v.useRef)(null),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),g=MQ(),_=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(RQ,``)}.${i}`}cQ(o,e,e.type)}catch{window.open(n,`_blank`)}};return n?(0,H.jsxs)(`div`,{className:u(`group relative my-4 inline-block`),"data-streamdown":`image-wrapper`,children:[(0,H.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,H.jsx)(`span`,{className:u(`text-muted-foreground text-xs italic`),"data-streamdown":`image-fallback`,children:g.imageNotAvailable}),o&&(0,H.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,H.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,H.jsx)(l,{size:14})})]}):null},BQ=0,VQ=()=>{BQ+=1,BQ===1&&(document.body.style.overflow=`hidden`)},HQ=()=>{BQ=Math.max(0,BQ-1),BQ===0&&(document.body.style.overflow=``)},UQ=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=kQ(),c=uQ(),[l,u]=(0,v.useState)(!1),d=MQ(),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){VQ();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),HQ()}}},[t,n]),!t||typeof document>`u`)return null;let m=(0,H.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,H.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,H.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,H.jsx)(s,{size:16})}),(0,H.jsxs)(`div`,{className:c(`flex flex-col gap-2`),children:[(0,H.jsxs)(`div`,{className:c(`flex items-center gap-2 font-semibold text-lg`),children:[(0,H.jsx)(o,{size:20}),(0,H.jsx)(`span`,{children:d.openExternalLink})]}),(0,H.jsx)(`p`,{className:c(`text-muted-foreground text-sm`),children:d.externalLinkWarning})]}),(0,H.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,H.jsxs)(`div`,{className:c(`flex gap-2`),children:[(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(i,{size:14}),(0,H.jsx)(`span`,{children:d.copied})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(a,{size:14}),(0,H.jsx)(`span`,{children:d.copyLink})]})}),(0,H.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,H.jsx)(o,{size:14}),(0,H.jsx)(`span`,{children:d.openLink})]})]})]})});return(0,Ed.createPortal)(m,document.body)},WQ=(0,v.createContext)(null),GQ=()=>(0,v.useContext)(WQ),KQ=()=>GQ()?.code??null,qQ=()=>GQ()?.mermaid??null,JQ=e=>{var t;let n=GQ();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},YQ=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},XQ=(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}),ZQ=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let o=uQ(),[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(null),{isAnimating:u,controls:d}=(0,v.useContext)($1),f=kQ(),p=qQ(),m=MQ(),h=PQ(d,`mermaid`,`diagram`),g=async t=>{try{if(t===`mmd`){cQ(`${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=YQ(l);if(t===`svg`){cQ(`${h}.svg`,u,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){let e=await XQ(u);cQ(`${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,H.jsxs)(`div`,{className:o(`relative`),ref:l,children:[(0,H.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,H.jsx)(f.DownloadIcon,{"aria-hidden":`true`,size:14})}),s?(0,H.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,H.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,H.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,H.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]})},QQ=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=kQ(),c=uQ(),[l,u]=(0,v.useState)(!1),{isAnimating:d,controls:f}=(0,v.useContext)($1),p=MQ(),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){VQ();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),HQ()}}},[l]),(0,v.useEffect)(()=>{l?n?.():r&&r()},[l,n,r]),(0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.jsx)(o,{"aria-hidden":`true`,size:14})}),l?(0,Ed.createPortal)((0,H.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,H.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,H.jsx)(ZQ,{chart:e,config:t}):null,g?(0,H.jsx)(NQ,{code:e}):null,(0,H.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,H.jsx)(s,{"aria-hidden":`true`,size:20})})]}),(0,H.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,H.jsx)(r0,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:m})})]}),document.body):null]})};function $Q(e){if(e.nodeType===Node.TEXT_NODE)return e.textContent??``;if(e.nodeType!==Node.ELEMENT_NODE)return``;let t=e;return t.tagName===`BR`?`
162
162
  `:Array.from(t.childNodes).map($Q).join(``)}var e$=e=>{let t=[],n=[],r=e.querySelectorAll(`thead th`);for(let e of r)t.push($Q(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($Q(e).trim());n.push(t)}return{headers:t,rows:n}},t$=e=>{if(typeof e!=`object`)return`,`;let t=e.table;return typeof t==`object`?t.csvSeparator??`,`:`,`},n$=(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===`
163
163
  `||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(`
@@ -167,7 +167,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
167
167
  `)},i$=e=>{let t=!1;for(let n of e)if(n===`\\`||n===`|`||n===`
168
168
  `){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===`\\`?n.push(`\\\\`):t===`|`?n.push(`\\|`):t===`
169
169
  `?n.push(`<br>`):n.push(t);return n.join(``)},a$=e=>{let{headers:t,rows:n}=e;if(t.length===0)return``;let r=Array(n.length+2),i=0,a=t.map(e=>i$(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?i$(e[r]):``;r[i]=`| ${n.join(` | `)} |`,i+=1}else{let t=e.map(e=>i$(e));r[i]=`| ${t.join(` | `)} |`,i+=1}return r.join(`
170
- `)},o$=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=uQ(),[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)($1),m=MQ(),h=t$(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=e$(t),o=``;o=e===`csv`?n$(a,h):e===`tsv`?r$(a):a$(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 _=kQ(),y=c?_.CheckIcon:_.CopyIcon;return(0,H.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,H.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,H.jsx)(y,{height:14,width:14})}),o?(0,H.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,H.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,H.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,H.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]})},s$=({children:e,className:t,onDownload:n,onError:r})=>{let i=uQ(),[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null),{isAnimating:c,controls:l}=(0,v.useContext)($1),u=MQ(),d=kQ(),f=t$(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=e$(t),a=e===`csv`?n$(i,f):a$(i),c=e===`csv`?`csv`:`md`;cQ(`${PQ(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,H.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,H.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,H.jsx)(d.DownloadIcon,{size:14})}),a?(0,H.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,H.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,H.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]})},c$=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=kQ(),o=uQ(),[s,c]=(0,v.useState)(!1),{isAnimating:l}=(0,v.useContext)($1),u=MQ(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,v.useEffect)(()=>{if(s){VQ();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),HQ()}}},[s]),(0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.jsx)(i,{size:14})}),s?(0,Ed.createPortal)((0,H.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,H.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,H.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,H.jsx)(o$,{}):null,r?(0,H.jsx)(s$,{}):null,(0,H.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,H.jsx)(a,{size:20})})]}),(0,H.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,H.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},l$=({children:e,className:t,maxHeight:n,showControls:r,showCopy:i=!0,showDownload:a=!0,showFullscreen:o=!0,...s})=>{let c=uQ(),{isAnimating:l}=(0,v.useContext)($1),u=fQ(n),d=pQ(l,!!u,e),f=r&&i,p=r&&a,m=r&&o,h=f||p||m;return(0,H.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,H.jsxs)(`div`,{className:c(`flex items-center justify-end gap-1`),children:[f?(0,H.jsx)(o$,{}):null,p?(0,H.jsx)(s$,{}):null,m?(0,H.jsx)(c$,{showCopy:f,showDownload:p,children:e}):null]}):null,(0,H.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,H.jsx)(`table`,{className:c(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...s,children:e})})]})},u$=/startLine=(\d+)/,d$=/\bnoLineNumbers\b/,f$=(0,v.lazy)(()=>kM(()=>import(`./mermaid-HWGCJPDP-DQNZoa_a.js`).then(e=>({default:e.Mermaid})),[])),p$=/language-([^\s]+)/,m$=`node`;function h$(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!==m$&&!Object.is(r[e],i[e]))return!1;return!0}function g$(e,t){return e?.properties?.metastring===t?.properties?.metastring}var _$=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,v$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},y$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},b$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},x$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.image;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},S$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`ol`,{className:i(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e})},(e,t)=>h$(e,t));S$.displayName=`MarkdownOl`;var C$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`li`,{className:i(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e})},(e,t)=>h$(e,t));C$.displayName=`MarkdownLi`;var w$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`ul`,{className:i(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e})},(e,t)=>h$(e,t));w$.displayName=`MarkdownUl`;var T$=(0,v.memo)(({className:e,node:t,...n})=>{let r=uQ();return(0,H.jsx)(`hr`,{className:r(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n})},(e,t)=>h$(e,t));T$.displayName=`MarkdownHr`;var E$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`span`,{className:i(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e})},(e,t)=>h$(e,t));E$.displayName=`MarkdownStrong`;var D$=(0,v.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=uQ(),{linkSafety:o}=(0,v.useContext)($1),[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,H.jsxs)(H.Fragment,{children:[(0,H.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,H.jsx)(UQ,{...p})]}):(0,H.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)=>h$(e,t));D$.displayName=`MarkdownA`;var O$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h1`,{className:i(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e})},(e,t)=>h$(e,t));O$.displayName=`MarkdownH1`;var k$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h2`,{className:i(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e})},(e,t)=>h$(e,t));k$.displayName=`MarkdownH2`;var A$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h3`,{className:i(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e})},(e,t)=>h$(e,t));A$.displayName=`MarkdownH3`;var j$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h4`,{className:i(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e})},(e,t)=>h$(e,t));j$.displayName=`MarkdownH4`;var M$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h5`,{className:i(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e})},(e,t)=>h$(e,t));M$.displayName=`MarkdownH5`;var N$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h6`,{className:i(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e})},(e,t)=>h$(e,t));N$.displayName=`MarkdownH6`;var P$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i,tableMaxHeight:a}=(0,v.useContext)($1),o=_$(i,`table`),s=v$(i,`copy`),c=v$(i,`download`),l=v$(i,`fullscreen`);return(0,H.jsx)(l$,{className:t,maxHeight:a,showControls:o,showCopy:s,showDownload:c,showFullscreen:l,...r,children:e})},(e,t)=>h$(e,t));P$.displayName=`MarkdownTable`;var F$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`thead`,{className:i(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e})},(e,t)=>h$(e,t));F$.displayName=`MarkdownThead`;var I$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`tbody`,{className:i(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e})},(e,t)=>h$(e,t));I$.displayName=`MarkdownTbody`;var L$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`tr`,{className:i(`border-border`,t),"data-streamdown":`table-row`,...r,children:e})},(e,t)=>h$(e,t));L$.displayName=`MarkdownTr`;var R$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.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)=>h$(e,t));R$.displayName=`MarkdownTh`;var z$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`td`,{className:i(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e})},(e,t)=>h$(e,t));z$.displayName=`MarkdownTd`;var B$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.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)=>h$(e,t));B$.displayName=`MarkdownBlockquote`;var V$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`sup`,{className:i(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e})},(e,t)=>h$(e,t));V$.displayName=`MarkdownSup`;var H$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`sub`,{className:i(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e})},(e,t)=>h$(e,t));H$.displayName=`MarkdownSub`;var U$=(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===S$){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,H.jsx)(`section`,{className:t,...r,children:i}):null}return(0,H.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>h$(e,t));U$.displayName=`MarkdownSection`;var W$=(0,v.memo)(({node:e,className:t,children:n,...r})=>{let i=uQ(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,v.useContext)($1),l=qQ(),u=iQ(),d=(t?.match(p$))?.at(1)??``,f=JQ(d);if(a)return(0,H.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(u$),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&d$.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,H.jsx)(v.Suspense,{fallback:(0,H.jsx)(LQ,{}),children:(0,H.jsx)(e,{code:y,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=_$(s,`mermaid`),n=b$(s,`download`),r=b$(s,`copy`),a=b$(s,`fullscreen`),c=b$(s,`panZoom`),l=e&&(n||r||a);return(0,H.jsx)(v.Suspense,{fallback:(0,H.jsx)(LQ,{}),children:(0,H.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,H.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,H.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,H.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,H.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,H.jsx)(ZQ,{chart:y,config:o?.config}):null,r?(0,H.jsx)(NQ,{code:y}):null,a?(0,H.jsx)(QQ,{chart:y,config:o?.config}):null]})}):null,(0,H.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,H.jsx)(f$,{chart:y,config:o?.config,showControls:c})})]})})}let b=_$(s,`code`),x=y$(s,`download`),S=y$(s,`copy`),{"data-block":C,...w}=r;return(0,H.jsx)(wQ,{className:t,code:y,isIncomplete:u,language:d,lineNumbers:_,startLine:g,...w,children:b?(0,H.jsxs)(H.Fragment,{children:[x?(0,H.jsx)(IQ,{code:y,language:d}):null,S?(0,H.jsx)(NQ,{}):null]}):null})},(e,t)=>h$(e,t)&&g$(e.node,t.node));W$.displayName=`MarkdownCode`;var G$=(0,v.memo)(({node:e,className:t,...n})=>{let{controls:r}=(0,v.useContext)($1),i=_$(r,`image`),a=i&&x$(r,`download`);return(0,H.jsx)(zQ,{className:t,node:e,showControls:i,showDownloadControl:a,...n})},(e,t)=>h$(e,t));G$.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,H.jsx)(H.Fragment,{children:e})}return(0,H.jsx)(`p`,{...n,children:e})},(e,t)=>h$(e,t));K$.displayName=`MarkdownParagraph`;var q$={ol:S$,li:C$,ul:w$,hr:T$,strong:E$,a:D$,h1:O$,h2:k$,h3:A$,h4:j$,h5:M$,h6:N$,table:P$,thead:F$,tbody:I$,tr:L$,th:R$,td:z$,blockquote:B$,code:W$,img:G$,pre:({children:e})=>(0,v.isValidElement)(e)?(0,v.cloneElement)(e,{"data-block":`true`}):e,sup:V$,sub:H$,p:K$,section:U$},J$=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Y$=/\p{L}/u;function X$(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}Y$.test(e)&&(n??=`ltr`,r+=1)}return i>r?`rtl`:r>i?`ltr`:n??`ltr`}var Z$=/^[ \t]{0,3}(`{3,}|~{3,})/,Q$=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,$$=e=>{let t=e.split(`
170
+ `)},o$=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=uQ(),[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)($1),m=MQ(),h=t$(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=e$(t),o=``;o=e===`csv`?n$(a,h):e===`tsv`?r$(a):a$(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 _=kQ(),y=c?_.CheckIcon:_.CopyIcon;return(0,H.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,H.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,H.jsx)(y,{height:14,width:14})}),o?(0,H.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,H.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,H.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,H.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]})},s$=({children:e,className:t,onDownload:n,onError:r})=>{let i=uQ(),[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null),{isAnimating:c,controls:l}=(0,v.useContext)($1),u=MQ(),d=kQ(),f=t$(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=e$(t),a=e===`csv`?n$(i,f):a$(i),c=e===`csv`?`csv`:`md`;cQ(`${PQ(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,H.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,H.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,H.jsx)(d.DownloadIcon,{size:14})}),a?(0,H.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,H.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,H.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]})},c$=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=kQ(),o=uQ(),[s,c]=(0,v.useState)(!1),{isAnimating:l}=(0,v.useContext)($1),u=MQ(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,v.useEffect)(()=>{if(s){VQ();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),HQ()}}},[s]),(0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.jsx)(i,{size:14})}),s?(0,Ed.createPortal)((0,H.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,H.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,H.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,H.jsx)(o$,{}):null,r?(0,H.jsx)(s$,{}):null,(0,H.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,H.jsx)(a,{size:20})})]}),(0,H.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,H.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},l$=({children:e,className:t,maxHeight:n,showControls:r,showCopy:i=!0,showDownload:a=!0,showFullscreen:o=!0,...s})=>{let c=uQ(),{isAnimating:l}=(0,v.useContext)($1),u=fQ(n),d=pQ(l,!!u,e),f=r&&i,p=r&&a,m=r&&o,h=f||p||m;return(0,H.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,H.jsxs)(`div`,{className:c(`flex items-center justify-end gap-1`),children:[f?(0,H.jsx)(o$,{}):null,p?(0,H.jsx)(s$,{}):null,m?(0,H.jsx)(c$,{showCopy:f,showDownload:p,children:e}):null]}):null,(0,H.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,H.jsx)(`table`,{className:c(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...s,children:e})})]})},u$=/startLine=(\d+)/,d$=/\bnoLineNumbers\b/,f$=(0,v.lazy)(()=>kM(()=>import(`./mermaid-HWGCJPDP-DTn0AouB.js`).then(e=>({default:e.Mermaid})),[])),p$=/language-([^\s]+)/,m$=`node`;function h$(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!==m$&&!Object.is(r[e],i[e]))return!1;return!0}function g$(e,t){return e?.properties?.metastring===t?.properties?.metastring}var _$=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,v$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},y$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},b$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},x$=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.image;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},S$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`ol`,{className:i(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e})},(e,t)=>h$(e,t));S$.displayName=`MarkdownOl`;var C$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`li`,{className:i(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e})},(e,t)=>h$(e,t));C$.displayName=`MarkdownLi`;var w$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`ul`,{className:i(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e})},(e,t)=>h$(e,t));w$.displayName=`MarkdownUl`;var T$=(0,v.memo)(({className:e,node:t,...n})=>{let r=uQ();return(0,H.jsx)(`hr`,{className:r(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n})},(e,t)=>h$(e,t));T$.displayName=`MarkdownHr`;var E$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`span`,{className:i(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e})},(e,t)=>h$(e,t));E$.displayName=`MarkdownStrong`;var D$=(0,v.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=uQ(),{linkSafety:o}=(0,v.useContext)($1),[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,H.jsxs)(H.Fragment,{children:[(0,H.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,H.jsx)(UQ,{...p})]}):(0,H.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)=>h$(e,t));D$.displayName=`MarkdownA`;var O$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h1`,{className:i(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e})},(e,t)=>h$(e,t));O$.displayName=`MarkdownH1`;var k$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h2`,{className:i(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e})},(e,t)=>h$(e,t));k$.displayName=`MarkdownH2`;var A$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h3`,{className:i(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e})},(e,t)=>h$(e,t));A$.displayName=`MarkdownH3`;var j$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h4`,{className:i(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e})},(e,t)=>h$(e,t));j$.displayName=`MarkdownH4`;var M$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h5`,{className:i(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e})},(e,t)=>h$(e,t));M$.displayName=`MarkdownH5`;var N$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`h6`,{className:i(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e})},(e,t)=>h$(e,t));N$.displayName=`MarkdownH6`;var P$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i,tableMaxHeight:a}=(0,v.useContext)($1),o=_$(i,`table`),s=v$(i,`copy`),c=v$(i,`download`),l=v$(i,`fullscreen`);return(0,H.jsx)(l$,{className:t,maxHeight:a,showControls:o,showCopy:s,showDownload:c,showFullscreen:l,...r,children:e})},(e,t)=>h$(e,t));P$.displayName=`MarkdownTable`;var F$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`thead`,{className:i(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e})},(e,t)=>h$(e,t));F$.displayName=`MarkdownThead`;var I$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`tbody`,{className:i(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e})},(e,t)=>h$(e,t));I$.displayName=`MarkdownTbody`;var L$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`tr`,{className:i(`border-border`,t),"data-streamdown":`table-row`,...r,children:e})},(e,t)=>h$(e,t));L$.displayName=`MarkdownTr`;var R$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.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)=>h$(e,t));R$.displayName=`MarkdownTh`;var z$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`td`,{className:i(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e})},(e,t)=>h$(e,t));z$.displayName=`MarkdownTd`;var B$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.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)=>h$(e,t));B$.displayName=`MarkdownBlockquote`;var V$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`sup`,{className:i(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e})},(e,t)=>h$(e,t));V$.displayName=`MarkdownSup`;var H$=(0,v.memo)(({children:e,className:t,node:n,...r})=>{let i=uQ();return(0,H.jsx)(`sub`,{className:i(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e})},(e,t)=>h$(e,t));H$.displayName=`MarkdownSub`;var U$=(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===S$){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,H.jsx)(`section`,{className:t,...r,children:i}):null}return(0,H.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>h$(e,t));U$.displayName=`MarkdownSection`;var W$=(0,v.memo)(({node:e,className:t,children:n,...r})=>{let i=uQ(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,v.useContext)($1),l=qQ(),u=iQ(),d=(t?.match(p$))?.at(1)??``,f=JQ(d);if(a)return(0,H.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(u$),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&d$.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,H.jsx)(v.Suspense,{fallback:(0,H.jsx)(LQ,{}),children:(0,H.jsx)(e,{code:y,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=_$(s,`mermaid`),n=b$(s,`download`),r=b$(s,`copy`),a=b$(s,`fullscreen`),c=b$(s,`panZoom`),l=e&&(n||r||a);return(0,H.jsx)(v.Suspense,{fallback:(0,H.jsx)(LQ,{}),children:(0,H.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,H.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,H.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,H.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,H.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,H.jsx)(ZQ,{chart:y,config:o?.config}):null,r?(0,H.jsx)(NQ,{code:y}):null,a?(0,H.jsx)(QQ,{chart:y,config:o?.config}):null]})}):null,(0,H.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,H.jsx)(f$,{chart:y,config:o?.config,showControls:c})})]})})}let b=_$(s,`code`),x=y$(s,`download`),S=y$(s,`copy`),{"data-block":C,...w}=r;return(0,H.jsx)(wQ,{className:t,code:y,isIncomplete:u,language:d,lineNumbers:_,startLine:g,...w,children:b?(0,H.jsxs)(H.Fragment,{children:[x?(0,H.jsx)(IQ,{code:y,language:d}):null,S?(0,H.jsx)(NQ,{}):null]}):null})},(e,t)=>h$(e,t)&&g$(e.node,t.node));W$.displayName=`MarkdownCode`;var G$=(0,v.memo)(({node:e,className:t,...n})=>{let{controls:r}=(0,v.useContext)($1),i=_$(r,`image`),a=i&&x$(r,`download`);return(0,H.jsx)(zQ,{className:t,node:e,showControls:i,showDownloadControl:a,...n})},(e,t)=>h$(e,t));G$.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,H.jsx)(H.Fragment,{children:e})}return(0,H.jsx)(`p`,{...n,children:e})},(e,t)=>h$(e,t));K$.displayName=`MarkdownParagraph`;var q$={ol:S$,li:C$,ul:w$,hr:T$,strong:E$,a:D$,h1:O$,h2:k$,h3:A$,h4:j$,h5:M$,h6:N$,table:P$,thead:F$,tbody:I$,tr:L$,th:R$,td:z$,blockquote:B$,code:W$,img:G$,pre:({children:e})=>(0,v.isValidElement)(e)?(0,v.cloneElement)(e,{"data-block":`true`}):e,sup:V$,sub:H$,p:K$,section:U$},J$=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Y$=/\p{L}/u;function X$(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}Y$.test(e)&&(n??=`ltr`,r+=1)}return i>r?`rtl`:r>i?`ltr`:n??`ltr`}var Z$=/^[ \t]{0,3}(`{3,}|~{3,})/,Q$=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,$$=e=>{let t=e.split(`
171
171
  `),n=null,r=0;for(let e of t){let t=Z$.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},e1=e=>{let t=e.split(`
172
172
  `);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&Q$.test(t))return!0}return!1},t1=()=>e=>{bP(e,`html`,(e,t,n)=>{!n||typeof t!=`number`||(n.children[t]={type:`text`,value:e.value})})},n1=[],r1={allowDangerousHtml:!0},i1=new WeakMap,a1=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=i1.get(e);n||(n=e.name,i1.set(e,n)),t+=n}else t+=String(e);t+=`:`,t+=JSON.stringify(n)}else if(typeof r==`function`){let e=i1.get(r);e||(e=r.name,i1.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()}},o1=e=>{let t=s1(e),n=e.children||``;return m1(t.runSync(t.parse(n),n),e)},s1=e=>{let t=a1.get(e);if(t)return t;let n=l1(e);return a1.set(e,n),n},c1=e=>e.some(e=>Array.isArray(e)?e[0]===bz:e===bz),l1=e=>{let t=e.rehypePlugins||n1,n=e.remarkPlugins||n1,r=c1(t)?n:[...n,t1],i=e.remarkRehypeOptions?{...r1,...e.remarkRehypeOptions}:r1;return BY().use(xJ).use(r).use(fY,i).use(t)},u1=e=>e,d1=(e,t,n,r)=>{n?e.children.splice(t,1):e.children[t]={type:`text`,value:r}},f1=(e,t)=>{for(let n in Iq)if(Object.hasOwn(Iq,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],i=Iq[n];(i===null||i.includes(e.tagName))&&(e.properties[n]=t(String(r||``),n,e)??void 0)}},p1=(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},m1=(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||u1;bP(e,(e,s,c)=>{if(e.type===`raw`&&c&&typeof s==`number`)return d1(c,s,a,e.value),s;if(e.type===`element`&&(f1(e,t),p1(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 mq(e,{Fragment:H.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:H.jsx,jsxs:H.jsxs,passKeys:!0,passNode:!0})},h1=/\[\^[\w-]{1,200}\](?!:)/,g1=/\[\^[\w-]{1,200}\]:/,_1=/<([A-Za-z][\w:-]*)[\s>/]/,v1=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),y1=new Map,b1=new Map,x1=e=>{let t=e.toLowerCase(),n=y1.get(t);if(n)return n;let r=RegExp(`<${t}(?=[\\s>/])[^>]*>`,`gi`);return y1.set(t,r),r},S1=e=>{let t=e.toLowerCase(),n=b1.get(t);if(n)return n;let r=RegExp(`</${t}(?=[\\s>])[^>]*>`,`gi`);return b1.set(t,r),r},C1=(e,t)=>{if(v1.has(t.toLowerCase()))return 0;let n=e.match(x1(t));if(!n)return 0;let r=0;for(let e of n)e.trimEnd().endsWith(`/>`)||(r+=1);return r},w1=(e,t)=>{let n=e.match(S1(t));return n?n.length:0},T1=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},Dne=e=>{let t=h1.test(e),n=g1.test(e);if(t||n)return[e];let r=yZ.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=C1(t,e),o=w1(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(_1);if(e){let n=e[1];C1(t,n)>w1(t,n)&&a.push(n)}}if(n>0&&!o){let e=i[n-1];if(T1(e)%2==1){i[n-1]=e+t;continue}}i.push(t),e.type!==`space`&&(o=e.type===`code`)}return i},E1=/^\n*/,D1=/\n*$/,O1=/\n\n/g,k1=(e,t,n)=>t.includes(`
173
173
  `)?`${e}${t.replace(O1,`
@@ -209,4 +209,4 @@ ${u}`,i=e.length;break}return i===0?e:r+e.slice(i)},j1=(e,t)=>{if(!t.length)retu
209
209
  `).entries())r=n5(r,r5((a===0?i:``)+(o||` `),t,{extraPx:n}))}return r}case`assistant_text`:return u5(e.text,t,n);case`thinking`:return r5(e.text,t,{extraPx:n});case`tool_call`:return o2(e)?{px:t.line+n,exact:!0}:f5(e,t,n);case`turn_result`:{let r=r5(`${e.isError?e.subtype:`done`} · ${rN(e.durationMs)} · ${nN(e.totalCostUsd)}`,t,{extraPx:n});for(let i of e.errors??[])r=n5(r,r5(i,t,{extraPx:n}));return r}case`notice`:return r5(e.text,t,{extraPx:n});case`compaction`:return r5(tN(e),t,{extraPx:n});case`file_delivered`:return r5(`${e.path} · ${aN(e.bytes)}`+(e.description?` · ${e.description}`:``),t,{extraPx:n});case`shell`:{let r=o4(e,!1),i=r5(a4(e),t,{extraPx:n});for(let e of r)i=n5(i,r5(e||` `,t,{extraPx:n}));let a=s4(e,!1,r.length);return a&&(i=n5(i,r5(a,t,{extraPx:n}))),i}default:return{px:0,exact:!1}}}function h5(e,t){if(`task`in e)return r5(E2(e.task,P3(e)),t);if(`run`in e){let n=m2(e.run);if(n.kind===`call`)return m5(n.item,t);let r=n.items.some(e=>e.status===`running`||e.status===`pending`);return r5(h2(n.items,r),t)}return m5(e.item,t)}function g5(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 _5={user:`l`,subagent:`l`,shell:`l`,turn:`r`,turnFailed:`r`,toolFailed:`r`,error:`r`,approval:`f`,recap:`f`,bookmark:`f`},v5={approval:7,error:6,turnFailed:5,toolFailed:4,user:3,turn:2,bookmark:1,subagent:1,shell:1,recap:0},y5={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 b5(e){return`${e.isError?e.subtype:`done`} · ${rN(e.durationMs)} · ${nN(e.totalCostUsd)}`}function x5(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}(${dN(e.input)})`;case`turn_result`:return b5(e);case`file_delivered`:return e.path;default:return``}}function S5(e){return e.kind===`tool_call`&&(e.status===`failed`||e.result?.isError===!0)}function C5(e,t,n){let r=new Map;return e.forEach((e,i)=>{e.kind===`tool_call`&&j3(e)===t&&r.set(n(i),i)}),new Set(r.values())}function w5(e,{frameParentId:t,bookmarks:n=[],recapItemIndex:r,rowIndexFor:i=e=>e}={}){let a=[],o=new Set;for(let t of e){let e=j3(t);e!==void 0&&o.add(e)}let s=C5(e,t,i),c={},l=()=>{let e=c.response??c.turn;e!==void 0&&a.push({kind:c.failed?`turnFailed`:`turn`,itemIndex:e,turnIndex:c.turn}),c={}};e.forEach((e,n)=>{if(e.kind===`tool_call`&&o.has(e.id)&&a.push({kind:`subagent`,itemIndex:n}),e.kind===`user`&&j3(e)===t)l(),a.push({kind:`user`,itemIndex:n});else if(e.kind===`turn_result`)c.turn=n,c.failed=e.isError,l();else if(e.kind===`notice`&&e.level===`error`)a.push({kind:`error`,itemIndex:n});else if(e.kind===`shell`)a.push({kind:`shell`,itemIndex:n});else if(S5(e)&&s.has(n))a.push({kind:`toolFailed`,itemIndex:n});else if(e.kind===`assistant_text`&&j3(e)===t){if(t!==void 0){a.push({kind:`turn`,itemIndex:n});return}c.response=n}}),l();for(let t of n)t>=0&&t<e.length&&a.push({kind:`bookmark`,itemIndex:t});return r!==void 0&&a.push({kind:`recap`,itemIndex:r}),a}function T5(e,t){let n=Math.max(1,t),r=Math.max(2,Math.round(e/n));return t=>({y:Math.min(Math.max(0,e-r),Math.round(t.itemIndex/n*e)),h:r})}function E5(e,t){let n=new Map;for(let r of e){let e=_5[r.kind],i=n.get(e)??[];i.push({mark:r,...t(r)}),n.set(e,i)}let r=[];for(let[e,t]of n){t.sort((e,t)=>e.y-t.y);let n=null;for(let{mark:i,y:a,h:o}of t)n&&a<=n.y+n.h+1?(n.h=Math.max(n.h,a+o-n.y),v5[i.kind]>v5[n.kind]&&(n.kind=i.kind),n.marks.push({mark:i,y:a})):(n={lane:e,kind:i.kind,y:a,h:o,marks:[{mark:i,y:a}]},r.push(n))}return r}function D5(e){return{lane:_5.approval,kind:`approval`,y:Math.max(0,e-2),h:2,marks:[]}}var One={excerptClass:`wd-scrub-ex`,muted:`muted`,danger:`danger`,glyph:`muted`,detail:`muted`},kne={excerptClass:`term-scrub-ex`,muted:`faint`,danger:`red`,glyph:`dim`,text:`fg`,strong:`bright`,detail:`fg`,answerGlyph:`● `};function O5({cluster:e,first:t,items:n,pendingApprovals:r,recapLabel:i},a){let o=e.marks.length>1?` · ${e.marks.length} marks`:``,s=t?.kind??e.kind;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{"data-tone":a.muted,children:[y5[s],o]}),e.kind===`approval`?Ane(r[0],a):s===`recap`?jne(i,a):Mne(t,n,a)]})}function Ane(e,t){return e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{"data-tone":t.strong,children:r6(e).heading}),(0,H.jsx)(`div`,{className:t.excerptClass,"data-tone":t.detail,children:`${e.displayName??e.toolName}(${dN(e.input)})`})]}):null}function jne(e,t){return e===void 0?null:(0,H.jsxs)(`div`,{"data-tone":t.muted,children:[`※ `,e]})}function Mne(e,t,n){if(!e)return null;let r=t[e.itemIndex];if(e.kind===`turn`||e.kind===`turnFailed`){let i=e.turnIndex===void 0?void 0:t[e.turnIndex];return(0,H.jsxs)(H.Fragment,{children:[r?.kind===`assistant_text`?(0,H.jsxs)(`div`,{className:n.excerptClass,"data-tone":n.text,children:[n.answerGlyph?(0,H.jsx)(`span`,{"data-tone":n.glyph,children:n.answerGlyph}):null,r.text]}):null,i?.kind===`turn_result`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{"data-tone":i.isError?n.danger:n.muted,children:b5(i)}),i.errors?.map((e,t)=>(0,H.jsx)(`div`,{"data-tone":n.danger,children:e},t))]}):null]})}if(!r)return null;let i=e.kind===`toolFailed`&&r.kind===`tool_call`?r.result?.text.split(`
210
210
  `).find(e=>e.trim()!==``):void 0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:n.excerptClass,"data-tone":e.kind===`error`||e.kind===`toolFailed`?n.danger:n.text,children:[e.kind===`user`?(0,H.jsx)(`span`,{"data-tone":n.glyph,children:`❯ `}):null,x5(r)]}),i?(0,H.jsx)(`div`,{className:n.excerptClass,"data-tone":n.danger,children:i}):null]})}function k5(e,t,n){return t>0?e/Math.max(t,n):0}function Nne(e,t){let{items:n,bookmarks:r,frameParentId:i,recapRow:a,pendingApprovals:o,rowIndexFor:s,offsetOfRow:c,sizeOfRow:l,positionInRow:u,totalSize:d,viewportH:f}=e,p=w5(n,{frameParentId:i,bookmarks:r,rowIndexFor:s}).map(e=>({...e,rowIndex:s(e.itemIndex)}));a&&p.push({kind:`recap`,itemIndex:-1,rowIndex:a.rowIndex});let m=k5(t,d,f),h=E5(p,e=>{let n=e.rowIndex??s(e.itemIndex),r=e.itemIndex>=0?u?.(e.itemIndex):void 0,i=l(n),a=r?2:Math.max(2,Math.round(i*m)),o=c(n)+(r?r.ordinal/r.count*i:0);return{y:Math.min(Math.max(0,t-a),Math.round(o*m)),h:a}});return o.length>0&&h.push(D5(t)),h}function Pne(e){let{scrollOffset:t,viewportH:n,totalSize:r,onJumpToRow:i,interactive:a,fontSize:o,lineHeight:s}=e,c=a8(),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?Nne(e,d):[],[e.items,e.bookmarks,e.recapRow,e.pendingApprovals,r,d,n]),b=k5(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=(t,n)=>{if(t.kind===`approval`&&t.marks.length===0){c.scrollToBottom();return}let r=g5(t,w(n));r&&i(r.rowIndex??e.rowIndexFor(r.itemIndex))},E=(e,t)=>{let n=w(t),r=g5(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,H.jsx)(z4,{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,H.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,H.jsx)(`div`,{className:`term-scrub-band`,style:{top:S,height:x}}),y.map((e,t)=>(0,H.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,H.jsx)(`div`,{ref:u,className:`term-scrub-peek`,style:{top:p.y},children:O5({cluster:p.cluster,first:p.mark,items:e.items,pendingApprovals:e.pendingApprovals,recapLabel:e.recapRow?.label},kne)}):null]})})}function Fne({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=E5(w5(e,{frameParentId:i,bookmarks:r,recapItemIndex:n}),T5(u,e.length));return t.length>0&&a.push(D5(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=g5(t,h(n));r&&o?.(r.itemIndex)},_=(e,t)=>{let n=h(t),r=g5(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,H.jsxs)(`div`,{ref:c,className:U(`wd-scrubber`,s),"data-interactive":a||void 0,"aria-hidden":!0,children:[m.map((e,t)=>(0,H.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,H.jsx)(`div`,{ref:l,className:`wd-scrub-peek`,style:{top:f.y},children:O5({cluster:f.cluster,first:f.mark,items:e,pendingApprovals:t},One)}):null]})}var A5=new WeakMap,j5=new WeakMap;function M5(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 N5(e,t){let n=M5(e[t-1]),r=M5(e[t]);return!n||!r||L3(n,r)}function Ine(e){let t=A5.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)}),A5.set(e,n),n}function P5(e,t){let n=Ine(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 Lne(e){let t=j5.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 j5.set(e,n),n}function Rne(e,t){return Lne(e).get(t)}function zne(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=B8(e);t&&n&&r&&o(e=>e&&e.width===n&&e.ch===r&&e.line===t?e:L8(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 F5=4,I5=50;function Bne(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 Vne(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 Hne(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&&N5(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>=F5)&&(f.current=setTimeout(()=>{Math.abs(o.scrollTop-u())>1&&d(e+1)},I5))};d(0);return}let d=t=>{let n=o.querySelector(`[data-index="${e}"]`);if(n){n.scrollIntoView({behavior:`instant`,block:u});return}t>=F5||(c.scrollToIndex(e,{align:u,behavior:`auto`}),f.current=setTimeout(()=>d(t+1),I5))};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),Bne(l)},()=>{d.current=null}}),p}function L5({item:e,fileUrl:t,attachmentUrl:n}){switch(e.kind){case`user`:return(0,H.jsx)(y4,{item:e,attachmentUrl:n});case`assistant_text`:return(0,H.jsx)(b4,{item:e});case`thinking`:return(0,H.jsx)(x4,{item:e});case`tool_call`:return o2(e)?(0,H.jsx)(v4,{item:e}):(0,H.jsx)(C4,{item:e});case`turn_result`:return(0,H.jsx)(M4,{item:e});case`notice`:return(0,H.jsx)(P4,{item:e});case`compaction`:return(0,H.jsx)(N4,{item:e});case`file_delivered`:return(0,H.jsx)(I4,{item:e,href:t?.(e.path)});case`shell`:return(0,H.jsx)(F4,{item:e});default:return null}}function R5({text:e,terminal:t}){let[n,r]=(0,v.useState)(!1);return t?(0,H.jsx)(`div`,{"data-slot":`brief`,children:(0,H.jsx)(j2,{onPress:()=>r(e=>!e),expanded:n,children:(0,H.jsx)($N,{glyph:`>`,glyphTone:`blue`,tone:`dim`,children:(0,H.jsx)(`span`,{className:U(`whitespace-pre-wrap`,!n&&`term-brief-clip`),style:n?void 0:{WebkitLineClamp:4},children:e})})})}):(0,H.jsx)(`div`,{"data-slot":`brief`,className:`px-4 py-2 text-body-sm whitespace-pre-wrap text-fg-2`,children:e})}function Une({block:e,fileUrl:t,onOpenSubagent:n}){let[r,i]=(0,v.useState)(!1),a=M2(r),o=(0,v.useMemo)(()=>P3(e),[e]),s=o.some(e=>e.kind===`user`)?void 0:b2(e.task),c=w2(e.task,o),l=T2(e.task),u=kN(c),d=(0,H.jsxs)(`div`,{ref:a,className:r?`term-open`:void 0,children:[(0,H.jsx)(j2,{onPress:()=>i(e=>!e),expanded:r,children:(0,H.jsx)($N,{glyph:c?u:`●`,glyphTone:l?`red`:c?`mark`:`dim`,tone:l?`red`:`green`,children:c?(0,H.jsx)(`span`,{className:`term-shimmer`,children:E2(e.task,o)}):E2(e.task,o)})}),r?(0,H.jsxs)(`div`,{className:`term-nested`,children:[s?(0,H.jsx)(R5,{text:s,terminal:!0}):null,e.children.map((n,r)=>{let i=e.children[r+1],a=`run`in n?(0,H.jsx)(j4,{items:n.run}):(0,H.jsx)(L5,{item:n.item,fileUrl:t});return(0,H.jsxs)(v.Fragment,{children:[r>0&&z3(e.children[r-1],n)?(0,H.jsx)(eP,{}):null,i&&!z3(n,i)?(0,H.jsx)(VN,{value:`inline`,children:a}):a]},n.key)})]}):null]});return n===void 0?d:(0,H.jsx)(HN,{actions:(0,H.jsx)(qN,{onOpen:()=>n(e.task.id)}),children:d})}function Wne({item:e,href:t,className:n}){let r=e.path.split(`/`).pop()||e.path;return(0,H.jsxs)(`div`,{"data-slot":`file-delivered`,className:U(`flex w-full items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2.5`,n),children:[(0,H.jsx)(ry,{className:`size-4 shrink-0 text-fg-3`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate font-mono text-body-sm font-medium text-fg-1`,children:r}),(0,H.jsxs)(`div`,{className:`truncate text-label text-fg-4`,children:[aN(e.bytes),e.description?` · ${e.description}`:``]})]}),t?(0,H.jsxs)(`a`,{href:t,download:r,className:U(`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,H.jsx)(Gv,{className:`size-3.5`}),`Download`]}):null]})}function z5({from:e,className:t,children:n,...r}){return(0,H.jsx)(`div`,{"data-slot":`message`,"data-from":e,className:U(`flex w-full flex-col items-start gap-1`,t),...r,children:n})}function B5({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`message-content`,className:U(`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 Gne({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,H.jsxs)(`div`,{"data-slot":`reasoning`,"data-streaming":t||void 0,className:U(`w-full`,r),children:[(0,H.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,H.jsx)(k_,{className:`size-3.5`}),(0,H.jsx)(`span`,{children:t?`Thinking…`:`Thought process`}),s?(0,H.jsx)(Q_,{className:U(`size-3.5 transition-transform`,i&&`rotate-180`)}):null]}),i&&s?(0,H.jsx)(`div`,{className:`mt-2 border-l-2 border-border pl-3 text-body-sm text-fg-3 [&_*]:text-fg-3`,children:(0,H.jsx)(a6,{streaming:t,children:e})}):null]})}var V5=2e3,Kne={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}},qne={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 Jne(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`?qne[n.slice(n.lastIndexOf(`.`)+1).toLowerCase()]:void 0}function Yne({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=B2(),u=g0(e),d=e.status??(e.result===void 0?`running`:`settled`),f=Kne[d],p=d===`failed`||e.result?.isError===!0,m=mN(e.name),h=U2(e.name),g=e.result?.text??``,_=!a&&g.length>V5,y=_?g.slice(0,V5):g,b=e.result?.truncated===!0,x=e.result?.totalChars??g.length,S=r?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border p-2.5`,children:[h?(0,H.jsx)(`p`,{className:`font-mono text-label text-fg-4`,children:e.name}):null,(0,H.jsx)(H5,{code:JSON.stringify(e.input,null,2),language:`json`,label:`Parameters`}),e.logs?.length?(0,H.jsx)(H5,{code:e.logs.join(`
211
211
  `),label:`Logs`}):null,e.result===void 0?null:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(H5,{code:y||`(empty result)`,language:Jne(e),label:p?`Error`:`Result`,className:U(p&&`border-danger/40 [&_pre]:text-danger`)}),s?(0,H.jsxs)(`p`,{className:`mt-1 text-label text-fg-3`,children:[`Fetching `,x.toLocaleString(),` chars…`]}):_||b?(0,H.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?(0,H.jsx)(Zne,{path:u,load:t}):null,w=e.result?.images?.length?(0,H.jsx)(`div`,{className:`flex flex-col gap-2 border-t border-border p-2.5`,children:e.result.images.map(t=>(0,H.jsx)(Xne,{toolUseId:e.id,name:v0(e.name,t),image:t},t.partIndex))}):null;return(0,H.jsxs)(`div`,{"data-slot":`tool-call`,"data-state":d,className:U(`w-full overflow-hidden rounded-lg border border-border bg-surface`,n),children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:U(`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,H.jsx)(m,{className:`size-3.5 shrink-0 text-fg-3`}),(0,H.jsx)(`span`,{className:U(`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,H.jsx)(po,{variant:`neutral`,className:`shrink-0`,children:e.backend}):null,(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-label text-fg-4`,children:dN(e.input)}),(0,H.jsxs)(po,{variant:f.variant,dot:!f.busy,className:`shrink-0 gap-1`,children:[f.busy?(0,H.jsx)(_E,{className:`size-3 text-current`}):null,d===`deferred`?(0,H.jsx)(yv,{className:`size-3 text-current`}):null,f.label]}),(0,H.jsx)(Q_,{className:U(`size-3.5 shrink-0 text-fg-4 transition-transform`,r&&`rotate-180`)})]}),C,w,S]})}function H5({code:e,label:t,className:n}){return(0,H.jsx)(vE,{code:e,label:t,variant:`panel`,className:n})}function Xne({toolUseId:e,name:t,image:n}){let{src:r,failed:i}=P0({toolUseId:e,...n});return(0,H.jsx)(`div`,{className:`flex h-60 items-start overflow-hidden rounded-md border border-border bg-surface-hover`,children:r?(0,H.jsx)(D0,{image:{src:r,name:t},className:`h-full max-w-full`,children:(0,H.jsx)(`img`,{src:r,alt:t,className:`h-full max-w-full object-contain`})}):(0,H.jsx)(`span`,{className:`p-2 text-label text-fg-4`,children:i?h0:m0(n)})})}function Zne({path:e,load:t}){let{src:n}=L0(e,t);if(!n)return null;let r=_0(e);return(0,H.jsx)(`div`,{className:`border-t border-border p-2.5`,children:(0,H.jsx)(D0,{image:{src:n,name:r},className:`block max-w-full`,children:(0,H.jsx)(`img`,{src:n,alt:r,className:`max-h-96 w-auto max-w-full rounded-md border border-border`})})})}function Qne({item:e}){return(0,H.jsxs)(`div`,{"data-slot":`turn-result`,className:`py-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,H.jsxs)(`span`,{className:U(`font-mono text-label`,e.isError?`text-danger`:`text-fg-4`),children:[e.isError?e.subtype:`turn done`,` · `,rN(e.durationMs),` · `,nN(e.costUsd??e.totalCostUsd)]}),(0,H.jsx)(`div`,{className:`h-px flex-1 bg-border`})]}),e.errors?.length?(0,H.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5 text-center`,children:e.errors.map((e,t)=>(0,H.jsx)(`li`,{className:`text-label break-words text-danger`,children:e},t))}):null]})}function $ne({item:e}){return(0,H.jsx)(`div`,{"data-slot":`notice`,className:U(`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 ere({item:e,fileUrl:t,attachmentUrl:n,hostImage:r,terminal:i}){if(i)return(0,H.jsx)(L5,{item:e,fileUrl:t,attachmentUrl:n});switch(e.kind){case`user`:return(0,H.jsx)(HN,{actions:(0,H.jsx)(KN,{id:e.id}),children:(0,H.jsxs)(z5,{from:`user`,children:[e.origin?(0,H.jsx)(`div`,{className:`wd-peer-origin text-xs text-muted-foreground`,children:g4(e.origin)}):null,e.attachments?.length?(0,H.jsx)(are,{attachments:e.attachments,attachmentUrl:n}):null,e.text?(0,H.jsx)(B5,{children:(0,H.jsx)(PN,{text:e.text})}):null]})});case`assistant_text`:return(0,H.jsx)(HN,{actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(KN,{id:e.id}),e.streaming?null:(0,H.jsx)(ZN,{text:e.text,label:`Copy message`})]}),children:(0,H.jsx)(z5,{from:`assistant`,children:(0,H.jsx)(B5,{children:(0,H.jsx)(a6,{streaming:e.streaming,children:e.text})})})});case`thinking`:return(0,H.jsx)(Gne,{isStreaming:e.id===`streaming-thinking`,children:e.text});case`tool_call`:return(0,H.jsx)(tre,{item:e,hostImage:r});case`turn_result`:return(0,H.jsx)(Qne,{item:e});case`notice`:return(0,H.jsx)($ne,{item:e});case`compaction`:return(0,H.jsx)(rre,{item:e});case`file_delivered`:return(0,H.jsx)(Wne,{item:e,href:t?.(e.path)});case`shell`:return(0,H.jsx)(nre,{item:e});default:return null}}function tre({item:e,hostImage:t}){let n=e.input?.command,r=typeof n==`string`?n:e.result?.text??``;return(0,H.jsx)(HN,{actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(KN,{id:e.id}),r?(0,H.jsx)(ZN,{text:r,label:`Copy`}):null]}),children:(0,H.jsx)(Yne,{item:e,hostImage:t})})}function nre({item:e}){let[t,n]=(0,v.useState)(!1),r=d4(),i=i4(e),a=o4(e,t),o=s4(e,t,a.length),s=e.shell.id;return f4(e),(0,H.jsx)(HN,{actions:(0,H.jsx)(p4,{item:e}),children:(0,H.jsxs)(`div`,{"data-slot":`shell`,className:`overflow-hidden rounded-md border border-border bg-surface`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5`,children:[(0,H.jsx)(`span`,{className:`font-mono text-label text-[var(--wd-shell-accent)]`,children:`$`}),(0,H.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(s)},children:e4(e)}),(0,H.jsx)(`span`,{className:U(`shrink-0 text-label`,i?`text-danger`:`text-fg-4`),children:t4(e)})]}),a.length>0?(0,H.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:a.join(`
212
- `)}):null,o?(0,H.jsx)(`div`,{className:`px-3 pb-2 text-label text-fg-4`,children:o}):null]})})}function rre({item:e}){return(0,H.jsxs)(`div`,{"data-slot":`compaction`,className:`flex items-center gap-2 py-1`,children:[(0,H.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,H.jsxs)(`span`,{className:`font-mono text-label ${e.error===void 0?`text-fg-3`:`text-danger`}`,children:[e.pending?`⋯`:`≡`,` `,tN(e)]}),(0,H.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function ire({line:e,since:t,terminal:n}){let r=t===void 0?void 0:sN(t),i=r?`${e} · last here ${r}`:e;return n?(0,H.jsx)(`div`,{"data-slot":`recap`,children:(0,H.jsxs)($N,{glyph:`※`,glyphTone:`faint`,tone:`faint`,children:[`recap: `,i]})}):(0,H.jsxs)(`div`,{"data-slot":`recap`,className:`flex items-center gap-2 py-1`,children:[(0,H.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,H.jsxs)(`span`,{className:`font-mono text-label text-fg-3`,children:[`※ recap: `,i]}),(0,H.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function are({attachments:e,attachmentUrl:t}){return(0,H.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,H.jsx)(D0,{image:{src:n,name:e.name},className:`rounded-md`,children:(0,H.jsx)(`img`,{src:n,alt:e.name,className:`size-20 rounded-md border border-border object-cover`})},e.id):(0,H.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 U5(e,t){return e!==void 0&&t<e}function ore(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 sre(e){return e.text||(e.attachments??[]).map(e=>e.name).join(`, `)}function cre({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,H.jsxs)(`div`,{"data-sticky-lane":i?`terminal`:`cards`,className:`absolute inset-x-0`,style:{top:e,height:t},children:[(0,H.jsx)(`div`,{"data-sticky-headlane":``,"aria-hidden":!0,children:(0,H.jsx)(`div`,{ref:u,"data-sticky-head":``,className:i&&n||void 0,children:c})}),(0,H.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,H.jsx)(`div`,{ref:s,"data-index":o,className:n||void 0,children:l})]})}function lre({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=a8(),[w,T]=(0,v.useState)(null),E=(0,v.useMemo)(()=>e.flatMap((e,t)=>`item`in e&&e.item.kind===`user`&&j3(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&&Vne(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=zne({terminal:r,fontSize:l,lineHeight:u,rowsRef:k}),j=I8({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&&N5(e,t)?A.line:0;return n&&`text`in n&&n.key===`brief`?z8(n.text,A)+r:n&&!(`line`in n)?R8(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(x8(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=Hne({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(P5(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,H.jsxs)(`div`,{ref:k,"data-slot":`transcript-rows`,className:`relative w-full`,style:{height:j.getTotalSize()},children:[(0,H.jsx)(O2,{items:d,children:j.getVirtualItems().map(i=>{let l=e[i.index],u=i.index>0&&(!r||N5(e,i.index))?c.className:void 0,d=r&&i.index<e.length-1&&!N5(e,i.index+1),f=`run`in l?(0,H.jsx)(`div`,{className:U(U5(t,l.index)&&`opacity-45`),children:(0,H.jsx)(j4,{items:l.run})}):`item`in l?(0,H.jsx)(`div`,{className:U(U5(t,l.index)&&`opacity-45`,ore(l.item,o)),children:(0,H.jsx)(ere,{item:l.item,fileUrl:g,attachmentUrl:_,hostImage:y,terminal:r})}):`text`in l&&l.key===`brief`?(0,H.jsx)(R5,{text:l.text,terminal:r}):`line`in l?(0,H.jsx)(ire,{line:l.line,since:n,terminal:r}):(0,H.jsx)(`div`,{className:U(U5(t,l.index)&&`opacity-45`),children:(0,H.jsx)(Une,{block:l,fileUrl:g,onOpenSubagent:s})}),p=(0,H.jsx)(VN,{value:d?`inline`:`below`,children:f});if(a&&`item`in l&&l.item.kind===`user`&&j3(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,H.jsx)(cre,{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?p:sre(l.item),content:p},l.key)}return(0,H.jsx)(`div`,{ref:j.measureElement,"data-index":i.index,className:U(`absolute inset-x-0 top-0`,u),style:{transform:`translateY(${i.start}px)`},children:p},l.key)})}),p&&w?.parentElement?(0,Ed.createPortal)(r?(0,H.jsx)(Pne,{items:d,pendingApprovals:f,recapRow:R,bookmarks:I,frameParentId:o,rowIndexFor:t=>P5(e,t),positionInRow:t=>Rne(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,H.jsx)(Fne,{items:d,pendingApprovals:f,recapItemIndex:L>=0?t:void 0,bookmarks:I,frameParentId:o,interactive:F,onJumpToItem:t=>M(P5(e,t),`start`)}),w.parentElement):null]})}function ure(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 dre(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 fre({active:e,fontSize:t,lineHeight:n,affordances:r,children:i}){return e?(0,H.jsx)(z4,{fontSize:t,lineHeight:n,affordances:r,bleed:`1ch`,className:`term-transcript`,children:i}):(0,H.jsx)(`div`,{"data-cards":``,className:`contents`,children:(0,H.jsx)(zN,{value:RN(r),children:i})})}function pre({state:e,fileUrl:t,attachmentUrl:n,canBrowseFiles:r,hostImage:i,variant:a=`cards`,fontSize:o,lineHeight:s,affordances:c,stickyPrompt:l=!1,scrubber:u,bookmarks:d,sessionNames:f,replaying:p=!1,catchUp:m,jumpToRecapRef:h,repinRef:g,reveal:_,frame:y,onOpenSubagent:b,emptyState:x,className:S}){let C=a===`terminal`,w=(0,v.useMemo)(()=>y?M3(e.items,y.parentToolUseId):e.items,[e.items,y]),T=(0,v.useMemo)(()=>y?e.items.find(e=>e.kind===`tool_call`&&e.id===y.parentToolUseId):void 0,[e.items,y]),E=$M[a],D=ure(e.status),O=!y&&m&&m.from>0&&m.from<e.items.length?m.from:void 0,k=(0,v.useMemo)(()=>O===void 0?void 0:PM(NM(e,O)),[e,O]),A=(0,v.useMemo)(()=>y&&T&&!w.some(e=>e.kind===`user`)?b2(T):void 0,[y,T,w]),j=(0,v.useMemo)(()=>{let e=(e,t)=>I3(w.slice(e,t),e,C);return O===void 0||!k?[...A?[{key:`brief`,text:A}]:[],...e(0,w.length)]:[...e(0,O),{key:`recap`,line:k},...e(O,w.length)]},[w,O,k,C,A]),M=(0,v.useMemo)(()=>e.skills?.map(e=>e.name),[e.skills]);return(0,H.jsx)(ZM,{value:a,children:(0,H.jsx)(I0,{value:i,children:(0,H.jsx)(MN,{names:M,children:(0,H.jsx)(NN,{names:f,children:(0,H.jsxs)(o8,{className:U(p&&`invisible`,S),children:[(0,H.jsx)(s8,{className:U(C&&`gap-0 p-0`),children:(0,H.jsxs)(fre,{active:C,fontSize:o,lineHeight:s,affordances:c,children:[y?T===void 0&&!p?(0,H.jsx)(`div`,{className:U(C?`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:w.length===0&&e.status!==`starting`?x===void 0?(0,H.jsx)(u8,{cwd:e.cwd,hasCommands:!!e.commands?.length,hasSkills:!!e.skills?.some(e=>e.enabled),canBrowseFiles:r}):x:null,y&&T===void 0&&!p?null:(0,H.jsx)(lre,{rows:j,boundary:O,since:m?.since,terminal:C,replaying:p,stickyPrompt:!y&&l,gap:E,fontSize:o,lineHeight:s,items:w,pendingApprovals:e.pendingApprovals,scrubber:u,bookmarks:y?void 0:d,affordances:c,fileUrl:t,attachmentUrl:n,hostImage:i,jumpToRecapRef:h,repinRef:g,reveal:y?void 0:_,frameParentId:y?.parentToolUseId,onOpenSubagent:y?void 0:b}),(y?T!==void 0&&w2(T,w):dre(e))?C?(0,H.jsxs)(H.Fragment,{children:[e.items.length>0?(0,H.jsx)(`div`,{className:`term-blank`,"aria-hidden":!0}):null,(0,H.jsx)(R4,{label:e.status===`starting`?`Starting…`:`Working…`,startedAt:D,tokens:e.contextUsage?.totalTokens})]}):(0,H.jsx)(l8,{label:e.status===`starting`?`Starting session…`:void 0}):null]})}),(0,H.jsx)(c8,{}),p?(0,H.jsx)(`div`,{"data-slot":`transcript-hold`,"aria-hidden":!0,className:`wd-hold-appear visible pointer-events-none absolute inset-0 overflow-hidden`,children:(0,H.jsx)(`div`,{className:U(`mx-auto w-full max-w-[var(--wd-transcript-max-width)]`,!C&&`px-4 py-4`),children:C?(0,H.jsx)(z4,{fontSize:o,lineHeight:s,affordances:!1,bleed:`1ch`,className:`term-transcript`,children:(0,H.jsx)(R4,{label:`Loading…`})}):(0,H.jsx)(l8,{label:`Loading session…`})})}):null]})})})})})}var mre=.02;function hre(e){let t=e.usageByModel??{},n=e.pricing,r=zk(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:Nk(e),usage:t,tokens:Fk(t),costUsd:Pk(e,n)?Rk(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,mre*Math.max(i??0,a??0));return{displayUsd:i??a,computedUsd:i,reportedUsd:a,breakdown:r,rows:o,unpricedShare:r.unpricedShare,showUnpricedWarning:r.unpricedShare>bk,unknownBasisModels:Ik(t),gapUsd:c?s:void 0}}function W5(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 G5({windows:e,now:t,className:n}){let r=W5(t===void 0),i=t??r;return(0,H.jsx)(`div`,{className:U(`flex flex-col gap-5`,n),children:e.map(e=>(0,H.jsx)(gre,{window:e,now:i},e.key))})}function gre({window:e,now:t}){let{key:n,info:r,updatedAt:i,inferredReset:a}=e,o=r.utilization??0,s=Qk(e,t),c=r.resetsAt===void 0?void 0:r.resetsAt*1e3,l=lN(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,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,H.jsx)(`span`,{className:`truncate text-body-sm text-fg-1`,children:cN(n)}),(0,H.jsxs)(`span`,{className:U(`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,H.jsxs)(`div`,{className:`relative mt-2 h-2 rounded-full bg-border`,children:[(0,H.jsx)(`div`,{className:U(`h-full rounded-full`,$4(o),s&&`opacity-40`),style:{width:`${Math.min(100,Math.max(2,o))}%`}}),d===void 0?null:(0,H.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,H.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3 text-label text-fg-4`,children:[c===void 0?null:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,H.jsx)(zx,{className:`size-3`}),` Resets in `,oN(c,t)]}),r.isUsingOverage?(0,H.jsx)(`span`,{className:`text-warning`,children:`overage`}):null,r.status===`rejected`?(0,H.jsx)(`span`,{className:`text-danger`,children:`limit reached`}):null,a?(0,H.jsx)(`span`,{children:`window reset · nothing reported since`}):null,i&&!a?(0,H.jsxs)(`span`,{className:U(s&&`text-warning`),children:[s?`last reported `:``,uN(i,t)]}):null]})]})}function K5(e){return e===`claude`?`Claude Code`:e}function q5({label:e,value:t,tone:n}){return(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,H.jsx)(`span`,{className:n===`muted`?`text-label text-fg-4`:`text-label text-fg-3`,children:e}),(0,H.jsx)(`span`,{className:`font-mono text-body-sm ${n===`muted`?`text-fg-4`:`text-fg-1`}`,children:t})]})}function _re({cost:e,engine:t}){let{breakdown:n,rows:r}=e;return r.length===0?(0,H.jsx)(q5,{label:`This session has cost`,value:nN(e.displayUsd)}):(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,H.jsx)(`span`,{className:`text-label text-fg-3`,children:`This session has cost`}),(0,H.jsx)(`span`,{className:`font-mono text-body text-fg-1`,children:nN(e.displayUsd)})]}),(0,H.jsxs)(`div`,{className:`space-y-1 border-t border-border pt-2`,children:[(0,H.jsx)(q5,{label:`input`,value:nN(n.input),tone:`muted`}),(0,H.jsx)(q5,{label:`output`,value:nN(n.output),tone:`muted`}),(0,H.jsx)(q5,{label:`cache write`,value:nN(n.cacheWrite),tone:`muted`}),(0,H.jsx)(q5,{label:`cache read`,value:nN(n.cacheRead),tone:`muted`})]}),(0,H.jsx)(`div`,{className:`space-y-1 border-t border-border pt-2`,children:r.map(e=>(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,H.jsx)(`span`,{className:`truncate text-label text-fg-4`,children:e.model}),(0,H.jsxs)(`span`,{className:`shrink-0 font-mono text-label text-fg-4`,children:[iN(e.tokens),` · `,e.costUsd===void 0?`no rate`:nN(e.costUsd)]})]},e.model))}),e.showUnpricedWarning?(0,H.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,H.jsxs)(`p`,{className:`text-label text-warning`,children:[K5(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,H.jsxs)(`p`,{className:`text-label text-fg-4`,children:[K5(t),` reports `,nN(e.reportedUsd),` for the same tokens.`]})]})}function vre({spend:e}){let{subscription:t}=e;return(0,H.jsxs)(`div`,{className:`mt-4 space-y-1 border-t border-border pt-3`,children:[(0,H.jsx)(q5,{label:`This profile, last 7 days`,value:nN(e.weekUsd)}),(0,H.jsx)(q5,{label:`Last 30 days`,value:nN(e.monthUsd),tone:`muted`}),t?(0,H.jsxs)(`p`,{className:`pt-1 text-label text-fg-4`,children:[yre(t.ratio),` the `,nN(t.weeklyShareUsd),` weekly share of your`,` `,nN(t.monthlyUsd),` a month. A subscription is a flat fee, so this is leverage, not a bill.`]}):null]})}function yre(e){return e>=10?`${Math.round(e)}x`:`${e.toFixed(1)}x`}function bre({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=W5(l),p=hre({costUsd:i,totalCostUsd:r,usageByModel:a,pricing:o}),m=Mk(f);return(0,H.jsx)(aT,{open:l,onOpenChange:u,children:(0,H.jsxs)(oT,{className:d,children:[(0,H.jsx)(sT,{title:`Usage`,description:K5(n),actions:t?(0,H.jsx)(po,{variant:`accent`,className:`mt-0.5 shrink-0 capitalize`,children:t}):null}),(0,H.jsxs)(cT,{children:[e.length===0?(0,H.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,H.jsx)(G5,{windows:e,now:f}),(0,H.jsx)(`div`,{className:`mt-5 border-t border-border pt-3`,children:(0,H.jsx)(_re,{cost:p,engine:n})}),s?(0,H.jsx)(vre,{spend:s}):null,(0,H.jsx)(`p`,{className:`mt-3 text-label text-fg-4`,children:m?`${yk} ${m}`:yk}),c?(0,H.jsxs)(`p`,{className:`mt-2 text-label text-fg-4`,children:[`Updated `,uN(c,f)]}):null]})]})})}var xre=[`button`,`a`,`input`,`textarea`,`select`,`summary`,`img`,`[contenteditable="true"]`,`[role="button"]`,`[role="menuitem"]`,`[role="checkbox"]`,`[role="radio"]`,`[role="tab"]`].join(`,`),Sre=[{panel:`context`,label:`Context`,Icon:dee},{panel:`usage`,label:`Usage`,Icon:Cy},{panel:`info`,label:`Session info`,Icon:Uy},{panel:`mcp`,label:`MCP servers`,Icon:_x},{panel:`skills`,label:`Skills`,Icon:lS},{panel:`files`,label:`Project files`,Icon:_y}];function Cre({client:e,sessionId:t,header:n,panelSurface:r=`internal`,statusSurface:i=`internal`,statusPlacement:a=`top`,onOpenPanel:o,onVitals:s,transcriptVariant:c=`cards`,transcriptFont:l=`sans`,affordances:u,terminalMetrics:d,scrubber:f=!1,bookmarks:p,peerMentions:m=!0,onToggleBookmark:h,reveal:g,subagents:_,shells:y,openSubagent:b,onSubagentChange:x,openShell:S,onShellChange:C,stickyPrompt:w=!1,controlsSurface:T=`internal`,onControls:E,focusComposerOnClick:D=!1,unseen:O,readOnly:k=!1,approvalPrompts:A,toolHost:j,clientTools:M,cacheTranscript:N,emptyState:P,onLinkClick:F,onOpenFile:I,fontSize:L,className:R}){let z={fontSize:d?.fontSize??L,lineHeight:d?.lineHeight??(L===void 0?void 0:Math.round(18/13*L))},ee=r===`external`,te=i===`external`,ne=T===`status`&&!te,re=T===`external`||ne,[ie,B]=(0,v.useState)(void 0),[ae,oe]=(0,v.useState)(),{state:V,connection:se,replaying:ce,protocolMismatch:le,shell:ue,pricing:de,models:fe,effectiveModel:pe,handle:me,send:he,runShell:ge,approve:_e,deny:ve,interrupt:ye,clearContext:be,setModel:xe,setPermissionMode:Se,reconnectNow:Ce,loadFullResult:we,loadShellOutput:Te,verifyShell:Ee,killShell:De,setShellAgentWrite:Oe}=dj(e,t,{onProtocolError:B,cacheTranscript:N}),{shellId:ke,enterShell:Ae,leaveShell:je,returnReveal:Me,shell:Ne,label:Pe}=J3({sessionId:t,items:V.items,session:V.session,shells:y,reveal:g,openShell:S,onShellChange:C}),Fe=V.session?.shellAgentWrite===void 0?void 0:Oe,Ie=(0,v.useMemo)(()=>({loadOutput:Te,verify:Ee,kill:De,open:Ae,agentWrite:Fe}),[Te,Ee,De,Ae,Fe]);(0,v.useEffect)(()=>B(void 0),[t]);let{subagentId:Le,enterSubagent:Re,leaveSubagent:ze,returnReveal:Be,frameItems:Ve,task:He,fallbackLabel:Ue}=V3({sessionId:t,items:V.items,session:V.session,reveal:g,openSubagent:b,onSubagentChange:x}),We=(0,v.useMemo)(()=>Be&&Me?Be.nonce>=Me.nonce?Be:Me:Be??Me,[Be,Me]),{mark:Ge,dismiss:Ke}=M6(t,O),qe=Ge?Math.max(0,V.items.length-Ge.itemCount):0,Je=(0,v.useCallback)(e=>{ee?o?.(e):oe(e)},[ee,o]);(0,v.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&Ce()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Ce]),MM(me,j===!1?{enabled:!1}:M?{...j,clientTools:{...j?.clientTools,...M}}:j);let Ye=c===`terminal`,Xe=V.capabilities,{usage:Ze,spend:Qe}=_M(e,V.session?.profile,{enabled:Xe.rateLimits}),$e=(0,v.useMemo)(()=>Xk({rateLimits:V.rateLimits,updatedAt:V.rateLimitsUpdatedAt},Ze),[V.rateLimits,V.rateLimitsUpdatedAt,Ze]),et=(0,v.useMemo)(()=>Object.keys($e).length>0?eA($e):void 0,[$e]),tt=(0,v.useMemo)(()=>{let e=Object.values($e).map(e=>e.updatedAt);return e.length>0?Math.max(...e):void 0},[$e]),nt=(0,v.useMemo)(()=>dk({checklist:V.checklist,subagents:_??V.session?.subagents}),[V.checklist,_,V.session?.subagents]),rt=fe.length>0,it=(0,v.useMemo)(()=>YM({capabilities:Xe,hasModels:rt,setModel:xe,setPermissionMode:Se,clearContext:be,openPanel:Je}),[Xe,rt,Je,be,xe,Se]),at=(0,v.useMemo)(()=>JM(HM({commands:Xe.slashCommands?V.commands:void 0,clientCommands:it,skills:Xe.skillsList?V.skills:void 0})),[Xe.slashCommands,Xe.skillsList,V.commands,V.skills,it]),ot=(0,v.useRef)(s);ot.current=s;let st=pe??V.model,ct=(0,v.useMemo)(()=>T3(Xe.permissionModes,V.session?.canBypassPermissions),[Xe.permissionModes,V.session?.canBypassPermissions]),lt={status:V.status,connection:se,engine:V.engine,capabilities:V.capabilities,model:st,models:fe,permissionMode:V.permissionMode,permissionModes:ct,skills:V.skills,composerCommands:at,cwd:V.cwd,contextUsage:V.contextUsage,tasks:nt,rateLimits:et,rateLimitsUpdatedAt:tt,itemCount:V.items.length,totalCostUsd:V.totalCostUsd},ut=(0,v.useRef)(void 0);(0,v.useEffect)(()=>{ut.current&&Tre(ut.current,lt)||(ut.current=lt,ot.current?.(lt))});let dt=(0,v.useRef)(E);dt.current=E;let ft=(0,v.useRef)({setModel:xe,setPermissionMode:Se,interrupt:ye});ft.current={setModel:xe,setPermissionMode:Se,interrupt:ye};let pt=(0,v.useRef)({setModel:e=>ft.current.setModel(e),setPermissionMode:e=>ft.current.setPermissionMode(e),interrupt:()=>ft.current.interrupt(),focusComposer:()=>Et.current?.focus(),insertComposerText:e=>Et.current?.insertText(e)});(0,v.useEffect)(()=>{let e=dt.current;return e?.(pt.current),()=>e?.(void 0)},[t]);let mt=(0,v.useMemo)(()=>new Set(p??[]),[p]),ht=(0,v.useMemo)(()=>h?{has:e=>mt.has(e),toggle:h}:void 0,[mt,h]),gt=V.status===`running`||V.status===`awaiting_approval`,_t=V.status===`failed`||V.status===`closed`,vt=Aj(e,t,{capabilities:Xe,engine:V.engine}),yt=Hj(e,V.cwd),bt=qj(e,t,m),xt=gM(e,t),St=(0,v.useCallback)((e,t)=>yt.search(e,{...t,limit:8}),[yt.search]),Ct=(0,v.useMemo)(()=>$k($e),[$e]),wt=P6(e,t,V.producedFiles),Tt=z0(e,t),Et=(0,v.useRef)(null),Dt=(0,v.useRef)(null),Ot=(0,v.useRef)(null),kt=(e,t)=>{if(t.length===0){let t=qM(e,it);if(t&&t.command.run(t.args))return}Ke(),Ot.current?.(),he(e,t)},At={context:Xe.contextUsage,usage:Xe.rateLimits,info:!0,mcp:Xe.mcpStatus,skills:Xe.skillsList,files:yt.available},jt=(0,H.jsxs)(Mw,{children:[(0,H.jsx)(Nw,{render:(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Session actions`,children:(0,H.jsx)(qv,{className:`size-4`})})}),(0,H.jsx)(Pw,{children:Sre.filter(e=>At[e.panel]).map(({panel:e,label:t,Icon:n})=>(0,H.jsxs)(Fw,{onClick:()=>Je(e),children:[(0,H.jsx)(n,{className:`size-3.5 text-fg-3`}),` `,t]},e))})]}),Mt=ee?null:jt,Nt=e=>({open:ae===e,onOpenChange:t=>oe(t?e:void 0)}),Pt=typeof n==`function`,Ft=(0,H.jsxs)(H.Fragment,{children:[fe.length?(0,H.jsx)(S3,{models:fe,model:pe,onModelChange:xe,disabled:_t,className:ne?`h-5`:void 0}):null,V.permissionMode?(0,H.jsx)(E3,{mode:V.permissionMode,onModeChange:Se,modes:Xe.permissionModes,canBypass:V.session?.canBypassPermissions,disabled:_t,className:ne?`h-5`:void 0}):null]}),It=te?null:(0,H.jsx)(K6,{state:V,rateLimits:et,connection:se,placement:a,controls:ne&&!k?Ft:void 0,onOpenStatus:ee&&!o?void 0:()=>Je(`info`),onOpenContext:ee&&!o?void 0:()=>Je(`context`),onOpenUsage:ee&&!o?void 0:()=>Je(`usage`),actions:Pt?void 0:Mt}),Lt=(0,v.useMemo)(()=>I?{cwd:V.cwd,open:I}:void 0,[I,V.cwd]),Rt=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!F)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&&F(n)&&(e.preventDefault(),e.stopPropagation())};return e.addEventListener(`click`,t,!0),()=>e.removeEventListener(`click`,t,!0)},[F]),(0,H.jsx)(j6,{variant:c,fileLinks:Lt,loadFullResult:we,shellActions:Ie,toolTitles:V.toolTitles,resultImages:Tt,children:(0,H.jsx)(`div`,{ref:Rt,"data-slot":`session-panel`,"data-agent-font":l,onClick:e=>{D&&!k&&(e.target?.closest(xre)||window.getSelection()?.isCollapsed!==!1&&Et.current?.focus())},className:U(`relative flex h-full min-h-0 flex-col overflow-hidden bg-bg`,R),style:L===void 0?void 0:{"--wd-font-size":`${Math.round(L)}px`},children:(0,H.jsxs)(E0,{children:[Pt?n({actions:Mt}):n,a===`top`?It:null,le===void 0?null:(0,H.jsxs)(J5,{level:`warning`,children:[`Server speaks protocol v`,le,`, this build renders v`,1,`. Some events may not render.`]}),ie?(0,H.jsx)(J5,{level:`error`,onDismiss:()=>B(void 0),children:ie}):null,ke===void 0?null:(0,H.jsx)(H3,{shell:Ne,label:Pe,onBack:je,onKill:()=>void De(ke),onAgentWrite:Fe?e=>void Fe(ke,e):void 0,terminal:Ye,...z}),ke===void 0&&Le!==void 0?(0,H.jsx)(A3,{task:He,items:Ve,label:Ue,onBack:ze,terminal:Ye,...z}):null,ke===void 0?(0,H.jsx)(GN,{value:ht,children:(0,H.jsx)(pre,{state:V,fileUrl:t?n=>e.sessionFileUrl(t,n):void 0,attachmentUrl:t?n=>e.attachmentUrl(t,n):void 0,canBrowseFiles:yt.available,sessionNames:bt.names,hostImage:wt,variant:c,...z,affordances:u,stickyPrompt:w,scrubber:f,bookmarks:p,replaying:ce,catchUp:Ge&&qe>0?{from:Ge.itemCount,since:Ge.since}:void 0,reveal:We??g,frame:Le===void 0?void 0:{parentToolUseId:Le},onOpenSubagent:Re,emptyState:P,jumpToRecapRef:Dt,repinRef:Ot},Le??`session`)}):(0,H.jsx)(U3,{handle:me,shellId:ke,fontSize:z.fontSize},ke),Ge&&qe>0&&!ce&&Le===void 0&&ke===void 0?(0,H.jsx)(wre,{count:qe,since:Ge.since,terminal:Ye,onJump:()=>Dt.current?.(),onDismiss:Ke}):null,!k&&Xe.interactiveApprovals&&V.pendingApprovals.length>0?(0,H.jsx)(k6,{requests:V.pendingApprovals,terminal:Ye,...z,affordances:u,hostPrompts:A,onApprove:_e,onDeny:ve}):null,k||Le!==void 0||ke!==void 0?null:(0,H.jsx)(H.Fragment,{children:(0,H.jsx)(H4,{ref:Et,onSend:kt,onInterrupt:ye,busy:gt,disabled:_t||!t,commands:Xe.slashCommands?V.commands:void 0,skills:Xe.skillsList?V.skills:void 0,clientCommands:it,attachments:vt,draft:xt,onSearchFiles:yt.available?St:void 0,peers:bt.peers,onShellCommand:ue?ge:void 0,layout:re?`inline`:`stacked`,toolbar:re?void 0:Ft,...z,affordances:u})}),a===`bottom`?It:null,ee?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(L6,{state:V,client:e,sessionId:t,...Nt(`info`)}),(0,H.jsx)(e3,{usage:V.contextUsage,engine:V.engine??`claude`,...Nt(`context`)}),(0,H.jsx)(bre,{rateLimits:Ct,subscriptionType:V.subscriptionType,engine:V.engine??`claude`,totalCostUsd:V.totalCostUsd,costUsd:V.costUsd,usageByModel:V.usageByModel,pricing:de,spend:Qe,updatedAt:tt,...Nt(`usage`)}),(0,H.jsx)(a3,{client:e,sessionId:t,canManageServers:Xe.mcpServerActions,...Nt(`mcp`)}),(0,H.jsx)(m3,{skills:V.skills,...Nt(`skills`),onUse:e=>Et.current?.insertText(VM(e))}),(0,H.jsx)(r3,{client:e,cwd:V.cwd,...Nt(`files`)})]})]})})})}function wre({count:e,since:t,terminal:n,onJump:r,onDismiss:i}){return(0,H.jsx)(`div`,{className:`px-3 pb-1`,children:(0,H.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,H.jsx)(`span`,{"aria-hidden":!0,className:U(`select-none`,n?`text-fg-3`:`text-accent`),children:`※`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e,` new `,e===1?`row`:`rows`,t===void 0?``:` since you were last here`]}),(0,H.jsx)(`button`,{type:`button`,onClick:r,className:`shrink-0 underline-offset-2 hover:text-fg-1 hover:underline`,children:`jump`}),(0,H.jsx)(`button`,{type:`button`,onClick:i,className:`shrink-0 underline-offset-2 hover:text-fg-1 hover:underline`,children:`dismiss`})]})})}function Tre(e,t){return Object.keys(t).every(n=>Object.is(e[n],t[n]))}function J5({level:e,onDismiss:t,children:n}){return(0,H.jsx)(`div`,{className:`px-3 pt-2`,children:(0,H.jsxs)(`div`,{role:`alert`,className:U(`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,H.jsx)(US,{className:`mt-0.5 size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:n}),t?(0,H.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Dismiss`,className:`shrink-0 opacity-70 transition-opacity hover:opacity-100`,children:(0,H.jsx)(hC,{className:`size-3.5`})}):null]})})}var Y5=`[^\\s:'"\`()\\[\\]{}<>|]+`,Ere=RegExp(`(?:^|[\\s'"\`([{<@,])((?:\\.\\.?)?(?:/${Y5})+|[^\\s:'"\`()\\[\\]{}<>|@,]+(?:/${Y5})+)(?::(\\d+))?`),Dre=/^([\w.@-]+\.[A-Za-z0-9]{1,10})(?::(\d+))?$/,Ore=/[.,;:!?)\]}'"`]+$/,kre=/\.[A-Za-z0-9]{1,10}$/;function Are(e,t=!1){let n=e??``,r=Ere.exec(n);if(!r)return t?jre(n):void 0;let i=r[1].replace(Ore,``);if(i.includes(`/`)&&!i.endsWith(`/`)&&(i.startsWith(`/`)||i.startsWith(`./`)||i.startsWith(`../`)||kre.test(i)))return{path:i,line:r[2]?Number(r[2]):void 0,length:i.length+(r[2]?r[2].length+1:0)}}function jre(e){let t=Dre.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 X5=`wd-path-link`,Mre=.6;function Z5(e){if(!e)return;let t=e.closest(`code`)!==null,n=e.textContent?.trim()??``,r=Are(n,t);if(r&&!(!t&&r.length<n.length*Mre))return{path:r.path,line:r.line}}function Nre({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(X5),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=Z5(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)&&Z5(t)&&(o=t,t.classList.add(X5)))},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 Pre(e,t){return s0(e,t)?.path??e}var Fre={anchor:see,atom:l_,beaker:p_,bike:__,binary:y_,blocks:x_,bot:T_,box:D_,brain:k_,briefcase:j_,brush:N_,bug:F_,"building-2":L_,cable:z_,camera:U_,car:G_,cat:q_,"circuit-board":hv,cloud:xv,code:Cv,coffee:Tv,cog:Dv,compass:kv,container:jv,cpu:Fv,"credit-card":Lv,database:zv,diamond:Vv,dog:Uv,feather:Zv,film:sy,flame:ly,"flask-conical":dy,folder:yy,"gamepad-2":mee,gauge:Cy,gem:hee,ghost:gee,gift:_ee,"git-branch":vee,globe:ky,"graduation-cap":yee,hammer:bee,hexagon:Fy,house:Ly,image:Vy,key:Gy,landmark:qy,laptop:Yy,layers:Zy,leaf:$y,library:tb,lightbulb:rb,lock:pb,mail:hb,map:_b,"message-circle":Tb,mic:kb,monitor:Nb,moon:Fb,mountain:Lb,music:zb,network:Vb,newspaper:Ub,notebook:Gb,orbit:qb,package:Yb,palette:Zb,"pen-tool":ax,phone:dx,"piggy-bank":px,plane:hx,plug:_x,puzzle:Tx,radar:Dx,radio:kx,receipt:jx,rocket:Fx,ruler:xee,satellite:See,scale:wee,scissors:Tee,server:Qx,shield:Oee,ship:kee,"shopping-cart":Aee,signal:jee,smartphone:sS,sparkles:lS,sprout:dS,square:xS,star:CS,sun:TS,table:DS,tag:kS,target:NS,telescope:jS,terminal:FS,"test-tube":LS,"tree-pine":VS,trophy:GS,truck:qS,umbrella:YS,users:$S,wallet:tC,wand:rC,waves:aC,webhook:sC,wifi:dC,wrench:pC,zap:_C};function Q5({icon:e,src:t,name:n,className:r}){if(!e)return null;if(e.type===`image`)return t?(0,H.jsx)(`img`,{src:t,alt:``,"aria-hidden":!0,title:n,className:U(`inline-block size-3 shrink-0 object-contain`,r)}):null;let i=Fre[e.name]??yy;return(0,H.jsx)(i,{className:U(`inline-block size-3 shrink-0`,r)})}var Ire=[{value:`all`,label:`All`},{value:`active`,label:`Active`},{value:`none`,label:`Hide`}];function $5({config:e,onConfigChange:t,rows:n,scope:r,gateways:i,className:a}){let o=(0,v.useMemo)(()=>IO(n),[n]),s=(0,v.useMemo)(()=>LO(n),[n]),c=(0,v.useMemo)(()=>{if(i)return i;let e=new Map;for(let t of n)e.set(t.hostId,t.hostName);return[...e].map(([e,t])=>({id:e,name:t}))},[n,i]),l=n=>t({...e,...n});return(0,H.jsxs)(`div`,{"data-slot":`session-filters`,className:U(`flex flex-col gap-3`,a),children:[(0,H.jsxs)(t7,{title:`Filter`,children:[r?(0,H.jsx)(n7,{label:`Scope`,children:(0,H.jsx)(TC,{className:`w-full min-w-0`,label:`Scope`,value:e.scoped?`scoped`:`all`,options:[{value:`scoped`,label:r.label},{value:`all`,label:`All folders`}],onChange:e=>l({scoped:e===`scoped`})})}):null,(0,H.jsx)(n7,{label:`State`,children:(0,H.jsx)(r7,{label:`State`,value:e.states,options:OO.map(e=>({value:e,label:kO[e]})),onChange:e=>l({states:e})})}),o.length>1?(0,H.jsx)(n7,{label:`Engine`,children:(0,H.jsx)(r7,{label:`Engine`,value:e.adapters,options:o.map(e=>({value:e,label:e})),onChange:e=>l({adapters:e})})}):null,c.length>1?(0,H.jsx)(n7,{label:`Gateway`,children:(0,H.jsx)(r7,{label:`Gateway`,value:e.gateways,options:c.map(e=>({value:e.id,label:e.name})),onChange:e=>l({gateways:e})})}):null,s.length>1?(0,H.jsx)(n7,{label:`Project`,children:(0,H.jsx)(r7,{label:`Project`,value:e.projects??[],options:s.map(e=>({value:e.key,label:e.label})),onChange:e=>l({projects:e})})}):null]}),(0,H.jsxs)(t7,{title:`Layout`,children:[(0,H.jsx)(n7,{label:`Group`,children:(0,H.jsx)(TC,{className:`w-full min-w-0`,label:`Group`,value:e.groupBy,options:[{value:`none`,label:`No grouping`},{value:`state`,label:`By state`},{value:`adapter`,label:`By engine`},...s.length>1?[{value:`project`,label:`By project`}]:[],...c.length>1?[{value:`gateway`,label:`By gateway`}]:[]],onChange:e=>l({groupBy:e})})}),(0,H.jsx)(n7,{label:`Sort`,children:(0,H.jsx)(TC,{className:`w-full min-w-0`,label:`Sort`,value:e.sortBy,options:[{value:`recent`,label:`Recent`},{value:`name`,label:`Name`},{value:`state`,label:`State`},...s.length>1?[{value:`project`,label:`Project`}]:[],...c.length>1?[{value:`gateway`,label:`Gateway`}]:[]],onChange:e=>l({sortBy:e})})})]}),(0,H.jsxs)(t7,{title:`Show under each session`,children:[(0,H.jsx)(n7,{label:`Agents`,children:(0,H.jsx)(e7,{label:`Agents`,value:e.subagents,onChange:e=>l({subagents:e})})}),(0,H.jsx)(n7,{label:`Shells`,children:(0,H.jsx)(e7,{label:`Shells`,value:e.shells??`active`,onChange:e=>l({shells:e})})}),(0,H.jsx)(n7,{label:`Tasks`,children:(0,H.jsx)(e7,{label:`Tasks`,value:e.tasks??`active`,onChange:e=>l({tasks:e})})})]})]})}function Lre({open:e,onOpenChange:t,className:n,...r}){let i=ak(r.config),a=i>0||ok(r.config);return(0,H.jsxs)(nT,{open:e,onOpenChange:t,children:[(0,H.jsx)(rT,{render:(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":i>0?`Filters (${i} active)`:`Filters`,title:i>0?`${i} filter${i===1?``:`s`} active`:`Filters`,className:n,children:(0,H.jsx)(pee,{className:U(`size-3.5`,a&&`fill-current text-fg-1`)})})}),(0,H.jsx)(iT,{className:`w-80`,children:(0,H.jsx)($5,{...r})})]})}function e7({label:e,value:t,onChange:n}){return(0,H.jsx)(`div`,{role:`radiogroup`,"aria-label":e,className:`flex w-full rounded-md border border-border p-px`,children:Ire.map(e=>(0,H.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t,onClick:()=>n(e.value),className:U(`min-w-0 flex-1 truncate rounded-[4px] px-1.5 py-0.5 text-label outline-none transition-colors`,`focus-visible:ring-2 focus-visible:ring-ring`,e.value===t?`bg-row-selected text-fg-1`:`text-fg-3 hover:bg-row-hover hover:text-fg-1`),children:e.label},e.value))})}function t7({title:e,children:t}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`div`,{className:`text-label font-medium uppercase tracking-wide text-fg-4`,children:e}),t]})}function n7({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{"aria-hidden":!0,className:`w-16 shrink-0 truncate text-label text-fg-3`,children:e}),(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:t})]})}function r7({label:e,value:t,options:n,onChange:r}){return(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsxs)(yC,{multiple:!0,value:t,onValueChange:e=>r(e),children:[(0,H.jsx)(SC,{"aria-label":e,className:`min-w-0 flex-1`,children:(0,H.jsx)(bC,{children:t.length===0?`All`:t.length===1?n.find(e=>e.value===t[0])?.label??`All`:`${t.length} selected`})}),(0,H.jsx)(CC,{children:n.map(e=>(0,H.jsx)(wC,{value:e.value,children:(0,H.jsx)(xC,{children:e.label})},e.value))})]}),t.length>0?(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clear ${e}`,onClick:()=>r([]),children:(0,H.jsx)(hC,{className:`size-3 text-fg-4`})}):null]})}function i7({usage:e,engine:t,size:n=11,className:r}){if(e===void 0)return null;let i=X4(t),a=`Context ${e.percentage.toFixed(0)}% · ${iN(e.totalTokens)} / ${iN(e.maxTokens)}`,o=U(`shrink-0 leading-none`,Q4(e.percentage),r),s=(0,H.jsx)(SE,{value:e.percentage,size:n,strokeWidth:2});return i?(0,H.jsx)(PT,{render:(0,H.jsx)(`span`,{className:o}),content:(0,H.jsxs)(`div`,{className:`flex max-w-64 flex-col gap-1 py-0.5`,children:[(0,H.jsx)(`span`,{className:`font-mono text-fg-2`,children:a}),(0,H.jsx)(`span`,{className:`text-fg-3`,children:i.summary}),(0,H.jsx)(`span`,{className:`text-fg-3`,children:i.hint})]}),children:s}):(0,H.jsx)(`span`,{title:a,className:o,children:s})}var Rre={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 a7(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 zre={claude:`text-vendor-claude`,codex:`text-vendor-openai`},Bre={claude:`text-vendor-claude`};function Vre(e,t){return zre[a7(e,t)??``]??`text-fg-3`}function Hre(e,t){return Bre[a7(e,t)??``]??`text-fg-3`}function o7({engine:e,model:t,className:n}){let r=Rre[a7(e,t)??``];return r?(0,H.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,fillRule:`evenodd`,role:`img`,"aria-label":r.title,className:U(`size-3 shrink-0 text-fg-3`,n),children:[(0,H.jsx)(`title`,{children:r.title}),(0,H.jsx)(`path`,{d:r.d})]}):(0,H.jsx)(`span`,{"aria-hidden":!0,title:e,className:U(`shrink-0 text-fg-3`,n),children:`·`})}function s7({row:e,className:t}){let{info:n}=e,r=U(`size-4 shrink-0`,t);if(e.state===`attention`)return(0,H.jsx)(h_,{className:U(r,`animate-pulse text-warning`)});if(e.state===`working`)return(0,H.jsx)(_E,{className:U(r,`text-info`)});switch(n.status){case`failed`:return(0,H.jsx)(av,{className:U(r,`text-danger`)});case`closed`:return(0,H.jsx)(dv,{className:U(r,`text-fg-4`)});case`parked`:return(0,H.jsx)(lv,{className:U(r,`text-fg-3`)});default:return(0,H.jsx)(Fb,{className:U(r,`text-fg-4`)})}}function Ure(e,t,n=`all`,r,i){let a=MO(e,n).filter(NO).map(e=>({key:e.toolUseId,kind:`agent`,label:PO(e),noun:`agent`,state:Kre(e.status),detail:e.toolCount>0?String(e.toolCount):void 0,title:`${PO(e)} · ${e.toolCount} tool${e.toolCount===1?``:`s`}`,onSelect:()=>t(e.toolUseId)})),o=i===void 0?[]:mk(e,i.show).map(e=>Wre(e,i));if(r===void 0)return[...a,...o];let s=e.shellAgentWrite!==void 0,c=WO(e,r.show??`active`,r.now).map(e=>Gre(e,r,s));return[...a,...o,...c]}function Wre(e,t){let n=e.source===`checklist`&&e.state===`running`&&!t.live,r=e.toolUseId;return{key:e.key,kind:`task`,label:e.label,noun:`task`,state:n?`pending`:e.state,detail:e.detail,title:n?`${e.label} · left in progress`:e.label,onSelect:()=>t.onSelect(e),onKill:e.stoppable&&r!==void 0&&t.onStop?()=>t.onStop?.(r):void 0,killLabel:`Stop this task`}}function Gre(e,t,n){let r=r4(e),i=e.status===`running`;return{key:e.id,kind:`shell`,label:Q2(e),noun:`shell`,state:n4(e)?`failed`:i?`running`:`done`,detail:i?e.agentWrite===!0?Y2:void 0:r,title:`${$2(e)} · ${r}`,onSelect:()=>t.onSelect(e.id),onKill:i&&t.onKill?()=>t.onKill?.(e.id):void 0,killLabel:`Kill this shell`,agentWrite:n&&t.onAgentWrite&&X2(e)?{granted:e.agentWrite===!0,label:Z2(e),toggle:()=>t.onAgentWrite?.(e.id,e.agentWrite!==!0)}:void 0}}function Kre(e){switch(e){case`running`:return`running`;case`failed`:return`failed`;default:return`done`}}function qre({step:e,active:t=!1,onSelect:n}){let r=e.state===`failed`?`text-danger`:e.kind===`shell`?`text-[var(--wd-shell-accent)]`:e.kind===`task`?e.state===`pending`?`text-fg-4`:`text-fg-2`:`text-success`;return(0,H.jsxs)(`div`,{className:U(`flex w-full items-center rounded-[4px] pr-1.5`,t?`bg-row-selected`:`hover:bg-row-active`,r),children:[(0,H.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,H.jsx)(Jre,{step:e}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.detail?(0,H.jsx)(`span`,{className:`shrink-0 tabular-nums text-fg-4`,children:e.detail}):null,e.kind===`agent`?(0,H.jsx)(uee,{className:`size-3.5 shrink-0 text-fg-4`}):null]}),e.agentWrite?(0,H.jsx)(`button`,{type:`button`,"aria-label":e.agentWrite.label,"aria-pressed":e.agentWrite.granted,title:e.agentWrite.label,onClick:t=>{t.stopPropagation(),e.agentWrite?.toggle()},className:U(`shrink-0 px-1 text-micro leading-none outline-none`,e.agentWrite.granted?`text-warning`:`text-fg-4 hover:text-fg-1`),children:(0,H.jsx)(QN,{granted:e.agentWrite.granted,className:`size-3.5`})}):null,e.onKill?(0,H.jsx)(`button`,{type:`button`,"aria-label":`${e.kind===`task`?`Stop`:`Kill`} ${e.label}`,title:e.killLabel,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 Jre({step:e}){if(e.kind===`shell`)return(0,H.jsx)(`span`,{className:`w-[11px] shrink-0 text-center leading-none`,children:`$`});switch(e.state){case`running`:return(0,H.jsx)(_E,{className:`size-[11px] shrink-0`});case`failed`:return(0,H.jsx)(av,{className:`size-[11px] shrink-0`});case`pending`:return(0,H.jsx)(pv,{className:`size-[11px] shrink-0`});default:return(0,H.jsx)(X_,{className:`size-[11px] shrink-0`})}}var c7={meta:!1,ctrl:!1,alt:!1};function Yre({row:e,active:t=!1,activeStepKey:n,showGateway:r,showProject:i=!0,projectIcons:a,subagents:o=`active`,shells:s=`active`,tasks:c=`active`,onSelect:l,onSelectSubagent:u,onSelectTask:d,onStopTask:f,onSelectShell:p,onKillShell:m,onShellAgentWrite:h,now:g,onRename:_,renameOn:y=`doubleClick`,editing:b,onEditingChange:x,actions:S,className:C}){let{info:w}=e,[T,E]=(0,v.useState)(!1),D=b??T,O=e=>{E(e),x?.(e)},k=w.engine??`claude`,A=i?BO(e):HO(e),j=i?VO(e):void 0,M=i?w.project?.icon:void 0,N=M?.type===`image`?a?.[M.hash]:void 0,P=nN(w.costUsd??w.totalCostUsd),F=[r?e.hostName:void 0,w.profile?`@${w.profile}`:void 0,P===`-`?void 0:P].filter(e=>!!e),I=pN(w.model),L=[];I&&L.push((0,H.jsx)(`span`,{className:Hre(k,w.model),children:I},`model`)),A!==void 0&&L.push((0,H.jsxs)(`span`,{title:j,children:[(0,H.jsx)(Q5,{icon:M,src:N,name:j,className:`mr-1.5 size-4 align-[-0.3em]`}),A]},`project`));for(let e of F)L.push((0,H.jsx)(`span`,{children:e},e));let R=Ure(w,e=>u?u(e):l?.(c7),o,{now:g??Date.now(),show:s,onSelect:e=>p?p(e):l?.(c7),onKill:m,onAgentWrite:h},{show:c,live:w.status===`running`||w.status===`starting`||w.status===`awaiting_approval`,onSelect:e=>d?d(e):l?.(c7),onStop:f}),z=R.some(e=>e.key===n);return(0,H.jsxs)(`div`,{"data-slot":`session-item`,"data-active":t||void 0,role:`button`,tabIndex:0,onClick:e=>{e.detail>1||D||l?.({meta:e.metaKey,ctrl:e.ctrlKey,alt:e.altKey})},onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l?.({meta:e.metaKey,ctrl:e.ctrlKey,alt:e.altKey}))},className:U(`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`,z?`bg-row-selected-weak`:t?`bg-row-selected`:`hover:bg-row-hover`,C),children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 py-0.5 pr-0.5 pl-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex h-5 items-center gap-1.5 overflow-hidden`,children:[(0,H.jsx)(l7,{children:(0,H.jsx)(s7,{row:e})}),D&&_?(0,H.jsx)(Xre,{initial:w.title??``,onCommit:e=>{O(!1),e!==(w.title??``)&&_(e)},onCancel:()=>O(!1)}):(0,H.jsx)(`span`,{onDoubleClick:_&&y===`doubleClick`?e=>{e.stopPropagation(),O(!0)}:void 0,className:`min-w-0 flex-1 truncate text-body-sm font-medium tracking-[-0.005em] text-fg-1`,children:RO(w)}),e.unseen>0?(0,H.jsx)(`span`,{title:`${e.unseen} new message${e.unseen===1?``:`s`}`,className:U(`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,H.jsx)(i7,{usage:w.contextUsage,engine:k,size:16,className:`p-0.5`})]}),(0,H.jsxs)(`div`,{className:`flex h-5 items-center gap-1.5 overflow-hidden text-body-sm tracking-[-0.005em]`,children:[(0,H.jsx)(l7,{children:(0,H.jsx)(o7,{engine:k,model:w.model,className:U(`size-4`,Vre(k,w.model))})}),(0,H.jsx)(`span`,{className:`min-w-0 truncate text-fg-4`,children:L.map((e,t)=>(0,H.jsxs)(v.Fragment,{children:[t>0?` · `:``,e]},t))}),(0,H.jsxs)(`span`,{className:`shrink-0 text-fg-4`,children:[L.length>0?`· `:``,sN(w.lastActivityAt??w.createdAt)]}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1`}),S]})]}),R.length>0?(0,H.jsx)(`div`,{className:`flex flex-col`,children:R.map(e=>(0,H.jsx)(qre,{step:e,active:e.key===n,onSelect:e.onSelect},e.key))}):null]})}function l7({children:e}){return(0,H.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:e})}function Xre({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,H.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:U(`-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 Zre(e){return U(`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 Qre({rows:e,config:t,onConfigChange:n,scope:r,activeId:i,activeSubagentId:a,activeShellId:o,now:s,isActive:c=e=>e.info.id===i,rowActions:l,gatewayCount:u,showSubset:d=!0,onSelect:f,onDelete:p,onRename:m,onClearContext:h,onSelectSubagent:g,onSelectTask:_,onStopTask:y,onSelectShell:b,onKillShell:x,onShellAgentWrite:S,emptyState:C,showControls:w=!0,showSearch:T=w,autoFocusSearch:E,projectIcons:D,className:O}){let k=(0,v.useMemo)(()=>XO(e,t,r),[e,t,r]),A=(0,v.useMemo)(()=>nk(k,t),[k,t]),j=rk(t,r,k.length,e.length),M=(0,v.useMemo)(()=>new Set(e.map(e=>e.hostId)).size,[e]),N=e=>n({...t,...e});return(0,H.jsxs)(`div`,{"data-slot":`session-browser`,className:U(`flex flex-col gap-3`,O),children:[T?(0,H.jsx)(tie,{value:t.search,onChange:e=>N({search:e}),autoFocus:E,className:`px-2`}):null,w?(0,H.jsx)($5,{config:t,onConfigChange:n,rows:e,scope:r,className:`px-2`}):null,j&&d?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-label text-fg-4`,children:[(0,H.jsxs)(`span`,{children:[j.shown,` of `,j.total,j.causes.length?` · ${j.causes.join(` · `)}`:null]}),(0,H.jsx)(`button`,{type:`button`,className:`text-fg-3 underline underline-offset-2 hover:text-fg-1`,onClick:()=>n(sk(t)),children:`Show all`})]}):null,e.length===0?C??(0,H.jsx)(bE,{icon:(0,H.jsx)(Zy,{}),title:`No sessions yet`}):k.length===0?ik(t)?(0,H.jsx)(bE,{icon:(0,H.jsx)(Jx,{}),title:`No matches`,description:`No session matches the current search and filters.`,action:`Clear filters`,onAction:()=>n(sk(t))}):r&&YO(t,r)?(0,H.jsx)(bE,{icon:(0,H.jsx)(py,{}),title:`Nothing in this folder`,description:`No session is running in ${r.label}.`,action:`Show all folders`,onAction:()=>N({scoped:!1})}):(0,H.jsx)(bE,{icon:(0,H.jsx)(Zy,{}),title:`Nothing here`,description:`No session to show.`}):(0,H.jsx)(`div`,{className:`flex flex-col gap-4 px-1`,children:A.map(e=>(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t.groupBy!==`none`&&e.label?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-2 text-label font-medium text-fg-4`,children:[t.groupBy===`project`?(0,H.jsx)(Q5,{icon:e.rows[0]?.info.project?.icon,src:$re(e.rows[0],D),name:e.label}):null,(0,H.jsx)(`span`,{className:`uppercase tracking-wide`,children:e.label}),(0,H.jsx)(`span`,{className:`text-fg-4/70`,children:e.rows.length})]}):null,e.rows.map(e=>(0,H.jsx)(eie,{row:e,active:c(e),activeSubagentId:a,activeShellId:o,actions:l?.(e),now:s,showGateway:(u??M)>1&&t.groupBy!==`gateway`,showProject:t.groupBy!==`project`,subagents:t.subagents,shells:t.shells,tasks:t.tasks,projectIcons:D,onSelect:f,onDelete:p,onRename:m,onClearContext:h,onSelectSubagent:g,onSelectTask:_,onStopTask:y,onSelectShell:b,onKillShell:x,onShellAgentWrite:S},`${e.hostId}:${e.info.id}`))]},e.key))})]})}function $re(e,t){let n=e?.info.project?.icon;return n?.type===`image`?t?.[n.hash]:void 0}function eie({row:e,active:t,actions:n,activeSubagentId:r,activeShellId:i,now:a,showGateway:o,showProject:s=!0,subagents:c,shells:l,tasks:u,projectIcons:d,onSelect:f,onDelete:p,onRename:m,onClearContext:h,onSelectSubagent:g,onSelectTask:_,onStopTask:y,onSelectShell:b,onKillShell:x,onShellAgentWrite:S}){let{info:C}=e,[w,T]=(0,v.useState)(!1);return(0,H.jsx)(Yre,{row:e,active:t===!0,activeStepKey:t?i??r:void 0,now:a,showGateway:o,showProject:s,subagents:c,shells:l,tasks:u,projectIcons:d,onSelect:t=>f?.(e,t),onSelectSubagent:g?t=>g(e,t):void 0,onSelectTask:_?t=>_(e,t):void 0,onStopTask:y?t=>y(e,t):void 0,onSelectShell:b?t=>b(e,t):void 0,onKillShell:x?t=>x(e,t):void 0,onShellAgentWrite:S?(t,n)=>S(e,t,n):void 0,onRename:m?t=>m(e,t):void 0,renameOn:n===void 0?`external`:`doubleClick`,editing:n===void 0?w:void 0,onEditingChange:n===void 0?T:void 0,actions:n??(0,H.jsxs)(H.Fragment,{children:[m&&!w?(0,H.jsx)(u7,{label:`Rename session`,onClick:()=>T(!0),children:(0,H.jsx)(lx,{className:`size-3 text-fg-3`})}):null,h&&C.capabilities?.clearContext?(0,H.jsx)(u7,{label:`Clear context`,title:`Clear the conversation - the session keeps running and the old conversation stays resumable`,onClick:()=>h(e),children:(0,H.jsx)(Yv,{className:`size-3 text-fg-3`})}):null,p?(0,H.jsx)(u7,{label:`Close session`,onClick:()=>p(e),children:(0,H.jsx)(zS,{className:`size-3 text-fg-3`})}):null]})})}function u7({label:e,title:t,onClick:n,children:r}){return(0,H.jsx)(uo,{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 tie({value:e,onChange:t,autoFocus:n,className:r,inputClassName:i}){return(0,H.jsxs)(`div`,{className:U(`relative`,r),children:[(0,H.jsx)(Xx,{className:`pointer-events-none absolute top-1/2 left-4.5 size-3.5 -translate-y-1/2 text-fg-4`}),(0,H.jsx)(vo,{value:e,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.stopPropagation(),t(``))},placeholder:`Search sessions`,"aria-label":`Search sessions`,autoFocus:n,className:U(`pr-7 pl-8`,i)}),e?(0,H.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>t(``),className:`absolute top-1/2 right-3.5 -translate-y-1/2 rounded p-0.5 text-fg-4 hover:text-fg-1`,children:(0,H.jsx)(hC,{className:`size-3`})}):null]})}function d7(){let[e,t]=(0,v.useState)(T());return(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Toggle theme`,onClick:()=>t(O()),children:e===`dark`?(0,H.jsx)(TS,{className:`size-4`}):(0,H.jsx)(Fb,{className:`size-4`})})}var f7=[{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`}],p7=`workerdeck.transcript-variant`;function m7(){return b(p7)===`terminal`?`terminal`:`cards`}function nie(e){x(p7,e)}var h7=`workerdeck.transcript-font`;function g7(){return b(h7)===`mono`?`mono`:`sans`}function rie(e){x(h7,e)}var _7=`workerdeck.font-size`;function v7(){let e=b(_7);if(e===void 0)return;let t=Number(e);return Number.isFinite(t)&&t>=8&&t<=24?Math.round(t):void 0}function iie(e){x(_7,e===void 0?void 0:String(Math.round(e)))}var y7=`workerdeck.catch-up`;function b7(){return b(y7)===`off`?`off`:`on`}function aie(e){x(y7,e)}var x7=`workerdeck.action-style`;function S7(){return b(x7)===`labeled`?`labeled`:`icons`}function oie(e){x(x7,e)}function C7({label:e,options:t,read:n,write:r,onChange:i}){let[a,o]=(0,v.useState)(n);return(0,H.jsx)(TC,{label:e,value:a,options:t,onChange:e=>{o(e),r(e),i?.(e)},className:`min-w-40`})}function w7({title:e,children:t}){return(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`h3`,{className:`text-label font-medium tracking-wide text-fg-3 uppercase`,children:e}),t]})}function sie({open:e,onOpenChange:t}){let[n,r]=(0,v.useState)(m7);return(0,H.jsx)(aT,{open:e,onOpenChange:t,children:(0,H.jsxs)(oT,{size:`md`,className:`w-[min(30rem,calc(100vw-2rem))]`,children:[(0,H.jsx)(sT,{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,H.jsx)(cT,{children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,H.jsxs)(w7,{title:`Appearance`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Theme`}),(0,H.jsx)(d7,{})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Agent view style`}),(0,H.jsx)(C7,{label:`Agent view style`,options:[{value:`cards`,label:`Cards`},{value:`terminal`,label:`Terminal`}],read:m7,write:nie,onChange:r})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Font size`}),(0,H.jsx)(C7,{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(v7()??``),write:e=>iie(e?Number(e):void 0)})]}),n===`cards`?(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Agent view font`}),(0,H.jsx)(C7,{label:`Agent view font`,options:[{value:`sans`,label:`Regular`},{value:`mono`,label:`Monospace`}],read:g7,write:rie})]}):null,(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Row actions`}),(0,H.jsx)(C7,{label:`Row actions`,options:[{value:`icons`,label:`Icons`},{value:`labeled`,label:`Icons and labels`}],read:S7,write:oie})]})]}),(0,H.jsx)(w7,{title:`Sessions`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsxs)(`span`,{className:`text-body-sm text-fg-2`,children:[`Catch-up mode`,(0,H.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,H.jsx)(C7,{label:`Catch-up mode`,options:[{value:`on`,label:`On`},{value:`off`,label:`Off`}],read:b7,write:aie})]})})]})})]})})}function T7({className:e}){return(0,H.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:e,children:[(0,H.jsx)(`path`,{d:`M12 3 20.5 7.75 12 12.5 3.5 7.75Z`}),(0,H.jsx)(`path`,{d:`M3.5 12.25 12 17l8.5-4.75`}),(0,H.jsx)(`path`,{d:`M3.5 16.5 12 21.25l8.5-4.75`}),(0,H.jsx)(`path`,{d:`M12 6.15 14.85 7.75 12 9.35 9.15 7.75Z`,fill:`#2fbf71`,stroke:`none`})]})}function E7(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)}}function D7(e,{load:t,intervalMs:n,onIdle:r}){let i=E7(e),a,o=0,s,c=()=>(a??=t(i).finally(()=>{a=void 0}),a),l=e=>{let t=i.subscribe(e);return++o===1&&(c(),n&&(s=setInterval(()=>void c(),n))),()=>{t(),--o===0&&(clearInterval(s),s=void 0,r?.())}};return{...i,subscribe:l,refresh:c,watched:()=>o>0,use:()=>(0,v.useSyncExternalStore)(l,i.get,i.get)}}var O7=`workerdeck.hosts.v1`;function k7(e){return`workerdeck.host.${e}.key`}var cie=`gateway`,A7=E7({hosts:[],ready:!1});function j7(e){I7.clear(),A7.set(e)}function M7(){let e=S(O7,[]);return Array.isArray(e)?e.map(({implicit:e,...t})=>t):[]}function N7(e){C(O7,e.filter(e=>!e.implicit))}function lie(){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 P7(e){return b(k7(e))??``}function F7(e,t){x(k7(e),t===``?void 0:t)}var I7=new Map;function L7(e){let t=I7.get(e);if(t)return t;let n=A7.get().hosts.find(t=>t.id===e);if(!n)return;let r=hA(n);if(r===void 0)return;let i=new yA({baseUrl:r,...n.implicit?{}:_A({baseUrl:r,key:P7(n.id)})});return I7.set(e,i),i}function R7(){return A7.get().hosts.find(e=>e.implicit)??A7.get().hosts[0]}function uie(){let e=R7();return e?L7(e.id):void 0}function z7(e){return gA(e)}function die(e,t){let n=M7(),r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[...n,e];N7(r),F7(e.id,t),j7({...A7.get(),hosts:[...A7.get().hosts.filter(e=>e.implicit),...r]})}function fie(e){let t=M7().filter(t=>t.id!==e);N7(t),F7(e,``),j7({...A7.get(),hosts:[...A7.get().hosts.filter(e=>e.implicit),...t]})}async function pie(){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 B7=!1;function V7(){if(B7)return;B7=!0;let e=M7();j7({hosts:e,ready:!1}),pie().then(t=>{j7({hosts:t?[{id:cie,name:`This gateway`,baseUrl:location.origin,implicit:!0},...e]:e,ready:!0})})}function H7(e){return V7(),A7.subscribe(e)}function U7(){return(0,v.useSyncExternalStore)(H7,A7.get,A7.get)}function mie(){return V7(),A7.get().hosts}function W7(e){return H7(e)}function G7({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)(()=>P7(e.id));return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label text-fg-3`,children:`Name`}),(0,H.jsx)(vo,{value:i,onChange:e=>a(e.target.value),placeholder:`Mac mini`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label text-fg-3`,children:`Address`}),(0,H.jsx)(vo,{value:o,onChange:e=>s(e.target.value),placeholder:`http://toby.ts.net:8787`,spellCheck:!1,className:`font-mono`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label text-fg-3`,children:`Auth key`}),(0,H.jsx)(vo,{type:`password`,value:c,onChange:e=>l(e.target.value),placeholder:`Leave empty for an unauthenticated gateway`,spellCheck:!1}),(0,H.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,H.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2`,children:[r,(0,H.jsx)(uo,{onClick:()=>{if(hA({baseUrl:o})===void 0){ZT.error(`That address is not a URL`);return}if(!i.trim()){ZT.error(`Give the gateway a name`);return}let t={id:e.id,name:i.trim(),baseUrl:o.trim()};die(t,c),n(t)},children:t})]})]})}function hie({open:e,onOpenChange:t,onCreated:n}){let[r,i]=(0,v.useState)(()=>K7());return(0,H.jsx)(aT,{open:e,onOpenChange:e=>{e&&i(K7()),t(e)},children:(0,H.jsxs)(oT,{children:[(0,H.jsx)(sT,{title:`Add gateway`,description:`A workerdeck gateway you run - typically over Tailscale.`}),(0,H.jsx)(cT,{children:(0,H.jsx)(G7,{host:r,submitLabel:`Add gateway`,onSaved:n,actions:(0,H.jsx)(uo,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`})})})]})})}function K7(){return{id:lie(),name:``,baseUrl:``}}function q7({host:e,onClose:t,onRemoved:n}){return(0,H.jsx)(aT,{open:!0,onOpenChange:e=>!e&&t(),children:(0,H.jsxs)(oT,{children:[(0,H.jsx)(sT,{title:`Remove ${e.name}?`,description:`Its auth key is deleted from this browser. The gateway itself keeps running.`}),(0,H.jsx)(cT,{children:(0,H.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,H.jsx)(uo,{variant:`outline`,onClick:t,children:`Cancel`}),(0,H.jsx)(uo,{variant:`destructive`,onClick:()=>{fie(e.id),n()},children:`Remove`})]})})]})})}function J7(e){return e===`sessions`?`workerdeck.sessions-sidebar-width`:`workerdeck.${e}-sidebar-width`}function Y7(e){return e===`sessions`?`workerdeck.sessions-sidebar-collapsed`:`workerdeck.${e}-sidebar-collapsed`}function gie(e){let t=Number(b(J7(e)));return t?Math.min(520,Math.max(240,t)):300}function _ie(e,t){x(J7(e),String(t))}function vie(e){return b(Y7(e))===`1`}function yie(e,t){x(Y7(e),t?`1`:`0`)}var X7=`workerdeck.sessions-search-shown`;function bie(){return b(X7)===`1`}function xie(e){x(X7,e?`1`:`0`)}function Z7({section:e,title:t,badge:n,actions:r,children:i,rail:a,railActions:o}){let[s,c]=(0,v.useState)(()=>gie(e)),[l,u]=(0,v.useState)(()=>vie(e)),d=t=>{u(t),yie(e,t)};return l?(0,H.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,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Expand ${t.toLowerCase()}`,onClick:()=>d(!1),children:(0,H.jsx)(tx,{className:`size-4`})}),o,a?(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{style:{width:s},className:`flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar`,children:[(0,H.jsxs)(`header`,{className:`flex h-9 shrink-0 items-center gap-1 pr-1 pl-3`,children:[(0,H.jsx)(`span`,{className:`truncate text-label font-medium tracking-wide text-fg-3 uppercase`,children:t}),n,(0,H.jsx)(`span`,{className:`flex-1`}),(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Collapse ${t.toLowerCase()}`,onClick:()=>d(!0),children:(0,H.jsx)($b,{className:`size-3.5`})}),r]}),i]}),(0,H.jsx)(yE,{orientation:`vertical`,value:s,onValueChange:t=>{c(t),_ie(e,t)},min:240,max:520,defaultValue:300,"aria-label":`Resize ${t.toLowerCase()} sidebar`})]})}function Q7({children:e,className:t}){return(0,H.jsx)(`div`,{className:U(`min-h-0 flex-1 overflow-y-auto pb-2`,t),children:e})}function $7({title:e,status:t,description:n,actions:r,active:i,onSelect:a,onDoubleClick:o}){return(0,H.jsxs)(`div`,{"data-slot":`sidebar-row`,"data-active":i||void 0,onClick:a,onDoubleClick:o,className:U(`group flex cursor-pointer flex-col gap-0.5 text-left transition-colors`,Zre(i===!0)),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(`button`,{type:`button`,className:U(`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,H.jsxs)(`div`,{className:`flex items-center gap-1 text-label text-fg-4`,children:[(0,H.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 e9({label:e,onClick:t,children:n}){return(0,H.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 t9=`workerdeck.watermarks.v1`,n9=E7(0),r9=new iA({read:()=>S(t9,void 0),write:e=>{C(t9,e),n9.set(n9.get()+1)}});function i9(){return n9.use(),{unseenFor:(0,v.useCallback)((e,t)=>aA(r9.get(e,t.id),t),[]),watermarks:r9}}function Sie(e,t){let n=r9.get(e,t);return n?{itemCount:n.itemCount,since:n.seenAt}:void 0}function Cie(e,t){let n=(0,v.useRef)({});return(0,v.useCallback)(r=>{t&&!document.hidden&&(n.current={...n.current,...r},r9.mark(e,t,n.current))},[e,t])}function wie(e){let{unseenFor:t}=i9();return(0,v.useMemo)(()=>e.reduce((e,n)=>e+t(n.hostId,n.info),0),[e,t])}var Tie=5e3,Eie=1200,Die=700,a9=D7({snapshots:[],loaded:!1},{load:Oie}),o9=0,s9;function c9(){return a9.refresh()}async function Oie(){o9=Date.now();let e=mie(),t=new Map(a9.get().snapshots.map(e=>[e.host.id,e])),n=await Promise.all(e.map(async e=>{let n=L7(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:hk(n)}}}));a9.set({snapshots:n,loaded:!0})}function kie(){if(s9!==void 0)return;let e=Math.max(0,Die-(Date.now()-o9));s9=setTimeout(()=>{s9=void 0,c9()},e)}var l9,u9;function Aie(e){let t=e?Eie:Tie;(l9===void 0||u9!==t)&&(l9!==void 0&&clearInterval(l9),u9=t,l9=setInterval(()=>void c9(),t))}function d9(){let e=a9.use();(0,v.useEffect)(()=>W7(()=>void c9()),[]);let t=e.snapshots.some(e=>e.sessions.some(e=>{let t=AO(e);return t===`working`||t===`attention`}));return(0,v.useEffect)(()=>Aie(t),[t]),{...e,refresh:c9}}function f9(e){let{unseenFor:t}=i9();return(0,v.useMemo)(()=>e.flatMap(({host:e,sessions:n})=>n.filter(e=>!UO(e)).map(n=>({hostId:e.id,hostName:e.name,local:z7(e),adapter:n.engine??`claude`,state:AO(n),info:n,unseen:t(e.id,n)}))),[e,t])}function jie(){let e=Mr(),t=xi({select:e=>e.location.pathname.match(/^\/gateways\/(.+)$/)?.[1]}),{hosts:n,ready:r}=U7(),{snapshots:i}=d9(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),l=i.filter(e=>e.error===void 0).length,u=(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Add gateway`,onClick:()=>o(!0),children:(0,H.jsx)(yx,{className:`size-4`})});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z7,{section:`gateways`,title:`Gateways`,badge:r&&n.length>0?(0,H.jsxs)(`span`,{className:`shrink-0 text-label text-fg-4`,children:[l,`/`,n.length]}):void 0,actions:u,railActions:u,children:(0,H.jsxs)(Q7,{children:[r&&n.length===0?(0,H.jsx)(bE,{icon:(0,H.jsx)(Qx,{}),title:`No gateways yet`,description:(0,H.jsxs)(H.Fragment,{children:[`Add one with `,(0,H.jsx)(xE,{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,H.jsx)($7,{active:n.id===t,onSelect:()=>void e({to:`/gateways/$hostId`,params:{hostId:n.id}}),title:n.name,status:(0,H.jsxs)(H.Fragment,{children:[n.implicit?(0,H.jsx)(`span`,{className:`shrink-0 text-label text-fg-4`,children:`this page`}):null,(0,H.jsx)(`span`,{"aria-hidden":!0,title:r?.error??(a===`ok`?`Connected`:`Connecting…`),className:U(`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,H.jsx)(e9,{label:`Remove ${n.name}`,onClick:()=>c(n),children:(0,H.jsx)(zS,{className:`size-3`})})},n.id)})]})}),s?(0,H.jsx)(q7,{host:s,onClose:()=>c(void 0),onRemoved:()=>{let n=s.id===t;c(void 0),n&&e({to:`/gateways`})}}):null,(0,H.jsx)(hie,{open:a,onOpenChange:o,onCreated:t=>{o(!1),e({to:`/gateways/$hostId`,params:{hostId:t.id}})}})]})}function p9({value:e,onChange:t,models:n=f7,className:r}){return(0,H.jsx)(S3,{variant:`form`,models:n,model:e||void 0,onModelChange:e=>t(e??``),className:r})}function Mie({profiles:e,value:t,onChange:n,className:r}){return e.length===0?null:(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Profile`}),(0,H.jsxs)(yC,{items:e.map(e=>({value:e.name,label:e.name})),value:t,onValueChange:e=>n(e),children:[(0,H.jsx)(SC,{className:r,children:(0,H.jsx)(bC,{})}),(0,H.jsx)(CC,{children:e.map(e=>(0,H.jsx)(wC,{value:e.name,children:(0,H.jsx)(xC,{children:(0,H.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 m9(){return uie()}function h9(e,t,n){let r=e?.capabilities??cA[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=f7.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 g9={profiles:[]},_9=D7(g9,{load:Nie});async function Nie(){let e=await m9()?.listProfiles().catch(()=>g9);_9.set(e??g9)}function v9(){return(0,v.useEffect)(()=>W7(()=>void _9.refresh()),[]),{..._9.use(),refresh:_9.refresh}}function Pie(){return v9().profiles}var y9=`workerdeck.last-profile`;function Fie(){let e=Pie(),[t,n]=(0,v.useState)(()=>b(y9)??``),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(y9,e)}}}var b9=`workerdeck.last-cwd`;function Iie(e){let[t,n]=(0,v.useState)([]);return(0,v.useEffect)(()=>{m9()?.listHostRoots().then(e=>n(e.roots.map(e=>e.path))).catch(()=>n([]))},[]),(0,v.useMemo)(()=>{let n=b(b9),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 Lie={session:`default`,job:`acceptEdits`},Rie={session:`ask`,job:`auto`};function x9(e){let[t,n]=(0,v.useState)(()=>b(b9)??``),[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)(Rie[e]),{profiles:p,profile:m,selected:h,select:g}=Fie(),_=h9(h,s??h?.defaults?.permissionMode??Lie[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(b9,t.trim()||e)}}function S9({form:e}){return e.engine.capabilities.interactiveApprovals?(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Questions`}),(0,H.jsxs)(yC,{items:p6.map(e=>({value:e.value,label:e.label})),value:e.questions,onValueChange:t=>e.setQuestions(t),children:[(0,H.jsx)(SC,{className:`min-w-36`,children:(0,H.jsx)(bC,{})}),(0,H.jsx)(CC,{children:p6.map(e=>(0,H.jsx)(wC,{value:e.value,children:(0,H.jsx)(xC,{children:`${e.label} - ${e.description}`})},e.value))})]})]}):null}function C9({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=Iie(t),c=(0,v.useId)(),{engine:l}=e;return(0,H.jsxs)(H.Fragment,{children:[l.capabilities.hostCwd!==!1&&(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Working directory`}),(0,H.jsx)(vo,{value:e.cwd,list:c,onChange:t=>e.setCwd(t.target.value),placeholder:`/path/to/project`,spellCheck:!1,className:`font-mono`}),(0,H.jsx)(`datalist`,{id:c,children:s.map(e=>(0,H.jsx)(`option`,{value:e},e))})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:n}),(0,H.jsx)(yo,{value:e.prompt,onChange:t=>e.setPrompt(t.target.value),rows:2,placeholder:r})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(Mie,{profiles:e.profiles,value:e.profile,onChange:t=>{e.selectProfile(t),o?.(t)},className:`min-w-32`}),(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Permission mode`}),(0,H.jsx)(E3,{variant:`form`,mode:l.mode,onModeChange:e.setMode,modes:l.modes,className:`min-w-44`})]}),i,(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Model`}),(0,H.jsx)(p9,{value:l.model,onChange:e.setModel,models:l.models,className:`min-w-40`})]}),l.reasoningEfforts.length>0?(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Effort`}),(0,H.jsxs)(yC,{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,H.jsx)(SC,{className:`min-w-28`,children:(0,H.jsx)(bC,{})}),(0,H.jsx)(CC,{children:[`default`,...l.reasoningEfforts].map(e=>(0,H.jsx)(wC,{value:e,children:(0,H.jsx)(xC,{children:e})},e))})]})]}):null,a]})]})}var w9=D7({jobs:[],stats:void 0,enabled:!0,live:!1,error:void 0},{load:zie,intervalMs:15e3,onIdle:Bie}),T9=w9.patch,E9;function D9(){return w9.refresh()}async function zie(){try{let e=m9();if(!e)return;let[t,n]=await Promise.all([e.listJobs(),e.queueStats()]);T9({jobs:t,stats:n,enabled:!0,error:void 0})}catch(e){let t=hk(e);/not configured/i.test(t)?T9({enabled:!1,error:void 0}):T9({error:t})}}function Bie(){E9?.(),E9=void 0,T9({live:!1})}function Vie(){if(E9||!w9.get().enabled||w9.get().stats===void 0||!w9.watched())return;let e=m9();if(!e)return;let t=e.attachQueue(),n=[t.on(`attached`,()=>void D9()),t.on(`stats`,e=>T9({stats:e})),t.on(`connectionChange`,e=>T9({live:e})),t.on(`event`,e=>{T9({jobs:w9.get().jobs.some(t=>t.id===e.job.id)?w9.get().jobs.map(t=>t.id===e.job.id?e.job:t):[...w9.get().jobs,e.job]})})];E9=()=>{for(let e of n)e();t.detach()}}function O9(){let e=w9.use();return(0,v.useEffect)(Vie,[e.enabled,e.stats]),{...e,refresh:D9}}function Hie({stats:e}){let t=e.dailyTokenLimit!==void 0&&e.dailyTokenLimit>0?e.dailyTokensUsed/e.dailyTokenLimit*100:void 0;return(0,H.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,H.jsxs)(`span`,{children:[`Running`,` `,(0,H.jsxs)(`span`,{className:`font-mono text-fg-1`,children:[e.running,`/`,e.maxConcurrency]})]}),(0,H.jsxs)(`span`,{children:[`Queued `,(0,H.jsx)(`span`,{className:`font-mono text-fg-1`,children:e.queued})]}),e.parked>0?(0,H.jsxs)(`span`,{children:[`Parked `,(0,H.jsx)(`span`,{className:`font-mono text-fg-1`,children:e.parked})]}):null,(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[t===void 0?null:(0,H.jsx)(SE,{value:t,className:t>=95?`text-danger`:t>=80?`text-warning`:`text-fg-3`}),`Daily tokens`,` `,(0,H.jsxs)(`span`,{className:`font-mono text-fg-1`,children:[iN(e.dailyTokensUsed),e.dailyTokenLimit===void 0?``:` / ${iN(e.dailyTokenLimit)}`]})]}),e.sessionTokenLimit===void 0?null:(0,H.jsxs)(`span`,{children:[`Per-job cap `,(0,H.jsx)(`span`,{className:`font-mono text-fg-1`,children:iN(e.sessionTokenLimit)})]}),e.paused?(0,H.jsx)(po,{variant:`warning`,dot:!0,children:`Paused - daily budget exhausted`}):null]})}function Uie({onScheduled:e}){let{snapshots:t}=d9(),n=t.find(e=>e.host.id===R7()?.id)?.sessions??[],r=x9(`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()){ZT.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)){ZT.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)){ZT.error(`Attempts must be a whole number of at least 1`);return}p(!0);try{r.rememberCwd(r.cwd.trim()),await m9().createJob({session:{...r.sessionFields({allowBypass:i}),prompt:r.prompt.trim()},maxTokens:t,attempts:n,webhook:u.trim()?{url:u.trim()}:void 0}),r.setPrompt(``),ZT.success(`Job scheduled`),e()}catch(e){ZT.error(hk(e,`Failed to schedule job`))}finally{p(!1)}};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(C9,{form:r,sessions:n,promptLabel:`Prompt (the task - runs unattended)`,extras:(0,H.jsx)(S9,{form:r}),actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Max tokens (optional)`}),(0,H.jsx)(vo,{value:o,onChange:e=>s(e.target.value),placeholder:`per-job cap`,inputMode:`numeric`,className:`min-w-28 font-mono`})]}),(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Attempts (optional)`}),(0,H.jsx)(vo,{value:c,onChange:e=>l(e.target.value),placeholder:`1`,inputMode:`numeric`,className:`min-w-20 font-mono`})]}),(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Webhook URL (optional)`}),(0,H.jsx)(vo,{value:u,onChange:e=>d(e.target.value),placeholder:`https://…/hook`,spellCheck:!1,className:`min-w-44 font-mono`})]}),(0,H.jsxs)(uo,{className:`ml-auto`,onClick:()=>void h(),disabled:f,children:[f?(0,H.jsx)(_E,{className:`size-3.5 text-current`}):(0,H.jsx)(yx,{className:`size-4`}),`Schedule`]})]})}),m.capabilities.settingSources?(0,H.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,H.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),className:`size-3.5 accent-(--color-fg-1)`}),`Allow switching to `,(0,H.jsx)(`code`,{className:`font-mono`,children:`bypassPermissions`}),` mid-run`,(0,H.jsx)(`span`,{className:`text-label text-fg-4`,children:`(dangerous)`})]}):null,(0,H.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,H.jsx)(`code`,{className:`font-mono`,children:`POST /sessions/:id/permissions/:requestId`}),`.`]})]})}function Wie({open:e,onOpenChange:t,onScheduled:n}){return(0,H.jsx)(aT,{open:e,onOpenChange:t,children:(0,H.jsxs)(oT,{size:`lg`,children:[(0,H.jsx)(sT,{title:`Schedule a job`,description:`A one-shot run the queue executes unattended.`}),(0,H.jsx)(cT,{children:e?(0,H.jsx)(Uie,{onScheduled:n}):null})]})})}function Gie(){let{stats:e,enabled:t,error:n}=O9();return(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[n?(0,H.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,H.jsx)(`code`,{className:`font-mono`,children:`pnpm server`}),`.`]}):null,t?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(bE,{icon:(0,H.jsx)(sb,{}),title:`No job selected`,description:(0,H.jsxs)(H.Fragment,{children:[`Pick one on the left, or schedule one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]})}),e?(0,H.jsx)(`div`,{className:`mt-2 w-full max-w-xl`,children:(0,H.jsx)(Hie,{stats:e})}):null]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(V_,{className:`size-8 text-fg-4`}),(0,H.jsx)(`p`,{className:`text-body-sm text-fg-3`,children:`The server has no job queue configured.`}),(0,H.jsxs)(`p`,{className:`max-w-md text-label text-fg-4`,children:[`Pass `,(0,H.jsxs)(`code`,{className:`font-mono`,children:[`queue: `,`{ maxConcurrency, … }`]}),` to`,` `,(0,H.jsx)(`code`,{className:`font-mono`,children:`createWorkerServer`}),` - the dev server enables it by default.`]})]})]})}var k9={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`}},Kie=[`queued`,`running`,`parked`];function qie(){let e=Mr(),t=xi({select:e=>e.location.pathname.match(/^\/jobs\/(.+)$/)?.[1]}),{jobs:n,enabled:r,live:i,refresh:a}=O9(),[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||Kie.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,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Schedule a job`,onClick:()=>s(!0),children:(0,H.jsx)(yx,{className:`size-4`})}):void 0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z7,{section:`jobs`,title:`Jobs`,badge:r?(0,H.jsx)(`span`,{"aria-hidden":!0,title:i?`Streaming over the queue socket`:`Polling`,className:U(`size-1.5 shrink-0 rounded-full`,i?`bg-success`:`bg-fg-4`)}):void 0,actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh`,onClick:()=>void a(),children:(0,H.jsx)(Nx,{className:`size-3.5`})}),h]}),railActions:h,children:r?(0,H.jsxs)(H.Fragment,{children:[n.length>0?(0,H.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pb-2`,children:[(0,H.jsx)(vo,{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,H.jsx)(uo,{variant:u?`default`:`outline`,size:`xs`,"aria-pressed":u,onClick:()=>d(!u),children:`Active`})]}):null,(0,H.jsxs)(Q7,{children:[n.length===0?(0,H.jsx)(bE,{icon:(0,H.jsx)(lb,{}),title:`No jobs yet`,description:(0,H.jsxs)(H.Fragment,{children:[`Schedule one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]})}):p.length===0?(0,H.jsx)(bE,{icon:(0,H.jsx)(Jx,{}),title:`No matches`,description:`No job matches the active filter.`,action:`Show all`,onAction:()=>d(!1)}):null,p.map(n=>(0,H.jsx)(Jie,{job:n,active:n.id===t,onOpen:()=>void e({to:`/jobs/$jobId`,params:{jobId:n.id}}),onChanged:()=>void a()},n.id)),m>0?(0,H.jsxs)(`p`,{className:`px-1 pt-2 text-center text-label text-fg-4`,children:[p.length,` of `,n.length]}):null]})]}):(0,H.jsx)(bE,{icon:(0,H.jsx)(lb,{}),title:`No job queue`,description:`This gateway runs without one, so there is nothing to schedule against.`})}),(0,H.jsx)(Wie,{open:o,onOpenChange:s,onScheduled:()=>{s(!1),a()}})]})}function Jie({job:e,active:t,onOpen:n,onChanged:r}){let i=k9[e.status],a=e.status===`queued`||e.status===`running`||e.status===`parked`,o=[sN(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(nN(s)),(0,H.jsx)($7,{active:t,onSelect:n,title:e.prompt,status:(0,H.jsxs)(po,{variant:i.variant,dot:!i.busy,className:`shrink-0`,children:[i.busy?(0,H.jsx)(_E,{className:`size-3 text-current`}):null,i.label]}),description:o.join(` · `),actions:a?(0,H.jsx)(e9,{label:`Cancel job`,onClick:()=>{m9()?.cancelJob(e.id).then(r).catch(e=>ZT.error(hk(e,`Cancel failed`)))},children:(0,H.jsx)(hC,{className:`size-3`})}):null})}var A9=[`web_search`,`download`,`web_fetch`,`deliver_file`];function j9(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}function M9({label:e,children:t}){return(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:e}),t]})}function Yie({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()){ZT.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:j9(d).length>0?j9(d):void 0,apiKeyEnv:p.trim()||void 0};let e={};b.length>0&&(e.capabilities=b),j9(S).length>0&&(e.mcpServers=j9(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 m9().createProfile(n),ZT.success(`Profile '${n.name}' created`),e(n.name)}catch(e){ZT.error(hk(e,`Failed to create profile`))}finally{D(!1)}};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`Engine`,children:(0,H.jsxs)(yC,{items:[{value:`provider`,label:`provider`},{value:`claude`,label:`claude`},{value:`codex`,label:`codex`}],value:t,onValueChange:e=>n(e),children:[(0,H.jsx)(SC,{className:`min-w-32`,children:(0,H.jsx)(bC,{})}),(0,H.jsxs)(CC,{children:[(0,H.jsx)(wC,{value:`provider`,children:(0,H.jsx)(xC,{children:`provider - model-agnostic engine`})}),(0,H.jsx)(wC,{value:`claude`,children:(0,H.jsx)(xC,{children:`claude - Agent SDK + config dir`})}),(0,H.jsx)(wC,{value:`codex`,children:(0,H.jsx)(xC,{children:`codex - app-server + CODEX_HOME`})})]})]})}),(0,H.jsx)(M9,{label:`Name`,children:(0,H.jsx)(vo,{value:r,onChange:e=>i(e.target.value),placeholder:`kimi`})}),(0,H.jsx)(M9,{label:`Description (optional)`,children:(0,H.jsx)(vo,{value:a,onChange:e=>o(e.target.value),placeholder:`what this profile is for`})})]}),O?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`Provider id`,children:(0,H.jsx)(vo,{value:s,onChange:e=>c(e.target.value),placeholder:`anthropic / openai / moonshotai`,className:`font-mono`})}),(0,H.jsx)(M9,{label:`Default model`,children:(0,H.jsx)(vo,{value:l,onChange:e=>u(e.target.value),placeholder:`kimi-k3`,className:`font-mono`})}),(0,H.jsx)(M9,{label:`Models offered (comma-separated)`,children:(0,H.jsx)(vo,{value:d,onChange:e=>f(e.target.value),placeholder:`kimi-k3, kimi-k2`,className:`font-mono`})}),(0,H.jsx)(M9,{label:`API key variable`,children:(0,H.jsx)(vo,{value:p,onChange:e=>m(e.target.value),placeholder:`MOONSHOT_API_KEY`,className:`font-mono`})})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`Capabilities granted`,children:(0,H.jsx)(`div`,{className:`flex flex-wrap gap-3 py-1.5`,children:A9.map(e=>(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,H.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,H.jsx)(`code`,{className:`font-mono text-label`,children:e})]},e))})}),(0,H.jsx)(M9,{label:`MCP servers (names, comma-separated)`,children:(0,H.jsx)(vo,{value:S,onChange:e=>C(e.target.value),placeholder:`deepwiki`,className:`font-mono`})})]}),(0,H.jsx)(M9,{label:`Instructions (optional)`,children:(0,H.jsx)(vo,{value:w,onChange:e=>T(e.target.value),placeholder:`prepended to the session's system prompt`})}),(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(M9,{label:`Home directory (optional)`,children:(0,H.jsx)(vo,{value:_,onChange:e=>y(e.target.value),placeholder:`/Users/you/.codex`,spellCheck:!1,className:`font-mono`})}),(0,H.jsxs)(`p`,{className:`text-label text-fg-4`,children:[`This profile's `,(0,H.jsx)(`code`,{className:`font-mono`,children:`CODEX_HOME`}),`. Must resolve inside the server's`,` `,(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(M9,{label:`Config directory`,children:(0,H.jsx)(vo,{value:h,onChange:e=>g(e.target.value),placeholder:`/Users/you/.claude`,spellCheck:!1,className:`font-mono`})}),(0,H.jsxs)(`p`,{className:`text-label text-fg-4`,children:[`Must resolve inside the server's `,(0,H.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,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsxs)(uo,{onClick:()=>void A(),disabled:E,children:[E?(0,H.jsx)(_E,{className:`size-3.5 text-current`}):(0,H.jsx)(yx,{className:`size-4`}),`Create profile`]})})]})}function Xie({open:e,onOpenChange:t,onCreated:n}){return(0,H.jsx)(aT,{open:e,onOpenChange:t,children:(0,H.jsxs)(oT,{size:`lg`,children:[(0,H.jsx)(sT,{title:`New profile`,description:`What a session runs as - a Claude config directory, or a model provider.`}),(0,H.jsx)(cT,{children:e?(0,H.jsx)(Yie,{onCreated:n}):null})]})})}function Zie(){let e=Mr(),t=xi({select:e=>e.location.pathname.match(/^\/profiles\/(.+)$/)?.[1]}),{profiles:n,canManage:r,refresh:i}=v9(),[a,o]=(0,v.useState)(!1),s=r?(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`New profile`,onClick:()=>o(!0),children:(0,H.jsx)(yx,{className:`size-4`})}):void 0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z7,{section:`profiles`,title:`Profiles`,badge:n.length>0?(0,H.jsx)(`span`,{className:`shrink-0 text-label text-fg-4`,children:n.length}):void 0,actions:s,railActions:s,children:(0,H.jsxs)(Q7,{children:[n.length===0?(0,H.jsx)(bE,{icon:(0,H.jsx)(zy,{}),title:r?`No profiles yet`:`No profiles`,description:r?(0,H.jsxs)(H.Fragment,{children:[`Add one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]}):`This gateway declares none, and this login may not add them.`}):null,n.map(n=>(0,H.jsx)($7,{active:n.name===t,onSelect:()=>void e({to:`/profiles/$profileName`,params:{profileName:n.name}}),title:n.name,status:n.managed?null:(0,H.jsx)(po,{variant:`neutral`,className:`shrink-0`,children:`declared`}),description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(o7,{engine:n.engine??`claude`,model:n.defaults?.model??n.provider?.model,className:`size-3 shrink-0 text-fg-3`}),(0,H.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,H.jsx)(Xie,{open:a,onOpenChange:o,onCreated:t=>{o(!1),i(),e({to:`/profiles/$profileName`,params:{profileName:t}})}})]})}function Qie({sessions:e,onCreated:t}){let n=x9(`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){ZT.error(`Working directory is required`);return}i(!0);try{n.rememberCwd(r),t((await m9().createSession({...n.sessionFields({prompt:e?void 0:n.prompt.trim()||void 0,resume:e?.sessionId,allowBypass:!0}),cwd:r})).id)}catch(e){ZT.error(hk(e,`Failed to create session`))}finally{i(!1)}},d=async()=>{if(!n.cwd.trim()){ZT.error(`Set a working directory first - resumable sessions are listed per project`);return}c(!0);try{o(await m9().listSdkSessions({dir:n.cwd.trim(),limit:20,profile:n.profile||void 0}))}catch(e){ZT.error(hk(e,`Failed to list resumable sessions`))}finally{c(!1)}};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(C9,{form:n,sessions:e,promptLabel:`Initial prompt (optional)`,onProfileChange:()=>o(void 0),extras:(0,H.jsx)(S9,{form:n}),actions:(0,H.jsxs)(uo,{className:`ml-auto`,onClick:()=>void u(),disabled:r,children:[r?(0,H.jsx)(_E,{className:`size-3.5 text-current`}):(0,H.jsx)(yx,{className:`size-4`}),`Create`]})}),l.capabilities.listSessions?(0,H.jsxs)(`div`,{className:`mt-1 border-t border-border pt-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Resume a previous session`}),(0,H.jsxs)(uo,{variant:`ghost`,size:`xs`,onClick:()=>void d(),disabled:s,children:[s?(0,H.jsx)(_E,{className:`size-3 text-current`}):(0,H.jsx)(Lx,{className:`size-3`}),a?`Reload`:`Browse`]})]}),a===void 0?null:a.length===0?(0,H.jsx)(`div`,{className:`py-3 text-center text-body-sm text-fg-4`,children:`No stored sessions for this directory.`}):(0,H.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:a.map(e=>(0,H.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate text-body-sm text-fg-1`,children:e.customTitle??e.summary}),(0,H.jsxs)(`div`,{className:`flex gap-2 font-mono text-label text-fg-4`,children:[e.gitBranch?(0,H.jsx)(`span`,{className:`truncate`,children:e.gitBranch}):null,(0,H.jsx)(`span`,{className:`shrink-0`,children:sN(e.lastModified)})]})]}),(0,H.jsx)(uo,{variant:`outline`,size:`xs`,onClick:()=>void u(e),disabled:r,children:`Resume`})]},e.sessionId))})]}):null]})}function $ie({open:e,onOpenChange:t,sessions:n,onCreated:r}){return(0,H.jsx)(aT,{open:e,onOpenChange:t,children:(0,H.jsxs)(oT,{size:`lg`,children:[(0,H.jsx)(sT,{title:`New session`,description:`Pick a directory and an engine.`}),(0,H.jsx)(cT,{children:(0,H.jsx)(Qie,{sessions:n,onCreated:r})})]})})}function eae(){return(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,H.jsx)(bE,{icon:(0,H.jsx)(T7,{}),title:`No session open`,description:(0,H.jsxs)(H.Fragment,{children:[`Pick one on the left, or start a new one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]})})})}var N9=`workerdeck.view-config`;function tae(){let[e,t]=(0,v.useState)(()=>({...FO,...S(N9,{}),search:``,scoped:!1}));return[e,(0,v.useCallback)(e=>{t(e),C(N9,e)},[])]}function nae(){let e=Mr(),t=xi({select:e=>e.location.pathname.match(/^\/sessions\/[^/]+\/(.+)$/)?.[1]??void 0}),n=jr({strict:!1}).subagent,r=jr({strict:!1}).shell,{snapshots:i,refresh:a}=d9(),o=f9(i),s=Zj(o,L7),c=i.filter(e=>e.error!==void 0),l=R7(),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]=tae(),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(bie),y=(0,v.useMemo)(()=>XO(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)=>{L7(e.hostId)?.killShell(e.info.id,t).then(()=>a()).catch(e=>ZT.error(hk(e,`Kill failed`)))},E=(e,t,n)=>{L7(e.hostId)?.setShellAgentWrite(e.info.id,t,n).then(()=>a()).catch(e=>ZT.error(hk(e,n?`Grant failed`:`Revoke failed`)))},D=(e,t)=>{L7(e.hostId)?.updateSession(e.info.id,{title:t||null}).then(()=>a()).catch(e=>ZT.error(hk(e,`Rename failed`)))},O=()=>{let e=!g;_(e),xie(e),!e&&f.search&&p({...f,search:``})},k=(e,t)=>{L7(e.hostId)?.stopTask(e.info.id,t).then(()=>a()).catch(e=>ZT.error(hk(e,`Stop failed`)))},A=(0,v.useRef)(0),j=(t,n)=>void e({to:`/sessions/$hostId/$sessionId`,params:{hostId:t.hostId,sessionId:t.info.id},search:n.toolUseId?{reveal:n.toolUseId,rn:++A.current}:{}}),M=(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`New session`,onClick:()=>h(!0),children:(0,H.jsx)(yx,{className:`size-4`})});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Z7,{section:`sessions`,title:`Sessions`,railActions:M,actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":g?`Hide search`:`Search sessions`,"aria-pressed":g,onClick:O,children:(0,H.jsx)(Xx,{className:U(`size-3.5`,g&&`text-fg-1`)})}),(0,H.jsx)(Lre,{config:f,onConfigChange:p,rows:o}),(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh`,onClick:()=>void a(),children:(0,H.jsx)(Nx,{className:`size-3.5`})}),M]}),rail:y.map(e=>(0,H.jsxs)(`button`,{type:`button`,title:`${RO(e.info)} - ${e.state}`,"aria-label":RO(e.info),onClick:()=>b(e),className:U(`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,H.jsx)(o7,{engine:e.adapter,model:e.info.model,className:`size-4`}),(0,H.jsx)(s7,{row:e})]},e.info.id)),children:[c.map(({host:e,error:t})=>(0,H.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,H.jsx)(Q7,{children:(0,H.jsx)(Qre,{rows:o,config:f,onConfigChange:p,showControls:!1,showSearch:g,autoFocusSearch:!0,projectIcons:s,activeId:t,activeSubagentId:n,activeShellId:r,onSelect:b,onSelectSubagent:S,onSelectTask:j,onStopTask:k,onSelectShell:w,onKillShell:T,onShellAgentWrite:E,onRename:D,onClearContext:e=>{let t=L7(e.hostId);if(!t)return;let n=t.attach(e.info.id,{reconnect:!1}),r=setTimeout(()=>{n.detach(),ZT.error(`Clear failed - the gateway did not answer`)},5e3);n.on(`attached`,()=>{n.clearContext(),setTimeout(()=>{clearTimeout(r),n.detach(),ZT.success(`Context cleared - the previous conversation stays resumable`),a()},150)})},onDelete:e=>{L7(e.hostId)?.deleteSession(e.info.id).then(()=>a()).catch(e=>ZT.error(hk(e,`Delete failed`)))},emptyState:(0,H.jsx)(bE,{icon:(0,H.jsx)(Zy,{}),title:`No sessions yet`,description:(0,H.jsxs)(H.Fragment,{children:[`Start one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]})})})})]}),(0,H.jsx)($ie,{open:m,onOpenChange:h,sessions:u,onCreated:e=>{h(!1),d(e),a()}})]})}function rae(){let{snapshots:e}=d9(),t=wie(f9(e));(0,v.useEffect)(()=>{document.title=t>0?`(${t}) workerdeck`:`workerdeck`},[t])}var P9=[{id:`sessions`,label:`Sessions`,icon:yS,path:`/sessions`,sidebar:nae},{id:`gateways`,label:`Gateways`,icon:_x,path:`/gateways`,sidebar:jie},{id:`jobs`,label:`Jobs`,icon:sb,path:`/jobs`,sidebar:qie},{id:`profiles`,label:`Profiles`,icon:ZS,path:`/profiles`,sidebar:Zie}],F9=`workerdeck.sidebar-collapsed`;function iae({children:e}){rae();let t=xi({select:e=>e.location.pathname}),n=[...P9].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(F9)===`1`),c=()=>{s(e=>(x(F9,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=>U(`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,H.jsxs)(`div`,{className:`flex h-dvh bg-sidebar`,children:[(0,H.jsxs)(`aside`,{className:U(`flex shrink-0 flex-col gap-1 p-3 transition-[width] duration-150`,o?`w-14 items-center`:`w-52`),children:[(0,H.jsxs)(`div`,{className:U(`flex items-center py-2`,o?`justify-center`:`gap-2 px-2`),children:[(0,H.jsx)(T7,{className:`size-4 shrink-0 text-fg-1`}),!o&&(0,H.jsx)(`span`,{className:`text-body-sm font-semibold tracking-tight text-fg-1`,children:`workerdeck`})]}),(0,H.jsx)(`nav`,{className:U(`mt-1 flex flex-1 flex-col gap-0.5`,o&&`items-center`),children:P9.map(e=>(0,H.jsxs)(Yr,{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,H.jsx)(e.icon,{className:`size-4 shrink-0`}),!o&&e.label]},e.id))}),(0,H.jsxs)(`div`,{className:U(`mt-1 grid place-items-center gap-1`,o?`grid-rows-3`:`grid-cols-3`),children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>a(!0),title:`Settings`,"aria-label":`Settings`,className:l,children:(0,H.jsx)(Eee,{className:`size-4`})}),(0,H.jsx)(d7,{}),(0,H.jsx)(`button`,{type:`button`,onClick:c,title:o?`Expand sidebar`:`Collapse sidebar`,"aria-label":o?`Expand sidebar`:`Collapse sidebar`,className:l,children:o?(0,H.jsx)(tx,{className:`size-4`}):(0,H.jsx)($b,{className:`size-4`})})]})]}),(0,H.jsxs)(`div`,{className:`app-frame frame-shine m-2 ml-0 flex min-w-0 flex-1 overflow-hidden rounded-xl`,children:[r?(0,H.jsx)(r,{},n?.id):null,(0,H.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:e??(0,H.jsx)(di,{})})]}),(0,H.jsx)(sie,{open:i,onOpenChange:a})]})}function I9({crumbs:e,actions:t,children:n}){return(0,H.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border bg-surface px-3`,children:[(0,H.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`flex min-w-0 items-center gap-1`,children:e.map((e,t)=>(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[t>0?(0,H.jsx)(nv,{"aria-hidden":!0,className:`size-3 shrink-0 text-fg-4`}):null,e.to?(0,H.jsx)(Yr,{to:e.to,className:`shrink-0 text-body-sm text-fg-3 outline-none hover:text-fg-1`,children:e.label}):(0,H.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,H.jsx)(`span`,{className:`flex-1`}),t]})}function L9({children:e}){return(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsx)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-5 px-6 py-6`,children:e})})}function R9({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-1.5`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-label font-medium text-fg-3`,children:e}),(0,H.jsx)(`span`,{className:`min-w-0 text-right text-body-sm text-fg-1`,children:t})]})}function aae(){let{hostId:e}=Ar({from:`/gateways/$hostId`}),t=Mr(),{hosts:n,ready:r}=U7(),{snapshots:i}=d9(),[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,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,H.jsx)(I9,{crumbs:[{label:`Gateways`,to:`/gateways`},{label:s.name}],actions:s.implicit?null:(0,H.jsxs)(uo,{variant:`outline`,size:`xs`,onClick:()=>o(!0),children:[(0,H.jsx)(zS,{className:`size-3`}),`Remove`]}),children:(0,H.jsx)(`span`,{className:`min-w-0 truncate font-mono text-label text-fg-4`,title:s.baseUrl,children:s.baseUrl})}),(0,H.jsxs)(L9,{children:[(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Connection`})}),(0,H.jsxs)(_o,{className:`flex flex-col divide-y divide-border`,children:[(0,H.jsx)(R9,{label:`Status`,children:l===`ok`?(0,H.jsx)(po,{variant:`success`,dot:!0,children:`Connected`}):l===`error`?(0,H.jsx)(po,{variant:`danger`,dot:!0,children:`Unreachable`}):(0,H.jsx)(po,{variant:`neutral`,dot:!0,children:`Connecting…`})}),c?.error?(0,H.jsx)(R9,{label:`Last error`,children:(0,H.jsx)(`span`,{className:`text-danger`,children:c.error})}):null,(0,H.jsx)(R9,{label:`Live sessions`,children:c?c.sessions.length:(0,H.jsx)(`span`,{className:`text-fg-4`,children:`-`})}),(0,H.jsx)(R9,{label:`Reachability`,children:z7(s)?`This machine (loopback)`:`Remote`}),(0,H.jsx)(R9,{label:`Credential`,children:s.implicit?(0,H.jsx)(`span`,{className:`text-fg-4`,children:`the login cookie it set - same origin`}):(0,H.jsx)(`span`,{className:`text-fg-4`,children:`an auth key held in this browser`})})]})]}),s.implicit?(0,H.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,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Settings`})}),(0,H.jsx)(_o,{children:(0,H.jsx)(G7,{host:s,onSaved:e=>ZT.success(`Saved ${e.name}`)},s.id)})]}),a?(0,H.jsx)(q7,{host:s,onClose:()=>o(!1),onRemoved:()=>{o(!1),t({to:`/gateways`})}}):null]})]})}function oae(){return(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,H.jsx)(bE,{icon:(0,H.jsx)(_x,{}),title:`No gateway selected`,description:(0,H.jsxs)(H.Fragment,{children:[`Pick one on the left, or add one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]})})})}function sae({files:e,activePath:t,onActivate:n,onClose:r,className:i}){return(0,H.jsx)(MT,{delay:500,closeDelay:0,children:(0,H.jsx)(`div`,{"data-slot":`editor-tabs`,role:`tablist`,"aria-label":`Open files`,className:U(`flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-surface`,i),children:e.map(i=>(0,H.jsx)(cae,{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 cae({file:e,active:t,onActivate:n,onClose:r,onArrow:i}){let a=yM(e),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{t&&o.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t]),(0,H.jsxs)(PT,{side:`bottom`,render:(0,H.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:U(`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,H.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`font-mono break-all`,children:e.path}),e.bytes===void 0?null:(0,H.jsx)(`span`,{className:`text-fg-4`,children:aN(e.bytes)})]}),children:[(0,H.jsx)(`span`,{className:U(`max-w-40 truncate font-mono text-label`,a&&`italic`),children:e.name}),e.status===`error`?(0,H.jsx)(`span`,{className:`shrink-0 text-danger`,children:`!`}):null,(0,H.jsxs)(`button`,{type:`button`,"aria-label":a?`Close ${e.name} (unsaved changes)`:`Close ${e.name}`,onClick:e=>{e.stopPropagation(),r()},className:U(`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,H.jsx)(`span`,{className:U(`block`,a&&`group-hover:hidden`),children:a?(0,H.jsx)(`span`,{className:`block size-3 rounded-full bg-fg-2`}):(0,H.jsx)(hC,{className:`size-3`})}),a?(0,H.jsx)(`span`,{className:`hidden group-hover:block`,children:(0,H.jsx)(hC,{className:`size-3`})}):null]})]})}var z9=12;function lae({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,H.jsxs)(`div`,{"data-slot":`file-tree`,style:a,className:U(`flex min-h-0 min-w-0 flex-col bg-surface`,o),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-2`,children:[t?.available?(0,H.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,H.jsx)(Xx,{className:`absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-fg-4`}),(0,H.jsx)(vo,{value:s,onChange:e=>c(e.target.value),placeholder:`Search files…`,className:`h-7 pr-7 pl-7 text-label`,spellCheck:!1}),d?(0,H.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,H.jsx)(hC,{className:`size-3.5`})}):null]}):(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate px-1 text-label text-fg-4`,children:e.root}),(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh the file tree`,onClick:()=>e.refresh(),children:(0,H.jsx)(Nx,{className:`size-3.5 text-fg-3`})}),i?(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Hide project files`,onClick:i,children:(0,H.jsx)($b,{className:`size-3.5 text-fg-3`})}):null]}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-1 py-1`,children:e.error?(0,H.jsx)(`p`,{className:`px-2 py-3 text-body-sm text-danger`,children:e.error}):d?l===void 0?(0,H.jsx)(`div`,{className:`py-6 text-center`,children:(0,H.jsx)(_E,{className:`size-4 text-fg-4`})}):l.length===0?(0,H.jsx)(`p`,{className:`px-2 py-6 text-center text-body-sm text-fg-4`,children:`No matching files.`}):(0,H.jsx)(`ul`,{children:l.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(B9,{label:uae(e.relative),detail:dae(e.relative),title:e.relative,icon:(0,H.jsx)(ay,{className:`size-3.5 shrink-0 text-fg-4`}),active:e.path===n,onClick:()=>r(e.path)})},e.path))}):e.loading?(0,H.jsx)(`div`,{className:`py-6 text-center`,children:(0,H.jsx)(_E,{className:`size-4 text-fg-4`})}):e.rows.length===0?(0,H.jsx)(`p`,{className:`px-2 py-6 text-center text-body-sm text-fg-4`,children:`This project is empty.`}):(0,H.jsx)(`ul`,{role:`tree`,"aria-label":`Project files`,children:e.rows.map(t=>(0,H.jsxs)(`li`,{role:`treeitem`,"aria-expanded":t.expanded,"aria-level":t.depth+1,children:[(0,H.jsx)(B9,{label:t.entry.name,indent:t.depth,active:t.entry.path===n,icon:t.entry.type===`dir`?t.loading?(0,H.jsx)(_E,{className:`size-3.5 shrink-0 text-fg-4`}):t.expanded?(0,H.jsx)(py,{className:`size-3.5 shrink-0 text-accent`}):(0,H.jsx)(yy,{className:`size-3.5 shrink-0 text-accent`}):(0,H.jsx)(n3,{type:t.entry.type}),chevron:t.entry.type===`dir`?(0,H.jsx)(nv,{className:U(`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,H.jsx)(`p`,{className:`truncate py-0.5 text-label text-fg-4`,style:{paddingLeft:(t.depth+1)*z9+22},children:`More entries than the server will return - use search.`}):null]},t.entry.path))})})]})}function B9({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,H.jsxs)(`button`,{ref:c,type:`button`,onClick:s,title:n??e,style:{paddingLeft:a*z9+4},className:U(`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,H.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center`,children:i}),r,(0,H.jsx)(`span`,{className:`shrink-0 truncate text-label`,children:e}),t?(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label text-fg-4`,children:t}):null]})}function uae(e){return e.slice(e.lastIndexOf(`/`)+1)}function dae(e){let t=e.lastIndexOf(`/`);return t===-1?void 0:e.slice(0,t)}function fae({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=pae(),f=(0,v.useRef)({onChange:n,onSave:r});return f.current={onChange:n,onSave:r},(0,v.useEffect)(()=>{let n=!1;return mae().then(r=>{if(n||!o.current)return;c.current=r;let a=r.editor.create(o.current,{value:t,language:U9(e),readOnly:i,automaticLayout:!0,theme:V9(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,U9(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(V9(d))},[d,l]),(0,H.jsxs)(`div`,{className:U(`relative min-h-0 min-w-0 flex-1`,a),children:[(0,H.jsx)(`div`,{ref:o,className:`absolute inset-0`}),l?null:(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bg`,children:(0,H.jsx)(_E,{className:`size-4 text-fg-4`})})]})}function pae(){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 V9(e){return e===`light`?`wd-light`:`wd-dark`}var H9;function mae(){return H9??=(async()=>{let e=await kM(()=>import(`./vs-B6pYAMqR.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})(),H9}function U9(e){let t=e.slice(e.lastIndexOf(`/`)+1);return hae[t.toLowerCase()]||(gae[t.slice(t.lastIndexOf(`.`)+1).toLowerCase()]??`plaintext`)}var hae={dockerfile:`dockerfile`,makefile:`plaintext`,".gitignore":`plaintext`,".env":`shell`},gae={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 _ae({file:e,canWrite:t,onChange:n,onSave:r,onRevert:i,onReload:a,onOverwrite:o,onDismissConflict:s,className:c}){return e?(0,H.jsxs)(`div`,{"data-slot":`file-viewer`,className:U(`flex min-h-0 min-w-0 flex-1 flex-col bg-bg`,c),children:[e.conflict?(0,H.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,H.jsx)(US,{className:`size-3.5 shrink-0 text-warning`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-warning`,children:`This file changed on disk since you opened it.`}),(0,H.jsx)(uo,{variant:`outline`,size:`xs`,onClick:()=>a?.(e.path),children:`Use the version on disk`}),(0,H.jsx)(uo,{variant:`outline`,size:`xs`,onClick:()=>o?.(e.path),children:`Keep mine`}),(0,H.jsx)(uo,{variant:`ghost`,size:`xs`,onClick:()=>s?.(e.path),children:`Dismiss`})]}):e.saveError?(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-danger/40 bg-danger-bg px-3 py-2`,children:[(0,H.jsx)(US,{className:`size-3.5 shrink-0 text-danger`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-danger`,children:e.saveError}),(0,H.jsx)(uo,{variant:`ghost`,size:`xs`,onClick:()=>s?.(e.path),children:`Dismiss`})]}):null,e.status===`loading`?(0,H.jsx)(W9,{children:(0,H.jsx)(_E,{className:`size-4 text-fg-4`})}):e.status===`error`?(0,H.jsxs)(W9,{children:[(0,H.jsx)(US,{className:`size-4 text-danger`}),(0,H.jsx)(`p`,{className:`text-body-sm text-danger`,children:e.error})]}):e.status===`binary`?(0,H.jsxs)(W9,{children:[(0,H.jsx)(ty,{className:`size-4 text-fg-4`}),(0,H.jsx)(`p`,{className:`text-body-sm text-fg-4`,children:`This file isn’t text.`}),(0,H.jsx)(`p`,{className:`text-label text-fg-4`,children:`It can’t be edited here without corrupting it.`})]}):(0,H.jsx)(fae,{path:e.path,value:bM(e),readOnly:!t,onChange:n?t=>n(e.path,t):void 0,onSave:r?()=>r(e.path):void 0}),e.status===`ready`&&(e.saving||yM(e)||!t)?(0,H.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-border px-3 py-1`,children:e.saving?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_E,{className:`size-3 text-fg-4`}),(0,H.jsx)(`span`,{className:`text-label text-fg-4`,children:`Saving…`})]}):t?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-label text-fg-3`,children:`Unsaved changes`}),(0,H.jsx)(`span`,{className:`flex-1`}),(0,H.jsx)(uo,{variant:`ghost`,size:`xs`,onClick:()=>i?.(e.path),children:`Revert`}),(0,H.jsxs)(uo,{variant:`outline`,size:`xs`,onClick:()=>r?.(e.path),children:[`Save`,(0,H.jsx)(`span`,{className:`ml-1 text-fg-4`,children:`⌘S`})]})]}):(0,H.jsx)(`span`,{className:`text-label text-fg-4`,children:`Read-only - this gateway doesn’t allow writes.`})}):null]}):null}function W9({children:e}){return(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-6`,children:e})}var vae=180,yae=520,bae=220,G9=120;function K9({client:e,sessionId:t,header:n,transcriptVariant:r,transcriptFont:i,affordances: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}=vM(e,t),j=A?.cwd,M=Wj(e,j),N=Hj(e,j),P=TM(e),{canWrite:F}=Uj(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=Sae(),[L,R]=(0,v.useState)(D??!1),[z,ee]=(0,v.useState)(E),te=(0,v.useRef)(O);te.current=O,(0,v.useEffect)(()=>{te.current?.({width:z,collapsed:L})},[z,L]);let[ne,re]=(0,v.useState)(360),ie=P.files.length>0,B=!I,ae=M.available&&!L;(0,v.useEffect)(()=>{B&&R(!0)},[B]);let oe=(0,v.useCallback)(e=>{let t=P.files.find(t=>t.path===e);if(t&&yM(t)){let e=t.name;if(!window.confirm(`${e} has unsaved changes. Close it and lose them?`))return}P.close(e)},[P]),V=(0,v.useRef)(null),se=xae(V);Nre({container:V,onOpen:(0,v.useCallback)(({path:e})=>P.open(Pre(e,j)),[P.open,j]),enabled:M.available,ignore:`.monaco-editor, .xterm`});let ce=Math.max(G9,se-bae),[le,ue]=(0,v.useState)(null),de=n===void 0||le===null?void 0:typeof n==`function`?e=>(0,Ed.createPortal)(n(e),le):(0,Ed.createPortal)(n,le);return(0,H.jsxs)(`div`,{"data-slot":`session-workspace`,className:U(`flex h-full min-h-0 w-full flex-col overflow-hidden bg-bg`,k),children:[n===void 0?null:(0,H.jsx)(`div`,{ref:ue,className:`shrink-0`}),(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[ae?(0,H.jsx)(lae,{tree:M,search:N,activePath:P.activePath,onOpenFile:P.open,onCollapse:()=>R(!0),style:{width:B?Math.min(z,320):z},className:U(`shrink-0 border-r border-border`,B&&`absolute inset-y-0 left-0 z-20 shadow-lg`)}):M.available?(0,H.jsx)(`div`,{className:`flex w-8 shrink-0 flex-col items-center border-r border-border bg-surface pt-1.5`,children:(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Show project files`,onClick:()=>R(!1),children:(0,H.jsx)(tx,{className:`size-4 text-fg-3`})})}):null,ae&&!B?(0,H.jsx)(yE,{orientation:`vertical`,value:z,onValueChange:ee,min:vae,max:yae,defaultValue:E,"aria-label":`Resize the file tree`}):null,(0,H.jsxs)(`div`,{ref:V,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[ie?(0,H.jsxs)(`div`,{className:`flex min-h-0 shrink-0 flex-col overflow-hidden`,style:{height:Math.min(ne,ce||ne)},children:[(0,H.jsx)(sae,{files:P.files,activePath:P.activePath,onActivate:P.activate,onClose:oe}),(0,H.jsx)(_ae,{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,ie?(0,H.jsx)(yE,{orientation:`horizontal`,value:Math.min(ne,ce||ne),onValueChange:re,min:G9,max:ce,"aria-label":`Resize the open file`}):null,(0,H.jsx)(Cre,{client:e,sessionId:t,header:de,transcriptVariant:r,transcriptFont:i,affordances: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`})]}),B&&ae?(0,H.jsx)(`button`,{type:`button`,"aria-label":`Close the file tree`,onClick:()=>R(!0),className:`absolute inset-0 z-10 bg-black/30`}):null]})]})}function xae(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 Sae(){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 q9=`workerdeck.rail`,Cae={width:260,collapsed:!1};function J9(){let e=S(q9,{});return{width:Math.min(520,Math.max(180,Number(e.width)||Cae.width)),collapsed:e.collapsed===!0}}function Y9(e){C(q9,e)}function wae(){let{jobId:e}=Ar({from:`/jobs/$jobId`}),t=Mr(),{jobs:n,refresh:r}=O9(),{snapshots:i}=d9(),a=n.find(t=>t.id===e),o=m9(),s=R7()?.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&&(ZT.error(`That job is no longer in the queue`),t({to:`/jobs`}))},[l,a,t]);let[d]=(0,v.useState)(m7),[f]=(0,v.useState)(g7),[p]=(0,v.useState)(S7),[m]=(0,v.useState)(v7),[h]=(0,v.useState)(J9);if(!a)return null;let g=(0,H.jsx)(X9,{job:a,onChanged:()=>void r()});return!o||!c||!a.sessionId?(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[g,(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center`,children:[(0,H.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,H.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,H.jsx)(K9,{client:o,sessionId:a.sessionId,readOnly:!0,transcriptVariant:d,transcriptFont:f,affordances:{labels:p===`labeled`},fontSize:m,scrubber:!0,stickyPrompt:!0,statusPlacement:`bottom`,defaultRailWidth:h.width,defaultRailCollapsed:h.collapsed,onRailChange:Y9,header:({actions:e})=>(0,H.jsx)(X9,{job:a,onChanged:()=>void r(),actions:e})},a.sessionId)}function X9({job:e,onChanged:t,actions:n}){let r=k9[e.status],i=e.status===`queued`||e.status===`running`||e.status===`parked`,a=async()=>{try{await m9().cancelJob(e.id),t()}catch(e){ZT.error(hk(e,`Cancel failed`))}};return(0,H.jsxs)(I9,{crumbs:[{label:`Jobs`,to:`/jobs`},{label:e.prompt}],actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(po,{variant:`neutral`,className:`shrink-0`,children:`read-only`}),(0,H.jsx)(gE,{value:e.id,"aria-label":`Copy job id`}),i?(0,H.jsxs)(uo,{variant:`outline`,size:`xs`,onClick:()=>void a(),children:[(0,H.jsx)(hC,{className:`size-3`}),`Cancel`]}):null,n]}),children:[(0,H.jsxs)(po,{variant:r.variant,dot:!r.busy,className:`shrink-0`,children:[r.busy?(0,H.jsx)(_E,{className:`size-3 text-current`}):null,r.label]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-x-3 font-mono text-label text-fg-4`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:e.cwd}),e.profile?(0,H.jsxs)(`span`,{className:`shrink-0`,children:[`@`,e.profile]}):null,(0,H.jsx)(`span`,{className:`shrink-0`,children:sN(e.finishedAt??e.startedAt??e.createdAt)}),e.maxAttempts!==void 0&&e.maxAttempts>1?(0,H.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,H.jsxs)(`span`,{className:`shrink-0`,children:[iN(e.usage.tokens),` tok`]}):null,(e.usage.costUsd??e.usage.totalCostUsd)>0?(0,H.jsx)(`span`,{className:`shrink-0`,children:nN(e.usage.costUsd??e.usage.totalCostUsd)}):null,e.error?(0,H.jsx)(`span`,{className:`truncate text-danger`,children:e.error}):null]})]})}function Tae({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=h9(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:j9(d).length>0?j9(d):void 0},i.session={capabilities:p,mcpServers:j9(h).length>0?j9(h):void 0,instructions:_.trim()||void 0}),x(!0);try{t(await m9().updateProfile(e.name,i)),ZT.success(`Profile saved`)}catch(e){ZT.error(hk(e,`Failed to save profile`))}finally{x(!1)}};return(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Edit profile`})}),(0,H.jsxs)(_o,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(M9,{label:`Description`,children:(0,H.jsx)(vo,{value:r,onChange:e=>i(e.target.value)})}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`Default model`,children:C.length>1?(0,H.jsx)(p9,{value:a,onChange:o,models:C}):(0,H.jsx)(vo,{value:a,onChange:e=>o(e.target.value),placeholder:`unset - request / engine default`,className:`font-mono`})}),(0,H.jsx)(M9,{label:`Default permission mode`,children:(0,H.jsx)(E3,{variant:`form`,mode:s,onModeChange:c,modes:S.modes})})]}),n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`Default model id`,children:(0,H.jsx)(vo,{value:l,onChange:e=>u(e.target.value),className:`font-mono`})}),(0,H.jsx)(M9,{label:`Models offered (comma-separated)`,children:(0,H.jsx)(vo,{value:d,onChange:e=>f(e.target.value),className:`font-mono`})})]}),(0,H.jsx)(M9,{label:`Capabilities granted`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 py-1.5`,children:[(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,H.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`]}),A9.map(e=>(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,H.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,H.jsx)(`code`,{className:`font-mono text-label`,children:e})]},e))]})}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`MCP servers (names, comma-separated)`,children:(0,H.jsx)(vo,{value:h,onChange:e=>g(e.target.value),className:`font-mono`})}),(0,H.jsx)(M9,{label:`Instructions`,children:(0,H.jsx)(vo,{value:_,onChange:e=>y(e.target.value)})})]})]}):null,(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.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,H.jsxs)(uo,{onClick:()=>void w(),disabled:b,children:[b?(0,H.jsx)(_E,{className:`size-3.5 text-current`}):(0,H.jsx)(Cee,{className:`size-4`}),`Save`]})]})]})]})}function Eae(e){window.location.href=`vscode://file${e}`}function Dae(){return(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,H.jsx)(bE,{icon:(0,H.jsx)(ZS,{}),title:`No profile selected`,description:`A profile is what a session runs as - its config directory and credentials, or a model provider.`})})}function Z9({items:e,empty:t}){return e.length===0?(0,H.jsx)(`span`,{className:`text-fg-4`,children:t}):(0,H.jsx)(`span`,{className:`flex flex-wrap justify-end gap-1`,children:e.map(e=>(0,H.jsx)(po,{variant:`neutral`,children:e},e))})}function Oae(){let{profileName:e}=Ar({from:`/profiles/$profileName`}),t=Mr(),{refresh:n}=v9(),{ready:r}=U7(),i=zj(async()=>m9()?.getProfile(e),[e,r],{enabled:r,pollMs:6e4}),a=i.data,o=i.error===void 0?void 0:hk(i.error,`Failed to load profile`),s=a?.profile,c=a?.config,l=(0,v.useMemo)(()=>$k(s?.usage),[s?.usage]),u=async()=>{try{await m9().deleteProfile(e),await n(),ZT.success(`Profile '${e}' deleted`),t({to:`/profiles`})}catch(e){ZT.error(hk(e,`Delete failed`))}};return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,H.jsx)(I9,{crumbs:[{label:`Profiles`,to:`/profiles`},{label:e}],actions:(0,H.jsxs)(H.Fragment,{children:[s?.configDir?(0,H.jsxs)(uo,{variant:`outline`,size:`xs`,onClick:()=>Eae(s.configDir),children:[(0,H.jsx)(Cv,{className:`size-3`}),`Open in VSCode`]}):null,s?.managed?(0,H.jsxs)(uo,{variant:`outline`,size:`xs`,onClick:()=>void u(),children:[(0,H.jsx)(zS,{className:`size-3`}),`Delete`]}):null]}),children:s?.description?(0,H.jsx)(`span`,{className:`min-w-0 truncate text-label text-fg-4`,children:s.description}):null}),(0,H.jsxs)(L9,{children:[o?(0,H.jsx)(`div`,{className:`rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger`,children:o}):null,!a&&!o?(0,H.jsx)(_E,{className:`mx-auto size-5 text-fg-4`}):null,s&&c?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Worker defaults`})}),(0,H.jsxs)(_o,{className:`flex flex-col divide-y divide-border`,children:[(0,H.jsx)(R9,{label:`Engine`,children:(0,H.jsx)(po,{variant:`neutral`,children:s.engine??`claude`})}),s.engine===`provider`?(0,H.jsx)(R9,{label:`Provider`,children:(0,H.jsx)(`span`,{className:`font-mono text-label`,children:s.provider?.id})}):(0,H.jsx)(R9,{label:`Config directory`,children:(0,H.jsx)(`span`,{className:`font-mono text-label`,children:s.configDir})}),(0,H.jsx)(R9,{label:`Default model`,children:s.defaults?.model??s.provider?.model??(0,H.jsx)(`span`,{className:`text-fg-4`,children:`request / engine default`})}),(0,H.jsx)(R9,{label:`Default permission mode`,children:s.defaults?.permissionMode??(0,H.jsx)(`span`,{className:`text-fg-4`,children:`request / engine default`})}),s.engine===`provider`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(R9,{label:`Models offered`,children:(0,H.jsx)(Z9,{items:s.provider?.models??[],empty:`the default model only`})}),(0,H.jsx)(R9,{label:`API key variable`,children:s.provider?.apiKeyEnv?(0,H.jsx)(`span`,{className:`font-mono text-label`,children:s.provider.apiKeyEnv}):(0,H.jsx)(`span`,{className:`text-fg-4`,children:`provider SDK default`})})]}):null]})]}),l.length>0?(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Plan usage`})}),(0,H.jsx)(_o,{children:(0,H.jsx)(G5,{windows:l})})]}):null,s.engine===`provider`?(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Session grants`})}),(0,H.jsxs)(_o,{className:`flex flex-col divide-y divide-border`,children:[(0,H.jsx)(R9,{label:`Capabilities`,children:(0,H.jsx)(Z9,{items:s.session?.capabilities??[],empty:`not declared - whatever the server wired`})}),(0,H.jsx)(R9,{label:`MCP servers`,children:(0,H.jsx)(Z9,{items:s.session?.mcpServers??[],empty:`not declared - every connected server`})}),(0,H.jsx)(R9,{label:`Instructions`,children:s.session?.instructions?`${s.session.instructions.length} characters`:(0,H.jsx)(`span`,{className:`text-fg-4`,children:`none`})})]})]}):null,s.engine===`provider`?null:(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Claude Code configuration`})}),(0,H.jsxs)(_o,{className:`flex flex-col divide-y divide-border`,children:[c.settings?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(R9,{label:`Model (settings.json)`,children:c.settings.model??(0,H.jsx)(`span`,{className:`text-fg-4`,children:`not set`})}),(0,H.jsx)(R9,{label:`Default permission mode`,children:c.settings.defaultPermissionMode??(0,H.jsx)(`span`,{className:`text-fg-4`,children:`not set`})}),(0,H.jsx)(R9,{label:`Permission rules`,children:(0,H.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,H.jsx)(R9,{label:`Env vars (names only)`,children:(0,H.jsx)(Z9,{items:c.settings.envKeys??[],empty:`none`})}),(0,H.jsx)(R9,{label:`Hooks`,children:(0,H.jsx)(Z9,{items:c.settings.hooks??[],empty:`none`})})]}):(0,H.jsx)(R9,{label:`settings.json`,children:(0,H.jsx)(`span`,{className:`text-fg-4`,children:`not found`})}),(0,H.jsx)(R9,{label:`User memory (CLAUDE.md)`,children:c.hasUserMemory?`present`:(0,H.jsx)(`span`,{className:`text-fg-4`,children:`none`})}),(0,H.jsx)(R9,{label:`Skills`,children:(0,H.jsx)(Z9,{items:c.skills,empty:`none`})}),(0,H.jsx)(R9,{label:`Agents`,children:(0,H.jsx)(Z9,{items:c.agents,empty:`none`})}),(0,H.jsx)(R9,{label:`Commands`,children:(0,H.jsx)(Z9,{items:c.commands,empty:`none`})})]})]}),s.managed?(0,H.jsx)(Tae,{profile:s,onSaved:e=>i.setData({...a,profile:e})}):null,(0,H.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,H.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]})]})}function kae(){let{hostId:e,sessionId:t}=Ar({from:`/sessions/$hostId/$sessionId`}),{ready:n}=U7(),r=Mr(),i=L7(e);return(0,v.useEffect)(()=>{n&&!i&&(ZT.error(`That gateway is not configured here`),r({to:`/sessions`}))},[n,i,r]),i?(0,H.jsx)(Aae,{hostId:e,sessionId:t,client:i},`${e}:${t}`):null}function Aae({hostId:e,sessionId:t,client:n}){let r=Mr(),{subagent:i,sn:a,reveal:o,rn:s,shell:c,shn:l}=jr({from:`/sessions/$hostId/$sessionId`}),{info:u,error:d}=vM(n,t),f=Cie(e,t),{bookmarks:p,toggle:m}=hM(`${e}:${t}`),[h]=(0,v.useState)(()=>b7()===`on`?Sie(e,t):void 0),[g]=(0,v.useState)(m7),[_]=(0,v.useState)(g7),[y]=(0,v.useState)(S7),[b]=(0,v.useState)(v7),[x]=(0,v.useState)(J9);(0,v.useEffect)(()=>{d&&(ZT.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}=d9(),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,H.jsx)(K9,{client:n,sessionId:t,transcriptVariant:g,transcriptFont:_,affordances:{labels:y===`labeled`},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:Y9,unseen:h,onVitals:e=>{f({itemCount:e.itemCount}),kie()},header:({actions:e})=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border bg-surface px-3 py-2`,children:[(0,H.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,H.jsx)(po,{variant:`neutral`,className:`shrink-0`,children:u.engine}):null,u?.cwd?(0,H.jsx)(`span`,{className:`min-w-0 truncate font-mono text-label text-fg-4`,title:u.cwd,children:u.cwd}):null,(0,H.jsx)(`span`,{className:`flex-1`}),(0,H.jsx)(gE,{value:t,"aria-label":`Copy session id`}),(0,H.jsxs)(qC,{children:[(0,H.jsx)(JC,{render:(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close session`,children:(0,H.jsx)(zS,{className:`size-4 text-fg-3`})})}),(0,H.jsxs)(XC,{children:[(0,H.jsx)(ZC,{children:`Close this session?`}),(0,H.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,H.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,H.jsx)(YC,{render:(0,H.jsx)(uo,{variant:`outline`,children:`Cancel`})}),(0,H.jsx)(uo,{variant:`destructive`,onClick:()=>void E(),children:`Close session`})]})]})]}),e]})},t)}var Q9=ei({component:iae}),jae=Qr({getParentRoute:()=>Q9,path:`/`,beforeLoad:()=>{throw He({to:`/sessions`})}}),Mae=Qr({getParentRoute:()=>Q9,path:`/sessions`,component:eae}),Nae=Qr({getParentRoute:()=>Q9,path:`/sessions/$hostId/$sessionId`,component:kae,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})}),Pae=Qr({getParentRoute:()=>Q9,path:`/gateways`,component:oae}),Fae=Qr({getParentRoute:()=>Q9,path:`/gateways/$hostId`,component:aae}),Iae=Qr({getParentRoute:()=>Q9,path:`/jobs`,component:Gie}),Lae=Qr({getParentRoute:()=>Q9,path:`/jobs/$jobId`,component:wae}),Rae=Qr({getParentRoute:()=>Q9,path:`/profiles`,component:Dae}),zae=Qr({getParentRoute:()=>Q9,path:`/profiles/$profileName`,component:Oae}),Bae=_i({routeTree:Q9.addChildren([jae,Mae,Nae,Pae,Fae,Iae,Lae,Rae,zae]),history:Tt()});function Vae(){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(bi,{router:Bae}),(0,H.jsx)(pE,{})]})}E();var $9=document.getElementById(`root`);if(!$9)throw Error(`Root element #root not found`);(0,y.createRoot)($9).render((0,H.jsx)(v.StrictMode,{children:(0,H.jsx)(Vae,{})}));export{kM as a,s as c,_Q as i,l,$1 as n,Un as o,r0 as r,d as s,KQ as t};
212
+ `)}):null,o?(0,H.jsx)(`div`,{className:`px-3 pb-2 text-label text-fg-4`,children:o}):null]})})}function rre({item:e}){return(0,H.jsxs)(`div`,{"data-slot":`compaction`,className:`flex items-center gap-2 py-1`,children:[(0,H.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,H.jsxs)(`span`,{className:`font-mono text-label ${e.error===void 0?`text-fg-3`:`text-danger`}`,children:[e.pending?`⋯`:`≡`,` `,tN(e)]}),(0,H.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function ire({line:e,since:t,terminal:n}){let r=t===void 0?void 0:sN(t),i=r?`${e} · last here ${r}`:e;return n?(0,H.jsx)(`div`,{"data-slot":`recap`,children:(0,H.jsxs)($N,{glyph:`※`,glyphTone:`faint`,tone:`faint`,children:[`recap: `,i]})}):(0,H.jsxs)(`div`,{"data-slot":`recap`,className:`flex items-center gap-2 py-1`,children:[(0,H.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,H.jsxs)(`span`,{className:`font-mono text-label text-fg-3`,children:[`※ recap: `,i]}),(0,H.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function are({attachments:e,attachmentUrl:t}){return(0,H.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,H.jsx)(D0,{image:{src:n,name:e.name},className:`rounded-md`,children:(0,H.jsx)(`img`,{src:n,alt:e.name,className:`size-20 rounded-md border border-border object-cover`})},e.id):(0,H.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 U5(e,t){return e!==void 0&&t<e}function ore(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 sre(e){return e.text||(e.attachments??[]).map(e=>e.name).join(`, `)}function cre({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,H.jsxs)(`div`,{"data-sticky-lane":i?`terminal`:`cards`,className:`absolute inset-x-0`,style:{top:e,height:t},children:[(0,H.jsx)(`div`,{"data-sticky-headlane":``,"aria-hidden":!0,children:(0,H.jsx)(`div`,{ref:u,"data-sticky-head":``,className:i&&n||void 0,children:c})}),(0,H.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,H.jsx)(`div`,{ref:s,"data-index":o,className:n||void 0,children:l})]})}function lre({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=a8(),[w,T]=(0,v.useState)(null),E=(0,v.useMemo)(()=>e.flatMap((e,t)=>`item`in e&&e.item.kind===`user`&&j3(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&&Vne(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=zne({terminal:r,fontSize:l,lineHeight:u,rowsRef:k}),j=I8({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&&N5(e,t)?A.line:0;return n&&`text`in n&&n.key===`brief`?z8(n.text,A)+r:n&&!(`line`in n)?R8(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(x8(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=Hne({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(P5(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,H.jsxs)(`div`,{ref:k,"data-slot":`transcript-rows`,className:`relative w-full`,style:{height:j.getTotalSize()},children:[(0,H.jsx)(O2,{items:d,children:j.getVirtualItems().map(i=>{let l=e[i.index],u=i.index>0&&(!r||N5(e,i.index))?c.className:void 0,d=r&&i.index<e.length-1&&!N5(e,i.index+1),f=`run`in l?(0,H.jsx)(`div`,{className:U(U5(t,l.index)&&`opacity-45`),children:(0,H.jsx)(j4,{items:l.run})}):`item`in l?(0,H.jsx)(`div`,{className:U(U5(t,l.index)&&`opacity-45`,ore(l.item,o)),children:(0,H.jsx)(ere,{item:l.item,fileUrl:g,attachmentUrl:_,hostImage:y,terminal:r})}):`text`in l&&l.key===`brief`?(0,H.jsx)(R5,{text:l.text,terminal:r}):`line`in l?(0,H.jsx)(ire,{line:l.line,since:n,terminal:r}):(0,H.jsx)(`div`,{className:U(U5(t,l.index)&&`opacity-45`),children:(0,H.jsx)(Une,{block:l,fileUrl:g,onOpenSubagent:s})}),p=(0,H.jsx)(VN,{value:d?`inline`:`below`,children:f});if(a&&`item`in l&&l.item.kind===`user`&&j3(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,H.jsx)(cre,{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?p:sre(l.item),content:p},l.key)}return(0,H.jsx)(`div`,{ref:j.measureElement,"data-index":i.index,className:U(`absolute inset-x-0 top-0`,u),style:{transform:`translateY(${i.start}px)`},children:p},l.key)})}),p&&w?.parentElement?(0,Ed.createPortal)(r?(0,H.jsx)(Pne,{items:d,pendingApprovals:f,recapRow:R,bookmarks:I,frameParentId:o,rowIndexFor:t=>P5(e,t),positionInRow:t=>Rne(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,H.jsx)(Fne,{items:d,pendingApprovals:f,recapItemIndex:L>=0?t:void 0,bookmarks:I,frameParentId:o,interactive:F,onJumpToItem:t=>M(P5(e,t),`start`)}),w.parentElement):null]})}function ure(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 dre(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 fre({active:e,fontSize:t,lineHeight:n,affordances:r,children:i}){return e?(0,H.jsx)(z4,{fontSize:t,lineHeight:n,affordances:r,bleed:`1ch`,className:`term-transcript`,children:i}):(0,H.jsx)(`div`,{"data-cards":``,className:`contents`,children:(0,H.jsx)(zN,{value:RN(r),children:i})})}function pre({state:e,fileUrl:t,attachmentUrl:n,canBrowseFiles:r,hostImage:i,variant:a=`cards`,fontSize:o,lineHeight:s,affordances:c,stickyPrompt:l=!1,scrubber:u,bookmarks:d,sessionNames:f,replaying:p=!1,catchUp:m,jumpToRecapRef:h,repinRef:g,reveal:_,frame:y,onOpenSubagent:b,emptyState:x,className:S}){let C=a===`terminal`,w=(0,v.useMemo)(()=>y?M3(e.items,y.parentToolUseId):e.items,[e.items,y]),T=(0,v.useMemo)(()=>y?e.items.find(e=>e.kind===`tool_call`&&e.id===y.parentToolUseId):void 0,[e.items,y]),E=$M[a],D=ure(e.status),O=!y&&m&&m.from>0&&m.from<e.items.length?m.from:void 0,k=(0,v.useMemo)(()=>O===void 0?void 0:PM(NM(e,O)),[e,O]),A=(0,v.useMemo)(()=>y&&T&&!w.some(e=>e.kind===`user`)?b2(T):void 0,[y,T,w]),j=(0,v.useMemo)(()=>{let e=(e,t)=>I3(w.slice(e,t),e,C);return O===void 0||!k?[...A?[{key:`brief`,text:A}]:[],...e(0,w.length)]:[...e(0,O),{key:`recap`,line:k},...e(O,w.length)]},[w,O,k,C,A]),M=(0,v.useMemo)(()=>e.skills?.map(e=>e.name),[e.skills]);return(0,H.jsx)(ZM,{value:a,children:(0,H.jsx)(I0,{value:i,children:(0,H.jsx)(MN,{names:M,children:(0,H.jsx)(NN,{names:f,children:(0,H.jsxs)(o8,{className:U(p&&`invisible`,S),children:[(0,H.jsx)(s8,{className:U(C&&`gap-0 p-0`),children:(0,H.jsxs)(fre,{active:C,fontSize:o,lineHeight:s,affordances:c,children:[y?T===void 0&&!p?(0,H.jsx)(`div`,{className:U(C?`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:w.length===0&&e.status!==`starting`?x===void 0?(0,H.jsx)(u8,{cwd:e.cwd,hasCommands:!!e.commands?.length,hasSkills:!!e.skills?.some(e=>e.enabled),canBrowseFiles:r}):x:null,y&&T===void 0&&!p?null:(0,H.jsx)(lre,{rows:j,boundary:O,since:m?.since,terminal:C,replaying:p,stickyPrompt:!y&&l,gap:E,fontSize:o,lineHeight:s,items:w,pendingApprovals:e.pendingApprovals,scrubber:u,bookmarks:y?void 0:d,affordances:c,fileUrl:t,attachmentUrl:n,hostImage:i,jumpToRecapRef:h,repinRef:g,reveal:y?void 0:_,frameParentId:y?.parentToolUseId,onOpenSubagent:y?void 0:b}),(y?T!==void 0&&w2(T,w):dre(e))?C?(0,H.jsxs)(H.Fragment,{children:[e.items.length>0?(0,H.jsx)(`div`,{className:`term-blank`,"aria-hidden":!0}):null,(0,H.jsx)(R4,{label:e.status===`starting`?`Starting…`:`Working…`,startedAt:D,tokens:e.contextUsage?.totalTokens})]}):(0,H.jsx)(l8,{label:e.status===`starting`?`Starting session…`:void 0}):null]})}),(0,H.jsx)(c8,{}),p?(0,H.jsx)(`div`,{"data-slot":`transcript-hold`,"aria-hidden":!0,className:`wd-hold-appear visible pointer-events-none absolute inset-0 overflow-hidden`,children:(0,H.jsx)(`div`,{className:U(`mx-auto w-full max-w-[var(--wd-transcript-max-width)]`,!C&&`px-4 py-4`),children:C?(0,H.jsx)(z4,{fontSize:o,lineHeight:s,affordances:!1,bleed:`1ch`,className:`term-transcript`,children:(0,H.jsx)(R4,{label:`Loading…`})}):(0,H.jsx)(l8,{label:`Loading session…`})})}):null]})})})})})}var mre=.02;function hre(e){let t=e.usageByModel??{},n=e.pricing,r=zk(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:Nk(e),usage:t,tokens:Fk(t),costUsd:Pk(e,n)?Rk(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,mre*Math.max(i??0,a??0));return{displayUsd:i??a,computedUsd:i,reportedUsd:a,breakdown:r,rows:o,unpricedShare:r.unpricedShare,showUnpricedWarning:r.unpricedShare>bk,unknownBasisModels:Ik(t),gapUsd:c?s:void 0}}function W5(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 G5({windows:e,now:t,className:n}){let r=W5(t===void 0),i=t??r;return(0,H.jsx)(`div`,{className:U(`flex flex-col gap-5`,n),children:e.map(e=>(0,H.jsx)(gre,{window:e,now:i},e.key))})}function gre({window:e,now:t}){let{key:n,info:r,updatedAt:i,inferredReset:a}=e,o=r.utilization??0,s=Qk(e,t),c=r.resetsAt===void 0?void 0:r.resetsAt*1e3,l=lN(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,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,H.jsx)(`span`,{className:`truncate text-body-sm text-fg-1`,children:cN(n)}),(0,H.jsxs)(`span`,{className:U(`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,H.jsxs)(`div`,{className:`relative mt-2 h-2 rounded-full bg-border`,children:[(0,H.jsx)(`div`,{className:U(`h-full rounded-full`,$4(o),s&&`opacity-40`),style:{width:`${Math.min(100,Math.max(2,o))}%`}}),d===void 0?null:(0,H.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,H.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3 text-label text-fg-4`,children:[c===void 0?null:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,H.jsx)(zx,{className:`size-3`}),` Resets in `,oN(c,t)]}),r.isUsingOverage?(0,H.jsx)(`span`,{className:`text-warning`,children:`overage`}):null,r.status===`rejected`?(0,H.jsx)(`span`,{className:`text-danger`,children:`limit reached`}):null,a?(0,H.jsx)(`span`,{children:`window reset · nothing reported since`}):null,i&&!a?(0,H.jsxs)(`span`,{className:U(s&&`text-warning`),children:[s?`last reported `:``,uN(i,t)]}):null]})]})}function K5(e){return e===`claude`?`Claude Code`:e}function q5({label:e,value:t,tone:n}){return(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,H.jsx)(`span`,{className:n===`muted`?`text-label text-fg-4`:`text-label text-fg-3`,children:e}),(0,H.jsx)(`span`,{className:`font-mono text-body-sm ${n===`muted`?`text-fg-4`:`text-fg-1`}`,children:t})]})}function _re({cost:e,engine:t}){let{breakdown:n,rows:r}=e;return r.length===0?(0,H.jsx)(q5,{label:`This session has cost`,value:nN(e.displayUsd)}):(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,H.jsx)(`span`,{className:`text-label text-fg-3`,children:`This session has cost`}),(0,H.jsx)(`span`,{className:`font-mono text-body text-fg-1`,children:nN(e.displayUsd)})]}),(0,H.jsxs)(`div`,{className:`space-y-1 border-t border-border pt-2`,children:[(0,H.jsx)(q5,{label:`input`,value:nN(n.input),tone:`muted`}),(0,H.jsx)(q5,{label:`output`,value:nN(n.output),tone:`muted`}),(0,H.jsx)(q5,{label:`cache write`,value:nN(n.cacheWrite),tone:`muted`}),(0,H.jsx)(q5,{label:`cache read`,value:nN(n.cacheRead),tone:`muted`})]}),(0,H.jsx)(`div`,{className:`space-y-1 border-t border-border pt-2`,children:r.map(e=>(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,H.jsx)(`span`,{className:`truncate text-label text-fg-4`,children:e.model}),(0,H.jsxs)(`span`,{className:`shrink-0 font-mono text-label text-fg-4`,children:[iN(e.tokens),` · `,e.costUsd===void 0?`no rate`:nN(e.costUsd)]})]},e.model))}),e.showUnpricedWarning?(0,H.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,H.jsxs)(`p`,{className:`text-label text-warning`,children:[K5(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,H.jsxs)(`p`,{className:`text-label text-fg-4`,children:[K5(t),` reports `,nN(e.reportedUsd),` for the same tokens.`]})]})}function vre({spend:e}){let{subscription:t}=e;return(0,H.jsxs)(`div`,{className:`mt-4 space-y-1 border-t border-border pt-3`,children:[(0,H.jsx)(q5,{label:`This profile, last 7 days`,value:nN(e.weekUsd)}),(0,H.jsx)(q5,{label:`Last 30 days`,value:nN(e.monthUsd),tone:`muted`}),t?(0,H.jsxs)(`p`,{className:`pt-1 text-label text-fg-4`,children:[yre(t.ratio),` the `,nN(t.weeklyShareUsd),` weekly share of your`,` `,nN(t.monthlyUsd),` a month. A subscription is a flat fee, so this is leverage, not a bill.`]}):null]})}function yre(e){return e>=10?`${Math.round(e)}x`:`${e.toFixed(1)}x`}function bre({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=W5(l),p=hre({costUsd:i,totalCostUsd:r,usageByModel:a,pricing:o}),m=Mk(f);return(0,H.jsx)(aT,{open:l,onOpenChange:u,children:(0,H.jsxs)(oT,{className:d,children:[(0,H.jsx)(sT,{title:`Usage`,description:K5(n),actions:t?(0,H.jsx)(po,{variant:`accent`,className:`mt-0.5 shrink-0 capitalize`,children:t}):null}),(0,H.jsxs)(cT,{children:[e.length===0?(0,H.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,H.jsx)(G5,{windows:e,now:f}),(0,H.jsx)(`div`,{className:`mt-5 border-t border-border pt-3`,children:(0,H.jsx)(_re,{cost:p,engine:n})}),s?(0,H.jsx)(vre,{spend:s}):null,(0,H.jsx)(`p`,{className:`mt-3 text-label text-fg-4`,children:m?`${yk} ${m}`:yk}),c?(0,H.jsxs)(`p`,{className:`mt-2 text-label text-fg-4`,children:[`Updated `,uN(c,f)]}):null]})]})})}var xre=[`button`,`a`,`input`,`textarea`,`select`,`summary`,`img`,`[contenteditable="true"]`,`[role="button"]`,`[role="menuitem"]`,`[role="checkbox"]`,`[role="radio"]`,`[role="tab"]`].join(`,`),Sre=[{panel:`context`,label:`Context`,Icon:dee},{panel:`usage`,label:`Usage`,Icon:Cy},{panel:`info`,label:`Session info`,Icon:Uy},{panel:`mcp`,label:`MCP servers`,Icon:_x},{panel:`skills`,label:`Skills`,Icon:lS},{panel:`files`,label:`Project files`,Icon:_y}];function Cre({client:e,sessionId:t,header:n,panelSurface:r=`internal`,statusSurface:i=`internal`,statusPlacement:a=`top`,onOpenPanel:o,onVitals:s,transcriptVariant:c=`cards`,transcriptFont:l=`sans`,affordances:u,terminalMetrics:d,scrubber:f=!1,bookmarks:p,peerMentions:m=!0,onToggleBookmark:h,reveal:g,subagents:_,shells:y,openSubagent:b,onSubagentChange:x,openShell:S,onShellChange:C,stickyPrompt:w=!1,controlsSurface:T=`internal`,onControls:E,focusComposerOnClick:D=!1,unseen:O,readOnly:k=!1,approvalPrompts:A,toolHost:j,clientTools:M,cacheTranscript:N,emptyState:P,onLinkClick:F,onOpenFile:I,fontSize:L,className:R}){let z={fontSize:d?.fontSize??L,lineHeight:d?.lineHeight??(L===void 0?void 0:Math.round(18/13*L))},ee=r===`external`,te=i===`external`,ne=T===`status`&&!te,re=T===`external`||ne,[ie,B]=(0,v.useState)(void 0),[ae,oe]=(0,v.useState)(),{state:V,connection:se,replaying:ce,protocolMismatch:le,shell:ue,pricing:de,models:fe,effectiveModel:pe,handle:me,send:he,runShell:ge,approve:_e,deny:ve,interrupt:ye,clearContext:be,setModel:xe,setPermissionMode:Se,reconnectNow:Ce,loadFullResult:we,loadShellOutput:Te,verifyShell:Ee,killShell:De,setShellAgentWrite:Oe}=dj(e,t,{onProtocolError:B,cacheTranscript:N}),{shellId:ke,enterShell:Ae,leaveShell:je,returnReveal:Me,shell:Ne,label:Pe}=J3({sessionId:t,items:V.items,session:V.session,shells:y,reveal:g,openShell:S,onShellChange:C}),Fe=V.session?.shellAgentWrite===void 0?void 0:Oe,Ie=(0,v.useMemo)(()=>({loadOutput:Te,verify:Ee,kill:De,open:Ae,agentWrite:Fe}),[Te,Ee,De,Ae,Fe]);(0,v.useEffect)(()=>B(void 0),[t]);let{subagentId:Le,enterSubagent:Re,leaveSubagent:ze,returnReveal:Be,frameItems:Ve,task:He,fallbackLabel:Ue}=V3({sessionId:t,items:V.items,session:V.session,reveal:g,openSubagent:b,onSubagentChange:x}),We=(0,v.useMemo)(()=>Be&&Me?Be.nonce>=Me.nonce?Be:Me:Be??Me,[Be,Me]),{mark:Ge,dismiss:Ke}=M6(t,O),qe=Ge?Math.max(0,V.items.length-Ge.itemCount):0,Je=(0,v.useCallback)(e=>{ee?o?.(e):oe(e)},[ee,o]);(0,v.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&Ce()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Ce]),MM(me,j===!1?{enabled:!1}:M?{...j,clientTools:{...j?.clientTools,...M}}:j);let Ye=c===`terminal`,Xe=V.capabilities,{usage:Ze,spend:Qe}=_M(e,V.session?.profile,{enabled:Xe.rateLimits}),$e=(0,v.useMemo)(()=>Xk({rateLimits:V.rateLimits,updatedAt:V.rateLimitsUpdatedAt},Ze),[V.rateLimits,V.rateLimitsUpdatedAt,Ze]),et=(0,v.useMemo)(()=>Object.keys($e).length>0?eA($e):void 0,[$e]),tt=(0,v.useMemo)(()=>{let e=Object.values($e).map(e=>e.updatedAt);return e.length>0?Math.max(...e):void 0},[$e]),nt=(0,v.useMemo)(()=>dk({checklist:V.checklist,subagents:_??V.session?.subagents}),[V.checklist,_,V.session?.subagents]),rt=fe.length>0,it=(0,v.useMemo)(()=>YM({capabilities:Xe,hasModels:rt,setModel:xe,setPermissionMode:Se,clearContext:be,openPanel:Je}),[Xe,rt,Je,be,xe,Se]),at=(0,v.useMemo)(()=>JM(HM({commands:Xe.slashCommands?V.commands:void 0,clientCommands:it,skills:Xe.skillsList?V.skills:void 0})),[Xe.slashCommands,Xe.skillsList,V.commands,V.skills,it]),ot=(0,v.useRef)(s);ot.current=s;let st=pe??V.model,ct=(0,v.useMemo)(()=>T3(Xe.permissionModes,V.session?.canBypassPermissions),[Xe.permissionModes,V.session?.canBypassPermissions]),lt={status:V.status,connection:se,engine:V.engine,capabilities:V.capabilities,model:st,models:fe,permissionMode:V.permissionMode,permissionModes:ct,skills:V.skills,composerCommands:at,cwd:V.cwd,contextUsage:V.contextUsage,tasks:nt,rateLimits:et,rateLimitsUpdatedAt:tt,itemCount:V.items.length,totalCostUsd:V.totalCostUsd},ut=(0,v.useRef)(void 0);(0,v.useEffect)(()=>{ut.current&&Tre(ut.current,lt)||(ut.current=lt,ot.current?.(lt))});let dt=(0,v.useRef)(E);dt.current=E;let ft=(0,v.useRef)({setModel:xe,setPermissionMode:Se,interrupt:ye});ft.current={setModel:xe,setPermissionMode:Se,interrupt:ye};let pt=(0,v.useRef)({setModel:e=>ft.current.setModel(e),setPermissionMode:e=>ft.current.setPermissionMode(e),interrupt:()=>ft.current.interrupt(),focusComposer:()=>Et.current?.focus(),insertComposerText:e=>Et.current?.insertText(e)});(0,v.useEffect)(()=>{let e=dt.current;return e?.(pt.current),()=>e?.(void 0)},[t]);let mt=(0,v.useMemo)(()=>new Set(p??[]),[p]),ht=(0,v.useMemo)(()=>h?{has:e=>mt.has(e),toggle:h}:void 0,[mt,h]),gt=V.status===`running`||V.status===`awaiting_approval`,_t=V.status===`failed`||V.status===`closed`,vt=Aj(e,t,{capabilities:Xe,engine:V.engine}),yt=Hj(e,V.cwd),bt=qj(e,t,m),xt=gM(e,t),St=(0,v.useCallback)((e,t)=>yt.search(e,{...t,limit:8}),[yt.search]),Ct=(0,v.useMemo)(()=>$k($e),[$e]),wt=P6(e,t,V.producedFiles),Tt=z0(e,t),Et=(0,v.useRef)(null),Dt=(0,v.useRef)(null),Ot=(0,v.useRef)(null),kt=(e,t)=>{if(t.length===0){let t=qM(e,it);if(t&&t.command.run(t.args))return}Ke(),Ot.current?.(),he(e,t)},At={context:Xe.contextUsage,usage:Xe.rateLimits,info:!0,mcp:Xe.mcpStatus,skills:Xe.skillsList,files:yt.available},jt=(0,H.jsxs)(Mw,{children:[(0,H.jsx)(Nw,{render:(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Session actions`,children:(0,H.jsx)(qv,{className:`size-4`})})}),(0,H.jsx)(Pw,{children:Sre.filter(e=>At[e.panel]).map(({panel:e,label:t,Icon:n})=>(0,H.jsxs)(Fw,{onClick:()=>Je(e),children:[(0,H.jsx)(n,{className:`size-3.5 text-fg-3`}),` `,t]},e))})]}),Mt=ee?null:jt,Nt=e=>({open:ae===e,onOpenChange:t=>oe(t?e:void 0)}),Pt=typeof n==`function`,Ft=(0,H.jsxs)(H.Fragment,{children:[fe.length?(0,H.jsx)(S3,{models:fe,model:pe,onModelChange:xe,disabled:_t,className:ne?`h-5`:void 0}):null,V.permissionMode?(0,H.jsx)(E3,{mode:V.permissionMode,onModeChange:Se,modes:Xe.permissionModes,canBypass:V.session?.canBypassPermissions,disabled:_t,className:ne?`h-5`:void 0}):null]}),It=te?null:(0,H.jsx)(K6,{state:V,rateLimits:et,connection:se,placement:a,controls:ne&&!k?Ft:void 0,onOpenStatus:ee&&!o?void 0:()=>Je(`info`),onOpenContext:ee&&!o?void 0:()=>Je(`context`),onOpenUsage:ee&&!o?void 0:()=>Je(`usage`),actions:Pt?void 0:Mt}),Lt=(0,v.useMemo)(()=>I?{cwd:V.cwd,open:I}:void 0,[I,V.cwd]),Rt=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!F)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&&F(n)&&(e.preventDefault(),e.stopPropagation())};return e.addEventListener(`click`,t,!0),()=>e.removeEventListener(`click`,t,!0)},[F]),(0,H.jsx)(j6,{variant:c,fileLinks:Lt,loadFullResult:we,shellActions:Ie,toolTitles:V.toolTitles,resultImages:Tt,children:(0,H.jsx)(`div`,{ref:Rt,"data-slot":`session-panel`,"data-agent-font":l,onClick:e=>{D&&!k&&(e.target?.closest(xre)||window.getSelection()?.isCollapsed!==!1&&Et.current?.focus())},className:U(`relative flex h-full min-h-0 flex-col overflow-hidden bg-bg`,R),style:L===void 0?void 0:{"--wd-font-size":`${Math.round(L)}px`},children:(0,H.jsxs)(E0,{children:[Pt?n({actions:Mt}):n,a===`top`?It:null,le===void 0?null:(0,H.jsxs)(J5,{level:`warning`,children:[`Server speaks protocol v`,le,`, this build renders v`,1,`. Some events may not render.`]}),ie?(0,H.jsx)(J5,{level:`error`,onDismiss:()=>B(void 0),children:ie}):null,ke===void 0?null:(0,H.jsx)(H3,{shell:Ne,label:Pe,onBack:je,onKill:()=>void De(ke),onAgentWrite:Fe?e=>void Fe(ke,e):void 0,terminal:Ye,...z}),ke===void 0&&Le!==void 0?(0,H.jsx)(A3,{task:He,items:Ve,label:Ue,onBack:ze,terminal:Ye,...z}):null,ke===void 0?(0,H.jsx)(GN,{value:ht,children:(0,H.jsx)(pre,{state:V,fileUrl:t?n=>e.sessionFileUrl(t,n):void 0,attachmentUrl:t?n=>e.attachmentUrl(t,n):void 0,canBrowseFiles:yt.available,sessionNames:bt.names,hostImage:wt,variant:c,...z,affordances:u,stickyPrompt:w,scrubber:f,bookmarks:p,replaying:ce,catchUp:Ge&&qe>0?{from:Ge.itemCount,since:Ge.since}:void 0,reveal:We??g,frame:Le===void 0?void 0:{parentToolUseId:Le},onOpenSubagent:Re,emptyState:P,jumpToRecapRef:Dt,repinRef:Ot},Le??`session`)}):(0,H.jsx)(U3,{handle:me,shellId:ke,fontSize:z.fontSize},ke),Ge&&qe>0&&!ce&&Le===void 0&&ke===void 0?(0,H.jsx)(wre,{count:qe,since:Ge.since,terminal:Ye,onJump:()=>Dt.current?.(),onDismiss:Ke}):null,!k&&Xe.interactiveApprovals&&V.pendingApprovals.length>0?(0,H.jsx)(k6,{requests:V.pendingApprovals,terminal:Ye,...z,affordances:u,hostPrompts:A,onApprove:_e,onDeny:ve}):null,k||Le!==void 0||ke!==void 0?null:(0,H.jsx)(H.Fragment,{children:(0,H.jsx)(H4,{ref:Et,onSend:kt,onInterrupt:ye,busy:gt,disabled:_t||!t,commands:Xe.slashCommands?V.commands:void 0,skills:Xe.skillsList?V.skills:void 0,clientCommands:it,attachments:vt,draft:xt,onSearchFiles:yt.available?St:void 0,peers:bt.peers,onShellCommand:ue?ge:void 0,layout:re?`inline`:`stacked`,toolbar:re?void 0:Ft,...z,affordances:u})}),a===`bottom`?It:null,ee?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(L6,{state:V,client:e,sessionId:t,...Nt(`info`)}),(0,H.jsx)(e3,{usage:V.contextUsage,engine:V.engine??`claude`,...Nt(`context`)}),(0,H.jsx)(bre,{rateLimits:Ct,subscriptionType:V.subscriptionType,engine:V.engine??`claude`,totalCostUsd:V.totalCostUsd,costUsd:V.costUsd,usageByModel:V.usageByModel,pricing:de,spend:Qe,updatedAt:tt,...Nt(`usage`)}),(0,H.jsx)(a3,{client:e,sessionId:t,canManageServers:Xe.mcpServerActions,...Nt(`mcp`)}),(0,H.jsx)(m3,{skills:V.skills,...Nt(`skills`),onUse:e=>Et.current?.insertText(VM(e))}),(0,H.jsx)(r3,{client:e,cwd:V.cwd,...Nt(`files`)})]})]})})})}function wre({count:e,since:t,terminal:n,onJump:r,onDismiss:i}){return(0,H.jsx)(`div`,{className:`px-3 pb-1`,children:(0,H.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,H.jsx)(`span`,{"aria-hidden":!0,className:U(`select-none`,n?`text-fg-3`:`text-accent`),children:`※`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e,` new `,e===1?`row`:`rows`,t===void 0?``:` since you were last here`]}),(0,H.jsx)(`button`,{type:`button`,onClick:r,className:`shrink-0 underline-offset-2 hover:text-fg-1 hover:underline`,children:`jump`}),(0,H.jsx)(`button`,{type:`button`,onClick:i,className:`shrink-0 underline-offset-2 hover:text-fg-1 hover:underline`,children:`dismiss`})]})})}function Tre(e,t){return Object.keys(t).every(n=>Object.is(e[n],t[n]))}function J5({level:e,onDismiss:t,children:n}){return(0,H.jsx)(`div`,{className:`px-3 pt-2`,children:(0,H.jsxs)(`div`,{role:`alert`,className:U(`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,H.jsx)(US,{className:`mt-0.5 size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:n}),t?(0,H.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Dismiss`,className:`shrink-0 opacity-70 transition-opacity hover:opacity-100`,children:(0,H.jsx)(hC,{className:`size-3.5`})}):null]})})}var Y5=`[^\\s:'"\`()\\[\\]{}<>|]+`,Ere=RegExp(`(?:^|[\\s'"\`([{<@,])((?:\\.\\.?)?(?:/${Y5})+|[^\\s:'"\`()\\[\\]{}<>|@,]+(?:/${Y5})+)(?::(\\d+))?`),Dre=/^([\w.@-]+\.[A-Za-z0-9]{1,10})(?::(\d+))?$/,Ore=/[.,;:!?)\]}'"`]+$/,kre=/\.[A-Za-z0-9]{1,10}$/;function Are(e,t=!1){let n=e??``,r=Ere.exec(n);if(!r)return t?jre(n):void 0;let i=r[1].replace(Ore,``);if(i.includes(`/`)&&!i.endsWith(`/`)&&(i.startsWith(`/`)||i.startsWith(`./`)||i.startsWith(`../`)||kre.test(i)))return{path:i,line:r[2]?Number(r[2]):void 0,length:i.length+(r[2]?r[2].length+1:0)}}function jre(e){let t=Dre.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 X5=`wd-path-link`,Mre=.6;function Z5(e){if(!e)return;let t=e.closest(`code`)!==null,n=e.textContent?.trim()??``,r=Are(n,t);if(r&&!(!t&&r.length<n.length*Mre))return{path:r.path,line:r.line}}function Nre({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(X5),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=Z5(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)&&Z5(t)&&(o=t,t.classList.add(X5)))},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 Pre(e,t){return s0(e,t)?.path??e}var Fre={anchor:see,atom:l_,beaker:p_,bike:__,binary:y_,blocks:x_,bot:T_,box:D_,brain:k_,briefcase:j_,brush:N_,bug:F_,"building-2":L_,cable:z_,camera:U_,car:G_,cat:q_,"circuit-board":hv,cloud:xv,code:Cv,coffee:Tv,cog:Dv,compass:kv,container:jv,cpu:Fv,"credit-card":Lv,database:zv,diamond:Vv,dog:Uv,feather:Zv,film:sy,flame:ly,"flask-conical":dy,folder:yy,"gamepad-2":mee,gauge:Cy,gem:hee,ghost:gee,gift:_ee,"git-branch":vee,globe:ky,"graduation-cap":yee,hammer:bee,hexagon:Fy,house:Ly,image:Vy,key:Gy,landmark:qy,laptop:Yy,layers:Zy,leaf:$y,library:tb,lightbulb:rb,lock:pb,mail:hb,map:_b,"message-circle":Tb,mic:kb,monitor:Nb,moon:Fb,mountain:Lb,music:zb,network:Vb,newspaper:Ub,notebook:Gb,orbit:qb,package:Yb,palette:Zb,"pen-tool":ax,phone:dx,"piggy-bank":px,plane:hx,plug:_x,puzzle:Tx,radar:Dx,radio:kx,receipt:jx,rocket:Fx,ruler:xee,satellite:See,scale:wee,scissors:Tee,server:Qx,shield:Oee,ship:kee,"shopping-cart":Aee,signal:jee,smartphone:sS,sparkles:lS,sprout:dS,square:xS,star:CS,sun:TS,table:DS,tag:kS,target:NS,telescope:jS,terminal:FS,"test-tube":LS,"tree-pine":VS,trophy:GS,truck:qS,umbrella:YS,users:$S,wallet:tC,wand:rC,waves:aC,webhook:sC,wifi:dC,wrench:pC,zap:_C};function Q5({icon:e,src:t,name:n,className:r}){if(!e)return null;if(e.type===`image`)return t?(0,H.jsx)(`img`,{src:t,alt:``,"aria-hidden":!0,title:n,className:U(`inline-block size-3 shrink-0 object-contain`,r)}):null;let i=Fre[e.name]??yy;return(0,H.jsx)(i,{className:U(`inline-block size-3 shrink-0`,r)})}var Ire=[{value:`all`,label:`All`},{value:`active`,label:`Active`},{value:`none`,label:`Hide`}];function $5({config:e,onConfigChange:t,rows:n,scope:r,gateways:i,className:a}){let o=(0,v.useMemo)(()=>IO(n),[n]),s=(0,v.useMemo)(()=>LO(n),[n]),c=(0,v.useMemo)(()=>{if(i)return i;let e=new Map;for(let t of n)e.set(t.hostId,t.hostName);return[...e].map(([e,t])=>({id:e,name:t}))},[n,i]),l=n=>t({...e,...n});return(0,H.jsxs)(`div`,{"data-slot":`session-filters`,className:U(`flex flex-col gap-3`,a),children:[(0,H.jsxs)(t7,{title:`Filter`,children:[r?(0,H.jsx)(n7,{label:`Scope`,children:(0,H.jsx)(TC,{className:`w-full min-w-0`,label:`Scope`,value:e.scoped?`scoped`:`all`,options:[{value:`scoped`,label:r.label},{value:`all`,label:`All folders`}],onChange:e=>l({scoped:e===`scoped`})})}):null,(0,H.jsx)(n7,{label:`State`,children:(0,H.jsx)(r7,{label:`State`,value:e.states,options:OO.map(e=>({value:e,label:kO[e]})),onChange:e=>l({states:e})})}),o.length>1?(0,H.jsx)(n7,{label:`Engine`,children:(0,H.jsx)(r7,{label:`Engine`,value:e.adapters,options:o.map(e=>({value:e,label:e})),onChange:e=>l({adapters:e})})}):null,c.length>1?(0,H.jsx)(n7,{label:`Gateway`,children:(0,H.jsx)(r7,{label:`Gateway`,value:e.gateways,options:c.map(e=>({value:e.id,label:e.name})),onChange:e=>l({gateways:e})})}):null,s.length>1?(0,H.jsx)(n7,{label:`Project`,children:(0,H.jsx)(r7,{label:`Project`,value:e.projects??[],options:s.map(e=>({value:e.key,label:e.label})),onChange:e=>l({projects:e})})}):null]}),(0,H.jsxs)(t7,{title:`Layout`,children:[(0,H.jsx)(n7,{label:`Group`,children:(0,H.jsx)(TC,{className:`w-full min-w-0`,label:`Group`,value:e.groupBy,options:[{value:`none`,label:`No grouping`},{value:`state`,label:`By state`},{value:`adapter`,label:`By engine`},...s.length>1?[{value:`project`,label:`By project`}]:[],...c.length>1?[{value:`gateway`,label:`By gateway`}]:[]],onChange:e=>l({groupBy:e})})}),(0,H.jsx)(n7,{label:`Sort`,children:(0,H.jsx)(TC,{className:`w-full min-w-0`,label:`Sort`,value:e.sortBy,options:[{value:`recent`,label:`Recent`},{value:`name`,label:`Name`},{value:`state`,label:`State`},...s.length>1?[{value:`project`,label:`Project`}]:[],...c.length>1?[{value:`gateway`,label:`Gateway`}]:[]],onChange:e=>l({sortBy:e})})})]}),(0,H.jsxs)(t7,{title:`Show under each session`,children:[(0,H.jsx)(n7,{label:`Agents`,children:(0,H.jsx)(e7,{label:`Agents`,value:e.subagents,onChange:e=>l({subagents:e})})}),(0,H.jsx)(n7,{label:`Shells`,children:(0,H.jsx)(e7,{label:`Shells`,value:e.shells??`active`,onChange:e=>l({shells:e})})}),(0,H.jsx)(n7,{label:`Tasks`,children:(0,H.jsx)(e7,{label:`Tasks`,value:e.tasks??`active`,onChange:e=>l({tasks:e})})})]})]})}function Lre({open:e,onOpenChange:t,className:n,...r}){let i=ak(r.config),a=i>0||ok(r.config);return(0,H.jsxs)(nT,{open:e,onOpenChange:t,children:[(0,H.jsx)(rT,{render:(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":i>0?`Filters (${i} active)`:`Filters`,title:i>0?`${i} filter${i===1?``:`s`} active`:`Filters`,className:n,children:(0,H.jsx)(pee,{className:U(`size-3.5`,a&&`fill-current text-fg-1`)})})}),(0,H.jsx)(iT,{className:`w-80`,children:(0,H.jsx)($5,{...r})})]})}function e7({label:e,value:t,onChange:n}){return(0,H.jsx)(`div`,{role:`radiogroup`,"aria-label":e,className:`flex w-full rounded-md border border-border p-px`,children:Ire.map(e=>(0,H.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t,onClick:()=>n(e.value),className:U(`min-w-0 flex-1 truncate rounded-[4px] px-1.5 py-0.5 text-label outline-none transition-colors`,`focus-visible:ring-2 focus-visible:ring-ring`,e.value===t?`bg-row-selected text-fg-1`:`text-fg-3 hover:bg-row-hover hover:text-fg-1`),children:e.label},e.value))})}function t7({title:e,children:t}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`div`,{className:`text-label font-medium uppercase tracking-wide text-fg-4`,children:e}),t]})}function n7({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{"aria-hidden":!0,className:`w-16 shrink-0 truncate text-label text-fg-3`,children:e}),(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:t})]})}function r7({label:e,value:t,options:n,onChange:r}){return(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsxs)(yC,{multiple:!0,value:t,onValueChange:e=>r(e),children:[(0,H.jsx)(SC,{"aria-label":e,className:`min-w-0 flex-1`,children:(0,H.jsx)(bC,{children:t.length===0?`All`:t.length===1?n.find(e=>e.value===t[0])?.label??`All`:`${t.length} selected`})}),(0,H.jsx)(CC,{children:n.map(e=>(0,H.jsx)(wC,{value:e.value,children:(0,H.jsx)(xC,{children:e.label})},e.value))})]}),t.length>0?(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clear ${e}`,onClick:()=>r([]),children:(0,H.jsx)(hC,{className:`size-3 text-fg-4`})}):null]})}function i7({usage:e,engine:t,size:n=11,className:r}){if(e===void 0)return null;let i=X4(t),a=`Context ${e.percentage.toFixed(0)}% · ${iN(e.totalTokens)} / ${iN(e.maxTokens)}`,o=U(`shrink-0 leading-none`,Q4(e.percentage),r),s=(0,H.jsx)(SE,{value:e.percentage,size:n,strokeWidth:2});return i?(0,H.jsx)(PT,{render:(0,H.jsx)(`span`,{className:o}),content:(0,H.jsxs)(`div`,{className:`flex max-w-64 flex-col gap-1 py-0.5`,children:[(0,H.jsx)(`span`,{className:`font-mono text-fg-2`,children:a}),(0,H.jsx)(`span`,{className:`text-fg-3`,children:i.summary}),(0,H.jsx)(`span`,{className:`text-fg-3`,children:i.hint})]}),children:s}):(0,H.jsx)(`span`,{title:a,className:o,children:s})}var Rre={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 a7(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 zre={claude:`text-vendor-claude`,codex:`text-vendor-openai`},Bre={claude:`text-vendor-claude`};function Vre(e,t){return zre[a7(e,t)??``]??`text-fg-3`}function Hre(e,t){return Bre[a7(e,t)??``]??`text-fg-3`}function o7({engine:e,model:t,className:n}){let r=Rre[a7(e,t)??``];return r?(0,H.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,fillRule:`evenodd`,role:`img`,"aria-label":r.title,className:U(`size-3 shrink-0 text-fg-3`,n),children:[(0,H.jsx)(`title`,{children:r.title}),(0,H.jsx)(`path`,{d:r.d})]}):(0,H.jsx)(`span`,{"aria-hidden":!0,title:e,className:U(`shrink-0 text-fg-3`,n),children:`·`})}function s7({row:e,className:t}){let{info:n}=e,r=U(`size-4 shrink-0`,t);if(e.state===`attention`)return(0,H.jsx)(h_,{className:U(r,`animate-pulse text-warning`)});if(e.state===`working`)return(0,H.jsx)(_E,{className:U(r,`text-info`)});switch(n.status){case`failed`:return(0,H.jsx)(av,{className:U(r,`text-danger`)});case`closed`:return(0,H.jsx)(dv,{className:U(r,`text-fg-4`)});case`parked`:return(0,H.jsx)(lv,{className:U(r,`text-fg-3`)});default:return(0,H.jsx)(Fb,{className:U(r,`text-fg-4`)})}}function Ure(e,t,n=`all`,r,i){let a=MO(e,n).filter(NO).map(e=>({key:e.toolUseId,kind:`agent`,label:PO(e),noun:`agent`,state:Kre(e.status),detail:e.toolCount>0?String(e.toolCount):void 0,title:`${PO(e)} · ${e.toolCount} tool${e.toolCount===1?``:`s`}`,onSelect:()=>t(e.toolUseId)})),o=i===void 0?[]:mk(e,i.show).map(e=>Wre(e,i));if(r===void 0)return[...a,...o];let s=e.shellAgentWrite!==void 0,c=WO(e,r.show??`active`,r.now).map(e=>Gre(e,r,s));return[...a,...o,...c]}function Wre(e,t){let n=e.source===`checklist`&&e.state===`running`&&!t.live,r=e.toolUseId;return{key:e.key,kind:`task`,label:e.label,noun:`task`,state:n?`pending`:e.state,detail:e.detail,title:n?`${e.label} · left in progress`:e.label,onSelect:()=>t.onSelect(e),onKill:e.stoppable&&r!==void 0&&t.onStop?()=>t.onStop?.(r):void 0,killLabel:`Stop this task`}}function Gre(e,t,n){let r=r4(e),i=e.status===`running`;return{key:e.id,kind:`shell`,label:Q2(e),noun:`shell`,state:n4(e)?`failed`:i?`running`:`done`,detail:i?e.agentWrite===!0?Y2:void 0:r,title:`${$2(e)} · ${r}`,onSelect:()=>t.onSelect(e.id),onKill:i&&t.onKill?()=>t.onKill?.(e.id):void 0,killLabel:`Kill this shell`,agentWrite:n&&t.onAgentWrite&&X2(e)?{granted:e.agentWrite===!0,label:Z2(e),toggle:()=>t.onAgentWrite?.(e.id,e.agentWrite!==!0)}:void 0}}function Kre(e){switch(e){case`running`:return`running`;case`failed`:return`failed`;default:return`done`}}function qre({step:e,active:t=!1,onSelect:n}){let r=e.state===`failed`?`text-danger`:e.kind===`shell`?`text-[var(--wd-shell-accent)]`:e.kind===`task`?e.state===`pending`?`text-fg-4`:`text-fg-2`:`text-success`;return(0,H.jsxs)(`div`,{className:U(`flex w-full items-center rounded-[4px] pr-1.5`,t?`bg-row-selected`:`hover:bg-row-active`,r),children:[(0,H.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,H.jsx)(Jre,{step:e}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.detail?(0,H.jsx)(`span`,{className:`shrink-0 tabular-nums text-fg-4`,children:e.detail}):null,e.kind===`agent`?(0,H.jsx)(uee,{className:`size-3.5 shrink-0 text-fg-4`}):null]}),e.agentWrite?(0,H.jsx)(`button`,{type:`button`,"aria-label":e.agentWrite.label,"aria-pressed":e.agentWrite.granted,title:e.agentWrite.label,onClick:t=>{t.stopPropagation(),e.agentWrite?.toggle()},className:U(`shrink-0 px-1 text-micro leading-none outline-none`,e.agentWrite.granted?`text-warning`:`text-fg-4 hover:text-fg-1`),children:(0,H.jsx)(QN,{granted:e.agentWrite.granted,className:`size-3.5`})}):null,e.onKill?(0,H.jsx)(`button`,{type:`button`,"aria-label":`${e.kind===`task`?`Stop`:`Kill`} ${e.label}`,title:e.killLabel,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 Jre({step:e}){if(e.kind===`shell`)return(0,H.jsx)(`span`,{className:`w-[11px] shrink-0 text-center leading-none`,children:`$`});switch(e.state){case`running`:return(0,H.jsx)(_E,{className:`size-[11px] shrink-0`});case`failed`:return(0,H.jsx)(av,{className:`size-[11px] shrink-0`});case`pending`:return(0,H.jsx)(pv,{className:`size-[11px] shrink-0`});default:return(0,H.jsx)(X_,{className:`size-[11px] shrink-0`})}}var c7={meta:!1,ctrl:!1,alt:!1};function Yre({row:e,active:t=!1,activeStepKey:n,showGateway:r,showProject:i=!0,projectIcons:a,subagents:o=`active`,shells:s=`active`,tasks:c=`active`,onSelect:l,onSelectSubagent:u,onSelectTask:d,onStopTask:f,onSelectShell:p,onKillShell:m,onShellAgentWrite:h,now:g,onRename:_,renameOn:y=`doubleClick`,editing:b,onEditingChange:x,actions:S,className:C}){let{info:w}=e,[T,E]=(0,v.useState)(!1),D=b??T,O=e=>{E(e),x?.(e)},k=w.engine??`claude`,A=i?BO(e):HO(e),j=i?VO(e):void 0,M=i?w.project?.icon:void 0,N=M?.type===`image`?a?.[M.hash]:void 0,P=nN(w.costUsd??w.totalCostUsd),F=[r?e.hostName:void 0,w.profile?`@${w.profile}`:void 0,P===`-`?void 0:P].filter(e=>!!e),I=pN(w.model),L=[];I&&L.push((0,H.jsx)(`span`,{className:Hre(k,w.model),children:I},`model`)),A!==void 0&&L.push((0,H.jsxs)(`span`,{title:j,children:[(0,H.jsx)(Q5,{icon:M,src:N,name:j,className:`mr-1.5 size-4 align-[-0.3em]`}),A]},`project`));for(let e of F)L.push((0,H.jsx)(`span`,{children:e},e));let R=Ure(w,e=>u?u(e):l?.(c7),o,{now:g??Date.now(),show:s,onSelect:e=>p?p(e):l?.(c7),onKill:m,onAgentWrite:h},{show:c,live:w.status===`running`||w.status===`starting`||w.status===`awaiting_approval`,onSelect:e=>d?d(e):l?.(c7),onStop:f}),z=R.some(e=>e.key===n);return(0,H.jsxs)(`div`,{"data-slot":`session-item`,"data-active":t||void 0,role:`button`,tabIndex:0,onClick:e=>{e.detail>1||D||l?.({meta:e.metaKey,ctrl:e.ctrlKey,alt:e.altKey})},onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l?.({meta:e.metaKey,ctrl:e.ctrlKey,alt:e.altKey}))},className:U(`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`,z?`bg-row-selected-weak`:t?`bg-row-selected`:`hover:bg-row-hover`,C),children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 py-0.5 pr-0.5 pl-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex h-5 items-center gap-1.5 overflow-hidden`,children:[(0,H.jsx)(l7,{children:(0,H.jsx)(s7,{row:e})}),D&&_?(0,H.jsx)(Xre,{initial:w.title??``,onCommit:e=>{O(!1),e!==(w.title??``)&&_(e)},onCancel:()=>O(!1)}):(0,H.jsx)(`span`,{onDoubleClick:_&&y===`doubleClick`?e=>{e.stopPropagation(),O(!0)}:void 0,className:`min-w-0 flex-1 truncate text-body-sm font-medium tracking-[-0.005em] text-fg-1`,children:RO(w)}),e.unseen>0?(0,H.jsx)(`span`,{title:`${e.unseen} new message${e.unseen===1?``:`s`}`,className:U(`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,H.jsx)(i7,{usage:w.contextUsage,engine:k,size:16,className:`p-0.5`})]}),(0,H.jsxs)(`div`,{className:`flex h-5 items-center gap-1.5 overflow-hidden text-body-sm tracking-[-0.005em]`,children:[(0,H.jsx)(l7,{children:(0,H.jsx)(o7,{engine:k,model:w.model,className:U(`size-4`,Vre(k,w.model))})}),(0,H.jsx)(`span`,{className:`min-w-0 truncate text-fg-4`,children:L.map((e,t)=>(0,H.jsxs)(v.Fragment,{children:[t>0?` · `:``,e]},t))}),(0,H.jsxs)(`span`,{className:`shrink-0 text-fg-4`,children:[L.length>0?`· `:``,sN(w.lastActivityAt??w.createdAt)]}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1`}),S]})]}),R.length>0?(0,H.jsx)(`div`,{className:`flex flex-col`,children:R.map(e=>(0,H.jsx)(qre,{step:e,active:e.key===n,onSelect:e.onSelect},e.key))}):null]})}function l7({children:e}){return(0,H.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:e})}function Xre({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,H.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:U(`-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 Zre(e){return U(`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 Qre({rows:e,config:t,onConfigChange:n,scope:r,activeId:i,activeSubagentId:a,activeShellId:o,now:s,isActive:c=e=>e.info.id===i,rowActions:l,gatewayCount:u,showSubset:d=!0,onSelect:f,onDelete:p,onRename:m,onClearContext:h,onSelectSubagent:g,onSelectTask:_,onStopTask:y,onSelectShell:b,onKillShell:x,onShellAgentWrite:S,emptyState:C,showControls:w=!0,showSearch:T=w,autoFocusSearch:E,projectIcons:D,className:O}){let k=(0,v.useMemo)(()=>XO(e,t,r),[e,t,r]),A=(0,v.useMemo)(()=>nk(k,t),[k,t]),j=rk(t,r,k.length,e.length),M=(0,v.useMemo)(()=>new Set(e.map(e=>e.hostId)).size,[e]),N=e=>n({...t,...e});return(0,H.jsxs)(`div`,{"data-slot":`session-browser`,className:U(`flex flex-col gap-3`,O),children:[T?(0,H.jsx)(tie,{value:t.search,onChange:e=>N({search:e}),autoFocus:E,className:`px-2`}):null,w?(0,H.jsx)($5,{config:t,onConfigChange:n,rows:e,scope:r,className:`px-2`}):null,j&&d?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-label text-fg-4`,children:[(0,H.jsxs)(`span`,{children:[j.shown,` of `,j.total,j.causes.length?` · ${j.causes.join(` · `)}`:null]}),(0,H.jsx)(`button`,{type:`button`,className:`text-fg-3 underline underline-offset-2 hover:text-fg-1`,onClick:()=>n(sk(t)),children:`Show all`})]}):null,e.length===0?C??(0,H.jsx)(bE,{icon:(0,H.jsx)(Zy,{}),title:`No sessions yet`}):k.length===0?ik(t)?(0,H.jsx)(bE,{icon:(0,H.jsx)(Jx,{}),title:`No matches`,description:`No session matches the current search and filters.`,action:`Clear filters`,onAction:()=>n(sk(t))}):r&&YO(t,r)?(0,H.jsx)(bE,{icon:(0,H.jsx)(py,{}),title:`Nothing in this folder`,description:`No session is running in ${r.label}.`,action:`Show all folders`,onAction:()=>N({scoped:!1})}):(0,H.jsx)(bE,{icon:(0,H.jsx)(Zy,{}),title:`Nothing here`,description:`No session to show.`}):(0,H.jsx)(`div`,{className:`flex flex-col gap-4 px-1`,children:A.map(e=>(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t.groupBy!==`none`&&e.label?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-2 text-label font-medium text-fg-4`,children:[t.groupBy===`project`?(0,H.jsx)(Q5,{icon:e.rows[0]?.info.project?.icon,src:$re(e.rows[0],D),name:e.label}):null,(0,H.jsx)(`span`,{className:`uppercase tracking-wide`,children:e.label}),(0,H.jsx)(`span`,{className:`text-fg-4/70`,children:e.rows.length})]}):null,e.rows.map(e=>(0,H.jsx)(eie,{row:e,active:c(e),activeSubagentId:a,activeShellId:o,actions:l?.(e),now:s,showGateway:(u??M)>1&&t.groupBy!==`gateway`,showProject:t.groupBy!==`project`,subagents:t.subagents,shells:t.shells,tasks:t.tasks,projectIcons:D,onSelect:f,onDelete:p,onRename:m,onClearContext:h,onSelectSubagent:g,onSelectTask:_,onStopTask:y,onSelectShell:b,onKillShell:x,onShellAgentWrite:S},`${e.hostId}:${e.info.id}`))]},e.key))})]})}function $re(e,t){let n=e?.info.project?.icon;return n?.type===`image`?t?.[n.hash]:void 0}function eie({row:e,active:t,actions:n,activeSubagentId:r,activeShellId:i,now:a,showGateway:o,showProject:s=!0,subagents:c,shells:l,tasks:u,projectIcons:d,onSelect:f,onDelete:p,onRename:m,onClearContext:h,onSelectSubagent:g,onSelectTask:_,onStopTask:y,onSelectShell:b,onKillShell:x,onShellAgentWrite:S}){let{info:C}=e,[w,T]=(0,v.useState)(!1);return(0,H.jsx)(Yre,{row:e,active:t===!0,activeStepKey:t?i??r:void 0,now:a,showGateway:o,showProject:s,subagents:c,shells:l,tasks:u,projectIcons:d,onSelect:t=>f?.(e,t),onSelectSubagent:g?t=>g(e,t):void 0,onSelectTask:_?t=>_(e,t):void 0,onStopTask:y?t=>y(e,t):void 0,onSelectShell:b?t=>b(e,t):void 0,onKillShell:x?t=>x(e,t):void 0,onShellAgentWrite:S?(t,n)=>S(e,t,n):void 0,onRename:m?t=>m(e,t):void 0,renameOn:n===void 0?`external`:`doubleClick`,editing:n===void 0?w:void 0,onEditingChange:n===void 0?T:void 0,actions:n??(0,H.jsxs)(H.Fragment,{children:[m&&!w?(0,H.jsx)(u7,{label:`Rename session`,onClick:()=>T(!0),children:(0,H.jsx)(lx,{className:`size-3 text-fg-3`})}):null,h&&C.capabilities?.clearContext?(0,H.jsx)(u7,{label:`Clear context`,title:`Clear the conversation - the session keeps running and the old conversation stays resumable`,onClick:()=>h(e),children:(0,H.jsx)(Yv,{className:`size-3 text-fg-3`})}):null,p?(0,H.jsx)(u7,{label:`Close session`,onClick:()=>p(e),children:(0,H.jsx)(zS,{className:`size-3 text-fg-3`})}):null]})})}function u7({label:e,title:t,onClick:n,children:r}){return(0,H.jsx)(uo,{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 tie({value:e,onChange:t,autoFocus:n,className:r,inputClassName:i}){return(0,H.jsxs)(`div`,{className:U(`relative`,r),children:[(0,H.jsx)(Xx,{className:`pointer-events-none absolute top-1/2 left-4.5 size-3.5 -translate-y-1/2 text-fg-4`}),(0,H.jsx)(vo,{value:e,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.stopPropagation(),t(``))},placeholder:`Search sessions`,"aria-label":`Search sessions`,autoFocus:n,className:U(`pr-7 pl-8`,i)}),e?(0,H.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>t(``),className:`absolute top-1/2 right-3.5 -translate-y-1/2 rounded p-0.5 text-fg-4 hover:text-fg-1`,children:(0,H.jsx)(hC,{className:`size-3`})}):null]})}function d7(){let[e,t]=(0,v.useState)(T());return(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Toggle theme`,onClick:()=>t(O()),children:e===`dark`?(0,H.jsx)(TS,{className:`size-4`}):(0,H.jsx)(Fb,{className:`size-4`})})}var f7=[{value:`default`,displayName:`Default (recommended)`,description:`The CLI's configured default model`},{value:`fable`,displayName:`Fable`,description:`Fable 5.1 · For your toughest challenges`},{value:`opus`,displayName:`Opus`,description:`Opus 5.5 · For complex work and everyday tasks`},{value:`sonnet`,displayName:`Sonnet`,description:`Sonnet 5.5 · Most efficient for simpler tasks`},{value:`haiku`,displayName:`Haiku`,description:`Haiku 4.5 · Fastest for quick answers`}],p7=`workerdeck.transcript-variant`;function m7(){return b(p7)===`terminal`?`terminal`:`cards`}function nie(e){x(p7,e)}var h7=`workerdeck.transcript-font`;function g7(){return b(h7)===`mono`?`mono`:`sans`}function rie(e){x(h7,e)}var _7=`workerdeck.font-size`;function v7(){let e=b(_7);if(e===void 0)return;let t=Number(e);return Number.isFinite(t)&&t>=8&&t<=24?Math.round(t):void 0}function iie(e){x(_7,e===void 0?void 0:String(Math.round(e)))}var y7=`workerdeck.catch-up`;function b7(){return b(y7)===`off`?`off`:`on`}function aie(e){x(y7,e)}var x7=`workerdeck.action-style`;function S7(){return b(x7)===`labeled`?`labeled`:`icons`}function oie(e){x(x7,e)}function C7({label:e,options:t,read:n,write:r,onChange:i}){let[a,o]=(0,v.useState)(n);return(0,H.jsx)(TC,{label:e,value:a,options:t,onChange:e=>{o(e),r(e),i?.(e)},className:`min-w-40`})}function w7({title:e,children:t}){return(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`h3`,{className:`text-label font-medium tracking-wide text-fg-3 uppercase`,children:e}),t]})}function sie({open:e,onOpenChange:t}){let[n,r]=(0,v.useState)(m7);return(0,H.jsx)(aT,{open:e,onOpenChange:t,children:(0,H.jsxs)(oT,{size:`md`,className:`w-[min(30rem,calc(100vw-2rem))]`,children:[(0,H.jsx)(sT,{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,H.jsx)(cT,{children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,H.jsxs)(w7,{title:`Appearance`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Theme`}),(0,H.jsx)(d7,{})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Agent view style`}),(0,H.jsx)(C7,{label:`Agent view style`,options:[{value:`cards`,label:`Cards`},{value:`terminal`,label:`Terminal`}],read:m7,write:nie,onChange:r})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Font size`}),(0,H.jsx)(C7,{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(v7()??``),write:e=>iie(e?Number(e):void 0)})]}),n===`cards`?(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Agent view font`}),(0,H.jsx)(C7,{label:`Agent view font`,options:[{value:`sans`,label:`Regular`},{value:`mono`,label:`Monospace`}],read:g7,write:rie})]}):null,(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-fg-2`,children:`Row actions`}),(0,H.jsx)(C7,{label:`Row actions`,options:[{value:`icons`,label:`Icons`},{value:`labeled`,label:`Icons and labels`}],read:S7,write:oie})]})]}),(0,H.jsx)(w7,{title:`Sessions`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsxs)(`span`,{className:`text-body-sm text-fg-2`,children:[`Catch-up mode`,(0,H.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,H.jsx)(C7,{label:`Catch-up mode`,options:[{value:`on`,label:`On`},{value:`off`,label:`Off`}],read:b7,write:aie})]})})]})})]})})}function T7({className:e}){return(0,H.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:e,children:[(0,H.jsx)(`path`,{d:`M12 3 20.5 7.75 12 12.5 3.5 7.75Z`}),(0,H.jsx)(`path`,{d:`M3.5 12.25 12 17l8.5-4.75`}),(0,H.jsx)(`path`,{d:`M3.5 16.5 12 21.25l8.5-4.75`}),(0,H.jsx)(`path`,{d:`M12 6.15 14.85 7.75 12 9.35 9.15 7.75Z`,fill:`#2fbf71`,stroke:`none`})]})}function E7(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)}}function D7(e,{load:t,intervalMs:n,onIdle:r}){let i=E7(e),a,o=0,s,c=()=>(a??=t(i).finally(()=>{a=void 0}),a),l=e=>{let t=i.subscribe(e);return++o===1&&(c(),n&&(s=setInterval(()=>void c(),n))),()=>{t(),--o===0&&(clearInterval(s),s=void 0,r?.())}};return{...i,subscribe:l,refresh:c,watched:()=>o>0,use:()=>(0,v.useSyncExternalStore)(l,i.get,i.get)}}var O7=`workerdeck.hosts.v1`;function k7(e){return`workerdeck.host.${e}.key`}var cie=`gateway`,A7=E7({hosts:[],ready:!1});function j7(e){I7.clear(),A7.set(e)}function M7(){let e=S(O7,[]);return Array.isArray(e)?e.map(({implicit:e,...t})=>t):[]}function N7(e){C(O7,e.filter(e=>!e.implicit))}function lie(){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 P7(e){return b(k7(e))??``}function F7(e,t){x(k7(e),t===``?void 0:t)}var I7=new Map;function L7(e){let t=I7.get(e);if(t)return t;let n=A7.get().hosts.find(t=>t.id===e);if(!n)return;let r=hA(n);if(r===void 0)return;let i=new yA({baseUrl:r,...n.implicit?{}:_A({baseUrl:r,key:P7(n.id)})});return I7.set(e,i),i}function R7(){return A7.get().hosts.find(e=>e.implicit)??A7.get().hosts[0]}function uie(){let e=R7();return e?L7(e.id):void 0}function z7(e){return gA(e)}function die(e,t){let n=M7(),r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[...n,e];N7(r),F7(e.id,t),j7({...A7.get(),hosts:[...A7.get().hosts.filter(e=>e.implicit),...r]})}function fie(e){let t=M7().filter(t=>t.id!==e);N7(t),F7(e,``),j7({...A7.get(),hosts:[...A7.get().hosts.filter(e=>e.implicit),...t]})}async function pie(){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 B7=!1;function V7(){if(B7)return;B7=!0;let e=M7();j7({hosts:e,ready:!1}),pie().then(t=>{j7({hosts:t?[{id:cie,name:`This gateway`,baseUrl:location.origin,implicit:!0},...e]:e,ready:!0})})}function H7(e){return V7(),A7.subscribe(e)}function U7(){return(0,v.useSyncExternalStore)(H7,A7.get,A7.get)}function mie(){return V7(),A7.get().hosts}function W7(e){return H7(e)}function G7({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)(()=>P7(e.id));return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label text-fg-3`,children:`Name`}),(0,H.jsx)(vo,{value:i,onChange:e=>a(e.target.value),placeholder:`Mac mini`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label text-fg-3`,children:`Address`}),(0,H.jsx)(vo,{value:o,onChange:e=>s(e.target.value),placeholder:`http://toby.ts.net:8787`,spellCheck:!1,className:`font-mono`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label text-fg-3`,children:`Auth key`}),(0,H.jsx)(vo,{type:`password`,value:c,onChange:e=>l(e.target.value),placeholder:`Leave empty for an unauthenticated gateway`,spellCheck:!1}),(0,H.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,H.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2`,children:[r,(0,H.jsx)(uo,{onClick:()=>{if(hA({baseUrl:o})===void 0){ZT.error(`That address is not a URL`);return}if(!i.trim()){ZT.error(`Give the gateway a name`);return}let t={id:e.id,name:i.trim(),baseUrl:o.trim()};die(t,c),n(t)},children:t})]})]})}function hie({open:e,onOpenChange:t,onCreated:n}){let[r,i]=(0,v.useState)(()=>K7());return(0,H.jsx)(aT,{open:e,onOpenChange:e=>{e&&i(K7()),t(e)},children:(0,H.jsxs)(oT,{children:[(0,H.jsx)(sT,{title:`Add gateway`,description:`A workerdeck gateway you run - typically over Tailscale.`}),(0,H.jsx)(cT,{children:(0,H.jsx)(G7,{host:r,submitLabel:`Add gateway`,onSaved:n,actions:(0,H.jsx)(uo,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`})})})]})})}function K7(){return{id:lie(),name:``,baseUrl:``}}function q7({host:e,onClose:t,onRemoved:n}){return(0,H.jsx)(aT,{open:!0,onOpenChange:e=>!e&&t(),children:(0,H.jsxs)(oT,{children:[(0,H.jsx)(sT,{title:`Remove ${e.name}?`,description:`Its auth key is deleted from this browser. The gateway itself keeps running.`}),(0,H.jsx)(cT,{children:(0,H.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,H.jsx)(uo,{variant:`outline`,onClick:t,children:`Cancel`}),(0,H.jsx)(uo,{variant:`destructive`,onClick:()=>{fie(e.id),n()},children:`Remove`})]})})]})})}function J7(e){return e===`sessions`?`workerdeck.sessions-sidebar-width`:`workerdeck.${e}-sidebar-width`}function Y7(e){return e===`sessions`?`workerdeck.sessions-sidebar-collapsed`:`workerdeck.${e}-sidebar-collapsed`}function gie(e){let t=Number(b(J7(e)));return t?Math.min(520,Math.max(240,t)):300}function _ie(e,t){x(J7(e),String(t))}function vie(e){return b(Y7(e))===`1`}function yie(e,t){x(Y7(e),t?`1`:`0`)}var X7=`workerdeck.sessions-search-shown`;function bie(){return b(X7)===`1`}function xie(e){x(X7,e?`1`:`0`)}function Z7({section:e,title:t,badge:n,actions:r,children:i,rail:a,railActions:o}){let[s,c]=(0,v.useState)(()=>gie(e)),[l,u]=(0,v.useState)(()=>vie(e)),d=t=>{u(t),yie(e,t)};return l?(0,H.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,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Expand ${t.toLowerCase()}`,onClick:()=>d(!1),children:(0,H.jsx)(tx,{className:`size-4`})}),o,a?(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{style:{width:s},className:`flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar`,children:[(0,H.jsxs)(`header`,{className:`flex h-9 shrink-0 items-center gap-1 pr-1 pl-3`,children:[(0,H.jsx)(`span`,{className:`truncate text-label font-medium tracking-wide text-fg-3 uppercase`,children:t}),n,(0,H.jsx)(`span`,{className:`flex-1`}),(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Collapse ${t.toLowerCase()}`,onClick:()=>d(!0),children:(0,H.jsx)($b,{className:`size-3.5`})}),r]}),i]}),(0,H.jsx)(yE,{orientation:`vertical`,value:s,onValueChange:t=>{c(t),_ie(e,t)},min:240,max:520,defaultValue:300,"aria-label":`Resize ${t.toLowerCase()} sidebar`})]})}function Q7({children:e,className:t}){return(0,H.jsx)(`div`,{className:U(`min-h-0 flex-1 overflow-y-auto pb-2`,t),children:e})}function $7({title:e,status:t,description:n,actions:r,active:i,onSelect:a,onDoubleClick:o}){return(0,H.jsxs)(`div`,{"data-slot":`sidebar-row`,"data-active":i||void 0,onClick:a,onDoubleClick:o,className:U(`group flex cursor-pointer flex-col gap-0.5 text-left transition-colors`,Zre(i===!0)),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(`button`,{type:`button`,className:U(`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,H.jsxs)(`div`,{className:`flex items-center gap-1 text-label text-fg-4`,children:[(0,H.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 e9({label:e,onClick:t,children:n}){return(0,H.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 t9=`workerdeck.watermarks.v1`,n9=E7(0),r9=new iA({read:()=>S(t9,void 0),write:e=>{C(t9,e),n9.set(n9.get()+1)}});function i9(){return n9.use(),{unseenFor:(0,v.useCallback)((e,t)=>aA(r9.get(e,t.id),t),[]),watermarks:r9}}function Sie(e,t){let n=r9.get(e,t);return n?{itemCount:n.itemCount,since:n.seenAt}:void 0}function Cie(e,t){let n=(0,v.useRef)({});return(0,v.useCallback)(r=>{t&&!document.hidden&&(n.current={...n.current,...r},r9.mark(e,t,n.current))},[e,t])}function wie(e){let{unseenFor:t}=i9();return(0,v.useMemo)(()=>e.reduce((e,n)=>e+t(n.hostId,n.info),0),[e,t])}var Tie=5e3,Eie=1200,Die=700,a9=D7({snapshots:[],loaded:!1},{load:Oie}),o9=0,s9;function c9(){return a9.refresh()}async function Oie(){o9=Date.now();let e=mie(),t=new Map(a9.get().snapshots.map(e=>[e.host.id,e])),n=await Promise.all(e.map(async e=>{let n=L7(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:hk(n)}}}));a9.set({snapshots:n,loaded:!0})}function kie(){if(s9!==void 0)return;let e=Math.max(0,Die-(Date.now()-o9));s9=setTimeout(()=>{s9=void 0,c9()},e)}var l9,u9;function Aie(e){let t=e?Eie:Tie;(l9===void 0||u9!==t)&&(l9!==void 0&&clearInterval(l9),u9=t,l9=setInterval(()=>void c9(),t))}function d9(){let e=a9.use();(0,v.useEffect)(()=>W7(()=>void c9()),[]);let t=e.snapshots.some(e=>e.sessions.some(e=>{let t=AO(e);return t===`working`||t===`attention`}));return(0,v.useEffect)(()=>Aie(t),[t]),{...e,refresh:c9}}function f9(e){let{unseenFor:t}=i9();return(0,v.useMemo)(()=>e.flatMap(({host:e,sessions:n})=>n.filter(e=>!UO(e)).map(n=>({hostId:e.id,hostName:e.name,local:z7(e),adapter:n.engine??`claude`,state:AO(n),info:n,unseen:t(e.id,n)}))),[e,t])}function jie(){let e=Mr(),t=xi({select:e=>e.location.pathname.match(/^\/gateways\/(.+)$/)?.[1]}),{hosts:n,ready:r}=U7(),{snapshots:i}=d9(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),l=i.filter(e=>e.error===void 0).length,u=(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Add gateway`,onClick:()=>o(!0),children:(0,H.jsx)(yx,{className:`size-4`})});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z7,{section:`gateways`,title:`Gateways`,badge:r&&n.length>0?(0,H.jsxs)(`span`,{className:`shrink-0 text-label text-fg-4`,children:[l,`/`,n.length]}):void 0,actions:u,railActions:u,children:(0,H.jsxs)(Q7,{children:[r&&n.length===0?(0,H.jsx)(bE,{icon:(0,H.jsx)(Qx,{}),title:`No gateways yet`,description:(0,H.jsxs)(H.Fragment,{children:[`Add one with `,(0,H.jsx)(xE,{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,H.jsx)($7,{active:n.id===t,onSelect:()=>void e({to:`/gateways/$hostId`,params:{hostId:n.id}}),title:n.name,status:(0,H.jsxs)(H.Fragment,{children:[n.implicit?(0,H.jsx)(`span`,{className:`shrink-0 text-label text-fg-4`,children:`this page`}):null,(0,H.jsx)(`span`,{"aria-hidden":!0,title:r?.error??(a===`ok`?`Connected`:`Connecting…`),className:U(`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,H.jsx)(e9,{label:`Remove ${n.name}`,onClick:()=>c(n),children:(0,H.jsx)(zS,{className:`size-3`})})},n.id)})]})}),s?(0,H.jsx)(q7,{host:s,onClose:()=>c(void 0),onRemoved:()=>{let n=s.id===t;c(void 0),n&&e({to:`/gateways`})}}):null,(0,H.jsx)(hie,{open:a,onOpenChange:o,onCreated:t=>{o(!1),e({to:`/gateways/$hostId`,params:{hostId:t.id}})}})]})}function p9({value:e,onChange:t,models:n=f7,className:r}){return(0,H.jsx)(S3,{variant:`form`,models:n,model:e||void 0,onModelChange:e=>t(e??``),className:r})}function Mie({profiles:e,value:t,onChange:n,className:r}){return e.length===0?null:(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Profile`}),(0,H.jsxs)(yC,{items:e.map(e=>({value:e.name,label:e.name})),value:t,onValueChange:e=>n(e),children:[(0,H.jsx)(SC,{className:r,children:(0,H.jsx)(bC,{})}),(0,H.jsx)(CC,{children:e.map(e=>(0,H.jsx)(wC,{value:e.name,children:(0,H.jsx)(xC,{children:(0,H.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 m9(){return uie()}function h9(e,t,n){let r=e?.capabilities??cA[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=f7.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 g9={profiles:[]},_9=D7(g9,{load:Nie});async function Nie(){let e=await m9()?.listProfiles().catch(()=>g9);_9.set(e??g9)}function v9(){return(0,v.useEffect)(()=>W7(()=>void _9.refresh()),[]),{..._9.use(),refresh:_9.refresh}}function Pie(){return v9().profiles}var y9=`workerdeck.last-profile`;function Fie(){let e=Pie(),[t,n]=(0,v.useState)(()=>b(y9)??``),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(y9,e)}}}var b9=`workerdeck.last-cwd`;function Iie(e){let[t,n]=(0,v.useState)([]);return(0,v.useEffect)(()=>{m9()?.listHostRoots().then(e=>n(e.roots.map(e=>e.path))).catch(()=>n([]))},[]),(0,v.useMemo)(()=>{let n=b(b9),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 Lie={session:`default`,job:`acceptEdits`},Rie={session:`ask`,job:`auto`};function x9(e){let[t,n]=(0,v.useState)(()=>b(b9)??``),[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)(Rie[e]),{profiles:p,profile:m,selected:h,select:g}=Fie(),_=h9(h,s??h?.defaults?.permissionMode??Lie[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(b9,t.trim()||e)}}function S9({form:e}){return e.engine.capabilities.interactiveApprovals?(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Questions`}),(0,H.jsxs)(yC,{items:p6.map(e=>({value:e.value,label:e.label})),value:e.questions,onValueChange:t=>e.setQuestions(t),children:[(0,H.jsx)(SC,{className:`min-w-36`,children:(0,H.jsx)(bC,{})}),(0,H.jsx)(CC,{children:p6.map(e=>(0,H.jsx)(wC,{value:e.value,children:(0,H.jsx)(xC,{children:`${e.label} - ${e.description}`})},e.value))})]})]}):null}function C9({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=Iie(t),c=(0,v.useId)(),{engine:l}=e;return(0,H.jsxs)(H.Fragment,{children:[l.capabilities.hostCwd!==!1&&(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Working directory`}),(0,H.jsx)(vo,{value:e.cwd,list:c,onChange:t=>e.setCwd(t.target.value),placeholder:`/path/to/project`,spellCheck:!1,className:`font-mono`}),(0,H.jsx)(`datalist`,{id:c,children:s.map(e=>(0,H.jsx)(`option`,{value:e},e))})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:n}),(0,H.jsx)(yo,{value:e.prompt,onChange:t=>e.setPrompt(t.target.value),rows:2,placeholder:r})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(Mie,{profiles:e.profiles,value:e.profile,onChange:t=>{e.selectProfile(t),o?.(t)},className:`min-w-32`}),(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Permission mode`}),(0,H.jsx)(E3,{variant:`form`,mode:l.mode,onModeChange:e.setMode,modes:l.modes,className:`min-w-44`})]}),i,(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Model`}),(0,H.jsx)(p9,{value:l.model,onChange:e.setModel,models:l.models,className:`min-w-40`})]}),l.reasoningEfforts.length>0?(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Effort`}),(0,H.jsxs)(yC,{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,H.jsx)(SC,{className:`min-w-28`,children:(0,H.jsx)(bC,{})}),(0,H.jsx)(CC,{children:[`default`,...l.reasoningEfforts].map(e=>(0,H.jsx)(wC,{value:e,children:(0,H.jsx)(xC,{children:e})},e))})]})]}):null,a]})]})}var w9=D7({jobs:[],stats:void 0,enabled:!0,live:!1,error:void 0},{load:zie,intervalMs:15e3,onIdle:Bie}),T9=w9.patch,E9;function D9(){return w9.refresh()}async function zie(){try{let e=m9();if(!e)return;let[t,n]=await Promise.all([e.listJobs(),e.queueStats()]);T9({jobs:t,stats:n,enabled:!0,error:void 0})}catch(e){let t=hk(e);/not configured/i.test(t)?T9({enabled:!1,error:void 0}):T9({error:t})}}function Bie(){E9?.(),E9=void 0,T9({live:!1})}function Vie(){if(E9||!w9.get().enabled||w9.get().stats===void 0||!w9.watched())return;let e=m9();if(!e)return;let t=e.attachQueue(),n=[t.on(`attached`,()=>void D9()),t.on(`stats`,e=>T9({stats:e})),t.on(`connectionChange`,e=>T9({live:e})),t.on(`event`,e=>{T9({jobs:w9.get().jobs.some(t=>t.id===e.job.id)?w9.get().jobs.map(t=>t.id===e.job.id?e.job:t):[...w9.get().jobs,e.job]})})];E9=()=>{for(let e of n)e();t.detach()}}function O9(){let e=w9.use();return(0,v.useEffect)(Vie,[e.enabled,e.stats]),{...e,refresh:D9}}function Hie({stats:e}){let t=e.dailyTokenLimit!==void 0&&e.dailyTokenLimit>0?e.dailyTokensUsed/e.dailyTokenLimit*100:void 0;return(0,H.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,H.jsxs)(`span`,{children:[`Running`,` `,(0,H.jsxs)(`span`,{className:`font-mono text-fg-1`,children:[e.running,`/`,e.maxConcurrency]})]}),(0,H.jsxs)(`span`,{children:[`Queued `,(0,H.jsx)(`span`,{className:`font-mono text-fg-1`,children:e.queued})]}),e.parked>0?(0,H.jsxs)(`span`,{children:[`Parked `,(0,H.jsx)(`span`,{className:`font-mono text-fg-1`,children:e.parked})]}):null,(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[t===void 0?null:(0,H.jsx)(SE,{value:t,className:t>=95?`text-danger`:t>=80?`text-warning`:`text-fg-3`}),`Daily tokens`,` `,(0,H.jsxs)(`span`,{className:`font-mono text-fg-1`,children:[iN(e.dailyTokensUsed),e.dailyTokenLimit===void 0?``:` / ${iN(e.dailyTokenLimit)}`]})]}),e.sessionTokenLimit===void 0?null:(0,H.jsxs)(`span`,{children:[`Per-job cap `,(0,H.jsx)(`span`,{className:`font-mono text-fg-1`,children:iN(e.sessionTokenLimit)})]}),e.paused?(0,H.jsx)(po,{variant:`warning`,dot:!0,children:`Paused - daily budget exhausted`}):null]})}function Uie({onScheduled:e}){let{snapshots:t}=d9(),n=t.find(e=>e.host.id===R7()?.id)?.sessions??[],r=x9(`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()){ZT.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)){ZT.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)){ZT.error(`Attempts must be a whole number of at least 1`);return}p(!0);try{r.rememberCwd(r.cwd.trim()),await m9().createJob({session:{...r.sessionFields({allowBypass:i}),prompt:r.prompt.trim()},maxTokens:t,attempts:n,webhook:u.trim()?{url:u.trim()}:void 0}),r.setPrompt(``),ZT.success(`Job scheduled`),e()}catch(e){ZT.error(hk(e,`Failed to schedule job`))}finally{p(!1)}};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(C9,{form:r,sessions:n,promptLabel:`Prompt (the task - runs unattended)`,extras:(0,H.jsx)(S9,{form:r}),actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Max tokens (optional)`}),(0,H.jsx)(vo,{value:o,onChange:e=>s(e.target.value),placeholder:`per-job cap`,inputMode:`numeric`,className:`min-w-28 font-mono`})]}),(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Attempts (optional)`}),(0,H.jsx)(vo,{value:c,onChange:e=>l(e.target.value),placeholder:`1`,inputMode:`numeric`,className:`min-w-20 font-mono`})]}),(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Webhook URL (optional)`}),(0,H.jsx)(vo,{value:u,onChange:e=>d(e.target.value),placeholder:`https://…/hook`,spellCheck:!1,className:`min-w-44 font-mono`})]}),(0,H.jsxs)(uo,{className:`ml-auto`,onClick:()=>void h(),disabled:f,children:[f?(0,H.jsx)(_E,{className:`size-3.5 text-current`}):(0,H.jsx)(yx,{className:`size-4`}),`Schedule`]})]})}),m.capabilities.settingSources?(0,H.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,H.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),className:`size-3.5 accent-(--color-fg-1)`}),`Allow switching to `,(0,H.jsx)(`code`,{className:`font-mono`,children:`bypassPermissions`}),` mid-run`,(0,H.jsx)(`span`,{className:`text-label text-fg-4`,children:`(dangerous)`})]}):null,(0,H.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,H.jsx)(`code`,{className:`font-mono`,children:`POST /sessions/:id/permissions/:requestId`}),`.`]})]})}function Wie({open:e,onOpenChange:t,onScheduled:n}){return(0,H.jsx)(aT,{open:e,onOpenChange:t,children:(0,H.jsxs)(oT,{size:`lg`,children:[(0,H.jsx)(sT,{title:`Schedule a job`,description:`A one-shot run the queue executes unattended.`}),(0,H.jsx)(cT,{children:e?(0,H.jsx)(Uie,{onScheduled:n}):null})]})})}function Gie(){let{stats:e,enabled:t,error:n}=O9();return(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[n?(0,H.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,H.jsx)(`code`,{className:`font-mono`,children:`pnpm server`}),`.`]}):null,t?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(bE,{icon:(0,H.jsx)(sb,{}),title:`No job selected`,description:(0,H.jsxs)(H.Fragment,{children:[`Pick one on the left, or schedule one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]})}),e?(0,H.jsx)(`div`,{className:`mt-2 w-full max-w-xl`,children:(0,H.jsx)(Hie,{stats:e})}):null]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(V_,{className:`size-8 text-fg-4`}),(0,H.jsx)(`p`,{className:`text-body-sm text-fg-3`,children:`The server has no job queue configured.`}),(0,H.jsxs)(`p`,{className:`max-w-md text-label text-fg-4`,children:[`Pass `,(0,H.jsxs)(`code`,{className:`font-mono`,children:[`queue: `,`{ maxConcurrency, … }`]}),` to`,` `,(0,H.jsx)(`code`,{className:`font-mono`,children:`createWorkerServer`}),` - the dev server enables it by default.`]})]})]})}var k9={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`}},Kie=[`queued`,`running`,`parked`];function qie(){let e=Mr(),t=xi({select:e=>e.location.pathname.match(/^\/jobs\/(.+)$/)?.[1]}),{jobs:n,enabled:r,live:i,refresh:a}=O9(),[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||Kie.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,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Schedule a job`,onClick:()=>s(!0),children:(0,H.jsx)(yx,{className:`size-4`})}):void 0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z7,{section:`jobs`,title:`Jobs`,badge:r?(0,H.jsx)(`span`,{"aria-hidden":!0,title:i?`Streaming over the queue socket`:`Polling`,className:U(`size-1.5 shrink-0 rounded-full`,i?`bg-success`:`bg-fg-4`)}):void 0,actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh`,onClick:()=>void a(),children:(0,H.jsx)(Nx,{className:`size-3.5`})}),h]}),railActions:h,children:r?(0,H.jsxs)(H.Fragment,{children:[n.length>0?(0,H.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pb-2`,children:[(0,H.jsx)(vo,{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,H.jsx)(uo,{variant:u?`default`:`outline`,size:`xs`,"aria-pressed":u,onClick:()=>d(!u),children:`Active`})]}):null,(0,H.jsxs)(Q7,{children:[n.length===0?(0,H.jsx)(bE,{icon:(0,H.jsx)(lb,{}),title:`No jobs yet`,description:(0,H.jsxs)(H.Fragment,{children:[`Schedule one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]})}):p.length===0?(0,H.jsx)(bE,{icon:(0,H.jsx)(Jx,{}),title:`No matches`,description:`No job matches the active filter.`,action:`Show all`,onAction:()=>d(!1)}):null,p.map(n=>(0,H.jsx)(Jie,{job:n,active:n.id===t,onOpen:()=>void e({to:`/jobs/$jobId`,params:{jobId:n.id}}),onChanged:()=>void a()},n.id)),m>0?(0,H.jsxs)(`p`,{className:`px-1 pt-2 text-center text-label text-fg-4`,children:[p.length,` of `,n.length]}):null]})]}):(0,H.jsx)(bE,{icon:(0,H.jsx)(lb,{}),title:`No job queue`,description:`This gateway runs without one, so there is nothing to schedule against.`})}),(0,H.jsx)(Wie,{open:o,onOpenChange:s,onScheduled:()=>{s(!1),a()}})]})}function Jie({job:e,active:t,onOpen:n,onChanged:r}){let i=k9[e.status],a=e.status===`queued`||e.status===`running`||e.status===`parked`,o=[sN(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(nN(s)),(0,H.jsx)($7,{active:t,onSelect:n,title:e.prompt,status:(0,H.jsxs)(po,{variant:i.variant,dot:!i.busy,className:`shrink-0`,children:[i.busy?(0,H.jsx)(_E,{className:`size-3 text-current`}):null,i.label]}),description:o.join(` · `),actions:a?(0,H.jsx)(e9,{label:`Cancel job`,onClick:()=>{m9()?.cancelJob(e.id).then(r).catch(e=>ZT.error(hk(e,`Cancel failed`)))},children:(0,H.jsx)(hC,{className:`size-3`})}):null})}var A9=[`web_search`,`download`,`web_fetch`,`deliver_file`];function j9(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}function M9({label:e,children:t}){return(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:e}),t]})}function Yie({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()){ZT.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:j9(d).length>0?j9(d):void 0,apiKeyEnv:p.trim()||void 0};let e={};b.length>0&&(e.capabilities=b),j9(S).length>0&&(e.mcpServers=j9(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 m9().createProfile(n),ZT.success(`Profile '${n.name}' created`),e(n.name)}catch(e){ZT.error(hk(e,`Failed to create profile`))}finally{D(!1)}};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`Engine`,children:(0,H.jsxs)(yC,{items:[{value:`provider`,label:`provider`},{value:`claude`,label:`claude`},{value:`codex`,label:`codex`}],value:t,onValueChange:e=>n(e),children:[(0,H.jsx)(SC,{className:`min-w-32`,children:(0,H.jsx)(bC,{})}),(0,H.jsxs)(CC,{children:[(0,H.jsx)(wC,{value:`provider`,children:(0,H.jsx)(xC,{children:`provider - model-agnostic engine`})}),(0,H.jsx)(wC,{value:`claude`,children:(0,H.jsx)(xC,{children:`claude - Agent SDK + config dir`})}),(0,H.jsx)(wC,{value:`codex`,children:(0,H.jsx)(xC,{children:`codex - app-server + CODEX_HOME`})})]})]})}),(0,H.jsx)(M9,{label:`Name`,children:(0,H.jsx)(vo,{value:r,onChange:e=>i(e.target.value),placeholder:`kimi`})}),(0,H.jsx)(M9,{label:`Description (optional)`,children:(0,H.jsx)(vo,{value:a,onChange:e=>o(e.target.value),placeholder:`what this profile is for`})})]}),O?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`Provider id`,children:(0,H.jsx)(vo,{value:s,onChange:e=>c(e.target.value),placeholder:`anthropic / openai / moonshotai`,className:`font-mono`})}),(0,H.jsx)(M9,{label:`Default model`,children:(0,H.jsx)(vo,{value:l,onChange:e=>u(e.target.value),placeholder:`kimi-k3`,className:`font-mono`})}),(0,H.jsx)(M9,{label:`Models offered (comma-separated)`,children:(0,H.jsx)(vo,{value:d,onChange:e=>f(e.target.value),placeholder:`kimi-k3, kimi-k2`,className:`font-mono`})}),(0,H.jsx)(M9,{label:`API key variable`,children:(0,H.jsx)(vo,{value:p,onChange:e=>m(e.target.value),placeholder:`MOONSHOT_API_KEY`,className:`font-mono`})})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`Capabilities granted`,children:(0,H.jsx)(`div`,{className:`flex flex-wrap gap-3 py-1.5`,children:A9.map(e=>(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,H.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,H.jsx)(`code`,{className:`font-mono text-label`,children:e})]},e))})}),(0,H.jsx)(M9,{label:`MCP servers (names, comma-separated)`,children:(0,H.jsx)(vo,{value:S,onChange:e=>C(e.target.value),placeholder:`deepwiki`,className:`font-mono`})})]}),(0,H.jsx)(M9,{label:`Instructions (optional)`,children:(0,H.jsx)(vo,{value:w,onChange:e=>T(e.target.value),placeholder:`prepended to the session's system prompt`})}),(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(M9,{label:`Home directory (optional)`,children:(0,H.jsx)(vo,{value:_,onChange:e=>y(e.target.value),placeholder:`/Users/you/.codex`,spellCheck:!1,className:`font-mono`})}),(0,H.jsxs)(`p`,{className:`text-label text-fg-4`,children:[`This profile's `,(0,H.jsx)(`code`,{className:`font-mono`,children:`CODEX_HOME`}),`. Must resolve inside the server's`,` `,(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(M9,{label:`Config directory`,children:(0,H.jsx)(vo,{value:h,onChange:e=>g(e.target.value),placeholder:`/Users/you/.claude`,spellCheck:!1,className:`font-mono`})}),(0,H.jsxs)(`p`,{className:`text-label text-fg-4`,children:[`Must resolve inside the server's `,(0,H.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,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsxs)(uo,{onClick:()=>void A(),disabled:E,children:[E?(0,H.jsx)(_E,{className:`size-3.5 text-current`}):(0,H.jsx)(yx,{className:`size-4`}),`Create profile`]})})]})}function Xie({open:e,onOpenChange:t,onCreated:n}){return(0,H.jsx)(aT,{open:e,onOpenChange:t,children:(0,H.jsxs)(oT,{size:`lg`,children:[(0,H.jsx)(sT,{title:`New profile`,description:`What a session runs as - a Claude config directory, or a model provider.`}),(0,H.jsx)(cT,{children:e?(0,H.jsx)(Yie,{onCreated:n}):null})]})})}function Zie(){let e=Mr(),t=xi({select:e=>e.location.pathname.match(/^\/profiles\/(.+)$/)?.[1]}),{profiles:n,canManage:r,refresh:i}=v9(),[a,o]=(0,v.useState)(!1),s=r?(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`New profile`,onClick:()=>o(!0),children:(0,H.jsx)(yx,{className:`size-4`})}):void 0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z7,{section:`profiles`,title:`Profiles`,badge:n.length>0?(0,H.jsx)(`span`,{className:`shrink-0 text-label text-fg-4`,children:n.length}):void 0,actions:s,railActions:s,children:(0,H.jsxs)(Q7,{children:[n.length===0?(0,H.jsx)(bE,{icon:(0,H.jsx)(zy,{}),title:r?`No profiles yet`:`No profiles`,description:r?(0,H.jsxs)(H.Fragment,{children:[`Add one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]}):`This gateway declares none, and this login may not add them.`}):null,n.map(n=>(0,H.jsx)($7,{active:n.name===t,onSelect:()=>void e({to:`/profiles/$profileName`,params:{profileName:n.name}}),title:n.name,status:n.managed?null:(0,H.jsx)(po,{variant:`neutral`,className:`shrink-0`,children:`declared`}),description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(o7,{engine:n.engine??`claude`,model:n.defaults?.model??n.provider?.model,className:`size-3 shrink-0 text-fg-3`}),(0,H.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,H.jsx)(Xie,{open:a,onOpenChange:o,onCreated:t=>{o(!1),i(),e({to:`/profiles/$profileName`,params:{profileName:t}})}})]})}function Qie({sessions:e,onCreated:t}){let n=x9(`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){ZT.error(`Working directory is required`);return}i(!0);try{n.rememberCwd(r),t((await m9().createSession({...n.sessionFields({prompt:e?void 0:n.prompt.trim()||void 0,resume:e?.sessionId,allowBypass:!0}),cwd:r})).id)}catch(e){ZT.error(hk(e,`Failed to create session`))}finally{i(!1)}},d=async()=>{if(!n.cwd.trim()){ZT.error(`Set a working directory first - resumable sessions are listed per project`);return}c(!0);try{o(await m9().listSdkSessions({dir:n.cwd.trim(),limit:20,profile:n.profile||void 0}))}catch(e){ZT.error(hk(e,`Failed to list resumable sessions`))}finally{c(!1)}};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(C9,{form:n,sessions:e,promptLabel:`Initial prompt (optional)`,onProfileChange:()=>o(void 0),extras:(0,H.jsx)(S9,{form:n}),actions:(0,H.jsxs)(uo,{className:`ml-auto`,onClick:()=>void u(),disabled:r,children:[r?(0,H.jsx)(_E,{className:`size-3.5 text-current`}):(0,H.jsx)(yx,{className:`size-4`}),`Create`]})}),l.capabilities.listSessions?(0,H.jsxs)(`div`,{className:`mt-1 border-t border-border pt-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-label font-medium text-fg-3`,children:`Resume a previous session`}),(0,H.jsxs)(uo,{variant:`ghost`,size:`xs`,onClick:()=>void d(),disabled:s,children:[s?(0,H.jsx)(_E,{className:`size-3 text-current`}):(0,H.jsx)(Lx,{className:`size-3`}),a?`Reload`:`Browse`]})]}),a===void 0?null:a.length===0?(0,H.jsx)(`div`,{className:`py-3 text-center text-body-sm text-fg-4`,children:`No stored sessions for this directory.`}):(0,H.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:a.map(e=>(0,H.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate text-body-sm text-fg-1`,children:e.customTitle??e.summary}),(0,H.jsxs)(`div`,{className:`flex gap-2 font-mono text-label text-fg-4`,children:[e.gitBranch?(0,H.jsx)(`span`,{className:`truncate`,children:e.gitBranch}):null,(0,H.jsx)(`span`,{className:`shrink-0`,children:sN(e.lastModified)})]})]}),(0,H.jsx)(uo,{variant:`outline`,size:`xs`,onClick:()=>void u(e),disabled:r,children:`Resume`})]},e.sessionId))})]}):null]})}function $ie({open:e,onOpenChange:t,sessions:n,onCreated:r}){return(0,H.jsx)(aT,{open:e,onOpenChange:t,children:(0,H.jsxs)(oT,{size:`lg`,children:[(0,H.jsx)(sT,{title:`New session`,description:`Pick a directory and an engine.`}),(0,H.jsx)(cT,{children:(0,H.jsx)(Qie,{sessions:n,onCreated:r})})]})})}function eae(){return(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,H.jsx)(bE,{icon:(0,H.jsx)(T7,{}),title:`No session open`,description:(0,H.jsxs)(H.Fragment,{children:[`Pick one on the left, or start a new one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]})})})}var N9=`workerdeck.view-config`;function tae(){let[e,t]=(0,v.useState)(()=>({...FO,...S(N9,{}),search:``,scoped:!1}));return[e,(0,v.useCallback)(e=>{t(e),C(N9,e)},[])]}function nae(){let e=Mr(),t=xi({select:e=>e.location.pathname.match(/^\/sessions\/[^/]+\/(.+)$/)?.[1]??void 0}),n=jr({strict:!1}).subagent,r=jr({strict:!1}).shell,{snapshots:i,refresh:a}=d9(),o=f9(i),s=Zj(o,L7),c=i.filter(e=>e.error!==void 0),l=R7(),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]=tae(),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(bie),y=(0,v.useMemo)(()=>XO(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)=>{L7(e.hostId)?.killShell(e.info.id,t).then(()=>a()).catch(e=>ZT.error(hk(e,`Kill failed`)))},E=(e,t,n)=>{L7(e.hostId)?.setShellAgentWrite(e.info.id,t,n).then(()=>a()).catch(e=>ZT.error(hk(e,n?`Grant failed`:`Revoke failed`)))},D=(e,t)=>{L7(e.hostId)?.updateSession(e.info.id,{title:t||null}).then(()=>a()).catch(e=>ZT.error(hk(e,`Rename failed`)))},O=()=>{let e=!g;_(e),xie(e),!e&&f.search&&p({...f,search:``})},k=(e,t)=>{L7(e.hostId)?.stopTask(e.info.id,t).then(()=>a()).catch(e=>ZT.error(hk(e,`Stop failed`)))},A=(0,v.useRef)(0),j=(t,n)=>void e({to:`/sessions/$hostId/$sessionId`,params:{hostId:t.hostId,sessionId:t.info.id},search:n.toolUseId?{reveal:n.toolUseId,rn:++A.current}:{}}),M=(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`New session`,onClick:()=>h(!0),children:(0,H.jsx)(yx,{className:`size-4`})});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Z7,{section:`sessions`,title:`Sessions`,railActions:M,actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":g?`Hide search`:`Search sessions`,"aria-pressed":g,onClick:O,children:(0,H.jsx)(Xx,{className:U(`size-3.5`,g&&`text-fg-1`)})}),(0,H.jsx)(Lre,{config:f,onConfigChange:p,rows:o}),(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh`,onClick:()=>void a(),children:(0,H.jsx)(Nx,{className:`size-3.5`})}),M]}),rail:y.map(e=>(0,H.jsxs)(`button`,{type:`button`,title:`${RO(e.info)} - ${e.state}`,"aria-label":RO(e.info),onClick:()=>b(e),className:U(`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,H.jsx)(o7,{engine:e.adapter,model:e.info.model,className:`size-4`}),(0,H.jsx)(s7,{row:e})]},e.info.id)),children:[c.map(({host:e,error:t})=>(0,H.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,H.jsx)(Q7,{children:(0,H.jsx)(Qre,{rows:o,config:f,onConfigChange:p,showControls:!1,showSearch:g,autoFocusSearch:!0,projectIcons:s,activeId:t,activeSubagentId:n,activeShellId:r,onSelect:b,onSelectSubagent:S,onSelectTask:j,onStopTask:k,onSelectShell:w,onKillShell:T,onShellAgentWrite:E,onRename:D,onClearContext:e=>{let t=L7(e.hostId);if(!t)return;let n=t.attach(e.info.id,{reconnect:!1}),r=setTimeout(()=>{n.detach(),ZT.error(`Clear failed - the gateway did not answer`)},5e3);n.on(`attached`,()=>{n.clearContext(),setTimeout(()=>{clearTimeout(r),n.detach(),ZT.success(`Context cleared - the previous conversation stays resumable`),a()},150)})},onDelete:e=>{L7(e.hostId)?.deleteSession(e.info.id).then(()=>a()).catch(e=>ZT.error(hk(e,`Delete failed`)))},emptyState:(0,H.jsx)(bE,{icon:(0,H.jsx)(Zy,{}),title:`No sessions yet`,description:(0,H.jsxs)(H.Fragment,{children:[`Start one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]})})})})]}),(0,H.jsx)($ie,{open:m,onOpenChange:h,sessions:u,onCreated:e=>{h(!1),d(e),a()}})]})}function rae(){let{snapshots:e}=d9(),t=wie(f9(e));(0,v.useEffect)(()=>{document.title=t>0?`(${t}) workerdeck`:`workerdeck`},[t])}var P9=[{id:`sessions`,label:`Sessions`,icon:yS,path:`/sessions`,sidebar:nae},{id:`gateways`,label:`Gateways`,icon:_x,path:`/gateways`,sidebar:jie},{id:`jobs`,label:`Jobs`,icon:sb,path:`/jobs`,sidebar:qie},{id:`profiles`,label:`Profiles`,icon:ZS,path:`/profiles`,sidebar:Zie}],F9=`workerdeck.sidebar-collapsed`;function iae({children:e}){rae();let t=xi({select:e=>e.location.pathname}),n=[...P9].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(F9)===`1`),c=()=>{s(e=>(x(F9,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=>U(`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,H.jsxs)(`div`,{className:`flex h-dvh bg-sidebar`,children:[(0,H.jsxs)(`aside`,{className:U(`flex shrink-0 flex-col gap-1 p-3 transition-[width] duration-150`,o?`w-14 items-center`:`w-52`),children:[(0,H.jsxs)(`div`,{className:U(`flex items-center py-2`,o?`justify-center`:`gap-2 px-2`),children:[(0,H.jsx)(T7,{className:`size-4 shrink-0 text-fg-1`}),!o&&(0,H.jsx)(`span`,{className:`text-body-sm font-semibold tracking-tight text-fg-1`,children:`workerdeck`})]}),(0,H.jsx)(`nav`,{className:U(`mt-1 flex flex-1 flex-col gap-0.5`,o&&`items-center`),children:P9.map(e=>(0,H.jsxs)(Yr,{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,H.jsx)(e.icon,{className:`size-4 shrink-0`}),!o&&e.label]},e.id))}),(0,H.jsxs)(`div`,{className:U(`mt-1 grid place-items-center gap-1`,o?`grid-rows-3`:`grid-cols-3`),children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>a(!0),title:`Settings`,"aria-label":`Settings`,className:l,children:(0,H.jsx)(Eee,{className:`size-4`})}),(0,H.jsx)(d7,{}),(0,H.jsx)(`button`,{type:`button`,onClick:c,title:o?`Expand sidebar`:`Collapse sidebar`,"aria-label":o?`Expand sidebar`:`Collapse sidebar`,className:l,children:o?(0,H.jsx)(tx,{className:`size-4`}):(0,H.jsx)($b,{className:`size-4`})})]})]}),(0,H.jsxs)(`div`,{className:`app-frame frame-shine m-2 ml-0 flex min-w-0 flex-1 overflow-hidden rounded-xl`,children:[r?(0,H.jsx)(r,{},n?.id):null,(0,H.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:e??(0,H.jsx)(di,{})})]}),(0,H.jsx)(sie,{open:i,onOpenChange:a})]})}function I9({crumbs:e,actions:t,children:n}){return(0,H.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border bg-surface px-3`,children:[(0,H.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`flex min-w-0 items-center gap-1`,children:e.map((e,t)=>(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[t>0?(0,H.jsx)(nv,{"aria-hidden":!0,className:`size-3 shrink-0 text-fg-4`}):null,e.to?(0,H.jsx)(Yr,{to:e.to,className:`shrink-0 text-body-sm text-fg-3 outline-none hover:text-fg-1`,children:e.label}):(0,H.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,H.jsx)(`span`,{className:`flex-1`}),t]})}function L9({children:e}){return(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsx)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-5 px-6 py-6`,children:e})})}function R9({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-1.5`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-label font-medium text-fg-3`,children:e}),(0,H.jsx)(`span`,{className:`min-w-0 text-right text-body-sm text-fg-1`,children:t})]})}function aae(){let{hostId:e}=Ar({from:`/gateways/$hostId`}),t=Mr(),{hosts:n,ready:r}=U7(),{snapshots:i}=d9(),[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,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,H.jsx)(I9,{crumbs:[{label:`Gateways`,to:`/gateways`},{label:s.name}],actions:s.implicit?null:(0,H.jsxs)(uo,{variant:`outline`,size:`xs`,onClick:()=>o(!0),children:[(0,H.jsx)(zS,{className:`size-3`}),`Remove`]}),children:(0,H.jsx)(`span`,{className:`min-w-0 truncate font-mono text-label text-fg-4`,title:s.baseUrl,children:s.baseUrl})}),(0,H.jsxs)(L9,{children:[(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Connection`})}),(0,H.jsxs)(_o,{className:`flex flex-col divide-y divide-border`,children:[(0,H.jsx)(R9,{label:`Status`,children:l===`ok`?(0,H.jsx)(po,{variant:`success`,dot:!0,children:`Connected`}):l===`error`?(0,H.jsx)(po,{variant:`danger`,dot:!0,children:`Unreachable`}):(0,H.jsx)(po,{variant:`neutral`,dot:!0,children:`Connecting…`})}),c?.error?(0,H.jsx)(R9,{label:`Last error`,children:(0,H.jsx)(`span`,{className:`text-danger`,children:c.error})}):null,(0,H.jsx)(R9,{label:`Live sessions`,children:c?c.sessions.length:(0,H.jsx)(`span`,{className:`text-fg-4`,children:`-`})}),(0,H.jsx)(R9,{label:`Reachability`,children:z7(s)?`This machine (loopback)`:`Remote`}),(0,H.jsx)(R9,{label:`Credential`,children:s.implicit?(0,H.jsx)(`span`,{className:`text-fg-4`,children:`the login cookie it set - same origin`}):(0,H.jsx)(`span`,{className:`text-fg-4`,children:`an auth key held in this browser`})})]})]}),s.implicit?(0,H.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,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Settings`})}),(0,H.jsx)(_o,{children:(0,H.jsx)(G7,{host:s,onSaved:e=>ZT.success(`Saved ${e.name}`)},s.id)})]}),a?(0,H.jsx)(q7,{host:s,onClose:()=>o(!1),onRemoved:()=>{o(!1),t({to:`/gateways`})}}):null]})]})}function oae(){return(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,H.jsx)(bE,{icon:(0,H.jsx)(_x,{}),title:`No gateway selected`,description:(0,H.jsxs)(H.Fragment,{children:[`Pick one on the left, or add one with `,(0,H.jsx)(xE,{children:`+`}),` above.`]})})})}function sae({files:e,activePath:t,onActivate:n,onClose:r,className:i}){return(0,H.jsx)(MT,{delay:500,closeDelay:0,children:(0,H.jsx)(`div`,{"data-slot":`editor-tabs`,role:`tablist`,"aria-label":`Open files`,className:U(`flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-surface`,i),children:e.map(i=>(0,H.jsx)(cae,{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 cae({file:e,active:t,onActivate:n,onClose:r,onArrow:i}){let a=yM(e),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{t&&o.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t]),(0,H.jsxs)(PT,{side:`bottom`,render:(0,H.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:U(`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,H.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`font-mono break-all`,children:e.path}),e.bytes===void 0?null:(0,H.jsx)(`span`,{className:`text-fg-4`,children:aN(e.bytes)})]}),children:[(0,H.jsx)(`span`,{className:U(`max-w-40 truncate font-mono text-label`,a&&`italic`),children:e.name}),e.status===`error`?(0,H.jsx)(`span`,{className:`shrink-0 text-danger`,children:`!`}):null,(0,H.jsxs)(`button`,{type:`button`,"aria-label":a?`Close ${e.name} (unsaved changes)`:`Close ${e.name}`,onClick:e=>{e.stopPropagation(),r()},className:U(`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,H.jsx)(`span`,{className:U(`block`,a&&`group-hover:hidden`),children:a?(0,H.jsx)(`span`,{className:`block size-3 rounded-full bg-fg-2`}):(0,H.jsx)(hC,{className:`size-3`})}),a?(0,H.jsx)(`span`,{className:`hidden group-hover:block`,children:(0,H.jsx)(hC,{className:`size-3`})}):null]})]})}var z9=12;function lae({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,H.jsxs)(`div`,{"data-slot":`file-tree`,style:a,className:U(`flex min-h-0 min-w-0 flex-col bg-surface`,o),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-2`,children:[t?.available?(0,H.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,H.jsx)(Xx,{className:`absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-fg-4`}),(0,H.jsx)(vo,{value:s,onChange:e=>c(e.target.value),placeholder:`Search files…`,className:`h-7 pr-7 pl-7 text-label`,spellCheck:!1}),d?(0,H.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,H.jsx)(hC,{className:`size-3.5`})}):null]}):(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate px-1 text-label text-fg-4`,children:e.root}),(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh the file tree`,onClick:()=>e.refresh(),children:(0,H.jsx)(Nx,{className:`size-3.5 text-fg-3`})}),i?(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Hide project files`,onClick:i,children:(0,H.jsx)($b,{className:`size-3.5 text-fg-3`})}):null]}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-1 py-1`,children:e.error?(0,H.jsx)(`p`,{className:`px-2 py-3 text-body-sm text-danger`,children:e.error}):d?l===void 0?(0,H.jsx)(`div`,{className:`py-6 text-center`,children:(0,H.jsx)(_E,{className:`size-4 text-fg-4`})}):l.length===0?(0,H.jsx)(`p`,{className:`px-2 py-6 text-center text-body-sm text-fg-4`,children:`No matching files.`}):(0,H.jsx)(`ul`,{children:l.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(B9,{label:uae(e.relative),detail:dae(e.relative),title:e.relative,icon:(0,H.jsx)(ay,{className:`size-3.5 shrink-0 text-fg-4`}),active:e.path===n,onClick:()=>r(e.path)})},e.path))}):e.loading?(0,H.jsx)(`div`,{className:`py-6 text-center`,children:(0,H.jsx)(_E,{className:`size-4 text-fg-4`})}):e.rows.length===0?(0,H.jsx)(`p`,{className:`px-2 py-6 text-center text-body-sm text-fg-4`,children:`This project is empty.`}):(0,H.jsx)(`ul`,{role:`tree`,"aria-label":`Project files`,children:e.rows.map(t=>(0,H.jsxs)(`li`,{role:`treeitem`,"aria-expanded":t.expanded,"aria-level":t.depth+1,children:[(0,H.jsx)(B9,{label:t.entry.name,indent:t.depth,active:t.entry.path===n,icon:t.entry.type===`dir`?t.loading?(0,H.jsx)(_E,{className:`size-3.5 shrink-0 text-fg-4`}):t.expanded?(0,H.jsx)(py,{className:`size-3.5 shrink-0 text-accent`}):(0,H.jsx)(yy,{className:`size-3.5 shrink-0 text-accent`}):(0,H.jsx)(n3,{type:t.entry.type}),chevron:t.entry.type===`dir`?(0,H.jsx)(nv,{className:U(`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,H.jsx)(`p`,{className:`truncate py-0.5 text-label text-fg-4`,style:{paddingLeft:(t.depth+1)*z9+22},children:`More entries than the server will return - use search.`}):null]},t.entry.path))})})]})}function B9({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,H.jsxs)(`button`,{ref:c,type:`button`,onClick:s,title:n??e,style:{paddingLeft:a*z9+4},className:U(`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,H.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center`,children:i}),r,(0,H.jsx)(`span`,{className:`shrink-0 truncate text-label`,children:e}),t?(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label text-fg-4`,children:t}):null]})}function uae(e){return e.slice(e.lastIndexOf(`/`)+1)}function dae(e){let t=e.lastIndexOf(`/`);return t===-1?void 0:e.slice(0,t)}function fae({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=pae(),f=(0,v.useRef)({onChange:n,onSave:r});return f.current={onChange:n,onSave:r},(0,v.useEffect)(()=>{let n=!1;return mae().then(r=>{if(n||!o.current)return;c.current=r;let a=r.editor.create(o.current,{value:t,language:U9(e),readOnly:i,automaticLayout:!0,theme:V9(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,U9(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(V9(d))},[d,l]),(0,H.jsxs)(`div`,{className:U(`relative min-h-0 min-w-0 flex-1`,a),children:[(0,H.jsx)(`div`,{ref:o,className:`absolute inset-0`}),l?null:(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bg`,children:(0,H.jsx)(_E,{className:`size-4 text-fg-4`})})]})}function pae(){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 V9(e){return e===`light`?`wd-light`:`wd-dark`}var H9;function mae(){return H9??=(async()=>{let e=await kM(()=>import(`./vs-OdJ6Y9dc.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})(),H9}function U9(e){let t=e.slice(e.lastIndexOf(`/`)+1);return hae[t.toLowerCase()]||(gae[t.slice(t.lastIndexOf(`.`)+1).toLowerCase()]??`plaintext`)}var hae={dockerfile:`dockerfile`,makefile:`plaintext`,".gitignore":`plaintext`,".env":`shell`},gae={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 _ae({file:e,canWrite:t,onChange:n,onSave:r,onRevert:i,onReload:a,onOverwrite:o,onDismissConflict:s,className:c}){return e?(0,H.jsxs)(`div`,{"data-slot":`file-viewer`,className:U(`flex min-h-0 min-w-0 flex-1 flex-col bg-bg`,c),children:[e.conflict?(0,H.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,H.jsx)(US,{className:`size-3.5 shrink-0 text-warning`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-warning`,children:`This file changed on disk since you opened it.`}),(0,H.jsx)(uo,{variant:`outline`,size:`xs`,onClick:()=>a?.(e.path),children:`Use the version on disk`}),(0,H.jsx)(uo,{variant:`outline`,size:`xs`,onClick:()=>o?.(e.path),children:`Keep mine`}),(0,H.jsx)(uo,{variant:`ghost`,size:`xs`,onClick:()=>s?.(e.path),children:`Dismiss`})]}):e.saveError?(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-danger/40 bg-danger-bg px-3 py-2`,children:[(0,H.jsx)(US,{className:`size-3.5 shrink-0 text-danger`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-danger`,children:e.saveError}),(0,H.jsx)(uo,{variant:`ghost`,size:`xs`,onClick:()=>s?.(e.path),children:`Dismiss`})]}):null,e.status===`loading`?(0,H.jsx)(W9,{children:(0,H.jsx)(_E,{className:`size-4 text-fg-4`})}):e.status===`error`?(0,H.jsxs)(W9,{children:[(0,H.jsx)(US,{className:`size-4 text-danger`}),(0,H.jsx)(`p`,{className:`text-body-sm text-danger`,children:e.error})]}):e.status===`binary`?(0,H.jsxs)(W9,{children:[(0,H.jsx)(ty,{className:`size-4 text-fg-4`}),(0,H.jsx)(`p`,{className:`text-body-sm text-fg-4`,children:`This file isn’t text.`}),(0,H.jsx)(`p`,{className:`text-label text-fg-4`,children:`It can’t be edited here without corrupting it.`})]}):(0,H.jsx)(fae,{path:e.path,value:bM(e),readOnly:!t,onChange:n?t=>n(e.path,t):void 0,onSave:r?()=>r(e.path):void 0}),e.status===`ready`&&(e.saving||yM(e)||!t)?(0,H.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-border px-3 py-1`,children:e.saving?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_E,{className:`size-3 text-fg-4`}),(0,H.jsx)(`span`,{className:`text-label text-fg-4`,children:`Saving…`})]}):t?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-label text-fg-3`,children:`Unsaved changes`}),(0,H.jsx)(`span`,{className:`flex-1`}),(0,H.jsx)(uo,{variant:`ghost`,size:`xs`,onClick:()=>i?.(e.path),children:`Revert`}),(0,H.jsxs)(uo,{variant:`outline`,size:`xs`,onClick:()=>r?.(e.path),children:[`Save`,(0,H.jsx)(`span`,{className:`ml-1 text-fg-4`,children:`⌘S`})]})]}):(0,H.jsx)(`span`,{className:`text-label text-fg-4`,children:`Read-only - this gateway doesn’t allow writes.`})}):null]}):null}function W9({children:e}){return(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-6`,children:e})}var vae=180,yae=520,bae=220,G9=120;function K9({client:e,sessionId:t,header:n,transcriptVariant:r,transcriptFont:i,affordances: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}=vM(e,t),j=A?.cwd,M=Wj(e,j),N=Hj(e,j),P=TM(e),{canWrite:F}=Uj(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=Sae(),[L,R]=(0,v.useState)(D??!1),[z,ee]=(0,v.useState)(E),te=(0,v.useRef)(O);te.current=O,(0,v.useEffect)(()=>{te.current?.({width:z,collapsed:L})},[z,L]);let[ne,re]=(0,v.useState)(360),ie=P.files.length>0,B=!I,ae=M.available&&!L;(0,v.useEffect)(()=>{B&&R(!0)},[B]);let oe=(0,v.useCallback)(e=>{let t=P.files.find(t=>t.path===e);if(t&&yM(t)){let e=t.name;if(!window.confirm(`${e} has unsaved changes. Close it and lose them?`))return}P.close(e)},[P]),V=(0,v.useRef)(null),se=xae(V);Nre({container:V,onOpen:(0,v.useCallback)(({path:e})=>P.open(Pre(e,j)),[P.open,j]),enabled:M.available,ignore:`.monaco-editor, .xterm`});let ce=Math.max(G9,se-bae),[le,ue]=(0,v.useState)(null),de=n===void 0||le===null?void 0:typeof n==`function`?e=>(0,Ed.createPortal)(n(e),le):(0,Ed.createPortal)(n,le);return(0,H.jsxs)(`div`,{"data-slot":`session-workspace`,className:U(`flex h-full min-h-0 w-full flex-col overflow-hidden bg-bg`,k),children:[n===void 0?null:(0,H.jsx)(`div`,{ref:ue,className:`shrink-0`}),(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[ae?(0,H.jsx)(lae,{tree:M,search:N,activePath:P.activePath,onOpenFile:P.open,onCollapse:()=>R(!0),style:{width:B?Math.min(z,320):z},className:U(`shrink-0 border-r border-border`,B&&`absolute inset-y-0 left-0 z-20 shadow-lg`)}):M.available?(0,H.jsx)(`div`,{className:`flex w-8 shrink-0 flex-col items-center border-r border-border bg-surface pt-1.5`,children:(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Show project files`,onClick:()=>R(!1),children:(0,H.jsx)(tx,{className:`size-4 text-fg-3`})})}):null,ae&&!B?(0,H.jsx)(yE,{orientation:`vertical`,value:z,onValueChange:ee,min:vae,max:yae,defaultValue:E,"aria-label":`Resize the file tree`}):null,(0,H.jsxs)(`div`,{ref:V,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[ie?(0,H.jsxs)(`div`,{className:`flex min-h-0 shrink-0 flex-col overflow-hidden`,style:{height:Math.min(ne,ce||ne)},children:[(0,H.jsx)(sae,{files:P.files,activePath:P.activePath,onActivate:P.activate,onClose:oe}),(0,H.jsx)(_ae,{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,ie?(0,H.jsx)(yE,{orientation:`horizontal`,value:Math.min(ne,ce||ne),onValueChange:re,min:G9,max:ce,"aria-label":`Resize the open file`}):null,(0,H.jsx)(Cre,{client:e,sessionId:t,header:de,transcriptVariant:r,transcriptFont:i,affordances: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`})]}),B&&ae?(0,H.jsx)(`button`,{type:`button`,"aria-label":`Close the file tree`,onClick:()=>R(!0),className:`absolute inset-0 z-10 bg-black/30`}):null]})]})}function xae(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 Sae(){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 q9=`workerdeck.rail`,Cae={width:260,collapsed:!1};function J9(){let e=S(q9,{});return{width:Math.min(520,Math.max(180,Number(e.width)||Cae.width)),collapsed:e.collapsed===!0}}function Y9(e){C(q9,e)}function wae(){let{jobId:e}=Ar({from:`/jobs/$jobId`}),t=Mr(),{jobs:n,refresh:r}=O9(),{snapshots:i}=d9(),a=n.find(t=>t.id===e),o=m9(),s=R7()?.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&&(ZT.error(`That job is no longer in the queue`),t({to:`/jobs`}))},[l,a,t]);let[d]=(0,v.useState)(m7),[f]=(0,v.useState)(g7),[p]=(0,v.useState)(S7),[m]=(0,v.useState)(v7),[h]=(0,v.useState)(J9);if(!a)return null;let g=(0,H.jsx)(X9,{job:a,onChanged:()=>void r()});return!o||!c||!a.sessionId?(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[g,(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center`,children:[(0,H.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,H.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,H.jsx)(K9,{client:o,sessionId:a.sessionId,readOnly:!0,transcriptVariant:d,transcriptFont:f,affordances:{labels:p===`labeled`},fontSize:m,scrubber:!0,stickyPrompt:!0,statusPlacement:`bottom`,defaultRailWidth:h.width,defaultRailCollapsed:h.collapsed,onRailChange:Y9,header:({actions:e})=>(0,H.jsx)(X9,{job:a,onChanged:()=>void r(),actions:e})},a.sessionId)}function X9({job:e,onChanged:t,actions:n}){let r=k9[e.status],i=e.status===`queued`||e.status===`running`||e.status===`parked`,a=async()=>{try{await m9().cancelJob(e.id),t()}catch(e){ZT.error(hk(e,`Cancel failed`))}};return(0,H.jsxs)(I9,{crumbs:[{label:`Jobs`,to:`/jobs`},{label:e.prompt}],actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(po,{variant:`neutral`,className:`shrink-0`,children:`read-only`}),(0,H.jsx)(gE,{value:e.id,"aria-label":`Copy job id`}),i?(0,H.jsxs)(uo,{variant:`outline`,size:`xs`,onClick:()=>void a(),children:[(0,H.jsx)(hC,{className:`size-3`}),`Cancel`]}):null,n]}),children:[(0,H.jsxs)(po,{variant:r.variant,dot:!r.busy,className:`shrink-0`,children:[r.busy?(0,H.jsx)(_E,{className:`size-3 text-current`}):null,r.label]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-x-3 font-mono text-label text-fg-4`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:e.cwd}),e.profile?(0,H.jsxs)(`span`,{className:`shrink-0`,children:[`@`,e.profile]}):null,(0,H.jsx)(`span`,{className:`shrink-0`,children:sN(e.finishedAt??e.startedAt??e.createdAt)}),e.maxAttempts!==void 0&&e.maxAttempts>1?(0,H.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,H.jsxs)(`span`,{className:`shrink-0`,children:[iN(e.usage.tokens),` tok`]}):null,(e.usage.costUsd??e.usage.totalCostUsd)>0?(0,H.jsx)(`span`,{className:`shrink-0`,children:nN(e.usage.costUsd??e.usage.totalCostUsd)}):null,e.error?(0,H.jsx)(`span`,{className:`truncate text-danger`,children:e.error}):null]})]})}function Tae({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=h9(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:j9(d).length>0?j9(d):void 0},i.session={capabilities:p,mcpServers:j9(h).length>0?j9(h):void 0,instructions:_.trim()||void 0}),x(!0);try{t(await m9().updateProfile(e.name,i)),ZT.success(`Profile saved`)}catch(e){ZT.error(hk(e,`Failed to save profile`))}finally{x(!1)}};return(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Edit profile`})}),(0,H.jsxs)(_o,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(M9,{label:`Description`,children:(0,H.jsx)(vo,{value:r,onChange:e=>i(e.target.value)})}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`Default model`,children:C.length>1?(0,H.jsx)(p9,{value:a,onChange:o,models:C}):(0,H.jsx)(vo,{value:a,onChange:e=>o(e.target.value),placeholder:`unset - request / engine default`,className:`font-mono`})}),(0,H.jsx)(M9,{label:`Default permission mode`,children:(0,H.jsx)(E3,{variant:`form`,mode:s,onModeChange:c,modes:S.modes})})]}),n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`Default model id`,children:(0,H.jsx)(vo,{value:l,onChange:e=>u(e.target.value),className:`font-mono`})}),(0,H.jsx)(M9,{label:`Models offered (comma-separated)`,children:(0,H.jsx)(vo,{value:d,onChange:e=>f(e.target.value),className:`font-mono`})})]}),(0,H.jsx)(M9,{label:`Capabilities granted`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 py-1.5`,children:[(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,H.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`]}),A9.map(e=>(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2`,children:[(0,H.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,H.jsx)(`code`,{className:`font-mono text-label`,children:e})]},e))]})}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsx)(M9,{label:`MCP servers (names, comma-separated)`,children:(0,H.jsx)(vo,{value:h,onChange:e=>g(e.target.value),className:`font-mono`})}),(0,H.jsx)(M9,{label:`Instructions`,children:(0,H.jsx)(vo,{value:_,onChange:e=>y(e.target.value)})})]})]}):null,(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.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,H.jsxs)(uo,{onClick:()=>void w(),disabled:b,children:[b?(0,H.jsx)(_E,{className:`size-3.5 text-current`}):(0,H.jsx)(Cee,{className:`size-4`}),`Save`]})]})]})]})}function Eae(e){window.location.href=`vscode://file${e}`}function Dae(){return(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,H.jsx)(bE,{icon:(0,H.jsx)(ZS,{}),title:`No profile selected`,description:`A profile is what a session runs as - its config directory and credentials, or a model provider.`})})}function Z9({items:e,empty:t}){return e.length===0?(0,H.jsx)(`span`,{className:`text-fg-4`,children:t}):(0,H.jsx)(`span`,{className:`flex flex-wrap justify-end gap-1`,children:e.map(e=>(0,H.jsx)(po,{variant:`neutral`,children:e},e))})}function Oae(){let{profileName:e}=Ar({from:`/profiles/$profileName`}),t=Mr(),{refresh:n}=v9(),{ready:r}=U7(),i=zj(async()=>m9()?.getProfile(e),[e,r],{enabled:r,pollMs:6e4}),a=i.data,o=i.error===void 0?void 0:hk(i.error,`Failed to load profile`),s=a?.profile,c=a?.config,l=(0,v.useMemo)(()=>$k(s?.usage),[s?.usage]),u=async()=>{try{await m9().deleteProfile(e),await n(),ZT.success(`Profile '${e}' deleted`),t({to:`/profiles`})}catch(e){ZT.error(hk(e,`Delete failed`))}};return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,H.jsx)(I9,{crumbs:[{label:`Profiles`,to:`/profiles`},{label:e}],actions:(0,H.jsxs)(H.Fragment,{children:[s?.configDir?(0,H.jsxs)(uo,{variant:`outline`,size:`xs`,onClick:()=>Eae(s.configDir),children:[(0,H.jsx)(Cv,{className:`size-3`}),`Open in VSCode`]}):null,s?.managed?(0,H.jsxs)(uo,{variant:`outline`,size:`xs`,onClick:()=>void u(),children:[(0,H.jsx)(zS,{className:`size-3`}),`Delete`]}):null]}),children:s?.description?(0,H.jsx)(`span`,{className:`min-w-0 truncate text-label text-fg-4`,children:s.description}):null}),(0,H.jsxs)(L9,{children:[o?(0,H.jsx)(`div`,{className:`rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger`,children:o}):null,!a&&!o?(0,H.jsx)(_E,{className:`mx-auto size-5 text-fg-4`}):null,s&&c?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Worker defaults`})}),(0,H.jsxs)(_o,{className:`flex flex-col divide-y divide-border`,children:[(0,H.jsx)(R9,{label:`Engine`,children:(0,H.jsx)(po,{variant:`neutral`,children:s.engine??`claude`})}),s.engine===`provider`?(0,H.jsx)(R9,{label:`Provider`,children:(0,H.jsx)(`span`,{className:`font-mono text-label`,children:s.provider?.id})}):(0,H.jsx)(R9,{label:`Config directory`,children:(0,H.jsx)(`span`,{className:`font-mono text-label`,children:s.configDir})}),(0,H.jsx)(R9,{label:`Default model`,children:s.defaults?.model??s.provider?.model??(0,H.jsx)(`span`,{className:`text-fg-4`,children:`request / engine default`})}),(0,H.jsx)(R9,{label:`Default permission mode`,children:s.defaults?.permissionMode??(0,H.jsx)(`span`,{className:`text-fg-4`,children:`request / engine default`})}),s.engine===`provider`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(R9,{label:`Models offered`,children:(0,H.jsx)(Z9,{items:s.provider?.models??[],empty:`the default model only`})}),(0,H.jsx)(R9,{label:`API key variable`,children:s.provider?.apiKeyEnv?(0,H.jsx)(`span`,{className:`font-mono text-label`,children:s.provider.apiKeyEnv}):(0,H.jsx)(`span`,{className:`text-fg-4`,children:`provider SDK default`})})]}):null]})]}),l.length>0?(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Plan usage`})}),(0,H.jsx)(_o,{children:(0,H.jsx)(G5,{windows:l})})]}):null,s.engine===`provider`?(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Session grants`})}),(0,H.jsxs)(_o,{className:`flex flex-col divide-y divide-border`,children:[(0,H.jsx)(R9,{label:`Capabilities`,children:(0,H.jsx)(Z9,{items:s.session?.capabilities??[],empty:`not declared - whatever the server wired`})}),(0,H.jsx)(R9,{label:`MCP servers`,children:(0,H.jsx)(Z9,{items:s.session?.mcpServers??[],empty:`not declared - every connected server`})}),(0,H.jsx)(R9,{label:`Instructions`,children:s.session?.instructions?`${s.session.instructions.length} characters`:(0,H.jsx)(`span`,{className:`text-fg-4`,children:`none`})})]})]}):null,s.engine===`provider`?null:(0,H.jsxs)(mo,{children:[(0,H.jsx)(ho,{children:(0,H.jsx)(go,{children:`Claude Code configuration`})}),(0,H.jsxs)(_o,{className:`flex flex-col divide-y divide-border`,children:[c.settings?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(R9,{label:`Model (settings.json)`,children:c.settings.model??(0,H.jsx)(`span`,{className:`text-fg-4`,children:`not set`})}),(0,H.jsx)(R9,{label:`Default permission mode`,children:c.settings.defaultPermissionMode??(0,H.jsx)(`span`,{className:`text-fg-4`,children:`not set`})}),(0,H.jsx)(R9,{label:`Permission rules`,children:(0,H.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,H.jsx)(R9,{label:`Env vars (names only)`,children:(0,H.jsx)(Z9,{items:c.settings.envKeys??[],empty:`none`})}),(0,H.jsx)(R9,{label:`Hooks`,children:(0,H.jsx)(Z9,{items:c.settings.hooks??[],empty:`none`})})]}):(0,H.jsx)(R9,{label:`settings.json`,children:(0,H.jsx)(`span`,{className:`text-fg-4`,children:`not found`})}),(0,H.jsx)(R9,{label:`User memory (CLAUDE.md)`,children:c.hasUserMemory?`present`:(0,H.jsx)(`span`,{className:`text-fg-4`,children:`none`})}),(0,H.jsx)(R9,{label:`Skills`,children:(0,H.jsx)(Z9,{items:c.skills,empty:`none`})}),(0,H.jsx)(R9,{label:`Agents`,children:(0,H.jsx)(Z9,{items:c.agents,empty:`none`})}),(0,H.jsx)(R9,{label:`Commands`,children:(0,H.jsx)(Z9,{items:c.commands,empty:`none`})})]})]}),s.managed?(0,H.jsx)(Tae,{profile:s,onSaved:e=>i.setData({...a,profile:e})}):null,(0,H.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,H.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]})]})}function kae(){let{hostId:e,sessionId:t}=Ar({from:`/sessions/$hostId/$sessionId`}),{ready:n}=U7(),r=Mr(),i=L7(e);return(0,v.useEffect)(()=>{n&&!i&&(ZT.error(`That gateway is not configured here`),r({to:`/sessions`}))},[n,i,r]),i?(0,H.jsx)(Aae,{hostId:e,sessionId:t,client:i},`${e}:${t}`):null}function Aae({hostId:e,sessionId:t,client:n}){let r=Mr(),{subagent:i,sn:a,reveal:o,rn:s,shell:c,shn:l}=jr({from:`/sessions/$hostId/$sessionId`}),{info:u,error:d}=vM(n,t),f=Cie(e,t),{bookmarks:p,toggle:m}=hM(`${e}:${t}`),[h]=(0,v.useState)(()=>b7()===`on`?Sie(e,t):void 0),[g]=(0,v.useState)(m7),[_]=(0,v.useState)(g7),[y]=(0,v.useState)(S7),[b]=(0,v.useState)(v7),[x]=(0,v.useState)(J9);(0,v.useEffect)(()=>{d&&(ZT.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}=d9(),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,H.jsx)(K9,{client:n,sessionId:t,transcriptVariant:g,transcriptFont:_,affordances:{labels:y===`labeled`},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:Y9,unseen:h,onVitals:e=>{f({itemCount:e.itemCount}),kie()},header:({actions:e})=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border bg-surface px-3 py-2`,children:[(0,H.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,H.jsx)(po,{variant:`neutral`,className:`shrink-0`,children:u.engine}):null,u?.cwd?(0,H.jsx)(`span`,{className:`min-w-0 truncate font-mono text-label text-fg-4`,title:u.cwd,children:u.cwd}):null,(0,H.jsx)(`span`,{className:`flex-1`}),(0,H.jsx)(gE,{value:t,"aria-label":`Copy session id`}),(0,H.jsxs)(qC,{children:[(0,H.jsx)(JC,{render:(0,H.jsx)(uo,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close session`,children:(0,H.jsx)(zS,{className:`size-4 text-fg-3`})})}),(0,H.jsxs)(XC,{children:[(0,H.jsx)(ZC,{children:`Close this session?`}),(0,H.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,H.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,H.jsx)(YC,{render:(0,H.jsx)(uo,{variant:`outline`,children:`Cancel`})}),(0,H.jsx)(uo,{variant:`destructive`,onClick:()=>void E(),children:`Close session`})]})]})]}),e]})},t)}var Q9=ei({component:iae}),jae=Qr({getParentRoute:()=>Q9,path:`/`,beforeLoad:()=>{throw He({to:`/sessions`})}}),Mae=Qr({getParentRoute:()=>Q9,path:`/sessions`,component:eae}),Nae=Qr({getParentRoute:()=>Q9,path:`/sessions/$hostId/$sessionId`,component:kae,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})}),Pae=Qr({getParentRoute:()=>Q9,path:`/gateways`,component:oae}),Fae=Qr({getParentRoute:()=>Q9,path:`/gateways/$hostId`,component:aae}),Iae=Qr({getParentRoute:()=>Q9,path:`/jobs`,component:Gie}),Lae=Qr({getParentRoute:()=>Q9,path:`/jobs/$jobId`,component:wae}),Rae=Qr({getParentRoute:()=>Q9,path:`/profiles`,component:Dae}),zae=Qr({getParentRoute:()=>Q9,path:`/profiles/$profileName`,component:Oae}),Bae=_i({routeTree:Q9.addChildren([jae,Mae,Nae,Pae,Fae,Iae,Lae,Rae,zae]),history:Tt()});function Vae(){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(bi,{router:Bae}),(0,H.jsx)(pE,{})]})}E();var $9=document.getElementById(`root`);if(!$9)throw Error(`Root element #root not found`);(0,y.createRoot)($9).render((0,H.jsx)(v.StrictMode,{children:(0,H.jsx)(Vae,{})}));export{kM as a,s as c,_Q as i,l,$1 as n,Un as o,r0 as r,d as s,KQ as t};