nomadexapp 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/nomadex.mjs +13 -6
- package/dist/assets/{dist-DO7LTg3a.js → dist-Alz6ZkbS.js} +1 -1
- package/dist/assets/{dist-BVTS1puf.js → dist-B4-hQjtE.js} +1 -1
- package/dist/assets/{dist-DH3Q_V27.js → dist-B6cfXU5R.js} +1 -1
- package/dist/assets/{dist-BOz4jprC.js → dist-BDEXao6W.js} +1 -1
- package/dist/assets/{dist-D6kXrcQY.js → dist-BFpuo4hT.js} +1 -1
- package/dist/assets/{dist-CUQQ4au1.js → dist-Bk6w2PLG.js} +1 -1
- package/dist/assets/{dist-ByyB_57-.js → dist-Bz_abif3.js} +1 -1
- package/dist/assets/{dist-CyFWfPpu.js → dist-CMb9XHCS.js} +1 -1
- package/dist/assets/{dist--QplBylv.js → dist-CdfyROF-.js} +1 -1
- package/dist/assets/{dist-ChuUwcd4.js → dist-D0ChGMIP.js} +1 -1
- package/dist/assets/{dist-Cuva2wRW.js → dist-D9-TuUR1.js} +1 -1
- package/dist/assets/{dist-BvjF9csH.js → dist-DZ2ryQd4.js} +1 -1
- package/dist/assets/{dist-mCTXNkQ9.js → dist-o59V-mFz.js} +1 -1
- package/dist/assets/{dist-C5sjJwrm.js → dist-t6-iLg-t.js} +1 -1
- package/dist/assets/{index-BpFNmvYv.js → index-DSb49pJE.js} +6 -6
- package/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D0ChGMIP.js","assets/dist-DhhFPaYP.js","assets/dist-C_ZftsU-.js","assets/dist-DYBvJnrG.js","assets/dist-o59V-mFz.js","assets/dist-Bz_abif3.js","assets/dist-Alz6ZkbS.js","assets/dist-B6cfXU5R.js","assets/dist-elfU6IUT.js","assets/dist-BFpuo4hT.js","assets/dist-Cc03jTPl.js","assets/dist-DZ2ryQd4.js","assets/dist-D9-TuUR1.js","assets/dist-CdfyROF-.js","assets/dist-Bk6w2PLG.js","assets/dist-CMb9XHCS.js","assets/dist-C6S96i9v.js","assets/dist-t6-iLg-t.js","assets/dist-BSpuB3dZ.js","assets/dist-DIQDx3Dq.js","assets/dist-CftiQ_Tf.js","assets/dockerfile-BBRxgo6-.js","assets/simple-mode-BwNcRC8_.js","assets/factor-bi5FmZTz.js","assets/nsis-BHchP6IS.js","assets/pug-C39WZDG2.js","assets/javascript-B9Zm1tmO.js","assets/dist-B4-hQjtE.js","assets/dist-BDEXao6W.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{$ as e,A as t,At as n,Ct as r,Dt as i,E as a,Et as o,Ft as s,G as c,J as l,K as u,L as d,Mt as f,Nt as p,O as m,Ot as h,P as g,Pt as _,Q as v,S as y,St as b,T as x,Tt as S,W as C,X as w,Y as T,Z as E,_t as D,a as O,at as ee,bt as te,c as ne,ct as re,dt as k,et as A,f as ie,ft as ae,g as oe,gt as se,ht as ce,it as j,j as M,jt as le,kt as ue,l as de,lt as fe,mt as pe,n as me,nt as he,o as ge,ot as _e,pt as N,q as ve,rt as ye,st as be,t as xe,tt as Se,ut as Ce,v as we,vt as P,w as Te,wt as Ee,x as De,xt as Oe,yt as ke}from"./dist-DhhFPaYP.js";var Ae=Object.create,je=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ne=Object.getOwnPropertyNames,Pe=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty,F=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ie=(e,t)=>{let n={};for(var r in e)je(n,r,{get:e[r],enumerable:!0});return t||je(n,Symbol.toStringTag,{value:`Module`}),n},Le=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Ne(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Fe.call(e,s)&&s!==n&&je(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Me(t,s))||r.enumerable});return e},Re=(e,t,n)=>(n=e==null?{}:Ae(Pe(e)),Le(t||!e||!e.__esModule?je(n,`default`,{value:e,enumerable:!0}):n,e));(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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ze=F((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&&ne(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&&ne(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 ee=new MessageChannel,te=ee.port2;ee.port1.onmessage=D,O=function(){te.postMessage(null)}}else O=function(){_(D,0)};function ne(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,ne(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}}}})),Be=F(((e,t)=>{t.exports=ze()})),Ve=F((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.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.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`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function ne(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function re(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(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 k(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,k(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ne(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),k(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ne(a,u),c+=k(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ne(a,u++),c+=k(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return k(re(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 A(e,t,n){if(e==null)return e;var r=[],i=0;return k(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ie(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var ae=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)},oe={map:A,forEach:function(e,t,n){A(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return A(e,function(){t++}),t},toArray:function(e){return A(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=oe,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},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=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.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 E(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)T.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 E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ie}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,ae)}catch(e){ae(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),He=F(((e,t)=>{t.exports=Ve()})),Ue=F((e=>{var t=He();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`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(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.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 o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.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=c(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=c(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})}}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=c(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=c(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})}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 s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),We=F(((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=Ue()})),Ge=F((e=>{var t=Be(),n=He(),r=We();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){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n: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 d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function ee(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var te=Symbol.for(`react.client.reference`);function ne(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?ne(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return ne(e(t))}catch{}}return null}var re=Array.isArray,k=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie={pending:!1,data:null,method:null,action:null},ae=[],oe=-1;function se(e){return{current:e}}function ce(e){0>oe||(e.current=ae[oe],ae[oe]=null,oe--)}function j(e,t){oe++,ae[oe]=e.current,e.current=t}var M=se(null),le=se(null),ue=se(null),de=se(null);function fe(e,t){switch(j(ue,t),j(le,e),j(M,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?qd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=qd(t),e=Jd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ce(M),j(M,e)}function pe(){ce(M),ce(le),ce(ue)}function me(e){e.memoizedState!==null&&j(de,e);var t=M.current,n=Jd(t,e.type);t!==n&&(j(le,e),j(M,n))}function he(e){le.current===e&&(ce(M),ce(le)),de.current===e&&(ce(de),np._currentValue=ie)}var ge,_e;function N(e){if(ge===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||``,_e=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ge+e+_e}var ve=!1;function ye(e,t){if(!e||ve)return``;ve=!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}e.call(n.prototype)}}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(`
|
|
@@ -204,11 +204,11 @@ console.log(qwenRoot);`],cwd:e,timeoutMs:5e3});if(t.exitCode!==0){let e=Jl([t.st
|
|
|
204
204
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
205
205
|
`,...a.current()});return/^[\t ]/.test(l)&&(l=mb(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}bb.peek=xb;function bb(e){return e.value||``}function xb(){return`<`}Sb.peek=Cb;function Sb(e,t,n,r){let i=db(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Cb(){return`!`}wb.peek=Tb;function wb(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Tb(){return`!`}Eb.peek=Db;function Eb(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Db(){return"`"}function Ob(e,t){let n=rm(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}kb.peek=Ab;function kb(e,t,n,r){let i=db(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Ob(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Ab(e,t,n){return Ob(e,n)?`<`:`[`}jb.peek=Mb;function jb(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Mb(){return`[`}function Nb(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Pb(e){let t=Nb(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Fb(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ib(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Lb(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Fb(n):Nb(n),s=e.ordered?o===`.`?`)`:`.`:Pb(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Ib(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Rb(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function zb(e,t,n,r){let i=Rb(n),a=n.bulletCurrent||Nb(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function Bb(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var Vb=J_([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Hb(e,t,n,r){return(e.children.some(function(e){return Vb(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Ub(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Wb.peek=Gb;function Wb(e,t,n,r){let i=Ub(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=hb(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=mb(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=hb(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+mb(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Gb(e,t,n){return n.options.strong||`*`}function Kb(e,t,n,r){return n.safe(e.value,r)}function qb(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Jb(e,t,n){let r=(Ib(n)+(n.options.ruleSpaces?` `:``)).repeat(qb(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Yb={blockquote:tb,break:ab,code:lb,definition:fb,emphasis:gb,hardBreak:ab,heading:yb,html:bb,image:Sb,imageReference:wb,inlineCode:Eb,link:kb,linkReference:jb,list:Lb,listItem:zb,paragraph:Bb,root:Hb,strong:Wb,text:Kb,thematicBreak:Jb};function Xb(){return{enter:{table:Zb,tableData:tx,tableHeader:tx,tableRow:$b},exit:{codeText:nx,table:Qb,tableData:ex,tableHeader:ex,tableRow:ex}}}function Zb(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function Qb(e){this.exit(e),this.data.inTable=void 0}function $b(e){this.enter({type:`tableRow`,children:[]},e)}function ex(e){this.exit(e)}function tx(e){this.enter({type:`tableCell`,children:[]},e)}function nx(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,rx));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function rx(e,t){return t===`|`?t:e}function ix(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
206
206
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
207
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Qy(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Yb.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function ax(){return{exit:{taskListCheckValueChecked:sx,taskListCheckValueUnchecked:sx,paragraph:cx}}}function ox(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:lx}}}function sx(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function cx(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function lx(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Yb.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function ux(){return[gy(),By(),Gy(),Xb(),ax()]}function dx(e){return{extensions:[_y(),Vy(e),Ky(),ix(e),ox()]}}var fx={tokenize:Ex,partial:!0},px={tokenize:Dx,partial:!0},mx={tokenize:Ox,partial:!0},hx={tokenize:kx,partial:!0},gx={tokenize:Ax,partial:!0},_x={name:`wwwAutolink`,tokenize:wx,previous:jx},vx={name:`protocolAutolink`,tokenize:Tx,previous:Mx},yx={name:`emailAutolink`,tokenize:Cx,previous:Nx},bx={};function xx(){return{text:bx}}for(var Sx=48;Sx<123;)bx[Sx]=yx,Sx++,Sx===58?Sx=65:Sx===91&&(Sx=97);bx[43]=yx,bx[45]=yx,bx[46]=yx,bx[95]=yx,bx[72]=[yx,vx],bx[104]=[yx,vx],bx[87]=[yx,_x],bx[119]=[yx,_x];function Cx(e,t,n){let r=this,i,a;return o;function o(t){return!Px(t)||!Nx.call(r,r.previous)||Fx(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Px(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(gx,u,l)(t):t===45||t===95||vm(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&_m(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function wx(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!jx.call(r,r.previous)||Fx(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(fx,e.attempt(px,e.attempt(mx,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Tx(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Mx.call(r,r.previous)&&!Fx(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(_m(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||bm(t)||wm(t)||Em(t)||Tm(t)?n(t):e.attempt(px,e.attempt(mx,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Ex(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Dx(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(hx,c,s)(t):t===null||wm(t)||Em(t)||t!==45&&Tm(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Ox(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(hx,t,a)(o):o===null||wm(o)||Em(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function kx(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||wm(o)||Em(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||wm(e)||Em(e)?t(e):r(e)}function a(e){return _m(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):_m(t)?(e.consume(t),o):n(t)}}function Ax(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return vm(e)?n(e):t(e)}}function jx(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||wm(e)}function Mx(e){return!_m(e)}function Nx(e){return!(e===47||Px(e))}function Px(e){return e===43||e===45||e===46||e===95||vm(e)}function Fx(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Ix={tokenize:Wx,partial:!0};function Lx(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Vx,continuation:{tokenize:Hx},exit:Ux}},text:{91:{name:`gfmFootnoteCall`,tokenize:Bx},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Rx,resolveTo:zx}}}}function Rx(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=gm(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function zx(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Bx(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||wm(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(gm(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return wm(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Vx(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||wm(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=gm(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return wm(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),km(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Hx(e,t,n){return e.check(Wm,t,e.attempt(Ix,t,n))}function Ux(e){e.exit(`gfmFootnoteDefinition`)}function Wx(e,t,n){let r=this;return km(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Gx(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&lm(o,o.length,0,Lm(s,e.slice(r+1,n),t)),lm(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),lm(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Im(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Im(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Kx=class{constructor(){this.map=[]}add(e,t,n){qx(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function qx(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Jx(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Yx(){return{flow:{null:{name:`table`,tokenize:Xx,resolveAll:Zx}}}}function Xx(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):X(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Z(t)?km(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||wm(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Z(t)?km(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Z(t)?km(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||X(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Z(t)?km(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||X(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||X(n)?(e.exit(`tableRow`),t(n)):Z(n)?km(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||wm(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Zx(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Kx;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&($x(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Qx(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Qx(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Qx(f,t,o,i,n,d)):(o[0]=o[1],d=Qx(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&$x(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Jx(t.events,n))}return e}function Qx(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},eS(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=eS(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=eS(t.events,n[2]),a=eS(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},eS(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function $x(e,t,n,r,i){let a=[],o=eS(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function eS(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var tS={name:`tasklistCheck`,tokenize:rS};function nS(){return{text:{91:tS}}}function rS(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return wm(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return X(r)?t(r):Z(r)?e.check({tokenize:iS},t,n)(r):n(r)}}function iS(e,t,n){return km(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function aS(e){return fm([xx(),Lx(),Gx(e),Yx(),nS()])}var oS={};function sS(e){let t=this,n=e||oS,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(aS(n)),a.push(ux()),o.push(dx(n))}function cS({alt:e=`Nomadex logo`,className:t}){return(0,L.jsx)(`img`,{alt:e,className:[`brand-mark`,t].filter(Boolean).join(` `),decoding:`async`,draggable:!1,src:`/favicon.svg`})}var lS=[`Opening workspace`,`Setting environment`,`Initializing modules`,`Starting services`],uS=1600,dS=380;function fS({messages:e=lS,metaText:t=`Connecting to workspace backend`,variant:n=`screen`,visibleRangeStart:r=0,visibleRangeEnd:i}){let a=e.length>0?e:lS,o=a.length-1,s=Math.max(0,Math.min(r,o)),c=Math.max(s,Math.min(i??o,o)),[l,u]=(0,I.useState)(s),[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(c-s<1)return;let e=window.setInterval(()=>{u(e=>{let t=e<s||e>c?s:e;return f(t),m(!1),t>=c?s:t+1})},uS);return()=>{window.clearInterval(e)}},[c,s]),(0,I.useEffect)(()=>{if(d===null)return;let e=window.requestAnimationFrame(()=>{m(!0)}),t=window.setTimeout(()=>{f(null),m(!1)},dS);return()=>{window.cancelAnimationFrame(e),window.clearTimeout(t)}},[l,d]);let h=l<s||l>c?s:l,g=d!==null&&d>=s&&d<=c?d:null,_=a[h]??a[s],v=g===null?null:a[g]??null;return(0,L.jsxs)(`div`,{"aria-live":`polite`,className:H(`connection-loading-screen`,n===`inline`&&`inline`),role:`status`,children:[(0,L.jsx)(cS,{alt:``,className:`connection-loading-mark`}),(0,L.jsxs)(`div`,{className:`connection-loading-row`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`connection-loading-spinner`}),(0,L.jsxs)(`div`,{className:`connection-loading-slot`,children:[v?(0,L.jsx)(`span`,{className:H(`connection-loading-message`,`leaving`,p&&`animate`),children:v}):null,(0,L.jsx)(`span`,{className:H(`connection-loading-message`,v?`entering`:`resting`,p&&`animate`),children:_})]}),(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:`connection-loading-dots`,children:[(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{})]})]}),(0,L.jsx)(`div`,{className:`connection-loading-meta`,children:t})]})}var pS={add:`new`,update:`mod`,delete:`del`},mS=e=>e.replace(/\\/g,`/`).split(`/`).filter(Boolean).at(-1)??e;function hS({entries:e,onOpenFile:t,title:n,variant:r=`turn`}){if(e.length===0)return null;let i=`${e.length}`;return(0,L.jsxs)(`div`,{className:H(`file-change-summary`,`file-change-summary-${r}`),children:[(0,L.jsxs)(`div`,{className:`file-change-summary-head`,children:[(0,L.jsx)(`div`,{className:`file-change-summary-title`,children:n}),(0,L.jsx)(`div`,{className:`file-change-summary-count`,children:i})]}),(0,L.jsx)(`div`,{className:`file-change-summary-list`,children:e.map(e=>{let n=mS(e.path);return(0,L.jsxs)(`button`,{className:H(`file-change-summary-item`,`file-change-kind-${e.kind}`),onClick:()=>t(e.path),title:e.path,type:`button`,children:[(0,L.jsx)(`span`,{className:`file-change-summary-kind`,children:pS[e.kind]}),(0,L.jsx)(`span`,{className:`file-change-summary-path`,children:n})]},`${e.itemId}:${e.path}`)})})]})}var gS=`Agent`;function _S({onFill:e,onSlash:t}){return(0,L.jsxs)(`div`,{className:`ww`,children:[(0,L.jsx)(cS,{className:`wico`}),(0,L.jsx)(`h1`,{children:`Nomadex`}),(0,L.jsx)(`p`,{children:`Agentic coding workspace for live threads, repo edits, command runs, and multi-provider orchestration.`}),(0,L.jsxs)(`div`,{className:`wbadges`,children:[(0,L.jsx)(`div`,{className:`wbadge`,children:`⚡ Live stream`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`🔍 Web search`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`⑂ Multi-agent`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`🔧 MCP tools`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`📋 Skills ($)`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`apply_patch`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`/ 25 slash cmds`})]}),(0,L.jsxs)(`div`,{className:`wsug`,children:[(0,L.jsxs)(`button`,{className:`sug`,type:`button`,onClick:()=>e(`Refactor the auth middleware to use JWT properly with full TypeScript types`),children:[(0,L.jsx)(`div`,{className:`sug-i`,children:`⚡`}),(0,L.jsx)(`div`,{className:`sug-t`,children:`Refactor code`}),(0,L.jsx)(`div`,{className:`sug-d`,children:`apply_patch + diffs`})]}),(0,L.jsxs)(`button`,{className:`sug`,type:`button`,onClick:()=>t(`/review`),children:[(0,L.jsx)(`div`,{className:`sug-i`,children:`🔍`}),(0,L.jsx)(`div`,{className:`sug-t`,children:`/review`}),(0,L.jsx)(`div`,{className:`sug-d`,children:`Audit working tree`})]}),(0,L.jsxs)(`button`,{className:`sug`,type:`button`,onClick:()=>e(`Write Jest unit tests for the auth service with 80%+ coverage`),children:[(0,L.jsx)(`div`,{className:`sug-i`,children:`🧪`}),(0,L.jsx)(`div`,{className:`sug-t`,children:`Write tests`}),(0,L.jsx)(`div`,{className:`sug-d`,children:`Jest + coverage`})]}),(0,L.jsxs)(`button`,{className:`sug`,type:`button`,onClick:()=>t(`/init`),children:[(0,L.jsx)(`div`,{className:`sug-i`,children:`📋`}),(0,L.jsx)(`div`,{className:`sug-t`,children:`/init`}),(0,L.jsx)(`div`,{className:`sug-d`,children:`Generate AGENTS.md`})]})]}),(0,L.jsx)(`p`,{className:`welcome-foot`,children:`/slash cmds · $skills · @file or /mention · !shell · ⌘K palette · Ctrl+G editor`})]})}function vS({threadLabelText:e}){return(0,L.jsx)(fS,{messages:[`Opening conversation`,`Reattaching thread`,`Loading recent history`,`Syncing transcript`],metaText:`Restoring ${Hd(e,42)}`,variant:`inline`})}var yS=(0,I.memo)(function({activeThread:e,activeThreadLabel:t,activeTurns:n,existingThreadHistoryPending:r,streamVisible:i,onReview:a,onRollback:o,onFill:s,onSlash:c,onCopy:l,onFork:u,onPlan:d,onEdit:f,onContext:p,onOpenFile:m,providerId:h}){if(!e)return(0,L.jsx)(_S,{onFill:s,onSlash:c});if(r)return(0,L.jsx)(vS,{threadLabelText:t});if(n.length===0)return(0,L.jsx)(_S,{onFill:s,onSlash:c});let g=n[n.length-1]?.id??null,_=n.some(e=>e.status===`inProgress`);return(0,L.jsx)(L.Fragment,{children:n.map(t=>{let n=gf(t),r=_s(t),s=(e.steers??[]).filter(e=>e.turnId===t.id),c=t.status===`inProgress`?[...t.items].reverse().find(e=>e.type===`agentMessage`)?.id??null:null;return(0,L.jsxs)(`div`,{className:`turn-block`,children:[t.items.map(n=>(0,L.jsx)(RS,{item:n,onContext:p,onCopy:l,onEdit:f,onFork:u,onOpenFile:m,onPlan:d,onRollback:o,providerId:h,onReview:a,rollbackDisabled:_,showRollback:n.type===`userMessage`,turnId:t.id,outputVisible:n.type===`commandExecution`?i[`${n.id}:aggregatedOutput`]:void 0,streaming:n.type===`agentMessage`&&n.id===c,textVisible:n.type===`agentMessage`?i[`${n.id}:text`]:void 0,plan:t.id===g?e.plan:null,turnStatus:t.status},n.id)),s.map(e=>(0,L.jsx)(xS,{entry:e,onOpenFile:m,providerId:h},e.id)),n?(0,L.jsx)(AS,{code:_f(t.error?.codexErrorInfo??null),onOpenFile:m,providerId:h,status:t.status,text:n}):null,t.status===`inProgress`?null:(0,L.jsx)(hS,{entries:r,onOpenFile:m,title:`Changed`,variant:`turn`})]},t.id)})})}),bS=new Intl.DateTimeFormat([],{hour:`numeric`,minute:`2-digit`}),xS=(0,I.memo)(function({entry:e,onOpenFile:t,providerId:n}){return(0,L.jsxs)(`div`,{className:H(`steer-card`,e.status===`pending`&&`pending`),children:[(0,L.jsxs)(`div`,{className:`steer-card-head`,children:[(0,L.jsx)(`span`,{className:`steer-card-label`,children:`Steer`}),(0,L.jsx)(`span`,{className:`steer-card-meta`,children:e.status===`pending`?`Applying`:bS.format(new Date(e.createdAt))})]}),(0,L.jsx)(`div`,{className:`steer-card-body`,children:(0,L.jsx)(jS,{onOpenFile:t,providerId:n,text:e.prompt})})]})}),SS=e=>{switch(e.status){case`inProgress`:return`Running`;case`completed`:return e.exitCode===0?`Completed`:`Exit ${e.exitCode??`?`}`;case`failed`:return`Failed`;case`declined`:return`Declined`;default:return e.status}},CS=e=>e.status===`inProgress`?`run`:e.status===`completed`&&e.exitCode===0?`ok`:`err`,wS=e=>e.replace(/\\/gu,`/`).split(`/`).filter(Boolean).pop()??e,TS=e=>{if(e==null)return null;if(e<1e3)return`${e}ms`;if(e<6e4){let t=e/1e3;return`${t>=10?t.toFixed(0):t.toFixed(1).replace(/\.0$/u,``)}s`}return`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`},ES=e=>{let t=e.replace(/\\/gu,`/`).trim();if(!t)return`(cwd)`;let n=t.split(`/`).filter(Boolean);return n.length===0?`/`:t.startsWith(`/home/`)&&n.length>=3?`~/${n.slice(2).join(`/`)}`:n.length>3?`.../${n.slice(-3).join(`/`)}`:t},DS=/^(?:\/usr\/bin\/env\s+)?((?:\/[^ "'`]+|[A-Za-z0-9_.-]+))(?:\s+(?:--?[A-Za-z0-9_-]+))*\s+(?:-lc|-c|\/c|-Command|-command)\s+(['"])([\s\S]*)\2$/u,OS=e=>{let t=e.commandActions.find(e=>e.command?.trim())?.command.trim()??e.command.trim(),n=t.match(DS),r=wS(n?.[1]??t).replace(/\.(?:bat|cmd|exe)$/iu,``)||`terminal`;return{commandText:n?.[3]?.trim()||t||`(command)`,cwdText:ES(e.cwd),durationText:TS(e.durationMs),processText:e.processId??`pty`,shellLabel:r}},kS=(e,t)=>`${e.trim().toLowerCase()}:${t.trim()}`,AS=(0,I.memo)(function({status:e,text:t,code:n,onOpenFile:r,providerId:i}){return(0,L.jsxs)(`div`,{className:`msg`,children:[(0,L.jsxs)(`div`,{className:`mh`,children:[(0,L.jsx)(`div`,{className:`mav a`,children:`⬡`}),(0,L.jsx)(`span`,{className:`mn`,children:gS}),(0,L.jsx)(`span`,{className:`mt`,children:e})]}),(0,L.jsx)(`div`,{className:`mb`,children:(0,L.jsxs)(`div`,{className:`turn-error-card`,children:[(0,L.jsx)(IS,{onOpenFile:r,providerId:i,text:t}),n?(0,L.jsx)(`div`,{className:`turn-error-code`,children:n}):null]})})]})}),jS=(0,I.memo)(function({text:e,onOpenFile:t,providerId:n}){return(0,L.jsx)(L.Fragment,{children:(0,I.useMemo)(()=>ps(e),[e]).map((e,r)=>e.kind===`text`?(0,L.jsx)(`span`,{children:e.value},`text-${r}`):e.kind===`code`?(0,L.jsx)(`code`,{className:`message-inline-code`,children:e.value},`code-${r}`):hs(e.path,n)===`#`?t?(0,L.jsx)(`button`,{className:`message-file-link file-link-button`,onClick:()=>t(e.path,e.line),title:e.path,type:`button`,children:e.displayPath},`file-${r}`):(0,L.jsx)(`code`,{className:`message-inline-code`,children:e.displayPath},`file-${r}`):(0,L.jsx)(`button`,{className:`message-file-link file-link-button`,onClick:()=>t(e.path,e.line),title:e.path,type:`button`,children:e.displayPath},`file-${r}`))})});function MS({url:e,alt:t,markdown:n,className:r}){let[i,a]=(0,I.useState)(!1);return i&&n?(0,L.jsx)(`p`,{className:`message-text`,children:n}):(0,L.jsx)(`a`,{className:`message-image-link`,href:e,rel:`noreferrer noopener`,target:`_blank`,children:(0,L.jsx)(`img`,{alt:t,className:H(`message-image-preview`,r),loading:`lazy`,onError:()=>a(!0),src:e})})}var NS=e=>{for(let t of I.Children.toArray(e)){if(!(0,I.isValidElement)(t))continue;let e=t.props.className;if(typeof e!=`string`)continue;let n=e.match(/language-([A-Za-z0-9_-]+)/u);if(n?.[1])return n[1]}return null},PS=e=>{let t=e;return(t.match(/```/gu)??[]).length%2==1&&(t=`${t}\n\`\`\``),(t.match(/~~~/gu)??[]).length%2==1&&(t=`${t}\n~~~`),t},FS=(0,I.memo)(function({text:e,onOpenFile:t,streaming:n=!1,showCursor:r=!1,providerId:i}){let a=(0,I.useDeferredValue)(e),o=n?a:e,s=(0,I.useMemo)(()=>n?PS(o):o,[o,n]),c=(0,I.useMemo)(()=>({a({href:e,children:n}){let r=typeof e==`string`?as(e,i):null;return r?(0,L.jsx)(`button`,{className:`message-file-link file-link-button message-markdown-link`,onClick:()=>t(r.path,r.line),title:r.path,type:`button`,children:n}):e?(0,L.jsx)(`a`,{className:`message-markdown-anchor`,href:e,rel:`noreferrer noopener`,target:`_blank`,children:n}):(0,L.jsx)(`span`,{className:`message-markdown-anchor`,children:n})},img({src:e,alt:t}){let n=typeof e==`string`?ms(e,i):``;return n?(0,L.jsx)(MS,{alt:t||`Embedded message image`,className:`message-markdown-image`,url:n}):t?(0,L.jsx)(`span`,{className:`message-inline-code`,children:t}):null},pre({children:e}){return(0,L.jsxs)(`div`,{className:`message-code-shell`,children:[(0,L.jsx)(`div`,{className:`message-code-head`,children:(0,L.jsx)(`span`,{children:NS(e)??`text`})}),(0,L.jsx)(`pre`,{className:`message-code-block`,children:e})]})},code({className:e,children:t}){return(0,L.jsx)(`code`,{className:H(`message-markdown-code`,e),children:t})}}),[t,i]);return(0,L.jsxs)(`div`,{className:H(`message-text-flow`,`message-markdown`,n&&`message-text-flow-streaming message-markdown-streaming`),children:[(0,L.jsx)(ry,{components:c,remarkPlugins:[sS],children:s}),r?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`live-cursor message-stream-cursor`}):null]})}),IS=(0,I.memo)(function({text:e,onOpenFile:t,textFx:n,streaming:r=!1,showCursor:i=!1,providerId:a}){let o=(0,I.useMemo)(()=>r?[]:gs(e,a),[a,r,e]).reduce((e,t)=>({entries:[...e.entries,{block:t,start:e.nextStart}],nextStart:e.nextStart+(t.kind===`image`?t.markdown.length:t.value.length)}),{entries:[],nextStart:0}).entries;if(r){let t=n??null,r=t?Math.max(0,Math.min(e.length,t.from)):0,a=t?Math.max(r,Math.min(e.length,t.to)):0;return(0,L.jsx)(`div`,{className:`message-text-flow message-text-flow-streaming`,children:(0,L.jsxs)(`p`,{className:`message-text message-text-streaming`,children:[e.slice(0,r),a>r?(0,L.jsx)(`span`,{className:`message-text-tail`,children:e.slice(r,a)}):null,e.slice(a),i?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`live-cursor live-cursor-inline`}):null]})})}return(0,L.jsx)(`div`,{className:`message-text-flow`,children:o.map(({block:e,start:r},i)=>{if(e.kind===`image`)return(0,L.jsx)(MS,{alt:e.alt||`Embedded message image`,className:`message-markdown-image`,markdown:e.markdown,url:e.url},`image-${i}`);if(!e.value)return null;let o=r+e.value.length,s=n??null,c=s?Math.max(0,s.from-r):0,l=s?Math.max(0,Math.min(e.value.length,s.to-r)):0,u=!1;if(s&&(u=s.to>s.from&&l>c&&o>s.from&&r<s.to),!u)return(0,L.jsx)(`p`,{className:`message-text`,children:(0,L.jsx)(jS,{onOpenFile:t,providerId:a,text:e.value})},`text-${i}`);let d=e.value.slice(0,c),f=e.value.slice(c,l),p=e.value.slice(l);return(0,L.jsxs)(`p`,{className:`message-text`,children:[d?(0,L.jsx)(jS,{onOpenFile:t,providerId:a,text:d}):null,f?(0,L.jsx)(`span`,{className:`message-text-tail`,children:(0,L.jsx)(jS,{onOpenFile:t,providerId:a,text:f})},`tail-${i}-${s?.to??e.value.length}`):null,p?(0,L.jsx)(jS,{onOpenFile:t,providerId:a,text:p}):null]},`text-${i}`)})})}),LS=(0,I.memo)(function({itemText:e,plan:t}){let n=t?.steps??[],r=t?.explanation?.trim()||e.trim();if(n.length===0)return(0,L.jsxs)(`div`,{className:`compact-bar`,children:[(0,L.jsx)(`span`,{className:`compact-ico`,children:`Plan`}),(0,L.jsx)(`span`,{className:`meta-glint`,children:r||e})]});let i=n.filter(e=>e.status===`completed`).length;return(0,L.jsxs)(`div`,{className:`turn-plan-card`,children:[(0,L.jsx)(`div`,{className:`turn-plan-card-head`,children:(0,L.jsxs)(`span`,{className:`turn-plan-card-progress`,children:[i,` of `,n.length,` tasks completed`]})}),r?(0,L.jsx)(`div`,{className:`turn-plan-card-summary`,children:r}):null,(0,L.jsx)(`ol`,{className:`turn-plan-card-list`,children:n.map((e,t)=>(0,L.jsxs)(`li`,{className:H(`turn-plan-card-step`,`is-${e.status}`),children:[(0,L.jsx)(`span`,{className:`turn-plan-card-step-marker`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{className:`turn-plan-card-step-index`,children:[t+1,`.`]}),(0,L.jsx)(`span`,{className:`turn-plan-card-step-text`,children:e.step})]},`${t}-${e.step}`))})]})}),RS=(0,I.memo)(function({item:e,plan:t,turnStatus:n,streaming:r=!1,textVisible:i,outputVisible:a,onCopy:o,onFork:s,onPlan:c,onRollback:l,onReview:u,onEdit:d,onContext:f,onOpenFile:p,providerId:m,turnId:h,showRollback:g=!1,rollbackDisabled:_=!1}){let[v,y]=(0,I.useState)(e.type===`commandExecution`?e.status===`inProgress`:!1),[b]=(0,I.useState)(()=>e.type===`userMessage`?new Intl.DateTimeFormat([],{hour:`numeric`,minute:`2-digit`}).format(new Date):``),x=(0,I.useRef)(e.type===`commandExecution`?e.status:null),S=e.type===`commandExecution`?e.status:null;if((0,I.useEffect)(()=>{if(e.type!==`commandExecution`||!S){x.current=null;return}let t=null,n=null;return S===`inProgress`?t=window.requestAnimationFrame(()=>{y(!0)}):x.current===`inProgress`&&(n=window.setTimeout(()=>y(!1),1e3)),x.current=S,()=>{t!==null&&window.cancelAnimationFrame(t),n!==null&&window.clearTimeout(n)}},[S,e.type]),e.type===`userMessage`){let t=fs(e,m),n=new Set(t.fileAttachments.map(e=>kS(e.label,e.path))),r=e.content.filter(e=>e.type===`skill`?!0:e.type===`mention`?!n.has(kS(e.name,e.path)):!1);return(0,L.jsxs)(`div`,{className:`msg user`,onContextMenu:t=>f(t,e),children:[(0,L.jsxs)(`div`,{className:`mb`,children:[t.images.length>0?(0,L.jsx)(`div`,{className:`message-image-list`,children:t.images.map((t,n)=>{let r=ms(t,m);return r?(0,L.jsx)(MS,{alt:`Message image preview`,url:r},`${e.id}-image-${n}`):null})}):null,t.fileAttachments.length>0||r.length>0?(0,L.jsxs)(`div`,{className:`attachment-row`,children:[t.fileAttachments.map(t=>{let n=mf(t.label,t.path);return(0,L.jsxs)(`button`,{className:H(`attachment-chip attachment-chip-file file-link-button`,`file-tone-${n.tone}`),onClick:()=>p(t.path),title:t.path,type:`button`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`file-chip-preview`,children:(0,L.jsx)(`span`,{className:`file-chip-ext`,children:n.badge})}),(0,L.jsxs)(`span`,{className:`file-chip-copy`,children:[(0,L.jsx)(`span`,{className:`file-chip-title`,children:n.title}),(0,L.jsx)(`span`,{className:`file-chip-meta`,children:n.kindLabel})]})]},`${e.id}-file-${t.path}`)}),r.map(t=>{if(t.type===`mention`){let n=mf(t.name,t.path);return(0,L.jsxs)(`button`,{className:H(`attachment-chip attachment-chip-file file-link-button`,`file-tone-${n.tone}`),onClick:()=>p(t.path),title:t.path,type:`button`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`file-chip-preview`,children:(0,L.jsx)(`span`,{className:`file-chip-ext`,children:n.badge})}),(0,L.jsxs)(`span`,{className:`file-chip-copy`,children:[(0,L.jsx)(`span`,{className:`file-chip-title`,children:n.title}),(0,L.jsx)(`span`,{className:`file-chip-meta`,children:n.kindLabel})]})]},`${e.id}-${t.type}-${t.name}`)}return(0,L.jsxs)(`span`,{className:`attachment-chip`,children:[(0,L.jsx)(`span`,{children:`📋`}),(0,L.jsx)(`span`,{children:t.name})]},`${e.id}-${t.type}-${t.name}`)})]}):null,t.text?(0,L.jsx)(IS,{onOpenFile:p,providerId:m,text:t.text}):null,(0,L.jsx)(`div`,{className:`msg-time`,children:b})]}),(0,L.jsxs)(`div`,{className:`macts`,children:[g?(0,L.jsx)(`button`,{className:`mact rollback`,disabled:_,title:_?`Wait for the current response to finish before rolling back.`:`Remove this prompt and everything after it.`,type:`button`,onClick:()=>l(h),children:`↶ Rollback`}):null,(0,L.jsx)(`button`,{className:`mact`,type:`button`,onClick:()=>o(t.text),children:`📋 Copy`}),(0,L.jsx)(`button`,{className:`mact`,type:`button`,onClick:()=>d(t.text),children:`✏ Edit`})]})]})}if(e.type===`agentMessage`){let t=typeof i==`number`?e.text.slice(0,i):e.text;return(0,L.jsxs)(`div`,{className:H(`msg assistant`,r&&`streaming`),onContextMenu:t=>f(t,e),children:[(0,L.jsxs)(`div`,{className:`mh`,children:[(0,L.jsx)(`div`,{className:`mav a`,children:`⬡`}),(0,L.jsx)(`span`,{className:`mn`,children:gS}),(0,L.jsx)(`span`,{className:`mt`,children:n===`inProgress`?`live`:n})]}),(0,L.jsx)(`div`,{className:`mb`,children:t?r?(0,L.jsx)(FS,{onOpenFile:p,providerId:m,showCursor:r,streaming:r,text:t}):(0,L.jsx)(FS,{onOpenFile:p,providerId:m,text:t}):null}),(0,L.jsxs)(`div`,{className:`macts`,children:[(0,L.jsx)(`button`,{className:`mact`,type:`button`,onClick:()=>s(),children:`⑂ /fork`}),(0,L.jsx)(`button`,{className:`mact`,type:`button`,onClick:()=>c(),children:`📋 /plan`}),(0,L.jsx)(`button`,{className:`mact`,type:`button`,onClick:()=>o(e.text),children:`📋`})]})]})}if(e.type===`reasoning`)return null;if(e.type===`plan`)return(0,L.jsx)(LS,{itemText:e.text,plan:t});if(e.type===`commandExecution`){let t=typeof a==`number`&&e.aggregatedOutput?e.aggregatedOutput.slice(0,a):e.aggregatedOutput??``,n=CS(e),r=OS(e);return(0,L.jsxs)(`div`,{className:H(`cmd-inline`,n,v&&`open`),children:[(0,L.jsxs)(`button`,{className:H(`cmd-inline-row`,n,v&&`open`),type:`button`,onClick:()=>y(e=>!e),children:[(0,L.jsxs)(`div`,{className:`cmd-inline-window-bar`,children:[(0,L.jsxs)(`div`,{className:`cmd-inline-traffic`,"aria-hidden":`true`,children:[(0,L.jsx)(`span`,{className:`cmd-inline-dot close`}),(0,L.jsx)(`span`,{className:`cmd-inline-dot minimize`}),(0,L.jsx)(`span`,{className:`cmd-inline-dot zoom`})]}),(0,L.jsx)(`span`,{className:`cmd-inline-shell meta-glint`,children:r.shellLabel}),(0,L.jsx)(`span`,{className:H(`cmd-inline-status-chip`,`meta-glint`,n),children:SS(e)})]}),(0,L.jsxs)(`div`,{className:`cmd-inline-main`,children:[(0,L.jsx)(`span`,{className:H(`cmd-inline-chevron`,v&&`open`),children:`▶`}),(0,L.jsxs)(`div`,{className:`cmd-inline-copy`,children:[(0,L.jsx)(`code`,{className:`cmd-inline-label`,children:r.commandText}),(0,L.jsxs)(`div`,{className:`cmd-inline-meta-line`,children:[(0,L.jsx)(`span`,{className:`cmd-inline-meta-pill`,children:r.cwdText}),(0,L.jsx)(`span`,{className:`cmd-inline-meta-pill`,children:r.processText}),r.durationText?(0,L.jsx)(`span`,{className:`cmd-inline-meta-pill`,children:r.durationText}):null]})]})]})]}),v?(0,L.jsxs)(`div`,{className:`cmd-inline-output`,children:[(0,L.jsxs)(`div`,{className:`cmd-inline-output-head`,children:[(0,L.jsx)(`span`,{children:`Output`}),(0,L.jsx)(`span`,{children:e.cwd})]}),(0,L.jsx)(`pre`,{children:t||`(no output)`})]}):null]})}if(e.type===`fileChange`)return(0,L.jsx)(zS,{item:e,onReview:u});if(e.type===`mcpToolCall`){let t=e.result?JSON.stringify(e.result.structuredContent??e.result.content??{},null,2):e.error?.message??`No output`;return(0,L.jsxs)(`div`,{className:H(`tool`,e.error?`err`:`ok`),children:[(0,L.jsxs)(`div`,{className:`tool-h`,children:[(0,L.jsxs)(`span`,{className:`meta-glint`,children:[e.error?`✗`:`✓`,` MCP · `,e.server,`/`,e.tool]}),(0,L.jsx)(`span`,{className:`tbadge meta-glint`,children:e.status})]}),(0,L.jsx)(`div`,{className:`tool-b`,children:(0,L.jsx)(`pre`,{className:`tool-pre`,children:t})})]})}return e.type===`dynamicToolCall`?(0,L.jsxs)(`div`,{className:H(`tool`,e.success?`ok`:`run`),children:[(0,L.jsxs)(`div`,{className:`tool-h`,children:[(0,L.jsxs)(`span`,{className:`meta-glint`,children:[e.success?`✓`:`↻`,` Tool · `,e.tool]}),(0,L.jsx)(`span`,{className:`tbadge meta-glint`,children:e.status})]}),(0,L.jsx)(`div`,{className:`tool-b`,children:e.contentItems?.map((t,n)=>(0,L.jsx)(`div`,{children:JSON.stringify(t)},`${e.id}-${n}`))??`No tool payload.`})]}):e.type===`collabAgentToolCall`?(0,L.jsxs)(`div`,{className:`agc`,children:[(0,L.jsxs)(`div`,{className:`agh`,children:[(0,L.jsx)(`div`,{className:`agdot`}),(0,L.jsxs)(`span`,{className:`agn meta-glint`,children:[`⑂ `,e.tool]}),(0,L.jsx)(`span`,{className:`ags meta-glint`,children:e.status})]}),(0,L.jsx)(`div`,{className:`agt`,children:e.prompt??`Subagent activity`}),(0,L.jsx)(`div`,{className:`agprog`,children:(0,L.jsx)(`div`,{className:`agbar`,style:{width:e.status===`completed`?`100%`:`58%`}})})]}):e.type===`webSearch`?(0,L.jsxs)(`div`,{className:`tool ok`,children:[(0,L.jsxs)(`div`,{className:`tool-h`,children:[(0,L.jsx)(`span`,{className:`meta-glint`,children:`✓ Web search`}),(0,L.jsx)(`span`,{className:`tbadge meta-glint`,children:`search`})]}),(0,L.jsx)(`div`,{className:`tool-b`,children:e.query})]}):e.type===`imageView`?(0,L.jsxs)(`div`,{className:`image-card`,children:[(0,L.jsxs)(`div`,{className:`tool-h`,children:[(0,L.jsx)(`span`,{className:`meta-glint`,children:`🖼 Image`}),(0,L.jsx)(`span`,{className:`tbadge meta-glint`,children:`view`})]}),(0,L.jsx)(`div`,{className:`tool-b`,children:e.path})]}):e.type===`imageGeneration`?(0,L.jsxs)(`div`,{className:`tool ok`,children:[(0,L.jsxs)(`div`,{className:`tool-h`,children:[(0,L.jsx)(`span`,{className:`meta-glint`,children:`✓ Image generation`}),(0,L.jsx)(`span`,{className:`tbadge meta-glint`,children:e.status})]}),(0,L.jsxs)(`div`,{className:`tool-b`,children:[(0,L.jsx)(`div`,{children:e.revisedPrompt}),(0,L.jsx)(`div`,{children:e.result})]})]}):e.type===`enteredReviewMode`||e.type===`exitedReviewMode`?(0,L.jsxs)(`div`,{className:`compact-bar`,children:[(0,L.jsx)(`span`,{className:`compact-ico`,children:e.type===`enteredReviewMode`?`🔍`:`✓`}),(0,L.jsx)(`span`,{className:`meta-glint`,children:e.review})]}):e.type===`contextCompaction`?(0,L.jsxs)(`div`,{className:`compact-bar`,children:[(0,L.jsx)(`span`,{className:`compact-ico`,children:`🗜`}),(0,L.jsx)(`span`,{className:`meta-glint`,children:`Conversation compacted to free context tokens.`})]}):null});function zS({item:e,onReview:t}){let n=e.status===`inProgress`?`editing`:e.status===`completed`?`applied`:e.status===`failed`?`failed`:e.status;return(0,L.jsx)(L.Fragment,{children:(e.changes.length>0?e.changes:[{path:`Editing files`,kind:{type:`update`,move_path:null},diff:``}]).map((r,i)=>(0,L.jsxs)(`div`,{className:H(`dw`,e.status===`inProgress`&&`live`,r.kind.type===`add`&&`new-file`),"data-change-kind":r.kind.type,children:[(0,L.jsxs)(`div`,{className:`dh`,children:[(0,L.jsxs)(`span`,{className:`meta-glint`,children:[`📄 `,r.path]}),(0,L.jsxs)(`div`,{className:`diff-head-actions`,children:[(0,L.jsx)(`button`,{className:`diff-review`,type:`button`,onClick:()=>t(vf(e.id,i,r.path)),children:`Review diff`}),(0,L.jsxs)(`span`,{className:`dstats`,children:[r.kind.type===`add`?(0,L.jsx)(`span`,{className:`diff-new`,children:`new`}):null,r.kind.type===`update`?(0,L.jsx)(`span`,{className:`diff-mod`,children:`mod`}):null,r.kind.type===`delete`?(0,L.jsx)(`span`,{className:`diff-del`,children:`del`}):null,(0,L.jsx)(`span`,{className:H(`diff-status`,e.status===`inProgress`&&`live`,e.status===`failed`&&`err`),children:n})]})]})]}),r.diff?r.diff.split(`
|
|
208
|
-
`).map((e,t)=>(0,L.jsx)(`div`,{className:H(`dl`,e.startsWith(`+`)&&`add`,e.startsWith(`-`)&&`rem`,!e.startsWith(`+`)&&!e.startsWith(`-`)&&`ctx`),children:e},`${r.path}-${t}`)):(0,L.jsx)(`div`,{className:`dl ctx`,children:`Waiting for diff…`})]},`${e.id}-${r.path}-${i}`))})}var BS=(e,t)=>{switch(t){case`accept`:switch(e.kind){case`command`:return`Run command`;case`patch`:return`Apply changes`;case`permissions`:return`Grant access`;default:return`Approve`}case`acceptForSession`:switch(e.kind){case`command`:return`Allow for session`;case`patch`:return`Allow writes for session`;case`permissions`:return`Grant for session`;default:return`Allow for session`}case`cancel`:return`Cancel`;default:return`Decline`}},VS=e=>{switch(e){case`accept`:case`acceptForSession`:return`approve`;case`cancel`:return`neutral`;default:return`danger`}};function HS({approval:e,mcpContentText:t,onMcpContentChange:n,onResolve:r,onSubmitMcp:i}){let a=e.availableDecisions&&e.availableDecisions.length>0?e.availableDecisions:[`accept`,`decline`],o=e.state===`pending`;return(0,L.jsxs)(`div`,{className:`approval-request-card`,children:[(0,L.jsxs)(`div`,{className:`approval-request-head`,children:[(0,L.jsxs)(`div`,{className:`approval-request-copy`,children:[(0,L.jsx)(`strong`,{children:e.title}),(0,L.jsx)(`span`,{children:e.detail})]}),(0,L.jsxs)(`div`,{className:`approval-request-badges`,children:[(0,L.jsx)(`span`,{className:H(`approval-request-risk`,e.risk),children:e.risk}),(0,L.jsx)(`span`,{className:`approval-request-state`,children:e.state})]})]}),e.kind===`question`?null:(0,L.jsxs)(`div`,{className:`approval-request-body`,children:[e.command?(0,L.jsxs)(`div`,{className:`approval-request-block`,children:[(0,L.jsx)(`div`,{className:`approval-request-label`,children:`Command`}),(0,L.jsx)(`code`,{className:`approval-request-command`,children:e.command})]}):null,e.cwd?(0,L.jsxs)(`div`,{className:`approval-request-meta`,children:[(0,L.jsx)(`span`,{className:`approval-request-label`,children:`Working directory`}),(0,L.jsx)(`span`,{className:`approval-request-value`,children:e.cwd})]}):null,e.files&&e.files.length>0?(0,L.jsxs)(`div`,{className:`approval-request-block`,children:[(0,L.jsx)(`div`,{className:`approval-request-label`,children:e.kind===`patch`?`Paths`:`Files`}),(0,L.jsx)(`div`,{className:`approval-request-list`,children:e.files.map(e=>(0,L.jsx)(`span`,{className:`approval-request-item`,children:e},e))})]}):null,e.permissionsSummary&&e.permissionsSummary.length>0?(0,L.jsxs)(`div`,{className:`approval-request-block`,children:[(0,L.jsx)(`div`,{className:`approval-request-label`,children:`Requested access`}),(0,L.jsx)(`div`,{className:`approval-request-list`,children:e.permissionsSummary.map(e=>(0,L.jsx)(`span`,{className:`approval-request-item`,children:e},e))})]}):null,e.kind===`mcp`?(0,L.jsxs)(L.Fragment,{children:[e.serverName?(0,L.jsxs)(`div`,{className:`approval-request-meta`,children:[(0,L.jsx)(`span`,{className:`approval-request-label`,children:`Server`}),(0,L.jsx)(`span`,{className:`approval-request-value`,children:e.serverName})]}):null,e.form?(0,L.jsxs)(`div`,{className:`approval-request-block`,children:[(0,L.jsx)(`div`,{className:`approval-request-label`,children:`Prompt details`}),(0,L.jsx)(`pre`,{className:`approval-request-pre`,children:e.form})]}):null,(0,L.jsxs)(`div`,{className:`approval-request-block`,children:[(0,L.jsx)(`label`,{className:`approval-request-label`,htmlFor:`approval-mcp-${e.id}`,children:`Response`}),(0,L.jsx)(`textarea`,{className:`approval-request-textarea`,id:`approval-mcp-${e.id}`,onChange:e=>n(e.target.value),placeholder:`Provide the response to send back to the MCP server.`,rows:5,value:t})]})]}):null]}),(0,L.jsx)(`div`,{className:`approval-request-actions`,children:e.kind===`mcp`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:`approval-request-button approve`,disabled:!o,onClick:()=>i(`accept`,t),type:`button`,children:`Send response`}),(0,L.jsx)(`button`,{className:`approval-request-button danger`,disabled:!o,onClick:()=>i(`decline`,t),type:`button`,children:`Decline`}),(0,L.jsx)(`button`,{className:`approval-request-button neutral`,disabled:!o,onClick:()=>i(`cancel`,t),type:`button`,children:`Cancel`})]}):a.map(t=>(0,L.jsx)(`button`,{className:H(`approval-request-button`,VS(t)),disabled:!o,onClick:()=>r(t),type:`button`,children:BS(e,t)},`${e.id}:${t}`))})]})}var US=(0,I.memo)(function({branchLabel:e,dirty:t,hasStagedChanges:n,message:r,preferencesPath:i,providers:a,selectedProviderId:o,summary:s,generating:c,committing:l,onCommit:u,onGenerate:d,onMessageChange:f,onProviderChange:p}){let m=a.find(e=>e.id===o)??a[0]??null,h=c||l;return(0,L.jsxs)(`section`,{className:`commit-composer-card`,children:[(0,L.jsxs)(`div`,{className:`commit-composer-head`,children:[(0,L.jsxs)(`div`,{className:`commit-composer-copy`,children:[(0,L.jsx)(`div`,{className:`commit-composer-title`,children:`Commit changes`}),(0,L.jsxs)(`div`,{className:`commit-composer-meta`,children:[(0,L.jsx)(`span`,{children:e}),(0,L.jsx)(`span`,{children:s||(t?`Working tree ready`:`Working tree clean`)})]})]}),(0,L.jsx)(`button`,{className:`commit-generate-button`,disabled:!t||h,onClick:d,type:`button`,children:c?`Generating…`:`Generate`})]}),(0,L.jsxs)(`div`,{className:`commit-composer-toolbar`,children:[(0,L.jsxs)(`label`,{className:`commit-provider-field`,children:[(0,L.jsx)(`span`,{children:`Provider`}),(0,L.jsx)(`select`,{className:`commit-provider-select`,disabled:h,onChange:e=>p(e.target.value),value:o,children:a.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.displayName},e.id))})]}),(0,L.jsxs)(`div`,{className:`commit-provider-note`,children:[(0,L.jsx)(`strong`,{children:m?.displayName??`Provider`}),(0,L.jsx)(`span`,{children:i?`Saved per project in .nomadex/project.json`:`Using the current workspace provider`})]})]}),(0,L.jsx)(`textarea`,{className:`commit-message-input`,disabled:l,onChange:e=>f(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),!l&&r.trim()&&u())},placeholder:`feat(scope): short summary`,rows:4,value:r}),(0,L.jsxs)(`div`,{className:`commit-composer-footer`,children:[(0,L.jsx)(`div`,{className:`commit-composer-hint`,children:n?`Commits the staged files.`:t?`Stages all current files first, then commits.`:`No pending files to commit.`}),(0,L.jsx)(`button`,{className:`commit-submit-button`,disabled:!t||!r.trim()||h,onClick:u,type:`button`,children:l?`Committing…`:`Commit`})]})]})}),WS=[`var(--ac)`,`var(--ac2)`,`var(--ac3)`,`var(--gn)`,`var(--og)`],GS=e=>e.kind===`head`||e.active?`current`:e.kind===`remote`?`remote`:e.kind===`tag`?`tag`:`local`,KS=(e,t,n)=>{let r=e.padEnd(t,` `);return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`git-activity-graph-text`,children:Array.from(r).map((e,t)=>{if(e===` `)return(0,L.jsx)(`span`,{className:`git-activity-graph-char`,children:` `},`blank:${t}`);let r=n[t%n.length]??`var(--ac)`;return(0,L.jsx)(`span`,{className:H(`git-activity-graph-char`,`on`,e===`*`&&`node`),style:{"--graph-accent":r},children:e},`${e}:${t}`)})})},qS=(0,I.memo)(function({model:e,onOpenThread:t}){let n=e.lanes.length>0?e.lanes.map(e=>e.accent):WS;return(0,L.jsxs)(`section`,{className:`git-activity-card`,children:[(0,L.jsxs)(`div`,{className:`git-activity-toolbar`,children:[(0,L.jsxs)(`div`,{className:`git-activity-copy`,children:[(0,L.jsx)(`div`,{className:`git-activity-title`,children:`Git Graph`}),(0,L.jsx)(`div`,{className:`git-activity-meta`,children:e.repoLabel})]}),(0,L.jsxs)(`div`,{className:`git-activity-summary`,children:[(0,L.jsx)(`span`,{className:`git-activity-summary-label`,children:e.branchLabel}),e.commitLabel?(0,L.jsx)(`code`,{className:`git-activity-summary-code`,children:e.commitLabel}):null]})]}),e.lanes.length>0?(0,L.jsx)(`div`,{className:`git-activity-legend`,role:`list`,"aria-label":`Branch legend`,children:e.lanes.map(e=>(0,L.jsxs)(`div`,{className:H(`git-activity-legend-item`,e.emphasis),role:`listitem`,style:{"--lane-accent":e.accent},children:[(0,L.jsx)(`span`,{className:`git-activity-legend-swatch`}),(0,L.jsx)(`span`,{className:`git-activity-legend-label`,children:e.label})]},e.id))}):null,e.workingTree?(0,L.jsxs)(`div`,{className:`git-working-tree-card`,children:[(0,L.jsxs)(`div`,{className:`git-working-tree-toolbar`,children:[(0,L.jsx)(`div`,{className:`git-working-tree-title`,children:`Working tree`}),(0,L.jsx)(`div`,{className:H(`git-working-tree-summary`,e.workingTree.dirty&&`dirty`),children:e.workingTree.summary})]}),e.workingTree.buckets.length>0?(0,L.jsx)(`div`,{className:`git-working-tree-grid`,children:e.workingTree.buckets.map(e=>(0,L.jsxs)(`div`,{className:`git-working-tree-group`,children:[(0,L.jsxs)(`div`,{className:`git-working-tree-group-head`,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`span`,{children:e.entries.length})]}),(0,L.jsxs)(`div`,{className:`git-working-tree-list`,children:[e.entries.slice(0,6).map(e=>(0,L.jsxs)(`div`,{className:`git-working-tree-item`,children:[(0,L.jsx)(`span`,{className:H(`git-working-tree-badge`,e.kind),children:e.badge}),(0,L.jsx)(`span`,{className:`git-working-tree-path`,title:e.originalPath?`${e.originalPath} -> ${e.path}`:e.path,children:e.path})]},e.id)),e.entries.length>6?(0,L.jsxs)(`div`,{className:`git-working-tree-more`,children:[`+`,e.entries.length-6,` more`]}):null]})]},e.id))}):(0,L.jsx)(`div`,{className:`git-working-tree-clean`,children:`No uncommitted files in this repo.`})]}):null,(0,L.jsxs)(`div`,{className:`git-activity-table`,children:[(0,L.jsxs)(`div`,{className:`git-activity-table-head`,children:[(0,L.jsx)(`div`,{className:`git-activity-graph-head`,style:{width:`${Math.max(e.graphWidth,4)+1}ch`}}),(0,L.jsx)(`div`,{className:`git-activity-head-message`,children:`Message`}),(0,L.jsx)(`div`,{className:`git-activity-head-date`,children:`Date`}),(0,L.jsx)(`div`,{className:`git-activity-head-author`,children:`Author`}),(0,L.jsx)(`div`,{className:`git-activity-head-sha`,children:`Commit`})]}),(0,L.jsx)(`div`,{className:`git-activity-table-body`,children:e.rows.map(r=>{let i=!!(r.threadId&&t),a=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`git-activity-graph-cell`,style:{width:`${Math.max(e.graphWidth,4)+1}ch`},children:KS(r.graph,Math.max(e.graphWidth,4),n)}),(0,L.jsxs)(`div`,{className:`git-activity-message-cell`,title:r.hint??r.subject,children:[r.refs.length>0?(0,L.jsx)(`div`,{className:`git-activity-ref-row`,children:r.refs.slice(0,3).map(e=>(0,L.jsx)(`span`,{className:H(`git-activity-ref`,GS(e)),children:e.label},e.id))}):null,(0,L.jsx)(`div`,{className:`git-activity-message-text`,children:r.subject})]}),(0,L.jsx)(`div`,{className:`git-activity-cell git-activity-date-cell`,children:r.dateLabel}),(0,L.jsx)(`div`,{className:`git-activity-cell git-activity-author-cell`,children:r.author}),(0,L.jsx)(`code`,{className:`git-activity-cell git-activity-sha-cell`,children:r.sha})]});return i&&r.threadId&&t?(0,L.jsx)(`button`,{className:H(`git-activity-table-row`,r.emphasis,`interactive`),onClick:()=>t(r.threadId),type:`button`,children:a},r.id):(0,L.jsx)(`div`,{className:H(`git-activity-table-row`,r.emphasis),children:a},r.id)})})]})]})});function JS({approval:e,answers:t,onAnswerChange:n,onSubmit:r}){let i=e.questions??[],a=i.length>0&&i.every(e=>(t[e.id]??``).trim().length>0);return(0,L.jsxs)(`div`,{className:`question-request-card`,children:[(0,L.jsxs)(`div`,{className:`question-request-head`,children:[(0,L.jsxs)(`div`,{className:`question-request-copy`,children:[(0,L.jsx)(`strong`,{children:e.title}),(0,L.jsx)(`span`,{children:e.detail})]}),(0,L.jsx)(`span`,{className:`question-request-state`,children:e.state})]}),(0,L.jsx)(`div`,{className:`question-request-body`,children:i.map((e,r)=>{let i=t[e.id]??``,a=e.isOther||(e.options?.length??0)===0;return(0,L.jsxs)(`div`,{className:`question-request-item`,children:[(0,L.jsxs)(`div`,{className:`question-request-item-head`,children:[(0,L.jsxs)(`span`,{className:`question-request-index`,children:[r+1,`.`]}),(0,L.jsxs)(`div`,{className:`question-request-item-copy`,children:[(0,L.jsx)(`span`,{className:`question-request-header`,children:e.header}),(0,L.jsx)(`div`,{className:`question-request-text`,children:e.question})]})]}),e.options&&e.options.length>0?(0,L.jsx)(`div`,{className:`question-request-options`,children:e.options.map(t=>(0,L.jsxs)(`button`,{className:H(`question-request-option`,i===t.label&&`active`),onClick:()=>n(e.id,t.label),type:`button`,children:[(0,L.jsx)(`span`,{className:`question-request-option-label`,children:t.label}),t.description?(0,L.jsx)(`span`,{className:`question-request-option-description`,children:t.description}):null]},`${e.id}:${t.label}`))}):null,a?(0,L.jsx)(`input`,{className:`question-request-input`,onChange:t=>n(e.id,t.target.value),placeholder:e.isSecret?`Enter value`:`Type your answer`,type:e.isSecret?`password`:`text`,value:i}):null]},e.id)})}),(0,L.jsx)(`div`,{className:`question-request-actions`,children:(0,L.jsx)(`button`,{className:`question-request-submit`,disabled:!a||e.state!==`pending`,onClick:r,type:`button`,children:`Submit answers`})})]})}var YS=e=>{if(!e)return`Reset time unavailable`;let t=new Date(e*1e3),n=Date.now();return t.getTime()-n<=1e3*60*60*24?`Resets ${t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`Resets ${t.toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}`},XS=(e,t)=>t?[e.name,e.description,e.scope??``,e.repo??``,e.downloads??``,...e.tags??[]].join(` `).toLowerCase().includes(t):!0,ZS=(0,I.memo)(function({snapshot:e,actions:t,onClose:n,pushToast:r}){let[i,a]=(0,I.useState)(``),o=i.trim().toLowerCase(),s=(0,I.useMemo)(()=>e.installedSkills.filter(e=>e.enabled).length,[e.installedSkills]),c=(0,I.useMemo)(()=>e.installedSkills.filter(e=>XS(e,o)),[o,e.installedSkills]),l=(0,I.useMemo)(()=>e.remoteSkills.filter(e=>XS(e,o)),[o,e.remoteSkills]);return(0,I.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n]),(0,L.jsx)(`div`,{className:`skills-library-overlay`,onClick:e=>{e.target===e.currentTarget&&n()},children:(0,L.jsxs)(`div`,{className:`skills-library-modal`,children:[(0,L.jsxs)(`div`,{className:`skills-library-hero`,children:[(0,L.jsxs)(`div`,{className:`skills-library-copy`,children:[(0,L.jsx)(`div`,{className:`skills-library-kicker`,children:`Nomadex Skill Library`}),(0,L.jsx)(`div`,{className:`skills-library-title`,children:`Manage installed and remote skills in one place`}),(0,L.jsx)(`div`,{className:`skills-library-subtitle`,children:`Toggle what stays active globally, browse marketplace packs, and keep the composer focused on actual prompts instead of setup.`})]}),(0,L.jsx)(`button`,{"aria-label":`Close skill library`,className:`skills-library-close`,onClick:n,type:`button`,children:`×`})]}),(0,L.jsxs)(`div`,{className:`skills-library-toolbar`,children:[(0,L.jsxs)(`div`,{className:`skills-library-stats`,children:[(0,L.jsxs)(`div`,{className:`skills-library-stat`,children:[(0,L.jsx)(`strong`,{children:e.installedSkills.length}),(0,L.jsx)(`span`,{children:`Installed`})]}),(0,L.jsxs)(`div`,{className:`skills-library-stat`,children:[(0,L.jsx)(`strong`,{children:s}),(0,L.jsx)(`span`,{children:`Enabled`})]}),(0,L.jsxs)(`div`,{className:`skills-library-stat`,children:[(0,L.jsx)(`strong`,{children:e.remoteSkills.length}),(0,L.jsx)(`span`,{children:`Marketplace`})]})]}),(0,L.jsx)(`input`,{autoFocus:!0,className:`skills-library-search`,onChange:e=>a(e.target.value),placeholder:`Search skills, tags, repo, or description…`,value:i})]}),(0,L.jsxs)(`div`,{className:`skills-library-grid`,children:[(0,L.jsxs)(`section`,{className:`skills-library-pane`,children:[(0,L.jsxs)(`div`,{className:`skills-library-pane-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`skills-library-pane-title`,children:`Installed`}),(0,L.jsx)(`div`,{className:`skills-library-pane-copy`,children:`Toggle globally available skills and inspect their local path.`})]}),(0,L.jsx)(`span`,{className:`skills-library-pane-count`,children:c.length})]}),(0,L.jsx)(`div`,{className:`skills-library-list`,children:c.length===0?(0,L.jsx)(`div`,{className:`skills-library-empty`,children:`No installed skills matched this search.`}):c.map(e=>(0,L.jsxs)(`article`,{className:H(`skills-library-card installed`,e.enabled&&`enabled`),children:[(0,L.jsxs)(`div`,{className:`skills-library-card-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`skills-library-card-title`,children:e.name}),(0,L.jsxs)(`div`,{className:`skills-library-card-meta`,children:[(0,L.jsx)(`span`,{className:`skills-library-chip`,children:e.scope}),(0,L.jsx)(`span`,{className:H(`skills-library-chip`,e.enabled&&`live`),children:e.enabled?`Enabled`:`Disabled`})]})]}),(0,L.jsx)(`button`,{className:H(`skills-library-action`,e.enabled&&`active`),onClick:()=>void t.toggleInstalledSkill(e.id),type:`button`,children:e.enabled?`Disable`:`Enable`})]}),(0,L.jsx)(`div`,{className:`skills-library-card-description`,children:e.description}),e.tags.length>0?(0,L.jsx)(`div`,{className:`skills-library-tag-row`,children:e.tags.map(e=>(0,L.jsx)(`span`,{className:`skills-library-tag`,children:e},e))}):null,(0,L.jsx)(`code`,{className:`skills-library-path`,children:e.path})]},e.id))})]}),(0,L.jsxs)(`section`,{className:`skills-library-pane marketplace`,children:[(0,L.jsxs)(`div`,{className:`skills-library-pane-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`skills-library-pane-title`,children:`Marketplace`}),(0,L.jsx)(`div`,{className:`skills-library-pane-copy`,children:`Install remote skills into your local workspace catalog.`})]}),(0,L.jsx)(`span`,{className:`skills-library-pane-count`,children:l.length})]}),(0,L.jsx)(`div`,{className:`skills-library-list`,children:l.length===0?(0,L.jsx)(`div`,{className:`skills-library-empty`,children:`No marketplace skills matched this search.`}):l.map(e=>(0,L.jsxs)(`article`,{className:`skills-library-card remote`,children:[(0,L.jsxs)(`div`,{className:`skills-library-card-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`skills-library-card-title`,children:e.name}),(0,L.jsxs)(`div`,{className:`skills-library-card-meta`,children:[(0,L.jsxs)(`span`,{className:`skills-library-chip`,children:[e.downloads,` downloads`]}),(0,L.jsx)(`span`,{className:`skills-library-chip`,children:e.repo})]})]}),(0,L.jsx)(`button`,{className:`skills-library-action install`,onClick:()=>{t.installSkill(e.id),r(`Installing ${e.name}`,`ok`)},type:`button`,children:`Install`})]}),(0,L.jsx)(`div`,{className:`skills-library-card-description`,children:e.description}),e.tags.length>0?(0,L.jsx)(`div`,{className:`skills-library-tag-row`,children:e.tags.map(e=>(0,L.jsx)(`span`,{className:`skills-library-tag`,children:e},e))}):null]},e.id))})]})]})]})})}),QS=(0,I.memo)(function({activeTheme:e,onClose:t,onSelect:n,themes:r}){return(0,L.jsx)(`div`,{className:`theme-picker-overlay`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{id:`tpicker`,children:[(0,L.jsxs)(`div`,{className:`tpicker-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`tpicker-title`,children:`Theme`}),(0,L.jsx)(`div`,{className:`tpicker-subtitle`,children:`Shell palettes for Nomadex.`})]}),(0,L.jsx)(`button`,{className:`tpicker-close`,onClick:t,type:`button`,"aria-label":`Close theme picker`,children:`×`})]}),(0,L.jsx)(`div`,{className:`tpicker-grid`,children:r.map(t=>(0,L.jsxs)(`button`,{className:H(`theme-card`,e===t.id&&`active`),onClick:()=>n(t.id),type:`button`,children:[(0,L.jsxs)(`div`,{className:`theme-card-preview`,children:[(0,L.jsx)(`span`,{className:`theme-card-surface`,style:{background:t.swatches[0]}}),(0,L.jsx)(`span`,{className:`theme-card-accent`,style:{background:t.swatches[1]}}),(0,L.jsx)(`span`,{className:`theme-card-accent`,style:{background:t.swatches[2]}})]}),(0,L.jsxs)(`div`,{className:`theme-card-copy`,children:[(0,L.jsxs)(`div`,{className:`theme-card-name`,children:[t.name,(0,L.jsx)(`span`,{className:`theme-card-mode`,children:t.mode})]}),(0,L.jsx)(`div`,{className:`theme-card-description`,children:t.description})]})]},t.id))})]})})}),$S=(0,I.memo)(function({snapshot:e,activeThreadLabel:t,actions:n,pushToast:r,selectModel:i,activeTheme:a,onOpenSkills:o,onOpenTheme:s}){let[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)({key:``,value:``}),f=a.charAt(0).toUpperCase()+a.slice(1),p=e.providers.find(t=>t.id===e.settings.provider)??e.providers[0],m=p?Zo(p.id,e.models):e.models,h=p?.transportKind===`cli`,g=p?e.providerSetup[p.id]:null,_=p?e.providerAuth[p.id]:null,v=_?.status===`starting`||_?.status===`waiting`||_?.status===`checking`,y=h?p?.id===`opencode`&&_?.status===`waiting`?`Paste the OpenCode Zen API key below`:_?.status===`waiting`?`Finish sign-in below`:g?.status===`ready`?`Local CLI session ready`:`Sign in or configure this local CLI`:`${e.account.planType} · ${e.account.authMode}`,b=h?v?_?.status===`checking`?`Checking`:`Signing in…`:g?.status===`ready`?`Ready`:`External`:e.account.loginInProgress?`Signing in…`:e.account.loggedIn?`Active`:`Signed out`,x=p?.id===`opencode`?`Use OpenCode Zen`:p?.id===`qwen-code`?`Use Qwen Code`:`Use ${p?.displayName??`provider`}`,S=h&&(g?.authenticated===!0||g?.status===`ready`||_?.status===`completed`),C=g?g.status===`ready`?`Ready`:g.status===`checking`?`Checking`:g.status===`needsInstall`?`Install`:g.status===`needsAuth`?`Sign in`:g.status===`needsConfig`?`Config`:g.status===`error`?`Error`:`Unknown`:`Unknown`,w=h&&_!==null&&_.status!==`idle`&&_.status!==`completed`,T=p?.id===`opencode`&&_?.status===`waiting`,E=`${p?.id??`none`}:${_?.status??`idle`}`,D=u.key===E?u.value:``,O=_?.authUrl??null,ee=_?.userCode??null;(0,I.useEffect)(()=>{!h||!p||!g||g.status!==`unknown`||n.checkProviderSetup(p.id)},[n,p,g,h]);let te=(0,I.useCallback)(async()=>{try{let t=await n.startChatGptLogin();t&&window.open(t,`_blank`,`noopener,noreferrer`),r(e.account.loggedIn?`Opened ChatGPT account switch`:`Opened ChatGPT sign-in`,`ok`),r(`If mobile redirects to localhost:1455, paste that callback URL below.`,``)}catch(e){r(e instanceof Error?e.message:`Failed to start ChatGPT login`,`err`)}},[n,r,e.account.loggedIn]),ne=(0,I.useCallback)(async()=>{if(!c.trim()){r(`Paste the full callback URL first`,`warn`);return}try{await n.completeChatGptLogin(c.trim()),l(``),r(`Mobile sign-in completed`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to complete mobile sign-in`,`err`)}},[n,c,r]),re=(0,I.useCallback)(async()=>{let t=window.prompt(e.account.authMode===`apiKey`?`Enter the replacement API key`:`Enter your OpenAI API key`,``);if(t?.trim())try{await n.loginWithApiKey(t.trim()),r(`API key account connected`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to connect API key`,`err`)}},[n,r,e.account.authMode]),k=(0,I.useCallback)(async()=>{try{await n.logoutAccount(),r(`Signed out of account`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to sign out`,`err`)}},[n,r]),A=(0,I.useCallback)(async()=>{try{await n.refreshAccount(),r(`Account status refreshed`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to refresh account`,`err`)}},[n,r]),ie=(0,I.useCallback)(async()=>{if(!(!p||!h))try{await n.startProviderAuth(p.id,p.id===`opencode`?`apiKey`:`oauth`),r(`${p.displayName} sign-in started`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to start provider sign-in`,`err`)}},[n,p,h,r]),ae=(0,I.useCallback)(async()=>{if(!(!p||!h))try{await n.switchProviderAccount(p.id,p.id===`opencode`?`apiKey`:`oauth`),r(`${p.displayName} is ready for a new sign-in`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to switch provider account`,`err`)}},[n,p,h,r]),oe=(0,I.useCallback)(async()=>{if(!(!p||!h))try{await n.cancelProviderAuth(p.id),r(`${p.displayName} sign-in cancelled`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to cancel provider sign-in`,`err`)}},[n,p,h,r]),se=(0,I.useCallback)(()=>{O&&window.open(O,`_blank`,`noopener,noreferrer`)},[O]),ce=(0,I.useCallback)(async()=>{if(ee)try{await navigator.clipboard.writeText(ee),r(`Copied sign-in code`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to copy sign-in code`,`err`)}},[ee,r]),j=(0,I.useCallback)(async()=>{if(!(!p||!T)){if(!D.trim()){r(`Paste the API key first`,`warn`);return}try{await n.submitProviderAuthSecret(p.id,D.trim()),d({key:E,value:``}),r(`API key submitted to OpenCode`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to submit the provider secret`,`err`)}}},[n,p,E,D,r,T]);return(0,L.jsxs)(`div`,{className:`config-stack`,children:[(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`Account`}),(0,L.jsxs)(`div`,{className:`account-card`,children:[(0,L.jsxs)(`div`,{className:`account-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`strong`,{children:h?`${p.displayName} local session`:e.account.loggedIn?e.account.workspace:`No active account`}),(0,L.jsx)(`div`,{className:`account-copy`,children:y})]}),(0,L.jsx)(`span`,{className:H(`account-badge`,h&&(v||g?.status===`ready`)||e.account.loggedIn?`ok`:`off`),children:b})]}),(0,L.jsxs)(`div`,{className:`account-meta`,children:[h?(0,L.jsx)(`span`,{children:p.transportLabel}):(0,L.jsx)(`span`,{children:e.account.credits}),!h&&e.account.requiresOpenaiAuth?(0,L.jsx)(`span`,{children:`OpenAI auth required`}):null]}),h?(0,L.jsxs)(L.Fragment,{children:[g?(0,L.jsxs)(`div`,{className:`usage-limit-list`,children:[(0,L.jsxs)(`div`,{className:`usage-limit-card provider-detail-card`,children:[(0,L.jsxs)(`div`,{className:`usage-limit-head`,children:[(0,L.jsx)(`strong`,{children:`Session`}),(0,L.jsx)(`span`,{children:C})]}),(0,L.jsx)(`div`,{className:`provider-detail-copy`,children:g.summary}),g.detail?(0,L.jsx)(`div`,{className:`usage-limit-copy`,children:g.detail}):null]}),(0,L.jsxs)(`div`,{className:`usage-limit-card provider-detail-card`,children:[(0,L.jsxs)(`div`,{className:`usage-limit-head`,children:[(0,L.jsx)(`strong`,{children:`Transport`}),(0,L.jsx)(`span`,{children:p.transportLabel})]}),(0,L.jsx)(`div`,{className:`provider-detail-copy`,children:g.sourcePath??`Local CLI session on this host.`}),(0,L.jsx)(`div`,{className:`usage-limit-copy`,children:g.checkedAt?`Checked ${g.checkedAt}`:`Not checked yet.`})]}),(0,L.jsxs)(`div`,{className:`usage-limit-card provider-detail-card`,children:[(0,L.jsxs)(`div`,{className:`usage-limit-head`,children:[(0,L.jsx)(`strong`,{children:`CLI`}),(0,L.jsx)(`span`,{children:g.version?`Detected`:`Unknown`})]}),(0,L.jsx)(`div`,{className:`provider-detail-copy`,children:g.version?`Version ${g.version}`:`Version unavailable`}),(0,L.jsx)(`div`,{className:`usage-limit-copy`,children:S?`Ready for new turns.`:`Sign in or configure the provider to use it in Nomadex.`})]})]}):null,w?(0,L.jsxs)(`div`,{className:`account-helper`,children:[(0,L.jsxs)(`div`,{className:`account-helper-copy`,children:[_?.summary,_?.detail?` ${_.detail}`:``]}),_?.userCode||_?.authUrl?(0,L.jsxs)(`div`,{className:`account-callback-form`,children:[_.userCode?(0,L.jsxs)(`div`,{className:`provider-auth-value`,children:[(0,L.jsx)(`span`,{children:`Code`}),(0,L.jsx)(`code`,{children:_.userCode})]}):null,_.authUrl?(0,L.jsxs)(`div`,{className:`provider-auth-value`,children:[(0,L.jsx)(`span`,{children:`URL`}),(0,L.jsx)(`code`,{children:_.authUrl})]}):null]}):null,T?(0,L.jsx)(`div`,{className:`account-callback-form`,children:(0,L.jsx)(`input`,{className:`account-callback-input`,type:`password`,value:D,onChange:e=>d({key:E,value:e.target.value}),placeholder:`Paste OpenCode Zen API key`,autoComplete:`off`,spellCheck:!1})}):null,(0,L.jsxs)(`div`,{className:`provider-auth-actions`,children:[_?.authUrl?(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:se,children:`Open auth page`}):null,_?.userCode?(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void ce(),children:`Copy code`}):null,T?(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,disabled:!D.trim(),onClick:()=>void j(),children:`Submit key`}):null,v?(0,L.jsx)(`button`,{className:`mini-action danger`,type:`button`,onClick:()=>void oe(),children:`Cancel`}):null]})]}):(0,L.jsx)(`div`,{className:`usage-limit-empty`,children:p.id===`opencode`?(0,L.jsxs)(L.Fragment,{children:[`OpenCode Zen uses an API key from`,` `,(0,L.jsx)(`code`,{children:`opencode.ai/auth`}),`. Start the sign-in below, open the auth page, then paste the Zen API key back into Nomadex.`]}):p.id===`qwen-code`?(0,L.jsxs)(L.Fragment,{children:[`Use the provider action below to connect`,` `,p.displayName,`. Nomadex will verify the local session automatically after the provider flow completes.`]}):p.installCommand?(0,L.jsxs)(L.Fragment,{children:[`Install with `,(0,L.jsx)(`code`,{children:p.installCommand}),`, then sign in or configure that CLI on the host machine. Nomadex will use the existing local session for new turns.`]}):(0,L.jsxs)(L.Fragment,{children:[`Sign in or configure `,p.displayName,` on the host machine first. Nomadex will use the existing local CLI session.`]})})]}):(0,L.jsxs)(`div`,{className:`usage-limit-list`,children:[e.account.usageWindows.map(e=>(0,L.jsxs)(`div`,{className:`usage-limit-card`,children:[(0,L.jsxs)(`div`,{className:`usage-limit-head`,children:[(0,L.jsx)(`strong`,{children:e.label}),(0,L.jsxs)(`span`,{children:[Math.round(e.usedPercent),`% used`]})]}),(0,L.jsx)(`div`,{className:`usage-limit-bar`,children:(0,L.jsx)(`span`,{className:`usage-limit-fill`,style:{width:`${Math.max(0,Math.min(100,e.usedPercent))}%`}})}),(0,L.jsx)(`div`,{className:`usage-limit-copy`,children:YS(e.resetsAt)})]},e.id)),e.account.usageWindows.length===0?(0,L.jsx)(`div`,{className:`usage-limit-empty`,children:`Sign in to view your account usage windows.`}):null]}),(0,L.jsx)(`div`,{className:`account-actions`,children:h?(0,L.jsxs)(L.Fragment,{children:[p.id===`opencode`||p.id===`qwen-code`?(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,disabled:v,onClick:()=>void(S?ae():ie()),children:v?`Starting…`:S?`Switch account`:x}):null,(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,disabled:g?.status===`checking`,onClick:()=>void n.checkProviderSetup(p.id),children:g?.status===`checking`?`Checking…`:`Check setup`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void A(),children:`Refresh`}),(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void te(),children:e.account.authMode===`chatgpt`?`Switch ChatGPT`:`Use ChatGPT`}),(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void re(),children:e.account.authMode===`apiKey`?`Replace API key`:`Use API key`}),e.account.loggedIn?(0,L.jsx)(`button`,{className:`mini-action danger`,type:`button`,onClick:()=>void k(),children:`Log out`}):null]})}),!h&&e.account.loginInProgress?(0,L.jsxs)(`div`,{className:`account-helper`,children:[(0,L.jsxs)(`div`,{className:`account-helper-copy`,children:[`On mobile, if ChatGPT returns to `,(0,L.jsx)(`code`,{children:`localhost:1455`}),`, copy that full URL and paste it here. You can also replace the failed callback host with`,` `,(0,L.jsx)(`code`,{children:typeof window<`u`?window.location.origin:``}),` `,`and keep the same path/query.`]}),(0,L.jsxs)(`div`,{className:`account-callback-form`,children:[(0,L.jsx)(`input`,{className:`account-callback-input`,placeholder:`http://localhost:1455/auth/callback?code=…&state=…`,value:c,onChange:e=>l(e.target.value)}),(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void ne(),children:`Finish mobile login`})]})]}):null,!h&&e.account.loginError?(0,L.jsx)(`div`,{className:`account-error`,children:e.account.loginError}):null]})]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`Model`}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`provider`}),(0,L.jsx)(`select`,{className:`ssel`,value:e.settings.provider,onChange:t=>{let r=e.providers.find(e=>e.id===t.target.value);n.updateSettings({provider:t.target.value,model:r?.defaultModel??e.settings.model})},children:e.providers.map(e=>(0,L.jsxs)(`option`,{disabled:e.availability!==`ready`,value:e.id,children:[e.displayName,e.availability===`ready`?``:` (scaffolded)`]},e.id))})]}),(0,L.jsxs)(`div`,{className:`config-provider-note`,children:[(0,L.jsx)(`strong`,{children:p?.displayName??`Provider`}),(0,L.jsx)(`span`,{children:p?.availability===`ready`?p.installCommand?`${p.transportLabel} · ${p.installCommand}`:p.transportLabel:`Scaffolded on this branch. Transport wiring comes next.`})]}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`model`}),m.length===0?(0,L.jsx)(`span`,{className:`sl`,children:`provider default`}):(0,L.jsx)(`select`,{className:`ssel`,value:e.settings.model,onChange:e=>void i(e.target.value),children:m.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.displayName},e.id))})]}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`reasoning_effort`}),(0,L.jsxs)(`select`,{className:`ssel`,value:e.settings.reasoningEffort,onChange:e=>void n.updateSettings({reasoningEffort:e.target.value}),children:[(0,L.jsx)(`option`,{value:`low`,children:`low`}),(0,L.jsx)(`option`,{value:`medium`,children:`medium`}),(0,L.jsx)(`option`,{value:`high`,children:`high`}),(0,L.jsx)(`option`,{value:`xhigh`,children:`xhigh`})]})]})]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`Approval & Sandbox`}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`approval_policy`}),(0,L.jsxs)(`select`,{className:`ssel`,value:Pd(e.settings),onChange:e=>void n.updateSettings(Fd(e.target.value)),children:[(0,L.jsx)(`option`,{value:`auto`,children:`auto`}),(0,L.jsx)(`option`,{value:`ro`,children:`read-only`}),(0,L.jsx)(`option`,{value:`fa`,children:`full-access`})]})]}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`sandbox`}),(0,L.jsxs)(`select`,{className:`ssel`,value:e.settings.sandboxMode,onChange:e=>void n.updateSettings({sandboxMode:e.target.value}),children:[(0,L.jsx)(`option`,{value:`workspace-write`,children:`workspace-write`}),(0,L.jsx)(`option`,{value:`read-only`,children:`read-only`}),(0,L.jsx)(`option`,{value:`danger-full-access`,children:`danger-full-access`})]})]}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`web_search`}),(0,L.jsx)(`div`,{className:H(`tog`,e.settings.webSearch&&`on`),onClick:()=>void n.updateSettings({webSearch:!e.settings.webSearch}),role:`button`,tabIndex:0,onKeyDown:()=>void 0})]})]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`Appearance`}),(0,L.jsxs)(`div`,{className:`config-shortcut-card appearance-shortcut-card`,children:[(0,L.jsxs)(`div`,{className:`config-shortcut-copy`,children:[(0,L.jsxs)(`strong`,{children:[f,` theme active`]}),(0,L.jsx)(`span`,{children:`Ambient background, shell surfaces, and persistent palette selection.`})]}),(0,L.jsx)(`button`,{className:`mini-action`,onClick:s,type:`button`,children:`Open Theme Picker`})]})]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`Skills`}),(0,L.jsxs)(`div`,{className:`config-shortcut-card skill-shortcut-card`,children:[(0,L.jsxs)(`div`,{className:`config-shortcut-copy`,children:[(0,L.jsx)(`strong`,{children:`Skills moved into a dedicated library`}),(0,L.jsxs)(`span`,{children:[e.installedSkills.length,` installed ·`,` `,e.installedSkills.filter(e=>e.enabled).length,` `,`enabled · `,e.remoteSkills.length,` available to install`]})]}),(0,L.jsx)(`button`,{className:`mini-action`,onClick:o,type:`button`,children:`Open Skills Library`})]})]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`MCP`}),e.mcpServers.map(e=>(0,L.jsxs)(`div`,{className:`mcp-card`,children:[(0,L.jsxs)(`div`,{className:`mcp-head`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`span`,{children:e.authStatus})]}),(0,L.jsx)(`div`,{className:`mcp-tools`,children:Object.keys(e.tools).slice(0,4).join(` · `)}),(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void n.toggleMcpAuth(e.name),children:e.authStatus===`notLoggedIn`?`Connect`:`Refresh`})]},e.name))]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsxs)(`div`,{className:`sg-t`,children:[`Feature Flags`,` `,(0,L.jsx)(`button`,{className:`feature-refresh`,type:`button`,onClick:()=>r(`Feature flags refreshed`,`ok`),children:`⟳`})]}),e.featureFlags.map(e=>(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsxs)(`span`,{className:`sl`,children:[e.name,` `,(0,L.jsxs)(`small`,{children:[`(`,e.stage,`)`]})]}),(0,L.jsx)(`div`,{className:H(`tog`,e.enabled&&`on`),onClick:()=>void n.toggleFeatureFlag(e.name),role:`button`,tabIndex:0,onKeyDown:()=>void 0})]},e.name))]}),(0,L.jsxs)(`div`,{className:`config-preview`,children:[(0,L.jsx)(`div`,{className:`config-title`,children:`Session config snapshot`}),(0,L.jsx)(`div`,{children:`# Nomadex workspace config`}),(0,L.jsxs)(`div`,{children:[`provider = "`,e.settings.provider,`"`]}),(0,L.jsxs)(`div`,{children:[`model = "`,e.settings.model,`"`]}),(0,L.jsxs)(`div`,{children:[`approval_policy = "`,e.settings.approvalPolicy,`"`]}),(0,L.jsxs)(`div`,{children:[`model_reasoning_effort = "`,e.settings.reasoningEffort,`"`]}),(0,L.jsxs)(`div`,{children:[`web_search = "`,e.settings.webSearch?`live`:`disabled`,`"`]}),(0,L.jsx)(`br`,{}),(0,L.jsx)(`div`,{children:`[features]`}),e.featureFlags.slice(0,4).map(e=>(0,L.jsxs)(`div`,{children:[e.name,` = `,e.enabled?`true`:`false`]},e.name)),(0,L.jsx)(`br`,{}),(0,L.jsx)(`div`,{children:`# active thread`}),(0,L.jsxs)(`div`,{children:[`thread = "`,t,`"`]})]})]})}),eC=1200,tC=e=>e.find(e=>e.status===`running`)?.id??e[0]?.id??null;function nC({cwd:e,terminals:t,onStartShell:n,onSendInput:r,onTerminate:i}){let[a,o]=(0,I.useState)(()=>tC(t)),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(null),p=(0,I.useRef)(null),m=(0,I.useRef)(null),h=(0,I.useRef)(a),g=(0,I.useRef)(!0);(0,I.useEffect)(()=>{let e=t.some(e=>e.id===a)?a:tC(t);e!==a&&o(e)},[a,t]);let _=(0,I.useMemo)(()=>t.find(e=>e.id===a)??t.find(e=>e.status===`running`)??t[0]??null,[a,t]),v=(0,I.useMemo)(()=>_?_.log.slice(-eC):[],[_]),y=_?Math.max(0,_.log.length-v.length):0,b=Math.max(t.length-1,0),x=!!(_?.writable&&_.status===`running`),S=(0,I.useCallback)(()=>{let e=m.current;if(!e)return;e.focus();let t=e.value.length;try{e.setSelectionRange(t,t)}catch{}},[]);(0,I.useEffect)(()=>{let e=p.current,t=_?.id??null;if(!e){h.current=t;return}let n=h.current!==t;if(h.current=t,!n&&!g.current)return;let r=window.requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});return()=>{window.cancelAnimationFrame(r)}},[_?.id,v.length]),(0,I.useEffect)(()=>{if(!x)return;let e=window.requestAnimationFrame(()=>{S()});return()=>{window.cancelAnimationFrame(e)}},[_?.id,x,S]);let C=()=>{let e=p.current;e&&(g.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},w=async()=>{u(null),f(`start`);try{o(await n()),c(``)}catch(e){u(e instanceof Error?e.message:`Unable to start the project shell.`)}finally{f(null)}},T=async()=>{if(!_||!x||!s.trim())return;let e=s;u(null),f(`send`);try{c(``),await r(_.id,`${e}\n`)}catch(t){c(e),u(t instanceof Error?t.message:`Unable to send terminal input.`)}finally{f(null),typeof window<`u`&&window.requestAnimationFrame(()=>{S()})}},E=async()=>{if(!(!_||!x)){u(null),f(`send`);try{await r(_.id,``)}catch(e){u(e instanceof Error?e.message:`Unable to send interrupt.`)}finally{f(null),typeof window<`u`&&window.requestAnimationFrame(()=>{S()})}}},D=async()=>{if(!(!_||_.status!==`running`)){u(null),f(`stop`);try{await i(_.id)}catch(e){u(e instanceof Error?e.message:`Unable to stop the terminal.`)}finally{f(null)}}};return(0,L.jsxs)(`div`,{className:`terminal-panel`,children:[(0,L.jsxs)(`div`,{className:`terminal-plain-bar`,children:[(0,L.jsxs)(`div`,{className:`terminal-plain-meta`,children:[(0,L.jsx)(`span`,{className:`terminal-plain-title`,children:`Terminal`}),_?(0,L.jsx)(`span`,{className:H(`status-chip`,`terminal-status-chip`,_.status),children:_.status}):null,b>0?(0,L.jsxs)(`span`,{className:`terminal-plain-count`,children:[t.length,` shells`]}):null]}),(0,L.jsxs)(`div`,{className:`terminal-toolbar-actions`,children:[(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void w(),children:d===`start`?`Starting…`:`New shell`}),_?(0,L.jsx)(`button`,{className:`mini-action`,disabled:!x||d===`send`,onClick:()=>void E(),type:`button`,children:`Ctrl+C`}):null,_?(0,L.jsx)(`button`,{className:`mini-action danger`,disabled:_.status!==`running`||d===`stop`,onClick:()=>void D(),type:`button`,children:d===`stop`?`Stopping…`:`Stop`}):null]})]}),(0,L.jsx)(`div`,{className:`terminal-project-path`,children:e}),l?(0,L.jsx)(`div`,{className:`terminal-inline-error`,children:l}):null,t.length===0?(0,L.jsxs)(`div`,{className:`terminal-empty-state`,children:[(0,L.jsx)(`div`,{className:`empty-panel`,children:`No project shell yet.`}),(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void w(),children:`Open project shell`})]}):null,t.length>0&&_?(0,L.jsxs)(L.Fragment,{children:[y>0?(0,L.jsxs)(`div`,{className:`terminal-log-cap`,children:[`Showing the latest `,v.length,` lines of `,_.log.length]}):null,(0,L.jsxs)(`div`,{className:H(`term`,`terminal-log-plain`,x&&`terminal-log-plain-interactive`),onClick:()=>{x&&S()},onScroll:C,ref:p,children:[v.map((e,t)=>(0,L.jsx)(`div`,{className:H(`terminal-log-row`,t===0&&`t-p`),children:e||` `},`${_.id}:log:${y+t}`)),x?(0,L.jsxs)(`form`,{className:`terminal-log-prompt t-p`,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),T()},children:[(0,L.jsx)(`span`,{className:`terminal-inline-editor-shell`,children:`$`}),(0,L.jsx)(`input`,{"aria-label":`Terminal input`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,className:`terminal-inline-editor`,enterKeyHint:`send`,onChange:e=>c(e.target.value),onKeyDown:e=>{e.stopPropagation(),(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`c`&&s.length===0&&(e.preventDefault(),E())},ref:m,spellCheck:!1,type:`text`,value:s}),(0,L.jsx)(`button`,{"aria-hidden":`true`,className:`terminal-submit-proxy`,tabIndex:-1,type:`submit`})]}):null]})]}):null]})}function rC(){return rC=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},rC.apply(null,arguments)}function iC(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var aC=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=uC(e.state,n.from);return r.line?sC(e):r.block?lC(e):!1};function oC(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var sC=oC(hC,0),cC=oC(mC,0),lC=oC((e,t)=>mC(e,t,pC(t)),0);function uC(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var dC=50;function fC(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-dC,r),o=e.sliceDoc(i,i+dC),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*dC?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+dC),d=e.sliceDoc(i-dC,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function pC(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function mC(e,t,n=t.selection.ranges){let r=n.map(e=>uC(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>fC(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function hC(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=uC(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var gC=pe.define(),_C=pe.define(),vC=te.define(),yC=te.define({combine(e){return f(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),bC=i.define({create(){return zC.empty},update(e,t){let n=t.state.facet(yC),r=t.annotation(gC);if(r){let i=DC.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?OC(o,o.length,n.minDepth,i):PC(o,t.startState.selection),new zC(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(_C);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(ue.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=DC.fromTransaction(t),o=t.annotation(ue.time),s=t.annotation(ue.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new zC(e.done.map(DC.fromJSON),e.undone.map(DC.fromJSON))}});function xC(e={}){return[bC,yC.of(e),u.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?CC:e.inputType==`historyRedo`?wC:null;return n?(e.preventDefault(),n(t)):!1}})]}function SC(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(bC,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var CC=SC(0,!1),wC=SC(1,!1),TC=SC(0,!0),EC=SC(1,!0),DC=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&se.fromJSON(t.changes),[],t.mapped&&ce.fromJSON(t.mapped),t.startSelection&&P.fromJSON(t.startSelection),t.selectionsAfter.map(P.fromJSON))}static fromTransaction(t,n){let r=MC;for(let e of t.startState.facet(vC)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,MC)}static selection(t){return new e(void 0,MC,void 0,void 0,t)}};function OC(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function kC(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function AC(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function jC(e,t){return e.length?t.length?e.concat(t):e:t}var MC=[],NC=200;function PC(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-NC));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),OC(e,e.length-1,1e9,n.setSelAfter(r)))}else return[DC.selection([t])]}function FC(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function IC(e,t){if(!e.length)return e;let n=e.length,r=MC;for(;n;){let i=LC(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[DC.selection(r)]:MC}function LC(e,t,n){let r=jC(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):MC,n);if(!e.changes)return DC.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(a):a;return new DC(i,o.mapEffects(e.effects,t),s,e.startSelection.map(a),r)}var RC=/^(input\.type|delete)($|\.)/,zC=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let s=this.done,c=s[s.length-1];return s=c&&c.changes&&!c.changes.empty&&t.changes&&(!r||RC.test(r))&&(!c.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,kC(c.changes,t.changes))||r==`input.type.compose`)?OC(s,s.length-1,i.minDepth,new DC(t.changes.compose(c.changes),jC(o.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,MC)):OC(s,s.length,i.minDepth,t),new e(s,MC,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:MC;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&AC(a[a.length-1],t)?this:new e(PC(this.done,t),this.undone,n,r)}addMapping(t){return new e(IC(this.done,t),IC(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:gC.of({side:e,rest:FC(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?MC:r.slice(0,r.length-1);return i.mapped&&(n=IC(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:gC.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};zC.empty=new zC(MC,MC);var BC=[{key:`Mod-z`,run:CC,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:wC,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:wC,preventDefault:!0},{key:`Mod-u`,run:TC,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:EC,preventDefault:!0}];function VC(e,t){return P.create(e.ranges.map(t),e.mainIndex)}function HC(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function UC({state:e,dispatch:t},n){let r=VC(e.selection,n);return r.eq(e.selection,!0)?!1:(t(HC(e,r)),!0)}function WC(e,t){return P.cursor(t?e.to:e.from)}function GC(e,t){return UC(e,n=>n.empty?e.moveByChar(n,t):WC(n,t))}function KC(e){return e.textDirectionAt(e.state.selection.main.head)==c.LTR}var qC=e=>GC(e,!KC(e)),JC=e=>GC(e,KC(e));function YC(e,t){return UC(e,n=>n.empty?e.moveByGroup(n,t):WC(n,t))}var XC=e=>YC(e,!KC(e)),ZC=e=>YC(e,KC(e));typeof Intl<`u`&&Intl.Segmenter;function QC(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function $C(e,t,n){let r=M(e).resolveInner(t.head),i=n?d.closedBy:d.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;QC(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?m(e,r.from,1):m(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,P.cursor(s,n?-1:1)}var ew=e=>UC(e,t=>$C(e.state,t,!KC(e))),tw=e=>UC(e,t=>$C(e.state,t,KC(e)));function nw(e,t){return UC(e,n=>{if(!n.empty)return WC(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var rw=e=>nw(e,!1),iw=e=>nw(e,!0);function aw(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(u.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function ow(e,t){let n=aw(e),{state:r}=e,i=VC(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):WC(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=u.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(HC(r,i),{effects:a}),!0}var sw=e=>ow(e,!1),cw=e=>ow(e,!0);function lw(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=P.cursor(r.from+n))}return i}var uw=e=>UC(e,t=>lw(e,t,!0)),dw=e=>UC(e,t=>lw(e,t,!1)),fw=e=>UC(e,t=>lw(e,t,!KC(e))),pw=e=>UC(e,t=>lw(e,t,KC(e))),mw=e=>UC(e,t=>P.cursor(e.lineBlockAt(t.head).from,1)),hw=e=>UC(e,t=>P.cursor(e.lineBlockAt(t.head).to,-1));function gw(e,t,n){let r=!1,i=VC(e.selection,t=>{let i=m(e,t.head,-1)||m(e,t.head,1)||t.head>0&&m(e,t.head-1,1)||t.head<e.doc.length&&m(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?P.range(t.anchor,a):P.cursor(a)});return r?(t(HC(e,i)),!0):!1}var _w=({state:e,dispatch:t})=>gw(e,t,!1);function vw(e,t){let n=VC(e.state.selection,e=>{let n=t(e);return P.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(HC(e.state,n)),!0)}function yw(e,t){return vw(e,n=>e.moveByChar(n,t))}var bw=e=>yw(e,!KC(e)),xw=e=>yw(e,KC(e));function Sw(e,t){return vw(e,n=>e.moveByGroup(n,t))}var Cw=e=>Sw(e,!KC(e)),ww=e=>Sw(e,KC(e)),Tw=e=>vw(e,t=>$C(e.state,t,!KC(e))),Ew=e=>vw(e,t=>$C(e.state,t,KC(e)));function Dw(e,t){return vw(e,n=>e.moveVertically(n,t))}var Ow=e=>Dw(e,!1),kw=e=>Dw(e,!0);function Aw(e,t){return vw(e,n=>e.moveVertically(n,t,aw(e).height))}var jw=e=>Aw(e,!1),Mw=e=>Aw(e,!0),Nw=e=>vw(e,t=>lw(e,t,!0)),Pw=e=>vw(e,t=>lw(e,t,!1)),Fw=e=>vw(e,t=>lw(e,t,!KC(e))),Iw=e=>vw(e,t=>lw(e,t,KC(e))),Lw=e=>vw(e,t=>P.cursor(e.lineBlockAt(t.head).from)),Rw=e=>vw(e,t=>P.cursor(e.lineBlockAt(t.head).to)),zw=({state:e,dispatch:t})=>(t(HC(e,{anchor:0})),!0),Bw=({state:e,dispatch:t})=>(t(HC(e,{anchor:e.doc.length})),!0),Vw=({state:e,dispatch:t})=>(t(HC(e,{anchor:e.selection.main.anchor,head:0})),!0),Hw=({state:e,dispatch:t})=>(t(HC(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Uw=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Ww=({state:e,dispatch:t})=>{let n=lT(e).map(({from:t,to:n})=>P.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:P.create(n),userEvent:`select`})),!0},Gw=({state:e,dispatch:t})=>{let n=VC(e.selection,t=>{let n=M(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return P.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(HC(e,n)),!0)};function Kw(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(HC(n,P.create(i,i.length-1))),!0)}var qw=e=>Kw(e,!1),Jw=e=>Kw(e,!0),Yw=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=P.create([n.main]):n.main.empty||(r=P.create([P.cursor(n.main.head)])),r?(t(HC(e,r)),!0):!1};function Xw(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Zw(e,o,!1)):o>i&&(n=`delete.forward`,o=Zw(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Zw(e,i,!1),a=Zw(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:P.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?u.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Zw(e,t,n){if(e instanceof u)for(let r of e.state.facet(u.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var Qw=(e,t,n)=>Xw(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=p(s,a.tabSize)%De(a)||De(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=_(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=_(o.text,c-o.from,!1,!1)+o.from);return c}),$w=e=>Qw(e,!1,!0),eT=e=>Qw(e,!0,!1),tT=(e,t)=>Xw(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=_(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),nT=e=>tT(e,!1),rT=e=>tT(e,!0),iT=e=>Xw(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),aT=e=>Xw(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),oT=e=>Xw(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),sT=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:h.of([``,``])},range:P.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},cT=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:_(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:_(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:P.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function lT(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function uT(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of lT(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(P.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(P.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:P.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var dT=({state:e,dispatch:t})=>uT(e,t,!1),fT=({state:e,dispatch:t})=>uT(e,t,!0);function pT(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of lT(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var mT=({state:e,dispatch:t})=>pT(e,t,!1),hT=({state:e,dispatch:t})=>pT(e,t,!0),gT=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(lT(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=VC(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function _T(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=M(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(d.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var vT=bT(!1),yT=bT(!0);function bT(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&_T(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new me(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=y(s,r);for(c??=p(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,x(t,c)];return o&&l.push(x(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:h.of(l)},range:P.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function xT(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:P.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var ST=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new me(e,{overrideIndentation:e=>n[e]??-1}),i=xT(e,(t,i,a)=>{let o=y(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=x(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},CT=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(xT(e,(t,n)=>{n.push({from:t.from,insert:e.facet(a)})}),{userEvent:`input.indent`})),!0),wT=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(xT(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=p(r,e.tabSize),a=0,o=x(e,Math.max(0,i-De(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),TT=e=>(e.setTabFocusMode(),!0),ET=[{key:`Ctrl-b`,run:qC,shift:bw,preventDefault:!0},{key:`Ctrl-f`,run:JC,shift:xw},{key:`Ctrl-p`,run:rw,shift:Ow},{key:`Ctrl-n`,run:iw,shift:kw},{key:`Ctrl-a`,run:mw,shift:Lw},{key:`Ctrl-e`,run:hw,shift:Rw},{key:`Ctrl-d`,run:eT},{key:`Ctrl-h`,run:$w},{key:`Ctrl-k`,run:iT},{key:`Ctrl-Alt-h`,run:nT},{key:`Ctrl-o`,run:sT},{key:`Ctrl-t`,run:cT},{key:`Ctrl-v`,run:cw}],DT=[{key:`ArrowLeft`,run:qC,shift:bw,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:XC,shift:Cw,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:fw,shift:Fw,preventDefault:!0},{key:`ArrowRight`,run:JC,shift:xw,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:ZC,shift:ww,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:pw,shift:Iw,preventDefault:!0},{key:`ArrowUp`,run:rw,shift:Ow,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:zw,shift:Vw},{mac:`Ctrl-ArrowUp`,run:sw,shift:jw},{key:`ArrowDown`,run:iw,shift:kw,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Bw,shift:Hw},{mac:`Ctrl-ArrowDown`,run:cw,shift:Mw},{key:`PageUp`,run:sw,shift:jw},{key:`PageDown`,run:cw,shift:Mw},{key:`Home`,run:dw,shift:Pw,preventDefault:!0},{key:`Mod-Home`,run:zw,shift:Vw},{key:`End`,run:uw,shift:Nw,preventDefault:!0},{key:`Mod-End`,run:Bw,shift:Hw},{key:`Enter`,run:vT,shift:vT},{key:`Mod-a`,run:Uw},{key:`Backspace`,run:$w,shift:$w,preventDefault:!0},{key:`Delete`,run:eT,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:nT,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:rT,preventDefault:!0},{mac:`Mod-Backspace`,run:aT,preventDefault:!0},{mac:`Mod-Delete`,run:oT,preventDefault:!0}].concat(ET.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),OT=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:ew,shift:Tw},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:tw,shift:Ew},{key:`Alt-ArrowUp`,run:dT},{key:`Shift-Alt-ArrowUp`,run:mT},{key:`Alt-ArrowDown`,run:fT},{key:`Shift-Alt-ArrowDown`,run:hT},{key:`Mod-Alt-ArrowUp`,run:qw},{key:`Mod-Alt-ArrowDown`,run:Jw},{key:`Escape`,run:Yw},{key:`Mod-Enter`,run:yT},{key:`Alt-l`,mac:`Ctrl-l`,run:Ww},{key:`Mod-i`,run:Gw,preventDefault:!0},{key:`Mod-[`,run:wT},{key:`Mod-]`,run:CT},{key:`Mod-Alt-\\`,run:ST},{key:`Shift-Mod-k`,run:gT},{key:`Shift-Mod-\\`,run:_w},{key:`Mod-/`,run:aC},{key:`Alt-A`,run:cC},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:TT}].concat(DT),kT={key:`Tab`,run:CT,shift:wT},AT=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,jT=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(AT(e)):AT,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return n(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=s(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=le(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(jT.prototype[Symbol.iterator]=function(){return this});var MT={from:-1,to:-1,match:/.*/.exec(``)},NT=`gm`+(/x/.unicode==null?``:`u`),PT=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=MT,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new LT(e,t,n,r,i);this.re=new RegExp(t,NT+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=zT(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=zT(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},FT=new WeakMap,IT=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=FT.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return FT.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),FT.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},LT=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=MT,this.matchPos=zT(e,r),this.re=new RegExp(t,NT+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=IT.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=zT(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=IT.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(PT.prototype[Symbol.iterator]=LT.prototype[Symbol.iterator]=function(){return this});function RT(e){try{return new RegExp(e,NT),!0}catch{return!1}}function zT(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var BT=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=Ce(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,d=c?+c.slice(1):0,f=s?+s:a.number;if(s&&l){let e=f/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),f=Math.round(t.doc.lines*e)}else s&&o&&(f=f*(o==`-`?-1:1)+a.number);let p=t.doc.line(Math.max(1,Math.min(t.doc.lines,f))),m=P.cursor(p.from+Math.max(0,Math.min(d,p.length)));e.dispatch({effects:[r,u.scrollIntoView(m.from,{y:`center`})],selection:m})}),!0},VT={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},HT=te.define({combine(e){return f(e,VT,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function UT(e){let t=[YT,JT];return e&&t.push(HT.of(e)),t}var WT=C.mark({class:`cm-selectionMatch`}),GT=C.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function KT(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=D.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=D.Word)}function qT(e,t,n,r){return e(t.sliceDoc(n,n+1))==D.Word&&e(t.sliceDoc(r-1,r))==D.Word}var JT=ve.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(HT),{state:n}=e,r=n.selection;if(r.ranges.length>1)return C.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return C.none;let e=n.wordAt(i.head);if(!e)return C.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return C.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(KT(o,n,i.from,i.to)&&qT(o,n,i.from,i.to)))return C.none}else if(a=n.sliceDoc(i.from,i.to),!a)return C.none}let s=[];for(let r of e.visibleRanges){let e=new jT(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||KT(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(GT.range(r,a)):(r>=i.to||a<=i.from)&&s.push(WT.range(r,a)),s.length>t.maxMatches))return C.none}}return C.set(s)}},{decorations:e=>e.decorations}),YT=u.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),XT=({state:e,dispatch:t})=>{let{selection:n}=e,r=P.create(n.ranges.map(t=>e.wordAt(t.head)||P.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function ZT(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new jT(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new jT(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var QT=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return XT({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=ZT(e,r);return i?(t(e.update({selection:e.selection.addRange(P.range(i.from,i.to),!1),effects:u.scrollIntoView(i.to)})),!0):!1},$T=te.define({combine(e){return f(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new NE(e),scrollToMatch:e=>u.scrollIntoView(e)})}}),eE=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||RT(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
209
|
-
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new dE(this):new aE(this)}getCursor(e,t=0,n){let r=e.doc?e:ke.create({doc:e});return n??=r.doc.length,this.regexp?sE(this,r,t,n):rE(this,r,t,n)}},tE=class{constructor(e){this.spec=e}};function nE(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function rE(e,t,n,r){let i;return e.wholeWord&&(i=iE(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=nE(e.test,t,i)),new jT(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function iE(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(cE(i,n-a))!=D.Word||t(lE(i,n-a))!=D.Word)&&(t(lE(i,r-a))!=D.Word||t(cE(i,r-a))!=D.Word))}var aE=class extends tE{constructor(e){super(e)}nextMatch(e,t,n){let r=rE(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=rE(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=rE(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=rE(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=rE(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function oE(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function sE(e,t,n,r){let i;return e.wholeWord&&(i=uE(t.charCategorizer(t.selection.main.head))),e.test&&(i=oE(e.test,t,i)),new PT(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function cE(e,t){return e.slice(_(e,t,!1),t)}function lE(e,t){return e.slice(t,_(e,t))}function uE(e){return(t,n,r)=>!r[0].length||(e(cE(r.input,r.index))!=D.Word||e(lE(r.input,r.index))!=D.Word)&&(e(lE(r.input,r.index+r[0].length))!=D.Word||e(cE(r.input,r.index+r[0].length))!=D.Word)}var dE=class extends tE{nextMatch(e,t,n){let r=sE(this.spec,e,n,e.doc.length).next();return r.done&&(r=sE(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=sE(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=sE(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=sE(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},fE=o.define(),pE=o.define(),mE=i.define({create(e){return new hE(DE(e).create(),null)},update(e,t){for(let n of t.effects)n.is(fE)?e=new hE(n.value.create(),e.panel):n.is(pE)&&(e=new hE(e.query,n.value?EE:null));return e},provide:e=>k.from(e,e=>e.panel)}),hE=class{constructor(e,t){this.query=e,this.panel=t}},gE=C.mark({class:`cm-searchMatch`}),_E=C.mark({class:`cm-searchMatch cm-searchMatch-selected`}),vE=ve.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(mE))}update(e){let t=e.state.field(mE);(t!=e.startState.field(mE)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return C.none;let{view:n}=this,r=new Ee;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?_E:gE)})}return r.finish()}},{decorations:e=>e.decorations});function yE(e){return t=>{let n=t.state.field(mE,!1);return n&&n.query.spec.valid?e(t,n):AE(t)}}var bE=yE((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=P.single(r.from,r.to),a=e.state.facet($T);return e.dispatch({selection:i,effects:[LE(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),kE(e),!0}),xE=yE((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=P.single(i.from,i.to),o=e.state.facet($T);return e.dispatch({selection:a,effects:[LE(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),kE(e),!0}),SE=yE((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:P.create(n.map(e=>P.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),CE=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new jT(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(P.range(t.value.from,t.value.to))}return t(e.update({selection:P.create(a,o),userEvent:`select.search.matches`})),!0},wE=yE((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,d=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),d.push(u.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let f=e.state.changes(s);return o&&(c=P.single(o.from,o.to).map(f),d.push(LE(e,o)),d.push(n.facet($T).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:`input.replace`}),!0}),TE=yE((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:u.announce.of(r),userEvent:`input.replace.all`}),!0});function EE(e){return e.state.facet($T).createPanel(e)}function DE(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet($T);return new eE({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function OE(e){let t=v(e,EE);return t&&t.dom.querySelector(`[main-field]`)}function kE(e){let t=OE(e);t&&t==e.root.activeElement&&t.select()}var AE=e=>{let t=e.state.field(mE,!1);if(t&&t.panel){let n=OE(e);if(n&&n!=e.root.activeElement){let r=DE(e.state,t.query.spec);r.valid&&e.dispatch({effects:fE.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[pE.of(!0),t?fE.of(DE(e.state,t.query.spec)):o.appendConfig.of(zE)]});return!0},jE=e=>{let t=e.state.field(mE,!1);if(!t||!t.panel)return!1;let n=v(e,EE);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:pE.of(!1)}),!0},ME=[{key:`Mod-f`,run:AE,scope:`editor search-panel`},{key:`F3`,run:bE,shift:xE,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:bE,shift:xE,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:jE,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:CE},{key:`Mod-Alt-g`,run:BT},{key:`Mod-d`,run:QT,preventDefault:!0}],NE=class{constructor(e){this.view=e;let t=this.query=e.state.field(mE).query.spec;this.commit=this.commit.bind(this),this.searchField=N(`input`,{value:t.search,placeholder:PE(e,`Find`),"aria-label":PE(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=N(`input`,{value:t.replace,placeholder:PE(e,`Replace`),"aria-label":PE(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=N(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=N(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=N(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return N(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=N(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>bE(e),[PE(e,`next`)]),n(`prev`,()=>xE(e),[PE(e,`previous`)]),n(`select`,()=>SE(e),[PE(e,`all`)]),N(`label`,null,[this.caseField,PE(e,`match case`)]),N(`label`,null,[this.reField,PE(e,`regexp`)]),N(`label`,null,[this.wordField,PE(e,`by word`)]),...e.state.readOnly?[]:[N(`br`),this.replaceField,n(`replace`,()=>wE(e),[PE(e,`replace`)]),n(`replaceAll`,()=>TE(e),[PE(e,`replace all`)])],N(`button`,{name:`close`,onclick:()=>jE(e),"aria-label":PE(e,`close`),type:`button`},[`×`])])}commit(){let e=new eE({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:fE.of(e)}))}keydown(e){fe(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?xE:bE)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),wE(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(fE)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet($T).top}};function PE(e,t){return e.state.phrase(t)}var FE=30,IE=/[\s\.,:;?!]/;function LE(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-FE),o=Math.min(i,n+FE),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<FE;e++)if(!IE.test(s[e+1])&&IE.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-FE;e--)if(!IE.test(s[e-1])&&IE.test(s[e])){s=s.slice(0,e);break}}return u.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var RE=u.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),zE=[mE,b.low(vE),RE],BE=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=M(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(qE(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function VE(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function HE(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=VE(t)+VE(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function UE(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:HE(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function WE(e,t){return n=>{for(let t=M(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var GE=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function KE(e){return e.selection.main.from}function qE(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var JE=pe.define();function YE(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:P.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var XE=new WeakMap;function ZE(e){if(!Array.isArray(e))return e;let t=XE.get(e);return t||XE.set(e,t=UE(e)),t}var QE=o.define(),$E=o.define(),eD=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let r=n(e,t),i=le(r);this.chars.push(r);let a=e.slice(t,t+i),o=a.toUpperCase();this.folded.push(n(o==a?a.toLowerCase():o,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:r,any:i,precise:a,byWord:o}=this;if(t.length==1){let i=n(e,0),a=le(i),o=a==e.length?0:-100;if(i!=t[0])if(i==r[0])o+=-200;else return null;return this.ret(o,[0,a])}let c=e.indexOf(this.pattern);if(c==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,u=0;if(c<0){for(let a=0,o=Math.min(e.length,200);a<o&&u<l;){let o=n(e,a);(o==t[u]||o==r[u])&&(i[u++]=a),a+=le(o)}if(u<l)return null}let d=0,f=0,p=!1,m=0,h=-1,g=-1,_=/[a-z]/.test(e),v=!0;for(let i=0,u=Math.min(e.length,200),y=0;i<u&&f<l;){let u=n(e,i);c<0&&(d<l&&u==t[d]&&(a[d++]=i),m<l&&(u==t[m]||u==r[m]?(m==0&&(h=i),g=i+1,m++):m=0));let b,x=u<255?u>=48&&u<=57||u>=97&&u<=122?2:u>=65&&u<=90?1:0:(b=s(u))==b.toLowerCase()?b==b.toUpperCase()?0:2:1;(!i||x==1&&_||y==0&&x!=0)&&(t[f]==u||r[f]==u&&(p=!0)?o[f++]=i:o.length&&(v=!1)),y=x,i+=le(u)}return f==l&&o[0]==0&&v?this.result(-100+(p?-200:0),o,e):m==l&&h==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):m==l?this.ret(-900-e.length,[h,g]):f==l?this.result(-100+(p?-200:0)+-700+(v?0:-1100),o,e):t.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,t,r){let i=[],a=0;for(let e of t){let t=e+(this.astral?le(n(r,e)):1);a&&i[a-1]==e?i[a-1]=t:(i[a++]=e,i[a++]=t)}return this.ret(e-r.length,i)}},tD=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},nD=te.define({combine(e){return f(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:iD,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>rD(e(n),t(n)),optionClass:(e,t)=>n=>rD(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function rD(e,t){return e?t?e+` `+t:e:t}function iD(e,t,n,r,i,a){let o=e.textDirection==c.RTL,s=o,l=!1,u=`top`,d,f,p=t.left-i.left,m=i.right-t.right,h=r.right-r.left,g=r.bottom-r.top;if(s&&p<Math.min(h,m)?s=!1:!s&&m<Math.min(h,p)&&(s=!0),h<=(s?p:m))d=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,f=Math.min(400,s?p:m);else{l=!0,f=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=g||e>t.top?d=n.bottom-t.top:(u=`bottom`,d=t.bottom-n.top)}let _=(t.bottom-t.top)/a.offsetHeight,v=(t.right-t.left)/a.offsetWidth;return{style:`${u}: ${d/_}px; max-width: ${f/v}px`,class:`cm-completionInfo-`+(l?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var aD=o.define();function oD(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function sD(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}var cD=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(nD);this.optionContent=oD(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=sD(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:aD.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(nD).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:$E.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=sD(r.length,i,e.state.facet(nD).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=sD(t.options.length,t.selected,this.view.state.facet(nD).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>_e(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&uD(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(nD).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function lD(e,t){return n=>new cD(n,e,t)}function uD(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function dD(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function fD(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(nD);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new GE(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new tD(n):new eD(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new GE(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):dD(e.completion)>dD(c)&&(s[s.length-1]=e),c=e.completion}return s}var pD=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,vD(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=fD(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(nD).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,vD(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:DD,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},mD=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(yD,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(nD),i=(r.override||n.languageDataAt(`autocomplete`,KE(n)).map(ZE)).map(e=>(this.active.find(t=>t.source==e)||new xD(e,this.active.some(e=>e.state!=0)?1:0)).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(wD));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!hD(i,this.active)||o?a=pD.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new xD(e.source,0):e));for(let e of t.effects)e.is(aD)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?gD:_D}};function hD(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var gD={"aria-autocomplete":`list`},_D={};function vD(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var yD=[];function bD(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(JE);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var xD=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=bD(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(QE))i=new e(i.source,1,n.value);else if(n.is($E))i=new e(i.source,0);else if(n.is(wD))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(KE(e.state))}},SD=class e extends xD{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=KE(t.state);if(o>a||!r||n&2&&(KE(t.startState)==this.from||o<this.limit))return new xD(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return CD(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new BE(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??KE(t.state)):new xD(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new xD(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function CD(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):qE(e,!0).test(i)}var wD=o.define({map(e,t){return e.map(e=>e.map(t))}}),TD=i.define({create(){return mD.start()},update(e,t){return e.update(t)},provide:e=>[ae.from(e,e=>e.tooltip),u.contentAttributes.from(e,e=>e.attrs)]});function ED(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(TD).active.find(e=>e.source==t.source);return r instanceof SD?(typeof n==`string`?e.dispatch({...YE(e.state,n,r.from,r.to),annotations:JE.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var DD=lD(TD,ED);function OD(t,n=`option`){return r=>{let i=r.state.field(TD,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<r.state.facet(nD).interactionDelay)return!1;let a=1,o;n==`page`&&(o=e(r,i.open.tooltip))&&(a=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector(`li`).offsetHeight)-1));let{length:s}=i.open.options,c=i.open.selected>-1?i.open.selected+a*(t?1:-1):t?0:s-1;return c<0?c=n==`page`?0:s-1:c>=s&&(c=n==`page`?s-1:0),r.dispatch({effects:aD.of(c)}),!0}}var kD=e=>{let t=e.state.field(TD,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(nD).interactionDelay?!1:ED(e,t.open.options[t.open.selected])},AD=e=>e.state.field(TD,!1)?(e.dispatch({effects:QE.of(!0)}),!0):!1,jD=e=>{let t=e.state.field(TD,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:$E.of(null)}),!0)},MD=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},ND=50,PD=1e3,FD=ve.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(TD).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(TD),n=e.state.facet(nD);if(!e.selectionSet&&!e.docChanged&&e.startState.field(TD)==t)return;let r=e.transactions.some(e=>{let t=bD(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>ND&&Date.now()-n.time>PD){for(let e of n.context.abortListeners)try{e()}catch(e){_e(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(QE)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(TD);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(nD).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new BE(t,KE(t),e.explicit,this.view),r=new MD(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:$E.of(null)}),_e(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(nD).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(nD),n=this.view.state.field(TD);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=KE(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+(i.active.explicit?0:1)),a=new SD(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new xD(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:wD.of(e)})}},{eventHandlers:{blur(t){let n=this.view.state.field(TD,!1);if(n&&n.tooltip&&this.view.state.facet(nD).closeOnBlur){let r=n.open&&e(this.view,n.open.tooltip);(!r||!r.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:$E.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:QE.of(!1)}),20),this.composing=0}}}),ID=typeof navigator==`object`&&/Win/.test(navigator.platform),LD=b.highest(u.domEventHandlers({keydown(e,t){let n=t.state.field(TD,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(ID&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&ED(t,r),!1}})),RD=u.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),zD=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},BD=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,Oe.TrackDel),r=t.mapPos(this.to,1,Oe.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},VD=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),o=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=o,s=/^\t*/.exec(i)[0].length;for(let t=0;t<s;t++)n+=e.facet(a);r.push(t+n.length-s),i=n+i.slice(s)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new BD(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new zD(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},HD=C.widget({widget:new class extends l{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),UD=C.mark({class:`cm-snippetField`}),WD=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=C.set(e.map(e=>(e.from==e.to?HD:UD).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},GD=o.define({map(e,t){return e&&e.map(t)}}),KD=o.define(),qD=i.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(GD))return n.value;if(n.is(KD)&&e)return new WD(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>u.decorations.from(e,e=>e?e.deco:C.none)});function JD(e,t){return P.create(e.filter(e=>e.field==t).map(e=>P.range(e.from,e.to)))}function YD(e){let t=VD.parse(e);return(e,n,r,i)=>{let{text:a,ranges:s}=t.instantiate(e.state,r),{main:c}=e.state.selection,l={changes:{from:r,to:i==c.from?c.to:i,insert:h.of(a)},scrollIntoView:!0,annotations:n?[JE.of(n),ue.userEvent.of(`input.complete`)]:void 0};if(s.length&&(l.selection=JD(s,0)),s.some(e=>e.field>0)){let t=new WD(s,0),n=l.effects=[GD.of(t)];e.state.field(qD,!1)===void 0&&n.push(o.appendConfig.of([qD,$D,tO,RD]))}e.dispatch(e.state.update(l))}}function XD(e){return({state:t,dispatch:n})=>{let r=t.field(qD,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:JD(r.ranges,i),effects:GD.of(a?null:new WD(r.ranges,i)),scrollIntoView:!0})),!0}}var ZD=[{key:`Tab`,run:XD(1),shift:XD(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(qD,!1)?(t(e.update({effects:GD.of(null)})),!0):!1}],QD=te.define({combine(e){return e.length?e[0]:ZD}}),$D=b.highest(j.compute([QD],e=>e.facet(QD)));function eO(e,t){return{...t,apply:YD(e)}}var tO=u.domEventHandlers({mousedown(e,t){let n=t.state.field(qD,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:JD(n.ranges,i.field),effects:GD.of(n.ranges.some(e=>e.field>i.field)?new WD(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),nO={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},rO=o.define({map(e,t){return t.mapPos(e,-1,Oe.TrackAfter)??void 0}}),iO=new class extends S{};iO.startSide=1,iO.endSide=-1;var aO=i.define({create(){return r.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(rO)&&(e=e.update({add:[iO.range(n.value,n.value+1)]}));return e}});function oO(){return[dO,aO]}var sO=`()[]{}<>«»»«[]{}`;function cO(e){for(let t=0;t<16;t+=2)if(sO.charCodeAt(t)==e)return sO.charAt(t+1);return s(e<128?e:e+1)}function lO(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||nO}var uO=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),dO=u.inputHandler.of((e,t,r,i)=>{if((uO?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let a=e.state.selection.main;if(i.length>2||i.length==2&&le(n(i,0))==1||t!=a.from||r!=a.to)return!1;let o=pO(e.state,i);return o?(e.dispatch(o),!0):!1}),fO=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=lO(e,e.selection.main.head).brackets||nO.brackets,i=null,a=e.changeByRange(t=>{if(t.empty){let i=gO(e.doc,t.head);for(let a of r)if(a==i&&hO(e.doc,t.head)==cO(n(a,0)))return{changes:{from:t.head-a.length,to:t.head+a.length},range:P.cursor(t.head-a.length)}}return{range:i=t}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:`delete.backward`})),!i}}];function pO(e,t){let r=lO(e,e.selection.main.head),i=r.brackets||nO.brackets;for(let a of i){let o=cO(n(a,0));if(t==a)return o==a?yO(e,a,i.indexOf(a+a+a)>-1,r):_O(e,a,o,r.before||nO.before);if(t==o&&mO(e,e.selection.main.from))return vO(e,a,o)}return null}function mO(e,t){let n=!1;return e.field(aO).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function hO(e,t){let r=e.sliceString(t,t+2);return r.slice(0,le(n(r,0)))}function gO(e,t){let r=e.sliceString(t-2,t);return le(n(r,0))==r.length?r:r.slice(1)}function _O(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:rO.of(a.to+t.length),range:P.range(a.anchor+t.length,a.head+t.length)};let o=hO(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:rO.of(a.head+t.length),range:P.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function vO(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&hO(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:P.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function yO(e,t,n,r){let i=r.stringPrefixes||nO.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:rO.of(r.to+t.length),range:P.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=hO(e.doc,o),c;if(s==t){if(bO(e,o))return{changes:{insert:t+t,from:o},effects:rO.of(o+t.length),range:P.cursor(o+t.length)};if(mO(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:P.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=SO(e,o-2*t.length,i))>-1&&bO(e,c))return{changes:{insert:t+t+t+t,from:o},effects:rO.of(o+t.length),range:P.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=D.Word&&SO(e,o,i)>-1&&!xO(e,o,t,i))return{changes:{insert:t+t,from:o},effects:rO.of(o+t.length),range:P.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function bO(e,t){let n=M(e).resolveInner(t+1);return n.parent&&n.from==t}function xO(e,t,n,r){let i=M(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function SO(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=D.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=D.Word)return n}return-1}function CO(e={}){return[LD,TD,nD.of(e),FD,TO,RD]}var wO=[{key:`Ctrl-Space`,run:AD},{mac:"Alt-`",run:AD},{mac:`Alt-i`,run:AD},{key:`Escape`,run:jD},{key:`ArrowDown`,run:OD(!0)},{key:`ArrowUp`,run:OD(!1)},{key:`PageDown`,run:OD(!0,`page`)},{key:`PageUp`,run:OD(!1,`page`)},{key:`Enter`,run:kD}],TO=b.highest(j.computeN([nD],e=>e.facet(nD).defaultKeymap?[wO]:[])),EO=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},DO=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(VO).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Ee,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=QO(s);if(i)o.add(n,n,C.widget({widget:new GO(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,C.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,OO(f))}};function OO(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new EO(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new EO(r.from,n,r.diagnostic)}),r}function kO(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(VO).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(jO))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function AO(e,t){return e.field(PO,!1)?t:t.concat(o.appendConfig.of($O))}var jO=o.define(),MO=o.define(),NO=o.define(),PO=i.define({create(){return new DO(C.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=OO(n,e.selected.diagnostic,i)||OO(n,null,i)}!n.size&&i&&t.state.facet(VO).autoPanel&&(i=null),e=new DO(n,i,r)}for(let n of t.effects)if(n.is(jO)){let r=t.state.facet(VO).autoPanel?n.value.length?qO.open:null:e.panel;e=DO.init(n.value,r,t.state)}else n.is(MO)?e=new DO(e.diagnostics,n.value?qO.open:null,e.selected):n.is(NO)&&(e=new DO(e.diagnostics,e.panel,n.value));return e},provide:e=>[k.from(e,e=>e.panel),u.decorations.from(e,e=>e.diagnostics)]}),FO=C.mark({class:`cm-lintRange cm-lintRange-active`});function IO(e,t,n){let{diagnostics:r}=e.state.field(PO),i,a=-1,o=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(VO).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:LO(e,i)}}}:null}function LO(e,t){return N(`ul`,{class:`cm-tooltip-lint`},t.map(t=>WO(e,t,!1)))}var RO=e=>{let t=e.state.field(PO,!1);(!t||!t.panel)&&e.dispatch({effects:AO(e.state,[MO.of(!0)])});let n=v(e,qO.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},zO=e=>{let t=e.state.field(PO,!1);return!t||!t.panel?!1:(e.dispatch({effects:MO.of(!1)}),!0)},BO=[{key:`Mod-Shift-m`,run:RO,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(PO,!1);if(!t)return!1;let n=e.state.selection.main,r=OO(t.diagnostics,null,n.to+1);return!r&&(r=OO(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],VO=te.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...f(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:HO,tooltipFilter:HO,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function HO(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function UO(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function WO(e,t,n){let r=n?UO(t.actions):[];return N(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},N(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=OO(e.state.field(PO).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),N(`u`,s.slice(c,c+1)),s.slice(c+1)];return N(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&N(`div`,{class:`cm-diagnosticSource`},t.source))}var GO=class extends l{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return N(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},KO=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=WO(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},qO=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)zO(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=UO(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=OO(this.view.state.field(PO).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=N(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=N(`div`,{class:`cm-panel-lint`},this.list,N(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>zO(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(PO).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(PO),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new KO(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new KO(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=OO(this.view.state.field(PO).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:NO.of(t)})}static open(t){return new e(t)}};function JO(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function YO(e){return JO(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var XO=u.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:YO(`#d11`)},".cm-lintRange-warning":{backgroundImage:YO(`orange`)},".cm-lintRange-info":{backgroundImage:YO(`#999`)},".cm-lintRange-hint":{backgroundImage:YO(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function ZO(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function QO(e){let t=`hint`,n=1;for(let r of e){let e=ZO(r.severity);e>n&&(n=e,t=r.severity)}return t}var $O=[PO,u.decorations.compute([PO],e=>{let{selected:t,panel:n}=e.field(PO);return!t||!n||t.from==t.to?C.none:C.set([FO.range(t.from,t.to)])}),ye(IO,{hideOn:kO}),XO],ek=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,r=[];e.closeBracketsKeymap!==!1&&(r=r.concat(fO)),e.defaultKeymap!==!1&&(r=r.concat(OT)),e.searchKeymap!==!1&&(r=r.concat(ME)),e.historyKeymap!==!1&&(r=r.concat(BC)),e.foldKeymap!==!1&&(r=r.concat(we)),e.completionKeymap!==!1&&(r=r.concat(wO)),e.lintKeymap!==!1&&(r=r.concat(BO));var i=[];return e.lineNumbers!==!1&&i.push(ee()),e.highlightActiveLineGutter!==!1&&i.push(Se()),e.highlightSpecialChars!==!1&&i.push(he()),e.history!==!1&&i.push(xC()),e.foldGutter!==!1&&i.push(oe()),e.drawSelection!==!1&&i.push(w()),e.dropCursor!==!1&&i.push(E()),e.allowMultipleSelections!==!1&&i.push(ke.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(Te()),e.syntaxHighlighting!==!1&&i.push(t(ie,{fallback:!0})),e.bracketMatching!==!1&&i.push(de()),e.closeBrackets!==!1&&i.push(oO()),e.autocompletion!==!1&&i.push(CO()),e.rectangularSelection!==!1&&i.push(re()),n!==!1&&i.push(T()),e.highlightActiveLine!==!1&&i.push(A()),e.highlightSelectionMatches!==!1&&i.push(UT()),e.tabSize&&typeof e.tabSize==`number`&&i.push(a.of(` `.repeat(e.tabSize))),i.concat([j.of(r.flat())]).filter(Boolean)},tk=`#e5c07b`,nk=`#e06c75`,rk=`#56b6c2`,ik=`#ffffff`,ak=`#abb2bf`,ok=`#7d8799`,sk=`#61afef`,ck=`#98c379`,lk=`#d19a66`,uk=`#c678dd`,dk=`#21252b`,fk=`#2c313a`,pk=`#282c34`,mk=`#353a42`,hk=`#3E4451`,gk=`#528bff`,_k=[u.theme({"&":{color:ak,backgroundColor:pk},".cm-content":{caretColor:gk},".cm-cursor, .cm-dropCursor":{borderLeftColor:gk},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:hk},".cm-panels":{backgroundColor:dk,color:ak},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:pk,color:ok,border:`none`},".cm-activeLineGutter":{backgroundColor:fk},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:mk},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:mk,borderBottomColor:mk},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:fk,color:ak}}},{dark:!0}),t(xe.define([{tag:g.keyword,color:uk},{tag:[g.name,g.deleted,g.character,g.propertyName,g.macroName],color:nk},{tag:[g.function(g.variableName),g.labelName],color:sk},{tag:[g.color,g.constant(g.name),g.standard(g.name)],color:lk},{tag:[g.definition(g.name),g.separator],color:ak},{tag:[g.typeName,g.className,g.number,g.changed,g.annotation,g.modifier,g.self,g.namespace],color:tk},{tag:[g.operator,g.operatorKeyword,g.url,g.escape,g.regexp,g.link,g.special(g.string)],color:rk},{tag:[g.meta,g.comment],color:ok},{tag:g.strong,fontWeight:`bold`},{tag:g.emphasis,fontStyle:`italic`},{tag:g.strikethrough,textDecoration:`line-through`},{tag:g.link,color:ok,textDecoration:`underline`},{tag:g.heading,fontWeight:`bold`,color:nk},{tag:[g.atom,g.bool,g.special(g.variableName)],color:lk},{tag:[g.processingInstruction,g.string,g.inserted],color:ck},{tag:g.invalid,color:ik}]))],vk=u.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),yk=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i=`light`,placeholder:a=``,basicSetup:o=!0}=e,s=[];switch(t&&s.unshift(j.of([kT])),o&&(typeof o==`boolean`?s.unshift(ek()):s.unshift(ek(o))),a&&s.unshift(be(a)),i){case`light`:s.push(vk);break;case`dark`:s.push(_k);break;case`none`:break;default:s.push(i);break}return n===!1&&s.push(u.editable.of(!1)),r&&s.push(ke.readOnly.of(!0)),[...s]},bk=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),xk=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},Sk=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},Ck=null,wk=()=>typeof window>`u`?new Sk:(Ck||=new Sk,Ck),Tk=pe.define(),Ek=200,Dk=[];function Ok(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:a,onUpdate:s,extensions:c=Dk,autoFocus:l,theme:d=`light`,height:f=null,minHeight:p=null,maxHeight:m=null,width:h=null,minWidth:g=null,maxWidth:_=null,placeholder:v=``,editable:y=!0,readOnly:b=!1,indentWithTab:x=!0,basicSetup:S=!0,root:C,initialState:w}=e,[T,E]=(0,I.useState)(),[D,O]=(0,I.useState)(),[ee,te]=(0,I.useState)(),ne=(0,I.useState)(()=>({current:null}))[0],re=(0,I.useState)(()=>({current:null}))[0],k=u.theme({"&":{height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_},"& .cm-scroller":{height:`100% !important`}}),A=[u.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(Tk))&&(ne.current?ne.current.reset():(ne.current=new xk(()=>{if(re.current){var e=re.current;re.current=null,e()}ne.current=null},Ek),wk().add(ne.current)),r(e.state.doc.toString(),e)),i&&i(bk(e))}),k,...yk({theme:d,editable:y,readOnly:b,placeholder:v,indentWithTab:x,basicSetup:S})];return s&&typeof s==`function`&&A.push(u.updateListener.of(s)),A=A.concat(c),(0,I.useLayoutEffect)(()=>{if(T&&!ee){var e={doc:t,selection:n,extensions:A},r=w?ke.fromJSON(w.json,e,w.fields):ke.create(e);if(te(r),!D){var i=new u({state:r,parent:T,root:C});O(i),a&&a(i,r)}}return()=>{D&&(te(void 0),O(void 0))}},[T,ee]),(0,I.useEffect)(()=>{e.container&&E(e.container)},[e.container]),(0,I.useEffect)(()=>()=>{D&&(D.destroy(),O(void 0)),ne.current&&=(ne.current.cancel(),null)},[D]),(0,I.useEffect)(()=>{l&&D&&D.focus()},[l,D]),(0,I.useEffect)(()=>{D&&D.dispatch({effects:o.reconfigure.of(A)})},[d,c,f,p,m,h,g,_,v,y,b,x,S,r,s]),(0,I.useEffect)(()=>{if(t!==void 0){var e=D?D.state.doc.toString():``;if(D&&t!==e){var n=ne.current&&!ne.current.isDone,r=()=>{D&&t!==D.state.doc.toString()&&D.dispatch({changes:{from:0,to:D.state.doc.toString().length,insert:t||``},annotations:[Tk.of(!0)]})};n?re.current=r:r()}}},[t,D]),{state:ee,setState:te,view:D,setView:O,container:T,setContainer:E}}var kk=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],Ak=(0,I.forwardRef)((e,t)=>{var{className:n,value:r=``,selection:i,extensions:a=[],onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,autoFocus:u,theme:d=`light`,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,root:C,initialState:w}=e,T=iC(e,kk),E=(0,I.useRef)(null),{state:D,view:O,container:ee,setContainer:te}=Ok({root:C,value:r,autoFocus:u,theme:d,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,selection:i,onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,extensions:a,initialState:w});(0,I.useImperativeHandle)(t,()=>({editor:E.current,state:D,view:O}),[E,ee,D,O]);var ne=(0,I.useCallback)(e=>{E.current=e,te(e)},[te]);if(typeof r!=`string`)throw Error(`value must be typeof string but got `+typeof r);return(0,L.jsx)(`div`,rC({ref:ne,className:(typeof d==`string`?`cm-theme-`+d:`cm-theme`)+(n?` `+n:``)},T))});Ak.displayName=`CodeMirror`;var jk=`modulepreload`,Mk=function(e){return`/`+e},Nk={},Q=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}))))}r=o(t.map(t=>{if(t=Mk(t,n),t in Nk)return;Nk[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:jk,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}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 $(e){return new ge(ne.define(e))}function Pk(e){return Q(()=>import(`./dist-ChuUwcd4.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([0,1,2]))}var Fk=[O.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return Q(()=>import(`./dist-DYBvJnrG.js`).then(e=>e.cpp()),__vite__mapDeps([3,1,2]))}}),O.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return Q(()=>import(`./dist-DYBvJnrG.js`).then(e=>e.cpp()),__vite__mapDeps([3,1,2]))}}),O.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return Pk(`Cassandra`)}}),O.of({name:`CSS`,extensions:[`css`],load(){return Q(()=>import(`./dist-mCTXNkQ9.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([4,1,2]))}}),O.of({name:`Go`,extensions:[`go`],load(){return Q(()=>import(`./dist-ByyB_57-.js`).then(e=>e.go()),__vite__mapDeps([5,1,2]))}}),O.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return Q(()=>import(`./dist-DO7LTg3a.js`).then(e=>e.html()),__vite__mapDeps([6,4,1,2,7]))}}),O.of({name:`Java`,extensions:[`java`],load(){return Q(()=>import(`./dist-elfU6IUT.js`).then(e=>e.java()),__vite__mapDeps([8,1,2]))}}),O.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return Q(()=>import(`./dist-DH3Q_V27.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,2]))}}),O.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return Q(()=>import(`./dist-D6kXrcQY.js`).then(e=>e.jinja()),__vite__mapDeps([9,4,1,2,6,7]))}}),O.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return Q(()=>import(`./dist-Cc03jTPl.js`).then(e=>e.json()),__vite__mapDeps([10,1,2]))}}),O.of({name:`JSX`,extensions:[`jsx`],load(){return Q(()=>import(`./dist-DH3Q_V27.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([7,1,2]))}}),O.of({name:`LESS`,extensions:[`less`],load(){return Q(()=>import(`./dist-BvjF9csH.js`).then(e=>e.less()),__vite__mapDeps([11,4,1,2]))}}),O.of({name:`Liquid`,extensions:[`liquid`],load(){return Q(()=>import(`./dist-Cuva2wRW.js`).then(e=>e.liquid()),__vite__mapDeps([12,4,1,2,6,7]))}}),O.of({name:`MariaDB SQL`,load(){return Pk(`MariaSQL`)}}),O.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return Q(()=>import(`./dist--QplBylv.js`).then(e=>e.markdown()),__vite__mapDeps([13,4,1,2,6,7]))}}),O.of({name:`MS SQL`,load(){return Pk(`MSSQL`)}}),O.of({name:`MySQL`,load(){return Pk(`MySQL`)}}),O.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return Q(()=>import(`./dist-CUQQ4au1.js`).then(e=>e.php()),__vite__mapDeps([14,4,1,2,6,7]))}}),O.of({name:`PLSQL`,extensions:[`pls`],load(){return Pk(`PLSQL`)}}),O.of({name:`PostgreSQL`,load(){return Pk(`PostgreSQL`)}}),O.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return Q(()=>import(`./dist-CyFWfPpu.js`).then(e=>e.python()),__vite__mapDeps([15,1,2]))}}),O.of({name:`Rust`,extensions:[`rs`],load(){return Q(()=>import(`./dist-C6S96i9v.js`).then(e=>e.rust()),__vite__mapDeps([16,1,2]))}}),O.of({name:`Sass`,extensions:[`sass`],load(){return Q(()=>import(`./dist-C5sjJwrm.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([17,4,1,2]))}}),O.of({name:`SCSS`,extensions:[`scss`],load(){return Q(()=>import(`./dist-C5sjJwrm.js`).then(e=>e.sass()),__vite__mapDeps([17,4,1,2]))}}),O.of({name:`SQL`,extensions:[`sql`],load(){return Pk(`StandardSQL`)}}),O.of({name:`SQLite`,load(){return Pk(`SQLite`)}}),O.of({name:`TSX`,extensions:[`tsx`],load(){return Q(()=>import(`./dist-DH3Q_V27.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([7,1,2]))}}),O.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return Q(()=>import(`./dist-DH3Q_V27.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,2]))}}),O.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return Q(()=>import(`./dist-BSpuB3dZ.js`).then(e=>e.wast()),__vite__mapDeps([18,1,2]))}}),O.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return Q(()=>import(`./dist-DIQDx3Dq.js`).then(e=>e.xml()),__vite__mapDeps([19,1,2]))}}),O.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return Q(()=>import(`./dist-CftiQ_Tf.js`).then(e=>e.yaml()),__vite__mapDeps([20,1,2]))}}),O.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return Q(()=>import(`./apl-Dgw9L7wA.js`).then(e=>$(e.apl)),[])}}),O.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return Q(()=>import(`./asciiarmor-B3T-Ib7X.js`).then(e=>$(e.asciiArmor)),[])}}),O.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return Q(()=>import(`./asn1-C0KgO0Wt.js`).then(e=>$(e.asn1({}))),[])}}),O.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return Q(()=>import(`./asterisk-D7tOY-Ef.js`).then(e=>$(e.asterisk)),[])}}),O.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return Q(()=>import(`./brainfuck-Dr6WXxS2.js`).then(e=>$(e.brainfuck)),[])}}),O.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return Q(()=>import(`./cobol-ng5WMKOY.js`).then(e=>$(e.cobol)),[])}}),O.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.csharp)),[])}}),O.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return Q(()=>import(`./clojure-DsDsbt3V.js`).then(e=>$(e.clojure)),[])}}),O.of({name:`ClojureScript`,extensions:[`cljs`],load(){return Q(()=>import(`./clojure-DsDsbt3V.js`).then(e=>$(e.clojure)),[])}}),O.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return Q(()=>import(`./css-zrdFFahf.js`).then(e=>$(e.gss)),[])}}),O.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return Q(()=>import(`./cmake-CaoY67QC.js`).then(e=>$(e.cmake)),[])}}),O.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return Q(()=>import(`./coffeescript-L66efR1O.js`).then(e=>$(e.coffeeScript)),[])}}),O.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return Q(()=>import(`./commonlisp-rk__8_Ow.js`).then(e=>$(e.commonLisp)),[])}}),O.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return Q(()=>import(`./cypher-DTKBhe_T.js`).then(e=>$(e.cypher)),[])}}),O.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return Q(()=>import(`./python-_LoDBjEZ.js`).then(e=>$(e.cython)),[])}}),O.of({name:`Crystal`,extensions:[`cr`],load(){return Q(()=>import(`./crystal-C1BeQSjD.js`).then(e=>$(e.crystal)),[])}}),O.of({name:`D`,extensions:[`d`],load(){return Q(()=>import(`./d-CDf89RKe.js`).then(e=>$(e.d)),[])}}),O.of({name:`Dart`,extensions:[`dart`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.dart)),[])}}),O.of({name:`diff`,extensions:[`diff`,`patch`],load(){return Q(()=>import(`./diff-BY4_GICG.js`).then(e=>$(e.diff)),[])}}),O.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return Q(()=>import(`./dockerfile-BBRxgo6-.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([21,22]))}}),O.of({name:`DTD`,extensions:[`dtd`],load(){return Q(()=>import(`./dtd-BOpcurKR.js`).then(e=>$(e.dtd)),[])}}),O.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return Q(()=>import(`./dylan-DrmRAfMX.js`).then(e=>$(e.dylan)),[])}}),O.of({name:`EBNF`,load(){return Q(()=>import(`./ebnf-DgECi_W8.js`).then(e=>$(e.ebnf)),[])}}),O.of({name:`ECL`,extensions:[`ecl`],load(){return Q(()=>import(`./ecl-CWDhUBvl.js`).then(e=>$(e.ecl)),[])}}),O.of({name:`edn`,extensions:[`edn`],load(){return Q(()=>import(`./clojure-DsDsbt3V.js`).then(e=>$(e.clojure)),[])}}),O.of({name:`Eiffel`,extensions:[`e`],load(){return Q(()=>import(`./eiffel-DBpGy7gs.js`).then(e=>$(e.eiffel)),[])}}),O.of({name:`Elm`,extensions:[`elm`],load(){return Q(()=>import(`./elm-Dj_ZNWRH.js`).then(e=>$(e.elm)),[])}}),O.of({name:`Erlang`,extensions:[`erl`],load(){return Q(()=>import(`./erlang-Br4TQPB7.js`).then(e=>$(e.erlang)),[])}}),O.of({name:`Esper`,load(){return Q(()=>import(`./sql-C_mHN2XB.js`).then(e=>$(e.esper)),[])}}),O.of({name:`Factor`,extensions:[`factor`],load(){return Q(()=>import(`./factor-bi5FmZTz.js`).then(e=>$(e.factor)),__vite__mapDeps([23,22]))}}),O.of({name:`FCL`,load(){return Q(()=>import(`./fcl-Dh6ibuJG.js`).then(e=>$(e.fcl)),[])}}),O.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return Q(()=>import(`./forth-fmpuPpMA.js`).then(e=>$(e.forth)),[])}}),O.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return Q(()=>import(`./fortran-CZwiXuJZ.js`).then(e=>$(e.fortran)),[])}}),O.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return Q(()=>import(`./mllike-DsgO-njf.js`).then(e=>$(e.fSharp)),[])}}),O.of({name:`Gas`,extensions:[`s`],load(){return Q(()=>import(`./gas-DotCoURX.js`).then(e=>$(e.gas)),[])}}),O.of({name:`Gherkin`,extensions:[`feature`],load(){return Q(()=>import(`./gherkin-Bw4mmeRF.js`).then(e=>$(e.gherkin)),[])}}),O.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return Q(()=>import(`./groovy-D7xek06K.js`).then(e=>$(e.groovy)),[])}}),O.of({name:`Haskell`,extensions:[`hs`],load(){return Q(()=>import(`./haskell-D5bv2Ijt.js`).then(e=>$(e.haskell)),[])}}),O.of({name:`Haxe`,extensions:[`hx`],load(){return Q(()=>import(`./haxe-UA0z6FgT.js`).then(e=>$(e.haxe)),[])}}),O.of({name:`HXML`,extensions:[`hxml`],load(){return Q(()=>import(`./haxe-UA0z6FgT.js`).then(e=>$(e.hxml)),[])}}),O.of({name:`HTTP`,load(){return Q(()=>import(`./http-DAkDDIPY.js`).then(e=>$(e.http)),[])}}),O.of({name:`IDL`,extensions:[`pro`],load(){return Q(()=>import(`./idl-DYj57TA2.js`).then(e=>$(e.idl)),[])}}),O.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return Q(()=>import(`./javascript-B9Zm1tmO.js`).then(e=>$(e.jsonld)),[])}}),O.of({name:`Julia`,extensions:[`jl`],load(){return Q(()=>import(`./julia-CpHdnx_N.js`).then(e=>$(e.julia)),[])}}),O.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.kotlin)),[])}}),O.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return Q(()=>import(`./livescript-DcEJKRZ4.js`).then(e=>$(e.liveScript)),[])}}),O.of({name:`Lua`,extensions:[`lua`],load(){return Q(()=>import(`./lua-s-LPZohT.js`).then(e=>$(e.lua)),[])}}),O.of({name:`mIRC`,extensions:[`mrc`],load(){return Q(()=>import(`./mirc-pTdL1Ym3.js`).then(e=>$(e.mirc)),[])}}),O.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return Q(()=>import(`./mathematica-c8TKcpav.js`).then(e=>$(e.mathematica)),[])}}),O.of({name:`Modelica`,extensions:[`mo`],load(){return Q(()=>import(`./modelica-PhVkZonB.js`).then(e=>$(e.modelica)),[])}}),O.of({name:`MUMPS`,extensions:[`mps`],load(){return Q(()=>import(`./mumps-DhD4kjw9.js`).then(e=>$(e.mumps)),[])}}),O.of({name:`Mbox`,extensions:[`mbox`],load(){return Q(()=>import(`./mbox-CUr7-CiI.js`).then(e=>$(e.mbox)),[])}}),O.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return Q(()=>import(`./nginx-CJc6p_yt.js`).then(e=>$(e.nginx)),[])}}),O.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return Q(()=>import(`./nsis-BHchP6IS.js`).then(e=>$(e.nsis)),__vite__mapDeps([24,22]))}}),O.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return Q(()=>import(`./ntriples-D1v3iWDa.js`).then(e=>$(e.ntriples)),[])}}),O.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.objectiveC)),[])}}),O.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.objectiveCpp)),[])}}),O.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return Q(()=>import(`./mllike-DsgO-njf.js`).then(e=>$(e.oCaml)),[])}}),O.of({name:`Octave`,extensions:[`m`],load(){return Q(()=>import(`./octave-D_WvWxqk.js`).then(e=>$(e.octave)),[])}}),O.of({name:`Oz`,extensions:[`oz`],load(){return Q(()=>import(`./oz-CmdX4m3g.js`).then(e=>$(e.oz)),[])}}),O.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return Q(()=>import(`./pascal-hNOkBp6J.js`).then(e=>$(e.pascal)),[])}}),O.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return Q(()=>import(`./perl-NQdG1b_r.js`).then(e=>$(e.perl)),[])}}),O.of({name:`Pig`,extensions:[`pig`],load(){return Q(()=>import(`./pig-CXzedlZV.js`).then(e=>$(e.pig)),[])}}),O.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return Q(()=>import(`./powershell-RXDVpFWf.js`).then(e=>$(e.powerShell)),[])}}),O.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return Q(()=>import(`./properties-BTvtucqR.js`).then(e=>$(e.properties)),[])}}),O.of({name:`ProtoBuf`,extensions:[`proto`],load(){return Q(()=>import(`./protobuf-zHRYyuba.js`).then(e=>$(e.protobuf)),[])}}),O.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return Q(()=>import(`./pug-C39WZDG2.js`).then(e=>$(e.pug)),__vite__mapDeps([25,26]))}}),O.of({name:`Puppet`,extensions:[`pp`],load(){return Q(()=>import(`./puppet-CMNLsBcD.js`).then(e=>$(e.puppet)),[])}}),O.of({name:`Q`,extensions:[`q`],load(){return Q(()=>import(`./q-SLmsw_60.js`).then(e=>$(e.q)),[])}}),O.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return Q(()=>import(`./r-CocOMjw8.js`).then(e=>$(e.r)),[])}}),O.of({name:`RPM Changes`,load(){return Q(()=>import(`./rpm-WgkTpiCm.js`).then(e=>$(e.rpmChanges)),[])}}),O.of({name:`RPM Spec`,extensions:[`spec`],load(){return Q(()=>import(`./rpm-WgkTpiCm.js`).then(e=>$(e.rpmSpec)),[])}}),O.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return Q(()=>import(`./ruby-DquNeiGE.js`).then(e=>$(e.ruby)),[])}}),O.of({name:`SAS`,extensions:[`sas`],load(){return Q(()=>import(`./sas-sJxciv6G.js`).then(e=>$(e.sas)),[])}}),O.of({name:`Scala`,extensions:[`scala`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.scala)),[])}}),O.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return Q(()=>import(`./scheme-DEjJDX5Z.js`).then(e=>$(e.scheme)),[])}}),O.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return Q(()=>import(`./shell-DhAwSAum.js`).then(e=>$(e.shell)),[])}}),O.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return Q(()=>import(`./sieve-CcW8-k2R.js`).then(e=>$(e.sieve)),[])}}),O.of({name:`Smalltalk`,extensions:[`st`],load(){return Q(()=>import(`./smalltalk-nXkQ5zwM.js`).then(e=>$(e.smalltalk)),[])}}),O.of({name:`Solr`,load(){return Q(()=>import(`./solr-DO54nYOg.js`).then(e=>$(e.solr)),[])}}),O.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return Q(()=>import(`./mllike-DsgO-njf.js`).then(e=>$(e.sml)),[])}}),O.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return Q(()=>import(`./sparql-CxAS_pwk.js`).then(e=>$(e.sparql)),[])}}),O.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return Q(()=>import(`./spreadsheet-DWzAMKF2.js`).then(e=>$(e.spreadsheet)),[])}}),O.of({name:`Squirrel`,extensions:[`nut`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.squirrel)),[])}}),O.of({name:`Stylus`,extensions:[`styl`],load(){return Q(()=>import(`./stylus-CQ8h_EBd.js`).then(e=>$(e.stylus)),[])}}),O.of({name:`Swift`,extensions:[`swift`],load(){return Q(()=>import(`./swift-D0Eq5raO.js`).then(e=>$(e.swift)),[])}}),O.of({name:`sTeX`,load(){return Q(()=>import(`./stex-BmuQ0Xsx.js`).then(e=>$(e.stex)),[])}}),O.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return Q(()=>import(`./stex-BmuQ0Xsx.js`).then(e=>$(e.stex)),[])}}),O.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return Q(()=>import(`./verilog-B0DGHLZN.js`).then(e=>$(e.verilog)),[])}}),O.of({name:`Tcl`,extensions:[`tcl`],load(){return Q(()=>import(`./tcl-D7utka2n.js`).then(e=>$(e.tcl)),[])}}),O.of({name:`Textile`,extensions:[`textile`],load(){return Q(()=>import(`./textile-XEeoev-k.js`).then(e=>$(e.textile)),[])}}),O.of({name:`TiddlyWiki`,load(){return Q(()=>import(`./tiddlywiki-CecErCuV.js`).then(e=>$(e.tiddlyWiki)),[])}}),O.of({name:`Tiki wiki`,load(){return Q(()=>import(`./tiki-BlL-kki4.js`).then(e=>$(e.tiki)),[])}}),O.of({name:`TOML`,extensions:[`toml`],load(){return Q(()=>import(`./toml-mmtg9INI.js`).then(e=>$(e.toml)),[])}}),O.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return Q(()=>import(`./troff-Crc1ZuaH.js`).then(e=>$(e.troff)),[])}}),O.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return Q(()=>import(`./ttcn-Cri02b1f.js`).then(e=>$(e.ttcn)),[])}}),O.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return Q(()=>import(`./ttcn-cfg--4YiJN4x.js`).then(e=>$(e.ttcnCfg)),[])}}),O.of({name:`Turtle`,extensions:[`ttl`],load(){return Q(()=>import(`./turtle-CUuoUr2N.js`).then(e=>$(e.turtle)),[])}}),O.of({name:`Web IDL`,extensions:[`webidl`],load(){return Q(()=>import(`./webidl-C_bKeJT2.js`).then(e=>$(e.webIDL)),[])}}),O.of({name:`VB.NET`,extensions:[`vb`],load(){return Q(()=>import(`./vb-BrHulZxe.js`).then(e=>$(e.vb)),[])}}),O.of({name:`VBScript`,extensions:[`vbs`],load(){return Q(()=>import(`./vbscript-vyHcteNE.js`).then(e=>$(e.vbScript)),[])}}),O.of({name:`Velocity`,extensions:[`vtl`],load(){return Q(()=>import(`./velocity-DN4o8rq-.js`).then(e=>$(e.velocity)),[])}}),O.of({name:`Verilog`,extensions:[`v`],load(){return Q(()=>import(`./verilog-B0DGHLZN.js`).then(e=>$(e.verilog)),[])}}),O.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return Q(()=>import(`./vhdl-WeAF-qEm.js`).then(e=>$(e.vhdl)),[])}}),O.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return Q(()=>import(`./xquery-CLyH3kVm.js`).then(e=>$(e.xQuery)),[])}}),O.of({name:`Yacas`,extensions:[`ys`],load(){return Q(()=>import(`./yacas-Dq3LuV9B.js`).then(e=>$(e.yacas)),[])}}),O.of({name:`Z80`,extensions:[`z80`],load(){return Q(()=>import(`./z80-Br7weo_y.js`).then(e=>$(e.z80)),[])}}),O.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return Q(()=>import(`./mscgen-ByD0zE8S.js`).then(e=>$(e.mscgen)),[])}}),O.of({name:`Xù`,extensions:[`xu`],load(){return Q(()=>import(`./mscgen-ByD0zE8S.js`).then(e=>$(e.xu)),[])}}),O.of({name:`MsGenny`,extensions:[`msgenny`],load(){return Q(()=>import(`./mscgen-ByD0zE8S.js`).then(e=>$(e.msgenny)),[])}}),O.of({name:`Vue`,extensions:[`vue`],load(){return Q(()=>import(`./dist-BVTS1puf.js`).then(e=>e.vue()),__vite__mapDeps([27,4,1,2,6,7]))}}),O.of({name:`Angular Template`,load(){return Q(()=>import(`./dist-BOz4jprC.js`).then(e=>e.angular()),__vite__mapDeps([28,4,1,2,6,7]))}})];function Ik(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
207
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Qy(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Yb.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function ax(){return{exit:{taskListCheckValueChecked:sx,taskListCheckValueUnchecked:sx,paragraph:cx}}}function ox(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:lx}}}function sx(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function cx(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function lx(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Yb.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function ux(){return[gy(),By(),Gy(),Xb(),ax()]}function dx(e){return{extensions:[_y(),Vy(e),Ky(),ix(e),ox()]}}var fx={tokenize:Ex,partial:!0},px={tokenize:Dx,partial:!0},mx={tokenize:Ox,partial:!0},hx={tokenize:kx,partial:!0},gx={tokenize:Ax,partial:!0},_x={name:`wwwAutolink`,tokenize:wx,previous:jx},vx={name:`protocolAutolink`,tokenize:Tx,previous:Mx},yx={name:`emailAutolink`,tokenize:Cx,previous:Nx},bx={};function xx(){return{text:bx}}for(var Sx=48;Sx<123;)bx[Sx]=yx,Sx++,Sx===58?Sx=65:Sx===91&&(Sx=97);bx[43]=yx,bx[45]=yx,bx[46]=yx,bx[95]=yx,bx[72]=[yx,vx],bx[104]=[yx,vx],bx[87]=[yx,_x],bx[119]=[yx,_x];function Cx(e,t,n){let r=this,i,a;return o;function o(t){return!Px(t)||!Nx.call(r,r.previous)||Fx(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Px(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(gx,u,l)(t):t===45||t===95||vm(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&_m(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function wx(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!jx.call(r,r.previous)||Fx(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(fx,e.attempt(px,e.attempt(mx,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Tx(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Mx.call(r,r.previous)&&!Fx(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(_m(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||bm(t)||wm(t)||Em(t)||Tm(t)?n(t):e.attempt(px,e.attempt(mx,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Ex(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Dx(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(hx,c,s)(t):t===null||wm(t)||Em(t)||t!==45&&Tm(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Ox(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(hx,t,a)(o):o===null||wm(o)||Em(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function kx(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||wm(o)||Em(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||wm(e)||Em(e)?t(e):r(e)}function a(e){return _m(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):_m(t)?(e.consume(t),o):n(t)}}function Ax(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return vm(e)?n(e):t(e)}}function jx(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||wm(e)}function Mx(e){return!_m(e)}function Nx(e){return!(e===47||Px(e))}function Px(e){return e===43||e===45||e===46||e===95||vm(e)}function Fx(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Ix={tokenize:Wx,partial:!0};function Lx(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Vx,continuation:{tokenize:Hx},exit:Ux}},text:{91:{name:`gfmFootnoteCall`,tokenize:Bx},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Rx,resolveTo:zx}}}}function Rx(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=gm(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function zx(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Bx(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||wm(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(gm(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return wm(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Vx(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||wm(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=gm(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return wm(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),km(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Hx(e,t,n){return e.check(Wm,t,e.attempt(Ix,t,n))}function Ux(e){e.exit(`gfmFootnoteDefinition`)}function Wx(e,t,n){let r=this;return km(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Gx(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&lm(o,o.length,0,Lm(s,e.slice(r+1,n),t)),lm(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),lm(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Im(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Im(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Kx=class{constructor(){this.map=[]}add(e,t,n){qx(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function qx(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Jx(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Yx(){return{flow:{null:{name:`table`,tokenize:Xx,resolveAll:Zx}}}}function Xx(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):X(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Z(t)?km(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||wm(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Z(t)?km(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Z(t)?km(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||X(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Z(t)?km(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||X(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||X(n)?(e.exit(`tableRow`),t(n)):Z(n)?km(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||wm(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Zx(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Kx;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&($x(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Qx(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Qx(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Qx(f,t,o,i,n,d)):(o[0]=o[1],d=Qx(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&$x(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Jx(t.events,n))}return e}function Qx(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},eS(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=eS(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=eS(t.events,n[2]),a=eS(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},eS(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function $x(e,t,n,r,i){let a=[],o=eS(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function eS(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var tS={name:`tasklistCheck`,tokenize:rS};function nS(){return{text:{91:tS}}}function rS(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return wm(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return X(r)?t(r):Z(r)?e.check({tokenize:iS},t,n)(r):n(r)}}function iS(e,t,n){return km(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function aS(e){return fm([xx(),Lx(),Gx(e),Yx(),nS()])}var oS={};function sS(e){let t=this,n=e||oS,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(aS(n)),a.push(ux()),o.push(dx(n))}function cS({alt:e=`Nomadex logo`,className:t}){return(0,L.jsx)(`img`,{alt:e,className:[`brand-mark`,t].filter(Boolean).join(` `),decoding:`async`,draggable:!1,src:`/favicon.svg`})}var lS=[`Opening workspace`,`Setting environment`,`Initializing modules`,`Starting services`],uS=1600,dS=380;function fS({messages:e=lS,metaText:t=`Connecting to workspace backend`,variant:n=`screen`,visibleRangeStart:r=0,visibleRangeEnd:i}){let a=e.length>0?e:lS,o=a.length-1,s=Math.max(0,Math.min(r,o)),c=Math.max(s,Math.min(i??o,o)),[l,u]=(0,I.useState)(s),[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(c-s<1)return;let e=window.setInterval(()=>{u(e=>{let t=e<s||e>c?s:e;return f(t),m(!1),t>=c?s:t+1})},uS);return()=>{window.clearInterval(e)}},[c,s]),(0,I.useEffect)(()=>{if(d===null)return;let e=window.requestAnimationFrame(()=>{m(!0)}),t=window.setTimeout(()=>{f(null),m(!1)},dS);return()=>{window.cancelAnimationFrame(e),window.clearTimeout(t)}},[l,d]);let h=l<s||l>c?s:l,g=d!==null&&d>=s&&d<=c?d:null,_=a[h]??a[s],v=g===null?null:a[g]??null;return(0,L.jsxs)(`div`,{"aria-live":`polite`,className:H(`connection-loading-screen`,n===`inline`&&`inline`),role:`status`,children:[(0,L.jsx)(cS,{alt:``,className:`connection-loading-mark`}),(0,L.jsxs)(`div`,{className:`connection-loading-row`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`connection-loading-spinner`}),(0,L.jsxs)(`div`,{className:`connection-loading-slot`,children:[v?(0,L.jsx)(`span`,{className:H(`connection-loading-message`,`leaving`,p&&`animate`),children:v}):null,(0,L.jsx)(`span`,{className:H(`connection-loading-message`,v?`entering`:`resting`,p&&`animate`),children:_})]}),(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:`connection-loading-dots`,children:[(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{})]})]}),(0,L.jsx)(`div`,{className:`connection-loading-meta`,children:t})]})}var pS={add:`new`,update:`mod`,delete:`del`},mS=e=>e.replace(/\\/g,`/`).split(`/`).filter(Boolean).at(-1)??e;function hS({entries:e,onOpenFile:t,title:n,variant:r=`turn`}){if(e.length===0)return null;let i=`${e.length}`;return(0,L.jsxs)(`div`,{className:H(`file-change-summary`,`file-change-summary-${r}`),children:[(0,L.jsxs)(`div`,{className:`file-change-summary-head`,children:[(0,L.jsx)(`div`,{className:`file-change-summary-title`,children:n}),(0,L.jsx)(`div`,{className:`file-change-summary-count`,children:i})]}),(0,L.jsx)(`div`,{className:`file-change-summary-list`,children:e.map(e=>{let n=mS(e.path);return(0,L.jsxs)(`button`,{className:H(`file-change-summary-item`,`file-change-kind-${e.kind}`),onClick:()=>t(e.path),title:e.path,type:`button`,children:[(0,L.jsx)(`span`,{className:`file-change-summary-kind`,children:pS[e.kind]}),(0,L.jsx)(`span`,{className:`file-change-summary-path`,children:n})]},`${e.itemId}:${e.path}`)})})]})}var gS=`Agent`;function _S({onFill:e,onSlash:t}){return(0,L.jsxs)(`div`,{className:`ww`,children:[(0,L.jsx)(cS,{className:`wico`}),(0,L.jsx)(`h1`,{children:`Nomadex`}),(0,L.jsx)(`p`,{children:`Agentic coding workspace for live threads, repo edits, command runs, and multi-provider orchestration.`}),(0,L.jsxs)(`div`,{className:`wbadges`,children:[(0,L.jsx)(`div`,{className:`wbadge`,children:`⚡ Live stream`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`🔍 Web search`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`⑂ Multi-agent`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`🔧 MCP tools`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`📋 Skills ($)`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`apply_patch`}),(0,L.jsx)(`div`,{className:`wbadge`,children:`/ 25 slash cmds`})]}),(0,L.jsxs)(`div`,{className:`wsug`,children:[(0,L.jsxs)(`button`,{className:`sug`,type:`button`,onClick:()=>e(`Refactor the auth middleware to use JWT properly with full TypeScript types`),children:[(0,L.jsx)(`div`,{className:`sug-i`,children:`⚡`}),(0,L.jsx)(`div`,{className:`sug-t`,children:`Refactor code`}),(0,L.jsx)(`div`,{className:`sug-d`,children:`apply_patch + diffs`})]}),(0,L.jsxs)(`button`,{className:`sug`,type:`button`,onClick:()=>t(`/review`),children:[(0,L.jsx)(`div`,{className:`sug-i`,children:`🔍`}),(0,L.jsx)(`div`,{className:`sug-t`,children:`/review`}),(0,L.jsx)(`div`,{className:`sug-d`,children:`Audit working tree`})]}),(0,L.jsxs)(`button`,{className:`sug`,type:`button`,onClick:()=>e(`Write Jest unit tests for the auth service with 80%+ coverage`),children:[(0,L.jsx)(`div`,{className:`sug-i`,children:`🧪`}),(0,L.jsx)(`div`,{className:`sug-t`,children:`Write tests`}),(0,L.jsx)(`div`,{className:`sug-d`,children:`Jest + coverage`})]}),(0,L.jsxs)(`button`,{className:`sug`,type:`button`,onClick:()=>t(`/init`),children:[(0,L.jsx)(`div`,{className:`sug-i`,children:`📋`}),(0,L.jsx)(`div`,{className:`sug-t`,children:`/init`}),(0,L.jsx)(`div`,{className:`sug-d`,children:`Generate AGENTS.md`})]})]}),(0,L.jsx)(`p`,{className:`welcome-foot`,children:`/slash cmds · $skills · @file or /mention · !shell · ⌘K palette · Ctrl+G editor`})]})}function vS({threadLabelText:e}){return(0,L.jsx)(fS,{messages:[`Opening conversation`,`Reattaching thread`,`Loading recent history`,`Syncing transcript`],metaText:`Restoring ${Hd(e,42)}`,variant:`inline`})}var yS=(0,I.memo)(function({activeThread:e,activeThreadLabel:t,activeTurns:n,existingThreadHistoryPending:r,streamVisible:i,onReview:a,onRollback:o,onFill:s,onSlash:c,onCopy:l,onFork:u,onPlan:d,onEdit:f,onContext:p,onOpenFile:m,providerId:h}){if(!e)return(0,L.jsx)(_S,{onFill:s,onSlash:c});if(r)return(0,L.jsx)(vS,{threadLabelText:t});if(n.length===0)return(0,L.jsx)(_S,{onFill:s,onSlash:c});let g=n[n.length-1]?.id??null,_=n.some(e=>e.status===`inProgress`);return(0,L.jsx)(L.Fragment,{children:n.map(t=>{let n=gf(t),r=_s(t),s=t.items.filter(e=>e.type===`userMessage`).map(e=>xS(fs(e,h).text)).filter(Boolean),c=(e.steers??[]).filter(e=>e.turnId===t.id).filter(e=>e.status===`pending`?!0:!s.includes(xS(e.prompt))),v=t.status===`inProgress`?[...t.items].reverse().find(e=>e.type===`agentMessage`)?.id??null:null;return(0,L.jsxs)(`div`,{className:`turn-block`,children:[t.items.map(n=>(0,L.jsx)(zS,{item:n,onContext:p,onCopy:l,onEdit:f,onFork:u,onOpenFile:m,onPlan:d,onRollback:o,providerId:h,onReview:a,rollbackDisabled:_,showRollback:n.type===`userMessage`,turnId:t.id,outputVisible:n.type===`commandExecution`?i[`${n.id}:aggregatedOutput`]:void 0,streaming:n.type===`agentMessage`&&n.id===v,textVisible:n.type===`agentMessage`?i[`${n.id}:text`]:void 0,plan:t.id===g?e.plan:null,turnStatus:t.status},n.id)),c.map(e=>(0,L.jsx)(SS,{entry:e,onOpenFile:m,providerId:h},e.id)),n?(0,L.jsx)(jS,{code:_f(t.error?.codexErrorInfo??null),onOpenFile:m,providerId:h,status:t.status,text:n}):null,t.status===`inProgress`?null:(0,L.jsx)(hS,{entries:r,onOpenFile:m,title:`Changed`,variant:`turn`})]},t.id)})})}),bS=new Intl.DateTimeFormat([],{hour:`numeric`,minute:`2-digit`}),xS=e=>e.replace(/\s+/gu,` `).trim(),SS=(0,I.memo)(function({entry:e,onOpenFile:t,providerId:n}){return(0,L.jsxs)(`div`,{className:H(`steer-card`,e.status===`pending`&&`pending`),children:[(0,L.jsxs)(`div`,{className:`steer-card-head`,children:[(0,L.jsx)(`span`,{className:`steer-card-label`,children:`Steer`}),(0,L.jsx)(`span`,{className:`steer-card-meta`,children:e.status===`pending`?`Applying`:bS.format(new Date(e.createdAt))})]}),(0,L.jsx)(`div`,{className:`steer-card-body`,children:(0,L.jsx)(MS,{onOpenFile:t,providerId:n,text:e.prompt})})]})}),CS=e=>{switch(e.status){case`inProgress`:return`Running`;case`completed`:return e.exitCode===0?`Completed`:`Exit ${e.exitCode??`?`}`;case`failed`:return`Failed`;case`declined`:return`Declined`;default:return e.status}},wS=e=>e.status===`inProgress`?`run`:e.status===`completed`&&e.exitCode===0?`ok`:`err`,TS=e=>e.replace(/\\/gu,`/`).split(`/`).filter(Boolean).pop()??e,ES=e=>{if(e==null)return null;if(e<1e3)return`${e}ms`;if(e<6e4){let t=e/1e3;return`${t>=10?t.toFixed(0):t.toFixed(1).replace(/\.0$/u,``)}s`}return`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`},DS=e=>{let t=e.replace(/\\/gu,`/`).trim();if(!t)return`(cwd)`;let n=t.split(`/`).filter(Boolean);return n.length===0?`/`:t.startsWith(`/home/`)&&n.length>=3?`~/${n.slice(2).join(`/`)}`:n.length>3?`.../${n.slice(-3).join(`/`)}`:t},OS=/^(?:\/usr\/bin\/env\s+)?((?:\/[^ "'`]+|[A-Za-z0-9_.-]+))(?:\s+(?:--?[A-Za-z0-9_-]+))*\s+(?:-lc|-c|\/c|-Command|-command)\s+(['"])([\s\S]*)\2$/u,kS=e=>{let t=e.commandActions.find(e=>e.command?.trim())?.command.trim()??e.command.trim(),n=t.match(OS),r=TS(n?.[1]??t).replace(/\.(?:bat|cmd|exe)$/iu,``)||`terminal`;return{commandText:n?.[3]?.trim()||t||`(command)`,cwdText:DS(e.cwd),durationText:ES(e.durationMs),processText:e.processId??`pty`,shellLabel:r}},AS=(e,t)=>`${e.trim().toLowerCase()}:${t.trim()}`,jS=(0,I.memo)(function({status:e,text:t,code:n,onOpenFile:r,providerId:i}){return(0,L.jsxs)(`div`,{className:`msg`,children:[(0,L.jsxs)(`div`,{className:`mh`,children:[(0,L.jsx)(`div`,{className:`mav a`,children:`⬡`}),(0,L.jsx)(`span`,{className:`mn`,children:gS}),(0,L.jsx)(`span`,{className:`mt`,children:e})]}),(0,L.jsx)(`div`,{className:`mb`,children:(0,L.jsxs)(`div`,{className:`turn-error-card`,children:[(0,L.jsx)(LS,{onOpenFile:r,providerId:i,text:t}),n?(0,L.jsx)(`div`,{className:`turn-error-code`,children:n}):null]})})]})}),MS=(0,I.memo)(function({text:e,onOpenFile:t,providerId:n}){return(0,L.jsx)(L.Fragment,{children:(0,I.useMemo)(()=>ps(e),[e]).map((e,r)=>e.kind===`text`?(0,L.jsx)(`span`,{children:e.value},`text-${r}`):e.kind===`code`?(0,L.jsx)(`code`,{className:`message-inline-code`,children:e.value},`code-${r}`):hs(e.path,n)===`#`?t?(0,L.jsx)(`button`,{className:`message-file-link file-link-button`,onClick:()=>t(e.path,e.line),title:e.path,type:`button`,children:e.displayPath},`file-${r}`):(0,L.jsx)(`code`,{className:`message-inline-code`,children:e.displayPath},`file-${r}`):(0,L.jsx)(`button`,{className:`message-file-link file-link-button`,onClick:()=>t(e.path,e.line),title:e.path,type:`button`,children:e.displayPath},`file-${r}`))})});function NS({url:e,alt:t,markdown:n,className:r}){let[i,a]=(0,I.useState)(!1);return i&&n?(0,L.jsx)(`p`,{className:`message-text`,children:n}):(0,L.jsx)(`a`,{className:`message-image-link`,href:e,rel:`noreferrer noopener`,target:`_blank`,children:(0,L.jsx)(`img`,{alt:t,className:H(`message-image-preview`,r),loading:`lazy`,onError:()=>a(!0),src:e})})}var PS=e=>{for(let t of I.Children.toArray(e)){if(!(0,I.isValidElement)(t))continue;let e=t.props.className;if(typeof e!=`string`)continue;let n=e.match(/language-([A-Za-z0-9_-]+)/u);if(n?.[1])return n[1]}return null},FS=e=>{let t=e;return(t.match(/```/gu)??[]).length%2==1&&(t=`${t}\n\`\`\``),(t.match(/~~~/gu)??[]).length%2==1&&(t=`${t}\n~~~`),t},IS=(0,I.memo)(function({text:e,onOpenFile:t,streaming:n=!1,showCursor:r=!1,providerId:i}){let a=(0,I.useDeferredValue)(e),o=n?a:e,s=(0,I.useMemo)(()=>n?FS(o):o,[o,n]),c=(0,I.useMemo)(()=>({a({href:e,children:n}){let r=typeof e==`string`?as(e,i):null;return r?(0,L.jsx)(`button`,{className:`message-file-link file-link-button message-markdown-link`,onClick:()=>t(r.path,r.line),title:r.path,type:`button`,children:n}):e?(0,L.jsx)(`a`,{className:`message-markdown-anchor`,href:e,rel:`noreferrer noopener`,target:`_blank`,children:n}):(0,L.jsx)(`span`,{className:`message-markdown-anchor`,children:n})},img({src:e,alt:t}){let n=typeof e==`string`?ms(e,i):``;return n?(0,L.jsx)(NS,{alt:t||`Embedded message image`,className:`message-markdown-image`,url:n}):t?(0,L.jsx)(`span`,{className:`message-inline-code`,children:t}):null},pre({children:e}){return(0,L.jsxs)(`div`,{className:`message-code-shell`,children:[(0,L.jsx)(`div`,{className:`message-code-head`,children:(0,L.jsx)(`span`,{children:PS(e)??`text`})}),(0,L.jsx)(`pre`,{className:`message-code-block`,children:e})]})},code({className:e,children:t}){return(0,L.jsx)(`code`,{className:H(`message-markdown-code`,e),children:t})}}),[t,i]);return(0,L.jsxs)(`div`,{className:H(`message-text-flow`,`message-markdown`,n&&`message-text-flow-streaming message-markdown-streaming`),children:[(0,L.jsx)(ry,{components:c,remarkPlugins:[sS],children:s}),r?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`live-cursor message-stream-cursor`}):null]})}),LS=(0,I.memo)(function({text:e,onOpenFile:t,textFx:n,streaming:r=!1,showCursor:i=!1,providerId:a}){let o=(0,I.useMemo)(()=>r?[]:gs(e,a),[a,r,e]).reduce((e,t)=>({entries:[...e.entries,{block:t,start:e.nextStart}],nextStart:e.nextStart+(t.kind===`image`?t.markdown.length:t.value.length)}),{entries:[],nextStart:0}).entries;if(r){let t=n??null,r=t?Math.max(0,Math.min(e.length,t.from)):0,a=t?Math.max(r,Math.min(e.length,t.to)):0;return(0,L.jsx)(`div`,{className:`message-text-flow message-text-flow-streaming`,children:(0,L.jsxs)(`p`,{className:`message-text message-text-streaming`,children:[e.slice(0,r),a>r?(0,L.jsx)(`span`,{className:`message-text-tail`,children:e.slice(r,a)}):null,e.slice(a),i?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`live-cursor live-cursor-inline`}):null]})})}return(0,L.jsx)(`div`,{className:`message-text-flow`,children:o.map(({block:e,start:r},i)=>{if(e.kind===`image`)return(0,L.jsx)(NS,{alt:e.alt||`Embedded message image`,className:`message-markdown-image`,markdown:e.markdown,url:e.url},`image-${i}`);if(!e.value)return null;let o=r+e.value.length,s=n??null,c=s?Math.max(0,s.from-r):0,l=s?Math.max(0,Math.min(e.value.length,s.to-r)):0,u=!1;if(s&&(u=s.to>s.from&&l>c&&o>s.from&&r<s.to),!u)return(0,L.jsx)(`p`,{className:`message-text`,children:(0,L.jsx)(MS,{onOpenFile:t,providerId:a,text:e.value})},`text-${i}`);let d=e.value.slice(0,c),f=e.value.slice(c,l),p=e.value.slice(l);return(0,L.jsxs)(`p`,{className:`message-text`,children:[d?(0,L.jsx)(MS,{onOpenFile:t,providerId:a,text:d}):null,f?(0,L.jsx)(`span`,{className:`message-text-tail`,children:(0,L.jsx)(MS,{onOpenFile:t,providerId:a,text:f})},`tail-${i}-${s?.to??e.value.length}`):null,p?(0,L.jsx)(MS,{onOpenFile:t,providerId:a,text:p}):null]},`text-${i}`)})})}),RS=(0,I.memo)(function({itemText:e,plan:t}){let n=t?.steps??[],r=t?.explanation?.trim()||e.trim();if(n.length===0)return(0,L.jsxs)(`div`,{className:`compact-bar`,children:[(0,L.jsx)(`span`,{className:`compact-ico`,children:`Plan`}),(0,L.jsx)(`span`,{className:`meta-glint`,children:r||e})]});let i=n.filter(e=>e.status===`completed`).length;return(0,L.jsxs)(`div`,{className:`turn-plan-card`,children:[(0,L.jsx)(`div`,{className:`turn-plan-card-head`,children:(0,L.jsxs)(`span`,{className:`turn-plan-card-progress`,children:[i,` of `,n.length,` tasks completed`]})}),r?(0,L.jsx)(`div`,{className:`turn-plan-card-summary`,children:r}):null,(0,L.jsx)(`ol`,{className:`turn-plan-card-list`,children:n.map((e,t)=>(0,L.jsxs)(`li`,{className:H(`turn-plan-card-step`,`is-${e.status}`),children:[(0,L.jsx)(`span`,{className:`turn-plan-card-step-marker`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{className:`turn-plan-card-step-index`,children:[t+1,`.`]}),(0,L.jsx)(`span`,{className:`turn-plan-card-step-text`,children:e.step})]},`${t}-${e.step}`))})]})}),zS=(0,I.memo)(function({item:e,plan:t,turnStatus:n,streaming:r=!1,textVisible:i,outputVisible:a,onCopy:o,onFork:s,onPlan:c,onRollback:l,onReview:u,onEdit:d,onContext:f,onOpenFile:p,providerId:m,turnId:h,showRollback:g=!1,rollbackDisabled:_=!1}){let[v,y]=(0,I.useState)(e.type===`commandExecution`?e.status===`inProgress`:!1),[b]=(0,I.useState)(()=>e.type===`userMessage`?new Intl.DateTimeFormat([],{hour:`numeric`,minute:`2-digit`}).format(new Date):``),x=(0,I.useRef)(e.type===`commandExecution`?e.status:null),S=e.type===`commandExecution`?e.status:null;if((0,I.useEffect)(()=>{if(e.type!==`commandExecution`||!S){x.current=null;return}let t=null,n=null;return S===`inProgress`?t=window.requestAnimationFrame(()=>{y(!0)}):x.current===`inProgress`&&(n=window.setTimeout(()=>y(!1),1e3)),x.current=S,()=>{t!==null&&window.cancelAnimationFrame(t),n!==null&&window.clearTimeout(n)}},[S,e.type]),e.type===`userMessage`){let t=fs(e,m),n=new Set(t.fileAttachments.map(e=>AS(e.label,e.path))),r=e.content.filter(e=>e.type===`skill`?!0:e.type===`mention`?!n.has(AS(e.name,e.path)):!1);return(0,L.jsxs)(`div`,{className:`msg user`,onContextMenu:t=>f(t,e),children:[(0,L.jsxs)(`div`,{className:`mb`,children:[t.images.length>0?(0,L.jsx)(`div`,{className:`message-image-list`,children:t.images.map((t,n)=>{let r=ms(t,m);return r?(0,L.jsx)(NS,{alt:`Message image preview`,url:r},`${e.id}-image-${n}`):null})}):null,t.fileAttachments.length>0||r.length>0?(0,L.jsxs)(`div`,{className:`attachment-row`,children:[t.fileAttachments.map(t=>{let n=mf(t.label,t.path);return(0,L.jsxs)(`button`,{className:H(`attachment-chip attachment-chip-file file-link-button`,`file-tone-${n.tone}`),onClick:()=>p(t.path),title:t.path,type:`button`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`file-chip-preview`,children:(0,L.jsx)(`span`,{className:`file-chip-ext`,children:n.badge})}),(0,L.jsxs)(`span`,{className:`file-chip-copy`,children:[(0,L.jsx)(`span`,{className:`file-chip-title`,children:n.title}),(0,L.jsx)(`span`,{className:`file-chip-meta`,children:n.kindLabel})]})]},`${e.id}-file-${t.path}`)}),r.map(t=>{if(t.type===`mention`){let n=mf(t.name,t.path);return(0,L.jsxs)(`button`,{className:H(`attachment-chip attachment-chip-file file-link-button`,`file-tone-${n.tone}`),onClick:()=>p(t.path),title:t.path,type:`button`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`file-chip-preview`,children:(0,L.jsx)(`span`,{className:`file-chip-ext`,children:n.badge})}),(0,L.jsxs)(`span`,{className:`file-chip-copy`,children:[(0,L.jsx)(`span`,{className:`file-chip-title`,children:n.title}),(0,L.jsx)(`span`,{className:`file-chip-meta`,children:n.kindLabel})]})]},`${e.id}-${t.type}-${t.name}`)}return(0,L.jsxs)(`span`,{className:`attachment-chip`,children:[(0,L.jsx)(`span`,{children:`📋`}),(0,L.jsx)(`span`,{children:t.name})]},`${e.id}-${t.type}-${t.name}`)})]}):null,t.text?(0,L.jsx)(LS,{onOpenFile:p,providerId:m,text:t.text}):null,(0,L.jsx)(`div`,{className:`msg-time`,children:b})]}),(0,L.jsxs)(`div`,{className:`macts`,children:[g?(0,L.jsx)(`button`,{className:`mact rollback`,disabled:_,title:_?`Wait for the current response to finish before rolling back.`:`Remove this prompt and everything after it.`,type:`button`,onClick:()=>l(h),children:`↶ Rollback`}):null,(0,L.jsx)(`button`,{className:`mact`,type:`button`,onClick:()=>o(t.text),children:`📋 Copy`}),(0,L.jsx)(`button`,{className:`mact`,type:`button`,onClick:()=>d(t.text),children:`✏ Edit`})]})]})}if(e.type===`agentMessage`){let t=typeof i==`number`?e.text.slice(0,i):e.text;return(0,L.jsxs)(`div`,{className:H(`msg assistant`,r&&`streaming`),onContextMenu:t=>f(t,e),children:[(0,L.jsxs)(`div`,{className:`mh`,children:[(0,L.jsx)(`div`,{className:`mav a`,children:`⬡`}),(0,L.jsx)(`span`,{className:`mn`,children:gS}),(0,L.jsx)(`span`,{className:`mt`,children:n===`inProgress`?`live`:n})]}),(0,L.jsx)(`div`,{className:`mb`,children:t?r?(0,L.jsx)(IS,{onOpenFile:p,providerId:m,showCursor:r,streaming:r,text:t}):(0,L.jsx)(IS,{onOpenFile:p,providerId:m,text:t}):null}),(0,L.jsxs)(`div`,{className:`macts`,children:[(0,L.jsx)(`button`,{className:`mact`,type:`button`,onClick:()=>s(),children:`⑂ /fork`}),(0,L.jsx)(`button`,{className:`mact`,type:`button`,onClick:()=>c(),children:`📋 /plan`}),(0,L.jsx)(`button`,{className:`mact`,type:`button`,onClick:()=>o(e.text),children:`📋`})]})]})}if(e.type===`reasoning`)return null;if(e.type===`plan`)return(0,L.jsx)(RS,{itemText:e.text,plan:t});if(e.type===`commandExecution`){let t=typeof a==`number`&&e.aggregatedOutput?e.aggregatedOutput.slice(0,a):e.aggregatedOutput??``,n=wS(e),r=kS(e);return(0,L.jsxs)(`div`,{className:H(`cmd-inline`,n,v&&`open`),children:[(0,L.jsxs)(`button`,{className:H(`cmd-inline-row`,n,v&&`open`),type:`button`,onClick:()=>y(e=>!e),children:[(0,L.jsxs)(`div`,{className:`cmd-inline-window-bar`,children:[(0,L.jsxs)(`div`,{className:`cmd-inline-traffic`,"aria-hidden":`true`,children:[(0,L.jsx)(`span`,{className:`cmd-inline-dot close`}),(0,L.jsx)(`span`,{className:`cmd-inline-dot minimize`}),(0,L.jsx)(`span`,{className:`cmd-inline-dot zoom`})]}),(0,L.jsx)(`span`,{className:`cmd-inline-shell meta-glint`,children:r.shellLabel}),(0,L.jsx)(`span`,{className:H(`cmd-inline-status-chip`,`meta-glint`,n),children:CS(e)})]}),(0,L.jsxs)(`div`,{className:`cmd-inline-main`,children:[(0,L.jsx)(`span`,{className:H(`cmd-inline-chevron`,v&&`open`),children:`▶`}),(0,L.jsxs)(`div`,{className:`cmd-inline-copy`,children:[(0,L.jsx)(`code`,{className:`cmd-inline-label`,children:r.commandText}),(0,L.jsxs)(`div`,{className:`cmd-inline-meta-line`,children:[(0,L.jsx)(`span`,{className:`cmd-inline-meta-pill`,children:r.cwdText}),(0,L.jsx)(`span`,{className:`cmd-inline-meta-pill`,children:r.processText}),r.durationText?(0,L.jsx)(`span`,{className:`cmd-inline-meta-pill`,children:r.durationText}):null]})]})]})]}),v?(0,L.jsxs)(`div`,{className:`cmd-inline-output`,children:[(0,L.jsxs)(`div`,{className:`cmd-inline-output-head`,children:[(0,L.jsx)(`span`,{children:`Output`}),(0,L.jsx)(`span`,{children:e.cwd})]}),(0,L.jsx)(`pre`,{children:t||`(no output)`})]}):null]})}if(e.type===`fileChange`)return(0,L.jsx)(BS,{item:e,onReview:u});if(e.type===`mcpToolCall`){let t=e.result?JSON.stringify(e.result.structuredContent??e.result.content??{},null,2):e.error?.message??`No output`;return(0,L.jsxs)(`div`,{className:H(`tool`,e.error?`err`:`ok`),children:[(0,L.jsxs)(`div`,{className:`tool-h`,children:[(0,L.jsxs)(`span`,{className:`meta-glint`,children:[e.error?`✗`:`✓`,` MCP · `,e.server,`/`,e.tool]}),(0,L.jsx)(`span`,{className:`tbadge meta-glint`,children:e.status})]}),(0,L.jsx)(`div`,{className:`tool-b`,children:(0,L.jsx)(`pre`,{className:`tool-pre`,children:t})})]})}return e.type===`dynamicToolCall`?(0,L.jsxs)(`div`,{className:H(`tool`,e.success?`ok`:`run`),children:[(0,L.jsxs)(`div`,{className:`tool-h`,children:[(0,L.jsxs)(`span`,{className:`meta-glint`,children:[e.success?`✓`:`↻`,` Tool · `,e.tool]}),(0,L.jsx)(`span`,{className:`tbadge meta-glint`,children:e.status})]}),(0,L.jsx)(`div`,{className:`tool-b`,children:e.contentItems?.map((t,n)=>(0,L.jsx)(`div`,{children:JSON.stringify(t)},`${e.id}-${n}`))??`No tool payload.`})]}):e.type===`collabAgentToolCall`?(0,L.jsxs)(`div`,{className:`agc`,children:[(0,L.jsxs)(`div`,{className:`agh`,children:[(0,L.jsx)(`div`,{className:`agdot`}),(0,L.jsxs)(`span`,{className:`agn meta-glint`,children:[`⑂ `,e.tool]}),(0,L.jsx)(`span`,{className:`ags meta-glint`,children:e.status})]}),(0,L.jsx)(`div`,{className:`agt`,children:e.prompt??`Subagent activity`}),(0,L.jsx)(`div`,{className:`agprog`,children:(0,L.jsx)(`div`,{className:`agbar`,style:{width:e.status===`completed`?`100%`:`58%`}})})]}):e.type===`webSearch`?(0,L.jsxs)(`div`,{className:`tool ok`,children:[(0,L.jsxs)(`div`,{className:`tool-h`,children:[(0,L.jsx)(`span`,{className:`meta-glint`,children:`✓ Web search`}),(0,L.jsx)(`span`,{className:`tbadge meta-glint`,children:`search`})]}),(0,L.jsx)(`div`,{className:`tool-b`,children:e.query})]}):e.type===`imageView`?(0,L.jsxs)(`div`,{className:`image-card`,children:[(0,L.jsxs)(`div`,{className:`tool-h`,children:[(0,L.jsx)(`span`,{className:`meta-glint`,children:`🖼 Image`}),(0,L.jsx)(`span`,{className:`tbadge meta-glint`,children:`view`})]}),(0,L.jsx)(`div`,{className:`tool-b`,children:e.path})]}):e.type===`imageGeneration`?(0,L.jsxs)(`div`,{className:`tool ok`,children:[(0,L.jsxs)(`div`,{className:`tool-h`,children:[(0,L.jsx)(`span`,{className:`meta-glint`,children:`✓ Image generation`}),(0,L.jsx)(`span`,{className:`tbadge meta-glint`,children:e.status})]}),(0,L.jsxs)(`div`,{className:`tool-b`,children:[(0,L.jsx)(`div`,{children:e.revisedPrompt}),(0,L.jsx)(`div`,{children:e.result})]})]}):e.type===`enteredReviewMode`||e.type===`exitedReviewMode`?(0,L.jsxs)(`div`,{className:`compact-bar`,children:[(0,L.jsx)(`span`,{className:`compact-ico`,children:e.type===`enteredReviewMode`?`🔍`:`✓`}),(0,L.jsx)(`span`,{className:`meta-glint`,children:e.review})]}):e.type===`contextCompaction`?(0,L.jsxs)(`div`,{className:`compact-bar`,children:[(0,L.jsx)(`span`,{className:`compact-ico`,children:`🗜`}),(0,L.jsx)(`span`,{className:`meta-glint`,children:`Conversation compacted to free context tokens.`})]}):null});function BS({item:e,onReview:t}){let n=e.status===`inProgress`?`editing`:e.status===`completed`?`applied`:e.status===`failed`?`failed`:e.status;return(0,L.jsx)(L.Fragment,{children:(e.changes.length>0?e.changes:[{path:`Editing files`,kind:{type:`update`,move_path:null},diff:``}]).map((r,i)=>(0,L.jsxs)(`div`,{className:H(`dw`,e.status===`inProgress`&&`live`,r.kind.type===`add`&&`new-file`),"data-change-kind":r.kind.type,children:[(0,L.jsxs)(`div`,{className:`dh`,children:[(0,L.jsxs)(`span`,{className:`meta-glint`,children:[`📄 `,r.path]}),(0,L.jsxs)(`div`,{className:`diff-head-actions`,children:[(0,L.jsx)(`button`,{className:`diff-review`,type:`button`,onClick:()=>t(vf(e.id,i,r.path)),children:`Review diff`}),(0,L.jsxs)(`span`,{className:`dstats`,children:[r.kind.type===`add`?(0,L.jsx)(`span`,{className:`diff-new`,children:`new`}):null,r.kind.type===`update`?(0,L.jsx)(`span`,{className:`diff-mod`,children:`mod`}):null,r.kind.type===`delete`?(0,L.jsx)(`span`,{className:`diff-del`,children:`del`}):null,(0,L.jsx)(`span`,{className:H(`diff-status`,e.status===`inProgress`&&`live`,e.status===`failed`&&`err`),children:n})]})]})]}),r.diff?r.diff.split(`
|
|
208
|
+
`).map((e,t)=>(0,L.jsx)(`div`,{className:H(`dl`,e.startsWith(`+`)&&`add`,e.startsWith(`-`)&&`rem`,!e.startsWith(`+`)&&!e.startsWith(`-`)&&`ctx`),children:e},`${r.path}-${t}`)):(0,L.jsx)(`div`,{className:`dl ctx`,children:`Waiting for diff…`})]},`${e.id}-${r.path}-${i}`))})}var VS=(e,t)=>{switch(t){case`accept`:switch(e.kind){case`command`:return`Run command`;case`patch`:return`Apply changes`;case`permissions`:return`Grant access`;default:return`Approve`}case`acceptForSession`:switch(e.kind){case`command`:return`Allow for session`;case`patch`:return`Allow writes for session`;case`permissions`:return`Grant for session`;default:return`Allow for session`}case`cancel`:return`Cancel`;default:return`Decline`}},HS=e=>{switch(e){case`accept`:case`acceptForSession`:return`approve`;case`cancel`:return`neutral`;default:return`danger`}};function US({approval:e,mcpContentText:t,onMcpContentChange:n,onResolve:r,onSubmitMcp:i}){let a=e.availableDecisions&&e.availableDecisions.length>0?e.availableDecisions:[`accept`,`decline`],o=e.state===`pending`;return(0,L.jsxs)(`div`,{className:`approval-request-card`,children:[(0,L.jsxs)(`div`,{className:`approval-request-head`,children:[(0,L.jsxs)(`div`,{className:`approval-request-copy`,children:[(0,L.jsx)(`strong`,{children:e.title}),(0,L.jsx)(`span`,{children:e.detail})]}),(0,L.jsxs)(`div`,{className:`approval-request-badges`,children:[(0,L.jsx)(`span`,{className:H(`approval-request-risk`,e.risk),children:e.risk}),(0,L.jsx)(`span`,{className:`approval-request-state`,children:e.state})]})]}),e.kind===`question`?null:(0,L.jsxs)(`div`,{className:`approval-request-body`,children:[e.command?(0,L.jsxs)(`div`,{className:`approval-request-block`,children:[(0,L.jsx)(`div`,{className:`approval-request-label`,children:`Command`}),(0,L.jsx)(`code`,{className:`approval-request-command`,children:e.command})]}):null,e.cwd?(0,L.jsxs)(`div`,{className:`approval-request-meta`,children:[(0,L.jsx)(`span`,{className:`approval-request-label`,children:`Working directory`}),(0,L.jsx)(`span`,{className:`approval-request-value`,children:e.cwd})]}):null,e.files&&e.files.length>0?(0,L.jsxs)(`div`,{className:`approval-request-block`,children:[(0,L.jsx)(`div`,{className:`approval-request-label`,children:e.kind===`patch`?`Paths`:`Files`}),(0,L.jsx)(`div`,{className:`approval-request-list`,children:e.files.map(e=>(0,L.jsx)(`span`,{className:`approval-request-item`,children:e},e))})]}):null,e.permissionsSummary&&e.permissionsSummary.length>0?(0,L.jsxs)(`div`,{className:`approval-request-block`,children:[(0,L.jsx)(`div`,{className:`approval-request-label`,children:`Requested access`}),(0,L.jsx)(`div`,{className:`approval-request-list`,children:e.permissionsSummary.map(e=>(0,L.jsx)(`span`,{className:`approval-request-item`,children:e},e))})]}):null,e.kind===`mcp`?(0,L.jsxs)(L.Fragment,{children:[e.serverName?(0,L.jsxs)(`div`,{className:`approval-request-meta`,children:[(0,L.jsx)(`span`,{className:`approval-request-label`,children:`Server`}),(0,L.jsx)(`span`,{className:`approval-request-value`,children:e.serverName})]}):null,e.form?(0,L.jsxs)(`div`,{className:`approval-request-block`,children:[(0,L.jsx)(`div`,{className:`approval-request-label`,children:`Prompt details`}),(0,L.jsx)(`pre`,{className:`approval-request-pre`,children:e.form})]}):null,(0,L.jsxs)(`div`,{className:`approval-request-block`,children:[(0,L.jsx)(`label`,{className:`approval-request-label`,htmlFor:`approval-mcp-${e.id}`,children:`Response`}),(0,L.jsx)(`textarea`,{className:`approval-request-textarea`,id:`approval-mcp-${e.id}`,onChange:e=>n(e.target.value),placeholder:`Provide the response to send back to the MCP server.`,rows:5,value:t})]})]}):null]}),(0,L.jsx)(`div`,{className:`approval-request-actions`,children:e.kind===`mcp`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:`approval-request-button approve`,disabled:!o,onClick:()=>i(`accept`,t),type:`button`,children:`Send response`}),(0,L.jsx)(`button`,{className:`approval-request-button danger`,disabled:!o,onClick:()=>i(`decline`,t),type:`button`,children:`Decline`}),(0,L.jsx)(`button`,{className:`approval-request-button neutral`,disabled:!o,onClick:()=>i(`cancel`,t),type:`button`,children:`Cancel`})]}):a.map(t=>(0,L.jsx)(`button`,{className:H(`approval-request-button`,HS(t)),disabled:!o,onClick:()=>r(t),type:`button`,children:VS(e,t)},`${e.id}:${t}`))})]})}var WS=(0,I.memo)(function({branchLabel:e,dirty:t,hasStagedChanges:n,message:r,preferencesPath:i,providers:a,selectedProviderId:o,summary:s,generating:c,committing:l,onCommit:u,onGenerate:d,onMessageChange:f,onProviderChange:p}){let m=a.find(e=>e.id===o)??a[0]??null,h=c||l;return(0,L.jsxs)(`section`,{className:`commit-composer-card`,children:[(0,L.jsxs)(`div`,{className:`commit-composer-head`,children:[(0,L.jsxs)(`div`,{className:`commit-composer-copy`,children:[(0,L.jsx)(`div`,{className:`commit-composer-title`,children:`Commit changes`}),(0,L.jsxs)(`div`,{className:`commit-composer-meta`,children:[(0,L.jsx)(`span`,{children:e}),(0,L.jsx)(`span`,{children:s||(t?`Working tree ready`:`Working tree clean`)})]})]}),(0,L.jsx)(`button`,{className:`commit-generate-button`,disabled:!t||h,onClick:d,type:`button`,children:c?`Generating…`:`Generate`})]}),(0,L.jsxs)(`div`,{className:`commit-composer-toolbar`,children:[(0,L.jsxs)(`label`,{className:`commit-provider-field`,children:[(0,L.jsx)(`span`,{children:`Provider`}),(0,L.jsx)(`select`,{className:`commit-provider-select`,disabled:h,onChange:e=>p(e.target.value),value:o,children:a.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.displayName},e.id))})]}),(0,L.jsxs)(`div`,{className:`commit-provider-note`,children:[(0,L.jsx)(`strong`,{children:m?.displayName??`Provider`}),(0,L.jsx)(`span`,{children:i?`Saved per project in .nomadex/project.json`:`Using the current workspace provider`})]})]}),(0,L.jsx)(`textarea`,{className:`commit-message-input`,disabled:l,onChange:e=>f(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),!l&&r.trim()&&u())},placeholder:`feat(scope): short summary`,rows:4,value:r}),(0,L.jsxs)(`div`,{className:`commit-composer-footer`,children:[(0,L.jsx)(`div`,{className:`commit-composer-hint`,children:n?`Commits the staged files.`:t?`Stages all current files first, then commits.`:`No pending files to commit.`}),(0,L.jsx)(`button`,{className:`commit-submit-button`,disabled:!t||!r.trim()||h,onClick:u,type:`button`,children:l?`Committing…`:`Commit`})]})]})}),GS=[`var(--ac)`,`var(--ac2)`,`var(--ac3)`,`var(--gn)`,`var(--og)`],KS=e=>e.kind===`head`||e.active?`current`:e.kind===`remote`?`remote`:e.kind===`tag`?`tag`:`local`,qS=(e,t,n)=>{let r=e.padEnd(t,` `);return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`git-activity-graph-text`,children:Array.from(r).map((e,t)=>{if(e===` `)return(0,L.jsx)(`span`,{className:`git-activity-graph-char`,children:` `},`blank:${t}`);let r=n[t%n.length]??`var(--ac)`;return(0,L.jsx)(`span`,{className:H(`git-activity-graph-char`,`on`,e===`*`&&`node`),style:{"--graph-accent":r},children:e},`${e}:${t}`)})})},JS=(0,I.memo)(function({model:e,onOpenThread:t}){let n=e.lanes.length>0?e.lanes.map(e=>e.accent):GS;return(0,L.jsxs)(`section`,{className:`git-activity-card`,children:[(0,L.jsxs)(`div`,{className:`git-activity-toolbar`,children:[(0,L.jsxs)(`div`,{className:`git-activity-copy`,children:[(0,L.jsx)(`div`,{className:`git-activity-title`,children:`Git Graph`}),(0,L.jsx)(`div`,{className:`git-activity-meta`,children:e.repoLabel})]}),(0,L.jsxs)(`div`,{className:`git-activity-summary`,children:[(0,L.jsx)(`span`,{className:`git-activity-summary-label`,children:e.branchLabel}),e.commitLabel?(0,L.jsx)(`code`,{className:`git-activity-summary-code`,children:e.commitLabel}):null]})]}),e.lanes.length>0?(0,L.jsx)(`div`,{className:`git-activity-legend`,role:`list`,"aria-label":`Branch legend`,children:e.lanes.map(e=>(0,L.jsxs)(`div`,{className:H(`git-activity-legend-item`,e.emphasis),role:`listitem`,style:{"--lane-accent":e.accent},children:[(0,L.jsx)(`span`,{className:`git-activity-legend-swatch`}),(0,L.jsx)(`span`,{className:`git-activity-legend-label`,children:e.label})]},e.id))}):null,e.workingTree?(0,L.jsxs)(`div`,{className:`git-working-tree-card`,children:[(0,L.jsxs)(`div`,{className:`git-working-tree-toolbar`,children:[(0,L.jsx)(`div`,{className:`git-working-tree-title`,children:`Working tree`}),(0,L.jsx)(`div`,{className:H(`git-working-tree-summary`,e.workingTree.dirty&&`dirty`),children:e.workingTree.summary})]}),e.workingTree.buckets.length>0?(0,L.jsx)(`div`,{className:`git-working-tree-grid`,children:e.workingTree.buckets.map(e=>(0,L.jsxs)(`div`,{className:`git-working-tree-group`,children:[(0,L.jsxs)(`div`,{className:`git-working-tree-group-head`,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`span`,{children:e.entries.length})]}),(0,L.jsxs)(`div`,{className:`git-working-tree-list`,children:[e.entries.slice(0,6).map(e=>(0,L.jsxs)(`div`,{className:`git-working-tree-item`,children:[(0,L.jsx)(`span`,{className:H(`git-working-tree-badge`,e.kind),children:e.badge}),(0,L.jsx)(`span`,{className:`git-working-tree-path`,title:e.originalPath?`${e.originalPath} -> ${e.path}`:e.path,children:e.path})]},e.id)),e.entries.length>6?(0,L.jsxs)(`div`,{className:`git-working-tree-more`,children:[`+`,e.entries.length-6,` more`]}):null]})]},e.id))}):(0,L.jsx)(`div`,{className:`git-working-tree-clean`,children:`No uncommitted files in this repo.`})]}):null,(0,L.jsxs)(`div`,{className:`git-activity-table`,children:[(0,L.jsxs)(`div`,{className:`git-activity-table-head`,children:[(0,L.jsx)(`div`,{className:`git-activity-graph-head`,style:{width:`${Math.max(e.graphWidth,4)+1}ch`}}),(0,L.jsx)(`div`,{className:`git-activity-head-message`,children:`Message`}),(0,L.jsx)(`div`,{className:`git-activity-head-date`,children:`Date`}),(0,L.jsx)(`div`,{className:`git-activity-head-author`,children:`Author`}),(0,L.jsx)(`div`,{className:`git-activity-head-sha`,children:`Commit`})]}),(0,L.jsx)(`div`,{className:`git-activity-table-body`,children:e.rows.map(r=>{let i=!!(r.threadId&&t),a=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`git-activity-graph-cell`,style:{width:`${Math.max(e.graphWidth,4)+1}ch`},children:qS(r.graph,Math.max(e.graphWidth,4),n)}),(0,L.jsxs)(`div`,{className:`git-activity-message-cell`,title:r.hint??r.subject,children:[r.refs.length>0?(0,L.jsx)(`div`,{className:`git-activity-ref-row`,children:r.refs.slice(0,3).map(e=>(0,L.jsx)(`span`,{className:H(`git-activity-ref`,KS(e)),children:e.label},e.id))}):null,(0,L.jsx)(`div`,{className:`git-activity-message-text`,children:r.subject})]}),(0,L.jsx)(`div`,{className:`git-activity-cell git-activity-date-cell`,children:r.dateLabel}),(0,L.jsx)(`div`,{className:`git-activity-cell git-activity-author-cell`,children:r.author}),(0,L.jsx)(`code`,{className:`git-activity-cell git-activity-sha-cell`,children:r.sha})]});return i&&r.threadId&&t?(0,L.jsx)(`button`,{className:H(`git-activity-table-row`,r.emphasis,`interactive`),onClick:()=>t(r.threadId),type:`button`,children:a},r.id):(0,L.jsx)(`div`,{className:H(`git-activity-table-row`,r.emphasis),children:a},r.id)})})]})]})});function YS({approval:e,answers:t,onAnswerChange:n,onSubmit:r}){let i=e.questions??[],a=i.length>0&&i.every(e=>(t[e.id]??``).trim().length>0);return(0,L.jsxs)(`div`,{className:`question-request-card`,children:[(0,L.jsxs)(`div`,{className:`question-request-head`,children:[(0,L.jsxs)(`div`,{className:`question-request-copy`,children:[(0,L.jsx)(`strong`,{children:e.title}),(0,L.jsx)(`span`,{children:e.detail})]}),(0,L.jsx)(`span`,{className:`question-request-state`,children:e.state})]}),(0,L.jsx)(`div`,{className:`question-request-body`,children:i.map((e,r)=>{let i=t[e.id]??``,a=e.isOther||(e.options?.length??0)===0;return(0,L.jsxs)(`div`,{className:`question-request-item`,children:[(0,L.jsxs)(`div`,{className:`question-request-item-head`,children:[(0,L.jsxs)(`span`,{className:`question-request-index`,children:[r+1,`.`]}),(0,L.jsxs)(`div`,{className:`question-request-item-copy`,children:[(0,L.jsx)(`span`,{className:`question-request-header`,children:e.header}),(0,L.jsx)(`div`,{className:`question-request-text`,children:e.question})]})]}),e.options&&e.options.length>0?(0,L.jsx)(`div`,{className:`question-request-options`,children:e.options.map(t=>(0,L.jsxs)(`button`,{className:H(`question-request-option`,i===t.label&&`active`),onClick:()=>n(e.id,t.label),type:`button`,children:[(0,L.jsx)(`span`,{className:`question-request-option-label`,children:t.label}),t.description?(0,L.jsx)(`span`,{className:`question-request-option-description`,children:t.description}):null]},`${e.id}:${t.label}`))}):null,a?(0,L.jsx)(`input`,{className:`question-request-input`,onChange:t=>n(e.id,t.target.value),placeholder:e.isSecret?`Enter value`:`Type your answer`,type:e.isSecret?`password`:`text`,value:i}):null]},e.id)})}),(0,L.jsx)(`div`,{className:`question-request-actions`,children:(0,L.jsx)(`button`,{className:`question-request-submit`,disabled:!a||e.state!==`pending`,onClick:r,type:`button`,children:`Submit answers`})})]})}var XS=e=>{if(!e)return`Reset time unavailable`;let t=new Date(e*1e3),n=Date.now();return t.getTime()-n<=1e3*60*60*24?`Resets ${t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`Resets ${t.toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}`},ZS=(e,t)=>t?[e.name,e.description,e.scope??``,e.repo??``,e.downloads??``,...e.tags??[]].join(` `).toLowerCase().includes(t):!0,QS=(0,I.memo)(function({snapshot:e,actions:t,onClose:n,pushToast:r}){let[i,a]=(0,I.useState)(``),o=i.trim().toLowerCase(),s=(0,I.useMemo)(()=>e.installedSkills.filter(e=>e.enabled).length,[e.installedSkills]),c=(0,I.useMemo)(()=>e.installedSkills.filter(e=>ZS(e,o)),[o,e.installedSkills]),l=(0,I.useMemo)(()=>e.remoteSkills.filter(e=>ZS(e,o)),[o,e.remoteSkills]);return(0,I.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n]),(0,L.jsx)(`div`,{className:`skills-library-overlay`,onClick:e=>{e.target===e.currentTarget&&n()},children:(0,L.jsxs)(`div`,{className:`skills-library-modal`,children:[(0,L.jsxs)(`div`,{className:`skills-library-hero`,children:[(0,L.jsxs)(`div`,{className:`skills-library-copy`,children:[(0,L.jsx)(`div`,{className:`skills-library-kicker`,children:`Nomadex Skill Library`}),(0,L.jsx)(`div`,{className:`skills-library-title`,children:`Manage installed and remote skills in one place`}),(0,L.jsx)(`div`,{className:`skills-library-subtitle`,children:`Toggle what stays active globally, browse marketplace packs, and keep the composer focused on actual prompts instead of setup.`})]}),(0,L.jsx)(`button`,{"aria-label":`Close skill library`,className:`skills-library-close`,onClick:n,type:`button`,children:`×`})]}),(0,L.jsxs)(`div`,{className:`skills-library-toolbar`,children:[(0,L.jsxs)(`div`,{className:`skills-library-stats`,children:[(0,L.jsxs)(`div`,{className:`skills-library-stat`,children:[(0,L.jsx)(`strong`,{children:e.installedSkills.length}),(0,L.jsx)(`span`,{children:`Installed`})]}),(0,L.jsxs)(`div`,{className:`skills-library-stat`,children:[(0,L.jsx)(`strong`,{children:s}),(0,L.jsx)(`span`,{children:`Enabled`})]}),(0,L.jsxs)(`div`,{className:`skills-library-stat`,children:[(0,L.jsx)(`strong`,{children:e.remoteSkills.length}),(0,L.jsx)(`span`,{children:`Marketplace`})]})]}),(0,L.jsx)(`input`,{autoFocus:!0,className:`skills-library-search`,onChange:e=>a(e.target.value),placeholder:`Search skills, tags, repo, or description…`,value:i})]}),(0,L.jsxs)(`div`,{className:`skills-library-grid`,children:[(0,L.jsxs)(`section`,{className:`skills-library-pane`,children:[(0,L.jsxs)(`div`,{className:`skills-library-pane-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`skills-library-pane-title`,children:`Installed`}),(0,L.jsx)(`div`,{className:`skills-library-pane-copy`,children:`Toggle globally available skills and inspect their local path.`})]}),(0,L.jsx)(`span`,{className:`skills-library-pane-count`,children:c.length})]}),(0,L.jsx)(`div`,{className:`skills-library-list`,children:c.length===0?(0,L.jsx)(`div`,{className:`skills-library-empty`,children:`No installed skills matched this search.`}):c.map(e=>(0,L.jsxs)(`article`,{className:H(`skills-library-card installed`,e.enabled&&`enabled`),children:[(0,L.jsxs)(`div`,{className:`skills-library-card-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`skills-library-card-title`,children:e.name}),(0,L.jsxs)(`div`,{className:`skills-library-card-meta`,children:[(0,L.jsx)(`span`,{className:`skills-library-chip`,children:e.scope}),(0,L.jsx)(`span`,{className:H(`skills-library-chip`,e.enabled&&`live`),children:e.enabled?`Enabled`:`Disabled`})]})]}),(0,L.jsx)(`button`,{className:H(`skills-library-action`,e.enabled&&`active`),onClick:()=>void t.toggleInstalledSkill(e.id),type:`button`,children:e.enabled?`Disable`:`Enable`})]}),(0,L.jsx)(`div`,{className:`skills-library-card-description`,children:e.description}),e.tags.length>0?(0,L.jsx)(`div`,{className:`skills-library-tag-row`,children:e.tags.map(e=>(0,L.jsx)(`span`,{className:`skills-library-tag`,children:e},e))}):null,(0,L.jsx)(`code`,{className:`skills-library-path`,children:e.path})]},e.id))})]}),(0,L.jsxs)(`section`,{className:`skills-library-pane marketplace`,children:[(0,L.jsxs)(`div`,{className:`skills-library-pane-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`skills-library-pane-title`,children:`Marketplace`}),(0,L.jsx)(`div`,{className:`skills-library-pane-copy`,children:`Install remote skills into your local workspace catalog.`})]}),(0,L.jsx)(`span`,{className:`skills-library-pane-count`,children:l.length})]}),(0,L.jsx)(`div`,{className:`skills-library-list`,children:l.length===0?(0,L.jsx)(`div`,{className:`skills-library-empty`,children:`No marketplace skills matched this search.`}):l.map(e=>(0,L.jsxs)(`article`,{className:`skills-library-card remote`,children:[(0,L.jsxs)(`div`,{className:`skills-library-card-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`skills-library-card-title`,children:e.name}),(0,L.jsxs)(`div`,{className:`skills-library-card-meta`,children:[(0,L.jsxs)(`span`,{className:`skills-library-chip`,children:[e.downloads,` downloads`]}),(0,L.jsx)(`span`,{className:`skills-library-chip`,children:e.repo})]})]}),(0,L.jsx)(`button`,{className:`skills-library-action install`,onClick:()=>{t.installSkill(e.id),r(`Installing ${e.name}`,`ok`)},type:`button`,children:`Install`})]}),(0,L.jsx)(`div`,{className:`skills-library-card-description`,children:e.description}),e.tags.length>0?(0,L.jsx)(`div`,{className:`skills-library-tag-row`,children:e.tags.map(e=>(0,L.jsx)(`span`,{className:`skills-library-tag`,children:e},e))}):null]},e.id))})]})]})]})})}),$S=(0,I.memo)(function({activeTheme:e,onClose:t,onSelect:n,themes:r}){return(0,L.jsx)(`div`,{className:`theme-picker-overlay`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{id:`tpicker`,children:[(0,L.jsxs)(`div`,{className:`tpicker-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`tpicker-title`,children:`Theme`}),(0,L.jsx)(`div`,{className:`tpicker-subtitle`,children:`Shell palettes for Nomadex.`})]}),(0,L.jsx)(`button`,{className:`tpicker-close`,onClick:t,type:`button`,"aria-label":`Close theme picker`,children:`×`})]}),(0,L.jsx)(`div`,{className:`tpicker-grid`,children:r.map(t=>(0,L.jsxs)(`button`,{className:H(`theme-card`,e===t.id&&`active`),onClick:()=>n(t.id),type:`button`,children:[(0,L.jsxs)(`div`,{className:`theme-card-preview`,children:[(0,L.jsx)(`span`,{className:`theme-card-surface`,style:{background:t.swatches[0]}}),(0,L.jsx)(`span`,{className:`theme-card-accent`,style:{background:t.swatches[1]}}),(0,L.jsx)(`span`,{className:`theme-card-accent`,style:{background:t.swatches[2]}})]}),(0,L.jsxs)(`div`,{className:`theme-card-copy`,children:[(0,L.jsxs)(`div`,{className:`theme-card-name`,children:[t.name,(0,L.jsx)(`span`,{className:`theme-card-mode`,children:t.mode})]}),(0,L.jsx)(`div`,{className:`theme-card-description`,children:t.description})]})]},t.id))})]})})}),eC=(0,I.memo)(function({snapshot:e,activeThreadLabel:t,actions:n,pushToast:r,selectModel:i,activeTheme:a,onOpenSkills:o,onOpenTheme:s}){let[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)({key:``,value:``}),f=a.charAt(0).toUpperCase()+a.slice(1),p=e.providers.find(t=>t.id===e.settings.provider)??e.providers[0],m=p?Zo(p.id,e.models):e.models,h=p?.transportKind===`cli`,g=p?e.providerSetup[p.id]:null,_=p?e.providerAuth[p.id]:null,v=_?.status===`starting`||_?.status===`waiting`||_?.status===`checking`,y=h?p?.id===`opencode`&&_?.status===`waiting`?`Paste the OpenCode Zen API key below`:_?.status===`waiting`?`Finish sign-in below`:g?.status===`ready`?`Local CLI session ready`:`Sign in or configure this local CLI`:`${e.account.planType} · ${e.account.authMode}`,b=h?v?_?.status===`checking`?`Checking`:`Signing in…`:g?.status===`ready`?`Ready`:`External`:e.account.loginInProgress?`Signing in…`:e.account.loggedIn?`Active`:`Signed out`,x=p?.id===`opencode`?`Use OpenCode Zen`:p?.id===`qwen-code`?`Use Qwen Code`:`Use ${p?.displayName??`provider`}`,S=h&&(g?.authenticated===!0||g?.status===`ready`||_?.status===`completed`),C=g?g.status===`ready`?`Ready`:g.status===`checking`?`Checking`:g.status===`needsInstall`?`Install`:g.status===`needsAuth`?`Sign in`:g.status===`needsConfig`?`Config`:g.status===`error`?`Error`:`Unknown`:`Unknown`,w=h&&_!==null&&_.status!==`idle`&&_.status!==`completed`,T=p?.id===`opencode`&&_?.status===`waiting`,E=`${p?.id??`none`}:${_?.status??`idle`}`,D=u.key===E?u.value:``,O=_?.authUrl??null,ee=_?.userCode??null;(0,I.useEffect)(()=>{!h||!p||!g||g.status!==`unknown`||n.checkProviderSetup(p.id)},[n,p,g,h]);let te=(0,I.useCallback)(async()=>{try{let t=await n.startChatGptLogin();t&&window.open(t,`_blank`,`noopener,noreferrer`),r(e.account.loggedIn?`Opened ChatGPT account switch`:`Opened ChatGPT sign-in`,`ok`),r(`If mobile redirects to localhost:1455, paste that callback URL below.`,``)}catch(e){r(e instanceof Error?e.message:`Failed to start ChatGPT login`,`err`)}},[n,r,e.account.loggedIn]),ne=(0,I.useCallback)(async()=>{if(!c.trim()){r(`Paste the full callback URL first`,`warn`);return}try{await n.completeChatGptLogin(c.trim()),l(``),r(`Mobile sign-in completed`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to complete mobile sign-in`,`err`)}},[n,c,r]),re=(0,I.useCallback)(async()=>{let t=window.prompt(e.account.authMode===`apiKey`?`Enter the replacement API key`:`Enter your OpenAI API key`,``);if(t?.trim())try{await n.loginWithApiKey(t.trim()),r(`API key account connected`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to connect API key`,`err`)}},[n,r,e.account.authMode]),k=(0,I.useCallback)(async()=>{try{await n.logoutAccount(),r(`Signed out of account`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to sign out`,`err`)}},[n,r]),A=(0,I.useCallback)(async()=>{try{await n.refreshAccount(),r(`Account status refreshed`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to refresh account`,`err`)}},[n,r]),ie=(0,I.useCallback)(async()=>{if(!(!p||!h))try{await n.startProviderAuth(p.id,p.id===`opencode`?`apiKey`:`oauth`),r(`${p.displayName} sign-in started`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to start provider sign-in`,`err`)}},[n,p,h,r]),ae=(0,I.useCallback)(async()=>{if(!(!p||!h))try{await n.switchProviderAccount(p.id,p.id===`opencode`?`apiKey`:`oauth`),r(`${p.displayName} is ready for a new sign-in`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to switch provider account`,`err`)}},[n,p,h,r]),oe=(0,I.useCallback)(async()=>{if(!(!p||!h))try{await n.cancelProviderAuth(p.id),r(`${p.displayName} sign-in cancelled`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to cancel provider sign-in`,`err`)}},[n,p,h,r]),se=(0,I.useCallback)(()=>{O&&window.open(O,`_blank`,`noopener,noreferrer`)},[O]),ce=(0,I.useCallback)(async()=>{if(ee)try{await navigator.clipboard.writeText(ee),r(`Copied sign-in code`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to copy sign-in code`,`err`)}},[ee,r]),j=(0,I.useCallback)(async()=>{if(!(!p||!T)){if(!D.trim()){r(`Paste the API key first`,`warn`);return}try{await n.submitProviderAuthSecret(p.id,D.trim()),d({key:E,value:``}),r(`API key submitted to OpenCode`,`ok`)}catch(e){r(e instanceof Error?e.message:`Failed to submit the provider secret`,`err`)}}},[n,p,E,D,r,T]);return(0,L.jsxs)(`div`,{className:`config-stack`,children:[(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`Account`}),(0,L.jsxs)(`div`,{className:`account-card`,children:[(0,L.jsxs)(`div`,{className:`account-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`strong`,{children:h?`${p.displayName} local session`:e.account.loggedIn?e.account.workspace:`No active account`}),(0,L.jsx)(`div`,{className:`account-copy`,children:y})]}),(0,L.jsx)(`span`,{className:H(`account-badge`,h&&(v||g?.status===`ready`)||e.account.loggedIn?`ok`:`off`),children:b})]}),(0,L.jsxs)(`div`,{className:`account-meta`,children:[h?(0,L.jsx)(`span`,{children:p.transportLabel}):(0,L.jsx)(`span`,{children:e.account.credits}),!h&&e.account.requiresOpenaiAuth?(0,L.jsx)(`span`,{children:`OpenAI auth required`}):null]}),h?(0,L.jsxs)(L.Fragment,{children:[g?(0,L.jsxs)(`div`,{className:`usage-limit-list`,children:[(0,L.jsxs)(`div`,{className:`usage-limit-card provider-detail-card`,children:[(0,L.jsxs)(`div`,{className:`usage-limit-head`,children:[(0,L.jsx)(`strong`,{children:`Session`}),(0,L.jsx)(`span`,{children:C})]}),(0,L.jsx)(`div`,{className:`provider-detail-copy`,children:g.summary}),g.detail?(0,L.jsx)(`div`,{className:`usage-limit-copy`,children:g.detail}):null]}),(0,L.jsxs)(`div`,{className:`usage-limit-card provider-detail-card`,children:[(0,L.jsxs)(`div`,{className:`usage-limit-head`,children:[(0,L.jsx)(`strong`,{children:`Transport`}),(0,L.jsx)(`span`,{children:p.transportLabel})]}),(0,L.jsx)(`div`,{className:`provider-detail-copy`,children:g.sourcePath??`Local CLI session on this host.`}),(0,L.jsx)(`div`,{className:`usage-limit-copy`,children:g.checkedAt?`Checked ${g.checkedAt}`:`Not checked yet.`})]}),(0,L.jsxs)(`div`,{className:`usage-limit-card provider-detail-card`,children:[(0,L.jsxs)(`div`,{className:`usage-limit-head`,children:[(0,L.jsx)(`strong`,{children:`CLI`}),(0,L.jsx)(`span`,{children:g.version?`Detected`:`Unknown`})]}),(0,L.jsx)(`div`,{className:`provider-detail-copy`,children:g.version?`Version ${g.version}`:`Version unavailable`}),(0,L.jsx)(`div`,{className:`usage-limit-copy`,children:S?`Ready for new turns.`:`Sign in or configure the provider to use it in Nomadex.`})]})]}):null,w?(0,L.jsxs)(`div`,{className:`account-helper`,children:[(0,L.jsxs)(`div`,{className:`account-helper-copy`,children:[_?.summary,_?.detail?` ${_.detail}`:``]}),_?.userCode||_?.authUrl?(0,L.jsxs)(`div`,{className:`account-callback-form`,children:[_.userCode?(0,L.jsxs)(`div`,{className:`provider-auth-value`,children:[(0,L.jsx)(`span`,{children:`Code`}),(0,L.jsx)(`code`,{children:_.userCode})]}):null,_.authUrl?(0,L.jsxs)(`div`,{className:`provider-auth-value`,children:[(0,L.jsx)(`span`,{children:`URL`}),(0,L.jsx)(`code`,{children:_.authUrl})]}):null]}):null,T?(0,L.jsx)(`div`,{className:`account-callback-form`,children:(0,L.jsx)(`input`,{className:`account-callback-input`,type:`password`,value:D,onChange:e=>d({key:E,value:e.target.value}),placeholder:`Paste OpenCode Zen API key`,autoComplete:`off`,spellCheck:!1})}):null,(0,L.jsxs)(`div`,{className:`provider-auth-actions`,children:[_?.authUrl?(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:se,children:`Open auth page`}):null,_?.userCode?(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void ce(),children:`Copy code`}):null,T?(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,disabled:!D.trim(),onClick:()=>void j(),children:`Submit key`}):null,v?(0,L.jsx)(`button`,{className:`mini-action danger`,type:`button`,onClick:()=>void oe(),children:`Cancel`}):null]})]}):(0,L.jsx)(`div`,{className:`usage-limit-empty`,children:p.id===`opencode`?(0,L.jsxs)(L.Fragment,{children:[`OpenCode Zen uses an API key from`,` `,(0,L.jsx)(`code`,{children:`opencode.ai/auth`}),`. Start the sign-in below, open the auth page, then paste the Zen API key back into Nomadex.`]}):p.id===`qwen-code`?(0,L.jsxs)(L.Fragment,{children:[`Use the provider action below to connect`,` `,p.displayName,`. Nomadex will verify the local session automatically after the provider flow completes.`]}):p.installCommand?(0,L.jsxs)(L.Fragment,{children:[`Install with `,(0,L.jsx)(`code`,{children:p.installCommand}),`, then sign in or configure that CLI on the host machine. Nomadex will use the existing local session for new turns.`]}):(0,L.jsxs)(L.Fragment,{children:[`Sign in or configure `,p.displayName,` on the host machine first. Nomadex will use the existing local CLI session.`]})})]}):(0,L.jsxs)(`div`,{className:`usage-limit-list`,children:[e.account.usageWindows.map(e=>(0,L.jsxs)(`div`,{className:`usage-limit-card`,children:[(0,L.jsxs)(`div`,{className:`usage-limit-head`,children:[(0,L.jsx)(`strong`,{children:e.label}),(0,L.jsxs)(`span`,{children:[Math.round(e.usedPercent),`% used`]})]}),(0,L.jsx)(`div`,{className:`usage-limit-bar`,children:(0,L.jsx)(`span`,{className:`usage-limit-fill`,style:{width:`${Math.max(0,Math.min(100,e.usedPercent))}%`}})}),(0,L.jsx)(`div`,{className:`usage-limit-copy`,children:XS(e.resetsAt)})]},e.id)),e.account.usageWindows.length===0?(0,L.jsx)(`div`,{className:`usage-limit-empty`,children:`Sign in to view your account usage windows.`}):null]}),(0,L.jsx)(`div`,{className:`account-actions`,children:h?(0,L.jsxs)(L.Fragment,{children:[p.id===`opencode`||p.id===`qwen-code`?(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,disabled:v,onClick:()=>void(S?ae():ie()),children:v?`Starting…`:S?`Switch account`:x}):null,(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,disabled:g?.status===`checking`,onClick:()=>void n.checkProviderSetup(p.id),children:g?.status===`checking`?`Checking…`:`Check setup`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void A(),children:`Refresh`}),(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void te(),children:e.account.authMode===`chatgpt`?`Switch ChatGPT`:`Use ChatGPT`}),(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void re(),children:e.account.authMode===`apiKey`?`Replace API key`:`Use API key`}),e.account.loggedIn?(0,L.jsx)(`button`,{className:`mini-action danger`,type:`button`,onClick:()=>void k(),children:`Log out`}):null]})}),!h&&e.account.loginInProgress?(0,L.jsxs)(`div`,{className:`account-helper`,children:[(0,L.jsxs)(`div`,{className:`account-helper-copy`,children:[`On mobile, if ChatGPT returns to `,(0,L.jsx)(`code`,{children:`localhost:1455`}),`, copy that full URL and paste it here. You can also replace the failed callback host with`,` `,(0,L.jsx)(`code`,{children:typeof window<`u`?window.location.origin:``}),` `,`and keep the same path/query.`]}),(0,L.jsxs)(`div`,{className:`account-callback-form`,children:[(0,L.jsx)(`input`,{className:`account-callback-input`,placeholder:`http://localhost:1455/auth/callback?code=…&state=…`,value:c,onChange:e=>l(e.target.value)}),(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void ne(),children:`Finish mobile login`})]})]}):null,!h&&e.account.loginError?(0,L.jsx)(`div`,{className:`account-error`,children:e.account.loginError}):null]})]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`Model`}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`provider`}),(0,L.jsx)(`select`,{className:`ssel`,value:e.settings.provider,onChange:t=>{let r=e.providers.find(e=>e.id===t.target.value);n.updateSettings({provider:t.target.value,model:r?.defaultModel??e.settings.model})},children:e.providers.map(e=>(0,L.jsxs)(`option`,{disabled:e.availability!==`ready`,value:e.id,children:[e.displayName,e.availability===`ready`?``:` (scaffolded)`]},e.id))})]}),(0,L.jsxs)(`div`,{className:`config-provider-note`,children:[(0,L.jsx)(`strong`,{children:p?.displayName??`Provider`}),(0,L.jsx)(`span`,{children:p?.availability===`ready`?p.installCommand?`${p.transportLabel} · ${p.installCommand}`:p.transportLabel:`Scaffolded on this branch. Transport wiring comes next.`})]}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`model`}),m.length===0?(0,L.jsx)(`span`,{className:`sl`,children:`provider default`}):(0,L.jsx)(`select`,{className:`ssel`,value:e.settings.model,onChange:e=>void i(e.target.value),children:m.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.displayName},e.id))})]}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`reasoning_effort`}),(0,L.jsxs)(`select`,{className:`ssel`,value:e.settings.reasoningEffort,onChange:e=>void n.updateSettings({reasoningEffort:e.target.value}),children:[(0,L.jsx)(`option`,{value:`low`,children:`low`}),(0,L.jsx)(`option`,{value:`medium`,children:`medium`}),(0,L.jsx)(`option`,{value:`high`,children:`high`}),(0,L.jsx)(`option`,{value:`xhigh`,children:`xhigh`})]})]})]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`Approval & Sandbox`}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`approval_policy`}),(0,L.jsxs)(`select`,{className:`ssel`,value:Pd(e.settings),onChange:e=>void n.updateSettings(Fd(e.target.value)),children:[(0,L.jsx)(`option`,{value:`auto`,children:`auto`}),(0,L.jsx)(`option`,{value:`ro`,children:`read-only`}),(0,L.jsx)(`option`,{value:`fa`,children:`full-access`})]})]}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`sandbox`}),(0,L.jsxs)(`select`,{className:`ssel`,value:e.settings.sandboxMode,onChange:e=>void n.updateSettings({sandboxMode:e.target.value}),children:[(0,L.jsx)(`option`,{value:`workspace-write`,children:`workspace-write`}),(0,L.jsx)(`option`,{value:`read-only`,children:`read-only`}),(0,L.jsx)(`option`,{value:`danger-full-access`,children:`danger-full-access`})]})]}),(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsx)(`span`,{className:`sl`,children:`web_search`}),(0,L.jsx)(`div`,{className:H(`tog`,e.settings.webSearch&&`on`),onClick:()=>void n.updateSettings({webSearch:!e.settings.webSearch}),role:`button`,tabIndex:0,onKeyDown:()=>void 0})]})]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`Appearance`}),(0,L.jsxs)(`div`,{className:`config-shortcut-card appearance-shortcut-card`,children:[(0,L.jsxs)(`div`,{className:`config-shortcut-copy`,children:[(0,L.jsxs)(`strong`,{children:[f,` theme active`]}),(0,L.jsx)(`span`,{children:`Ambient background, shell surfaces, and persistent palette selection.`})]}),(0,L.jsx)(`button`,{className:`mini-action`,onClick:s,type:`button`,children:`Open Theme Picker`})]})]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`Skills`}),(0,L.jsxs)(`div`,{className:`config-shortcut-card skill-shortcut-card`,children:[(0,L.jsxs)(`div`,{className:`config-shortcut-copy`,children:[(0,L.jsx)(`strong`,{children:`Skills moved into a dedicated library`}),(0,L.jsxs)(`span`,{children:[e.installedSkills.length,` installed ·`,` `,e.installedSkills.filter(e=>e.enabled).length,` `,`enabled · `,e.remoteSkills.length,` available to install`]})]}),(0,L.jsx)(`button`,{className:`mini-action`,onClick:o,type:`button`,children:`Open Skills Library`})]})]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsx)(`div`,{className:`sg-t`,children:`MCP`}),e.mcpServers.map(e=>(0,L.jsxs)(`div`,{className:`mcp-card`,children:[(0,L.jsxs)(`div`,{className:`mcp-head`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`span`,{children:e.authStatus})]}),(0,L.jsx)(`div`,{className:`mcp-tools`,children:Object.keys(e.tools).slice(0,4).join(` · `)}),(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void n.toggleMcpAuth(e.name),children:e.authStatus===`notLoggedIn`?`Connect`:`Refresh`})]},e.name))]}),(0,L.jsxs)(`div`,{className:`sg`,children:[(0,L.jsxs)(`div`,{className:`sg-t`,children:[`Feature Flags`,` `,(0,L.jsx)(`button`,{className:`feature-refresh`,type:`button`,onClick:()=>r(`Feature flags refreshed`,`ok`),children:`⟳`})]}),e.featureFlags.map(e=>(0,L.jsxs)(`div`,{className:`sr`,children:[(0,L.jsxs)(`span`,{className:`sl`,children:[e.name,` `,(0,L.jsxs)(`small`,{children:[`(`,e.stage,`)`]})]}),(0,L.jsx)(`div`,{className:H(`tog`,e.enabled&&`on`),onClick:()=>void n.toggleFeatureFlag(e.name),role:`button`,tabIndex:0,onKeyDown:()=>void 0})]},e.name))]}),(0,L.jsxs)(`div`,{className:`config-preview`,children:[(0,L.jsx)(`div`,{className:`config-title`,children:`Session config snapshot`}),(0,L.jsx)(`div`,{children:`# Nomadex workspace config`}),(0,L.jsxs)(`div`,{children:[`provider = "`,e.settings.provider,`"`]}),(0,L.jsxs)(`div`,{children:[`model = "`,e.settings.model,`"`]}),(0,L.jsxs)(`div`,{children:[`approval_policy = "`,e.settings.approvalPolicy,`"`]}),(0,L.jsxs)(`div`,{children:[`model_reasoning_effort = "`,e.settings.reasoningEffort,`"`]}),(0,L.jsxs)(`div`,{children:[`web_search = "`,e.settings.webSearch?`live`:`disabled`,`"`]}),(0,L.jsx)(`br`,{}),(0,L.jsx)(`div`,{children:`[features]`}),e.featureFlags.slice(0,4).map(e=>(0,L.jsxs)(`div`,{children:[e.name,` = `,e.enabled?`true`:`false`]},e.name)),(0,L.jsx)(`br`,{}),(0,L.jsx)(`div`,{children:`# active thread`}),(0,L.jsxs)(`div`,{children:[`thread = "`,t,`"`]})]})]})}),tC=1200,nC=e=>e.find(e=>e.status===`running`)?.id??e[0]?.id??null;function rC({cwd:e,terminals:t,onStartShell:n,onSendInput:r,onTerminate:i}){let[a,o]=(0,I.useState)(()=>nC(t)),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(null),p=(0,I.useRef)(null),m=(0,I.useRef)(null),h=(0,I.useRef)(a),g=(0,I.useRef)(!0);(0,I.useEffect)(()=>{let e=t.some(e=>e.id===a)?a:nC(t);e!==a&&o(e)},[a,t]);let _=(0,I.useMemo)(()=>t.find(e=>e.id===a)??t.find(e=>e.status===`running`)??t[0]??null,[a,t]),v=(0,I.useMemo)(()=>_?_.log.slice(-tC):[],[_]),y=_?Math.max(0,_.log.length-v.length):0,b=Math.max(t.length-1,0),x=!!(_?.writable&&_.status===`running`),S=(0,I.useCallback)(()=>{let e=m.current;if(!e)return;e.focus();let t=e.value.length;try{e.setSelectionRange(t,t)}catch{}},[]);(0,I.useEffect)(()=>{let e=p.current,t=_?.id??null;if(!e){h.current=t;return}let n=h.current!==t;if(h.current=t,!n&&!g.current)return;let r=window.requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});return()=>{window.cancelAnimationFrame(r)}},[_?.id,v.length]),(0,I.useEffect)(()=>{if(!x)return;let e=window.requestAnimationFrame(()=>{S()});return()=>{window.cancelAnimationFrame(e)}},[_?.id,x,S]);let C=()=>{let e=p.current;e&&(g.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},w=async()=>{u(null),f(`start`);try{o(await n()),c(``)}catch(e){u(e instanceof Error?e.message:`Unable to start the project shell.`)}finally{f(null)}},T=async()=>{if(!_||!x||!s.trim())return;let e=s;u(null),f(`send`);try{c(``),await r(_.id,`${e}\n`)}catch(t){c(e),u(t instanceof Error?t.message:`Unable to send terminal input.`)}finally{f(null),typeof window<`u`&&window.requestAnimationFrame(()=>{S()})}},E=async()=>{if(!(!_||!x)){u(null),f(`send`);try{await r(_.id,``)}catch(e){u(e instanceof Error?e.message:`Unable to send interrupt.`)}finally{f(null),typeof window<`u`&&window.requestAnimationFrame(()=>{S()})}}},D=async()=>{if(!(!_||_.status!==`running`)){u(null),f(`stop`);try{await i(_.id)}catch(e){u(e instanceof Error?e.message:`Unable to stop the terminal.`)}finally{f(null)}}};return(0,L.jsxs)(`div`,{className:`terminal-panel`,children:[(0,L.jsxs)(`div`,{className:`terminal-plain-bar`,children:[(0,L.jsxs)(`div`,{className:`terminal-plain-meta`,children:[(0,L.jsx)(`span`,{className:`terminal-plain-title`,children:`Terminal`}),_?(0,L.jsx)(`span`,{className:H(`status-chip`,`terminal-status-chip`,_.status),children:_.status}):null,b>0?(0,L.jsxs)(`span`,{className:`terminal-plain-count`,children:[t.length,` shells`]}):null]}),(0,L.jsxs)(`div`,{className:`terminal-toolbar-actions`,children:[(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void w(),children:d===`start`?`Starting…`:`New shell`}),_?(0,L.jsx)(`button`,{className:`mini-action`,disabled:!x||d===`send`,onClick:()=>void E(),type:`button`,children:`Ctrl+C`}):null,_?(0,L.jsx)(`button`,{className:`mini-action danger`,disabled:_.status!==`running`||d===`stop`,onClick:()=>void D(),type:`button`,children:d===`stop`?`Stopping…`:`Stop`}):null]})]}),(0,L.jsx)(`div`,{className:`terminal-project-path`,children:e}),l?(0,L.jsx)(`div`,{className:`terminal-inline-error`,children:l}):null,t.length===0?(0,L.jsxs)(`div`,{className:`terminal-empty-state`,children:[(0,L.jsx)(`div`,{className:`empty-panel`,children:`No project shell yet.`}),(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>void w(),children:`Open project shell`})]}):null,t.length>0&&_?(0,L.jsxs)(L.Fragment,{children:[y>0?(0,L.jsxs)(`div`,{className:`terminal-log-cap`,children:[`Showing the latest `,v.length,` lines of `,_.log.length]}):null,(0,L.jsxs)(`div`,{className:H(`term`,`terminal-log-plain`,x&&`terminal-log-plain-interactive`),onClick:()=>{x&&S()},onScroll:C,ref:p,children:[v.map((e,t)=>(0,L.jsx)(`div`,{className:H(`terminal-log-row`,t===0&&`t-p`),children:e||` `},`${_.id}:log:${y+t}`)),x?(0,L.jsxs)(`form`,{className:`terminal-log-prompt t-p`,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),T()},children:[(0,L.jsx)(`span`,{className:`terminal-inline-editor-shell`,children:`$`}),(0,L.jsx)(`input`,{"aria-label":`Terminal input`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,className:`terminal-inline-editor`,enterKeyHint:`send`,onChange:e=>c(e.target.value),onKeyDown:e=>{e.stopPropagation(),(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`c`&&s.length===0&&(e.preventDefault(),E())},ref:m,spellCheck:!1,type:`text`,value:s}),(0,L.jsx)(`button`,{"aria-hidden":`true`,className:`terminal-submit-proxy`,tabIndex:-1,type:`submit`})]}):null]})]}):null]})}function iC(){return iC=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},iC.apply(null,arguments)}function aC(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var oC=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=dC(e.state,n.from);return r.line?cC(e):r.block?uC(e):!1};function sC(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var cC=sC(gC,0),lC=sC(hC,0),uC=sC((e,t)=>hC(e,t,mC(t)),0);function dC(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var fC=50;function pC(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-fC,r),o=e.sliceDoc(i,i+fC),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*fC?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+fC),d=e.sliceDoc(i-fC,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function mC(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function hC(e,t,n=t.selection.ranges){let r=n.map(e=>dC(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>pC(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function gC(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=dC(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var _C=pe.define(),vC=pe.define(),yC=te.define(),bC=te.define({combine(e){return f(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),xC=i.define({create(){return BC.empty},update(e,t){let n=t.state.facet(bC),r=t.annotation(_C);if(r){let i=OC.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?kC(o,o.length,n.minDepth,i):FC(o,t.startState.selection),new BC(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(vC);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(ue.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=OC.fromTransaction(t),o=t.annotation(ue.time),s=t.annotation(ue.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new BC(e.done.map(OC.fromJSON),e.undone.map(OC.fromJSON))}});function SC(e={}){return[xC,bC.of(e),u.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?wC:e.inputType==`historyRedo`?TC:null;return n?(e.preventDefault(),n(t)):!1}})]}function CC(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(xC,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var wC=CC(0,!1),TC=CC(1,!1),EC=CC(0,!0),DC=CC(1,!0),OC=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&se.fromJSON(t.changes),[],t.mapped&&ce.fromJSON(t.mapped),t.startSelection&&P.fromJSON(t.startSelection),t.selectionsAfter.map(P.fromJSON))}static fromTransaction(t,n){let r=NC;for(let e of t.startState.facet(yC)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,NC)}static selection(t){return new e(void 0,NC,void 0,void 0,t)}};function kC(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function AC(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function jC(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function MC(e,t){return e.length?t.length?e.concat(t):e:t}var NC=[],PC=200;function FC(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-PC));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),kC(e,e.length-1,1e9,n.setSelAfter(r)))}else return[OC.selection([t])]}function IC(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function LC(e,t){if(!e.length)return e;let n=e.length,r=NC;for(;n;){let i=RC(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[OC.selection(r)]:NC}function RC(e,t,n){let r=MC(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):NC,n);if(!e.changes)return OC.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(a):a;return new OC(i,o.mapEffects(e.effects,t),s,e.startSelection.map(a),r)}var zC=/^(input\.type|delete)($|\.)/,BC=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let s=this.done,c=s[s.length-1];return s=c&&c.changes&&!c.changes.empty&&t.changes&&(!r||zC.test(r))&&(!c.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,AC(c.changes,t.changes))||r==`input.type.compose`)?kC(s,s.length-1,i.minDepth,new OC(t.changes.compose(c.changes),MC(o.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,NC)):kC(s,s.length,i.minDepth,t),new e(s,NC,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:NC;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&jC(a[a.length-1],t)?this:new e(FC(this.done,t),this.undone,n,r)}addMapping(t){return new e(LC(this.done,t),LC(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:_C.of({side:e,rest:IC(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?NC:r.slice(0,r.length-1);return i.mapped&&(n=LC(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:_C.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};BC.empty=new BC(NC,NC);var VC=[{key:`Mod-z`,run:wC,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:TC,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:TC,preventDefault:!0},{key:`Mod-u`,run:EC,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:DC,preventDefault:!0}];function HC(e,t){return P.create(e.ranges.map(t),e.mainIndex)}function UC(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function WC({state:e,dispatch:t},n){let r=HC(e.selection,n);return r.eq(e.selection,!0)?!1:(t(UC(e,r)),!0)}function GC(e,t){return P.cursor(t?e.to:e.from)}function KC(e,t){return WC(e,n=>n.empty?e.moveByChar(n,t):GC(n,t))}function qC(e){return e.textDirectionAt(e.state.selection.main.head)==c.LTR}var JC=e=>KC(e,!qC(e)),YC=e=>KC(e,qC(e));function XC(e,t){return WC(e,n=>n.empty?e.moveByGroup(n,t):GC(n,t))}var ZC=e=>XC(e,!qC(e)),QC=e=>XC(e,qC(e));typeof Intl<`u`&&Intl.Segmenter;function $C(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function ew(e,t,n){let r=M(e).resolveInner(t.head),i=n?d.closedBy:d.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;$C(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?m(e,r.from,1):m(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,P.cursor(s,n?-1:1)}var tw=e=>WC(e,t=>ew(e.state,t,!qC(e))),nw=e=>WC(e,t=>ew(e.state,t,qC(e)));function rw(e,t){return WC(e,n=>{if(!n.empty)return GC(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var iw=e=>rw(e,!1),aw=e=>rw(e,!0);function ow(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(u.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function sw(e,t){let n=ow(e),{state:r}=e,i=HC(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):GC(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=u.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(UC(r,i),{effects:a}),!0}var cw=e=>sw(e,!1),lw=e=>sw(e,!0);function uw(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=P.cursor(r.from+n))}return i}var dw=e=>WC(e,t=>uw(e,t,!0)),fw=e=>WC(e,t=>uw(e,t,!1)),pw=e=>WC(e,t=>uw(e,t,!qC(e))),mw=e=>WC(e,t=>uw(e,t,qC(e))),hw=e=>WC(e,t=>P.cursor(e.lineBlockAt(t.head).from,1)),gw=e=>WC(e,t=>P.cursor(e.lineBlockAt(t.head).to,-1));function _w(e,t,n){let r=!1,i=HC(e.selection,t=>{let i=m(e,t.head,-1)||m(e,t.head,1)||t.head>0&&m(e,t.head-1,1)||t.head<e.doc.length&&m(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?P.range(t.anchor,a):P.cursor(a)});return r?(t(UC(e,i)),!0):!1}var vw=({state:e,dispatch:t})=>_w(e,t,!1);function yw(e,t){let n=HC(e.state.selection,e=>{let n=t(e);return P.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(UC(e.state,n)),!0)}function bw(e,t){return yw(e,n=>e.moveByChar(n,t))}var xw=e=>bw(e,!qC(e)),Sw=e=>bw(e,qC(e));function Cw(e,t){return yw(e,n=>e.moveByGroup(n,t))}var ww=e=>Cw(e,!qC(e)),Tw=e=>Cw(e,qC(e)),Ew=e=>yw(e,t=>ew(e.state,t,!qC(e))),Dw=e=>yw(e,t=>ew(e.state,t,qC(e)));function Ow(e,t){return yw(e,n=>e.moveVertically(n,t))}var kw=e=>Ow(e,!1),Aw=e=>Ow(e,!0);function jw(e,t){return yw(e,n=>e.moveVertically(n,t,ow(e).height))}var Mw=e=>jw(e,!1),Nw=e=>jw(e,!0),Pw=e=>yw(e,t=>uw(e,t,!0)),Fw=e=>yw(e,t=>uw(e,t,!1)),Iw=e=>yw(e,t=>uw(e,t,!qC(e))),Lw=e=>yw(e,t=>uw(e,t,qC(e))),Rw=e=>yw(e,t=>P.cursor(e.lineBlockAt(t.head).from)),zw=e=>yw(e,t=>P.cursor(e.lineBlockAt(t.head).to)),Bw=({state:e,dispatch:t})=>(t(UC(e,{anchor:0})),!0),Vw=({state:e,dispatch:t})=>(t(UC(e,{anchor:e.doc.length})),!0),Hw=({state:e,dispatch:t})=>(t(UC(e,{anchor:e.selection.main.anchor,head:0})),!0),Uw=({state:e,dispatch:t})=>(t(UC(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Ww=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Gw=({state:e,dispatch:t})=>{let n=uT(e).map(({from:t,to:n})=>P.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:P.create(n),userEvent:`select`})),!0},Kw=({state:e,dispatch:t})=>{let n=HC(e.selection,t=>{let n=M(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return P.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(UC(e,n)),!0)};function qw(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(UC(n,P.create(i,i.length-1))),!0)}var Jw=e=>qw(e,!1),Yw=e=>qw(e,!0),Xw=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=P.create([n.main]):n.main.empty||(r=P.create([P.cursor(n.main.head)])),r?(t(UC(e,r)),!0):!1};function Zw(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Qw(e,o,!1)):o>i&&(n=`delete.forward`,o=Qw(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Qw(e,i,!1),a=Qw(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:P.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?u.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Qw(e,t,n){if(e instanceof u)for(let r of e.state.facet(u.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var $w=(e,t,n)=>Zw(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=p(s,a.tabSize)%De(a)||De(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=_(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=_(o.text,c-o.from,!1,!1)+o.from);return c}),eT=e=>$w(e,!1,!0),tT=e=>$w(e,!0,!1),nT=(e,t)=>Zw(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=_(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),rT=e=>nT(e,!1),iT=e=>nT(e,!0),aT=e=>Zw(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),oT=e=>Zw(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),sT=e=>Zw(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),cT=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:h.of([``,``])},range:P.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},lT=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:_(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:_(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:P.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function uT(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function dT(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of uT(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(P.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(P.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:P.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var fT=({state:e,dispatch:t})=>dT(e,t,!1),pT=({state:e,dispatch:t})=>dT(e,t,!0);function mT(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of uT(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var hT=({state:e,dispatch:t})=>mT(e,t,!1),gT=({state:e,dispatch:t})=>mT(e,t,!0),_T=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(uT(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=HC(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function vT(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=M(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(d.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var yT=xT(!1),bT=xT(!0);function xT(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&vT(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new me(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=y(s,r);for(c??=p(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,x(t,c)];return o&&l.push(x(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:h.of(l)},range:P.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function ST(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:P.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var CT=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new me(e,{overrideIndentation:e=>n[e]??-1}),i=ST(e,(t,i,a)=>{let o=y(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=x(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},wT=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(ST(e,(t,n)=>{n.push({from:t.from,insert:e.facet(a)})}),{userEvent:`input.indent`})),!0),TT=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(ST(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=p(r,e.tabSize),a=0,o=x(e,Math.max(0,i-De(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),ET=e=>(e.setTabFocusMode(),!0),DT=[{key:`Ctrl-b`,run:JC,shift:xw,preventDefault:!0},{key:`Ctrl-f`,run:YC,shift:Sw},{key:`Ctrl-p`,run:iw,shift:kw},{key:`Ctrl-n`,run:aw,shift:Aw},{key:`Ctrl-a`,run:hw,shift:Rw},{key:`Ctrl-e`,run:gw,shift:zw},{key:`Ctrl-d`,run:tT},{key:`Ctrl-h`,run:eT},{key:`Ctrl-k`,run:aT},{key:`Ctrl-Alt-h`,run:rT},{key:`Ctrl-o`,run:cT},{key:`Ctrl-t`,run:lT},{key:`Ctrl-v`,run:lw}],OT=[{key:`ArrowLeft`,run:JC,shift:xw,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:ZC,shift:ww,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:pw,shift:Iw,preventDefault:!0},{key:`ArrowRight`,run:YC,shift:Sw,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:QC,shift:Tw,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:mw,shift:Lw,preventDefault:!0},{key:`ArrowUp`,run:iw,shift:kw,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Bw,shift:Hw},{mac:`Ctrl-ArrowUp`,run:cw,shift:Mw},{key:`ArrowDown`,run:aw,shift:Aw,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Vw,shift:Uw},{mac:`Ctrl-ArrowDown`,run:lw,shift:Nw},{key:`PageUp`,run:cw,shift:Mw},{key:`PageDown`,run:lw,shift:Nw},{key:`Home`,run:fw,shift:Fw,preventDefault:!0},{key:`Mod-Home`,run:Bw,shift:Hw},{key:`End`,run:dw,shift:Pw,preventDefault:!0},{key:`Mod-End`,run:Vw,shift:Uw},{key:`Enter`,run:yT,shift:yT},{key:`Mod-a`,run:Ww},{key:`Backspace`,run:eT,shift:eT,preventDefault:!0},{key:`Delete`,run:tT,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:rT,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:iT,preventDefault:!0},{mac:`Mod-Backspace`,run:oT,preventDefault:!0},{mac:`Mod-Delete`,run:sT,preventDefault:!0}].concat(DT.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),kT=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:tw,shift:Ew},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:nw,shift:Dw},{key:`Alt-ArrowUp`,run:fT},{key:`Shift-Alt-ArrowUp`,run:hT},{key:`Alt-ArrowDown`,run:pT},{key:`Shift-Alt-ArrowDown`,run:gT},{key:`Mod-Alt-ArrowUp`,run:Jw},{key:`Mod-Alt-ArrowDown`,run:Yw},{key:`Escape`,run:Xw},{key:`Mod-Enter`,run:bT},{key:`Alt-l`,mac:`Ctrl-l`,run:Gw},{key:`Mod-i`,run:Kw,preventDefault:!0},{key:`Mod-[`,run:TT},{key:`Mod-]`,run:wT},{key:`Mod-Alt-\\`,run:CT},{key:`Shift-Mod-k`,run:_T},{key:`Shift-Mod-\\`,run:vw},{key:`Mod-/`,run:oC},{key:`Alt-A`,run:lC},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:ET}].concat(OT),AT={key:`Tab`,run:wT,shift:TT},jT=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,MT=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(jT(e)):jT,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return n(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=s(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=le(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(MT.prototype[Symbol.iterator]=function(){return this});var NT={from:-1,to:-1,match:/.*/.exec(``)},PT=`gm`+(/x/.unicode==null?``:`u`),FT=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=NT,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new RT(e,t,n,r,i);this.re=new RegExp(t,PT+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=BT(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=BT(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},IT=new WeakMap,LT=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=IT.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return IT.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),IT.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},RT=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=NT,this.matchPos=BT(e,r),this.re=new RegExp(t,PT+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=LT.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=BT(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=LT.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(FT.prototype[Symbol.iterator]=RT.prototype[Symbol.iterator]=function(){return this});function zT(e){try{return new RegExp(e,PT),!0}catch{return!1}}function BT(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var VT=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=Ce(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,d=c?+c.slice(1):0,f=s?+s:a.number;if(s&&l){let e=f/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),f=Math.round(t.doc.lines*e)}else s&&o&&(f=f*(o==`-`?-1:1)+a.number);let p=t.doc.line(Math.max(1,Math.min(t.doc.lines,f))),m=P.cursor(p.from+Math.max(0,Math.min(d,p.length)));e.dispatch({effects:[r,u.scrollIntoView(m.from,{y:`center`})],selection:m})}),!0},HT={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},UT=te.define({combine(e){return f(e,HT,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function WT(e){let t=[XT,YT];return e&&t.push(UT.of(e)),t}var GT=C.mark({class:`cm-selectionMatch`}),KT=C.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function qT(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=D.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=D.Word)}function JT(e,t,n,r){return e(t.sliceDoc(n,n+1))==D.Word&&e(t.sliceDoc(r-1,r))==D.Word}var YT=ve.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(UT),{state:n}=e,r=n.selection;if(r.ranges.length>1)return C.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return C.none;let e=n.wordAt(i.head);if(!e)return C.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return C.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(qT(o,n,i.from,i.to)&&JT(o,n,i.from,i.to)))return C.none}else if(a=n.sliceDoc(i.from,i.to),!a)return C.none}let s=[];for(let r of e.visibleRanges){let e=new MT(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||qT(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(KT.range(r,a)):(r>=i.to||a<=i.from)&&s.push(GT.range(r,a)),s.length>t.maxMatches))return C.none}}return C.set(s)}},{decorations:e=>e.decorations}),XT=u.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),ZT=({state:e,dispatch:t})=>{let{selection:n}=e,r=P.create(n.ranges.map(t=>e.wordAt(t.head)||P.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function QT(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new MT(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new MT(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var $T=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return ZT({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=QT(e,r);return i?(t(e.update({selection:e.selection.addRange(P.range(i.from,i.to),!1),effects:u.scrollIntoView(i.to)})),!0):!1},eE=te.define({combine(e){return f(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new PE(e),scrollToMatch:e=>u.scrollIntoView(e)})}}),tE=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||zT(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
209
|
+
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new fE(this):new oE(this)}getCursor(e,t=0,n){let r=e.doc?e:ke.create({doc:e});return n??=r.doc.length,this.regexp?cE(this,r,t,n):iE(this,r,t,n)}},nE=class{constructor(e){this.spec=e}};function rE(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function iE(e,t,n,r){let i;return e.wholeWord&&(i=aE(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=rE(e.test,t,i)),new MT(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function aE(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(lE(i,n-a))!=D.Word||t(uE(i,n-a))!=D.Word)&&(t(uE(i,r-a))!=D.Word||t(lE(i,r-a))!=D.Word))}var oE=class extends nE{constructor(e){super(e)}nextMatch(e,t,n){let r=iE(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=iE(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=iE(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=iE(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=iE(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function sE(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function cE(e,t,n,r){let i;return e.wholeWord&&(i=dE(t.charCategorizer(t.selection.main.head))),e.test&&(i=sE(e.test,t,i)),new FT(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function lE(e,t){return e.slice(_(e,t,!1),t)}function uE(e,t){return e.slice(t,_(e,t))}function dE(e){return(t,n,r)=>!r[0].length||(e(lE(r.input,r.index))!=D.Word||e(uE(r.input,r.index))!=D.Word)&&(e(uE(r.input,r.index+r[0].length))!=D.Word||e(lE(r.input,r.index+r[0].length))!=D.Word)}var fE=class extends nE{nextMatch(e,t,n){let r=cE(this.spec,e,n,e.doc.length).next();return r.done&&(r=cE(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=cE(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=cE(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=cE(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},pE=o.define(),mE=o.define(),hE=i.define({create(e){return new gE(OE(e).create(),null)},update(e,t){for(let n of t.effects)n.is(pE)?e=new gE(n.value.create(),e.panel):n.is(mE)&&(e=new gE(e.query,n.value?DE:null));return e},provide:e=>k.from(e,e=>e.panel)}),gE=class{constructor(e,t){this.query=e,this.panel=t}},_E=C.mark({class:`cm-searchMatch`}),vE=C.mark({class:`cm-searchMatch cm-searchMatch-selected`}),yE=ve.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(hE))}update(e){let t=e.state.field(hE);(t!=e.startState.field(hE)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return C.none;let{view:n}=this,r=new Ee;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?vE:_E)})}return r.finish()}},{decorations:e=>e.decorations});function bE(e){return t=>{let n=t.state.field(hE,!1);return n&&n.query.spec.valid?e(t,n):jE(t)}}var xE=bE((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=P.single(r.from,r.to),a=e.state.facet(eE);return e.dispatch({selection:i,effects:[RE(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),AE(e),!0}),SE=bE((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=P.single(i.from,i.to),o=e.state.facet(eE);return e.dispatch({selection:a,effects:[RE(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),AE(e),!0}),CE=bE((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:P.create(n.map(e=>P.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),wE=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new MT(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(P.range(t.value.from,t.value.to))}return t(e.update({selection:P.create(a,o),userEvent:`select.search.matches`})),!0},TE=bE((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,d=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),d.push(u.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let f=e.state.changes(s);return o&&(c=P.single(o.from,o.to).map(f),d.push(RE(e,o)),d.push(n.facet(eE).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:`input.replace`}),!0}),EE=bE((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:u.announce.of(r),userEvent:`input.replace.all`}),!0});function DE(e){return e.state.facet(eE).createPanel(e)}function OE(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(eE);return new tE({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function kE(e){let t=v(e,DE);return t&&t.dom.querySelector(`[main-field]`)}function AE(e){let t=kE(e);t&&t==e.root.activeElement&&t.select()}var jE=e=>{let t=e.state.field(hE,!1);if(t&&t.panel){let n=kE(e);if(n&&n!=e.root.activeElement){let r=OE(e.state,t.query.spec);r.valid&&e.dispatch({effects:pE.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[mE.of(!0),t?pE.of(OE(e.state,t.query.spec)):o.appendConfig.of(BE)]});return!0},ME=e=>{let t=e.state.field(hE,!1);if(!t||!t.panel)return!1;let n=v(e,DE);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:mE.of(!1)}),!0},NE=[{key:`Mod-f`,run:jE,scope:`editor search-panel`},{key:`F3`,run:xE,shift:SE,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:xE,shift:SE,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:ME,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:wE},{key:`Mod-Alt-g`,run:VT},{key:`Mod-d`,run:$T,preventDefault:!0}],PE=class{constructor(e){this.view=e;let t=this.query=e.state.field(hE).query.spec;this.commit=this.commit.bind(this),this.searchField=N(`input`,{value:t.search,placeholder:FE(e,`Find`),"aria-label":FE(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=N(`input`,{value:t.replace,placeholder:FE(e,`Replace`),"aria-label":FE(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=N(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=N(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=N(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return N(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=N(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>xE(e),[FE(e,`next`)]),n(`prev`,()=>SE(e),[FE(e,`previous`)]),n(`select`,()=>CE(e),[FE(e,`all`)]),N(`label`,null,[this.caseField,FE(e,`match case`)]),N(`label`,null,[this.reField,FE(e,`regexp`)]),N(`label`,null,[this.wordField,FE(e,`by word`)]),...e.state.readOnly?[]:[N(`br`),this.replaceField,n(`replace`,()=>TE(e),[FE(e,`replace`)]),n(`replaceAll`,()=>EE(e),[FE(e,`replace all`)])],N(`button`,{name:`close`,onclick:()=>ME(e),"aria-label":FE(e,`close`),type:`button`},[`×`])])}commit(){let e=new tE({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:pE.of(e)}))}keydown(e){fe(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?SE:xE)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),TE(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(pE)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(eE).top}};function FE(e,t){return e.state.phrase(t)}var IE=30,LE=/[\s\.,:;?!]/;function RE(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-IE),o=Math.min(i,n+IE),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<IE;e++)if(!LE.test(s[e+1])&&LE.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-IE;e--)if(!LE.test(s[e-1])&&LE.test(s[e])){s=s.slice(0,e);break}}return u.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var zE=u.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),BE=[hE,b.low(yE),zE],VE=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=M(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(JE(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function HE(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function UE(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=HE(t)+HE(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function WE(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:UE(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function GE(e,t){return n=>{for(let t=M(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var KE=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function qE(e){return e.selection.main.from}function JE(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var YE=pe.define();function XE(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:P.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var ZE=new WeakMap;function QE(e){if(!Array.isArray(e))return e;let t=ZE.get(e);return t||ZE.set(e,t=WE(e)),t}var $E=o.define(),eD=o.define(),tD=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let r=n(e,t),i=le(r);this.chars.push(r);let a=e.slice(t,t+i),o=a.toUpperCase();this.folded.push(n(o==a?a.toLowerCase():o,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:r,any:i,precise:a,byWord:o}=this;if(t.length==1){let i=n(e,0),a=le(i),o=a==e.length?0:-100;if(i!=t[0])if(i==r[0])o+=-200;else return null;return this.ret(o,[0,a])}let c=e.indexOf(this.pattern);if(c==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,u=0;if(c<0){for(let a=0,o=Math.min(e.length,200);a<o&&u<l;){let o=n(e,a);(o==t[u]||o==r[u])&&(i[u++]=a),a+=le(o)}if(u<l)return null}let d=0,f=0,p=!1,m=0,h=-1,g=-1,_=/[a-z]/.test(e),v=!0;for(let i=0,u=Math.min(e.length,200),y=0;i<u&&f<l;){let u=n(e,i);c<0&&(d<l&&u==t[d]&&(a[d++]=i),m<l&&(u==t[m]||u==r[m]?(m==0&&(h=i),g=i+1,m++):m=0));let b,x=u<255?u>=48&&u<=57||u>=97&&u<=122?2:u>=65&&u<=90?1:0:(b=s(u))==b.toLowerCase()?b==b.toUpperCase()?0:2:1;(!i||x==1&&_||y==0&&x!=0)&&(t[f]==u||r[f]==u&&(p=!0)?o[f++]=i:o.length&&(v=!1)),y=x,i+=le(u)}return f==l&&o[0]==0&&v?this.result(-100+(p?-200:0),o,e):m==l&&h==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):m==l?this.ret(-900-e.length,[h,g]):f==l?this.result(-100+(p?-200:0)+-700+(v?0:-1100),o,e):t.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,t,r){let i=[],a=0;for(let e of t){let t=e+(this.astral?le(n(r,e)):1);a&&i[a-1]==e?i[a-1]=t:(i[a++]=e,i[a++]=t)}return this.ret(e-r.length,i)}},nD=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},rD=te.define({combine(e){return f(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:aD,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>iD(e(n),t(n)),optionClass:(e,t)=>n=>iD(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function iD(e,t){return e?t?e+` `+t:e:t}function aD(e,t,n,r,i,a){let o=e.textDirection==c.RTL,s=o,l=!1,u=`top`,d,f,p=t.left-i.left,m=i.right-t.right,h=r.right-r.left,g=r.bottom-r.top;if(s&&p<Math.min(h,m)?s=!1:!s&&m<Math.min(h,p)&&(s=!0),h<=(s?p:m))d=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,f=Math.min(400,s?p:m);else{l=!0,f=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=g||e>t.top?d=n.bottom-t.top:(u=`bottom`,d=t.bottom-n.top)}let _=(t.bottom-t.top)/a.offsetHeight,v=(t.right-t.left)/a.offsetWidth;return{style:`${u}: ${d/_}px; max-width: ${f/v}px`,class:`cm-completionInfo-`+(l?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var oD=o.define();function sD(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function cD(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}var lD=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(rD);this.optionContent=sD(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=cD(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:oD.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(rD).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:eD.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=cD(r.length,i,e.state.facet(rD).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=cD(t.options.length,t.selected,this.view.state.facet(rD).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>_e(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&dD(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(rD).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function uD(e,t){return n=>new lD(n,e,t)}function dD(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function fD(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function pD(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(rD);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new KE(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new nD(n):new tD(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new KE(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):fD(e.completion)>fD(c)&&(s[s.length-1]=e),c=e.completion}return s}var mD=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,yD(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=pD(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(rD).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,yD(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:OD,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},hD=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(bD,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(rD),i=(r.override||n.languageDataAt(`autocomplete`,qE(n)).map(QE)).map(e=>(this.active.find(t=>t.source==e)||new SD(e,this.active.some(e=>e.state!=0)?1:0)).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(TD));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!gD(i,this.active)||o?a=mD.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new SD(e.source,0):e));for(let e of t.effects)e.is(oD)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?_D:vD}};function gD(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var _D={"aria-autocomplete":`list`},vD={};function yD(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var bD=[];function xD(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(YE);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var SD=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=xD(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is($E))i=new e(i.source,1,n.value);else if(n.is(eD))i=new e(i.source,0);else if(n.is(TD))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(qE(e.state))}},CD=class e extends SD{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=qE(t.state);if(o>a||!r||n&2&&(qE(t.startState)==this.from||o<this.limit))return new SD(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return wD(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new VE(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??qE(t.state)):new SD(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new SD(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function wD(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):JE(e,!0).test(i)}var TD=o.define({map(e,t){return e.map(e=>e.map(t))}}),ED=i.define({create(){return hD.start()},update(e,t){return e.update(t)},provide:e=>[ae.from(e,e=>e.tooltip),u.contentAttributes.from(e,e=>e.attrs)]});function DD(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(ED).active.find(e=>e.source==t.source);return r instanceof CD?(typeof n==`string`?e.dispatch({...XE(e.state,n,r.from,r.to),annotations:YE.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var OD=uD(ED,DD);function kD(t,n=`option`){return r=>{let i=r.state.field(ED,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<r.state.facet(rD).interactionDelay)return!1;let a=1,o;n==`page`&&(o=e(r,i.open.tooltip))&&(a=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector(`li`).offsetHeight)-1));let{length:s}=i.open.options,c=i.open.selected>-1?i.open.selected+a*(t?1:-1):t?0:s-1;return c<0?c=n==`page`?0:s-1:c>=s&&(c=n==`page`?s-1:0),r.dispatch({effects:oD.of(c)}),!0}}var AD=e=>{let t=e.state.field(ED,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(rD).interactionDelay?!1:DD(e,t.open.options[t.open.selected])},jD=e=>e.state.field(ED,!1)?(e.dispatch({effects:$E.of(!0)}),!0):!1,MD=e=>{let t=e.state.field(ED,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:eD.of(null)}),!0)},ND=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},PD=50,FD=1e3,ID=ve.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(ED).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(ED),n=e.state.facet(rD);if(!e.selectionSet&&!e.docChanged&&e.startState.field(ED)==t)return;let r=e.transactions.some(e=>{let t=xD(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>PD&&Date.now()-n.time>FD){for(let e of n.context.abortListeners)try{e()}catch(e){_e(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is($E)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(ED);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(rD).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new VE(t,qE(t),e.explicit,this.view),r=new ND(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:eD.of(null)}),_e(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(rD).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(rD),n=this.view.state.field(ED);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=qE(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+(i.active.explicit?0:1)),a=new CD(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new SD(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:TD.of(e)})}},{eventHandlers:{blur(t){let n=this.view.state.field(ED,!1);if(n&&n.tooltip&&this.view.state.facet(rD).closeOnBlur){let r=n.open&&e(this.view,n.open.tooltip);(!r||!r.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:eD.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:$E.of(!1)}),20),this.composing=0}}}),LD=typeof navigator==`object`&&/Win/.test(navigator.platform),RD=b.highest(u.domEventHandlers({keydown(e,t){let n=t.state.field(ED,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(LD&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&DD(t,r),!1}})),zD=u.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),BD=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},VD=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,Oe.TrackDel),r=t.mapPos(this.to,1,Oe.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},HD=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),o=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=o,s=/^\t*/.exec(i)[0].length;for(let t=0;t<s;t++)n+=e.facet(a);r.push(t+n.length-s),i=n+i.slice(s)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new VD(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new BD(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},UD=C.widget({widget:new class extends l{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),WD=C.mark({class:`cm-snippetField`}),GD=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=C.set(e.map(e=>(e.from==e.to?UD:WD).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},KD=o.define({map(e,t){return e&&e.map(t)}}),qD=o.define(),JD=i.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(KD))return n.value;if(n.is(qD)&&e)return new GD(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>u.decorations.from(e,e=>e?e.deco:C.none)});function YD(e,t){return P.create(e.filter(e=>e.field==t).map(e=>P.range(e.from,e.to)))}function XD(e){let t=HD.parse(e);return(e,n,r,i)=>{let{text:a,ranges:s}=t.instantiate(e.state,r),{main:c}=e.state.selection,l={changes:{from:r,to:i==c.from?c.to:i,insert:h.of(a)},scrollIntoView:!0,annotations:n?[YE.of(n),ue.userEvent.of(`input.complete`)]:void 0};if(s.length&&(l.selection=YD(s,0)),s.some(e=>e.field>0)){let t=new GD(s,0),n=l.effects=[KD.of(t)];e.state.field(JD,!1)===void 0&&n.push(o.appendConfig.of([JD,eO,nO,zD]))}e.dispatch(e.state.update(l))}}function ZD(e){return({state:t,dispatch:n})=>{let r=t.field(JD,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:YD(r.ranges,i),effects:KD.of(a?null:new GD(r.ranges,i)),scrollIntoView:!0})),!0}}var QD=[{key:`Tab`,run:ZD(1),shift:ZD(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(JD,!1)?(t(e.update({effects:KD.of(null)})),!0):!1}],$D=te.define({combine(e){return e.length?e[0]:QD}}),eO=b.highest(j.compute([$D],e=>e.facet($D)));function tO(e,t){return{...t,apply:XD(e)}}var nO=u.domEventHandlers({mousedown(e,t){let n=t.state.field(JD,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:YD(n.ranges,i.field),effects:KD.of(n.ranges.some(e=>e.field>i.field)?new GD(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),rO={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},iO=o.define({map(e,t){return t.mapPos(e,-1,Oe.TrackAfter)??void 0}}),aO=new class extends S{};aO.startSide=1,aO.endSide=-1;var oO=i.define({create(){return r.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(iO)&&(e=e.update({add:[aO.range(n.value,n.value+1)]}));return e}});function sO(){return[fO,oO]}var cO=`()[]{}<>«»»«[]{}`;function lO(e){for(let t=0;t<16;t+=2)if(cO.charCodeAt(t)==e)return cO.charAt(t+1);return s(e<128?e:e+1)}function uO(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||rO}var dO=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),fO=u.inputHandler.of((e,t,r,i)=>{if((dO?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let a=e.state.selection.main;if(i.length>2||i.length==2&&le(n(i,0))==1||t!=a.from||r!=a.to)return!1;let o=mO(e.state,i);return o?(e.dispatch(o),!0):!1}),pO=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=uO(e,e.selection.main.head).brackets||rO.brackets,i=null,a=e.changeByRange(t=>{if(t.empty){let i=_O(e.doc,t.head);for(let a of r)if(a==i&&gO(e.doc,t.head)==lO(n(a,0)))return{changes:{from:t.head-a.length,to:t.head+a.length},range:P.cursor(t.head-a.length)}}return{range:i=t}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:`delete.backward`})),!i}}];function mO(e,t){let r=uO(e,e.selection.main.head),i=r.brackets||rO.brackets;for(let a of i){let o=lO(n(a,0));if(t==a)return o==a?bO(e,a,i.indexOf(a+a+a)>-1,r):vO(e,a,o,r.before||rO.before);if(t==o&&hO(e,e.selection.main.from))return yO(e,a,o)}return null}function hO(e,t){let n=!1;return e.field(oO).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function gO(e,t){let r=e.sliceString(t,t+2);return r.slice(0,le(n(r,0)))}function _O(e,t){let r=e.sliceString(t-2,t);return le(n(r,0))==r.length?r:r.slice(1)}function vO(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:iO.of(a.to+t.length),range:P.range(a.anchor+t.length,a.head+t.length)};let o=gO(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:iO.of(a.head+t.length),range:P.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function yO(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&gO(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:P.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function bO(e,t,n,r){let i=r.stringPrefixes||rO.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:iO.of(r.to+t.length),range:P.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=gO(e.doc,o),c;if(s==t){if(xO(e,o))return{changes:{insert:t+t,from:o},effects:iO.of(o+t.length),range:P.cursor(o+t.length)};if(hO(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:P.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=CO(e,o-2*t.length,i))>-1&&xO(e,c))return{changes:{insert:t+t+t+t,from:o},effects:iO.of(o+t.length),range:P.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=D.Word&&CO(e,o,i)>-1&&!SO(e,o,t,i))return{changes:{insert:t+t,from:o},effects:iO.of(o+t.length),range:P.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function xO(e,t){let n=M(e).resolveInner(t+1);return n.parent&&n.from==t}function SO(e,t,n,r){let i=M(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function CO(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=D.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=D.Word)return n}return-1}function wO(e={}){return[RD,ED,rD.of(e),ID,EO,zD]}var TO=[{key:`Ctrl-Space`,run:jD},{mac:"Alt-`",run:jD},{mac:`Alt-i`,run:jD},{key:`Escape`,run:MD},{key:`ArrowDown`,run:kD(!0)},{key:`ArrowUp`,run:kD(!1)},{key:`PageDown`,run:kD(!0,`page`)},{key:`PageUp`,run:kD(!1,`page`)},{key:`Enter`,run:AD}],EO=b.highest(j.computeN([rD],e=>e.facet(rD).defaultKeymap?[TO]:[])),DO=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},OO=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(HO).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Ee,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=$O(s);if(i)o.add(n,n,C.widget({widget:new KO(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,C.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,kO(f))}};function kO(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new DO(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new DO(r.from,n,r.diagnostic)}),r}function AO(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(HO).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(MO))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function jO(e,t){return e.field(FO,!1)?t:t.concat(o.appendConfig.of(ek))}var MO=o.define(),NO=o.define(),PO=o.define(),FO=i.define({create(){return new OO(C.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=kO(n,e.selected.diagnostic,i)||kO(n,null,i)}!n.size&&i&&t.state.facet(HO).autoPanel&&(i=null),e=new OO(n,i,r)}for(let n of t.effects)if(n.is(MO)){let r=t.state.facet(HO).autoPanel?n.value.length?JO.open:null:e.panel;e=OO.init(n.value,r,t.state)}else n.is(NO)?e=new OO(e.diagnostics,n.value?JO.open:null,e.selected):n.is(PO)&&(e=new OO(e.diagnostics,e.panel,n.value));return e},provide:e=>[k.from(e,e=>e.panel),u.decorations.from(e,e=>e.diagnostics)]}),IO=C.mark({class:`cm-lintRange cm-lintRange-active`});function LO(e,t,n){let{diagnostics:r}=e.state.field(FO),i,a=-1,o=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(HO).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:RO(e,i)}}}:null}function RO(e,t){return N(`ul`,{class:`cm-tooltip-lint`},t.map(t=>GO(e,t,!1)))}var zO=e=>{let t=e.state.field(FO,!1);(!t||!t.panel)&&e.dispatch({effects:jO(e.state,[NO.of(!0)])});let n=v(e,JO.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},BO=e=>{let t=e.state.field(FO,!1);return!t||!t.panel?!1:(e.dispatch({effects:NO.of(!1)}),!0)},VO=[{key:`Mod-Shift-m`,run:zO,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(FO,!1);if(!t)return!1;let n=e.state.selection.main,r=kO(t.diagnostics,null,n.to+1);return!r&&(r=kO(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],HO=te.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...f(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:UO,tooltipFilter:UO,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function UO(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function WO(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function GO(e,t,n){let r=n?WO(t.actions):[];return N(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},N(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=kO(e.state.field(FO).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),N(`u`,s.slice(c,c+1)),s.slice(c+1)];return N(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&N(`div`,{class:`cm-diagnosticSource`},t.source))}var KO=class extends l{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return N(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},qO=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=GO(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},JO=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)BO(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=WO(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=kO(this.view.state.field(FO).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=N(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=N(`div`,{class:`cm-panel-lint`},this.list,N(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>BO(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(FO).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(FO),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new qO(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new qO(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=kO(this.view.state.field(FO).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:PO.of(t)})}static open(t){return new e(t)}};function YO(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function XO(e){return YO(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var ZO=u.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:XO(`#d11`)},".cm-lintRange-warning":{backgroundImage:XO(`orange`)},".cm-lintRange-info":{backgroundImage:XO(`#999`)},".cm-lintRange-hint":{backgroundImage:XO(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function QO(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function $O(e){let t=`hint`,n=1;for(let r of e){let e=QO(r.severity);e>n&&(n=e,t=r.severity)}return t}var ek=[FO,u.decorations.compute([FO],e=>{let{selected:t,panel:n}=e.field(FO);return!t||!n||t.from==t.to?C.none:C.set([IO.range(t.from,t.to)])}),ye(LO,{hideOn:AO}),ZO],tk=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,r=[];e.closeBracketsKeymap!==!1&&(r=r.concat(pO)),e.defaultKeymap!==!1&&(r=r.concat(kT)),e.searchKeymap!==!1&&(r=r.concat(NE)),e.historyKeymap!==!1&&(r=r.concat(VC)),e.foldKeymap!==!1&&(r=r.concat(we)),e.completionKeymap!==!1&&(r=r.concat(TO)),e.lintKeymap!==!1&&(r=r.concat(VO));var i=[];return e.lineNumbers!==!1&&i.push(ee()),e.highlightActiveLineGutter!==!1&&i.push(Se()),e.highlightSpecialChars!==!1&&i.push(he()),e.history!==!1&&i.push(SC()),e.foldGutter!==!1&&i.push(oe()),e.drawSelection!==!1&&i.push(w()),e.dropCursor!==!1&&i.push(E()),e.allowMultipleSelections!==!1&&i.push(ke.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(Te()),e.syntaxHighlighting!==!1&&i.push(t(ie,{fallback:!0})),e.bracketMatching!==!1&&i.push(de()),e.closeBrackets!==!1&&i.push(sO()),e.autocompletion!==!1&&i.push(wO()),e.rectangularSelection!==!1&&i.push(re()),n!==!1&&i.push(T()),e.highlightActiveLine!==!1&&i.push(A()),e.highlightSelectionMatches!==!1&&i.push(WT()),e.tabSize&&typeof e.tabSize==`number`&&i.push(a.of(` `.repeat(e.tabSize))),i.concat([j.of(r.flat())]).filter(Boolean)},nk=`#e5c07b`,rk=`#e06c75`,ik=`#56b6c2`,ak=`#ffffff`,ok=`#abb2bf`,sk=`#7d8799`,ck=`#61afef`,lk=`#98c379`,uk=`#d19a66`,dk=`#c678dd`,fk=`#21252b`,pk=`#2c313a`,mk=`#282c34`,hk=`#353a42`,gk=`#3E4451`,_k=`#528bff`,vk=[u.theme({"&":{color:ok,backgroundColor:mk},".cm-content":{caretColor:_k},".cm-cursor, .cm-dropCursor":{borderLeftColor:_k},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:gk},".cm-panels":{backgroundColor:fk,color:ok},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:mk,color:sk,border:`none`},".cm-activeLineGutter":{backgroundColor:pk},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:hk},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:hk,borderBottomColor:hk},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:pk,color:ok}}},{dark:!0}),t(xe.define([{tag:g.keyword,color:dk},{tag:[g.name,g.deleted,g.character,g.propertyName,g.macroName],color:rk},{tag:[g.function(g.variableName),g.labelName],color:ck},{tag:[g.color,g.constant(g.name),g.standard(g.name)],color:uk},{tag:[g.definition(g.name),g.separator],color:ok},{tag:[g.typeName,g.className,g.number,g.changed,g.annotation,g.modifier,g.self,g.namespace],color:nk},{tag:[g.operator,g.operatorKeyword,g.url,g.escape,g.regexp,g.link,g.special(g.string)],color:ik},{tag:[g.meta,g.comment],color:sk},{tag:g.strong,fontWeight:`bold`},{tag:g.emphasis,fontStyle:`italic`},{tag:g.strikethrough,textDecoration:`line-through`},{tag:g.link,color:sk,textDecoration:`underline`},{tag:g.heading,fontWeight:`bold`,color:rk},{tag:[g.atom,g.bool,g.special(g.variableName)],color:uk},{tag:[g.processingInstruction,g.string,g.inserted],color:lk},{tag:g.invalid,color:ak}]))],yk=u.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),bk=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i=`light`,placeholder:a=``,basicSetup:o=!0}=e,s=[];switch(t&&s.unshift(j.of([AT])),o&&(typeof o==`boolean`?s.unshift(tk()):s.unshift(tk(o))),a&&s.unshift(be(a)),i){case`light`:s.push(yk);break;case`dark`:s.push(vk);break;case`none`:break;default:s.push(i);break}return n===!1&&s.push(u.editable.of(!1)),r&&s.push(ke.readOnly.of(!0)),[...s]},xk=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),Sk=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},Ck=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},wk=null,Tk=()=>typeof window>`u`?new Ck:(wk||=new Ck,wk),Ek=pe.define(),Dk=200,Ok=[];function kk(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:a,onUpdate:s,extensions:c=Ok,autoFocus:l,theme:d=`light`,height:f=null,minHeight:p=null,maxHeight:m=null,width:h=null,minWidth:g=null,maxWidth:_=null,placeholder:v=``,editable:y=!0,readOnly:b=!1,indentWithTab:x=!0,basicSetup:S=!0,root:C,initialState:w}=e,[T,E]=(0,I.useState)(),[D,O]=(0,I.useState)(),[ee,te]=(0,I.useState)(),ne=(0,I.useState)(()=>({current:null}))[0],re=(0,I.useState)(()=>({current:null}))[0],k=u.theme({"&":{height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_},"& .cm-scroller":{height:`100% !important`}}),A=[u.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(Ek))&&(ne.current?ne.current.reset():(ne.current=new Sk(()=>{if(re.current){var e=re.current;re.current=null,e()}ne.current=null},Dk),Tk().add(ne.current)),r(e.state.doc.toString(),e)),i&&i(xk(e))}),k,...bk({theme:d,editable:y,readOnly:b,placeholder:v,indentWithTab:x,basicSetup:S})];return s&&typeof s==`function`&&A.push(u.updateListener.of(s)),A=A.concat(c),(0,I.useLayoutEffect)(()=>{if(T&&!ee){var e={doc:t,selection:n,extensions:A},r=w?ke.fromJSON(w.json,e,w.fields):ke.create(e);if(te(r),!D){var i=new u({state:r,parent:T,root:C});O(i),a&&a(i,r)}}return()=>{D&&(te(void 0),O(void 0))}},[T,ee]),(0,I.useEffect)(()=>{e.container&&E(e.container)},[e.container]),(0,I.useEffect)(()=>()=>{D&&(D.destroy(),O(void 0)),ne.current&&=(ne.current.cancel(),null)},[D]),(0,I.useEffect)(()=>{l&&D&&D.focus()},[l,D]),(0,I.useEffect)(()=>{D&&D.dispatch({effects:o.reconfigure.of(A)})},[d,c,f,p,m,h,g,_,v,y,b,x,S,r,s]),(0,I.useEffect)(()=>{if(t!==void 0){var e=D?D.state.doc.toString():``;if(D&&t!==e){var n=ne.current&&!ne.current.isDone,r=()=>{D&&t!==D.state.doc.toString()&&D.dispatch({changes:{from:0,to:D.state.doc.toString().length,insert:t||``},annotations:[Ek.of(!0)]})};n?re.current=r:r()}}},[t,D]),{state:ee,setState:te,view:D,setView:O,container:T,setContainer:E}}var Ak=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],jk=(0,I.forwardRef)((e,t)=>{var{className:n,value:r=``,selection:i,extensions:a=[],onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,autoFocus:u,theme:d=`light`,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,root:C,initialState:w}=e,T=aC(e,Ak),E=(0,I.useRef)(null),{state:D,view:O,container:ee,setContainer:te}=kk({root:C,value:r,autoFocus:u,theme:d,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,selection:i,onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,extensions:a,initialState:w});(0,I.useImperativeHandle)(t,()=>({editor:E.current,state:D,view:O}),[E,ee,D,O]);var ne=(0,I.useCallback)(e=>{E.current=e,te(e)},[te]);if(typeof r!=`string`)throw Error(`value must be typeof string but got `+typeof r);return(0,L.jsx)(`div`,iC({ref:ne,className:(typeof d==`string`?`cm-theme-`+d:`cm-theme`)+(n?` `+n:``)},T))});jk.displayName=`CodeMirror`;var Mk=`modulepreload`,Nk=function(e){return`/`+e},Pk={},Q=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}))))}r=o(t.map(t=>{if(t=Nk(t,n),t in Pk)return;Pk[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Mk,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}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 $(e){return new ge(ne.define(e))}function Fk(e){return Q(()=>import(`./dist-D0ChGMIP.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([0,1,2]))}var Ik=[O.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return Q(()=>import(`./dist-DYBvJnrG.js`).then(e=>e.cpp()),__vite__mapDeps([3,1,2]))}}),O.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return Q(()=>import(`./dist-DYBvJnrG.js`).then(e=>e.cpp()),__vite__mapDeps([3,1,2]))}}),O.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return Fk(`Cassandra`)}}),O.of({name:`CSS`,extensions:[`css`],load(){return Q(()=>import(`./dist-o59V-mFz.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([4,1,2]))}}),O.of({name:`Go`,extensions:[`go`],load(){return Q(()=>import(`./dist-Bz_abif3.js`).then(e=>e.go()),__vite__mapDeps([5,1,2]))}}),O.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return Q(()=>import(`./dist-Alz6ZkbS.js`).then(e=>e.html()),__vite__mapDeps([6,4,1,2,7]))}}),O.of({name:`Java`,extensions:[`java`],load(){return Q(()=>import(`./dist-elfU6IUT.js`).then(e=>e.java()),__vite__mapDeps([8,1,2]))}}),O.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return Q(()=>import(`./dist-B6cfXU5R.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,2]))}}),O.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return Q(()=>import(`./dist-BFpuo4hT.js`).then(e=>e.jinja()),__vite__mapDeps([9,4,1,2,6,7]))}}),O.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return Q(()=>import(`./dist-Cc03jTPl.js`).then(e=>e.json()),__vite__mapDeps([10,1,2]))}}),O.of({name:`JSX`,extensions:[`jsx`],load(){return Q(()=>import(`./dist-B6cfXU5R.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([7,1,2]))}}),O.of({name:`LESS`,extensions:[`less`],load(){return Q(()=>import(`./dist-DZ2ryQd4.js`).then(e=>e.less()),__vite__mapDeps([11,4,1,2]))}}),O.of({name:`Liquid`,extensions:[`liquid`],load(){return Q(()=>import(`./dist-D9-TuUR1.js`).then(e=>e.liquid()),__vite__mapDeps([12,4,1,2,6,7]))}}),O.of({name:`MariaDB SQL`,load(){return Fk(`MariaSQL`)}}),O.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return Q(()=>import(`./dist-CdfyROF-.js`).then(e=>e.markdown()),__vite__mapDeps([13,4,1,2,6,7]))}}),O.of({name:`MS SQL`,load(){return Fk(`MSSQL`)}}),O.of({name:`MySQL`,load(){return Fk(`MySQL`)}}),O.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return Q(()=>import(`./dist-Bk6w2PLG.js`).then(e=>e.php()),__vite__mapDeps([14,4,1,2,6,7]))}}),O.of({name:`PLSQL`,extensions:[`pls`],load(){return Fk(`PLSQL`)}}),O.of({name:`PostgreSQL`,load(){return Fk(`PostgreSQL`)}}),O.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return Q(()=>import(`./dist-CMb9XHCS.js`).then(e=>e.python()),__vite__mapDeps([15,1,2]))}}),O.of({name:`Rust`,extensions:[`rs`],load(){return Q(()=>import(`./dist-C6S96i9v.js`).then(e=>e.rust()),__vite__mapDeps([16,1,2]))}}),O.of({name:`Sass`,extensions:[`sass`],load(){return Q(()=>import(`./dist-t6-iLg-t.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([17,4,1,2]))}}),O.of({name:`SCSS`,extensions:[`scss`],load(){return Q(()=>import(`./dist-t6-iLg-t.js`).then(e=>e.sass()),__vite__mapDeps([17,4,1,2]))}}),O.of({name:`SQL`,extensions:[`sql`],load(){return Fk(`StandardSQL`)}}),O.of({name:`SQLite`,load(){return Fk(`SQLite`)}}),O.of({name:`TSX`,extensions:[`tsx`],load(){return Q(()=>import(`./dist-B6cfXU5R.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([7,1,2]))}}),O.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return Q(()=>import(`./dist-B6cfXU5R.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,2]))}}),O.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return Q(()=>import(`./dist-BSpuB3dZ.js`).then(e=>e.wast()),__vite__mapDeps([18,1,2]))}}),O.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return Q(()=>import(`./dist-DIQDx3Dq.js`).then(e=>e.xml()),__vite__mapDeps([19,1,2]))}}),O.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return Q(()=>import(`./dist-CftiQ_Tf.js`).then(e=>e.yaml()),__vite__mapDeps([20,1,2]))}}),O.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return Q(()=>import(`./apl-Dgw9L7wA.js`).then(e=>$(e.apl)),[])}}),O.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return Q(()=>import(`./asciiarmor-B3T-Ib7X.js`).then(e=>$(e.asciiArmor)),[])}}),O.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return Q(()=>import(`./asn1-C0KgO0Wt.js`).then(e=>$(e.asn1({}))),[])}}),O.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return Q(()=>import(`./asterisk-D7tOY-Ef.js`).then(e=>$(e.asterisk)),[])}}),O.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return Q(()=>import(`./brainfuck-Dr6WXxS2.js`).then(e=>$(e.brainfuck)),[])}}),O.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return Q(()=>import(`./cobol-ng5WMKOY.js`).then(e=>$(e.cobol)),[])}}),O.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.csharp)),[])}}),O.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return Q(()=>import(`./clojure-DsDsbt3V.js`).then(e=>$(e.clojure)),[])}}),O.of({name:`ClojureScript`,extensions:[`cljs`],load(){return Q(()=>import(`./clojure-DsDsbt3V.js`).then(e=>$(e.clojure)),[])}}),O.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return Q(()=>import(`./css-zrdFFahf.js`).then(e=>$(e.gss)),[])}}),O.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return Q(()=>import(`./cmake-CaoY67QC.js`).then(e=>$(e.cmake)),[])}}),O.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return Q(()=>import(`./coffeescript-L66efR1O.js`).then(e=>$(e.coffeeScript)),[])}}),O.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return Q(()=>import(`./commonlisp-rk__8_Ow.js`).then(e=>$(e.commonLisp)),[])}}),O.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return Q(()=>import(`./cypher-DTKBhe_T.js`).then(e=>$(e.cypher)),[])}}),O.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return Q(()=>import(`./python-_LoDBjEZ.js`).then(e=>$(e.cython)),[])}}),O.of({name:`Crystal`,extensions:[`cr`],load(){return Q(()=>import(`./crystal-C1BeQSjD.js`).then(e=>$(e.crystal)),[])}}),O.of({name:`D`,extensions:[`d`],load(){return Q(()=>import(`./d-CDf89RKe.js`).then(e=>$(e.d)),[])}}),O.of({name:`Dart`,extensions:[`dart`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.dart)),[])}}),O.of({name:`diff`,extensions:[`diff`,`patch`],load(){return Q(()=>import(`./diff-BY4_GICG.js`).then(e=>$(e.diff)),[])}}),O.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return Q(()=>import(`./dockerfile-BBRxgo6-.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([21,22]))}}),O.of({name:`DTD`,extensions:[`dtd`],load(){return Q(()=>import(`./dtd-BOpcurKR.js`).then(e=>$(e.dtd)),[])}}),O.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return Q(()=>import(`./dylan-DrmRAfMX.js`).then(e=>$(e.dylan)),[])}}),O.of({name:`EBNF`,load(){return Q(()=>import(`./ebnf-DgECi_W8.js`).then(e=>$(e.ebnf)),[])}}),O.of({name:`ECL`,extensions:[`ecl`],load(){return Q(()=>import(`./ecl-CWDhUBvl.js`).then(e=>$(e.ecl)),[])}}),O.of({name:`edn`,extensions:[`edn`],load(){return Q(()=>import(`./clojure-DsDsbt3V.js`).then(e=>$(e.clojure)),[])}}),O.of({name:`Eiffel`,extensions:[`e`],load(){return Q(()=>import(`./eiffel-DBpGy7gs.js`).then(e=>$(e.eiffel)),[])}}),O.of({name:`Elm`,extensions:[`elm`],load(){return Q(()=>import(`./elm-Dj_ZNWRH.js`).then(e=>$(e.elm)),[])}}),O.of({name:`Erlang`,extensions:[`erl`],load(){return Q(()=>import(`./erlang-Br4TQPB7.js`).then(e=>$(e.erlang)),[])}}),O.of({name:`Esper`,load(){return Q(()=>import(`./sql-C_mHN2XB.js`).then(e=>$(e.esper)),[])}}),O.of({name:`Factor`,extensions:[`factor`],load(){return Q(()=>import(`./factor-bi5FmZTz.js`).then(e=>$(e.factor)),__vite__mapDeps([23,22]))}}),O.of({name:`FCL`,load(){return Q(()=>import(`./fcl-Dh6ibuJG.js`).then(e=>$(e.fcl)),[])}}),O.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return Q(()=>import(`./forth-fmpuPpMA.js`).then(e=>$(e.forth)),[])}}),O.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return Q(()=>import(`./fortran-CZwiXuJZ.js`).then(e=>$(e.fortran)),[])}}),O.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return Q(()=>import(`./mllike-DsgO-njf.js`).then(e=>$(e.fSharp)),[])}}),O.of({name:`Gas`,extensions:[`s`],load(){return Q(()=>import(`./gas-DotCoURX.js`).then(e=>$(e.gas)),[])}}),O.of({name:`Gherkin`,extensions:[`feature`],load(){return Q(()=>import(`./gherkin-Bw4mmeRF.js`).then(e=>$(e.gherkin)),[])}}),O.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return Q(()=>import(`./groovy-D7xek06K.js`).then(e=>$(e.groovy)),[])}}),O.of({name:`Haskell`,extensions:[`hs`],load(){return Q(()=>import(`./haskell-D5bv2Ijt.js`).then(e=>$(e.haskell)),[])}}),O.of({name:`Haxe`,extensions:[`hx`],load(){return Q(()=>import(`./haxe-UA0z6FgT.js`).then(e=>$(e.haxe)),[])}}),O.of({name:`HXML`,extensions:[`hxml`],load(){return Q(()=>import(`./haxe-UA0z6FgT.js`).then(e=>$(e.hxml)),[])}}),O.of({name:`HTTP`,load(){return Q(()=>import(`./http-DAkDDIPY.js`).then(e=>$(e.http)),[])}}),O.of({name:`IDL`,extensions:[`pro`],load(){return Q(()=>import(`./idl-DYj57TA2.js`).then(e=>$(e.idl)),[])}}),O.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return Q(()=>import(`./javascript-B9Zm1tmO.js`).then(e=>$(e.jsonld)),[])}}),O.of({name:`Julia`,extensions:[`jl`],load(){return Q(()=>import(`./julia-CpHdnx_N.js`).then(e=>$(e.julia)),[])}}),O.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.kotlin)),[])}}),O.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return Q(()=>import(`./livescript-DcEJKRZ4.js`).then(e=>$(e.liveScript)),[])}}),O.of({name:`Lua`,extensions:[`lua`],load(){return Q(()=>import(`./lua-s-LPZohT.js`).then(e=>$(e.lua)),[])}}),O.of({name:`mIRC`,extensions:[`mrc`],load(){return Q(()=>import(`./mirc-pTdL1Ym3.js`).then(e=>$(e.mirc)),[])}}),O.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return Q(()=>import(`./mathematica-c8TKcpav.js`).then(e=>$(e.mathematica)),[])}}),O.of({name:`Modelica`,extensions:[`mo`],load(){return Q(()=>import(`./modelica-PhVkZonB.js`).then(e=>$(e.modelica)),[])}}),O.of({name:`MUMPS`,extensions:[`mps`],load(){return Q(()=>import(`./mumps-DhD4kjw9.js`).then(e=>$(e.mumps)),[])}}),O.of({name:`Mbox`,extensions:[`mbox`],load(){return Q(()=>import(`./mbox-CUr7-CiI.js`).then(e=>$(e.mbox)),[])}}),O.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return Q(()=>import(`./nginx-CJc6p_yt.js`).then(e=>$(e.nginx)),[])}}),O.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return Q(()=>import(`./nsis-BHchP6IS.js`).then(e=>$(e.nsis)),__vite__mapDeps([24,22]))}}),O.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return Q(()=>import(`./ntriples-D1v3iWDa.js`).then(e=>$(e.ntriples)),[])}}),O.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.objectiveC)),[])}}),O.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.objectiveCpp)),[])}}),O.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return Q(()=>import(`./mllike-DsgO-njf.js`).then(e=>$(e.oCaml)),[])}}),O.of({name:`Octave`,extensions:[`m`],load(){return Q(()=>import(`./octave-D_WvWxqk.js`).then(e=>$(e.octave)),[])}}),O.of({name:`Oz`,extensions:[`oz`],load(){return Q(()=>import(`./oz-CmdX4m3g.js`).then(e=>$(e.oz)),[])}}),O.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return Q(()=>import(`./pascal-hNOkBp6J.js`).then(e=>$(e.pascal)),[])}}),O.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return Q(()=>import(`./perl-NQdG1b_r.js`).then(e=>$(e.perl)),[])}}),O.of({name:`Pig`,extensions:[`pig`],load(){return Q(()=>import(`./pig-CXzedlZV.js`).then(e=>$(e.pig)),[])}}),O.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return Q(()=>import(`./powershell-RXDVpFWf.js`).then(e=>$(e.powerShell)),[])}}),O.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return Q(()=>import(`./properties-BTvtucqR.js`).then(e=>$(e.properties)),[])}}),O.of({name:`ProtoBuf`,extensions:[`proto`],load(){return Q(()=>import(`./protobuf-zHRYyuba.js`).then(e=>$(e.protobuf)),[])}}),O.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return Q(()=>import(`./pug-C39WZDG2.js`).then(e=>$(e.pug)),__vite__mapDeps([25,26]))}}),O.of({name:`Puppet`,extensions:[`pp`],load(){return Q(()=>import(`./puppet-CMNLsBcD.js`).then(e=>$(e.puppet)),[])}}),O.of({name:`Q`,extensions:[`q`],load(){return Q(()=>import(`./q-SLmsw_60.js`).then(e=>$(e.q)),[])}}),O.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return Q(()=>import(`./r-CocOMjw8.js`).then(e=>$(e.r)),[])}}),O.of({name:`RPM Changes`,load(){return Q(()=>import(`./rpm-WgkTpiCm.js`).then(e=>$(e.rpmChanges)),[])}}),O.of({name:`RPM Spec`,extensions:[`spec`],load(){return Q(()=>import(`./rpm-WgkTpiCm.js`).then(e=>$(e.rpmSpec)),[])}}),O.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return Q(()=>import(`./ruby-DquNeiGE.js`).then(e=>$(e.ruby)),[])}}),O.of({name:`SAS`,extensions:[`sas`],load(){return Q(()=>import(`./sas-sJxciv6G.js`).then(e=>$(e.sas)),[])}}),O.of({name:`Scala`,extensions:[`scala`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.scala)),[])}}),O.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return Q(()=>import(`./scheme-DEjJDX5Z.js`).then(e=>$(e.scheme)),[])}}),O.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return Q(()=>import(`./shell-DhAwSAum.js`).then(e=>$(e.shell)),[])}}),O.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return Q(()=>import(`./sieve-CcW8-k2R.js`).then(e=>$(e.sieve)),[])}}),O.of({name:`Smalltalk`,extensions:[`st`],load(){return Q(()=>import(`./smalltalk-nXkQ5zwM.js`).then(e=>$(e.smalltalk)),[])}}),O.of({name:`Solr`,load(){return Q(()=>import(`./solr-DO54nYOg.js`).then(e=>$(e.solr)),[])}}),O.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return Q(()=>import(`./mllike-DsgO-njf.js`).then(e=>$(e.sml)),[])}}),O.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return Q(()=>import(`./sparql-CxAS_pwk.js`).then(e=>$(e.sparql)),[])}}),O.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return Q(()=>import(`./spreadsheet-DWzAMKF2.js`).then(e=>$(e.spreadsheet)),[])}}),O.of({name:`Squirrel`,extensions:[`nut`],load(){return Q(()=>import(`./clike-DQfG49Bz.js`).then(e=>$(e.squirrel)),[])}}),O.of({name:`Stylus`,extensions:[`styl`],load(){return Q(()=>import(`./stylus-CQ8h_EBd.js`).then(e=>$(e.stylus)),[])}}),O.of({name:`Swift`,extensions:[`swift`],load(){return Q(()=>import(`./swift-D0Eq5raO.js`).then(e=>$(e.swift)),[])}}),O.of({name:`sTeX`,load(){return Q(()=>import(`./stex-BmuQ0Xsx.js`).then(e=>$(e.stex)),[])}}),O.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return Q(()=>import(`./stex-BmuQ0Xsx.js`).then(e=>$(e.stex)),[])}}),O.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return Q(()=>import(`./verilog-B0DGHLZN.js`).then(e=>$(e.verilog)),[])}}),O.of({name:`Tcl`,extensions:[`tcl`],load(){return Q(()=>import(`./tcl-D7utka2n.js`).then(e=>$(e.tcl)),[])}}),O.of({name:`Textile`,extensions:[`textile`],load(){return Q(()=>import(`./textile-XEeoev-k.js`).then(e=>$(e.textile)),[])}}),O.of({name:`TiddlyWiki`,load(){return Q(()=>import(`./tiddlywiki-CecErCuV.js`).then(e=>$(e.tiddlyWiki)),[])}}),O.of({name:`Tiki wiki`,load(){return Q(()=>import(`./tiki-BlL-kki4.js`).then(e=>$(e.tiki)),[])}}),O.of({name:`TOML`,extensions:[`toml`],load(){return Q(()=>import(`./toml-mmtg9INI.js`).then(e=>$(e.toml)),[])}}),O.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return Q(()=>import(`./troff-Crc1ZuaH.js`).then(e=>$(e.troff)),[])}}),O.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return Q(()=>import(`./ttcn-Cri02b1f.js`).then(e=>$(e.ttcn)),[])}}),O.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return Q(()=>import(`./ttcn-cfg--4YiJN4x.js`).then(e=>$(e.ttcnCfg)),[])}}),O.of({name:`Turtle`,extensions:[`ttl`],load(){return Q(()=>import(`./turtle-CUuoUr2N.js`).then(e=>$(e.turtle)),[])}}),O.of({name:`Web IDL`,extensions:[`webidl`],load(){return Q(()=>import(`./webidl-C_bKeJT2.js`).then(e=>$(e.webIDL)),[])}}),O.of({name:`VB.NET`,extensions:[`vb`],load(){return Q(()=>import(`./vb-BrHulZxe.js`).then(e=>$(e.vb)),[])}}),O.of({name:`VBScript`,extensions:[`vbs`],load(){return Q(()=>import(`./vbscript-vyHcteNE.js`).then(e=>$(e.vbScript)),[])}}),O.of({name:`Velocity`,extensions:[`vtl`],load(){return Q(()=>import(`./velocity-DN4o8rq-.js`).then(e=>$(e.velocity)),[])}}),O.of({name:`Verilog`,extensions:[`v`],load(){return Q(()=>import(`./verilog-B0DGHLZN.js`).then(e=>$(e.verilog)),[])}}),O.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return Q(()=>import(`./vhdl-WeAF-qEm.js`).then(e=>$(e.vhdl)),[])}}),O.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return Q(()=>import(`./xquery-CLyH3kVm.js`).then(e=>$(e.xQuery)),[])}}),O.of({name:`Yacas`,extensions:[`ys`],load(){return Q(()=>import(`./yacas-Dq3LuV9B.js`).then(e=>$(e.yacas)),[])}}),O.of({name:`Z80`,extensions:[`z80`],load(){return Q(()=>import(`./z80-Br7weo_y.js`).then(e=>$(e.z80)),[])}}),O.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return Q(()=>import(`./mscgen-ByD0zE8S.js`).then(e=>$(e.mscgen)),[])}}),O.of({name:`Xù`,extensions:[`xu`],load(){return Q(()=>import(`./mscgen-ByD0zE8S.js`).then(e=>$(e.xu)),[])}}),O.of({name:`MsGenny`,extensions:[`msgenny`],load(){return Q(()=>import(`./mscgen-ByD0zE8S.js`).then(e=>$(e.msgenny)),[])}}),O.of({name:`Vue`,extensions:[`vue`],load(){return Q(()=>import(`./dist-B4-hQjtE.js`).then(e=>e.vue()),__vite__mapDeps([27,4,1,2,6,7]))}}),O.of({name:`Angular Template`,load(){return Q(()=>import(`./dist-BDEXao6W.js`).then(e=>e.angular()),__vite__mapDeps([28,4,1,2,6,7]))}})];function Lk(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
210
210
|
font-size: .6rem;
|
|
211
211
|
font-weight: bold;
|
|
212
|
-
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function Lk(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var Rk=(e,t)=>Math.abs(e-t)<1.01,zk=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},Bk=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Vk=e=>e,Hk=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Uk=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Bk(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Bk(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Wk={passive:!0},Gk=typeof window>`u`?!0:`onscrollend`in window,Kk=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&Gk?()=>void 0:zk(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,Wk);let l=e.options.useScrollendEvent&&Gk;return l&&n.addEventListener(`scrollend`,c,Wk),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},qk=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Jk=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},Yk=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Vk,rangeExtractor:Hk,onChange:()=>{},measureElement:qk,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Ik(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=Ik(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=Ik(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Ik(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Zk({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Ik(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=Ik(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return Lk(t[Xk(0,t.length-1,e=>Lk(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&Rk(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},Xk=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Zk({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=Xk(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Qk=typeof document<`u`?I.useLayoutEffect:I.useEffect;function $k({useFlushSync:e=!0,...t}){let n=I.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Fa.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=I.useState(()=>new Yk(r));return i.setOptions(r),Qk(()=>i._didMount(),[]),Qk(()=>i._willUpdate()),i}function eA(e){return $k({observeElementRect:Uk,observeElementOffset:Kk,scrollToFn:Jk,...e})}var tA=u.theme({"&":{height:`100%`,color:`var(--file-editor-ink)`,backgroundColor:`var(--file-editor-surface)`},"&.cm-focused":{outline:`none`},".cm-scroller":{overflow:`auto`,fontFamily:`var(--mono)`,lineHeight:`1.72`},".cm-content":{minHeight:`100%`,padding:`14px 0 24px`,caretColor:`var(--file-editor-caret)`},".cm-line":{padding:`0 20px 0 16px`},".cm-gutters":{backgroundColor:`var(--file-editor-gutter)`,color:`var(--file-editor-muted)`,borderRight:`1px solid var(--file-editor-rule)`},".cm-lineNumbers .cm-gutterElement":{padding:`0 12px 0 16px`,minWidth:`42px`},".cm-activeLine":{backgroundColor:`var(--file-editor-active)`},".cm-activeLineGutter":{color:`var(--file-editor-ink)`,backgroundColor:`transparent`},".cm-selectionBackground, &.cm-focused .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`var(--file-editor-selection)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--file-editor-caret)`},".cm-searchMatch":{backgroundColor:`rgb(255 214 102 / 16%)`,outline:`1px solid rgb(255 214 102 / 18%)`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`rgb(255 214 102 / 26%)`},".cm-tooltip":{border:`1px solid var(--file-editor-rule)`,borderRadius:`10px`,backgroundColor:`rgb(11 15 27 / 98%)`,boxShadow:`0 20px 48px rgb(0 0 0 / 38%)`},".cm-panels":{backgroundColor:`rgb(11 15 27 / 96%)`,borderBottom:`1px solid var(--file-editor-rule)`}},{dark:!0}),nA=xe.define([{tag:g.keyword,color:`#c792ea`},{tag:[g.name,g.deleted,g.character,g.propertyName,g.macroName],color:`#82aaff`},{tag:[g.function(g.variableName),g.labelName],color:`#82aaff`},{tag:[g.color,g.constant(g.name),g.standard(g.name)],color:`#f78c6c`},{tag:[g.definition(g.name),g.separator],color:`#eeffff`},{tag:[g.className,g.typeName],color:`#ffcb6b`},{tag:[g.number,g.changed,g.annotation,g.modifier,g.self,g.namespace],color:`#f78c6c`},{tag:[g.operator,g.operatorKeyword],color:`#89ddff`},{tag:[g.url,g.escape,g.regexp,g.link],color:`#80cbc4`},{tag:[g.meta,g.comment],color:`#637777`,fontStyle:`italic`},{tag:[g.string,g.inserted],color:`#c3e88d`},{tag:[g.invalid],color:`#ff5370`},{tag:[g.bool,g.null],color:`#f78c6c`},{tag:g.heading,color:`#82aaff`,fontWeight:`700`},{tag:g.emphasis,fontStyle:`italic`},{tag:g.strong,fontWeight:`700`},{tag:g.strikethrough,textDecoration:`line-through`}]),rA=(0,I.memo)(function({breadcrumbs:e,currentPath:t,directoryEntries:n,editorPath:r,loading:i,mentionedPaths:a,modifiedByPath:o,onNavigate:s,onOpenEntry:c,parentPath:l,rootPath:u}){let d=(0,I.useRef)(null),f=eA({count:n.length,getScrollElement:()=>d.current,estimateSize:()=>38,overscan:10});return(0,I.useEffect)(()=>{let e=d.current;e&&(e.scrollTop=0)},[t]),(0,L.jsxs)(`div`,{className:`file-explorer-panel`,children:[(0,L.jsxs)(`div`,{className:`panel-head-row`,children:[l?(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>s(l),children:`← Back`}):null,(0,L.jsxs)(`div`,{className:`panel-hint`,children:[`📁 `,t,` · `,o.size,` modified`]})]}),(0,L.jsx)(`div`,{className:`file-breadcrumbs`,children:e.map(e=>(0,L.jsx)(`button`,{className:H(`file-crumb`,e.path===t&&`active`),type:`button`,onClick:()=>s(e.path),children:e.label},e.path))}),i?(0,L.jsx)(`div`,{className:`empty-panel`,children:`Loading files for this directory…`}):null,!i&&n.length===0?(0,L.jsx)(`div`,{className:`empty-panel`,children:`No direct files or folders found in this directory.`}):null,!i&&n.length>0?(0,L.jsx)(`div`,{className:`file-explorer-scroll`,ref:d,children:(0,L.jsx)(`div`,{className:`file-explorer-list`,role:`presentation`,style:{height:`${f.getTotalSize()}px`},children:f.getVirtualItems().map(e=>{let t=n[e.index];if(!t)return null;let i=t.path.startsWith(`${u}/`)?t.path.slice(u.length+1):t.name,s=o.get(t.name)??o.get(i),l=a.has(t.path);return(0,L.jsxs)(`button`,{className:H(`fi file-explorer-row`,t.kind===`directory`&&`dir`,s===`mod`&&`active`,l&&`mentioned`,r===t.path&&`open`),type:`button`,onClick:()=>void c(t),style:{transform:`translateY(${e.start}px)`},children:[(0,L.jsx)(`span`,{children:t.kind===`directory`?`📁`:`📄`}),(0,L.jsx)(`span`,{className:`fi-n`,children:t.name}),l?(0,L.jsx)(`span`,{className:`fbdg mention`,children:`@`}):null,s?(0,L.jsx)(`span`,{className:H(`fbdg`,s),children:s}):null]},t.id)})})}):null,(0,L.jsxs)(`div`,{className:`panel-meta`,children:[(0,L.jsx)(`div`,{children:`Tap a file to open the full editor. Tap folders to drill in.`}),(0,L.jsxs)(`div`,{children:[`Use `,(0,L.jsx)(`code`,{children:`/mention filename`}),` or type `,(0,L.jsx)(`code`,{children:`@filename`}),` in the composer.`]})]})]})});function iA({activePath:e,breadcrumbs:t,busy:n,entries:r,loading:i,onClose:a,onNavigate:o,onPick:s,parentPath:c}){return(0,L.jsx)(`div`,{className:`project-picker-overlay`,onClick:e=>{e.target===e.currentTarget&&a()},children:(0,L.jsxs)(`div`,{className:`project-picker-modal`,children:[(0,L.jsxs)(`div`,{className:`project-picker-head`,children:[(0,L.jsxs)(`div`,{className:`project-picker-copy`,children:[(0,L.jsx)(`div`,{className:`project-picker-title`,children:`Start New Session`}),(0,L.jsx)(`div`,{className:`project-picker-subtitle`,children:`Pick the project folder to use as this session's working directory.`})]}),(0,L.jsx)(`button`,{"aria-label":`Close project picker`,className:`project-picker-close`,disabled:n,onClick:a,type:`button`,children:`×`})]}),(0,L.jsx)(`div`,{className:`project-picker-breadcrumbs`,children:t.map(t=>(0,L.jsx)(`button`,{className:H(`project-picker-crumb`,t.path===e&&`active`),disabled:n,onClick:()=>o(t.path),type:`button`,children:t.label},t.path))}),(0,L.jsxs)(`div`,{className:`project-picker-toolbar`,children:[c?(0,L.jsx)(`button`,{className:`project-picker-action`,disabled:n,onClick:()=>o(c),type:`button`,children:`← Up`}):(0,L.jsx)(`span`,{className:`project-picker-root`,children:`Root`}),(0,L.jsx)(`button`,{className:`project-picker-start`,disabled:n||i,onClick:()=>s(e),type:`button`,children:n?`Starting…`:`Use This Folder`})]}),(0,L.jsx)(`div`,{className:`project-picker-current`,children:e}),(0,L.jsx)(`div`,{className:`project-picker-list`,children:i?(0,L.jsx)(`div`,{className:`project-picker-empty`,children:`Loading folders…`}):r.length===0?(0,L.jsx)(`div`,{className:`project-picker-empty`,children:`No folders found here.`}):r.map(e=>(0,L.jsxs)(`button`,{className:`project-picker-entry`,disabled:n,onClick:()=>o(e.path),type:`button`,children:[(0,L.jsx)(`span`,{className:`project-picker-entry-icon`,children:`📁`}),(0,L.jsxs)(`span`,{className:`project-picker-entry-copy`,children:[(0,L.jsx)(`span`,{className:`project-picker-entry-name`,children:e.name}),(0,L.jsx)(`span`,{className:`project-picker-entry-path`,children:e.path})]}),(0,L.jsx)(`span`,{className:`project-picker-entry-arrow`,children:`→`})]},e.id))})]})})}function aA({messages:e,onSteer:t,onDelete:n}){return e.length===0?null:(0,L.jsx)(`div`,{className:`queued-messages`,children:(0,L.jsx)(`div`,{className:`queued-messages-inner`,children:e.map(e=>{let r=e.prompt.trim()||[e.images.length>0?`${e.images.length} image`:``,e.files.length>0?`${e.files.length} upload`:``,e.mentions.length>0?`${e.mentions.length} file`:``,e.skills.length>0?`${e.skills.length} skill`:``].filter(Boolean).join(` · `);return(0,L.jsxs)(`div`,{className:`queued-row`,children:[(0,L.jsx)(`span`,{className:`queued-row-icon`,children:`💬`}),(0,L.jsx)(`span`,{className:`queued-row-text`,children:Hd(r||`Queued follow-up`,96)}),(0,L.jsxs)(`div`,{className:`queued-row-actions`,children:[(0,L.jsx)(`button`,{className:`queued-row-steer`,type:`button`,onClick:()=>t(e.id),children:`Steer`}),(0,L.jsx)(`button`,{"aria-label":`Delete queued message`,className:`queued-row-delete`,type:`button`,onClick:()=>n(e.id),children:`×`})]})]},e.id)})})})}var oA=(0,I.memo)(function({value:e,mentions:t,placeholder:n,textareaRef:r,composerMirrorRef:i,onPaste:a,onValueChange:o,onKeyDown:s}){let[c,l]=(0,I.useState)(e),u=(0,I.useMemo)(()=>t.filter(e=>$d(c,e)),[c,t]),d=(0,I.useMemo)(()=>u.length>0?tf(c,u):[],[u,c]),f=(0,I.useCallback)(()=>{if(u.length===0)return;let e=r.current,t=i.current;!e||!t||(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft)},[u.length,i,r]);(0,I.useEffect)(()=>{let e=r.current;e&&(e.style.height=`auto`,e.style.height=`${Math.max(60,Math.min(e.scrollHeight,140))}px`,f())},[60,c,f,r]);let p=(0,I.useCallback)(e=>{let t=e.target.value;l(t),o(t)},[o]);return(0,L.jsxs)(`div`,{className:`composer-text-shell`,children:[u.length>0?(0,L.jsx)(`div`,{className:`composer-mirror`,ref:i,"aria-hidden":`true`,children:c?d.map((e,t)=>(0,L.jsx)(`span`,{className:H(`composer-segment`,e.mention&&`file`),children:e.text},`${e.text}-${t}`)):null}):null,c?null:(0,L.jsx)(`span`,{className:`composer-placeholder`,children:n}),(0,L.jsx)(`textarea`,{id:`ta`,ref:r,rows:3,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,placeholder:``,spellCheck:!1,value:c,onChange:p,onKeyDown:s,onPaste:a,onScroll:f})]})});function sA({entry:e}){let t=Sf(e.diff);return t.length===0?(0,L.jsx)(`div`,{className:`diff-patch-empty`,children:`Waiting for diff…`}):(0,L.jsx)(`div`,{className:`diff-patch-viewer`,children:t.map(e=>(0,L.jsxs)(`div`,{className:H(`diff-patch-row`,e.kind),children:[(0,L.jsx)(`span`,{className:`diff-patch-num`,children:e.oldLine??``}),(0,L.jsx)(`span`,{className:`diff-patch-num`,children:e.newLine??``}),(0,L.jsx)(`pre`,{className:`diff-patch-text`,children:e.text||` `})]},e.id))})}function cA({backLabel:e=`Back to Chat`,diffEntries:t,findings:n,onBack:r,onSelectEntry:i,selectedEntryId:a}){let o=(0,I.useMemo)(()=>t.find(e=>e.id===a)??t[0]??null,[t,a]),s=(0,I.useMemo)(()=>t.reduce((e,t)=>e+t.additions,0),[t]),c=(0,I.useMemo)(()=>t.reduce((e,t)=>e+t.removals,0),[t]);return(0,L.jsx)(`div`,{id:`review-page`,children:(0,L.jsxs)(`div`,{className:`diff-review-shell page`,children:[(0,L.jsxs)(`div`,{className:`diff-review-page-head`,children:[(0,L.jsxs)(`button`,{className:`file-editor-back`,onClick:r,type:`button`,children:[`← `,e]}),(0,L.jsxs)(`div`,{className:`diff-review-page-copy`,children:[(0,L.jsx)(`div`,{className:`diff-review-page-title`,children:`Patch review`}),(0,L.jsxs)(`div`,{className:`diff-review-page-subtitle`,children:[t.length,` changed file`,t.length===1?``:`s`,` · +`,s,` / -`,c]})]})]}),t.length===0?(0,L.jsx)(`div`,{className:`empty-panel`,children:`No diff items in this thread yet.`}):(0,L.jsxs)(`div`,{className:`diff-review-layout page`,children:[(0,L.jsx)(`div`,{className:`diff-review-sidebar`,children:t.map(e=>(0,L.jsxs)(`button`,{className:H(`diff-review-entry`,o?.id===e.id&&`active`),type:`button`,onClick:()=>i(e.id),children:[(0,L.jsxs)(`div`,{className:`diff-review-entry-top`,children:[(0,L.jsx)(`span`,{className:H(`diff-kind-pill`,e.kind.type===`add`&&`new`,e.kind.type===`delete`&&`del`),children:bf(e.kind)}),(0,L.jsx)(`span`,{className:H(`diff-status`,e.status===`inProgress`&&`live`,e.status===`failed`&&`err`),children:e.status===`inProgress`?`editing`:e.status})]}),(0,L.jsx)(`div`,{className:`diff-review-entry-path`,children:e.path}),(0,L.jsxs)(`div`,{className:`diff-review-entry-meta`,children:[(0,L.jsxs)(`span`,{children:[`+`,e.additions]}),(0,L.jsxs)(`span`,{children:[`-`,e.removals]}),(0,L.jsxs)(`span`,{children:[e.hunks,` hunk`,e.hunks===1?``:`s`]})]})]},e.id))}),o?(0,L.jsxs)(`div`,{className:`diff-review-main`,children:[(0,L.jsxs)(`div`,{className:`diff-focus-head`,children:[(0,L.jsx)(`div`,{className:`diff-focus-title`,children:o.path}),(0,L.jsxs)(`div`,{className:`diff-focus-meta`,children:[(0,L.jsx)(`span`,{className:H(`diff-kind-pill`,o.kind.type===`add`&&`new`,o.kind.type===`delete`&&`del`),children:bf(o.kind)}),(0,L.jsx)(`span`,{className:H(`diff-status`,o.status===`inProgress`&&`live`,o.status===`failed`&&`err`),children:o.status===`inProgress`?`editing`:o.status}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[`+`,o.additions]}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[`-`,o.removals]}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[o.hunks,` hunk`,o.hunks===1?``:`s`]})]})]}),(0,L.jsx)(sA,{entry:o})]}):null]}),n.length>0?(0,L.jsx)(`div`,{className:`review-list`,children:n.map(e=>(0,L.jsxs)(`div`,{className:H(`review-item`,e.severity),children:[(0,L.jsxs)(`div`,{className:`review-header`,children:[(0,L.jsx)(`span`,{children:e.severity}),(0,L.jsx)(`span`,{children:e.file.split(`/`).slice(-2).join(`/`)}),(0,L.jsxs)(`span`,{children:[`:`,e.line]})]}),(0,L.jsx)(`div`,{className:`review-title`,children:e.title}),(0,L.jsx)(`div`,{className:`review-summary`,children:e.summary})]},e.id))}):null]})})}function lA({preview:e,variant:n=`panel`,onBack:r,backLabel:i=`Back`,onSave:a,providerId:o}){let s=hs(e.path,o),c=(0,I.useRef)(null),[l,d]=(0,I.useState)(e.content),[f,p]=(0,I.useState)(e.content),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)(`Plain text`),[b,x]=(0,I.useState)(null),S=l!==f;(0,I.useEffect)(()=>{d(e.content),p(e.content),h(null),_(!1)},[e.content,e.error,e.loading,e.path]),(0,I.useEffect)(()=>{let t=e.path||e.name,n=O.matchFilename(Fk,t),r=!1;if(x(null),y(n?.name??`Plain text`),n)return n.load().then(e=>{r||x(e.extension)}).catch(()=>{r||x(null)}),()=>{r=!0}},[e.name,e.path]);let C=(0,I.useCallback)(async()=>{if(!(!a||e.loading||e.error||g||!S)){_(!0),h(null);try{await a(e.path,l),p(l)}catch(e){h(e instanceof Error?e.message:`Unable to save this file.`)}finally{_(!1)}}},[l,S,g,a,e.error,e.loading,e.path]),w=(0,I.useMemo)(()=>{let e=[tA,t(nA),j.of([{key:`Mod-s`,preventDefault:!0,run:()=>(C(),!0)}])];return b&&e.push(b),e},[b,C]);(0,I.useEffect)(()=>{let t=c.current;if(!(!t||e.loading||e.error)){if(typeof e.line==`number`&&e.line>0){let n=t.state.doc.line(Math.min(e.line,t.state.doc.lines));t.dispatch({selection:{anchor:n.from},effects:u.scrollIntoView(n.from,{y:`center`})});return}t.scrollDOM.scrollTo({left:0,top:0})}},[e.error,e.line,e.loading,e.path]);let T=(0,I.useCallback)(()=>{r&&(S&&typeof window<`u`&&!window.confirm(`Discard unsaved changes to ${e.name}?`)||r())},[S,r,e.name]),E=g?`Saving…`:S?`Save`:`Saved`,D=m?`Save failed`:g?`Saving`:S?`Unsaved`:`Saved`;return(0,L.jsxs)(`div`,{className:H(`file-editor`,n===`page`&&`page`),children:[(0,L.jsxs)(`div`,{className:`file-editor-head`,children:[n===`page`?(0,L.jsxs)(`button`,{className:`file-editor-back`,onClick:T,type:`button`,children:[`← `,i]}):null,(0,L.jsxs)(`div`,{className:`file-editor-copy`,children:[(0,L.jsx)(`div`,{className:`file-editor-title`,children:e.name}),(0,L.jsx)(`div`,{className:`file-editor-path`,children:e.path})]}),(0,L.jsxs)(`div`,{className:`file-editor-actions`,children:[(0,L.jsxs)(`div`,{className:`file-editor-meta`,children:[(0,L.jsx)(`span`,{className:`file-editor-chip`,children:v}),typeof e.line==`number`&&e.line>0?(0,L.jsxs)(`span`,{className:`file-editor-chip`,children:[`Line `,e.line]}):null,(0,L.jsx)(`span`,{className:H(`file-editor-status`,S&&`dirty`,m&&`error`),children:D})]}),s===`#`?null:(0,L.jsx)(`a`,{className:`file-editor-link`,href:s,rel:`noreferrer noopener`,target:`_blank`,children:`Raw`}),(0,L.jsx)(`button`,{className:`file-editor-save`,disabled:!a||e.loading||!!e.error||g||!S,onClick:()=>void C(),type:`button`,children:E})]})]}),(0,L.jsxs)(`div`,{className:`file-editor-body`,children:[e.loading?(0,L.jsx)(`div`,{className:`file-editor-empty`,children:`Opening file…`}):null,!e.loading&&e.error?(0,L.jsx)(`div`,{className:`file-editor-empty`,children:e.error}):null,!e.loading&&!e.error?(0,L.jsx)(Ak,{className:`file-editor-surface`,editable:!!a,extensions:w,height:`100%`,onChange:e=>{d(e),m&&h(null)},onCreateEditor:e=>{c.current=e},value:l}):null]})]})}var uA=`materializedThreadId`,dA=e=>{if(!e||typeof e!=`object`)return null;let t=e[uA];return typeof t==`string`?t:null},fA=(e,t)=>Object.fromEntries((e.questions??[]).map(e=>[e.id,[(t[e.id]??``).trim()].filter(Boolean)])),pA=(0,I.createContext)(null),mA=Sc(),hA=mA.mentionCatalog,gA=mA.directoryCatalogRoot||`.`,_A=18,vA=14,yA=[`Opening workspace`,`Setting environment`,`Initializing modules`,`Starting services`],bA=[`Opening conversation`,`Reattaching thread`,`Loading recent history`,`Syncing transcript`],xA=[...yA,...bA];function SA({name:e,className:t}){let n=H(`chrome-icon`,t);switch(e){case`auto`:return(0,L.jsx)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:`m8.1 1.4-1.7 4 2.3.3-1 4.9 3.9-6-2.4-.3 1.5-3Z`})});case`plan`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M4 3.5v9`}),(0,L.jsx)(`path`,{d:`M4 5h5`}),(0,L.jsx)(`path`,{d:`M4 8h7`}),(0,L.jsx)(`path`,{d:`M4 11h4`}),(0,L.jsx)(`circle`,{cx:`11.5`,cy:`8`,r:`1.5`})]});case`mention`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.3`}),(0,L.jsx)(`path`,{d:`M10.8 10.1a2.3 2.3 0 1 1 .4-4.6v3.6c0 .7.4 1 1 1 .9 0 1.4-.8 1.4-2.1A5.4 5.4 0 1 0 8 13.4`})]});case`attach`:return(0,L.jsx)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:`m6 8.5 3.8-3.8a2 2 0 1 1 2.8 2.8L7.9 12.2A3 3 0 0 1 3.6 8l4.3-4.3`})});case`image`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`rect`,{x:`2.5`,y:`3`,width:`11`,height:`10`,rx:`2`}),(0,L.jsx)(`circle`,{cx:`6`,cy:`6.5`,r:`1`}),(0,L.jsx)(`path`,{d:`m4.5 11 2.4-2.4 1.9 1.9 1.4-1.4 1.3 1.9`})]});case`terminal`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`rect`,{x:`2.5`,y:`3`,width:`11`,height:`10`,rx:`2`}),(0,L.jsx)(`path`,{d:`m5.3 6 1.8 1.8-1.8 1.8`}),(0,L.jsx)(`path`,{d:`M8.7 9.8h2.2`})]});case`web`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.2`}),(0,L.jsx)(`path`,{d:`m10.2 10.2 2.6 2.6`})]});case`review`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M4.5 2.8h5l2 2v7.4a1 1 0 0 1-1 1h-6a1 1 0 0 1-1-1V3.8a1 1 0 0 1 1-1Z`}),(0,L.jsx)(`path`,{d:`M9.5 2.8v2h2`}),(0,L.jsx)(`path`,{d:`M5.7 8h4.6`}),(0,L.jsx)(`path`,{d:`M5.7 10.3h3.2`})]});case`agents`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`circle`,{cx:`4.2`,cy:`8`,r:`1.5`}),(0,L.jsx)(`circle`,{cx:`11.8`,cy:`5.2`,r:`1.5`}),(0,L.jsx)(`circle`,{cx:`11.8`,cy:`10.8`,r:`1.5`}),(0,L.jsx)(`path`,{d:`M5.5 7.3 10.4 5.8`}),(0,L.jsx)(`path`,{d:`M5.5 8.7 10.4 10.2`})]});case`compact`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M3.5 5h9`}),(0,L.jsx)(`path`,{d:`M3.5 8h6`}),(0,L.jsx)(`path`,{d:`M3.5 11h9`}),(0,L.jsx)(`path`,{d:`m11 6.3 1.8 1.7L11 9.7`})]});case`editor`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M4.4 11.6 11.6 4.4`}),(0,L.jsx)(`path`,{d:`m10.4 3.6 2 2`}),(0,L.jsx)(`path`,{d:`M4 12.2 3.6 13l.8-.4 1.4-.3-.8-.8Z`}),(0,L.jsx)(`path`,{d:`M3.5 3.4h5.2`})]});case`send`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`m8 12.7-.1-8.8`}),(0,L.jsx)(`path`,{d:`m5.3 6.1 2.6-2.8 2.8 2.8`})]});case`stop`:return(0,L.jsx)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,L.jsx)(`rect`,{x:`4.6`,y:`4.6`,width:`6.8`,height:`6.8`,rx:`1.2`})});case`branch`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`circle`,{cx:`5`,cy:`4`,r:`1.4`}),(0,L.jsx)(`circle`,{cx:`11`,cy:`12`,r:`1.4`}),(0,L.jsx)(`circle`,{cx:`11`,cy:`4`,r:`1.4`}),(0,L.jsx)(`path`,{d:`M5 5.4v4.1c0 1.4 1.1 2.5 2.5 2.5H9.6`}),(0,L.jsx)(`path`,{d:`M5 5.4c0 1.4 1.1 2.5 2.5 2.5H9.6`})]});case`model`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`m8 2.6 4.4 2.5v5L8 12.6l-4.4-2.5v-5Z`}),(0,L.jsx)(`path`,{d:`m8 2.6 4.4 2.5L8 7.6 3.6 5.1Z`}),(0,L.jsx)(`path`,{d:`M8 7.6v5`})]});case`shield`:return(0,L.jsx)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:`M8 2.5 12 4v3.6c0 2.4-1.4 4.2-4 5.9-2.6-1.7-4-3.5-4-5.9V4Z`})})}}var CA=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:e>=1e5?0:1}).format(e),wA=e=>{if(!e)return`workspace`;let t=e.replace(/\/+$/u,``);return t?t.split(`/`).filter(Boolean).at(-1)??t:`workspace`},TA=(e,t)=>{if(t!==null){if(t<=300)return`5h`;if(t>=1440*7)return`Week`}let n=e.trim().toLowerCase();return n.includes(`week`)?`Week`:n.includes(`5`)?`5h`:e},EA=(e,t)=>{let n=0;for(let r of e)for(let e of r.items)switch(e.type){case`userMessage`:n+=Jd(e,t).length;break;case`agentMessage`:case`plan`:n+=e.text.length;break;case`reasoning`:n+=e.summary.join(`
|
|
212
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function Rk(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var zk=(e,t)=>Math.abs(e-t)<1.01,Bk=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},Vk=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Hk=e=>e,Uk=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Wk=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Vk(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Vk(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Gk={passive:!0},Kk=typeof window>`u`?!0:`onscrollend`in window,qk=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&Kk?()=>void 0:Bk(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,Gk);let l=e.options.useScrollendEvent&&Kk;return l&&n.addEventListener(`scrollend`,c,Gk),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},Jk=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Yk=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},Xk=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Hk,rangeExtractor:Uk,onChange:()=>{},measureElement:Jk,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Lk(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=Lk(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=Lk(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Lk(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Qk({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Lk(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=Lk(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return Rk(t[Zk(0,t.length-1,e=>Rk(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&zk(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},Zk=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Qk({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=Zk(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var $k=typeof document<`u`?I.useLayoutEffect:I.useEffect;function eA({useFlushSync:e=!0,...t}){let n=I.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Fa.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=I.useState(()=>new Xk(r));return i.setOptions(r),$k(()=>i._didMount(),[]),$k(()=>i._willUpdate()),i}function tA(e){return eA({observeElementRect:Wk,observeElementOffset:qk,scrollToFn:Yk,...e})}var nA=u.theme({"&":{height:`100%`,color:`var(--file-editor-ink)`,backgroundColor:`var(--file-editor-surface)`},"&.cm-focused":{outline:`none`},".cm-scroller":{overflow:`auto`,fontFamily:`var(--mono)`,lineHeight:`1.72`},".cm-content":{minHeight:`100%`,padding:`14px 0 24px`,caretColor:`var(--file-editor-caret)`},".cm-line":{padding:`0 20px 0 16px`},".cm-gutters":{backgroundColor:`var(--file-editor-gutter)`,color:`var(--file-editor-muted)`,borderRight:`1px solid var(--file-editor-rule)`},".cm-lineNumbers .cm-gutterElement":{padding:`0 12px 0 16px`,minWidth:`42px`},".cm-activeLine":{backgroundColor:`var(--file-editor-active)`},".cm-activeLineGutter":{color:`var(--file-editor-ink)`,backgroundColor:`transparent`},".cm-selectionBackground, &.cm-focused .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`var(--file-editor-selection)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--file-editor-caret)`},".cm-searchMatch":{backgroundColor:`rgb(255 214 102 / 16%)`,outline:`1px solid rgb(255 214 102 / 18%)`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`rgb(255 214 102 / 26%)`},".cm-tooltip":{border:`1px solid var(--file-editor-rule)`,borderRadius:`10px`,backgroundColor:`rgb(11 15 27 / 98%)`,boxShadow:`0 20px 48px rgb(0 0 0 / 38%)`},".cm-panels":{backgroundColor:`rgb(11 15 27 / 96%)`,borderBottom:`1px solid var(--file-editor-rule)`}},{dark:!0}),rA=xe.define([{tag:g.keyword,color:`#c792ea`},{tag:[g.name,g.deleted,g.character,g.propertyName,g.macroName],color:`#82aaff`},{tag:[g.function(g.variableName),g.labelName],color:`#82aaff`},{tag:[g.color,g.constant(g.name),g.standard(g.name)],color:`#f78c6c`},{tag:[g.definition(g.name),g.separator],color:`#eeffff`},{tag:[g.className,g.typeName],color:`#ffcb6b`},{tag:[g.number,g.changed,g.annotation,g.modifier,g.self,g.namespace],color:`#f78c6c`},{tag:[g.operator,g.operatorKeyword],color:`#89ddff`},{tag:[g.url,g.escape,g.regexp,g.link],color:`#80cbc4`},{tag:[g.meta,g.comment],color:`#637777`,fontStyle:`italic`},{tag:[g.string,g.inserted],color:`#c3e88d`},{tag:[g.invalid],color:`#ff5370`},{tag:[g.bool,g.null],color:`#f78c6c`},{tag:g.heading,color:`#82aaff`,fontWeight:`700`},{tag:g.emphasis,fontStyle:`italic`},{tag:g.strong,fontWeight:`700`},{tag:g.strikethrough,textDecoration:`line-through`}]),iA=(0,I.memo)(function({breadcrumbs:e,currentPath:t,directoryEntries:n,editorPath:r,loading:i,mentionedPaths:a,modifiedByPath:o,onNavigate:s,onOpenEntry:c,parentPath:l,rootPath:u}){let d=(0,I.useRef)(null),f=tA({count:n.length,getScrollElement:()=>d.current,estimateSize:()=>38,overscan:10});return(0,I.useEffect)(()=>{let e=d.current;e&&(e.scrollTop=0)},[t]),(0,L.jsxs)(`div`,{className:`file-explorer-panel`,children:[(0,L.jsxs)(`div`,{className:`panel-head-row`,children:[l?(0,L.jsx)(`button`,{className:`mini-action`,type:`button`,onClick:()=>s(l),children:`← Back`}):null,(0,L.jsxs)(`div`,{className:`panel-hint`,children:[`📁 `,t,` · `,o.size,` modified`]})]}),(0,L.jsx)(`div`,{className:`file-breadcrumbs`,children:e.map(e=>(0,L.jsx)(`button`,{className:H(`file-crumb`,e.path===t&&`active`),type:`button`,onClick:()=>s(e.path),children:e.label},e.path))}),i?(0,L.jsx)(`div`,{className:`empty-panel`,children:`Loading files for this directory…`}):null,!i&&n.length===0?(0,L.jsx)(`div`,{className:`empty-panel`,children:`No direct files or folders found in this directory.`}):null,!i&&n.length>0?(0,L.jsx)(`div`,{className:`file-explorer-scroll`,ref:d,children:(0,L.jsx)(`div`,{className:`file-explorer-list`,role:`presentation`,style:{height:`${f.getTotalSize()}px`},children:f.getVirtualItems().map(e=>{let t=n[e.index];if(!t)return null;let i=t.path.startsWith(`${u}/`)?t.path.slice(u.length+1):t.name,s=o.get(t.name)??o.get(i),l=a.has(t.path);return(0,L.jsxs)(`button`,{className:H(`fi file-explorer-row`,t.kind===`directory`&&`dir`,s===`mod`&&`active`,l&&`mentioned`,r===t.path&&`open`),type:`button`,onClick:()=>void c(t),style:{transform:`translateY(${e.start}px)`},children:[(0,L.jsx)(`span`,{children:t.kind===`directory`?`📁`:`📄`}),(0,L.jsx)(`span`,{className:`fi-n`,children:t.name}),l?(0,L.jsx)(`span`,{className:`fbdg mention`,children:`@`}):null,s?(0,L.jsx)(`span`,{className:H(`fbdg`,s),children:s}):null]},t.id)})})}):null,(0,L.jsxs)(`div`,{className:`panel-meta`,children:[(0,L.jsx)(`div`,{children:`Tap a file to open the full editor. Tap folders to drill in.`}),(0,L.jsxs)(`div`,{children:[`Use `,(0,L.jsx)(`code`,{children:`/mention filename`}),` or type `,(0,L.jsx)(`code`,{children:`@filename`}),` in the composer.`]})]})]})});function aA({activePath:e,breadcrumbs:t,busy:n,entries:r,loading:i,onClose:a,onNavigate:o,onPick:s,parentPath:c}){return(0,L.jsx)(`div`,{className:`project-picker-overlay`,onClick:e=>{e.target===e.currentTarget&&a()},children:(0,L.jsxs)(`div`,{className:`project-picker-modal`,children:[(0,L.jsxs)(`div`,{className:`project-picker-head`,children:[(0,L.jsxs)(`div`,{className:`project-picker-copy`,children:[(0,L.jsx)(`div`,{className:`project-picker-title`,children:`Start New Session`}),(0,L.jsx)(`div`,{className:`project-picker-subtitle`,children:`Pick the project folder to use as this session's working directory.`})]}),(0,L.jsx)(`button`,{"aria-label":`Close project picker`,className:`project-picker-close`,disabled:n,onClick:a,type:`button`,children:`×`})]}),(0,L.jsx)(`div`,{className:`project-picker-breadcrumbs`,children:t.map(t=>(0,L.jsx)(`button`,{className:H(`project-picker-crumb`,t.path===e&&`active`),disabled:n,onClick:()=>o(t.path),type:`button`,children:t.label},t.path))}),(0,L.jsxs)(`div`,{className:`project-picker-toolbar`,children:[c?(0,L.jsx)(`button`,{className:`project-picker-action`,disabled:n,onClick:()=>o(c),type:`button`,children:`← Up`}):(0,L.jsx)(`span`,{className:`project-picker-root`,children:`Root`}),(0,L.jsx)(`button`,{className:`project-picker-start`,disabled:n||i,onClick:()=>s(e),type:`button`,children:n?`Starting…`:`Use This Folder`})]}),(0,L.jsx)(`div`,{className:`project-picker-current`,children:e}),(0,L.jsx)(`div`,{className:`project-picker-list`,children:i?(0,L.jsx)(`div`,{className:`project-picker-empty`,children:`Loading folders…`}):r.length===0?(0,L.jsx)(`div`,{className:`project-picker-empty`,children:`No folders found here.`}):r.map(e=>(0,L.jsxs)(`button`,{className:`project-picker-entry`,disabled:n,onClick:()=>o(e.path),type:`button`,children:[(0,L.jsx)(`span`,{className:`project-picker-entry-icon`,children:`📁`}),(0,L.jsxs)(`span`,{className:`project-picker-entry-copy`,children:[(0,L.jsx)(`span`,{className:`project-picker-entry-name`,children:e.name}),(0,L.jsx)(`span`,{className:`project-picker-entry-path`,children:e.path})]}),(0,L.jsx)(`span`,{className:`project-picker-entry-arrow`,children:`→`})]},e.id))})]})})}function oA({messages:e,onSteer:t,onDelete:n}){return e.length===0?null:(0,L.jsx)(`div`,{className:`queued-messages`,children:(0,L.jsx)(`div`,{className:`queued-messages-inner`,children:e.map(e=>{let r=e.prompt.trim()||[e.images.length>0?`${e.images.length} image`:``,e.files.length>0?`${e.files.length} upload`:``,e.mentions.length>0?`${e.mentions.length} file`:``,e.skills.length>0?`${e.skills.length} skill`:``].filter(Boolean).join(` · `);return(0,L.jsxs)(`div`,{className:`queued-row`,children:[(0,L.jsx)(`span`,{className:`queued-row-icon`,children:`💬`}),(0,L.jsx)(`span`,{className:`queued-row-text`,children:Hd(r||`Queued follow-up`,96)}),(0,L.jsxs)(`div`,{className:`queued-row-actions`,children:[(0,L.jsx)(`button`,{className:`queued-row-steer`,type:`button`,onClick:()=>t(e.id),children:`Steer`}),(0,L.jsx)(`button`,{"aria-label":`Delete queued message`,className:`queued-row-delete`,type:`button`,onClick:()=>n(e.id),children:`×`})]})]},e.id)})})})}var sA=(0,I.memo)(function({value:e,mentions:t,placeholder:n,textareaRef:r,composerMirrorRef:i,onPaste:a,onValueChange:o,onKeyDown:s}){let[c,l]=(0,I.useState)(e),u=(0,I.useMemo)(()=>t.filter(e=>$d(c,e)),[c,t]),d=(0,I.useMemo)(()=>u.length>0?tf(c,u):[],[u,c]),f=(0,I.useCallback)(()=>{if(u.length===0)return;let e=r.current,t=i.current;!e||!t||(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft)},[u.length,i,r]);(0,I.useEffect)(()=>{let e=r.current;e&&(e.style.height=`auto`,e.style.height=`${Math.max(60,Math.min(e.scrollHeight,140))}px`,f())},[60,c,f,r]);let p=(0,I.useCallback)(e=>{let t=e.target.value;l(t),o(t)},[o]);return(0,L.jsxs)(`div`,{className:`composer-text-shell`,children:[u.length>0?(0,L.jsx)(`div`,{className:`composer-mirror`,ref:i,"aria-hidden":`true`,children:c?d.map((e,t)=>(0,L.jsx)(`span`,{className:H(`composer-segment`,e.mention&&`file`),children:e.text},`${e.text}-${t}`)):null}):null,c?null:(0,L.jsx)(`span`,{className:`composer-placeholder`,children:n}),(0,L.jsx)(`textarea`,{id:`ta`,ref:r,rows:3,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,placeholder:``,spellCheck:!1,value:c,onChange:p,onKeyDown:s,onPaste:a,onScroll:f})]})});function cA({entry:e}){let t=Sf(e.diff);return t.length===0?(0,L.jsx)(`div`,{className:`diff-patch-empty`,children:`Waiting for diff…`}):(0,L.jsx)(`div`,{className:`diff-patch-viewer`,children:t.map(e=>(0,L.jsxs)(`div`,{className:H(`diff-patch-row`,e.kind),children:[(0,L.jsx)(`span`,{className:`diff-patch-num`,children:e.oldLine??``}),(0,L.jsx)(`span`,{className:`diff-patch-num`,children:e.newLine??``}),(0,L.jsx)(`pre`,{className:`diff-patch-text`,children:e.text||` `})]},e.id))})}function lA({backLabel:e=`Back to Chat`,diffEntries:t,findings:n,onBack:r,onSelectEntry:i,selectedEntryId:a}){let o=(0,I.useMemo)(()=>t.find(e=>e.id===a)??t[0]??null,[t,a]),s=(0,I.useMemo)(()=>t.reduce((e,t)=>e+t.additions,0),[t]),c=(0,I.useMemo)(()=>t.reduce((e,t)=>e+t.removals,0),[t]);return(0,L.jsx)(`div`,{id:`review-page`,children:(0,L.jsxs)(`div`,{className:`diff-review-shell page`,children:[(0,L.jsxs)(`div`,{className:`diff-review-page-head`,children:[(0,L.jsxs)(`button`,{className:`file-editor-back`,onClick:r,type:`button`,children:[`← `,e]}),(0,L.jsxs)(`div`,{className:`diff-review-page-copy`,children:[(0,L.jsx)(`div`,{className:`diff-review-page-title`,children:`Patch review`}),(0,L.jsxs)(`div`,{className:`diff-review-page-subtitle`,children:[t.length,` changed file`,t.length===1?``:`s`,` · +`,s,` / -`,c]})]})]}),t.length===0?(0,L.jsx)(`div`,{className:`empty-panel`,children:`No diff items in this thread yet.`}):(0,L.jsxs)(`div`,{className:`diff-review-layout page`,children:[(0,L.jsx)(`div`,{className:`diff-review-sidebar`,children:t.map(e=>(0,L.jsxs)(`button`,{className:H(`diff-review-entry`,o?.id===e.id&&`active`),type:`button`,onClick:()=>i(e.id),children:[(0,L.jsxs)(`div`,{className:`diff-review-entry-top`,children:[(0,L.jsx)(`span`,{className:H(`diff-kind-pill`,e.kind.type===`add`&&`new`,e.kind.type===`delete`&&`del`),children:bf(e.kind)}),(0,L.jsx)(`span`,{className:H(`diff-status`,e.status===`inProgress`&&`live`,e.status===`failed`&&`err`),children:e.status===`inProgress`?`editing`:e.status})]}),(0,L.jsx)(`div`,{className:`diff-review-entry-path`,children:e.path}),(0,L.jsxs)(`div`,{className:`diff-review-entry-meta`,children:[(0,L.jsxs)(`span`,{children:[`+`,e.additions]}),(0,L.jsxs)(`span`,{children:[`-`,e.removals]}),(0,L.jsxs)(`span`,{children:[e.hunks,` hunk`,e.hunks===1?``:`s`]})]})]},e.id))}),o?(0,L.jsxs)(`div`,{className:`diff-review-main`,children:[(0,L.jsxs)(`div`,{className:`diff-focus-head`,children:[(0,L.jsx)(`div`,{className:`diff-focus-title`,children:o.path}),(0,L.jsxs)(`div`,{className:`diff-focus-meta`,children:[(0,L.jsx)(`span`,{className:H(`diff-kind-pill`,o.kind.type===`add`&&`new`,o.kind.type===`delete`&&`del`),children:bf(o.kind)}),(0,L.jsx)(`span`,{className:H(`diff-status`,o.status===`inProgress`&&`live`,o.status===`failed`&&`err`),children:o.status===`inProgress`?`editing`:o.status}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[`+`,o.additions]}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[`-`,o.removals]}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[o.hunks,` hunk`,o.hunks===1?``:`s`]})]})]}),(0,L.jsx)(cA,{entry:o})]}):null]}),n.length>0?(0,L.jsx)(`div`,{className:`review-list`,children:n.map(e=>(0,L.jsxs)(`div`,{className:H(`review-item`,e.severity),children:[(0,L.jsxs)(`div`,{className:`review-header`,children:[(0,L.jsx)(`span`,{children:e.severity}),(0,L.jsx)(`span`,{children:e.file.split(`/`).slice(-2).join(`/`)}),(0,L.jsxs)(`span`,{children:[`:`,e.line]})]}),(0,L.jsx)(`div`,{className:`review-title`,children:e.title}),(0,L.jsx)(`div`,{className:`review-summary`,children:e.summary})]},e.id))}):null]})})}function uA({preview:e,variant:n=`panel`,onBack:r,backLabel:i=`Back`,onSave:a,providerId:o}){let s=hs(e.path,o),c=(0,I.useRef)(null),[l,d]=(0,I.useState)(e.content),[f,p]=(0,I.useState)(e.content),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)(`Plain text`),[b,x]=(0,I.useState)(null),S=l!==f;(0,I.useEffect)(()=>{d(e.content),p(e.content),h(null),_(!1)},[e.content,e.error,e.loading,e.path]),(0,I.useEffect)(()=>{let t=e.path||e.name,n=O.matchFilename(Ik,t),r=!1;if(x(null),y(n?.name??`Plain text`),n)return n.load().then(e=>{r||x(e.extension)}).catch(()=>{r||x(null)}),()=>{r=!0}},[e.name,e.path]);let C=(0,I.useCallback)(async()=>{if(!(!a||e.loading||e.error||g||!S)){_(!0),h(null);try{await a(e.path,l),p(l)}catch(e){h(e instanceof Error?e.message:`Unable to save this file.`)}finally{_(!1)}}},[l,S,g,a,e.error,e.loading,e.path]),w=(0,I.useMemo)(()=>{let e=[nA,t(rA),j.of([{key:`Mod-s`,preventDefault:!0,run:()=>(C(),!0)}])];return b&&e.push(b),e},[b,C]);(0,I.useEffect)(()=>{let t=c.current;if(!(!t||e.loading||e.error)){if(typeof e.line==`number`&&e.line>0){let n=t.state.doc.line(Math.min(e.line,t.state.doc.lines));t.dispatch({selection:{anchor:n.from},effects:u.scrollIntoView(n.from,{y:`center`})});return}t.scrollDOM.scrollTo({left:0,top:0})}},[e.error,e.line,e.loading,e.path]);let T=(0,I.useCallback)(()=>{r&&(S&&typeof window<`u`&&!window.confirm(`Discard unsaved changes to ${e.name}?`)||r())},[S,r,e.name]),E=g?`Saving…`:S?`Save`:`Saved`,D=m?`Save failed`:g?`Saving`:S?`Unsaved`:`Saved`;return(0,L.jsxs)(`div`,{className:H(`file-editor`,n===`page`&&`page`),children:[(0,L.jsxs)(`div`,{className:`file-editor-head`,children:[n===`page`?(0,L.jsxs)(`button`,{className:`file-editor-back`,onClick:T,type:`button`,children:[`← `,i]}):null,(0,L.jsxs)(`div`,{className:`file-editor-copy`,children:[(0,L.jsx)(`div`,{className:`file-editor-title`,children:e.name}),(0,L.jsx)(`div`,{className:`file-editor-path`,children:e.path})]}),(0,L.jsxs)(`div`,{className:`file-editor-actions`,children:[(0,L.jsxs)(`div`,{className:`file-editor-meta`,children:[(0,L.jsx)(`span`,{className:`file-editor-chip`,children:v}),typeof e.line==`number`&&e.line>0?(0,L.jsxs)(`span`,{className:`file-editor-chip`,children:[`Line `,e.line]}):null,(0,L.jsx)(`span`,{className:H(`file-editor-status`,S&&`dirty`,m&&`error`),children:D})]}),s===`#`?null:(0,L.jsx)(`a`,{className:`file-editor-link`,href:s,rel:`noreferrer noopener`,target:`_blank`,children:`Raw`}),(0,L.jsx)(`button`,{className:`file-editor-save`,disabled:!a||e.loading||!!e.error||g||!S,onClick:()=>void C(),type:`button`,children:E})]})]}),(0,L.jsxs)(`div`,{className:`file-editor-body`,children:[e.loading?(0,L.jsx)(`div`,{className:`file-editor-empty`,children:`Opening file…`}):null,!e.loading&&e.error?(0,L.jsx)(`div`,{className:`file-editor-empty`,children:e.error}):null,!e.loading&&!e.error?(0,L.jsx)(jk,{className:`file-editor-surface`,editable:!!a,extensions:w,height:`100%`,onChange:e=>{d(e),m&&h(null)},onCreateEditor:e=>{c.current=e},value:l}):null]})]})}var dA=`materializedThreadId`,fA=e=>{if(!e||typeof e!=`object`)return null;let t=e[dA];return typeof t==`string`?t:null},pA=(e,t)=>Object.fromEntries((e.questions??[]).map(e=>[e.id,[(t[e.id]??``).trim()].filter(Boolean)])),mA=(0,I.createContext)(null),hA=Sc(),gA=hA.mentionCatalog,_A=hA.directoryCatalogRoot||`.`,vA=18,yA=14,bA=[`Opening workspace`,`Setting environment`,`Initializing modules`,`Starting services`],xA=[`Opening conversation`,`Reattaching thread`,`Loading recent history`,`Syncing transcript`],SA=[...bA,...xA];function CA({name:e,className:t}){let n=H(`chrome-icon`,t);switch(e){case`auto`:return(0,L.jsx)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:`m8.1 1.4-1.7 4 2.3.3-1 4.9 3.9-6-2.4-.3 1.5-3Z`})});case`plan`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M4 3.5v9`}),(0,L.jsx)(`path`,{d:`M4 5h5`}),(0,L.jsx)(`path`,{d:`M4 8h7`}),(0,L.jsx)(`path`,{d:`M4 11h4`}),(0,L.jsx)(`circle`,{cx:`11.5`,cy:`8`,r:`1.5`})]});case`mention`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.3`}),(0,L.jsx)(`path`,{d:`M10.8 10.1a2.3 2.3 0 1 1 .4-4.6v3.6c0 .7.4 1 1 1 .9 0 1.4-.8 1.4-2.1A5.4 5.4 0 1 0 8 13.4`})]});case`attach`:return(0,L.jsx)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:`m6 8.5 3.8-3.8a2 2 0 1 1 2.8 2.8L7.9 12.2A3 3 0 0 1 3.6 8l4.3-4.3`})});case`image`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`rect`,{x:`2.5`,y:`3`,width:`11`,height:`10`,rx:`2`}),(0,L.jsx)(`circle`,{cx:`6`,cy:`6.5`,r:`1`}),(0,L.jsx)(`path`,{d:`m4.5 11 2.4-2.4 1.9 1.9 1.4-1.4 1.3 1.9`})]});case`terminal`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`rect`,{x:`2.5`,y:`3`,width:`11`,height:`10`,rx:`2`}),(0,L.jsx)(`path`,{d:`m5.3 6 1.8 1.8-1.8 1.8`}),(0,L.jsx)(`path`,{d:`M8.7 9.8h2.2`})]});case`web`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.2`}),(0,L.jsx)(`path`,{d:`m10.2 10.2 2.6 2.6`})]});case`review`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M4.5 2.8h5l2 2v7.4a1 1 0 0 1-1 1h-6a1 1 0 0 1-1-1V3.8a1 1 0 0 1 1-1Z`}),(0,L.jsx)(`path`,{d:`M9.5 2.8v2h2`}),(0,L.jsx)(`path`,{d:`M5.7 8h4.6`}),(0,L.jsx)(`path`,{d:`M5.7 10.3h3.2`})]});case`agents`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`circle`,{cx:`4.2`,cy:`8`,r:`1.5`}),(0,L.jsx)(`circle`,{cx:`11.8`,cy:`5.2`,r:`1.5`}),(0,L.jsx)(`circle`,{cx:`11.8`,cy:`10.8`,r:`1.5`}),(0,L.jsx)(`path`,{d:`M5.5 7.3 10.4 5.8`}),(0,L.jsx)(`path`,{d:`M5.5 8.7 10.4 10.2`})]});case`compact`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M3.5 5h9`}),(0,L.jsx)(`path`,{d:`M3.5 8h6`}),(0,L.jsx)(`path`,{d:`M3.5 11h9`}),(0,L.jsx)(`path`,{d:`m11 6.3 1.8 1.7L11 9.7`})]});case`editor`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M4.4 11.6 11.6 4.4`}),(0,L.jsx)(`path`,{d:`m10.4 3.6 2 2`}),(0,L.jsx)(`path`,{d:`M4 12.2 3.6 13l.8-.4 1.4-.3-.8-.8Z`}),(0,L.jsx)(`path`,{d:`M3.5 3.4h5.2`})]});case`send`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`m8 12.7-.1-8.8`}),(0,L.jsx)(`path`,{d:`m5.3 6.1 2.6-2.8 2.8 2.8`})]});case`stop`:return(0,L.jsx)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,L.jsx)(`rect`,{x:`4.6`,y:`4.6`,width:`6.8`,height:`6.8`,rx:`1.2`})});case`branch`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`circle`,{cx:`5`,cy:`4`,r:`1.4`}),(0,L.jsx)(`circle`,{cx:`11`,cy:`12`,r:`1.4`}),(0,L.jsx)(`circle`,{cx:`11`,cy:`4`,r:`1.4`}),(0,L.jsx)(`path`,{d:`M5 5.4v4.1c0 1.4 1.1 2.5 2.5 2.5H9.6`}),(0,L.jsx)(`path`,{d:`M5 5.4c0 1.4 1.1 2.5 2.5 2.5H9.6`})]});case`model`:return(0,L.jsxs)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`m8 2.6 4.4 2.5v5L8 12.6l-4.4-2.5v-5Z`}),(0,L.jsx)(`path`,{d:`m8 2.6 4.4 2.5L8 7.6 3.6 5.1Z`}),(0,L.jsx)(`path`,{d:`M8 7.6v5`})]});case`shield`:return(0,L.jsx)(`svg`,{className:n,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:`M8 2.5 12 4v3.6c0 2.4-1.4 4.2-4 5.9-2.6-1.7-4-3.5-4-5.9V4Z`})})}}var wA=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:e>=1e5?0:1}).format(e),TA=e=>{if(!e)return`workspace`;let t=e.replace(/\/+$/u,``);return t?t.split(`/`).filter(Boolean).at(-1)??t:`workspace`},EA=(e,t)=>{if(t!==null){if(t<=300)return`5h`;if(t>=1440*7)return`Week`}let n=e.trim().toLowerCase();return n.includes(`week`)?`Week`:n.includes(`5`)?`5h`:e},DA=(e,t)=>{let n=0;for(let r of e)for(let e of r.items)switch(e.type){case`userMessage`:n+=Jd(e,t).length;break;case`agentMessage`:case`plan`:n+=e.text.length;break;case`reasoning`:n+=e.summary.join(`
|
|
213
213
|
`).length,n+=e.content.join(`
|
|
214
|
-
`).length;break;case`webSearch`:n+=e.query.length;break;case`collabAgentToolCall`:n+=(e.prompt??``).length;break;default:break}return Math.max(0,Math.round(n/3.7))},DA=async e=>{if(typeof navigator<`u`&&navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),t.remove()},OA=e=>new Promise(t=>{window.setTimeout(t,e)}),kA=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),AA=(e,t)=>e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`&&e.message.trim()?e.message:t,jA=()=>{let e=(0,I.useContext)(pA);if(!e)throw Error(`Workspace context is missing.`);return e};function MA({children:e}){let[t,n]=(0,I.useState)(Sc()),r=(0,I.useRef)(t),i=(0,I.useRef)(null),a=(0,I.useRef)([]);(0,I.useEffect)(()=>{r.current=t},[t]);let o=(0,I.useCallback)(e=>{n(t=>{let n=structuredClone(t);return e(n),n})},[]);(0,I.useEffect)(()=>{let e=new ud(Sc());i.current=e;let t=e.subscribe(e=>{(0,I.startTransition)(()=>{n(e)})}),o=()=>{let t=r.current.transport;t.mode===`live`&&t.status===`connected`||e.connect().catch(()=>void 0)};o();let s=window.setInterval(()=>{o()},5e3),c=()=>{document.visibilityState===`visible`&&o()};return window.addEventListener(`focus`,o),document.addEventListener(`visibilitychange`,c),()=>{t(),window.clearInterval(s),window.removeEventListener(`focus`,o),document.removeEventListener(`visibilitychange`,c),e.disconnect(),a.current.forEach(e=>window.clearTimeout(e)),a.current=[]}},[]);let s=(0,I.useCallback)(async(e,t,n)=>{let a=r.current,o=i.current,s=!!o&&(n?.preferLive||a.transport.mode===`live`&&a.transport.status===`connected`);if(!o&&n?.preferLive)throw Error(`The workspace runtime is still starting. Try again.`);if(o&&s){let i=n?.preferLive?3:1,a=null;for(let s=0;s<i;s+=1)try{let t=r.current;return(t.transport.mode!==`live`||t.transport.status!==`connected`)&&await o.connect(),await e()}catch(e){if(a=e,s<i-1){await OA(320*(s+1));continue}if(n?.fallbackOnLiveError??!0)return await t();throw e}throw a}return await t()},[]),c=(0,I.useCallback)(async(e,t)=>{let n=kd(`thread`),r=Cc(n,t?.title??`New Session`,e,t?.cwd);return o(e=>{e.threads=jd([r,...e.threads.filter(e=>e.thread.id!==n)])}),n},[o]),l=(0,I.useCallback)(async({threadId:e,mode:t,prompt:n,mentions:i,skills:s,images:c,files:l,settings:u})=>{let d=r.current.threads.find(t=>t.thread.id===e)?.thread.cwd??r.current.directoryCatalogRoot??`.`,f=Ec({threadId:e,prompt:n,mode:t,settings:u,mentions:[...i,...Wd(d,l,u.provider)],skills:s,images:c,steer:null});o(r=>{r.threads=jd(r.threads.map(r=>r.thread.id===e?{...r,thread:{...r.thread,preview:n||r.thread.preview,updatedAt:Math.floor(Date.now()/1e3),status:{type:`active`,activeFlags:[]},turns:[...r.thread.turns,f.turn]},plan:f.plan,review:t===`review`?f.review:r.review,terminals:[...f.terminals,...r.terminals].slice(0,6),tokenUsage:{input:r.tokenUsage.input+Math.max(n.length*2,128),output:r.tokenUsage.output,cached:r.tokenUsage.cached}}:r)),r.streams=[...r.streams.filter(t=>t.threadId!==e),...f.streams]});let p=window.setTimeout(()=>{o(n=>{n.threads=jd(n.threads.map(n=>n.thread.id===e?{...n,thread:{...n.thread,updatedAt:Math.floor(Date.now()/1e3),status:{type:`idle`},turns:n.thread.turns.map(e=>e.id===f.turn.id?{...e,status:`completed`,items:e.items.map(e=>{if(e.type===`commandExecution`)return{...e,status:`completed`,exitCode:0,durationMs:1840};if(e.type===`collabAgentToolCall`){let t=Object.fromEntries(Object.entries(e.agentsStates).map(([e,t])=>[e,{...t,status:`completed`,message:t?.message??`Completed.`}]));return{...e,status:`completed`,agentsStates:t}}return e})}:e)},review:t===`review`?f.review:n.review,terminals:n.terminals.map(e=>f.terminals.some(t=>t.id===e.id)?{...e,status:`idle`,lastEvent:`just now`}:e),tokenUsage:{input:n.tokenUsage.input,output:n.tokenUsage.output+512,cached:n.tokenUsage.cached+96}}:n)),n.streams=n.streams.map(t=>t.threadId===e&&t.turnId===f.turn.id?{...t,visible:t.total}:t)})},2800);return a.current.push(p),e},[o]),u=(0,I.useMemo)(()=>({createThread:async(e,t)=>await s(async()=>await i.current.createThread(e,{cwd:t?.cwd}),async()=>await c(e,t),{preferLive:!0,fallbackOnLiveError:!1}),resumeThread:async e=>await s(async()=>{let t=i.current;await t.resumeThread(e).catch(()=>void 0),await t.ensureThreadLoaded(e).catch(()=>void 0)},async()=>void 0,{preferLive:!0,fallbackOnLiveError:!1}),interruptTurn:async e=>await s(async()=>await i.current.interruptTurn(e),async()=>{let t=!1;return o(n=>{n.threads=jd(n.threads.map(r=>{if(r.thread.id!==e)return r;let i=[...r.thread.turns].reverse().find(e=>e.status===`inProgress`);return i?(t=!0,wf(n,e,i.id),{...r,thread:{...r.thread,status:{type:`idle`},turns:r.thread.turns.map(e=>e.id===i.id?{...e,status:`interrupted`}:e)}}):r}))}),t}),sendComposer:async e=>await s(async()=>await i.current.sendComposer(e),async()=>await l(e),{preferLive:!0,fallbackOnLiveError:!1}),applySteer:async e=>await s(async()=>await i.current.applySteer(e),async()=>{let t=!1,n={id:`steer:${e.threadId}:${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,turnId:``,prompt:e.prompt.trim()||`Steer applied`,createdAt:Date.now(),status:`applied`};return o(r=>{r.threads=r.threads.map(r=>{if(r.thread.id!==e.threadId)return r;let i=[...r.thread.turns].reverse().find(e=>e.status===`inProgress`);return i?(t=!0,n.turnId=i.id,{...r,steers:[n,...(r.steers??[]).filter(e=>e.id!==n.id)]}):r})}),t},{preferLive:!0,fallbackOnLiveError:!1}),searchMentions:async(e,t)=>await s(async()=>{await i.current.searchMentions(e,t)},async()=>{o(n=>{let r=t.trim().toLowerCase(),i=`${e.replace(/\/+$/u,``)}/`;n.mentionCatalog=hA.filter(e=>e.path.startsWith(i)).filter(e=>r?`${e.name} ${e.path}`.toLowerCase().includes(r):!0).slice(0,18)})}),loadDirectory:async e=>await s(async()=>{await i.current.loadDirectory(e)},async()=>{o(t=>{t.directoryCatalogRoot=e,t.directoryCatalog=Kd(e)})}),readFile:async e=>await s(async()=>await i.current.readFile(e),async()=>{let t=hs(e,r.current.settings.provider);if(t===`#`)throw Error(`File preview is unavailable for this path.`);let n=await fetch(t);if(!n.ok)throw Error(`Failed to read ${e}`);return await n.text()}),saveFile:async(e,t)=>await s(async()=>{await i.current.writeFile(e,t)},async()=>{throw Error(`Saving files requires a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),readGitGraph:async(e,t=80)=>await s(async()=>await i.current.readGitGraph(e,t),async()=>``),readGitStatus:async e=>await s(async()=>await i.current.readGitStatus(e),async()=>``),readWorkspaceCommitPreferences:async e=>await s(async()=>await i.current.readWorkspaceCommitPreferences(e),async()=>{throw Error(`Commit preferences require a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),writeWorkspaceCommitPreferences:async(e,t)=>await s(async()=>await i.current.writeWorkspaceCommitPreferences(e,t),async()=>{throw Error(`Commit preferences require a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),generateCommitMessage:async({cwd:e,providerId:t})=>await s(async()=>await i.current.generateCommitMessage({cwd:e,providerId:t}),async()=>{throw Error(`Commit drafting requires a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),commitWorkingTree:async({cwd:e,message:t})=>await s(async()=>await i.current.commitWorkingTree({cwd:e,message:t}),async()=>{throw Error(`Git commit requires a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),checkProviderSetup:async e=>await s(async()=>{await i.current.checkProviderSetup(e)},async()=>{o(t=>{let n=e??t.settings.provider;t.providerSetup[n]={...t.providerSetup[n],status:`error`,summary:`Setup checks require a live workspace connection.`,detail:`Reconnect Nomadex to the host bridge, then check again.`,checkedAt:`just now`}})},{preferLive:!0}),startProviderAuth:async(e,t)=>await s(async()=>{await i.current.startProviderAuth(e,t)},async()=>{o(n=>{let r=e??n.settings.provider;n.providerAuth[r]={...n.providerAuth[r],status:`error`,flow:t??n.providerAuth[r].flow,summary:`Provider sign-in requires a live workspace connection.`,detail:`Reconnect Nomadex to the host bridge, then try again.`,processId:null,updatedAt:`just now`}})},{preferLive:!0}),submitProviderAuthSecret:async(e,t)=>await s(async()=>{await i.current.submitProviderAuthSecret(e,t)},async()=>{o(t=>{let n=e??t.settings.provider;t.providerAuth[n]={...t.providerAuth[n],status:`error`,summary:`Provider sign-in requires a live workspace connection.`,detail:`Reconnect Nomadex to the host bridge, then try again.`,processId:null,updatedAt:`just now`}})},{preferLive:!0}),cancelProviderAuth:async e=>await s(async()=>{await i.current.cancelProviderAuth(e)},async()=>{o(t=>{let n=e??t.settings.provider;t.providerAuth[n]={...t.providerAuth[n],status:`idle`,summary:`No sign-in in progress.`,detail:null,authUrl:null,userCode:null,processId:null,updatedAt:`just now`}})},{preferLive:!0}),switchProviderAccount:async(e,t)=>await s(async()=>{await i.current.switchProviderAccount(e,t)},async()=>{o(n=>{let r=e??n.settings.provider;n.providerAuth[r]={...n.providerAuth[r],status:`error`,flow:t??n.providerAuth[r].flow,summary:`Provider account switching requires a live workspace connection.`,detail:`Reconnect Nomadex to the host bridge, then try again.`,processId:null,updatedAt:`just now`}})},{preferLive:!0}),updateSettings:async e=>await s(async()=>{await i.current.updateSettings(e)},async()=>{e.provider&&Go(e.provider),o(t=>{t.settings={...t.settings,...e},t.lastSavedAt=`just now`})}),toggleFeatureFlag:async e=>await s(async()=>{await i.current.toggleFeatureFlag(e)},async()=>{o(t=>{t.featureFlags=t.featureFlags.map(t=>t.name===e?{...t,enabled:!t.enabled}:t),t.lastSavedAt=`just now`})}),toggleInstalledSkill:async e=>await s(async()=>{await i.current.toggleInstalledSkill(e)},async()=>{o(t=>{t.installedSkills=t.installedSkills.map(t=>t.id===e?{...t,enabled:!t.enabled}:t)})}),installSkill:async e=>await s(async()=>{await i.current.installSkill(e)},async()=>{o(t=>{let n=t.remoteSkills.find(t=>t.id===e);n&&(t.installedSkills=[{...n,path:`/home/allan/.codex/skills/${n.name}/SKILL.md`,enabled:!0,source:`installed`},...t.installedSkills],t.remoteSkills=t.remoteSkills.filter(t=>t.id!==e))})}),toggleMcpAuth:async e=>await s(async()=>{await i.current.toggleMcpAuth(e)},async()=>{o(t=>{t.mcpServers=t.mcpServers.map(t=>t.name===e?{...t,authStatus:t.authStatus===`notLoggedIn`?`oAuth`:t.authStatus}:t)})}),startChatGptLogin:async()=>await s(async()=>await i.current.startChatGptLogin(),async()=>(o(e=>{e.account.loginInProgress=!0,e.account.pendingLoginId=kd(`login`),e.account.loginError=null}),`https://chatgpt.com/`)),completeChatGptLogin:async e=>await s(async()=>{let t=await fetch(Ho(r.current.settings.provider).authCompletePath,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({callbackUrl:e})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error??n?.message??`Failed to complete mobile login`);await i.current.refreshAccount()},async()=>{o(e=>{e.account={...e.account,planType:`ChatGPT Pro`,workspace:`mobile relay account`,authMode:`chatgpt`,loggedIn:!0,requiresOpenaiAuth:!1,loginInProgress:!1,pendingLoginId:null,loginError:null}})}),loginWithApiKey:async e=>await s(async()=>{await i.current.loginWithApiKey(e)},async()=>{o(e=>{e.account={...e.account,planType:`API key`,workspace:`API key session`,authMode:`apiKey`,loggedIn:!0,requiresOpenaiAuth:!1,loginInProgress:!1,pendingLoginId:null,loginError:null}})}),logoutAccount:async()=>await s(async()=>{await i.current.logoutAccount()},async()=>{o(e=>{e.account={...e.account,planType:`Signed out`,workspace:`No active account`,authMode:`signedOut`,loggedIn:!1,loginInProgress:!1,pendingLoginId:null,loginError:null,usageWindows:[],rateUsed:0,rateLimit:100,credits:`Sign in to view rate limits`}})}),refreshAccount:async()=>await s(async()=>{await i.current.refreshAccount()},async()=>void 0),cleanTerminals:async e=>await s(async()=>{await i.current.cleanTerminals(e)},async()=>{o(t=>{t.threads=t.threads.map(t=>t.thread.id===e?{...t,terminals:t.terminals.filter(e=>e.status===`running`)}:t)})}),startProjectTerminal:async(e,t)=>await s(async()=>await i.current.startProjectTerminal(e,t),async()=>{throw Error(`Interactive terminals require a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),sendTerminalInput:async(e,t,n)=>await s(async()=>{await i.current.sendTerminalInput(t,n)},async()=>{throw Error(`Interactive terminals require a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),terminateTerminal:async(e,t)=>await s(async()=>{await i.current.terminateTerminal(t)},async()=>{throw Error(`Interactive terminals require a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),resolveApproval:async(e,t)=>await s(async()=>{await i.current.resolveApproval(e,t)},async()=>{o(n=>{n.threads=n.threads.map(n=>({...n,approvals:n.approvals.map(n=>n.id===e?{...n,state:t===`accept`||t===`acceptForSession`?`approved`:`declined`}:n)}))})}),submitQuestion:async(e,t)=>await s(async()=>{await i.current.submitQuestion(e,t)},async()=>{o(n=>{n.threads=n.threads.map(n=>({...n,approvals:n.approvals.map(n=>n.id===e?{...n,state:`submitted`,detail:`${n.detail} · ${Object.values(t).flat().filter(Boolean).join(`, `)}`}:n)}))})}),submitMcp:async(e,t,n)=>await s(async()=>{await i.current.submitMcp(e,t,n)},async()=>{o(n=>{n.threads=n.threads.map(n=>({...n,approvals:n.approvals.map(n=>n.id===e?{...n,state:t===`accept`?`submitted`:`declined`}:n)}))})}),rollbackToTurn:async(e,t)=>await s(async()=>{await i.current.rollbackToTurn(e,t)},async()=>{o(n=>{n.threads=n.threads.map(n=>{if(n.thread.id!==e)return n;let r=n.thread.turns.filter(e=>e.status!==`inProgress`),i=r.findIndex(e=>e.id===t);if(i===-1)return n;let a=new Set(r.slice(i).map(e=>e.id));if(a.size===0)return n;let o=n.thread.turns.filter(e=>!a.has(e.id));return{...n,thread:{...n.thread,turns:o,updatedAt:Math.floor(Date.now()/1e3)},steers:(n.steers??[]).filter(e=>!a.has(e.turnId)),approvals:n.approvals.filter(e=>!e.turnId||!a.has(e.turnId))}})})},{preferLive:!0,fallbackOnLiveError:!1}),forkThread:async e=>{let t=r.current.threads.find(t=>t.thread.id===e),n=kd(`thread`);return o(e=>{let r=t?structuredClone(t):Cc(n,`Forked Session`,e.settings);r.thread.id=n,r.thread.name=t?`Fork of ${Yd(t)}`:`Forked Session`,r.thread.preview=t?.thread.preview??`Forked session`,r.thread.createdAt=Math.floor(Date.now()/1e3),r.thread.updatedAt=Math.floor(Date.now()/1e3),r.thread.status={type:`idle`},r.approvals=[],r.terminals=[],e.threads=jd([r,...e.threads.filter(e=>e.thread.id!==n)])}),n},compactThread:async e=>{o(t=>{t.threads=t.threads.map(t=>{if(t.thread.id!==e)return t;let n=[...t.thread.turns];if(n.length===0)return t;let r=n[n.length-1];return r.items.some(e=>e.type===`contextCompaction`)||(r.items=[...r.items,{type:`contextCompaction`,id:kd(`compact`)}]),{...t,plan:t.plan?{...t.plan,explanation:`Conversation compacted to free context.`}:t.plan,thread:{...t.thread,turns:n}}})})}}),[c,o,l,s]);return(0,L.jsx)(pA.Provider,{value:{snapshot:t,actions:u},children:e})}function NA(){return(0,L.jsx)(PA,{})}function PA(){let{snapshot:e,actions:t}=jA(),n=Na(),r=Ta({select:e=>e.location}),i=zd(r.pathname),a=(0,I.useMemo)(()=>{let e=r.pathname.split(`/`).filter(Boolean);return e[0]!==`threads`||!e[1]||!e[2]||gd(e[2])?null:e[2]},[r.pathname]),o=(0,I.useMemo)(()=>new URLSearchParams(r.search),[r.search]),s=(0,I.useMemo)(()=>{let t=new Map;return e.threads.forEach(e=>{let n=t.get(e.thread.id);(!n||e.thread.updatedAt>=n.thread.updatedAt)&&t.set(e.thread.id,e)}),jd([...t.values()])},[e.threads]),c=(0,I.useMemo)(()=>{let e={};return s.forEach(t=>{e[t.thread.id]=Yd(t)}),e},[s]),l=i.threadId??s[0]?.thread.id??null,u=l?s.find(e=>e.thread.id===l)??null:null,d=u?c[u.thread.id]??Vd(u.thread):`New Session`,f=Id(i.section),[p,m]=(0,I.useState)(()=>Ad()),h=i.section===`editor`?o.get(`path`):null,g=(0,I.useMemo)(()=>{let e=i.section===`editor`?o.get(`line`):null;if(!e)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null},[i.section,o]),_=(0,I.useMemo)(()=>{let e=i.section===`editor`?o.get(`from`):null;switch(e){case`ops`:case`review`:case`agents`:case`skills`:case`mcp`:case`settings`:case`chat`:return e;default:return`chat`}},[i.section,o]),v=i.section===`review`?o.get(`diff`):null,y=(0,I.useMemo)(()=>{let e=i.section===`review`?o.get(`from`):null;switch(e){case`ops`:case`agents`:case`skills`:case`mcp`:case`settings`:case`chat`:return e;default:return`chat`}},[i.section,o]),[b,x]=(0,I.useState)(!1),[S,C]=(0,I.useState)(()=>Ad()),[w,T]=(0,I.useState)(!1),[E,D]=(0,I.useState)(f??`files`),[O,ee]=(0,I.useState)(!1),[te,ne]=(0,I.useState)(!1),[re,k]=(0,I.useState)(!1),[A,ie]=(0,I.useState)(!1),[ae,oe]=(0,I.useState)(!1),[se,ce]=(0,I.useState)(!1),[j,M]=(0,I.useState)(gA),[le,ue]=(0,I.useState)(``),[de,fe]=(0,I.useState)(`chat`),[pe,me]=(0,I.useState)(!1),[he,ge]=(0,I.useState)(!1),[_e,N]=(0,I.useState)(!1),[ve,ye]=(0,I.useState)(!1),[be,xe]=(0,I.useState)(!1),[Se,Ce]=(0,I.useState)([]),[we,P]=(0,I.useState)([]),[Te,Ee]=(0,I.useState)([]),[De,Oe]=(0,I.useState)([]),[ke,Ae]=(0,I.useState)(l?[l,...e.threads.slice(1,2).map(e=>e.thread.id)]:[]),[je,Me]=(0,I.useState)(``),[Ne,Pe]=(0,I.useState)(null),[Fe,F]=(0,I.useState)(``),[Ie,Le]=(0,I.useState)(0),[Re,ze]=(0,I.useState)({}),[Be,Ve]=(0,I.useState)([]),[He,Ue]=(0,I.useState)(null),[We,Ge]=(0,I.useState)(null),[Ke,qe]=(0,I.useState)(null),[Je,Ye]=(0,I.useState)(null),[Xe,Ze]=(0,I.useState)({}),[Qe,$e]=(0,I.useState)({}),[et,tt]=(0,I.useState)({}),nt=(0,I.useRef)(null),rt=(0,I.useRef)(null),[it,at]=(0,I.useState)(!1),[ot,st]=(0,I.useState)(null),[ct,lt]=(0,I.useState)(!1),[ut,dt]=(0,I.useState)(null),[ft,pt]=(0,I.useState)(0),[mt,ht]=(0,I.useState)(e.settings.provider),[gt,_t]=(0,I.useState)(null),[vt,yt]=(0,I.useState)(``),[bt,xt]=(0,I.useState)(!1),[St,Ct]=(0,I.useState)(!1),[wt,Tt]=(0,I.useState)({top:52,right:12}),[Et,Dt]=(0,I.useState)(0);(0,I.useEffect)(()=>{!a||!i.threadId||n({to:`/threads/$threadId`,params:{threadId:i.threadId},replace:!0})},[a,n,i.threadId]);let[Ot,kt]=(0,I.useState)(()=>{if(typeof window>`u`)return yd;let e=window.localStorage.getItem(bd);return Dd(e)?e:yd}),At=(0,I.useRef)(null),jt=(0,I.useRef)(null),Mt=(0,I.useRef)(null),Nt=(0,I.useRef)(null),Pt=(0,I.useRef)(null),Ft=(0,I.useRef)(null),It=(0,I.useRef)(null),Lt=(0,I.useRef)({}),Rt=(0,I.useRef)({}),zt=(0,I.useRef)({}),Bt=(0,I.useRef)(null),Vt=(0,I.useRef)(le),Ht=(0,I.useRef)({}),Ut=(0,I.useRef)(!1),Wt=(0,I.useRef)(null),Gt=(0,I.useRef)(null),Kt=(0,I.useRef)(null),qt=(0,I.useRef)(!0),Jt=(0,I.useRef)({}),Yt=(0,I.useRef)({}),[Xt,Zt]=(0,I.useState)({}),[Qt,$t]=(0,I.useState)(0),en=(0,I.useDeferredValue)(le),tn=(0,I.useDeferredValue)(Fe);(0,I.useEffect)(()=>{Vt.current=le},[le]);let[nn,rn]=(0,I.useState)(!0);(0,I.useEffect)(()=>()=>{Bt.current!==null&&window.cancelAnimationFrame(Bt.current)},[]),(0,I.useEffect)(()=>{let e=()=>{m(e=>{let t=Ad();return e===t?e:t})};return e(),window.addEventListener(`resize`,e,{passive:!0}),()=>{window.removeEventListener(`resize`,e)}},[]);let an=(0,I.useCallback)(()=>{let e=Pt.current?.getBoundingClientRect();Tt({top:(e?.bottom??48)+4,right:Math.max(12,window.innerWidth-(e?.right??window.innerWidth-12))})},[]);(0,I.useEffect)(()=>{if(typeof document>`u`)return;let e=Od(Ot),t=document.documentElement;t.dataset.uiTheme=e.id,t.style.setProperty(`color-scheme`,e.mode),window.localStorage.setItem(bd,Ot),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.themeColor),document.querySelector(`meta[name="color-scheme"]`)?.setAttribute(`content`,e.mode),document.querySelector(`meta[name="apple-mobile-web-app-status-bar-style"]`)?.setAttribute(`content`,e.mode===`light`?`default`:`black-translucent`)},[Ot]),(0,I.useLayoutEffect)(()=>{if(!te)return;let e=()=>{an()};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[te,an]);let on=(0,I.useMemo)(()=>{let e=new Set(s.map(e=>e.thread.id));return[...new Set(ke.filter(t=>e.has(t)))].slice(0,6)},[ke,s]),R=(0,I.useMemo)(()=>Nd(u?.thread.turns??[]),[u?.thread.turns]),sn=(0,I.useMemo)(()=>Math.max(0,R.length-_A),[R.length]),cn=(0,I.useMemo)(()=>{if(!l)return sn;let e=Xe[l];if(e==null)return sn;let t=R.length===0?0:Math.max(0,R.length-1);return Math.max(0,Math.min(e,t))},[sn,l,R.length,Xe]),ln=(0,I.useMemo)(()=>R.slice(cn),[R,cn]),un=(0,I.useMemo)(()=>R.map(e=>`${e.id}:${e.status}:${e.items.length}:${e.error?.message??``}`).join(`|`),[R]),dn=[...R].reverse().find(e=>e.status===`inProgress`)??null,fn=l?Re[l]??[]:[],pn=(0,I.useMemo)(()=>vs(dn),[dn]),mn=(0,I.useMemo)(()=>_s(dn),[dn]),hn=!w&&S&&i.section!==`editor`&&i.section!==`review`,gn=hn&&!p,_n=p||b,vn=!p&&gn,yn=O||re||A||ae,bn=(0,I.useMemo)(()=>u?.approvals.filter(e=>e.state===`pending`).length??0,[u?.approvals]),xn=(0,I.useMemo)(()=>u?.approvals.filter(e=>e.state===`pending`)??[],[u?.approvals]),Sn=Pd(e.settings),Cn=(0,I.useMemo)(()=>{let e=u?.thread.cwd??null;return e?!We||!qd(e,We)?e:We:null},[u?.thread.cwd,We]),wn=(0,I.useMemo)(()=>({...e.settings,collaborationMode:he?`plan`:`default`}),[e.settings,he]);(0,I.useEffect)(()=>{let t=new Set(e.threads.flatMap(e=>e.approvals.filter(e=>e.kind===`question`&&e.state===`pending`).map(e=>e.id)));$e(e=>{let n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[e.threads]),(0,I.useEffect)(()=>{let t=new Set(e.threads.flatMap(e=>e.approvals.filter(e=>e.kind===`mcp`&&e.state===`pending`).map(e=>e.id)));tt(e=>{let n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[e.threads]);let Tn=(0,I.useMemo)(()=>{let e={Today:[],Yesterday:[],Earlier:[]};return s.forEach(t=>{e[Bd(t.thread.updatedAt)].push(t)}),e},[s]),En=(0,I.useMemo)(()=>e.providers.find(t=>t.id===e.settings.provider)??Ho(e.settings.provider),[e.providers,e.settings.provider]),Dn=(0,I.useMemo)(()=>Zo(En.id,e.models.length>0?e.models:mA.models),[En.id,e.models]),On=(0,I.useMemo)(()=>Qo(En.id,e.settings.model,e.models.length>0?e.models:mA.models),[En.id,e.settings.model,e.models]),kn=`${En.displayName} · ${On?.displayName??(e.settings.model===`default`?`provider default`:e.settings.model)}`,An=(0,I.useMemo)(()=>Od(Ot),[Ot]),jn=(0,I.useMemo)(()=>R.flatMap(e=>e.items.filter(e=>e.type===`fileChange`)),[R]),Mn=(0,I.useMemo)(()=>R.flatMap(e=>e.items.flatMap(e=>e.type===`fileChange`?(e.changes.length>0?e.changes:[{path:`Editing files`,kind:{type:`update`,move_path:null},diff:``}]).map((t,n)=>{let r=xf(t.diff);return{id:vf(e.id,n,t.path),itemId:e.id,path:t.path,diff:t.diff,kind:t.kind,status:e.status,additions:r.additions,removals:r.removals,hunks:r.hunks}}):[])).reverse(),[R]),Nn=(0,I.useMemo)(()=>s.filter(e=>e.thread.cwd===u?.thread.cwd),[u?.thread.cwd,s]),Pn=(0,I.useMemo)(()=>u?.thread.cwd?.trim()||e.directoryCatalogRoot||null,[u?.thread.cwd,e.directoryCatalogRoot]),Fn=(0,I.useMemo)(()=>Mn.find(e=>e.id===Je)??Mn[0]??null,[Mn,Je]);(0,I.useEffect)(()=>{if(!u){ht(e.settings.provider),_t(null),yt(``);return}if(!Pn){ht(e.settings.provider),_t(null);return}let n=!1;return yt(``),t.readWorkspaceCommitPreferences(Pn).then(e=>{n||(ht(e.provider),_t(e.filePath))}).catch(()=>{n||(ht(e.settings.provider),_t(null))}),()=>{n=!0}},[t,u,Pn,e.settings.provider]),(0,I.useEffect)(()=>{if(!u){st(null),lt(!1),dt(null);return}let e=Ks({activeThread:u,relatedThreads:Nn});if(st(e),dt(null),E!==`graph`){lt(!1);return}let n=`${u.thread.cwd}:${u.thread.gitInfo?.sha??`workspace`}`,r=Ht.current[n]??``,i=!1;return lt(!0),Promise.allSettled([r?Promise.resolve(r):t.readGitGraph(u.thread.cwd,80),t.readGitStatus(u.thread.cwd)]).then(([t,r])=>{if(i)return;let a=t.status===`fulfilled`?t.value:``,o=r.status===`fulfilled`?r.value:``,s=Ks({activeThread:u,relatedThreads:Nn,rawStatus:o}),c=(a.trim().length>0?Gs({activeThread:u,rawLog:a,rawStatus:o}):null)??s??e;a.trim().length>0&&(Ht.current[n]=a),dt(t.status===`rejected`?AA(t.reason,`Unable to read git history.`):null),st(c)}).finally(()=>{i||lt(!1)}),()=>{i=!0}},[t,u,ft,E,Nn]);let In=ot?.workingTree??null,Ln=!!In?.dirty||jn.some(e=>e.status!==`failed`),Rn=!!In?.buckets.some(e=>e.id===`staged`&&e.entries.length>0),zn=ot?.branchLabel||u?.thread.gitInfo?.branch||`current branch`,Bn=(0,I.useMemo)(()=>{if(!u)return[];if(!Fn)return u.review;let e=yf(Fn.path);return u.review.filter(t=>{let n=yf(t.file);return n===e||n.endsWith(`/${e}`)})},[u,Fn]),Vn=(0,I.useMemo)(()=>e.directoryCatalogRoot===j?e.directoryCatalog.filter(e=>e.kind===`directory`):[],[j,e.directoryCatalog,e.directoryCatalogRoot]),Hn=(0,I.useMemo)(()=>{if(j===gA)return null;let e=j.lastIndexOf(`/`);return e<=0?gA:j.slice(0,e)||gA},[j]),Un=(0,I.useMemo)(()=>{let e=gA.replace(/\/+$/u,``),t=j.replace(/\/+$/u,``),n=t===e?``:t.slice(e.length).replace(/^\/+/u,``);return[{label:e.split(`/`).filter(Boolean).pop()??e,path:e},...n.split(`/`).filter(Boolean).reduce((t,n)=>{let r=t.at(-1)?.path??e;return t.push({label:n,path:`${r.replace(/\/+$/u,``)}/${n}`}),t},[])]},[j]),Wn=(0,I.useMemo)(()=>R.flatMap(e=>e.items.filter(e=>e.type===`collabAgentToolCall`)),[R]),Gn=(0,I.useMemo)(()=>{for(let e of[...R].reverse())for(let t of[...e.items].reverse())if(t.type===`agentMessage`)return t;return null},[R]),Kn=(0,I.useMemo)(()=>{if(Ne===`mention`){let t=Fe.replace(/^@/u,``).trim().toLowerCase(),n=u&&e.directoryCatalogRoot===u.thread.cwd?e.directoryCatalog.filter(e=>t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0):[],r=new Map;return[...n,...e.mentionCatalog].forEach(e=>{r.has(e.path)||r.set(e.path,e)}),[...r.values()].slice(0,24).map(e=>({id:e.id,label:e.name,description:Hd(e.path,92),mode:`mention`,value:e.path}))}return Ne===`skill`?[...e.installedSkills,...e.remoteSkills].map(e=>({id:e.id,label:`$${e.name}`,description:e.description,mode:`skill`,value:e.name})):Td.map(e=>({id:e.cmd,label:e.cmd,description:e.dsc,mode:`slash`,value:e.cmd}))},[u,Ne,Fe,e.directoryCatalog,e.directoryCatalogRoot,e.installedSkills,e.mentionCatalog,e.remoteSkills]),qn=(0,I.useMemo)(()=>{let e=tn.trim().toLowerCase();return e?Kn.filter(t=>`${t.label} ${t.description}`.toLowerCase().includes(e)).slice(0,12):Kn.slice(0,12)},[tn,Kn]);(0,I.useEffect)(()=>{if(!l)return;let e=window.requestAnimationFrame(()=>{Ae(e=>e.includes(l)?e:[l,...e.filter(e=>e!==l)].slice(0,6))});return()=>{window.cancelAnimationFrame(e)}},[l]),(0,I.useLayoutEffect)(()=>{l&&Wt.current!==l&&(delete Jt.current[l],Ze(e=>{if(!(l in e))return e;let t={...e};return delete t[l],t}),qt.current=!0,Gt.current=null,Kt.current=null)},[l]);let Jn=(0,I.useMemo)(()=>e.transport.mode===`live`&&e.transport.status===`connected`&&!!u&&hf(u,R),[u,R,e.transport.mode,e.transport.status]),Yn=(0,I.useMemo)(()=>i.threadId===u?.thread.id&&Jn,[Jn,u?.thread.id,i.threadId]);(0,I.useEffect)(()=>{if(nn){if(e.transport.status===`connecting`){Ut.current=!0;return}Ut.current&&(Jn||rn(!1))}},[Jn,nn,e.transport.status]);let Xn=(0,I.useCallback)(()=>{$t(e=>e+1)},[]),Zn=(0,I.useCallback)((e,t,r=`chat`)=>{!e||!t||e===t||(Ae(n=>{let r=n.map(n=>n===e?t:n);return r.includes(t)||r.unshift(t),[...new Set(r)].slice(0,6)}),ze(n=>{let r=n[e]??[];if(r.length===0)return n;let i={...n};return delete i[e],i[t]=[...r,...i[t]??[]],i}),Lt.current[e]&&(Lt.current[t]=Lt.current[e],delete Lt.current[e]),Rt.current[e]&&(Rt.current[t]=Rt.current[e],delete Rt.current[e]),Jt.current[e]&&(Jt.current[t]=Jt.current[e],delete Jt.current[e]),Wt.current===e&&(Wt.current=t),Gt.current?.threadId===e&&(Gt.current={...Gt.current,threadId:t}),Ze(n=>{if(!(e in n))return n;let r={...n};return r[t]=r[e]??r[t]??0,delete r[e],r}),i.threadId===e&&n(r===`chat`?{to:`/threads/$threadId`,params:{threadId:t}}:{to:`/threads/$threadId/$section`,params:{threadId:t,section:hd(r)}}),Xn())},[n,Xn,i.threadId]),Qn=(0,I.useCallback)(async(e,n=`chat`)=>{try{let r=await t.sendComposer(e);return Zn(e.threadId,r,n),r}catch(t){let r=dA(t);throw r&&Zn(e.threadId,r,n),t}},[t,Zn]),$n=(0,I.useCallback)((e,t,n)=>{$e(r=>({...r,[e]:{...r[e]??{},[t]:n}}))},[]),er=(0,I.useCallback)(async e=>{let n=fA(e,Qe[e.id]??{});await t.submitQuestion(e.id,n),$e(t=>{if(!(e.id in t))return t;let n={...t};return delete n[e.id],n})},[t,Qe]),tr=(0,I.useCallback)((e,t)=>{tt(n=>({...n,[e]:t}))},[]),nr=(0,I.useCallback)(async(e,n)=>{await t.resolveApproval(e.id,n)},[t]),rr=(0,I.useCallback)(async(e,n)=>{await t.submitMcp(e.id,n,et[e.id]??``),tt(t=>{if(!(e.id in t))return t;let n={...t};return delete n[e.id],n})},[t,et]),ir=(0,I.useCallback)(e=>e.kind===`question`?(0,L.jsx)(JS,{answers:Qe[e.id]??{},approval:e,onAnswerChange:(t,n)=>$n(e.id,t,n),onSubmit:()=>void er(e)},e.id):(0,L.jsx)(HS,{approval:e,mcpContentText:et[e.id]??``,onMcpContentChange:t=>tr(e.id,t),onResolve:t=>void nr(e,t),onSubmitMcp:t=>void rr(e,t)},e.id),[et,Qe,nr,rr,er,tr,$n]);(0,I.useEffect)(()=>{if(!i.threadId||e.transport.mode!==`live`||e.transport.status!==`connected`||!u||!hf(u,R))return;let n=i.threadId,r=0,a=()=>{r+=1,t.resumeThread(n)};a();let o=window.setInterval(()=>{if(r>=5){window.clearInterval(o);return}a()},1200);return()=>{window.clearInterval(o)}},[t,u,R,i.threadId,e.transport.mode,e.transport.status]),(0,I.useEffect)(()=>{if(i.section!==`review`)return;let e=v&&Mn.some(e=>e.id===v)?v:Mn[0]?.id??null;Ye(t=>t===e?t:e)},[Mn,v,i.section]),(0,I.useEffect)(()=>{if(!Je||!Mn.some(e=>e.id===Je)){let e=window.requestAnimationFrame(()=>{Ye(Mn[0]?.id??null)});return()=>{window.cancelAnimationFrame(e)}}},[Mn,Je]),(0,I.useEffect)(()=>{e.transport.mode===`live`&&e.transport.status!==`connected`||Object.entries(Re).forEach(([t,n])=>{if(n.length===0||Lt.current[t])return;let r=e.threads.find(e=>e.thread.id===t)?.thread.turns.some(e=>e.status===`inProgress`)??!1;if(Rt.current[t]){if(r)return;delete Rt.current[t]}if(r)return;let[i]=n;i&&(Lt.current[t]=!0,ze(e=>{let n=e[t]??[];if(n[0]?.id!==i.id)return e;let r=n.slice(1);if(r.length===0){let n={...e};return delete n[t],n}return{...e,[t]:r}}),Qn({threadId:t,mode:i.mode,prompt:i.prompt,mentions:i.mentions,skills:i.skills,images:i.images,files:i.files,settings:wn}).then(e=>{Rt.current[e]=!0}).catch(e=>{let n=dA(e)??t;ze(e=>({...e,[n]:[i,...e[n]??[]]})),Xn()}).finally(()=>{delete Lt.current[t]}))})},[wn,Re,Qt,Xn,Qn,e.threads,e.transport.mode,e.transport.status]),(0,I.useEffect)(()=>{let e=()=>{typeof document<`u`&&document.visibilityState!==`visible`||Xn()},t=()=>{document.visibilityState===`visible`&&Xn()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,t)}},[Xn]),(0,I.useLayoutEffect)(()=>{if(i.section===`editor`||i.section===`review`){C(!1);return}if(!p&&w){C(!1);return}if(!f){p||C(!1);return}D(e=>e===f||f===`files`&&e===`graph`?e:f),C(e=>e||!0)},[p,w,i.section,f]),(0,I.useEffect)(()=>{w&&(p||!f)&&T(!1)},[p,w,f]),(0,I.useEffect)(()=>{if(!u||Ne!==`mention`)return;e.directoryCatalogRoot!==u.thread.cwd&&t.loadDirectory(u.thread.cwd);let n=tn.replace(/^@/,``).trim();n&&t.searchMentions(u.thread.cwd,n)},[t,u,tn,Ne,e.directoryCatalogRoot]),(0,I.useEffect)(()=>{let e=u?.thread.cwd;if(!e)return;let t=window.requestAnimationFrame(()=>{Ge(t=>t&&qd(e,t)?t:e),qe(t=>t&&qd(e,t.path)?t:null)});return()=>{window.cancelAnimationFrame(t)}},[u?.thread.cwd]),(0,I.useEffect)(()=>{Cn&&t.loadDirectory(Cn)},[t,Cn]),(0,I.useEffect)(()=>{A&&t.loadDirectory(j)},[t,A,j]),(0,I.useEffect)(()=>{if(i.section!==`editor`||!h||Ke?.path===h&&!Ke.loading&&Ke.error===null)return;let e=h.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??h,n=!1;return t.readFile(h).then(t=>{n||(0,I.startTransition)(()=>{qe({path:h,name:e,content:t,loading:!1,error:null,line:g})})}).catch(t=>{n||qe({path:h,name:e,content:``,loading:!1,error:t instanceof Error?t.message:`Unable to open this file.`,line:g})}),()=>{n=!0}},[t,g,h,Ke,i.section]),(0,I.useEffect)(()=>{let t=e.transport.mode===`live`,n=e.streams;if(t){let e=window.requestAnimationFrame(()=>{let e={};for(let t of n){let n=Cf(t);e[t.key]=n}Yt.current=e,(0,I.startTransition)(()=>{Zt(e)})});return()=>{window.cancelAnimationFrame(e)}}let r=window.requestAnimationFrame(()=>{let e=Yt.current,t=Object.keys(e).length!==n.length,r={};for(let i of n){let n=Cf(i),a=Math.min(e[i.key]??0,n);r[i.key]=a,(e[i.key]??void 0)!==a&&(t=!0)}t&&(Yt.current=r,(0,I.startTransition)(()=>{Zt(r)}))}),i=window.setInterval(()=>{let e=Yt.current,t={},r=Object.keys(e).length!==n.length;for(let i of n){let n=Cf(i),a=Math.min(e[i.key]??0,n),o=n-a,s=Math.max(1,i.speed,Math.ceil(o/5)),c=a<n?Math.min(n,a+s):a;t[i.key]=c,c!==a&&(r=!0)}r&&(Yt.current=t,(0,I.startTransition)(()=>{Zt(t)}))},24);return()=>{window.cancelAnimationFrame(r),window.clearInterval(i)}},[e.streams,e.transport.mode]);let ar=(0,I.useCallback)(e=>e.scrollHeight-e.scrollTop-e.clientHeight<=72,[]),or=(0,I.useCallback)((e=l)=>{let t=At.current;if(!t||!e)return;let n=ar(t);qt.current=n,at(e=>e===!n?e:!n),Jt.current[e]={pinned:n,top:t.scrollTop}},[l,ar]),sr=(0,I.useCallback)(()=>{if(!l||cn<=0||Yn)return;let e=At.current;e&&Gt.current?.threadId!==l&&(Gt.current={threadId:l,previousHeight:e.scrollHeight,previousTop:e.scrollTop},Ze(e=>{let t=e[l]??sn,n=Math.max(0,t-vA);return n===t?(Gt.current=null,e):{...e,[l]:n}}))},[sn,l,cn,Yn]),cr=(0,I.useCallback)((e=!1)=>{let t=At.current;t&&(!e&&!qt.current||(t.scrollTop=t.scrollHeight,qt.current=!0,at(!1),l&&(Jt.current[l]={pinned:!0,top:t.scrollTop})))},[l]);(0,I.useEffect)(()=>{let e=At.current;if(!e||!l||i.section===`editor`||i.section===`review`)return;let t=()=>{let t=ar(e);qt.current=t,at(e=>e===!t?e:!t),Jt.current[l]={pinned:t,top:e.scrollTop}};t();let n=()=>{t(),e.scrollTop<=48&&sr()};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t(),e.removeEventListener(`scroll`,n)}},[l,ar,sr,i.section]);let lr=(0,I.useCallback)(e=>{let t=null,n=null,r=0,i=()=>{cr(e?.force??!1);let n=At.current;if(!n)return;let a=n.scrollHeight-n.scrollTop-n.clientHeight;r+=1,a>2&&r<8&&(t=window.requestAnimationFrame(i))};return t=window.requestAnimationFrame(i),n=e?.extraDelay?window.setTimeout(i,90):null,()=>{t!==null&&window.cancelAnimationFrame(t),n!==null&&window.clearTimeout(n)}},[cr]);(0,I.useLayoutEffect)(()=>{At.current&&cr()},[cr,Xt,un]),(0,I.useLayoutEffect)(()=>{if(!l||i.section===`editor`||i.section===`review`)return;let e=Wt.current===l?Jt.current[l]:void 0;qt.current=e?.pinned??!0,at(!(e?.pinned??!0))},[l,i.section]),(0,I.useLayoutEffect)(()=>{if(!l||i.section===`editor`||i.section===`review`)return;let e=()=>{let e=At.current;if(!e)return;let t=Wt.current===l,n=t?Jt.current[l]:void 0;if(!t){cr(!0);return}if(!n){Wt.current=null,cr(!0);return}if(n.pinned){Wt.current=null,cr(!0);return}let r=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTop=Math.min(n.top,r),Wt.current=null,or(l)};e();let t=window.requestAnimationFrame(e),n=window.setTimeout(e,90);return()=>{window.cancelAnimationFrame(t),window.clearTimeout(n)}},[l,cr,i.section,or]),(0,I.useLayoutEffect)(()=>{let e=Gt.current;if(!e||e.threadId!==l)return;let t=At.current;if(!t)return;let n=t.scrollHeight-e.previousHeight;t.scrollTop=e.previousTop+n,Gt.current=null,or(l)},[l,ln.length,or]),(0,I.useEffect)(()=>()=>{i.section===`editor`||i.section===`review`||or(l)},[l,i.section,or]),(0,I.useEffect)(()=>{if(!l){at(!1),Kt.current=null;return}if(Yn||R.length===0){Kt.current=null;return}let e=`${l}:${R.at(-1)?.id??`empty`}:${R.length}`;if(Kt.current!==e)return Kt.current=e,lr({extraDelay:!0,force:!0})},[l,R,Yn,lr]);let ur=(0,I.useCallback)(()=>{lr({extraDelay:!0,force:!0})},[lr]);(0,I.useEffect)(()=>()=>Te.forEach(e=>e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url)),[Te]);let z=(0,I.useCallback)((e,t)=>{let n=kd(`toast`);Ve(r=>[...r,{id:n,message:e,tone:t}]);let r=window.setTimeout(()=>{Ve(e=>e.filter(e=>e.id!==n)),delete zt.current[n]},2600);zt.current[n]=r},[]),dr=(0,I.useCallback)(()=>{Ht.current={},pt(e=>e+1)},[]),fr=(0,I.useCallback)(async()=>{dr(),Ye(null);let e=Cn??Pn;if(e)try{await t.loadDirectory(e)}catch{Pn&&Pn!==e&&(Ge(Pn),await t.loadDirectory(Pn).catch(()=>void 0))}h&&qe({path:h,name:h.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??h,content:``,loading:!0,error:null,line:g})},[t,Cn,Pn,g,h,dr]),pr=(0,I.useCallback)(async e=>{let n=mt;if(ht(e),u){if(!Pn){ht(n),z(`Open the repository folder first.`,`warn`);return}try{_t((await t.writeWorkspaceCommitPreferences(Pn??u.thread.cwd,{provider:e})).filePath),dr()}catch(e){ht(n),z(AA(e,`Failed to save the commit provider for this project.`),`err`)}}},[t,u,Pn,mt,z,dr]),mr=(0,I.useCallback)(async()=>{if(!(!u||bt||St)){if(!Pn){z(`Open the repository folder first.`,`warn`);return}xt(!0);try{yt(await t.generateCommitMessage({cwd:Pn,providerId:mt})),z(`Drafted a commit message.`,`ok`)}catch(e){z(AA(e,`Failed to draft a commit message.`),`err`)}finally{xt(!1)}}},[t,u,Pn,St,bt,mt,z]),hr=(0,I.useCallback)(async()=>{if(!(!u||bt||St)){if(!Pn){z(`Open the repository folder first.`,`warn`);return}if(!vt.trim()){z(`Enter a commit message first.`,`warn`);return}Ct(!0);try{let e=await t.commitWorkingTree({cwd:Pn,message:vt});yt(``),dr(),z(e.stagedAll?`Staged all files and created the commit.`:`Created the commit.`,`ok`)}catch(e){z(AA(e,`Failed to create the commit.`),`err`)}finally{Ct(!1)}}},[t,u,Pn,St,bt,vt,z,dr]),gr=(0,I.useCallback)(e=>{let t=e;window.requestAnimationFrame(()=>{let e=Mt.current;if(!e)return;e.focus();let n=t?.length??e.value.length;try{e.setSelectionRange(n,n)}catch{}})},[]),_r=(0,I.useCallback)(()=>Mt.current?.value??le,[le]),vr=(0,I.useCallback)(e=>{let t=_r(),n=typeof e==`function`?e(t):e;return ue(n),Dt(e=>e+1),n},[_r]),yr=(0,I.useCallback)(()=>{ue(``),Dt(e=>e+1),Ce([]),P([]),Oe([]),Ee(e=>(e.forEach(e=>e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url)),[])),Pe(null),F(``),Le(0)},[]),br=(0,I.useCallback)((e,t)=>{let n={...t,id:kd(`queue`),mentions:[...t.mentions],skills:[...t.skills],files:[...t.files],images:[...t.images]};ze(t=>({...t,[e]:[...t[e]??[],n]}))},[]),xr=(0,I.useCallback)((e,t)=>{ze(n=>{let r=n[e]??[],i=r.filter(e=>e.id!==t);if(i.length===r.length)return n;if(i.length===0){let t={...n};return delete t[e],t}return{...n,[e]:i}})},[]),Sr=(0,I.useCallback)((e,t)=>{ze(n=>({...n,[e]:[t,...n[e]??[]]}))},[]),Cr=(0,I.useCallback)((e,t=`chat`,r)=>{e!==l&&(Wt.current=null,Gt.current=null,qt.current=!0);let i=()=>{if(t===`chat`){n({to:`/threads/$threadId`,params:{threadId:e}});return}n({to:`/threads/$threadId/$section`,params:{threadId:e,section:hd(t)}})};if(r?.immediate||l===e){i();return}(0,I.startTransition)(i)},[l,n]),wr=(0,I.useCallback)(e=>{Wt.current=null,Gt.current=null,Kt.current=null,qt.current=!0,at(!1),delete Jt.current[e],Ze(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n}),x(!1),Cr(e,`chat`,{immediate:!0}),e===l&&window.requestAnimationFrame(()=>{lr({extraDelay:!0,force:!0})})},[l,Cr,lr]),Tr=(0,I.useCallback)((e,t)=>{if(!l)return;let r=typeof t?.line==`number`&&t.line>0?t.line:null,i=t?.source??`chat`,a=e.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??e;or(),i===`chat`&&(Wt.current=l),qe(t=>t?.path===e&&!t.loading?{...t,line:r}:{path:e,name:a,content:t?.path===e?t.content:``,loading:t?.path===e?t.loading:!0,error:null,line:r}),n({to:`/threads/$threadId/$section`,params:{threadId:l,section:hd(`editor`)},search:{path:e,line:r?String(r):void 0,from:i}})},[l,n,or]),Er=(0,I.useCallback)(e=>{if(e===`terminal`){ye(!0),N(!0);return}T(!1),D(e),C(!0),x(!1),l&&Cr(l,Ld(e))},[l,Cr]),Dr=(0,I.useCallback)(()=>{p||(T(!1),C(!1),x(e=>!e))},[p]),Or=(0,I.useCallback)((e,t=`chat`)=>{if(!l)return;let r=e??Fn?.id??Mn[0]?.id??null;r&&Ye(r),or(),t===`chat`&&(Wt.current=l),n({to:`/threads/$threadId/$section`,params:{threadId:l,section:hd(`review`)},search:{diff:r??void 0,from:t}})},[l,Mn,n,or,Fn]),kr=(0,I.useCallback)(()=>{if(C(!1),l){if(!p){T(!0),window.requestAnimationFrame(()=>{Cr(l,`chat`,{immediate:!0})});return}Cr(l,`chat`,{immediate:!0})}},[l,p,Cr]);(0,I.useEffect)(()=>{i.section===`skills`&&oe(!0)},[i.section]);let Ar=(0,I.useCallback)(()=>{oe(!0),x(!1)},[]),jr=(0,I.useCallback)(()=>{oe(!1),i.section===`skills`&&l&&Cr(l,`chat`)},[l,Cr,i.section]),Mr=(0,I.useCallback)(()=>{k(!0),x(!1),ne(!1),ee(!1)},[]),Nr=(0,I.useCallback)(()=>{k(!1)},[]),Pr=(0,I.useCallback)(async n=>{if(se)return null;ce(!0);try{let e=await t.createThread(wn,{title:`New Session`,cwd:n});return M(n),Ae(t=>[e,...t.filter(t=>t!==e)].slice(0,6)),Cr(e,`chat`),x(!1),C(p),yr(),z(`New session — ${n}`,`ok`),e}catch(t){return z(AA(t,e.transport.error??`Failed to start session`),`err`),null}finally{ce(!1)}},[t,p,wn,Cr,se,z,yr,e.transport.error]),Fr=(0,I.useCallback)(()=>{M(e=>e&&e.trim().length>0?e:u?.thread.cwd??gA),ie(!0),x(!1),ee(!1)},[u]),Ir=(0,I.useCallback)(async e=>{await Pr(e??j)&&ie(!1)},[Pr,j]),Lr=(0,I.useCallback)(async()=>{Fr()},[Fr]),Rr=(0,I.useCallback)(async()=>{if(!l){await Lr();return}let e=await t.forkThread(l);Ae(t=>[e,...t.filter(t=>t!==e)].slice(0,6)),Cr(e,`chat`),z(`/fork — session forked`,`ok`)},[t,l,Lr,Cr,z]),zr=(0,I.useCallback)(async()=>{l&&(await t.compactThread(l),z(`/compact — transcript summarized`,`ok`))},[t,l,z]),Br=(0,I.useCallback)(async e=>{if(l){if(dn){z(`Wait for the current response to finish before rolling back.`,`err`);return}if(window.confirm(`Roll back from this prompt? This will remove this prompt and every later message, then undo the file changes from those turns.`))try{await t.rollbackToTurn(l,e),await fr(),z(`/rollback — reverted to selected prompt`,`ok`)}catch(e){z(AA(e,`Failed to roll back from the selected prompt.`),`err`)}}},[t,l,dn,z,fr]),Vr=(0,I.useCallback)(async e=>{await t.updateSettings({model:e}),ne(!1),z(`Model: ${e}`,``)},[t,z]),Hr=(0,I.useCallback)(e=>{kt(e),k(!1),z(`Theme: ${e}`,``)},[z]),Ur=(0,I.useCallback)(async()=>{let e=xd[(xd.indexOf(Sn)+1)%xd.length];await t.updateSettings(Fd(e)),z(`Approval: ${Sd[e]}`,``)},[t,Sn,z]),Wr=(0,I.useCallback)(()=>{Pe(null),F(``),Le(0)},[]);(0,I.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){e.preventDefault(),ee(!0),x(!1);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`n`){e.preventDefault(),Lr();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`g`){e.preventDefault(),z(`Ctrl+G — opening editor bridge`,``);return}e.key===`Escape`&&(ee(!1),ne(!1),k(!1),ie(!1),Ue(null),Wr())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Wr,Lr,z]),(0,I.useEffect)(()=>{let e=e=>{let t=e.target;t&&(t.closest(`#ctxmenu`)||Ue(null),!t.closest(`#hmodel`)&&!t.closest(`#mpicker`)&&ne(!1),!t.closest(`#htheme`)&&!t.closest(`#tpicker`)&&k(!1),!t.closest(`#ta`)&&!t.closest(`#slashpop`)&&Wr())};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[Wr]);let Gr=(0,I.useCallback)(e=>{gr(vr(t=>t.replace(/(?:^|\s)([@$/][^\s]*)$/,t=>t.replace(/[@$/][^\s]*$/,e))))},[gr,vr]),Kr=(0,I.useCallback)(e=>{Ce(t=>t.some(t=>t.id===e.id||t.path===e.path)?t:[...t,e]),Wr(),gr(vr(t=>ef(t,e))),z(`/mention — ${Qd(e)} linked`,`ok`)},[Wr,gr,z,vr]),qr=(0,I.useCallback)(n=>{let r=[...e.installedSkills,...e.remoteSkills].find(e=>e.name===n);r&&(r.source===`remote`?(t.installSkill(r.id),z(`Installing $${r.name}`,`ok`)):(P(e=>e.some(e=>e.id===r.id)?e:[...e,{...r,source:`installed`}]),z(`$${r.name} attached`,`ok`)),Wr(),gr(vr(e=>e.replace(/(?:^|\s)\$[^\s]*$/,``))))},[t,Wr,gr,z,vr,e.installedSkills,e.remoteSkills]),Jr=(0,I.useMemo)(()=>Se.filter(e=>$d(en,e)),[en,Se]),Yr=(0,I.useCallback)(async(e,n=!1)=>{let[r,...i]=e.trim().split(/\s+/),a=i.join(` `);switch(r){case`/new`:await Lr();break;case`/fork`:await Rr();break;case`/compact`:await zr();break;case`/mention`:Pe(`mention`),F(a);break;case`/model`:ne(e=>!e);break;case`/permissions`:await Ur();break;case`/plan`:ge(!0),z(`Plan mode enabled`,`ok`);break;case`/review`:fe(`review`),Er(`diff`),n&&l?(await Qn({threadId:l,mode:`review`,prompt:a,mentions:Jr,skills:we,files:De,images:Te,settings:wn},`review`),yr()):z(`/review ready`,`ok`);break;case`/ps`:Er(`terminal`);break;case`/diff`:Er(`diff`);break;case`/skills`:Ar();break;case`/mcp`:Er(`config`),l&&Cr(l,`mcp`);break;case`/theme`:Mr(),z(`Theme picker opened`,`ok`);break;case`/status`:Er(`config`),z(`Session diagnostics opened`,`ok`);break;case`/copy`:Gn&&(await DA(Gn.text),z(`Copied latest response`,`ok`));break;case`/clear`:yr(),z(`/clear — composer reset`,``);break;case`/experimental`:Er(`config`);break;case`/init`:vr(`/init Generate AGENTS.md for this repo`),gr(`/init Generate AGENTS.md for this repo`);break;case`/resume`:case`/feedback`:case`/apps`:case`/exit`:case`/quit`:case`/personality`:z(`${r} queued`,``);break;case`/logout`:await t.logoutAccount(),z(`Signed out of account`,`ok`);break;default:n&&l&&(await Qn({threadId:l,mode:de,prompt:e,mentions:Jr,skills:we,files:De,images:Te,settings:wn}),yr())}},[t,l,zr,de,Ur,Lr,Rr,Gn,Cr,Er,Mr,Ar,z,yr,Qn,gr,Te,De,Jr,we,vr,wn]),Xr=(0,I.useMemo)(()=>{let e=[{label:`Session`,items:[{icon:`💬`,name:`New Session (/new)`,key:`⌘N`,command:{type:`createSession`}},{icon:`⑂`,name:`Fork Session (/fork)`,key:``,command:{type:`forkSession`}},{icon:`🗜`,name:`Compact Transcript (/compact)`,key:``,command:{type:`compactSession`}},{icon:`🗑`,name:`Clear Composer`,key:``,command:{type:`resetComposer`}}]},{label:`Navigate`,items:[{icon:`📁`,name:`Files Panel`,key:``,command:{type:`openPanel`,tab:`files`}},{icon:`⎇`,name:`Branches Panel`,key:``,command:{type:`openPanel`,tab:`graph`}},{icon:`⬛`,name:`Terminal Dock (/ps)`,key:``,command:{type:`openPanel`,tab:`terminal`}},{icon:`⑂`,name:`Multi-agent Panel`,key:``,command:{type:`openPanel`,tab:`agents`}},{icon:`📋`,name:`Skills Library (/skills)`,key:``,command:{type:`openSkills`}},{icon:`⚙`,name:`Config & Feature Flags`,key:`⌘,`,command:{type:`openPanel`,tab:`config`}}]},{label:`Slash`,items:Td.map(e=>({icon:`/`,name:`${e.cmd} — ${e.dsc}`,key:``,command:{type:`runSlash`,slash:e.cmd}}))},...Dn.length>0?[{label:`Model`,items:Dn.map(e=>({icon:`🤖`,name:e.displayName,key:``,command:{type:`selectModel`,modelId:e.id}}))}]:[]],t=je.trim().toLowerCase();return t?e.map(e=>({...e,items:e.items.filter(n=>`${n.name} ${e.label}`.toLowerCase().includes(t))})).filter(e=>e.items.length>0):e},[je,Dn]),Zr=(0,I.useCallback)(e=>{switch(e.type){case`createSession`:Lr();break;case`forkSession`:Rr();break;case`compactSession`:zr();break;case`openSkills`:Ar();break;case`resetComposer`:yr();break;case`openPanel`:Er(e.tab);break;case`runSlash`:Yr(e.slash);break;case`selectModel`:Vr(e.modelId);break}},[zr,Lr,Rr,Er,Ar,yr,Yr,Vr]),Qr=(0,I.useCallback)(e=>{Ee(t=>{let n=t.find(t=>t.id===e);return n?.url.startsWith(`blob:`)&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)})},[]),$r=(0,I.useCallback)(e=>{Vt.current=e,Bt.current===null&&(Bt.current=window.requestAnimationFrame(()=>{Bt.current=null;let e=Vt.current;(0,I.startTransition)(()=>{ue(e)});let t=e.match(/(?:^|\s)([@$/])([^\s]*)$/);if(!t){Wr();return}let n=t[1],r=t[2]??``;if(n===`/`){Pe(`slash`),F(`/${r}`),Le(0);return}if(n===`@`){Pe(`mention`),F(r),Le(0);return}if(n===`$`){Pe(`skill`),F(r),Le(0);return}Wr()}))},[Wr]),ei=(0,I.useCallback)(t=>{if(t.mode===`slash`){Gr(`${t.value} `),Wr();return}if(t.mode===`mention`){let n=e.mentionCatalog.find(e=>e.id===t.id);n&&Kr(n);return}qr(t.value)},[Kr,qr,Wr,Gr,e.mentionCatalog]),ti=(0,I.useCallback)(async n=>{let r=n??Mt.current?.value??le,a=r.trim(),o=Se.filter(e=>$d(r,e)),s={composerValue:r,mentions:[...Se],skills:[...we],files:[...De],images:[...Te]};if(!(!a&&o.length===0&&we.length===0&&De.length===0&&Te.length===0))try{let n=l,r=n?e.threads.some(e=>e.thread.id===n):!1;if((!n||!r)&&(n=await t.createThread(wn,{title:`New Session`,cwd:j}),Ae(e=>[n,...e.filter(e=>e!==n)].slice(0,6)),Cr(n,`chat`)),a.startsWith(`/`)){await Yr(a,!0);return}let s=de===`review`||i.section===`review`?`review`:`chat`,c=a,u=Te.length===0;if(dn){br(n,{mode:s,prompt:c,mentions:o,skills:we,files:De,images:Te}),yr(),z(`Message queued`,`ok`);return}u&&(yr(),await kA()),n=await Qn({threadId:n,mode:s,prompt:c,mentions:o,skills:we,files:De,images:Te,settings:wn}),u||yr()}catch(t){s.images.length===0&&!_r().trim()&&(ue(s.composerValue),Dt(e=>e+1),Ce(s.mentions),P(s.skills),Oe(s.files),Pe(null),F(``),Le(0)),z(AA(t,e.transport.error??`Failed to send message`),`err`)}},[t,l,dn,le,de,br,_r,Cr,z,yr,i.section,Yr,Qn,e.transport.error,e.threads,Se,Te,De,we,wn,j]),ni=(0,I.useCallback)(async e=>{if(Ne&&qn.length>0){if(e.key===`ArrowDown`){e.preventDefault(),Le(e=>Math.min(qn.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Le(e=>Math.max(0,e-1));return}if(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey){e.preventDefault(),ei(qn[Ie]);return}if(e.key===`Escape`){Wr();return}}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`g`){e.preventDefault(),z(`Ctrl+G — opening editor bridge`,``);return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),await ti(e.currentTarget.value))},[Wr,qn,ei,z,Ie,Ne,ti]),ri=(0,I.useCallback)((e,t)=>{let n=e.filter(e=>e.type.startsWith(`image/`));if(n.length===0)return 0;let r=Date.now();return Ee(e=>[...e,...n.map((e,t)=>{let n=e.type.split(`/`)[1]?.replace(/[^a-z0-9]/gi,``).toLowerCase()||`png`;return{id:kd(`image`),name:e.name||`pasted-image-${r}-${t+1}.${n}`,url:URL.createObjectURL(e),size:Ud(e.size),file:e}})]),z(n.length===1?t===`paste`?`Image pasted`:`Image attached`:t===`paste`?`${n.length} images pasted`:`${n.length} images attached`,`ok`),n.length},[z]),ii=(0,I.useCallback)(e=>{let t=Array.from(e.clipboardData.files??[]);ri(t.length>0?t:Array.from(e.clipboardData.items??[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e),`paste`)!==0&&e.preventDefault()},[ri]),ai=(0,I.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length!==0&&(ri(t,`attach`),e.target.value=``)},[ri]),oi=(0,I.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length!==0&&(Oe(e=>[...e,...t.map(e=>({id:kd(`file`),name:e.name,size:Ud(e.size),file:e}))]),e.target.value=``,z(`File attached`,`ok`))},[z]),si=(0,I.useCallback)(async()=>{if(!l)return;let e=await t.interruptTurn(l);z(e?`Stop requested`:`No active turn to stop`,e?`warn`:``)},[t,l,z]),ci=(0,I.useCallback)(e=>{P(t=>t.filter(t=>t.id!==e))},[]),li=(0,I.useCallback)(e=>{Oe(t=>t.filter(t=>t.id!==e))},[]),ui=(0,I.useCallback)(async e=>{if(!l)return;let n=(Re[l]??[]).find(t=>t.id===e);if(n){if(xr(l,e),dn){if(await t.applySteer({threadId:l,prompt:n.prompt,mentions:n.mentions,skills:n.skills,files:n.files,images:n.images})){z(`Queued message sent as steer`,`ok`);return}Sr(l,n),z(`No active turn to steer`,`warn`);return}try{await Qn({threadId:l,mode:n.mode,prompt:n.prompt,mentions:n.mentions,skills:n.skills,files:n.files,images:n.images,settings:wn})}catch(e){Sr(dA(e)??l,n)}}},[t,l,dn,wn,Sr,z,Re,xr,Qn]),di=(0,I.useCallback)(e=>{if(on.length<=1){z(`Cannot close last tab`,``);return}let t=on.filter(t=>t!==e);Ae(t),e===l&&t[0]&&Cr(t[0],`chat`)},[l,Cr,z,on]),fi=Ne?q[Ne]:dn?`Queue a follow-up while the agent is still running…`:q.slash,pi=`${CA((0,I.useMemo)(()=>EA(R,e.settings.provider),[R,e.settings.provider]))} / 200k`,mi=(0,I.useMemo)(()=>[...e.account.usageWindows].sort((e,t)=>(e.windowDurationMins??2**53-1)-(t.windowDurationMins??2**53-1)).slice(0,2),[e.account.usageWindows]),hi=e.transport.status===`connected`?`Connected`:e.transport.status,gi=wA(u?.thread.cwd),_i=u?.thread.gitInfo?.branch??`workspace`,vi=Sd[Sn].toLowerCase(),yi=dn?`Streaming`:`Idle`,bi=(0,I.useMemo)(()=>u?.terminals.filter(e=>e.source===`shell`)??[],[u?.terminals]),xi=bi.length>0,Si=(0,I.useCallback)(()=>{!l||!u?.thread.cwd||xi||t.startProjectTerminal(l,u.thread.cwd).catch(e=>{z(e instanceof Error?e.message:`Unable to start the project shell.`,`err`)})},[t,u?.thread.cwd,l,xi,z]);(0,I.useEffect)(()=>{if(!(!_e||!ve||be)){if(typeof window>`u`){xe(!0);return}return nt.current=window.requestAnimationFrame(()=>{nt.current=null,xe(!0)}),()=>{nt.current!==null&&(window.cancelAnimationFrame(nt.current),nt.current=null)}}},[ve,be,_e]),(0,I.useEffect)(()=>{if(!(!_e||!be||!l||!u?.thread.cwd||xi)){if(typeof window>`u`){Si();return}return rt.current=window.requestAnimationFrame(()=>{rt.current=null,Si()}),()=>{rt.current!==null&&(window.cancelAnimationFrame(rt.current),rt.current=null)}}},[u?.thread.cwd,l,xi,Si,be,_e]);let Ci=(0,I.useCallback)(()=>{_e||(ye(!0),N(!0))},[_e]),wi=(0,I.useCallback)(()=>{typeof window<`u`&&(nt.current!==null&&(window.cancelAnimationFrame(nt.current),nt.current=null),rt.current!==null&&(window.cancelAnimationFrame(rt.current),rt.current=null)),N(!1)},[]),Ti=(0,I.useCallback)(e=>{DA(e).then(()=>z(`Copied!`,`ok`))},[z]),Ei=(0,I.useCallback)((e,t)=>{Tr(e,{line:t,source:`chat`})},[Tr]),Di=(0,I.useCallback)(e=>{Or(e)},[Or]),Oi=(0,I.useCallback)(e=>{Tr(e,{source:`chat`})},[Tr]),ki=(0,I.useCallback)(()=>{Yr(`/plan`)},[Yr]),Ai=(0,I.useCallback)(e=>{vr(e),gr(e)},[gr,vr]),ji=(0,I.useCallback)(e=>{Yr(e)},[Yr]),Mi=(0,I.useCallback)((e,t)=>{e.preventDefault(),Ue({x:Math.min(e.clientX,window.innerWidth-172),y:Math.min(e.clientY,window.innerHeight-212),item:t})},[]),Ni=(0,I.useCallback)(()=>{if(l){if(_===`ops`){D(`files`),C(!0),Cr(l,`ops`);return}Cr(l,_)}},[l,_,Cr]),B=(0,I.useCallback)(()=>{if(l){if(y===`ops`){D(`files`),C(!0),Cr(l,`ops`);return}Cr(l,y)}},[l,Cr,y]),Pi=(0,I.useMemo)(()=>i.section!==`editor`||!h?null:Ke?.path===h?{...Ke,line:g}:{path:h,name:h.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??h,content:``,loading:!0,error:null,line:g},[g,h,Ke,i.section]),Fi=(0,I.useCallback)(async(e,n)=>{await t.saveFile(e,n),qe(t=>t?.path===e?{...t,content:n,loading:!1,error:null}:t),z(`Saved ${e.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??e}`,`ok`)},[t,z]),Ii=_===`ops`?`Back to Files`:`Back to Chat`,Li=(0,I.useCallback)(async e=>{if(e.kind===`directory`){Ge(e.path),qe(null);return}Tr(e.path,{source:`ops`})},[Tr]),Ri=()=>{if(!u)return(0,L.jsx)(`div`,{className:`empty-panel`,children:`No active thread.`});if(E===`graph`)return ot?(0,L.jsxs)(`div`,{className:`graph-panel-stack`,children:[(0,L.jsx)(US,{branchLabel:zn,committing:St,dirty:Ln,generating:bt,hasStagedChanges:Rn,message:vt,onCommit:()=>void hr(),onGenerate:()=>void mr(),onMessageChange:yt,onProviderChange:e=>{pr(e)},preferencesPath:gt,providers:e.providers,selectedProviderId:mt,summary:In?.summary??`Working tree clean`}),ot.source===`session`?(0,L.jsx)(`div`,{className:`panel-hint`,children:ut?`Showing session-derived history because local git output is unavailable.`:`Showing session-derived history.`}):ct?(0,L.jsx)(`div`,{className:`panel-hint`,children:`Refreshing git history…`}):null,(0,L.jsx)(qS,{model:ot,onOpenThread:wr})]}):(0,L.jsx)(`div`,{className:`empty-panel`,children:ct?`Loading git history…`:`No repository graph available for this session yet.`});if(E===`files`){let t=new Map,n=u.thread.cwd,r=Cn??n,a=e.directoryCatalogRoot===r?e.directoryCatalog:[],o=new Set(Jr.map(e=>e.path)),s=r===n?``:r.slice(n.length).replace(/^\/+/u,``),c=[{label:n.split(`/`).filter(Boolean).pop()??n,path:n},...s.split(`/`).filter(Boolean).reduce((e,t)=>{let r=e.at(-1)?.path??n;return e.push({label:t,path:`${r.replace(/\/+$/u,``)}/${t}`}),e},[])],l=r===n?null:r.slice(0,r.lastIndexOf(`/`))||n;return jn.forEach(e=>{e.changes.forEach(e=>{t.set(e.path,e.kind.type===`add`?`new`:e.kind.type===`delete`?`del`:`mod`)})}),(0,L.jsx)(rA,{breadcrumbs:c,currentPath:r,directoryEntries:a,editorPath:i.section===`editor`?h:null,loading:e.directoryCatalogRoot!==r,mentionedPaths:o,modifiedByPath:t,onNavigate:e=>{Ge(e),qe(t=>t&&qd(e,t.path)?t:null)},onOpenEntry:Li,parentPath:l,rootPath:n})}if(E===`diff`){let e=Mn.reduce((e,t)=>e+t.additions,0),t=Mn.reduce((e,t)=>e+t.removals,0);return(0,L.jsxs)(`div`,{className:`diff-review-shell`,children:[(0,L.jsxs)(`div`,{className:`panel-hint`,children:[`Patch review · `,Mn.length,` changed file`,Mn.length===1?``:`s`,` · +`,e,` / -`,t]}),Mn.length===0?(0,L.jsx)(`div`,{className:`empty-panel`,children:`No diff items in this thread yet.`}):null,Mn.length>0?(0,L.jsxs)(`div`,{className:`diff-review-layout`,children:[(0,L.jsx)(`div`,{className:`diff-review-sidebar`,children:Mn.map(e=>(0,L.jsxs)(`button`,{className:H(`diff-review-entry`,Fn?.id===e.id&&`active`),type:`button`,onClick:()=>Ye(e.id),children:[(0,L.jsxs)(`div`,{className:`diff-review-entry-top`,children:[(0,L.jsx)(`span`,{className:H(`diff-kind-pill`,e.kind.type===`add`&&`new`,e.kind.type===`delete`&&`del`),children:bf(e.kind)}),(0,L.jsx)(`span`,{className:H(`diff-status`,e.status===`inProgress`&&`live`,e.status===`failed`&&`err`),children:e.status===`inProgress`?`editing`:e.status})]}),(0,L.jsx)(`div`,{className:`diff-review-entry-path`,children:e.path}),(0,L.jsxs)(`div`,{className:`diff-review-entry-meta`,children:[(0,L.jsxs)(`span`,{children:[`+`,e.additions]}),(0,L.jsxs)(`span`,{children:[`-`,e.removals]}),(0,L.jsxs)(`span`,{children:[e.hunks,` hunk`,e.hunks===1?``:`s`]})]})]},e.id))}),Fn?(0,L.jsxs)(`div`,{className:`diff-review-main`,children:[(0,L.jsxs)(`div`,{className:`diff-focus-head`,children:[(0,L.jsx)(`div`,{className:`diff-focus-title`,children:Fn.path}),(0,L.jsxs)(`div`,{className:`diff-focus-meta`,children:[(0,L.jsx)(`span`,{className:H(`diff-kind-pill`,Fn.kind.type===`add`&&`new`,Fn.kind.type===`delete`&&`del`),children:bf(Fn.kind)}),(0,L.jsx)(`span`,{className:H(`diff-status`,Fn.status===`inProgress`&&`live`,Fn.status===`failed`&&`err`),children:Fn.status===`inProgress`?`editing`:Fn.status}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[`+`,Fn.additions]}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[`-`,Fn.removals]}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[Fn.hunks,` hunk`,Fn.hunks===1?``:`s`]})]})]}),(0,L.jsx)(sA,{entry:Fn})]}):null]}):null,Bn.length>0?(0,L.jsx)(`div`,{className:`review-list`,children:Bn.map(e=>(0,L.jsxs)(`div`,{className:H(`review-item`,e.severity),children:[(0,L.jsxs)(`div`,{className:`review-header`,children:[(0,L.jsx)(`span`,{children:e.severity}),(0,L.jsx)(`span`,{children:e.file.split(`/`).slice(-2).join(`/`)}),(0,L.jsxs)(`span`,{children:[`:`,e.line]})]}),(0,L.jsx)(`div`,{className:`review-title`,children:e.title}),(0,L.jsx)(`div`,{className:`review-summary`,children:e.summary})]},e.id))}):u.review.length>0?(0,L.jsx)(`div`,{className:`empty-panel`,children:`No review findings mapped to the selected file.`}):null,xn.length>0?(0,L.jsx)(`div`,{className:`panel-actions`,children:xn.map(e=>ir(e))}):null]})}if(E===`terminal`)return(0,L.jsx)(`div`,{className:`empty-panel`,children:`Terminal moved to the bottom dock. Use the Shell toggle above the prompt.`});if(E===`agents`){let t=e.threads.filter(e=>e.thread.agentNickname||e.thread.agentRole);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`panel-head-row`,children:[(0,L.jsx)(`div`,{className:`panel-hint`,children:`⑂ Multi-agent session`}),(0,L.jsx)(`button`,{className:`abtn yes small`,type:`button`,onClick:()=>z(`spawn_agent("alpha") → started`,`ok`),children:`+ Spawn`})]}),Wn.length===0&&t.length===0?(0,L.jsx)(`div`,{className:`empty-panel`,children:`No subagent activity in this thread yet.`}):null,Wn.map(e=>(0,L.jsxs)(`div`,{className:`agc`,children:[(0,L.jsxs)(`div`,{className:`agh`,children:[(0,L.jsx)(`div`,{className:`agdot`}),(0,L.jsxs)(`span`,{className:`agn`,children:[`⑂ `,e.tool]}),(0,L.jsx)(`span`,{className:`ags`,children:e.status})]}),(0,L.jsx)(`div`,{className:`agt`,children:e.prompt??`Subagent activity`}),e.receiverThreadIds.map(t=>{let n=e.agentsStates[t],r=n?.status===`completed`?100:n?.status===`running`?58:18;return(0,L.jsxs)(`div`,{className:`agent-progress`,children:[(0,L.jsxs)(`div`,{className:`agent-progress-header`,children:[(0,L.jsx)(`span`,{children:t.slice(0,12)}),(0,L.jsx)(`span`,{children:n?.status??`pending`})]}),(0,L.jsx)(`div`,{className:`agprog`,children:(0,L.jsx)(`div`,{className:`agbar`,style:{width:`${r}%`}})}),(0,L.jsx)(`div`,{className:`agent-progress-copy`,children:n?.message??`No update yet.`})]},t)})]},e.id)),t.map(e=>(0,L.jsxs)(`div`,{className:`agc`,children:[(0,L.jsxs)(`div`,{className:`agh`,children:[(0,L.jsx)(`div`,{className:`agdot`}),(0,L.jsxs)(`span`,{className:`agn`,children:[`⑂ `,e.thread.agentNickname??c[e.thread.id]??Vd(e.thread)]}),(0,L.jsx)(`span`,{className:`ags`,children:e.thread.status.type})]}),(0,L.jsx)(`div`,{className:`agt`,children:e.thread.agentRole??`Subagent thread`})]},e.thread.id))]})}return(0,L.jsx)(`div`,{children:(0,L.jsx)($S,{snapshot:e,activeThreadLabel:d,actions:t,activeTheme:Ot,onOpenSkills:Ar,onOpenTheme:Mr,pushToast:z,selectModel:Vr})})},zi=()=>{if(!Ne)return null;let t=Ne===`mention`&&!!u&&e.directoryCatalogRoot!==(u?.thread.cwd??null),n=Ne===`mention`?t?`Loading files from the current directory…`:`No files found for this query.`:Ne===`skill`?`No skills matched.`:`No commands matched.`;return(0,L.jsx)(`div`,{id:`slashpop`,style:{display:`block`},children:qn.length>0?qn.map((e,t)=>(0,L.jsxs)(`button`,{className:H(`spi`,t===Ie&&`sel`),type:`button`,onMouseDown:t=>{t.preventDefault(),ei(e)},children:[(0,L.jsx)(`span`,{className:`sp-cmd`,children:e.label}),(0,L.jsx)(`span`,{className:`sp-dsc`,children:e.description})]},e.id)):(0,L.jsx)(`div`,{className:`sp-empty`,children:n})})},Bi=nn&&Jn;return nn?(0,L.jsx)(`main`,{className:`workspace-shell connection-loading-shell`,children:(0,L.jsx)(fS,{messages:xA,metaText:Bi?`Restoring ${Hd(d,42)}`:`Connecting to workspace backend`,visibleRangeEnd:Bi?xA.length-1:yA.length-1,visibleRangeStart:Bi?yA.length:0})}):(0,L.jsxs)(`main`,{className:H(`workspace-shell`,yn&&`overlay-open`),children:[(0,L.jsxs)(`header`,{id:`hdr`,children:[(0,L.jsx)(`button`,{className:`hb mbtn`,type:`button`,onClick:Dr,title:`Menu`,children:`☰`}),(0,L.jsxs)(`div`,{className:`logo`,children:[(0,L.jsx)(cS,{alt:``,className:`logo-ico`}),(0,L.jsx)(`span`,{children:`Nomadex`})]}),(0,L.jsx)(`div`,{className:`hsep`}),(0,L.jsx)(`button`,{className:H(`hbadge`,Cd[Sn]),id:`aprbadge`,type:`button`,onClick:()=>void Ur(),title:`Cycle approval mode`,children:Sd[Sn]}),(0,L.jsx)(`button`,{className:`hb`,type:`button`,onClick:()=>ee(!0),title:`Command palette`,children:`⌘`}),(0,L.jsx)(`button`,{className:`hb`,type:`button`,onClick:()=>Er(`agents`),title:`Multi-agent panel`,children:`⑂`}),(0,L.jsx)(`button`,{className:`hb`,type:`button`,onClick:()=>Er(`files`),title:`Files and diff`,children:`📁`}),(0,L.jsx)(`button`,{className:`hb`,type:`button`,onClick:Ar,title:`Skills library`,children:`📋`}),(0,L.jsx)(`button`,{className:`hb`,type:`button`,onClick:()=>Er(`config`),title:`Config and settings`,children:`⚙`}),(0,L.jsxs)(`button`,{className:`htheme`,id:`htheme`,type:`button`,onClick:()=>{ne(!1),k(e=>!e)},title:`Theme picker`,children:[(0,L.jsx)(`span`,{className:`theme-dot`}),(0,L.jsx)(`span`,{className:`theme-label`,children:An.name}),(0,L.jsx)(`span`,{className:`hmodel-arrow`,children:`▾`})]}),(0,L.jsxs)(`button`,{className:`hmodel`,id:`hmodel`,type:`button`,disabled:Dn.length===0,ref:Pt,onClick:()=>{Dn.length!==0&&(k(!1),ne(e=>!e))},title:Dn.length===0?`${En.displayName} uses its own CLI model configuration`:void 0,children:[(0,L.jsx)(`div`,{className:`mdot`}),(0,L.jsx)(`span`,{id:`mlabel`,children:kn}),(0,L.jsx)(`span`,{className:`hmodel-arrow`,children:`▾`})]})]}),(0,L.jsxs)(`div`,{id:`layout`,children:[!p&&b?(0,L.jsx)(`button`,{id:`sbo`,className:`show`,type:`button`,"aria-label":`Close sidebar`,onClick:()=>x(!1)}):null,_n?(0,L.jsxs)(`aside`,{id:`sb`,className:H(!p&&b&&`open`),children:[(0,L.jsx)(`button`,{className:`snew`,type:`button`,onClick:()=>void Lr(),children:`+ New Session`}),(0,L.jsx)(`div`,{className:`shist`,children:[`Today`,`Yesterday`,`Earlier`].map(e=>Tn[e].length>0?(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`sgl`,children:e}),Tn[e].map(e=>(0,L.jsxs)(`button`,{className:H(`si`,e.thread.id===l&&`active`),type:`button`,onClick:()=>wr(e.thread.id),children:[(0,L.jsx)(`span`,{children:e.thread.agentNickname?`⑂`:`💬`}),(0,L.jsx)(`span`,{className:`si-t`,children:c[e.thread.id]??Vd(e.thread)})]},e.thread.id))]},e):null)}),(0,L.jsxs)(`div`,{className:`sbot`,children:[(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>ee(!0),children:[(0,L.jsx)(`span`,{children:`⌘`}),(0,L.jsx)(`span`,{children:`Command palette`}),(0,L.jsx)(`span`,{className:`skbd`,children:`⌘K`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>void Yr(`/review`),children:[(0,L.jsx)(`span`,{children:`🔍`}),(0,L.jsx)(`span`,{children:`/review working tree`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>void Yr(`/fork`),children:[(0,L.jsx)(`span`,{children:`⑂`}),(0,L.jsx)(`span`,{children:`/fork session`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>void Yr(`/compact`),children:[(0,L.jsx)(`span`,{children:`🗜`}),(0,L.jsx)(`span`,{children:`/compact transcript`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:Ar,children:[(0,L.jsx)(`span`,{children:`📋`}),(0,L.jsx)(`span`,{children:`Skills library`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:Mr,children:[(0,L.jsx)(`span`,{children:`◐`}),(0,L.jsx)(`span`,{children:`Theme picker`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>Ai(`/init Generate AGENTS.md scaffold`),children:[(0,L.jsx)(`span`,{children:`📋`}),(0,L.jsx)(`span`,{children:`/init AGENTS.md`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>Er(`config`),children:[(0,L.jsx)(`span`,{children:`⚙`}),(0,L.jsx)(`span`,{children:`config.toml`})]})]})]}):null,(0,L.jsxs)(`section`,{id:`main`,className:H(vn&&`covered`),children:[(0,L.jsxs)(`div`,{id:`tabs`,children:[on.map(e=>{let t=s.find(t=>t.thread.id===e),n=t?.thread;return!t||!n?null:(0,L.jsxs)(`button`,{className:H(`tab`,e===l&&`active`),"data-i":e,type:`button`,onClick:()=>Cr(e,`chat`),children:[(0,L.jsx)(`span`,{children:n.agentNickname?`⑂`:`💬`}),(0,L.jsx)(`span`,{children:Hd(c[t.thread.id]??Vd(t.thread),18)}),(0,L.jsx)(`span`,{className:`tab-x`,onClick:t=>{t.stopPropagation(),di(e)},children:`×`})]},e)}),(0,L.jsx)(`button`,{className:`tabadd`,type:`button`,onClick:()=>void Lr(),title:`New session`,children:`+`})]}),i.section===`editor`?(0,L.jsx)(`div`,{id:`editor-page`,children:Pi?(0,L.jsx)(lA,{backLabel:Ii,onBack:Ni,onSave:Fi,preview:Pi,providerId:e.settings.provider,variant:`page`}):(0,L.jsx)(`div`,{className:`empty-panel`,children:`No file selected.`})}):i.section===`review`?(0,L.jsx)(cA,{backLabel:y===`ops`?`Back to Files`:`Back to Chat`,diffEntries:Mn,findings:Bn,onBack:B,onSelectEntry:e=>Or(e,y),selectedEntryId:Je}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{id:`chat`,ref:At,children:[(0,L.jsx)(yS,{activeThread:u,activeThreadLabel:d,activeTurns:ln,existingThreadHistoryPending:Yn,onContext:Mi,onCopy:Ti,onEdit:Ai,onFill:Ai,onFork:Rr,onOpenFile:Ei,onPlan:ki,onRollback:Br,onReview:Di,onSlash:ji,providerId:e.settings.provider,streamVisible:Xt}),(0,L.jsx)(pd,{overlay:pn,pendingApprovalsCount:bn,queuedCount:fn.length}),(0,L.jsx)(`div`,{"aria-hidden":`true`,ref:jt})]}),(0,L.jsxs)(`div`,{id:`ia`,children:[it?(0,L.jsx)(`div`,{className:`chat-jump-row`,children:(0,L.jsx)(`button`,{className:`chat-jump-button`,type:`button`,onClick:ur,children:`↓ Latest`})}):null,we.length>0||De.length>0||Te.length>0?(0,L.jsxs)(`div`,{id:`ctx-row`,children:[we.map(e=>(0,L.jsxs)(`div`,{className:`ctag`,children:[(0,L.jsx)(`span`,{children:`📋`}),(0,L.jsxs)(`span`,{children:[`$`,e.name]}),(0,L.jsx)(`button`,{className:`ctx-x`,type:`button`,onClick:()=>ci(e.id),children:`×`})]},e.id)),De.map(e=>{let t=mf(e.name);return(0,L.jsxs)(`div`,{className:H(`ctag ctag-file`,`file-tone-${t.tone}`),children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`file-chip-preview`,children:(0,L.jsx)(`span`,{className:`file-chip-ext`,children:t.badge})}),(0,L.jsxs)(`span`,{className:`file-chip-copy`,children:[(0,L.jsx)(`span`,{className:`file-chip-title`,children:t.title}),(0,L.jsx)(`span`,{className:`file-chip-meta`,children:e.size})]}),(0,L.jsx)(`button`,{className:`ctx-x`,type:`button`,onClick:()=>li(e.id),children:`×`})]},e.id)}),Te.map(e=>(0,L.jsxs)(`div`,{className:`ctag ctag-image`,children:[(0,L.jsx)(`img`,{alt:e.name,className:`ctag-thumb`,loading:`lazy`,src:e.url}),(0,L.jsx)(`span`,{className:`ctag-label`,children:e.name}),(0,L.jsx)(`button`,{className:`ctx-x`,type:`button`,onClick:()=>Qr(e.id),children:`×`})]},e.id))]}):null,fn.length>0?(0,L.jsx)(aA,{messages:fn,onDelete:e=>l&&xr(l,e),onSteer:ui}):null,mn.length>0?(0,L.jsx)(hS,{entries:mn,onOpenFile:Oi,title:`Changing`,variant:`live`}):null,xn.length>0?(0,L.jsx)(`div`,{className:`question-request-stack`,children:xn.map(e=>ir(e))}):null,(ve||_e)&&u?(0,L.jsxs)(`div`,{className:H(`workspace-terminal-dock`,!_e&&`hidden`),children:[(0,L.jsxs)(`div`,{className:`workspace-terminal-dock-bar`,children:[(0,L.jsx)(`button`,{className:`workspace-terminal-dock-tab active`,type:`button`,children:`Terminal`}),(0,L.jsx)(`button`,{className:`workspace-terminal-dock-close`,onClick:wi,type:`button`,children:`Hide`})]}),(0,L.jsx)(`div`,{className:`workspace-terminal-dock-body`,children:be?(0,L.jsx)(nC,{cwd:u.thread.cwd,onSendInput:(e,n)=>t.sendTerminalInput(u.thread.id,e,n),onStartShell:()=>t.startProjectTerminal(u.thread.id,u.thread.cwd),onTerminate:e=>t.terminateTerminal(u.thread.id,e),terminals:bi}):(0,L.jsx)(`div`,{className:`workspace-terminal-dock-loading`,children:`Opening terminal`})})]}):null,(0,L.jsxs)(`div`,{id:`ib`,className:H(fn.length>0&&`queue-open`),children:[(0,L.jsxs)(`div`,{id:`toolbar`,children:[(0,L.jsxs)(`button`,{className:H(`tbtn`,pe&&`on`),type:`button`,onClick:()=>me(e=>!e),children:[(0,L.jsx)(SA,{name:`auto`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Auto`})]}),(0,L.jsxs)(`button`,{className:H(`tbtn`,he&&`on`),type:`button`,onClick:async()=>{ge(!he)},children:[(0,L.jsx)(SA,{name:`plan`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Plan`})]}),(0,L.jsx)(`div`,{className:`tsep2`}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>{Pe(`mention`),F(``),Le(0),Mt.current?.focus()},children:[(0,L.jsx)(SA,{name:`mention`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Mention`})]}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>It.current?.click(),children:[(0,L.jsx)(SA,{name:`attach`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Files`})]}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>Ft.current?.click(),children:[(0,L.jsx)(SA,{name:`image`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Image`})]}),(0,L.jsxs)(`button`,{className:H(`tbtn`,_e&&`on`),type:`button`,onClick:()=>void(_e?wi():Ci()),children:[(0,L.jsx)(SA,{name:`terminal`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Shell`})]}),(0,L.jsxs)(`button`,{className:H(`tbtn`,e.settings.webSearch&&`on`),type:`button`,onClick:()=>void t.updateSettings({webSearch:!e.settings.webSearch}),children:[(0,L.jsx)(SA,{name:`web`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Web`})]}),(0,L.jsx)(`div`,{className:`tsep2`}),(0,L.jsxs)(`button`,{className:H(`tbtn`,de===`review`&&`on`),type:`button`,onClick:()=>fe(e=>e===`review`?`chat`:`review`),children:[(0,L.jsx)(SA,{name:`review`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Review`})]}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>Er(`agents`),children:[(0,L.jsx)(SA,{name:`agents`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Agents`})]}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>void zr(),children:[(0,L.jsx)(SA,{name:`compact`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Trim`})]}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>z(`Ctrl+G — opening editor bridge`,``),children:[(0,L.jsx)(SA,{name:`editor`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Editor`})]})]}),(0,L.jsxs)(`div`,{id:`irow`,children:[(0,L.jsx)(oA,{composerMirrorRef:Nt,mentions:Se,onKeyDown:ni,onPaste:ii,onValueChange:$r,placeholder:fi,textareaRef:Mt,value:le},Et),(0,L.jsx)(`button`,{id:`sendbtn`,type:`button`,"aria-label":dn?`Queue message`:`Send message`,onClick:()=>void ti(Mt.current?.value),children:(0,L.jsx)(SA,{name:`send`})}),(0,L.jsx)(`button`,{id:`stopbtn`,style:{display:dn?`flex`:`none`},type:`button`,"aria-label":`Stop current turn`,onClick:()=>void si(),children:(0,L.jsx)(SA,{name:`stop`})})]}),zi(),(0,L.jsx)(`div`,{id:`ifooter`,children:(0,L.jsxs)(`div`,{className:`composer-footer-meta`,children:[(0,L.jsx)(`div`,{className:`composer-shortcuts`,children:(0,L.jsx)(`span`,{className:`composer-hint`,children:`Shift+Enter`})}),(0,L.jsxs)(`div`,{className:`composer-usage-metric`,children:[(0,L.jsx)(`span`,{className:`composer-usage-label`,children:`Context`}),(0,L.jsx)(`span`,{id:`tokcount`,children:pi})]}),(0,L.jsx)(`div`,{className:`composer-limit-list`,children:mi.map(e=>(0,L.jsxs)(`div`,{className:`composer-limit-chip`,children:[(0,L.jsx)(`span`,{className:`composer-limit-name`,children:TA(e.label,e.windowDurationMins)}),(0,L.jsxs)(`span`,{className:`composer-limit-value`,children:[Math.round(e.usedPercent),`%`]})]},e.id))})]})})]})]})]})]}),p||hn?(0,L.jsxs)(`aside`,{id:`rp`,className:H(hn&&`open`),children:[(0,L.jsxs)(`div`,{className:`rph`,children:[(0,L.jsx)(`span`,{className:`rpt`,id:`rp-title`,children:wd[E]}),(0,L.jsx)(`button`,{className:`rpclose`,type:`button`,onClick:kr,children:`×`})]}),(0,L.jsx)(`div`,{className:`rptabs`,id:`rptabs`,children:[`files`,`graph`,`diff`,`agents`,`config`].map(e=>(0,L.jsx)(`button`,{className:H(`rptab`,E===e&&`active`),type:`button`,onClick:()=>{if(e===`diff`){Or(Fn?.id??Mn[0]?.id,i.section===`ops`?`ops`:`chat`);return}D(e)},children:wd[e]},e))}),(0,L.jsx)(`div`,{className:`rpbody`,id:`rpbody`,children:hn?Ri():null})]}):null]}),(0,L.jsxs)(`div`,{id:`statusbar`,children:[(0,L.jsxs)(`div`,{className:`sbi sbi-transport`,children:[(0,L.jsx)(`div`,{className:H(`sbd`,Rd(e.transport.status))}),(0,L.jsx)(`span`,{children:hi})]}),(0,L.jsxs)(`div`,{className:`sbi sbi-branch`,children:[(0,L.jsx)(SA,{name:`branch`}),(0,L.jsx)(`span`,{className:`sb-project sb-fulltext`,children:gi}),(0,L.jsx)(`span`,{className:`sb-divider`,children:`/`}),(0,L.jsx)(`span`,{className:`sb-fulltext`,children:_i})]}),(0,L.jsxs)(`div`,{className:`sbi sbi-model`,id:`sb-model`,children:[(0,L.jsx)(SA,{name:`model`}),(0,L.jsx)(`span`,{children:kn})]}),(0,L.jsxs)(`div`,{className:`sbi sbi-access`,children:[(0,L.jsx)(SA,{name:`shield`}),(0,L.jsx)(`span`,{children:vi})]}),(0,L.jsx)(`div`,{className:`sbi`,id:`sb-st`,children:yi})]}),te&&Dn.length>0?(0,L.jsx)(`div`,{id:`mpicker`,style:{display:`block`,top:`${wt.top}px`,right:`${wt.right}px`,left:`auto`},children:Dn.map((t,n)=>(0,L.jsxs)(`div`,{className:`mpi`,onClick:()=>void Vr(t.id),onKeyDown:()=>void 0,role:`button`,tabIndex:0,children:[(0,L.jsxs)(`div`,{className:`mpi-n`,children:[t.displayName,t.id===e.settings.model?(0,L.jsxs)(L.Fragment,{children:[` `,`✓ `,(0,L.jsx)(`span`,{className:`model-rec`,children:`active`})]}):null]}),(0,L.jsx)(`div`,{className:`mpi-d`,children:t.description}),n<Dn.length-1?(0,L.jsx)(`div`,{className:`mpsep`}):null]},t.id))}):null,re?(0,L.jsx)(QS,{activeTheme:Ot,onClose:Nr,onSelect:Hr,themes:Ed}):null,A?(0,L.jsx)(iA,{activePath:j,breadcrumbs:Un,busy:se,entries:Vn,loading:e.directoryCatalogRoot!==j,onClose:()=>ie(!1),onNavigate:M,onPick:e=>{M(e),Ir(e)},parentPath:Hn}):null,ae?(0,L.jsx)(ZS,{actions:t,onClose:jr,pushToast:z,snapshot:e}):null,O?(0,L.jsx)(`div`,{id:`cmo`,className:`show`,onClick:e=>e.target===e.currentTarget&&ee(!1),children:(0,L.jsxs)(`div`,{id:`cmp`,children:[(0,L.jsxs)(`div`,{className:`cmr`,children:[(0,L.jsx)(`span`,{className:`cm-ico`,children:`⌘`}),(0,L.jsx)(`input`,{id:`cminput`,autoFocus:!0,placeholder:`Search commands, slash commands, models…`,value:je,onChange:e=>Me(e.target.value),onKeyDown:e=>{if(e.key===`Escape`&&ee(!1),e.key===`Enter`){e.preventDefault();let t=Xr[0]?.items[0];t&&(ee(!1),Zr(t.command))}}})]}),(0,L.jsx)(`div`,{className:`cmlist`,id:`cmlist`,children:Xr.length===0?(0,L.jsx)(`div`,{className:`empty-command`,children:`No results`}):Xr.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`cmgl`,children:e.label}),e.items.map(t=>(0,L.jsxs)(`button`,{className:`cmi`,type:`button`,onClick:()=>{ee(!1),Zr(t.command)},children:[(0,L.jsx)(`span`,{children:t.icon}),(0,L.jsx)(`span`,{className:`cmi-nm`,children:t.name}),t.key?(0,L.jsx)(`span`,{className:`cmkbd`,children:t.key}):null]},`${e.label}-${t.name}`))]},e.label))})]})}):null,He?(0,L.jsxs)(`div`,{id:`ctxmenu`,className:`show`,style:{left:`${He.x}px`,top:`${He.y}px`},children:[(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{let t=He.item;t?.type===`agentMessage`&&DA(t.text).then(()=>z(`Copied`,`ok`)),t?.type===`userMessage`&&DA(Jd(t,e.settings.provider)).then(()=>z(`Copied`,`ok`)),Ue(null)},children:`📋 Copy message`}),(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{let t=He.item;t?.type===`agentMessage`&&Ai(t.text),t?.type===`userMessage`&&Ai(Jd(t,e.settings.provider)),Ue(null)},children:`✏ Edit & resend`}),(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{Gn&&Ai(Gn.text),Ue(null)},children:`🔄 Regenerate`}),(0,L.jsx)(`div`,{className:`ctxs`}),(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{Rr(),Ue(null)},children:`⑂ /fork from here`}),(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{Yr(`/plan`),Ue(null)},children:`📋 /plan from here`}),(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{Pe(`mention`),F(``),Ue(null)},children:`📎 /mention file`}),(0,L.jsx)(`div`,{className:`ctxs`}),(0,L.jsx)(`button`,{className:`ctxi danger`,type:`button`,onClick:()=>{z(`Deleted`,``),Ue(null)},children:`🗑 Delete`})]}):null,(0,L.jsx)(`div`,{id:`toasts`,children:Be.map(e=>(0,L.jsx)(`div`,{className:H(`toast`,e.tone),children:e.message},e.id))}),(0,L.jsx)(`input`,{ref:It,className:`hidden-input`,type:`file`,multiple:!0,onChange:oi}),(0,L.jsx)(`input`,{ref:Ft,className:`hidden-input`,type:`file`,accept:`image/*`,multiple:!0,onChange:ai})]})}function FA(){return(0,L.jsx)(MA,{children:(0,L.jsx)(V,{})})}var IA=Qa({component:FA}),LA=Xa({getParentRoute:()=>IA,path:`/`,component:NA}),RA=Xa({getParentRoute:()=>IA,path:`/threads`,component:NA}),zA=Xa({getParentRoute:()=>IA,path:`/thread/$threadId`,component:NA}),BA=Xa({getParentRoute:()=>IA,path:`/threads/$threadId`,component:NA}),VA=Xa({getParentRoute:()=>IA,path:`/threads/$threadId/$section`,component:NA}),HA=go({routeTree:IA.addChildren([LA,RA,zA,BA,VA])}),UA=new Gt({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}}),WA=document.getElementById(`root`);if(!WA)throw Error(`Root element not found.`);(0,bo.createRoot)(WA).render((0,L.jsx)(Yt,{client:UA,children:(0,L.jsx)(yo,{router:HA})}));export{Ie as a,eO as i,UE as n,WE as r,BE as t};
|
|
214
|
+
`).length;break;case`webSearch`:n+=e.query.length;break;case`collabAgentToolCall`:n+=(e.prompt??``).length;break;default:break}return Math.max(0,Math.round(n/3.7))},OA=async e=>{if(typeof navigator<`u`&&navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),t.remove()},kA=e=>new Promise(t=>{window.setTimeout(t,e)}),AA=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),jA=(e,t)=>e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`&&e.message.trim()?e.message:t,MA=()=>{let e=(0,I.useContext)(mA);if(!e)throw Error(`Workspace context is missing.`);return e};function NA({children:e}){let[t,n]=(0,I.useState)(Sc()),r=(0,I.useRef)(t),i=(0,I.useRef)(null),a=(0,I.useRef)([]);(0,I.useEffect)(()=>{r.current=t},[t]);let o=(0,I.useCallback)(e=>{n(t=>{let n=structuredClone(t);return e(n),n})},[]);(0,I.useEffect)(()=>{let e=new ud(Sc());i.current=e;let t=e.subscribe(e=>{(0,I.startTransition)(()=>{n(e)})}),o=()=>{let t=r.current.transport;t.mode===`live`&&t.status===`connected`||e.connect().catch(()=>void 0)};o();let s=window.setInterval(()=>{o()},5e3),c=()=>{document.visibilityState===`visible`&&o()};return window.addEventListener(`focus`,o),document.addEventListener(`visibilitychange`,c),()=>{t(),window.clearInterval(s),window.removeEventListener(`focus`,o),document.removeEventListener(`visibilitychange`,c),e.disconnect(),a.current.forEach(e=>window.clearTimeout(e)),a.current=[]}},[]);let s=(0,I.useCallback)(async(e,t,n)=>{let a=r.current,o=i.current,s=!!o&&(n?.preferLive||a.transport.mode===`live`&&a.transport.status===`connected`);if(!o&&n?.preferLive)throw Error(`The workspace runtime is still starting. Try again.`);if(o&&s){let i=n?.preferLive?3:1,a=null;for(let s=0;s<i;s+=1)try{let t=r.current;return(t.transport.mode!==`live`||t.transport.status!==`connected`)&&await o.connect(),await e()}catch(e){if(a=e,s<i-1){await kA(320*(s+1));continue}if(n?.fallbackOnLiveError??!0)return await t();throw e}throw a}return await t()},[]),c=(0,I.useCallback)(async(e,t)=>{let n=kd(`thread`),r=Cc(n,t?.title??`New Session`,e,t?.cwd);return o(e=>{e.threads=jd([r,...e.threads.filter(e=>e.thread.id!==n)])}),n},[o]),l=(0,I.useCallback)(async({threadId:e,mode:t,prompt:n,mentions:i,skills:s,images:c,files:l,settings:u})=>{let d=r.current.threads.find(t=>t.thread.id===e)?.thread.cwd??r.current.directoryCatalogRoot??`.`,f=Ec({threadId:e,prompt:n,mode:t,settings:u,mentions:[...i,...Wd(d,l,u.provider)],skills:s,images:c,steer:null});o(r=>{r.threads=jd(r.threads.map(r=>r.thread.id===e?{...r,thread:{...r.thread,preview:n||r.thread.preview,updatedAt:Math.floor(Date.now()/1e3),status:{type:`active`,activeFlags:[]},turns:[...r.thread.turns,f.turn]},plan:f.plan,review:t===`review`?f.review:r.review,terminals:[...f.terminals,...r.terminals].slice(0,6),tokenUsage:{input:r.tokenUsage.input+Math.max(n.length*2,128),output:r.tokenUsage.output,cached:r.tokenUsage.cached}}:r)),r.streams=[...r.streams.filter(t=>t.threadId!==e),...f.streams]});let p=window.setTimeout(()=>{o(n=>{n.threads=jd(n.threads.map(n=>n.thread.id===e?{...n,thread:{...n.thread,updatedAt:Math.floor(Date.now()/1e3),status:{type:`idle`},turns:n.thread.turns.map(e=>e.id===f.turn.id?{...e,status:`completed`,items:e.items.map(e=>{if(e.type===`commandExecution`)return{...e,status:`completed`,exitCode:0,durationMs:1840};if(e.type===`collabAgentToolCall`){let t=Object.fromEntries(Object.entries(e.agentsStates).map(([e,t])=>[e,{...t,status:`completed`,message:t?.message??`Completed.`}]));return{...e,status:`completed`,agentsStates:t}}return e})}:e)},review:t===`review`?f.review:n.review,terminals:n.terminals.map(e=>f.terminals.some(t=>t.id===e.id)?{...e,status:`idle`,lastEvent:`just now`}:e),tokenUsage:{input:n.tokenUsage.input,output:n.tokenUsage.output+512,cached:n.tokenUsage.cached+96}}:n)),n.streams=n.streams.map(t=>t.threadId===e&&t.turnId===f.turn.id?{...t,visible:t.total}:t)})},2800);return a.current.push(p),e},[o]),u=(0,I.useMemo)(()=>({createThread:async(e,t)=>await s(async()=>await i.current.createThread(e,{cwd:t?.cwd}),async()=>await c(e,t),{preferLive:!0,fallbackOnLiveError:!1}),resumeThread:async e=>await s(async()=>{let t=i.current;await t.resumeThread(e).catch(()=>void 0),await t.ensureThreadLoaded(e).catch(()=>void 0)},async()=>void 0,{preferLive:!0,fallbackOnLiveError:!1}),interruptTurn:async e=>await s(async()=>await i.current.interruptTurn(e),async()=>{let t=!1;return o(n=>{n.threads=jd(n.threads.map(r=>{if(r.thread.id!==e)return r;let i=[...r.thread.turns].reverse().find(e=>e.status===`inProgress`);return i?(t=!0,wf(n,e,i.id),{...r,thread:{...r.thread,status:{type:`idle`},turns:r.thread.turns.map(e=>e.id===i.id?{...e,status:`interrupted`}:e)}}):r}))}),t}),sendComposer:async e=>await s(async()=>await i.current.sendComposer(e),async()=>await l(e),{preferLive:!0,fallbackOnLiveError:!1}),applySteer:async e=>await s(async()=>await i.current.applySteer(e),async()=>{let t=!1,n={id:`steer:${e.threadId}:${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,turnId:``,prompt:e.prompt.trim()||`Steer applied`,createdAt:Date.now(),status:`applied`};return o(r=>{r.threads=r.threads.map(r=>{if(r.thread.id!==e.threadId)return r;let i=[...r.thread.turns].reverse().find(e=>e.status===`inProgress`);return i?(t=!0,n.turnId=i.id,{...r,steers:[n,...(r.steers??[]).filter(e=>e.id!==n.id)]}):r})}),t},{preferLive:!0,fallbackOnLiveError:!1}),searchMentions:async(e,t)=>await s(async()=>{await i.current.searchMentions(e,t)},async()=>{o(n=>{let r=t.trim().toLowerCase(),i=`${e.replace(/\/+$/u,``)}/`;n.mentionCatalog=gA.filter(e=>e.path.startsWith(i)).filter(e=>r?`${e.name} ${e.path}`.toLowerCase().includes(r):!0).slice(0,18)})}),loadDirectory:async e=>await s(async()=>{await i.current.loadDirectory(e)},async()=>{o(t=>{t.directoryCatalogRoot=e,t.directoryCatalog=Kd(e)})}),readFile:async e=>await s(async()=>await i.current.readFile(e),async()=>{let t=hs(e,r.current.settings.provider);if(t===`#`)throw Error(`File preview is unavailable for this path.`);let n=await fetch(t);if(!n.ok)throw Error(`Failed to read ${e}`);return await n.text()}),saveFile:async(e,t)=>await s(async()=>{await i.current.writeFile(e,t)},async()=>{throw Error(`Saving files requires a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),readGitGraph:async(e,t=80)=>await s(async()=>await i.current.readGitGraph(e,t),async()=>``),readGitStatus:async e=>await s(async()=>await i.current.readGitStatus(e),async()=>``),readWorkspaceCommitPreferences:async e=>await s(async()=>await i.current.readWorkspaceCommitPreferences(e),async()=>{throw Error(`Commit preferences require a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),writeWorkspaceCommitPreferences:async(e,t)=>await s(async()=>await i.current.writeWorkspaceCommitPreferences(e,t),async()=>{throw Error(`Commit preferences require a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),generateCommitMessage:async({cwd:e,providerId:t})=>await s(async()=>await i.current.generateCommitMessage({cwd:e,providerId:t}),async()=>{throw Error(`Commit drafting requires a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),commitWorkingTree:async({cwd:e,message:t})=>await s(async()=>await i.current.commitWorkingTree({cwd:e,message:t}),async()=>{throw Error(`Git commit requires a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),checkProviderSetup:async e=>await s(async()=>{await i.current.checkProviderSetup(e)},async()=>{o(t=>{let n=e??t.settings.provider;t.providerSetup[n]={...t.providerSetup[n],status:`error`,summary:`Setup checks require a live workspace connection.`,detail:`Reconnect Nomadex to the host bridge, then check again.`,checkedAt:`just now`}})},{preferLive:!0}),startProviderAuth:async(e,t)=>await s(async()=>{await i.current.startProviderAuth(e,t)},async()=>{o(n=>{let r=e??n.settings.provider;n.providerAuth[r]={...n.providerAuth[r],status:`error`,flow:t??n.providerAuth[r].flow,summary:`Provider sign-in requires a live workspace connection.`,detail:`Reconnect Nomadex to the host bridge, then try again.`,processId:null,updatedAt:`just now`}})},{preferLive:!0}),submitProviderAuthSecret:async(e,t)=>await s(async()=>{await i.current.submitProviderAuthSecret(e,t)},async()=>{o(t=>{let n=e??t.settings.provider;t.providerAuth[n]={...t.providerAuth[n],status:`error`,summary:`Provider sign-in requires a live workspace connection.`,detail:`Reconnect Nomadex to the host bridge, then try again.`,processId:null,updatedAt:`just now`}})},{preferLive:!0}),cancelProviderAuth:async e=>await s(async()=>{await i.current.cancelProviderAuth(e)},async()=>{o(t=>{let n=e??t.settings.provider;t.providerAuth[n]={...t.providerAuth[n],status:`idle`,summary:`No sign-in in progress.`,detail:null,authUrl:null,userCode:null,processId:null,updatedAt:`just now`}})},{preferLive:!0}),switchProviderAccount:async(e,t)=>await s(async()=>{await i.current.switchProviderAccount(e,t)},async()=>{o(n=>{let r=e??n.settings.provider;n.providerAuth[r]={...n.providerAuth[r],status:`error`,flow:t??n.providerAuth[r].flow,summary:`Provider account switching requires a live workspace connection.`,detail:`Reconnect Nomadex to the host bridge, then try again.`,processId:null,updatedAt:`just now`}})},{preferLive:!0}),updateSettings:async e=>await s(async()=>{await i.current.updateSettings(e)},async()=>{e.provider&&Go(e.provider),o(t=>{t.settings={...t.settings,...e},t.lastSavedAt=`just now`})}),toggleFeatureFlag:async e=>await s(async()=>{await i.current.toggleFeatureFlag(e)},async()=>{o(t=>{t.featureFlags=t.featureFlags.map(t=>t.name===e?{...t,enabled:!t.enabled}:t),t.lastSavedAt=`just now`})}),toggleInstalledSkill:async e=>await s(async()=>{await i.current.toggleInstalledSkill(e)},async()=>{o(t=>{t.installedSkills=t.installedSkills.map(t=>t.id===e?{...t,enabled:!t.enabled}:t)})}),installSkill:async e=>await s(async()=>{await i.current.installSkill(e)},async()=>{o(t=>{let n=t.remoteSkills.find(t=>t.id===e);n&&(t.installedSkills=[{...n,path:`/home/allan/.codex/skills/${n.name}/SKILL.md`,enabled:!0,source:`installed`},...t.installedSkills],t.remoteSkills=t.remoteSkills.filter(t=>t.id!==e))})}),toggleMcpAuth:async e=>await s(async()=>{await i.current.toggleMcpAuth(e)},async()=>{o(t=>{t.mcpServers=t.mcpServers.map(t=>t.name===e?{...t,authStatus:t.authStatus===`notLoggedIn`?`oAuth`:t.authStatus}:t)})}),startChatGptLogin:async()=>await s(async()=>await i.current.startChatGptLogin(),async()=>(o(e=>{e.account.loginInProgress=!0,e.account.pendingLoginId=kd(`login`),e.account.loginError=null}),`https://chatgpt.com/`)),completeChatGptLogin:async e=>await s(async()=>{let t=await fetch(Ho(r.current.settings.provider).authCompletePath,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({callbackUrl:e})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error??n?.message??`Failed to complete mobile login`);await i.current.refreshAccount()},async()=>{o(e=>{e.account={...e.account,planType:`ChatGPT Pro`,workspace:`mobile relay account`,authMode:`chatgpt`,loggedIn:!0,requiresOpenaiAuth:!1,loginInProgress:!1,pendingLoginId:null,loginError:null}})}),loginWithApiKey:async e=>await s(async()=>{await i.current.loginWithApiKey(e)},async()=>{o(e=>{e.account={...e.account,planType:`API key`,workspace:`API key session`,authMode:`apiKey`,loggedIn:!0,requiresOpenaiAuth:!1,loginInProgress:!1,pendingLoginId:null,loginError:null}})}),logoutAccount:async()=>await s(async()=>{await i.current.logoutAccount()},async()=>{o(e=>{e.account={...e.account,planType:`Signed out`,workspace:`No active account`,authMode:`signedOut`,loggedIn:!1,loginInProgress:!1,pendingLoginId:null,loginError:null,usageWindows:[],rateUsed:0,rateLimit:100,credits:`Sign in to view rate limits`}})}),refreshAccount:async()=>await s(async()=>{await i.current.refreshAccount()},async()=>void 0),cleanTerminals:async e=>await s(async()=>{await i.current.cleanTerminals(e)},async()=>{o(t=>{t.threads=t.threads.map(t=>t.thread.id===e?{...t,terminals:t.terminals.filter(e=>e.status===`running`)}:t)})}),startProjectTerminal:async(e,t)=>await s(async()=>await i.current.startProjectTerminal(e,t),async()=>{throw Error(`Interactive terminals require a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),sendTerminalInput:async(e,t,n)=>await s(async()=>{await i.current.sendTerminalInput(t,n)},async()=>{throw Error(`Interactive terminals require a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),terminateTerminal:async(e,t)=>await s(async()=>{await i.current.terminateTerminal(t)},async()=>{throw Error(`Interactive terminals require a live workspace connection.`)},{preferLive:!0,fallbackOnLiveError:!1}),resolveApproval:async(e,t)=>await s(async()=>{await i.current.resolveApproval(e,t)},async()=>{o(n=>{n.threads=n.threads.map(n=>({...n,approvals:n.approvals.map(n=>n.id===e?{...n,state:t===`accept`||t===`acceptForSession`?`approved`:`declined`}:n)}))})}),submitQuestion:async(e,t)=>await s(async()=>{await i.current.submitQuestion(e,t)},async()=>{o(n=>{n.threads=n.threads.map(n=>({...n,approvals:n.approvals.map(n=>n.id===e?{...n,state:`submitted`,detail:`${n.detail} · ${Object.values(t).flat().filter(Boolean).join(`, `)}`}:n)}))})}),submitMcp:async(e,t,n)=>await s(async()=>{await i.current.submitMcp(e,t,n)},async()=>{o(n=>{n.threads=n.threads.map(n=>({...n,approvals:n.approvals.map(n=>n.id===e?{...n,state:t===`accept`?`submitted`:`declined`}:n)}))})}),rollbackToTurn:async(e,t)=>await s(async()=>{await i.current.rollbackToTurn(e,t)},async()=>{o(n=>{n.threads=n.threads.map(n=>{if(n.thread.id!==e)return n;let r=n.thread.turns.filter(e=>e.status!==`inProgress`),i=r.findIndex(e=>e.id===t);if(i===-1)return n;let a=new Set(r.slice(i).map(e=>e.id));if(a.size===0)return n;let o=n.thread.turns.filter(e=>!a.has(e.id));return{...n,thread:{...n.thread,turns:o,updatedAt:Math.floor(Date.now()/1e3)},steers:(n.steers??[]).filter(e=>!a.has(e.turnId)),approvals:n.approvals.filter(e=>!e.turnId||!a.has(e.turnId))}})})},{preferLive:!0,fallbackOnLiveError:!1}),forkThread:async e=>{let t=r.current.threads.find(t=>t.thread.id===e),n=kd(`thread`);return o(e=>{let r=t?structuredClone(t):Cc(n,`Forked Session`,e.settings);r.thread.id=n,r.thread.name=t?`Fork of ${Yd(t)}`:`Forked Session`,r.thread.preview=t?.thread.preview??`Forked session`,r.thread.createdAt=Math.floor(Date.now()/1e3),r.thread.updatedAt=Math.floor(Date.now()/1e3),r.thread.status={type:`idle`},r.approvals=[],r.terminals=[],e.threads=jd([r,...e.threads.filter(e=>e.thread.id!==n)])}),n},compactThread:async e=>{o(t=>{t.threads=t.threads.map(t=>{if(t.thread.id!==e)return t;let n=[...t.thread.turns];if(n.length===0)return t;let r=n[n.length-1];return r.items.some(e=>e.type===`contextCompaction`)||(r.items=[...r.items,{type:`contextCompaction`,id:kd(`compact`)}]),{...t,plan:t.plan?{...t.plan,explanation:`Conversation compacted to free context.`}:t.plan,thread:{...t.thread,turns:n}}})})}}),[c,o,l,s]);return(0,L.jsx)(mA.Provider,{value:{snapshot:t,actions:u},children:e})}function PA(){return(0,L.jsx)(FA,{})}function FA(){let{snapshot:e,actions:t}=MA(),n=Na(),r=Ta({select:e=>e.location}),i=zd(r.pathname),a=(0,I.useMemo)(()=>{let e=r.pathname.split(`/`).filter(Boolean);return e[0]!==`threads`||!e[1]||!e[2]||gd(e[2])?null:e[2]},[r.pathname]),o=(0,I.useMemo)(()=>new URLSearchParams(r.search),[r.search]),s=(0,I.useMemo)(()=>{let t=new Map;return e.threads.forEach(e=>{let n=t.get(e.thread.id);(!n||e.thread.updatedAt>=n.thread.updatedAt)&&t.set(e.thread.id,e)}),jd([...t.values()])},[e.threads]),c=(0,I.useMemo)(()=>{let e={};return s.forEach(t=>{e[t.thread.id]=Yd(t)}),e},[s]),l=i.threadId??s[0]?.thread.id??null,u=l?s.find(e=>e.thread.id===l)??null:null,d=u?c[u.thread.id]??Vd(u.thread):`New Session`,f=Id(i.section),[p,m]=(0,I.useState)(()=>Ad()),h=i.section===`editor`?o.get(`path`):null,g=(0,I.useMemo)(()=>{let e=i.section===`editor`?o.get(`line`):null;if(!e)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null},[i.section,o]),_=(0,I.useMemo)(()=>{let e=i.section===`editor`?o.get(`from`):null;switch(e){case`ops`:case`review`:case`agents`:case`skills`:case`mcp`:case`settings`:case`chat`:return e;default:return`chat`}},[i.section,o]),v=i.section===`review`?o.get(`diff`):null,y=(0,I.useMemo)(()=>{let e=i.section===`review`?o.get(`from`):null;switch(e){case`ops`:case`agents`:case`skills`:case`mcp`:case`settings`:case`chat`:return e;default:return`chat`}},[i.section,o]),[b,x]=(0,I.useState)(!1),[S,C]=(0,I.useState)(()=>Ad()),[w,T]=(0,I.useState)(!1),[E,D]=(0,I.useState)(f??`files`),[O,ee]=(0,I.useState)(!1),[te,ne]=(0,I.useState)(!1),[re,k]=(0,I.useState)(!1),[A,ie]=(0,I.useState)(!1),[ae,oe]=(0,I.useState)(!1),[se,ce]=(0,I.useState)(!1),[j,M]=(0,I.useState)(_A),[le,ue]=(0,I.useState)(``),[de,fe]=(0,I.useState)(`chat`),[pe,me]=(0,I.useState)(!1),[he,ge]=(0,I.useState)(!1),[_e,N]=(0,I.useState)(!1),[ve,ye]=(0,I.useState)(!1),[be,xe]=(0,I.useState)(!1),[Se,Ce]=(0,I.useState)([]),[we,P]=(0,I.useState)([]),[Te,Ee]=(0,I.useState)([]),[De,Oe]=(0,I.useState)([]),[ke,Ae]=(0,I.useState)(l?[l,...e.threads.slice(1,2).map(e=>e.thread.id)]:[]),[je,Me]=(0,I.useState)(``),[Ne,Pe]=(0,I.useState)(null),[Fe,F]=(0,I.useState)(``),[Ie,Le]=(0,I.useState)(0),[Re,ze]=(0,I.useState)({}),[Be,Ve]=(0,I.useState)([]),[He,Ue]=(0,I.useState)(null),[We,Ge]=(0,I.useState)(null),[Ke,qe]=(0,I.useState)(null),[Je,Ye]=(0,I.useState)(null),[Xe,Ze]=(0,I.useState)({}),[Qe,$e]=(0,I.useState)({}),[et,tt]=(0,I.useState)({}),nt=(0,I.useRef)(null),rt=(0,I.useRef)(null),[it,at]=(0,I.useState)(!1),[ot,st]=(0,I.useState)(null),[ct,lt]=(0,I.useState)(!1),[ut,dt]=(0,I.useState)(null),[ft,pt]=(0,I.useState)(0),[mt,ht]=(0,I.useState)(e.settings.provider),[gt,_t]=(0,I.useState)(null),[vt,yt]=(0,I.useState)(``),[bt,xt]=(0,I.useState)(!1),[St,Ct]=(0,I.useState)(!1),[wt,Tt]=(0,I.useState)({top:52,right:12}),[Et,Dt]=(0,I.useState)(0);(0,I.useEffect)(()=>{!a||!i.threadId||n({to:`/threads/$threadId`,params:{threadId:i.threadId},replace:!0})},[a,n,i.threadId]);let[Ot,kt]=(0,I.useState)(()=>{if(typeof window>`u`)return yd;let e=window.localStorage.getItem(bd);return Dd(e)?e:yd}),At=(0,I.useRef)(null),jt=(0,I.useRef)(null),Mt=(0,I.useRef)(null),Nt=(0,I.useRef)(null),Pt=(0,I.useRef)(null),Ft=(0,I.useRef)(null),It=(0,I.useRef)(null),Lt=(0,I.useRef)({}),Rt=(0,I.useRef)({}),zt=(0,I.useRef)({}),Bt=(0,I.useRef)(null),Vt=(0,I.useRef)(le),Ht=(0,I.useRef)({}),Ut=(0,I.useRef)(!1),Wt=(0,I.useRef)(null),Gt=(0,I.useRef)(null),Kt=(0,I.useRef)(null),qt=(0,I.useRef)(!0),Jt=(0,I.useRef)({}),Yt=(0,I.useRef)({}),[Xt,Zt]=(0,I.useState)({}),[Qt,$t]=(0,I.useState)(0),en=(0,I.useDeferredValue)(le),tn=(0,I.useDeferredValue)(Fe);(0,I.useEffect)(()=>{Vt.current=le},[le]);let[nn,rn]=(0,I.useState)(!0);(0,I.useEffect)(()=>()=>{Bt.current!==null&&window.cancelAnimationFrame(Bt.current)},[]),(0,I.useEffect)(()=>{let e=()=>{m(e=>{let t=Ad();return e===t?e:t})};return e(),window.addEventListener(`resize`,e,{passive:!0}),()=>{window.removeEventListener(`resize`,e)}},[]);let an=(0,I.useCallback)(()=>{let e=Pt.current?.getBoundingClientRect();Tt({top:(e?.bottom??48)+4,right:Math.max(12,window.innerWidth-(e?.right??window.innerWidth-12))})},[]);(0,I.useEffect)(()=>{if(typeof document>`u`)return;let e=Od(Ot),t=document.documentElement;t.dataset.uiTheme=e.id,t.style.setProperty(`color-scheme`,e.mode),window.localStorage.setItem(bd,Ot),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.themeColor),document.querySelector(`meta[name="color-scheme"]`)?.setAttribute(`content`,e.mode),document.querySelector(`meta[name="apple-mobile-web-app-status-bar-style"]`)?.setAttribute(`content`,e.mode===`light`?`default`:`black-translucent`)},[Ot]),(0,I.useLayoutEffect)(()=>{if(!te)return;let e=()=>{an()};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[te,an]);let on=(0,I.useMemo)(()=>{let e=new Set(s.map(e=>e.thread.id));return[...new Set(ke.filter(t=>e.has(t)))].slice(0,6)},[ke,s]),R=(0,I.useMemo)(()=>Nd(u?.thread.turns??[]),[u?.thread.turns]),sn=(0,I.useMemo)(()=>Math.max(0,R.length-vA),[R.length]),cn=(0,I.useMemo)(()=>{if(!l)return sn;let e=Xe[l];if(e==null)return sn;let t=R.length===0?0:Math.max(0,R.length-1);return Math.max(0,Math.min(e,t))},[sn,l,R.length,Xe]),ln=(0,I.useMemo)(()=>R.slice(cn),[R,cn]),un=(0,I.useMemo)(()=>R.map(e=>`${e.id}:${e.status}:${e.items.length}:${e.error?.message??``}`).join(`|`),[R]),dn=[...R].reverse().find(e=>e.status===`inProgress`)??null,fn=l?Re[l]??[]:[],pn=(0,I.useMemo)(()=>vs(dn),[dn]),mn=(0,I.useMemo)(()=>_s(dn),[dn]),hn=!w&&S&&i.section!==`editor`&&i.section!==`review`,gn=hn&&!p,_n=p||b,vn=!p&&gn,yn=O||re||A||ae,bn=(0,I.useMemo)(()=>u?.approvals.filter(e=>e.state===`pending`).length??0,[u?.approvals]),xn=(0,I.useMemo)(()=>u?.approvals.filter(e=>e.state===`pending`)??[],[u?.approvals]),Sn=Pd(e.settings),Cn=(0,I.useMemo)(()=>{let e=u?.thread.cwd??null;return e?!We||!qd(e,We)?e:We:null},[u?.thread.cwd,We]),wn=(0,I.useMemo)(()=>({...e.settings,collaborationMode:he?`plan`:`default`}),[e.settings,he]);(0,I.useEffect)(()=>{let t=new Set(e.threads.flatMap(e=>e.approvals.filter(e=>e.kind===`question`&&e.state===`pending`).map(e=>e.id)));$e(e=>{let n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[e.threads]),(0,I.useEffect)(()=>{let t=new Set(e.threads.flatMap(e=>e.approvals.filter(e=>e.kind===`mcp`&&e.state===`pending`).map(e=>e.id)));tt(e=>{let n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[e.threads]);let Tn=(0,I.useMemo)(()=>{let e={Today:[],Yesterday:[],Earlier:[]};return s.forEach(t=>{e[Bd(t.thread.updatedAt)].push(t)}),e},[s]),En=(0,I.useMemo)(()=>e.providers.find(t=>t.id===e.settings.provider)??Ho(e.settings.provider),[e.providers,e.settings.provider]),Dn=(0,I.useMemo)(()=>Zo(En.id,e.models.length>0?e.models:hA.models),[En.id,e.models]),On=(0,I.useMemo)(()=>Qo(En.id,e.settings.model,e.models.length>0?e.models:hA.models),[En.id,e.settings.model,e.models]),kn=`${En.displayName} · ${On?.displayName??(e.settings.model===`default`?`provider default`:e.settings.model)}`,An=(0,I.useMemo)(()=>Od(Ot),[Ot]),jn=(0,I.useMemo)(()=>R.flatMap(e=>e.items.filter(e=>e.type===`fileChange`)),[R]),Mn=(0,I.useMemo)(()=>R.flatMap(e=>e.items.flatMap(e=>e.type===`fileChange`?(e.changes.length>0?e.changes:[{path:`Editing files`,kind:{type:`update`,move_path:null},diff:``}]).map((t,n)=>{let r=xf(t.diff);return{id:vf(e.id,n,t.path),itemId:e.id,path:t.path,diff:t.diff,kind:t.kind,status:e.status,additions:r.additions,removals:r.removals,hunks:r.hunks}}):[])).reverse(),[R]),Nn=(0,I.useMemo)(()=>s.filter(e=>e.thread.cwd===u?.thread.cwd),[u?.thread.cwd,s]),Pn=(0,I.useMemo)(()=>u?.thread.cwd?.trim()||e.directoryCatalogRoot||null,[u?.thread.cwd,e.directoryCatalogRoot]),Fn=(0,I.useMemo)(()=>Mn.find(e=>e.id===Je)??Mn[0]??null,[Mn,Je]);(0,I.useEffect)(()=>{if(!u){ht(e.settings.provider),_t(null),yt(``);return}if(!Pn){ht(e.settings.provider),_t(null);return}let n=!1;return yt(``),t.readWorkspaceCommitPreferences(Pn).then(e=>{n||(ht(e.provider),_t(e.filePath))}).catch(()=>{n||(ht(e.settings.provider),_t(null))}),()=>{n=!0}},[t,u,Pn,e.settings.provider]),(0,I.useEffect)(()=>{if(!u){st(null),lt(!1),dt(null);return}let e=Ks({activeThread:u,relatedThreads:Nn});if(st(e),dt(null),E!==`graph`){lt(!1);return}let n=`${u.thread.cwd}:${u.thread.gitInfo?.sha??`workspace`}`,r=Ht.current[n]??``,i=!1;return lt(!0),Promise.allSettled([r?Promise.resolve(r):t.readGitGraph(u.thread.cwd,80),t.readGitStatus(u.thread.cwd)]).then(([t,r])=>{if(i)return;let a=t.status===`fulfilled`?t.value:``,o=r.status===`fulfilled`?r.value:``,s=Ks({activeThread:u,relatedThreads:Nn,rawStatus:o}),c=(a.trim().length>0?Gs({activeThread:u,rawLog:a,rawStatus:o}):null)??s??e;a.trim().length>0&&(Ht.current[n]=a),dt(t.status===`rejected`?jA(t.reason,`Unable to read git history.`):null),st(c)}).finally(()=>{i||lt(!1)}),()=>{i=!0}},[t,u,ft,E,Nn]);let In=ot?.workingTree??null,Ln=!!In?.dirty||jn.some(e=>e.status!==`failed`),Rn=!!In?.buckets.some(e=>e.id===`staged`&&e.entries.length>0),zn=ot?.branchLabel||u?.thread.gitInfo?.branch||`current branch`,Bn=(0,I.useMemo)(()=>{if(!u)return[];if(!Fn)return u.review;let e=yf(Fn.path);return u.review.filter(t=>{let n=yf(t.file);return n===e||n.endsWith(`/${e}`)})},[u,Fn]),Vn=(0,I.useMemo)(()=>e.directoryCatalogRoot===j?e.directoryCatalog.filter(e=>e.kind===`directory`):[],[j,e.directoryCatalog,e.directoryCatalogRoot]),Hn=(0,I.useMemo)(()=>{if(j===_A)return null;let e=j.lastIndexOf(`/`);return e<=0?_A:j.slice(0,e)||_A},[j]),Un=(0,I.useMemo)(()=>{let e=_A.replace(/\/+$/u,``),t=j.replace(/\/+$/u,``),n=t===e?``:t.slice(e.length).replace(/^\/+/u,``);return[{label:e.split(`/`).filter(Boolean).pop()??e,path:e},...n.split(`/`).filter(Boolean).reduce((t,n)=>{let r=t.at(-1)?.path??e;return t.push({label:n,path:`${r.replace(/\/+$/u,``)}/${n}`}),t},[])]},[j]),Wn=(0,I.useMemo)(()=>R.flatMap(e=>e.items.filter(e=>e.type===`collabAgentToolCall`)),[R]),Gn=(0,I.useMemo)(()=>{for(let e of[...R].reverse())for(let t of[...e.items].reverse())if(t.type===`agentMessage`)return t;return null},[R]),Kn=(0,I.useMemo)(()=>{if(Ne===`mention`){let t=Fe.replace(/^@/u,``).trim().toLowerCase(),n=u&&e.directoryCatalogRoot===u.thread.cwd?e.directoryCatalog.filter(e=>t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0):[],r=new Map;return[...n,...e.mentionCatalog].forEach(e=>{r.has(e.path)||r.set(e.path,e)}),[...r.values()].slice(0,24).map(e=>({id:e.id,label:e.name,description:Hd(e.path,92),mode:`mention`,value:e.path}))}return Ne===`skill`?[...e.installedSkills,...e.remoteSkills].map(e=>({id:e.id,label:`$${e.name}`,description:e.description,mode:`skill`,value:e.name})):Td.map(e=>({id:e.cmd,label:e.cmd,description:e.dsc,mode:`slash`,value:e.cmd}))},[u,Ne,Fe,e.directoryCatalog,e.directoryCatalogRoot,e.installedSkills,e.mentionCatalog,e.remoteSkills]),qn=(0,I.useMemo)(()=>{let e=tn.trim().toLowerCase();return e?Kn.filter(t=>`${t.label} ${t.description}`.toLowerCase().includes(e)).slice(0,12):Kn.slice(0,12)},[tn,Kn]);(0,I.useEffect)(()=>{if(!l)return;let e=window.requestAnimationFrame(()=>{Ae(e=>e.includes(l)?e:[l,...e.filter(e=>e!==l)].slice(0,6))});return()=>{window.cancelAnimationFrame(e)}},[l]),(0,I.useLayoutEffect)(()=>{l&&Wt.current!==l&&(delete Jt.current[l],Ze(e=>{if(!(l in e))return e;let t={...e};return delete t[l],t}),qt.current=!0,Gt.current=null,Kt.current=null)},[l]);let Jn=(0,I.useMemo)(()=>e.transport.mode===`live`&&e.transport.status===`connected`&&!!u&&hf(u,R),[u,R,e.transport.mode,e.transport.status]),Yn=(0,I.useMemo)(()=>i.threadId===u?.thread.id&&Jn,[Jn,u?.thread.id,i.threadId]);(0,I.useEffect)(()=>{if(nn){if(e.transport.status===`connecting`){Ut.current=!0;return}Ut.current&&(Jn||rn(!1))}},[Jn,nn,e.transport.status]);let Xn=(0,I.useCallback)(()=>{$t(e=>e+1)},[]),Zn=(0,I.useCallback)((e,t,r=`chat`)=>{!e||!t||e===t||(Ae(n=>{let r=n.map(n=>n===e?t:n);return r.includes(t)||r.unshift(t),[...new Set(r)].slice(0,6)}),ze(n=>{let r=n[e]??[];if(r.length===0)return n;let i={...n};return delete i[e],i[t]=[...r,...i[t]??[]],i}),Lt.current[e]&&(Lt.current[t]=Lt.current[e],delete Lt.current[e]),Rt.current[e]&&(Rt.current[t]=Rt.current[e],delete Rt.current[e]),Jt.current[e]&&(Jt.current[t]=Jt.current[e],delete Jt.current[e]),Wt.current===e&&(Wt.current=t),Gt.current?.threadId===e&&(Gt.current={...Gt.current,threadId:t}),Ze(n=>{if(!(e in n))return n;let r={...n};return r[t]=r[e]??r[t]??0,delete r[e],r}),i.threadId===e&&n(r===`chat`?{to:`/threads/$threadId`,params:{threadId:t}}:{to:`/threads/$threadId/$section`,params:{threadId:t,section:hd(r)}}),Xn())},[n,Xn,i.threadId]),Qn=(0,I.useCallback)(async(e,n=`chat`)=>{try{let r=await t.sendComposer(e);return Zn(e.threadId,r,n),r}catch(t){let r=fA(t);throw r&&Zn(e.threadId,r,n),t}},[t,Zn]),$n=(0,I.useCallback)((e,t,n)=>{$e(r=>({...r,[e]:{...r[e]??{},[t]:n}}))},[]),er=(0,I.useCallback)(async e=>{let n=pA(e,Qe[e.id]??{});await t.submitQuestion(e.id,n),$e(t=>{if(!(e.id in t))return t;let n={...t};return delete n[e.id],n})},[t,Qe]),tr=(0,I.useCallback)((e,t)=>{tt(n=>({...n,[e]:t}))},[]),nr=(0,I.useCallback)(async(e,n)=>{await t.resolveApproval(e.id,n)},[t]),rr=(0,I.useCallback)(async(e,n)=>{await t.submitMcp(e.id,n,et[e.id]??``),tt(t=>{if(!(e.id in t))return t;let n={...t};return delete n[e.id],n})},[t,et]),ir=(0,I.useCallback)(e=>e.kind===`question`?(0,L.jsx)(YS,{answers:Qe[e.id]??{},approval:e,onAnswerChange:(t,n)=>$n(e.id,t,n),onSubmit:()=>void er(e)},e.id):(0,L.jsx)(US,{approval:e,mcpContentText:et[e.id]??``,onMcpContentChange:t=>tr(e.id,t),onResolve:t=>void nr(e,t),onSubmitMcp:t=>void rr(e,t)},e.id),[et,Qe,nr,rr,er,tr,$n]);(0,I.useEffect)(()=>{if(!i.threadId||e.transport.mode!==`live`||e.transport.status!==`connected`||!u||!hf(u,R))return;let n=i.threadId,r=0,a=()=>{r+=1,t.resumeThread(n)};a();let o=window.setInterval(()=>{if(r>=5){window.clearInterval(o);return}a()},1200);return()=>{window.clearInterval(o)}},[t,u,R,i.threadId,e.transport.mode,e.transport.status]),(0,I.useEffect)(()=>{if(i.section!==`review`)return;let e=v&&Mn.some(e=>e.id===v)?v:Mn[0]?.id??null;Ye(t=>t===e?t:e)},[Mn,v,i.section]),(0,I.useEffect)(()=>{if(!Je||!Mn.some(e=>e.id===Je)){let e=window.requestAnimationFrame(()=>{Ye(Mn[0]?.id??null)});return()=>{window.cancelAnimationFrame(e)}}},[Mn,Je]),(0,I.useEffect)(()=>{e.transport.mode===`live`&&e.transport.status!==`connected`||Object.entries(Re).forEach(([t,n])=>{if(n.length===0||Lt.current[t])return;let r=e.threads.find(e=>e.thread.id===t)?.thread.turns.some(e=>e.status===`inProgress`)??!1;if(Rt.current[t]){if(r)return;delete Rt.current[t]}if(r)return;let[i]=n;i&&(Lt.current[t]=!0,ze(e=>{let n=e[t]??[];if(n[0]?.id!==i.id)return e;let r=n.slice(1);if(r.length===0){let n={...e};return delete n[t],n}return{...e,[t]:r}}),Qn({threadId:t,mode:i.mode,prompt:i.prompt,mentions:i.mentions,skills:i.skills,images:i.images,files:i.files,settings:wn}).then(e=>{Rt.current[e]=!0}).catch(e=>{let n=fA(e)??t;ze(e=>({...e,[n]:[i,...e[n]??[]]})),Xn()}).finally(()=>{delete Lt.current[t]}))})},[wn,Re,Qt,Xn,Qn,e.threads,e.transport.mode,e.transport.status]),(0,I.useEffect)(()=>{let e=()=>{typeof document<`u`&&document.visibilityState!==`visible`||Xn()},t=()=>{document.visibilityState===`visible`&&Xn()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,t)}},[Xn]),(0,I.useLayoutEffect)(()=>{if(i.section===`editor`||i.section===`review`){C(!1);return}if(!p&&w){C(!1);return}if(!f){p||C(!1);return}D(e=>e===f||f===`files`&&e===`graph`?e:f),C(e=>e||!0)},[p,w,i.section,f]),(0,I.useEffect)(()=>{w&&(p||!f)&&T(!1)},[p,w,f]),(0,I.useEffect)(()=>{if(!u||Ne!==`mention`)return;e.directoryCatalogRoot!==u.thread.cwd&&t.loadDirectory(u.thread.cwd);let n=tn.replace(/^@/,``).trim();n&&t.searchMentions(u.thread.cwd,n)},[t,u,tn,Ne,e.directoryCatalogRoot]),(0,I.useEffect)(()=>{let e=u?.thread.cwd;if(!e)return;let t=window.requestAnimationFrame(()=>{Ge(t=>t&&qd(e,t)?t:e),qe(t=>t&&qd(e,t.path)?t:null)});return()=>{window.cancelAnimationFrame(t)}},[u?.thread.cwd]),(0,I.useEffect)(()=>{Cn&&t.loadDirectory(Cn)},[t,Cn]),(0,I.useEffect)(()=>{A&&t.loadDirectory(j)},[t,A,j]),(0,I.useEffect)(()=>{if(i.section!==`editor`||!h||Ke?.path===h&&!Ke.loading&&Ke.error===null)return;let e=h.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??h,n=!1;return t.readFile(h).then(t=>{n||(0,I.startTransition)(()=>{qe({path:h,name:e,content:t,loading:!1,error:null,line:g})})}).catch(t=>{n||qe({path:h,name:e,content:``,loading:!1,error:t instanceof Error?t.message:`Unable to open this file.`,line:g})}),()=>{n=!0}},[t,g,h,Ke,i.section]),(0,I.useEffect)(()=>{let t=e.transport.mode===`live`,n=e.streams;if(t){let e=window.requestAnimationFrame(()=>{let e={};for(let t of n){let n=Cf(t);e[t.key]=n}Yt.current=e,(0,I.startTransition)(()=>{Zt(e)})});return()=>{window.cancelAnimationFrame(e)}}let r=window.requestAnimationFrame(()=>{let e=Yt.current,t=Object.keys(e).length!==n.length,r={};for(let i of n){let n=Cf(i),a=Math.min(e[i.key]??0,n);r[i.key]=a,(e[i.key]??void 0)!==a&&(t=!0)}t&&(Yt.current=r,(0,I.startTransition)(()=>{Zt(r)}))}),i=window.setInterval(()=>{let e=Yt.current,t={},r=Object.keys(e).length!==n.length;for(let i of n){let n=Cf(i),a=Math.min(e[i.key]??0,n),o=n-a,s=Math.max(1,i.speed,Math.ceil(o/5)),c=a<n?Math.min(n,a+s):a;t[i.key]=c,c!==a&&(r=!0)}r&&(Yt.current=t,(0,I.startTransition)(()=>{Zt(t)}))},24);return()=>{window.cancelAnimationFrame(r),window.clearInterval(i)}},[e.streams,e.transport.mode]);let ar=(0,I.useCallback)(e=>e.scrollHeight-e.scrollTop-e.clientHeight<=72,[]),or=(0,I.useCallback)((e=l)=>{let t=At.current;if(!t||!e)return;let n=ar(t);qt.current=n,at(e=>e===!n?e:!n),Jt.current[e]={pinned:n,top:t.scrollTop}},[l,ar]),sr=(0,I.useCallback)(()=>{if(!l||cn<=0||Yn)return;let e=At.current;e&&Gt.current?.threadId!==l&&(Gt.current={threadId:l,previousHeight:e.scrollHeight,previousTop:e.scrollTop},Ze(e=>{let t=e[l]??sn,n=Math.max(0,t-yA);return n===t?(Gt.current=null,e):{...e,[l]:n}}))},[sn,l,cn,Yn]),cr=(0,I.useCallback)((e=!1)=>{let t=At.current;t&&(!e&&!qt.current||(t.scrollTop=t.scrollHeight,qt.current=!0,at(!1),l&&(Jt.current[l]={pinned:!0,top:t.scrollTop})))},[l]);(0,I.useEffect)(()=>{let e=At.current;if(!e||!l||i.section===`editor`||i.section===`review`)return;let t=()=>{let t=ar(e);qt.current=t,at(e=>e===!t?e:!t),Jt.current[l]={pinned:t,top:e.scrollTop}};t();let n=()=>{t(),e.scrollTop<=48&&sr()};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t(),e.removeEventListener(`scroll`,n)}},[l,ar,sr,i.section]);let lr=(0,I.useCallback)(e=>{let t=null,n=null,r=0,i=()=>{cr(e?.force??!1);let n=At.current;if(!n)return;let a=n.scrollHeight-n.scrollTop-n.clientHeight;r+=1,a>2&&r<8&&(t=window.requestAnimationFrame(i))};return t=window.requestAnimationFrame(i),n=e?.extraDelay?window.setTimeout(i,90):null,()=>{t!==null&&window.cancelAnimationFrame(t),n!==null&&window.clearTimeout(n)}},[cr]);(0,I.useLayoutEffect)(()=>{At.current&&cr()},[cr,Xt,un]),(0,I.useLayoutEffect)(()=>{if(!l||i.section===`editor`||i.section===`review`)return;let e=Wt.current===l?Jt.current[l]:void 0;qt.current=e?.pinned??!0,at(!(e?.pinned??!0))},[l,i.section]),(0,I.useLayoutEffect)(()=>{if(!l||i.section===`editor`||i.section===`review`)return;let e=()=>{let e=At.current;if(!e)return;let t=Wt.current===l,n=t?Jt.current[l]:void 0;if(!t){cr(!0);return}if(!n){Wt.current=null,cr(!0);return}if(n.pinned){Wt.current=null,cr(!0);return}let r=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTop=Math.min(n.top,r),Wt.current=null,or(l)};e();let t=window.requestAnimationFrame(e),n=window.setTimeout(e,90);return()=>{window.cancelAnimationFrame(t),window.clearTimeout(n)}},[l,cr,i.section,or]),(0,I.useLayoutEffect)(()=>{let e=Gt.current;if(!e||e.threadId!==l)return;let t=At.current;if(!t)return;let n=t.scrollHeight-e.previousHeight;t.scrollTop=e.previousTop+n,Gt.current=null,or(l)},[l,ln.length,or]),(0,I.useEffect)(()=>()=>{i.section===`editor`||i.section===`review`||or(l)},[l,i.section,or]),(0,I.useEffect)(()=>{if(!l){at(!1),Kt.current=null;return}if(Yn||R.length===0){Kt.current=null;return}let e=`${l}:${R.at(-1)?.id??`empty`}:${R.length}`;if(Kt.current!==e)return Kt.current=e,lr({extraDelay:!0,force:!0})},[l,R,Yn,lr]);let ur=(0,I.useCallback)(()=>{lr({extraDelay:!0,force:!0})},[lr]);(0,I.useEffect)(()=>()=>Te.forEach(e=>e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url)),[Te]);let z=(0,I.useCallback)((e,t)=>{let n=kd(`toast`);Ve(r=>[...r,{id:n,message:e,tone:t}]);let r=window.setTimeout(()=>{Ve(e=>e.filter(e=>e.id!==n)),delete zt.current[n]},2600);zt.current[n]=r},[]),dr=(0,I.useCallback)(()=>{Ht.current={},pt(e=>e+1)},[]),fr=(0,I.useCallback)(async()=>{dr(),Ye(null);let e=Cn??Pn;if(e)try{await t.loadDirectory(e)}catch{Pn&&Pn!==e&&(Ge(Pn),await t.loadDirectory(Pn).catch(()=>void 0))}h&&qe({path:h,name:h.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??h,content:``,loading:!0,error:null,line:g})},[t,Cn,Pn,g,h,dr]),pr=(0,I.useCallback)(async e=>{let n=mt;if(ht(e),u){if(!Pn){ht(n),z(`Open the repository folder first.`,`warn`);return}try{_t((await t.writeWorkspaceCommitPreferences(Pn??u.thread.cwd,{provider:e})).filePath),dr()}catch(e){ht(n),z(jA(e,`Failed to save the commit provider for this project.`),`err`)}}},[t,u,Pn,mt,z,dr]),mr=(0,I.useCallback)(async()=>{if(!(!u||bt||St)){if(!Pn){z(`Open the repository folder first.`,`warn`);return}xt(!0);try{yt(await t.generateCommitMessage({cwd:Pn,providerId:mt})),z(`Drafted a commit message.`,`ok`)}catch(e){z(jA(e,`Failed to draft a commit message.`),`err`)}finally{xt(!1)}}},[t,u,Pn,St,bt,mt,z]),hr=(0,I.useCallback)(async()=>{if(!(!u||bt||St)){if(!Pn){z(`Open the repository folder first.`,`warn`);return}if(!vt.trim()){z(`Enter a commit message first.`,`warn`);return}Ct(!0);try{let e=await t.commitWorkingTree({cwd:Pn,message:vt});yt(``),dr(),z(e.stagedAll?`Staged all files and created the commit.`:`Created the commit.`,`ok`)}catch(e){z(jA(e,`Failed to create the commit.`),`err`)}finally{Ct(!1)}}},[t,u,Pn,St,bt,vt,z,dr]),gr=(0,I.useCallback)(e=>{let t=e;window.requestAnimationFrame(()=>{let e=Mt.current;if(!e)return;e.focus();let n=t?.length??e.value.length;try{e.setSelectionRange(n,n)}catch{}})},[]),_r=(0,I.useCallback)(()=>Mt.current?.value??le,[le]),vr=(0,I.useCallback)(e=>{let t=_r(),n=typeof e==`function`?e(t):e;return ue(n),Dt(e=>e+1),n},[_r]),yr=(0,I.useCallback)(()=>{ue(``),Dt(e=>e+1),Ce([]),P([]),Oe([]),Ee(e=>(e.forEach(e=>e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url)),[])),Pe(null),F(``),Le(0)},[]),br=(0,I.useCallback)((e,t)=>{let n={...t,id:kd(`queue`),mentions:[...t.mentions],skills:[...t.skills],files:[...t.files],images:[...t.images]};ze(t=>({...t,[e]:[...t[e]??[],n]}))},[]),xr=(0,I.useCallback)((e,t)=>{ze(n=>{let r=n[e]??[],i=r.filter(e=>e.id!==t);if(i.length===r.length)return n;if(i.length===0){let t={...n};return delete t[e],t}return{...n,[e]:i}})},[]),Sr=(0,I.useCallback)((e,t)=>{ze(n=>({...n,[e]:[t,...n[e]??[]]}))},[]),Cr=(0,I.useCallback)((e,t=`chat`,r)=>{e!==l&&(Wt.current=null,Gt.current=null,qt.current=!0);let i=()=>{if(t===`chat`){n({to:`/threads/$threadId`,params:{threadId:e}});return}n({to:`/threads/$threadId/$section`,params:{threadId:e,section:hd(t)}})};if(r?.immediate||l===e){i();return}(0,I.startTransition)(i)},[l,n]),wr=(0,I.useCallback)(e=>{Wt.current=null,Gt.current=null,Kt.current=null,qt.current=!0,at(!1),delete Jt.current[e],Ze(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n}),x(!1),Cr(e,`chat`,{immediate:!0}),e===l&&window.requestAnimationFrame(()=>{lr({extraDelay:!0,force:!0})})},[l,Cr,lr]),Tr=(0,I.useCallback)((e,t)=>{if(!l)return;let r=typeof t?.line==`number`&&t.line>0?t.line:null,i=t?.source??`chat`,a=e.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??e;or(),i===`chat`&&(Wt.current=l),qe(t=>t?.path===e&&!t.loading?{...t,line:r}:{path:e,name:a,content:t?.path===e?t.content:``,loading:t?.path===e?t.loading:!0,error:null,line:r}),n({to:`/threads/$threadId/$section`,params:{threadId:l,section:hd(`editor`)},search:{path:e,line:r?String(r):void 0,from:i}})},[l,n,or]),Er=(0,I.useCallback)(e=>{if(e===`terminal`){ye(!0),N(!0);return}T(!1),D(e),C(!0),x(!1),l&&Cr(l,Ld(e))},[l,Cr]),Dr=(0,I.useCallback)(()=>{p||(T(!1),C(!1),x(e=>!e))},[p]),Or=(0,I.useCallback)((e,t=`chat`)=>{if(!l)return;let r=e??Fn?.id??Mn[0]?.id??null;r&&Ye(r),or(),t===`chat`&&(Wt.current=l),n({to:`/threads/$threadId/$section`,params:{threadId:l,section:hd(`review`)},search:{diff:r??void 0,from:t}})},[l,Mn,n,or,Fn]),kr=(0,I.useCallback)(()=>{if(C(!1),l){if(!p){T(!0),window.requestAnimationFrame(()=>{Cr(l,`chat`,{immediate:!0})});return}Cr(l,`chat`,{immediate:!0})}},[l,p,Cr]);(0,I.useEffect)(()=>{i.section===`skills`&&oe(!0)},[i.section]);let Ar=(0,I.useCallback)(()=>{oe(!0),x(!1)},[]),jr=(0,I.useCallback)(()=>{oe(!1),i.section===`skills`&&l&&Cr(l,`chat`)},[l,Cr,i.section]),Mr=(0,I.useCallback)(()=>{k(!0),x(!1),ne(!1),ee(!1)},[]),Nr=(0,I.useCallback)(()=>{k(!1)},[]),Pr=(0,I.useCallback)(async n=>{if(se)return null;ce(!0);try{let e=await t.createThread(wn,{title:`New Session`,cwd:n});return M(n),Ae(t=>[e,...t.filter(t=>t!==e)].slice(0,6)),Cr(e,`chat`),x(!1),C(p),yr(),z(`New session — ${n}`,`ok`),e}catch(t){return z(jA(t,e.transport.error??`Failed to start session`),`err`),null}finally{ce(!1)}},[t,p,wn,Cr,se,z,yr,e.transport.error]),Fr=(0,I.useCallback)(()=>{M(e=>e&&e.trim().length>0?e:u?.thread.cwd??_A),ie(!0),x(!1),ee(!1)},[u]),Ir=(0,I.useCallback)(async e=>{await Pr(e??j)&&ie(!1)},[Pr,j]),Lr=(0,I.useCallback)(async()=>{Fr()},[Fr]),Rr=(0,I.useCallback)(async()=>{if(!l){await Lr();return}let e=await t.forkThread(l);Ae(t=>[e,...t.filter(t=>t!==e)].slice(0,6)),Cr(e,`chat`),z(`/fork — session forked`,`ok`)},[t,l,Lr,Cr,z]),zr=(0,I.useCallback)(async()=>{l&&(await t.compactThread(l),z(`/compact — transcript summarized`,`ok`))},[t,l,z]),Br=(0,I.useCallback)(async e=>{if(l){if(dn){z(`Wait for the current response to finish before rolling back.`,`err`);return}if(window.confirm(`Roll back from this prompt? This will remove this prompt and every later message, then undo the file changes from those turns.`))try{await t.rollbackToTurn(l,e),await fr(),z(`/rollback — reverted to selected prompt`,`ok`)}catch(e){z(jA(e,`Failed to roll back from the selected prompt.`),`err`)}}},[t,l,dn,z,fr]),Vr=(0,I.useCallback)(async e=>{await t.updateSettings({model:e}),ne(!1),z(`Model: ${e}`,``)},[t,z]),Hr=(0,I.useCallback)(e=>{kt(e),k(!1),z(`Theme: ${e}`,``)},[z]),Ur=(0,I.useCallback)(async()=>{let e=xd[(xd.indexOf(Sn)+1)%xd.length];await t.updateSettings(Fd(e)),z(`Approval: ${Sd[e]}`,``)},[t,Sn,z]),Wr=(0,I.useCallback)(()=>{Pe(null),F(``),Le(0)},[]);(0,I.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){e.preventDefault(),ee(!0),x(!1);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`n`){e.preventDefault(),Lr();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`g`){e.preventDefault(),z(`Ctrl+G — opening editor bridge`,``);return}e.key===`Escape`&&(ee(!1),ne(!1),k(!1),ie(!1),Ue(null),Wr())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Wr,Lr,z]),(0,I.useEffect)(()=>{let e=e=>{let t=e.target;t&&(t.closest(`#ctxmenu`)||Ue(null),!t.closest(`#hmodel`)&&!t.closest(`#mpicker`)&&ne(!1),!t.closest(`#htheme`)&&!t.closest(`#tpicker`)&&k(!1),!t.closest(`#ta`)&&!t.closest(`#slashpop`)&&Wr())};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[Wr]);let Gr=(0,I.useCallback)(e=>{gr(vr(t=>t.replace(/(?:^|\s)([@$/][^\s]*)$/,t=>t.replace(/[@$/][^\s]*$/,e))))},[gr,vr]),Kr=(0,I.useCallback)(e=>{Ce(t=>t.some(t=>t.id===e.id||t.path===e.path)?t:[...t,e]),Wr(),gr(vr(t=>ef(t,e))),z(`/mention — ${Qd(e)} linked`,`ok`)},[Wr,gr,z,vr]),qr=(0,I.useCallback)(n=>{let r=[...e.installedSkills,...e.remoteSkills].find(e=>e.name===n);r&&(r.source===`remote`?(t.installSkill(r.id),z(`Installing $${r.name}`,`ok`)):(P(e=>e.some(e=>e.id===r.id)?e:[...e,{...r,source:`installed`}]),z(`$${r.name} attached`,`ok`)),Wr(),gr(vr(e=>e.replace(/(?:^|\s)\$[^\s]*$/,``))))},[t,Wr,gr,z,vr,e.installedSkills,e.remoteSkills]),Jr=(0,I.useMemo)(()=>Se.filter(e=>$d(en,e)),[en,Se]),Yr=(0,I.useCallback)(async(e,n=!1)=>{let[r,...i]=e.trim().split(/\s+/),a=i.join(` `);switch(r){case`/new`:await Lr();break;case`/fork`:await Rr();break;case`/compact`:await zr();break;case`/mention`:Pe(`mention`),F(a);break;case`/model`:ne(e=>!e);break;case`/permissions`:await Ur();break;case`/plan`:ge(!0),z(`Plan mode enabled`,`ok`);break;case`/review`:fe(`review`),Er(`diff`),n&&l?(await Qn({threadId:l,mode:`review`,prompt:a,mentions:Jr,skills:we,files:De,images:Te,settings:wn},`review`),yr()):z(`/review ready`,`ok`);break;case`/ps`:Er(`terminal`);break;case`/diff`:Er(`diff`);break;case`/skills`:Ar();break;case`/mcp`:Er(`config`),l&&Cr(l,`mcp`);break;case`/theme`:Mr(),z(`Theme picker opened`,`ok`);break;case`/status`:Er(`config`),z(`Session diagnostics opened`,`ok`);break;case`/copy`:Gn&&(await OA(Gn.text),z(`Copied latest response`,`ok`));break;case`/clear`:yr(),z(`/clear — composer reset`,``);break;case`/experimental`:Er(`config`);break;case`/init`:vr(`/init Generate AGENTS.md for this repo`),gr(`/init Generate AGENTS.md for this repo`);break;case`/resume`:case`/feedback`:case`/apps`:case`/exit`:case`/quit`:case`/personality`:z(`${r} queued`,``);break;case`/logout`:await t.logoutAccount(),z(`Signed out of account`,`ok`);break;default:n&&l&&(await Qn({threadId:l,mode:de,prompt:e,mentions:Jr,skills:we,files:De,images:Te,settings:wn}),yr())}},[t,l,zr,de,Ur,Lr,Rr,Gn,Cr,Er,Mr,Ar,z,yr,Qn,gr,Te,De,Jr,we,vr,wn]),Xr=(0,I.useMemo)(()=>{let e=[{label:`Session`,items:[{icon:`💬`,name:`New Session (/new)`,key:`⌘N`,command:{type:`createSession`}},{icon:`⑂`,name:`Fork Session (/fork)`,key:``,command:{type:`forkSession`}},{icon:`🗜`,name:`Compact Transcript (/compact)`,key:``,command:{type:`compactSession`}},{icon:`🗑`,name:`Clear Composer`,key:``,command:{type:`resetComposer`}}]},{label:`Navigate`,items:[{icon:`📁`,name:`Files Panel`,key:``,command:{type:`openPanel`,tab:`files`}},{icon:`⎇`,name:`Branches Panel`,key:``,command:{type:`openPanel`,tab:`graph`}},{icon:`⬛`,name:`Terminal Dock (/ps)`,key:``,command:{type:`openPanel`,tab:`terminal`}},{icon:`⑂`,name:`Multi-agent Panel`,key:``,command:{type:`openPanel`,tab:`agents`}},{icon:`📋`,name:`Skills Library (/skills)`,key:``,command:{type:`openSkills`}},{icon:`⚙`,name:`Config & Feature Flags`,key:`⌘,`,command:{type:`openPanel`,tab:`config`}}]},{label:`Slash`,items:Td.map(e=>({icon:`/`,name:`${e.cmd} — ${e.dsc}`,key:``,command:{type:`runSlash`,slash:e.cmd}}))},...Dn.length>0?[{label:`Model`,items:Dn.map(e=>({icon:`🤖`,name:e.displayName,key:``,command:{type:`selectModel`,modelId:e.id}}))}]:[]],t=je.trim().toLowerCase();return t?e.map(e=>({...e,items:e.items.filter(n=>`${n.name} ${e.label}`.toLowerCase().includes(t))})).filter(e=>e.items.length>0):e},[je,Dn]),Zr=(0,I.useCallback)(e=>{switch(e.type){case`createSession`:Lr();break;case`forkSession`:Rr();break;case`compactSession`:zr();break;case`openSkills`:Ar();break;case`resetComposer`:yr();break;case`openPanel`:Er(e.tab);break;case`runSlash`:Yr(e.slash);break;case`selectModel`:Vr(e.modelId);break}},[zr,Lr,Rr,Er,Ar,yr,Yr,Vr]),Qr=(0,I.useCallback)(e=>{Ee(t=>{let n=t.find(t=>t.id===e);return n?.url.startsWith(`blob:`)&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)})},[]),$r=(0,I.useCallback)(e=>{Vt.current=e,Bt.current===null&&(Bt.current=window.requestAnimationFrame(()=>{Bt.current=null;let e=Vt.current;(0,I.startTransition)(()=>{ue(e)});let t=e.match(/(?:^|\s)([@$/])([^\s]*)$/);if(!t){Wr();return}let n=t[1],r=t[2]??``;if(n===`/`){Pe(`slash`),F(`/${r}`),Le(0);return}if(n===`@`){Pe(`mention`),F(r),Le(0);return}if(n===`$`){Pe(`skill`),F(r),Le(0);return}Wr()}))},[Wr]),ei=(0,I.useCallback)(t=>{if(t.mode===`slash`){Gr(`${t.value} `),Wr();return}if(t.mode===`mention`){let n=e.mentionCatalog.find(e=>e.id===t.id);n&&Kr(n);return}qr(t.value)},[Kr,qr,Wr,Gr,e.mentionCatalog]),ti=(0,I.useCallback)(async n=>{let r=n??Mt.current?.value??le,a=r.trim(),o=Se.filter(e=>$d(r,e)),s={composerValue:r,mentions:[...Se],skills:[...we],files:[...De],images:[...Te]};if(!(!a&&o.length===0&&we.length===0&&De.length===0&&Te.length===0))try{let n=l,r=n?e.threads.some(e=>e.thread.id===n):!1;if((!n||!r)&&(n=await t.createThread(wn,{title:`New Session`,cwd:j}),Ae(e=>[n,...e.filter(e=>e!==n)].slice(0,6)),Cr(n,`chat`)),a.startsWith(`/`)){await Yr(a,!0);return}let s=de===`review`||i.section===`review`?`review`:`chat`,c=a,u=Te.length===0;if(dn){br(n,{mode:s,prompt:c,mentions:o,skills:we,files:De,images:Te}),yr(),z(`Message queued`,`ok`);return}u&&(yr(),await AA()),n=await Qn({threadId:n,mode:s,prompt:c,mentions:o,skills:we,files:De,images:Te,settings:wn}),u||yr()}catch(t){s.images.length===0&&!_r().trim()&&(ue(s.composerValue),Dt(e=>e+1),Ce(s.mentions),P(s.skills),Oe(s.files),Pe(null),F(``),Le(0)),z(jA(t,e.transport.error??`Failed to send message`),`err`)}},[t,l,dn,le,de,br,_r,Cr,z,yr,i.section,Yr,Qn,e.transport.error,e.threads,Se,Te,De,we,wn,j]),ni=(0,I.useCallback)(async e=>{if(Ne&&qn.length>0){if(e.key===`ArrowDown`){e.preventDefault(),Le(e=>Math.min(qn.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Le(e=>Math.max(0,e-1));return}if(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey){e.preventDefault(),ei(qn[Ie]);return}if(e.key===`Escape`){Wr();return}}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`g`){e.preventDefault(),z(`Ctrl+G — opening editor bridge`,``);return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),await ti(e.currentTarget.value))},[Wr,qn,ei,z,Ie,Ne,ti]),ri=(0,I.useCallback)((e,t)=>{let n=e.filter(e=>e.type.startsWith(`image/`));if(n.length===0)return 0;let r=Date.now();return Ee(e=>[...e,...n.map((e,t)=>{let n=e.type.split(`/`)[1]?.replace(/[^a-z0-9]/gi,``).toLowerCase()||`png`;return{id:kd(`image`),name:e.name||`pasted-image-${r}-${t+1}.${n}`,url:URL.createObjectURL(e),size:Ud(e.size),file:e}})]),z(n.length===1?t===`paste`?`Image pasted`:`Image attached`:t===`paste`?`${n.length} images pasted`:`${n.length} images attached`,`ok`),n.length},[z]),ii=(0,I.useCallback)(e=>{let t=Array.from(e.clipboardData.files??[]);ri(t.length>0?t:Array.from(e.clipboardData.items??[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e),`paste`)!==0&&e.preventDefault()},[ri]),ai=(0,I.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length!==0&&(ri(t,`attach`),e.target.value=``)},[ri]),oi=(0,I.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length!==0&&(Oe(e=>[...e,...t.map(e=>({id:kd(`file`),name:e.name,size:Ud(e.size),file:e}))]),e.target.value=``,z(`File attached`,`ok`))},[z]),si=(0,I.useCallback)(async()=>{if(!l)return;let e=await t.interruptTurn(l);z(e?`Stop requested`:`No active turn to stop`,e?`warn`:``)},[t,l,z]),ci=(0,I.useCallback)(e=>{P(t=>t.filter(t=>t.id!==e))},[]),li=(0,I.useCallback)(e=>{Oe(t=>t.filter(t=>t.id!==e))},[]),ui=(0,I.useCallback)(async e=>{if(!l)return;let n=(Re[l]??[]).find(t=>t.id===e);if(n){if(xr(l,e),dn){if(await t.applySteer({threadId:l,prompt:n.prompt,mentions:n.mentions,skills:n.skills,files:n.files,images:n.images})){z(`Queued message sent as steer`,`ok`);return}Sr(l,n),z(`No active turn to steer`,`warn`);return}try{await Qn({threadId:l,mode:n.mode,prompt:n.prompt,mentions:n.mentions,skills:n.skills,files:n.files,images:n.images,settings:wn})}catch(e){Sr(fA(e)??l,n)}}},[t,l,dn,wn,Sr,z,Re,xr,Qn]),di=(0,I.useCallback)(e=>{if(on.length<=1){z(`Cannot close last tab`,``);return}let t=on.filter(t=>t!==e);Ae(t),e===l&&t[0]&&Cr(t[0],`chat`)},[l,Cr,z,on]),fi=Ne?q[Ne]:dn?`Queue a follow-up while the agent is still running…`:q.slash,pi=`${wA((0,I.useMemo)(()=>DA(R,e.settings.provider),[R,e.settings.provider]))} / 200k`,mi=(0,I.useMemo)(()=>[...e.account.usageWindows].sort((e,t)=>(e.windowDurationMins??2**53-1)-(t.windowDurationMins??2**53-1)).slice(0,2),[e.account.usageWindows]),hi=e.transport.status===`connected`?`Connected`:e.transport.status,gi=TA(u?.thread.cwd),_i=u?.thread.gitInfo?.branch??`workspace`,vi=Sd[Sn].toLowerCase(),yi=dn?`Streaming`:`Idle`,bi=(0,I.useMemo)(()=>u?.terminals.filter(e=>e.source===`shell`)??[],[u?.terminals]),xi=bi.length>0,Si=(0,I.useCallback)(()=>{!l||!u?.thread.cwd||xi||t.startProjectTerminal(l,u.thread.cwd).catch(e=>{z(e instanceof Error?e.message:`Unable to start the project shell.`,`err`)})},[t,u?.thread.cwd,l,xi,z]);(0,I.useEffect)(()=>{if(!(!_e||!ve||be)){if(typeof window>`u`){xe(!0);return}return nt.current=window.requestAnimationFrame(()=>{nt.current=null,xe(!0)}),()=>{nt.current!==null&&(window.cancelAnimationFrame(nt.current),nt.current=null)}}},[ve,be,_e]),(0,I.useEffect)(()=>{if(!(!_e||!be||!l||!u?.thread.cwd||xi)){if(typeof window>`u`){Si();return}return rt.current=window.requestAnimationFrame(()=>{rt.current=null,Si()}),()=>{rt.current!==null&&(window.cancelAnimationFrame(rt.current),rt.current=null)}}},[u?.thread.cwd,l,xi,Si,be,_e]);let Ci=(0,I.useCallback)(()=>{_e||(ye(!0),N(!0))},[_e]),wi=(0,I.useCallback)(()=>{typeof window<`u`&&(nt.current!==null&&(window.cancelAnimationFrame(nt.current),nt.current=null),rt.current!==null&&(window.cancelAnimationFrame(rt.current),rt.current=null)),N(!1)},[]),Ti=(0,I.useCallback)(e=>{OA(e).then(()=>z(`Copied!`,`ok`))},[z]),Ei=(0,I.useCallback)((e,t)=>{Tr(e,{line:t,source:`chat`})},[Tr]),Di=(0,I.useCallback)(e=>{Or(e)},[Or]),Oi=(0,I.useCallback)(e=>{Tr(e,{source:`chat`})},[Tr]),ki=(0,I.useCallback)(()=>{Yr(`/plan`)},[Yr]),Ai=(0,I.useCallback)(e=>{vr(e),gr(e)},[gr,vr]),ji=(0,I.useCallback)(e=>{Yr(e)},[Yr]),Mi=(0,I.useCallback)((e,t)=>{e.preventDefault(),Ue({x:Math.min(e.clientX,window.innerWidth-172),y:Math.min(e.clientY,window.innerHeight-212),item:t})},[]),Ni=(0,I.useCallback)(()=>{if(l){if(_===`ops`){D(`files`),C(!0),Cr(l,`ops`);return}Cr(l,_)}},[l,_,Cr]),B=(0,I.useCallback)(()=>{if(l){if(y===`ops`){D(`files`),C(!0),Cr(l,`ops`);return}Cr(l,y)}},[l,Cr,y]),Pi=(0,I.useMemo)(()=>i.section!==`editor`||!h?null:Ke?.path===h?{...Ke,line:g}:{path:h,name:h.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??h,content:``,loading:!0,error:null,line:g},[g,h,Ke,i.section]),Fi=(0,I.useCallback)(async(e,n)=>{await t.saveFile(e,n),qe(t=>t?.path===e?{...t,content:n,loading:!1,error:null}:t),z(`Saved ${e.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??e}`,`ok`)},[t,z]),Ii=_===`ops`?`Back to Files`:`Back to Chat`,Li=(0,I.useCallback)(async e=>{if(e.kind===`directory`){Ge(e.path),qe(null);return}Tr(e.path,{source:`ops`})},[Tr]),Ri=()=>{if(!u)return(0,L.jsx)(`div`,{className:`empty-panel`,children:`No active thread.`});if(E===`graph`)return ot?(0,L.jsxs)(`div`,{className:`graph-panel-stack`,children:[(0,L.jsx)(WS,{branchLabel:zn,committing:St,dirty:Ln,generating:bt,hasStagedChanges:Rn,message:vt,onCommit:()=>void hr(),onGenerate:()=>void mr(),onMessageChange:yt,onProviderChange:e=>{pr(e)},preferencesPath:gt,providers:e.providers,selectedProviderId:mt,summary:In?.summary??`Working tree clean`}),ot.source===`session`?(0,L.jsx)(`div`,{className:`panel-hint`,children:ut?`Showing session-derived history because local git output is unavailable.`:`Showing session-derived history.`}):ct?(0,L.jsx)(`div`,{className:`panel-hint`,children:`Refreshing git history…`}):null,(0,L.jsx)(JS,{model:ot,onOpenThread:wr})]}):(0,L.jsx)(`div`,{className:`empty-panel`,children:ct?`Loading git history…`:`No repository graph available for this session yet.`});if(E===`files`){let t=new Map,n=u.thread.cwd,r=Cn??n,a=e.directoryCatalogRoot===r?e.directoryCatalog:[],o=new Set(Jr.map(e=>e.path)),s=r===n?``:r.slice(n.length).replace(/^\/+/u,``),c=[{label:n.split(`/`).filter(Boolean).pop()??n,path:n},...s.split(`/`).filter(Boolean).reduce((e,t)=>{let r=e.at(-1)?.path??n;return e.push({label:t,path:`${r.replace(/\/+$/u,``)}/${t}`}),e},[])],l=r===n?null:r.slice(0,r.lastIndexOf(`/`))||n;return jn.forEach(e=>{e.changes.forEach(e=>{t.set(e.path,e.kind.type===`add`?`new`:e.kind.type===`delete`?`del`:`mod`)})}),(0,L.jsx)(iA,{breadcrumbs:c,currentPath:r,directoryEntries:a,editorPath:i.section===`editor`?h:null,loading:e.directoryCatalogRoot!==r,mentionedPaths:o,modifiedByPath:t,onNavigate:e=>{Ge(e),qe(t=>t&&qd(e,t.path)?t:null)},onOpenEntry:Li,parentPath:l,rootPath:n})}if(E===`diff`){let e=Mn.reduce((e,t)=>e+t.additions,0),t=Mn.reduce((e,t)=>e+t.removals,0);return(0,L.jsxs)(`div`,{className:`diff-review-shell`,children:[(0,L.jsxs)(`div`,{className:`panel-hint`,children:[`Patch review · `,Mn.length,` changed file`,Mn.length===1?``:`s`,` · +`,e,` / -`,t]}),Mn.length===0?(0,L.jsx)(`div`,{className:`empty-panel`,children:`No diff items in this thread yet.`}):null,Mn.length>0?(0,L.jsxs)(`div`,{className:`diff-review-layout`,children:[(0,L.jsx)(`div`,{className:`diff-review-sidebar`,children:Mn.map(e=>(0,L.jsxs)(`button`,{className:H(`diff-review-entry`,Fn?.id===e.id&&`active`),type:`button`,onClick:()=>Ye(e.id),children:[(0,L.jsxs)(`div`,{className:`diff-review-entry-top`,children:[(0,L.jsx)(`span`,{className:H(`diff-kind-pill`,e.kind.type===`add`&&`new`,e.kind.type===`delete`&&`del`),children:bf(e.kind)}),(0,L.jsx)(`span`,{className:H(`diff-status`,e.status===`inProgress`&&`live`,e.status===`failed`&&`err`),children:e.status===`inProgress`?`editing`:e.status})]}),(0,L.jsx)(`div`,{className:`diff-review-entry-path`,children:e.path}),(0,L.jsxs)(`div`,{className:`diff-review-entry-meta`,children:[(0,L.jsxs)(`span`,{children:[`+`,e.additions]}),(0,L.jsxs)(`span`,{children:[`-`,e.removals]}),(0,L.jsxs)(`span`,{children:[e.hunks,` hunk`,e.hunks===1?``:`s`]})]})]},e.id))}),Fn?(0,L.jsxs)(`div`,{className:`diff-review-main`,children:[(0,L.jsxs)(`div`,{className:`diff-focus-head`,children:[(0,L.jsx)(`div`,{className:`diff-focus-title`,children:Fn.path}),(0,L.jsxs)(`div`,{className:`diff-focus-meta`,children:[(0,L.jsx)(`span`,{className:H(`diff-kind-pill`,Fn.kind.type===`add`&&`new`,Fn.kind.type===`delete`&&`del`),children:bf(Fn.kind)}),(0,L.jsx)(`span`,{className:H(`diff-status`,Fn.status===`inProgress`&&`live`,Fn.status===`failed`&&`err`),children:Fn.status===`inProgress`?`editing`:Fn.status}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[`+`,Fn.additions]}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[`-`,Fn.removals]}),(0,L.jsxs)(`span`,{className:`diff-stat-chip`,children:[Fn.hunks,` hunk`,Fn.hunks===1?``:`s`]})]})]}),(0,L.jsx)(cA,{entry:Fn})]}):null]}):null,Bn.length>0?(0,L.jsx)(`div`,{className:`review-list`,children:Bn.map(e=>(0,L.jsxs)(`div`,{className:H(`review-item`,e.severity),children:[(0,L.jsxs)(`div`,{className:`review-header`,children:[(0,L.jsx)(`span`,{children:e.severity}),(0,L.jsx)(`span`,{children:e.file.split(`/`).slice(-2).join(`/`)}),(0,L.jsxs)(`span`,{children:[`:`,e.line]})]}),(0,L.jsx)(`div`,{className:`review-title`,children:e.title}),(0,L.jsx)(`div`,{className:`review-summary`,children:e.summary})]},e.id))}):u.review.length>0?(0,L.jsx)(`div`,{className:`empty-panel`,children:`No review findings mapped to the selected file.`}):null,xn.length>0?(0,L.jsx)(`div`,{className:`panel-actions`,children:xn.map(e=>ir(e))}):null]})}if(E===`terminal`)return(0,L.jsx)(`div`,{className:`empty-panel`,children:`Terminal moved to the bottom dock. Use the Shell toggle above the prompt.`});if(E===`agents`){let t=e.threads.filter(e=>e.thread.agentNickname||e.thread.agentRole);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`panel-head-row`,children:[(0,L.jsx)(`div`,{className:`panel-hint`,children:`⑂ Multi-agent session`}),(0,L.jsx)(`button`,{className:`abtn yes small`,type:`button`,onClick:()=>z(`spawn_agent("alpha") → started`,`ok`),children:`+ Spawn`})]}),Wn.length===0&&t.length===0?(0,L.jsx)(`div`,{className:`empty-panel`,children:`No subagent activity in this thread yet.`}):null,Wn.map(e=>(0,L.jsxs)(`div`,{className:`agc`,children:[(0,L.jsxs)(`div`,{className:`agh`,children:[(0,L.jsx)(`div`,{className:`agdot`}),(0,L.jsxs)(`span`,{className:`agn`,children:[`⑂ `,e.tool]}),(0,L.jsx)(`span`,{className:`ags`,children:e.status})]}),(0,L.jsx)(`div`,{className:`agt`,children:e.prompt??`Subagent activity`}),e.receiverThreadIds.map(t=>{let n=e.agentsStates[t],r=n?.status===`completed`?100:n?.status===`running`?58:18;return(0,L.jsxs)(`div`,{className:`agent-progress`,children:[(0,L.jsxs)(`div`,{className:`agent-progress-header`,children:[(0,L.jsx)(`span`,{children:t.slice(0,12)}),(0,L.jsx)(`span`,{children:n?.status??`pending`})]}),(0,L.jsx)(`div`,{className:`agprog`,children:(0,L.jsx)(`div`,{className:`agbar`,style:{width:`${r}%`}})}),(0,L.jsx)(`div`,{className:`agent-progress-copy`,children:n?.message??`No update yet.`})]},t)})]},e.id)),t.map(e=>(0,L.jsxs)(`div`,{className:`agc`,children:[(0,L.jsxs)(`div`,{className:`agh`,children:[(0,L.jsx)(`div`,{className:`agdot`}),(0,L.jsxs)(`span`,{className:`agn`,children:[`⑂ `,e.thread.agentNickname??c[e.thread.id]??Vd(e.thread)]}),(0,L.jsx)(`span`,{className:`ags`,children:e.thread.status.type})]}),(0,L.jsx)(`div`,{className:`agt`,children:e.thread.agentRole??`Subagent thread`})]},e.thread.id))]})}return(0,L.jsx)(`div`,{children:(0,L.jsx)(eC,{snapshot:e,activeThreadLabel:d,actions:t,activeTheme:Ot,onOpenSkills:Ar,onOpenTheme:Mr,pushToast:z,selectModel:Vr})})},zi=()=>{if(!Ne)return null;let t=Ne===`mention`&&!!u&&e.directoryCatalogRoot!==(u?.thread.cwd??null),n=Ne===`mention`?t?`Loading files from the current directory…`:`No files found for this query.`:Ne===`skill`?`No skills matched.`:`No commands matched.`;return(0,L.jsx)(`div`,{id:`slashpop`,style:{display:`block`},children:qn.length>0?qn.map((e,t)=>(0,L.jsxs)(`button`,{className:H(`spi`,t===Ie&&`sel`),type:`button`,onMouseDown:t=>{t.preventDefault(),ei(e)},children:[(0,L.jsx)(`span`,{className:`sp-cmd`,children:e.label}),(0,L.jsx)(`span`,{className:`sp-dsc`,children:e.description})]},e.id)):(0,L.jsx)(`div`,{className:`sp-empty`,children:n})})},Bi=nn&&Jn;return nn?(0,L.jsx)(`main`,{className:`workspace-shell connection-loading-shell`,children:(0,L.jsx)(fS,{messages:SA,metaText:Bi?`Restoring ${Hd(d,42)}`:`Connecting to workspace backend`,visibleRangeEnd:Bi?SA.length-1:bA.length-1,visibleRangeStart:Bi?bA.length:0})}):(0,L.jsxs)(`main`,{className:H(`workspace-shell`,yn&&`overlay-open`),children:[(0,L.jsxs)(`header`,{id:`hdr`,children:[(0,L.jsx)(`button`,{className:`hb mbtn`,type:`button`,onClick:Dr,title:`Menu`,children:`☰`}),(0,L.jsxs)(`div`,{className:`logo`,children:[(0,L.jsx)(cS,{alt:``,className:`logo-ico`}),(0,L.jsx)(`span`,{children:`Nomadex`})]}),(0,L.jsx)(`div`,{className:`hsep`}),(0,L.jsx)(`button`,{className:H(`hbadge`,Cd[Sn]),id:`aprbadge`,type:`button`,onClick:()=>void Ur(),title:`Cycle approval mode`,children:Sd[Sn]}),(0,L.jsx)(`button`,{className:`hb`,type:`button`,onClick:()=>ee(!0),title:`Command palette`,children:`⌘`}),(0,L.jsx)(`button`,{className:`hb`,type:`button`,onClick:()=>Er(`agents`),title:`Multi-agent panel`,children:`⑂`}),(0,L.jsx)(`button`,{className:`hb`,type:`button`,onClick:()=>Er(`files`),title:`Files and diff`,children:`📁`}),(0,L.jsx)(`button`,{className:`hb`,type:`button`,onClick:Ar,title:`Skills library`,children:`📋`}),(0,L.jsx)(`button`,{className:`hb`,type:`button`,onClick:()=>Er(`config`),title:`Config and settings`,children:`⚙`}),(0,L.jsxs)(`button`,{className:`htheme`,id:`htheme`,type:`button`,onClick:()=>{ne(!1),k(e=>!e)},title:`Theme picker`,children:[(0,L.jsx)(`span`,{className:`theme-dot`}),(0,L.jsx)(`span`,{className:`theme-label`,children:An.name}),(0,L.jsx)(`span`,{className:`hmodel-arrow`,children:`▾`})]}),(0,L.jsxs)(`button`,{className:`hmodel`,id:`hmodel`,type:`button`,disabled:Dn.length===0,ref:Pt,onClick:()=>{Dn.length!==0&&(k(!1),ne(e=>!e))},title:Dn.length===0?`${En.displayName} uses its own CLI model configuration`:void 0,children:[(0,L.jsx)(`div`,{className:`mdot`}),(0,L.jsx)(`span`,{id:`mlabel`,children:kn}),(0,L.jsx)(`span`,{className:`hmodel-arrow`,children:`▾`})]})]}),(0,L.jsxs)(`div`,{id:`layout`,children:[!p&&b?(0,L.jsx)(`button`,{id:`sbo`,className:`show`,type:`button`,"aria-label":`Close sidebar`,onClick:()=>x(!1)}):null,_n?(0,L.jsxs)(`aside`,{id:`sb`,className:H(!p&&b&&`open`),children:[(0,L.jsx)(`button`,{className:`snew`,type:`button`,onClick:()=>void Lr(),children:`+ New Session`}),(0,L.jsx)(`div`,{className:`shist`,children:[`Today`,`Yesterday`,`Earlier`].map(e=>Tn[e].length>0?(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`sgl`,children:e}),Tn[e].map(e=>(0,L.jsxs)(`button`,{className:H(`si`,e.thread.id===l&&`active`),type:`button`,onClick:()=>wr(e.thread.id),children:[(0,L.jsx)(`span`,{children:e.thread.agentNickname?`⑂`:`💬`}),(0,L.jsx)(`span`,{className:`si-t`,children:c[e.thread.id]??Vd(e.thread)})]},e.thread.id))]},e):null)}),(0,L.jsxs)(`div`,{className:`sbot`,children:[(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>ee(!0),children:[(0,L.jsx)(`span`,{children:`⌘`}),(0,L.jsx)(`span`,{children:`Command palette`}),(0,L.jsx)(`span`,{className:`skbd`,children:`⌘K`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>void Yr(`/review`),children:[(0,L.jsx)(`span`,{children:`🔍`}),(0,L.jsx)(`span`,{children:`/review working tree`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>void Yr(`/fork`),children:[(0,L.jsx)(`span`,{children:`⑂`}),(0,L.jsx)(`span`,{children:`/fork session`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>void Yr(`/compact`),children:[(0,L.jsx)(`span`,{children:`🗜`}),(0,L.jsx)(`span`,{children:`/compact transcript`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:Ar,children:[(0,L.jsx)(`span`,{children:`📋`}),(0,L.jsx)(`span`,{children:`Skills library`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:Mr,children:[(0,L.jsx)(`span`,{children:`◐`}),(0,L.jsx)(`span`,{children:`Theme picker`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>Ai(`/init Generate AGENTS.md scaffold`),children:[(0,L.jsx)(`span`,{children:`📋`}),(0,L.jsx)(`span`,{children:`/init AGENTS.md`})]}),(0,L.jsxs)(`button`,{className:`slink`,type:`button`,onClick:()=>Er(`config`),children:[(0,L.jsx)(`span`,{children:`⚙`}),(0,L.jsx)(`span`,{children:`config.toml`})]})]})]}):null,(0,L.jsxs)(`section`,{id:`main`,className:H(vn&&`covered`),children:[(0,L.jsxs)(`div`,{id:`tabs`,children:[on.map(e=>{let t=s.find(t=>t.thread.id===e),n=t?.thread;return!t||!n?null:(0,L.jsxs)(`button`,{className:H(`tab`,e===l&&`active`),"data-i":e,type:`button`,onClick:()=>Cr(e,`chat`),children:[(0,L.jsx)(`span`,{children:n.agentNickname?`⑂`:`💬`}),(0,L.jsx)(`span`,{children:Hd(c[t.thread.id]??Vd(t.thread),18)}),(0,L.jsx)(`span`,{className:`tab-x`,onClick:t=>{t.stopPropagation(),di(e)},children:`×`})]},e)}),(0,L.jsx)(`button`,{className:`tabadd`,type:`button`,onClick:()=>void Lr(),title:`New session`,children:`+`})]}),i.section===`editor`?(0,L.jsx)(`div`,{id:`editor-page`,children:Pi?(0,L.jsx)(uA,{backLabel:Ii,onBack:Ni,onSave:Fi,preview:Pi,providerId:e.settings.provider,variant:`page`}):(0,L.jsx)(`div`,{className:`empty-panel`,children:`No file selected.`})}):i.section===`review`?(0,L.jsx)(lA,{backLabel:y===`ops`?`Back to Files`:`Back to Chat`,diffEntries:Mn,findings:Bn,onBack:B,onSelectEntry:e=>Or(e,y),selectedEntryId:Je}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{id:`chat`,ref:At,children:[(0,L.jsx)(yS,{activeThread:u,activeThreadLabel:d,activeTurns:ln,existingThreadHistoryPending:Yn,onContext:Mi,onCopy:Ti,onEdit:Ai,onFill:Ai,onFork:Rr,onOpenFile:Ei,onPlan:ki,onRollback:Br,onReview:Di,onSlash:ji,providerId:e.settings.provider,streamVisible:Xt}),(0,L.jsx)(pd,{overlay:pn,pendingApprovalsCount:bn,queuedCount:fn.length}),(0,L.jsx)(`div`,{"aria-hidden":`true`,ref:jt})]}),(0,L.jsxs)(`div`,{id:`ia`,children:[it?(0,L.jsx)(`div`,{className:`chat-jump-row`,children:(0,L.jsx)(`button`,{className:`chat-jump-button`,type:`button`,onClick:ur,children:`↓ Latest`})}):null,we.length>0||De.length>0||Te.length>0?(0,L.jsxs)(`div`,{id:`ctx-row`,children:[we.map(e=>(0,L.jsxs)(`div`,{className:`ctag`,children:[(0,L.jsx)(`span`,{children:`📋`}),(0,L.jsxs)(`span`,{children:[`$`,e.name]}),(0,L.jsx)(`button`,{className:`ctx-x`,type:`button`,onClick:()=>ci(e.id),children:`×`})]},e.id)),De.map(e=>{let t=mf(e.name);return(0,L.jsxs)(`div`,{className:H(`ctag ctag-file`,`file-tone-${t.tone}`),children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`file-chip-preview`,children:(0,L.jsx)(`span`,{className:`file-chip-ext`,children:t.badge})}),(0,L.jsxs)(`span`,{className:`file-chip-copy`,children:[(0,L.jsx)(`span`,{className:`file-chip-title`,children:t.title}),(0,L.jsx)(`span`,{className:`file-chip-meta`,children:e.size})]}),(0,L.jsx)(`button`,{className:`ctx-x`,type:`button`,onClick:()=>li(e.id),children:`×`})]},e.id)}),Te.map(e=>(0,L.jsxs)(`div`,{className:`ctag ctag-image`,children:[(0,L.jsx)(`img`,{alt:e.name,className:`ctag-thumb`,loading:`lazy`,src:e.url}),(0,L.jsx)(`span`,{className:`ctag-label`,children:e.name}),(0,L.jsx)(`button`,{className:`ctx-x`,type:`button`,onClick:()=>Qr(e.id),children:`×`})]},e.id))]}):null,fn.length>0?(0,L.jsx)(oA,{messages:fn,onDelete:e=>l&&xr(l,e),onSteer:ui}):null,mn.length>0?(0,L.jsx)(hS,{entries:mn,onOpenFile:Oi,title:`Changing`,variant:`live`}):null,xn.length>0?(0,L.jsx)(`div`,{className:`question-request-stack`,children:xn.map(e=>ir(e))}):null,(ve||_e)&&u?(0,L.jsxs)(`div`,{className:H(`workspace-terminal-dock`,!_e&&`hidden`),children:[(0,L.jsxs)(`div`,{className:`workspace-terminal-dock-bar`,children:[(0,L.jsx)(`button`,{className:`workspace-terminal-dock-tab active`,type:`button`,children:`Terminal`}),(0,L.jsx)(`button`,{className:`workspace-terminal-dock-close`,onClick:wi,type:`button`,children:`Hide`})]}),(0,L.jsx)(`div`,{className:`workspace-terminal-dock-body`,children:be?(0,L.jsx)(rC,{cwd:u.thread.cwd,onSendInput:(e,n)=>t.sendTerminalInput(u.thread.id,e,n),onStartShell:()=>t.startProjectTerminal(u.thread.id,u.thread.cwd),onTerminate:e=>t.terminateTerminal(u.thread.id,e),terminals:bi}):(0,L.jsx)(`div`,{className:`workspace-terminal-dock-loading`,children:`Opening terminal`})})]}):null,(0,L.jsxs)(`div`,{id:`ib`,className:H(fn.length>0&&`queue-open`),children:[(0,L.jsxs)(`div`,{id:`toolbar`,children:[(0,L.jsxs)(`button`,{className:H(`tbtn`,pe&&`on`),type:`button`,onClick:()=>me(e=>!e),children:[(0,L.jsx)(CA,{name:`auto`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Auto`})]}),(0,L.jsxs)(`button`,{className:H(`tbtn`,he&&`on`),type:`button`,onClick:async()=>{ge(!he)},children:[(0,L.jsx)(CA,{name:`plan`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Plan`})]}),(0,L.jsx)(`div`,{className:`tsep2`}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>{Pe(`mention`),F(``),Le(0),Mt.current?.focus()},children:[(0,L.jsx)(CA,{name:`mention`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Mention`})]}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>It.current?.click(),children:[(0,L.jsx)(CA,{name:`attach`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Files`})]}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>Ft.current?.click(),children:[(0,L.jsx)(CA,{name:`image`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Image`})]}),(0,L.jsxs)(`button`,{className:H(`tbtn`,_e&&`on`),type:`button`,onClick:()=>void(_e?wi():Ci()),children:[(0,L.jsx)(CA,{name:`terminal`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Shell`})]}),(0,L.jsxs)(`button`,{className:H(`tbtn`,e.settings.webSearch&&`on`),type:`button`,onClick:()=>void t.updateSettings({webSearch:!e.settings.webSearch}),children:[(0,L.jsx)(CA,{name:`web`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Web`})]}),(0,L.jsx)(`div`,{className:`tsep2`}),(0,L.jsxs)(`button`,{className:H(`tbtn`,de===`review`&&`on`),type:`button`,onClick:()=>fe(e=>e===`review`?`chat`:`review`),children:[(0,L.jsx)(CA,{name:`review`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Review`})]}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>Er(`agents`),children:[(0,L.jsx)(CA,{name:`agents`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Agents`})]}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>void zr(),children:[(0,L.jsx)(CA,{name:`compact`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Trim`})]}),(0,L.jsxs)(`button`,{className:`tbtn`,type:`button`,onClick:()=>z(`Ctrl+G — opening editor bridge`,``),children:[(0,L.jsx)(CA,{name:`editor`}),(0,L.jsx)(`span`,{className:`tbtn-label`,children:`Editor`})]})]}),(0,L.jsxs)(`div`,{id:`irow`,children:[(0,L.jsx)(sA,{composerMirrorRef:Nt,mentions:Se,onKeyDown:ni,onPaste:ii,onValueChange:$r,placeholder:fi,textareaRef:Mt,value:le},Et),(0,L.jsx)(`button`,{id:`sendbtn`,type:`button`,"aria-label":dn?`Queue message`:`Send message`,onClick:()=>void ti(Mt.current?.value),children:(0,L.jsx)(CA,{name:`send`})}),(0,L.jsx)(`button`,{id:`stopbtn`,style:{display:dn?`flex`:`none`},type:`button`,"aria-label":`Stop current turn`,onClick:()=>void si(),children:(0,L.jsx)(CA,{name:`stop`})})]}),zi(),(0,L.jsx)(`div`,{id:`ifooter`,children:(0,L.jsxs)(`div`,{className:`composer-footer-meta`,children:[(0,L.jsx)(`div`,{className:`composer-shortcuts`,children:(0,L.jsx)(`span`,{className:`composer-hint`,children:`Shift+Enter`})}),(0,L.jsxs)(`div`,{className:`composer-usage-metric`,children:[(0,L.jsx)(`span`,{className:`composer-usage-label`,children:`Context`}),(0,L.jsx)(`span`,{id:`tokcount`,children:pi})]}),(0,L.jsx)(`div`,{className:`composer-limit-list`,children:mi.map(e=>(0,L.jsxs)(`div`,{className:`composer-limit-chip`,children:[(0,L.jsx)(`span`,{className:`composer-limit-name`,children:EA(e.label,e.windowDurationMins)}),(0,L.jsxs)(`span`,{className:`composer-limit-value`,children:[Math.round(e.usedPercent),`%`]})]},e.id))})]})})]})]})]})]}),p||hn?(0,L.jsxs)(`aside`,{id:`rp`,className:H(hn&&`open`),children:[(0,L.jsxs)(`div`,{className:`rph`,children:[(0,L.jsx)(`span`,{className:`rpt`,id:`rp-title`,children:wd[E]}),(0,L.jsx)(`button`,{className:`rpclose`,type:`button`,onClick:kr,children:`×`})]}),(0,L.jsx)(`div`,{className:`rptabs`,id:`rptabs`,children:[`files`,`graph`,`diff`,`agents`,`config`].map(e=>(0,L.jsx)(`button`,{className:H(`rptab`,E===e&&`active`),type:`button`,onClick:()=>{if(e===`diff`){Or(Fn?.id??Mn[0]?.id,i.section===`ops`?`ops`:`chat`);return}D(e)},children:wd[e]},e))}),(0,L.jsx)(`div`,{className:`rpbody`,id:`rpbody`,children:hn?Ri():null})]}):null]}),(0,L.jsxs)(`div`,{id:`statusbar`,children:[(0,L.jsxs)(`div`,{className:`sbi sbi-transport`,children:[(0,L.jsx)(`div`,{className:H(`sbd`,Rd(e.transport.status))}),(0,L.jsx)(`span`,{children:hi})]}),(0,L.jsxs)(`div`,{className:`sbi sbi-branch`,children:[(0,L.jsx)(CA,{name:`branch`}),(0,L.jsx)(`span`,{className:`sb-project sb-fulltext`,children:gi}),(0,L.jsx)(`span`,{className:`sb-divider`,children:`/`}),(0,L.jsx)(`span`,{className:`sb-fulltext`,children:_i})]}),(0,L.jsxs)(`div`,{className:`sbi sbi-model`,id:`sb-model`,children:[(0,L.jsx)(CA,{name:`model`}),(0,L.jsx)(`span`,{children:kn})]}),(0,L.jsxs)(`div`,{className:`sbi sbi-access`,children:[(0,L.jsx)(CA,{name:`shield`}),(0,L.jsx)(`span`,{children:vi})]}),(0,L.jsx)(`div`,{className:`sbi`,id:`sb-st`,children:yi})]}),te&&Dn.length>0?(0,L.jsx)(`div`,{id:`mpicker`,style:{display:`block`,top:`${wt.top}px`,right:`${wt.right}px`,left:`auto`},children:Dn.map((t,n)=>(0,L.jsxs)(`div`,{className:`mpi`,onClick:()=>void Vr(t.id),onKeyDown:()=>void 0,role:`button`,tabIndex:0,children:[(0,L.jsxs)(`div`,{className:`mpi-n`,children:[t.displayName,t.id===e.settings.model?(0,L.jsxs)(L.Fragment,{children:[` `,`✓ `,(0,L.jsx)(`span`,{className:`model-rec`,children:`active`})]}):null]}),(0,L.jsx)(`div`,{className:`mpi-d`,children:t.description}),n<Dn.length-1?(0,L.jsx)(`div`,{className:`mpsep`}):null]},t.id))}):null,re?(0,L.jsx)($S,{activeTheme:Ot,onClose:Nr,onSelect:Hr,themes:Ed}):null,A?(0,L.jsx)(aA,{activePath:j,breadcrumbs:Un,busy:se,entries:Vn,loading:e.directoryCatalogRoot!==j,onClose:()=>ie(!1),onNavigate:M,onPick:e=>{M(e),Ir(e)},parentPath:Hn}):null,ae?(0,L.jsx)(QS,{actions:t,onClose:jr,pushToast:z,snapshot:e}):null,O?(0,L.jsx)(`div`,{id:`cmo`,className:`show`,onClick:e=>e.target===e.currentTarget&&ee(!1),children:(0,L.jsxs)(`div`,{id:`cmp`,children:[(0,L.jsxs)(`div`,{className:`cmr`,children:[(0,L.jsx)(`span`,{className:`cm-ico`,children:`⌘`}),(0,L.jsx)(`input`,{id:`cminput`,autoFocus:!0,placeholder:`Search commands, slash commands, models…`,value:je,onChange:e=>Me(e.target.value),onKeyDown:e=>{if(e.key===`Escape`&&ee(!1),e.key===`Enter`){e.preventDefault();let t=Xr[0]?.items[0];t&&(ee(!1),Zr(t.command))}}})]}),(0,L.jsx)(`div`,{className:`cmlist`,id:`cmlist`,children:Xr.length===0?(0,L.jsx)(`div`,{className:`empty-command`,children:`No results`}):Xr.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`cmgl`,children:e.label}),e.items.map(t=>(0,L.jsxs)(`button`,{className:`cmi`,type:`button`,onClick:()=>{ee(!1),Zr(t.command)},children:[(0,L.jsx)(`span`,{children:t.icon}),(0,L.jsx)(`span`,{className:`cmi-nm`,children:t.name}),t.key?(0,L.jsx)(`span`,{className:`cmkbd`,children:t.key}):null]},`${e.label}-${t.name}`))]},e.label))})]})}):null,He?(0,L.jsxs)(`div`,{id:`ctxmenu`,className:`show`,style:{left:`${He.x}px`,top:`${He.y}px`},children:[(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{let t=He.item;t?.type===`agentMessage`&&OA(t.text).then(()=>z(`Copied`,`ok`)),t?.type===`userMessage`&&OA(Jd(t,e.settings.provider)).then(()=>z(`Copied`,`ok`)),Ue(null)},children:`📋 Copy message`}),(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{let t=He.item;t?.type===`agentMessage`&&Ai(t.text),t?.type===`userMessage`&&Ai(Jd(t,e.settings.provider)),Ue(null)},children:`✏ Edit & resend`}),(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{Gn&&Ai(Gn.text),Ue(null)},children:`🔄 Regenerate`}),(0,L.jsx)(`div`,{className:`ctxs`}),(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{Rr(),Ue(null)},children:`⑂ /fork from here`}),(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{Yr(`/plan`),Ue(null)},children:`📋 /plan from here`}),(0,L.jsx)(`button`,{className:`ctxi`,type:`button`,onClick:()=>{Pe(`mention`),F(``),Ue(null)},children:`📎 /mention file`}),(0,L.jsx)(`div`,{className:`ctxs`}),(0,L.jsx)(`button`,{className:`ctxi danger`,type:`button`,onClick:()=>{z(`Deleted`,``),Ue(null)},children:`🗑 Delete`})]}):null,(0,L.jsx)(`div`,{id:`toasts`,children:Be.map(e=>(0,L.jsx)(`div`,{className:H(`toast`,e.tone),children:e.message},e.id))}),(0,L.jsx)(`input`,{ref:It,className:`hidden-input`,type:`file`,multiple:!0,onChange:oi}),(0,L.jsx)(`input`,{ref:Ft,className:`hidden-input`,type:`file`,accept:`image/*`,multiple:!0,onChange:ai})]})}function IA(){return(0,L.jsx)(NA,{children:(0,L.jsx)(V,{})})}var LA=Qa({component:IA}),RA=Xa({getParentRoute:()=>LA,path:`/`,component:PA}),zA=Xa({getParentRoute:()=>LA,path:`/threads`,component:PA}),BA=Xa({getParentRoute:()=>LA,path:`/thread/$threadId`,component:PA}),VA=Xa({getParentRoute:()=>LA,path:`/threads/$threadId`,component:PA}),HA=Xa({getParentRoute:()=>LA,path:`/threads/$threadId/$section`,component:PA}),UA=go({routeTree:LA.addChildren([RA,zA,BA,VA,HA])}),WA=new Gt({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}}),GA=document.getElementById(`root`);if(!GA)throw Error(`Root element not found.`);(0,bo.createRoot)(GA).render((0,L.jsx)(Yt,{client:WA,children:(0,L.jsx)(yo,{router:UA})}));export{Ie as a,tO as i,WE as n,GE as r,VE as t};
|